| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 var __create = Object.create; 2 var __defProp = Object.defineProperty; 3 var __getOwnPropDesc = Object.getOwnPropertyDescriptor; 4 var __getOwnPropNames = Object.getOwnPropertyNames; 5 var __getProtoOf = Object.getPrototypeOf; 6 var __hasOwnProp = Object.prototype.hasOwnProperty; 7 var __commonJS = (cb, mod) => function __require() { 8 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; 9 }; 10 var __export = (target, all) => { 11 for (var name in all) 12 __defProp(target, name, { get: all[name], enumerable: true }); 13 }; 14 var __copyProps = (to, from, except, desc) => { 15 if (from && typeof from === "object" || typeof from === "function") { 16 for (let key of __getOwnPropNames(from)) 17 if (!__hasOwnProp.call(to, key) && key !== except) 18 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); 19 } 20 return to; 21 }; 22 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( 23 // If the importer is in node compatibility mode or this is not an ESM 24 // file that has been converted to a CommonJS file using a Babel- 25 // compatible transform (i.e. "__esModule" has not been set), then set 26 // "default" to the CommonJS "module.exports" for node compatibility. 27 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, 28 mod 29 )); 30 31 // package-external:@wordpress/i18n 32 var require_i18n = __commonJS({ 33 "package-external:@wordpress/i18n"(exports, module) { 34 module.exports = window.wp.i18n; 35 } 36 }); 37 38 // package-external:@wordpress/element 39 var require_element = __commonJS({ 40 "package-external:@wordpress/element"(exports, module) { 41 module.exports = window.wp.element; 42 } 43 }); 44 45 // vendor-external:react 46 var require_react = __commonJS({ 47 "vendor-external:react"(exports, module) { 48 module.exports = window.React; 49 } 50 }); 51 52 // vendor-external:react/jsx-runtime 53 var require_jsx_runtime = __commonJS({ 54 "vendor-external:react/jsx-runtime"(exports, module) { 55 module.exports = window.ReactJSXRuntime; 56 } 57 }); 58 59 // vendor-external:react-dom 60 var require_react_dom = __commonJS({ 61 "vendor-external:react-dom"(exports, module) { 62 module.exports = window.ReactDOM; 63 } 64 }); 65 66 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js 67 var require_use_sync_external_store_shim_development = __commonJS({ 68 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports) { 69 "use strict"; 70 (function() { 71 function is(x2, y2) { 72 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2; 73 } 74 function useSyncExternalStore$2(subscribe2, getSnapshot) { 75 didWarnOld18Alpha || void 0 === React84.startTransition || (didWarnOld18Alpha = true, console.error( 76 "You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release." 77 )); 78 var value = getSnapshot(); 79 if (!didWarnUncachedGetSnapshot) { 80 var cachedValue = getSnapshot(); 81 objectIs(value, cachedValue) || (console.error( 82 "The result of getSnapshot should be cached to avoid an infinite loop" 83 ), didWarnUncachedGetSnapshot = true); 84 } 85 cachedValue = useState56({ 86 inst: { value, getSnapshot } 87 }); 88 var inst = cachedValue[0].inst, forceUpdate = cachedValue[1]; 89 useLayoutEffect5( 90 function() { 91 inst.value = value; 92 inst.getSnapshot = getSnapshot; 93 checkIfSnapshotChanged(inst) && forceUpdate({ inst }); 94 }, 95 [subscribe2, value, getSnapshot] 96 ); 97 useEffect48( 98 function() { 99 checkIfSnapshotChanged(inst) && forceUpdate({ inst }); 100 return subscribe2(function() { 101 checkIfSnapshotChanged(inst) && forceUpdate({ inst }); 102 }); 103 }, 104 [subscribe2] 105 ); 106 useDebugValue2(value); 107 return value; 108 } 109 function checkIfSnapshotChanged(inst) { 110 var latestGetSnapshot = inst.getSnapshot; 111 inst = inst.value; 112 try { 113 var nextValue = latestGetSnapshot(); 114 return !objectIs(inst, nextValue); 115 } catch (error2) { 116 return true; 117 } 118 } 119 function useSyncExternalStore$1(subscribe2, getSnapshot) { 120 return getSnapshot(); 121 } 122 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error()); 123 var React84 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is, useState56 = React84.useState, useEffect48 = React84.useEffect, useLayoutEffect5 = React84.useLayoutEffect, useDebugValue2 = React84.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2; 124 exports.useSyncExternalStore = void 0 !== React84.useSyncExternalStore ? React84.useSyncExternalStore : shim; 125 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error()); 126 })(); 127 } 128 }); 129 130 // node_modules/use-sync-external-store/shim/index.js 131 var require_shim = __commonJS({ 132 "node_modules/use-sync-external-store/shim/index.js"(exports, module) { 133 "use strict"; 134 if (false) { 135 module.exports = null; 136 } else { 137 module.exports = require_use_sync_external_store_shim_development(); 138 } 139 } 140 }); 141 142 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js 143 var require_with_selector_development = __commonJS({ 144 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js"(exports) { 145 "use strict"; 146 (function() { 147 function is(x2, y2) { 148 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2; 149 } 150 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error()); 151 var React84 = require_react(), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore3 = shim.useSyncExternalStore, useRef67 = React84.useRef, useEffect48 = React84.useEffect, useMemo71 = React84.useMemo, useDebugValue2 = React84.useDebugValue; 152 exports.useSyncExternalStoreWithSelector = function(subscribe2, getSnapshot, getServerSnapshot, selector2, isEqual) { 153 var instRef = useRef67(null); 154 if (null === instRef.current) { 155 var inst = { hasValue: false, value: null }; 156 instRef.current = inst; 157 } else inst = instRef.current; 158 instRef = useMemo71( 159 function() { 160 function memoizedSelector(nextSnapshot) { 161 if (!hasMemo) { 162 hasMemo = true; 163 memoizedSnapshot = nextSnapshot; 164 nextSnapshot = selector2(nextSnapshot); 165 if (void 0 !== isEqual && inst.hasValue) { 166 var currentSelection = inst.value; 167 if (isEqual(currentSelection, nextSnapshot)) 168 return memoizedSelection = currentSelection; 169 } 170 return memoizedSelection = nextSnapshot; 171 } 172 currentSelection = memoizedSelection; 173 if (objectIs(memoizedSnapshot, nextSnapshot)) 174 return currentSelection; 175 var nextSelection = selector2(nextSnapshot); 176 if (void 0 !== isEqual && isEqual(currentSelection, nextSelection)) 177 return memoizedSnapshot = nextSnapshot, currentSelection; 178 memoizedSnapshot = nextSnapshot; 179 return memoizedSelection = nextSelection; 180 } 181 var hasMemo = false, memoizedSnapshot, memoizedSelection, maybeGetServerSnapshot = void 0 === getServerSnapshot ? null : getServerSnapshot; 182 return [ 183 function() { 184 return memoizedSelector(getSnapshot()); 185 }, 186 null === maybeGetServerSnapshot ? void 0 : function() { 187 return memoizedSelector(maybeGetServerSnapshot()); 188 } 189 ]; 190 }, 191 [getSnapshot, getServerSnapshot, selector2, isEqual] 192 ); 193 var value = useSyncExternalStore3(subscribe2, instRef[0], instRef[1]); 194 useEffect48( 195 function() { 196 inst.hasValue = true; 197 inst.value = value; 198 }, 199 [value] 200 ); 201 useDebugValue2(value); 202 return value; 203 }; 204 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error()); 205 })(); 206 } 207 }); 208 209 // node_modules/use-sync-external-store/shim/with-selector.js 210 var require_with_selector = __commonJS({ 211 "node_modules/use-sync-external-store/shim/with-selector.js"(exports, module) { 212 "use strict"; 213 if (false) { 214 module.exports = null; 215 } else { 216 module.exports = require_with_selector_development(); 217 } 218 } 219 }); 220 221 // package-external:@wordpress/primitives 222 var require_primitives = __commonJS({ 223 "package-external:@wordpress/primitives"(exports, module) { 224 module.exports = window.wp.primitives; 225 } 226 }); 227 228 // package-external:@wordpress/compose 229 var require_compose = __commonJS({ 230 "package-external:@wordpress/compose"(exports, module) { 231 module.exports = window.wp.compose; 232 } 233 }); 234 235 // package-external:@wordpress/theme 236 var require_theme = __commonJS({ 237 "package-external:@wordpress/theme"(exports, module) { 238 module.exports = window.wp.theme; 239 } 240 }); 241 242 // package-external:@wordpress/private-apis 243 var require_private_apis = __commonJS({ 244 "package-external:@wordpress/private-apis"(exports, module) { 245 module.exports = window.wp.privateApis; 246 } 247 }); 248 249 // package-external:@wordpress/components 250 var require_components = __commonJS({ 251 "package-external:@wordpress/components"(exports, module) { 252 module.exports = window.wp.components; 253 } 254 }); 255 256 // package-external:@wordpress/keycodes 257 var require_keycodes = __commonJS({ 258 "package-external:@wordpress/keycodes"(exports, module) { 259 module.exports = window.wp.keycodes; 260 } 261 }); 262 263 // package-external:@wordpress/data 264 var require_data = __commonJS({ 265 "package-external:@wordpress/data"(exports, module) { 266 module.exports = window.wp.data; 267 } 268 }); 269 270 // node_modules/remove-accents/index.js 271 var require_remove_accents = __commonJS({ 272 "node_modules/remove-accents/index.js"(exports, module) { 273 var characterMap = { 274 "À": "A", 275 "Á": "A", 276 "Â": "A", 277 "Ã": "A", 278 "Ä": "A", 279 "Å": "A", 280 "Ấ": "A", 281 "Ắ": "A", 282 "Ẳ": "A", 283 "Ẵ": "A", 284 "Ặ": "A", 285 "Æ": "AE", 286 "Ầ": "A", 287 "Ằ": "A", 288 "Ȃ": "A", 289 "Ả": "A", 290 "Ạ": "A", 291 "Ẩ": "A", 292 "Ẫ": "A", 293 "Ậ": "A", 294 "Ç": "C", 295 "Ḉ": "C", 296 "È": "E", 297 "É": "E", 298 "Ê": "E", 299 "Ë": "E", 300 "Ế": "E", 301 "Ḗ": "E", 302 "Ề": "E", 303 "Ḕ": "E", 304 "Ḝ": "E", 305 "Ȇ": "E", 306 "Ẻ": "E", 307 "Ẽ": "E", 308 "Ẹ": "E", 309 "Ể": "E", 310 "Ễ": "E", 311 "Ệ": "E", 312 "Ì": "I", 313 "Í": "I", 314 "Î": "I", 315 "Ï": "I", 316 "Ḯ": "I", 317 "Ȋ": "I", 318 "Ỉ": "I", 319 "Ị": "I", 320 "Ð": "D", 321 "Ñ": "N", 322 "Ò": "O", 323 "Ó": "O", 324 "Ô": "O", 325 "Õ": "O", 326 "Ö": "O", 327 "Ø": "O", 328 "Ố": "O", 329 "Ṍ": "O", 330 "Ṓ": "O", 331 "Ȏ": "O", 332 "Ỏ": "O", 333 "Ọ": "O", 334 "Ổ": "O", 335 "Ỗ": "O", 336 "Ộ": "O", 337 "Ờ": "O", 338 "Ở": "O", 339 "Ỡ": "O", 340 "Ớ": "O", 341 "Ợ": "O", 342 "Ù": "U", 343 "Ú": "U", 344 "Û": "U", 345 "Ü": "U", 346 "Ủ": "U", 347 "Ụ": "U", 348 "Ử": "U", 349 "Ữ": "U", 350 "Ự": "U", 351 "Ý": "Y", 352 "à": "a", 353 "á": "a", 354 "â": "a", 355 "ã": "a", 356 "ä": "a", 357 "å": "a", 358 "ấ": "a", 359 "ắ": "a", 360 "ẳ": "a", 361 "ẵ": "a", 362 "ặ": "a", 363 "æ": "ae", 364 "ầ": "a", 365 "ằ": "a", 366 "ȃ": "a", 367 "ả": "a", 368 "ạ": "a", 369 "ẩ": "a", 370 "ẫ": "a", 371 "ậ": "a", 372 "ç": "c", 373 "ḉ": "c", 374 "è": "e", 375 "é": "e", 376 "ê": "e", 377 "ë": "e", 378 "ế": "e", 379 "ḗ": "e", 380 "ề": "e", 381 "ḕ": "e", 382 "ḝ": "e", 383 "ȇ": "e", 384 "ẻ": "e", 385 "ẽ": "e", 386 "ẹ": "e", 387 "ể": "e", 388 "ễ": "e", 389 "ệ": "e", 390 "ì": "i", 391 "í": "i", 392 "î": "i", 393 "ï": "i", 394 "ḯ": "i", 395 "ȋ": "i", 396 "ỉ": "i", 397 "ị": "i", 398 "ð": "d", 399 "ñ": "n", 400 "ò": "o", 401 "ó": "o", 402 "ô": "o", 403 "õ": "o", 404 "ö": "o", 405 "ø": "o", 406 "ố": "o", 407 "ṍ": "o", 408 "ṓ": "o", 409 "ȏ": "o", 410 "ỏ": "o", 411 "ọ": "o", 412 "ổ": "o", 413 "ỗ": "o", 414 "ộ": "o", 415 "ờ": "o", 416 "ở": "o", 417 "ỡ": "o", 418 "ớ": "o", 419 "ợ": "o", 420 "ù": "u", 421 "ú": "u", 422 "û": "u", 423 "ü": "u", 424 "ủ": "u", 425 "ụ": "u", 426 "ử": "u", 427 "ữ": "u", 428 "ự": "u", 429 "ý": "y", 430 "ÿ": "y", 431 "Ā": "A", 432 "ā": "a", 433 "Ă": "A", 434 "ă": "a", 435 "Ą": "A", 436 "ą": "a", 437 "Ć": "C", 438 "ć": "c", 439 "Ĉ": "C", 440 "ĉ": "c", 441 "Ċ": "C", 442 "ċ": "c", 443 "Č": "C", 444 "č": "c", 445 "C̆": "C", 446 "c̆": "c", 447 "Ď": "D", 448 "ď": "d", 449 "Đ": "D", 450 "đ": "d", 451 "Ē": "E", 452 "ē": "e", 453 "Ĕ": "E", 454 "ĕ": "e", 455 "Ė": "E", 456 "ė": "e", 457 "Ę": "E", 458 "ę": "e", 459 "Ě": "E", 460 "ě": "e", 461 "Ĝ": "G", 462 "Ǵ": "G", 463 "ĝ": "g", 464 "ǵ": "g", 465 "Ğ": "G", 466 "ğ": "g", 467 "Ġ": "G", 468 "ġ": "g", 469 "Ģ": "G", 470 "ģ": "g", 471 "Ĥ": "H", 472 "ĥ": "h", 473 "Ħ": "H", 474 "ħ": "h", 475 "Ḫ": "H", 476 "ḫ": "h", 477 "Ĩ": "I", 478 "ĩ": "i", 479 "Ī": "I", 480 "ī": "i", 481 "Ĭ": "I", 482 "ĭ": "i", 483 "Į": "I", 484 "į": "i", 485 "İ": "I", 486 "ı": "i", 487 "IJ": "IJ", 488 "ij": "ij", 489 "Ĵ": "J", 490 "ĵ": "j", 491 "Ķ": "K", 492 "ķ": "k", 493 "Ḱ": "K", 494 "ḱ": "k", 495 "K̆": "K", 496 "k̆": "k", 497 "Ĺ": "L", 498 "ĺ": "l", 499 "Ļ": "L", 500 "ļ": "l", 501 "Ľ": "L", 502 "ľ": "l", 503 "Ŀ": "L", 504 "ŀ": "l", 505 "Ł": "l", 506 "ł": "l", 507 "Ḿ": "M", 508 "ḿ": "m", 509 "M̆": "M", 510 "m̆": "m", 511 "Ń": "N", 512 "ń": "n", 513 "Ņ": "N", 514 "ņ": "n", 515 "Ň": "N", 516 "ň": "n", 517 "ʼn": "n", 518 "N̆": "N", 519 "n̆": "n", 520 "Ō": "O", 521 "ō": "o", 522 "Ŏ": "O", 523 "ŏ": "o", 524 "Ő": "O", 525 "ő": "o", 526 "Œ": "OE", 527 "œ": "oe", 528 "P̆": "P", 529 "p̆": "p", 530 "Ŕ": "R", 531 "ŕ": "r", 532 "Ŗ": "R", 533 "ŗ": "r", 534 "Ř": "R", 535 "ř": "r", 536 "R̆": "R", 537 "r̆": "r", 538 "Ȓ": "R", 539 "ȓ": "r", 540 "Ś": "S", 541 "ś": "s", 542 "Ŝ": "S", 543 "ŝ": "s", 544 "Ş": "S", 545 "Ș": "S", 546 "ș": "s", 547 "ş": "s", 548 "Š": "S", 549 "š": "s", 550 "Ţ": "T", 551 "ţ": "t", 552 "ț": "t", 553 "Ț": "T", 554 "Ť": "T", 555 "ť": "t", 556 "Ŧ": "T", 557 "ŧ": "t", 558 "T̆": "T", 559 "t̆": "t", 560 "Ũ": "U", 561 "ũ": "u", 562 "Ū": "U", 563 "ū": "u", 564 "Ŭ": "U", 565 "ŭ": "u", 566 "Ů": "U", 567 "ů": "u", 568 "Ű": "U", 569 "ű": "u", 570 "Ų": "U", 571 "ų": "u", 572 "Ȗ": "U", 573 "ȗ": "u", 574 "V̆": "V", 575 "v̆": "v", 576 "Ŵ": "W", 577 "ŵ": "w", 578 "Ẃ": "W", 579 "ẃ": "w", 580 "X̆": "X", 581 "x̆": "x", 582 "Ŷ": "Y", 583 "ŷ": "y", 584 "Ÿ": "Y", 585 "Y̆": "Y", 586 "y̆": "y", 587 "Ź": "Z", 588 "ź": "z", 589 "Ż": "Z", 590 "ż": "z", 591 "Ž": "Z", 592 "ž": "z", 593 "ſ": "s", 594 "ƒ": "f", 595 "Ơ": "O", 596 "ơ": "o", 597 "Ư": "U", 598 "ư": "u", 599 "Ǎ": "A", 600 "ǎ": "a", 601 "Ǐ": "I", 602 "ǐ": "i", 603 "Ǒ": "O", 604 "ǒ": "o", 605 "Ǔ": "U", 606 "ǔ": "u", 607 "Ǖ": "U", 608 "ǖ": "u", 609 "Ǘ": "U", 610 "ǘ": "u", 611 "Ǚ": "U", 612 "ǚ": "u", 613 "Ǜ": "U", 614 "ǜ": "u", 615 "Ứ": "U", 616 "ứ": "u", 617 "Ṹ": "U", 618 "ṹ": "u", 619 "Ǻ": "A", 620 "ǻ": "a", 621 "Ǽ": "AE", 622 "ǽ": "ae", 623 "Ǿ": "O", 624 "ǿ": "o", 625 "Þ": "TH", 626 "þ": "th", 627 "Ṕ": "P", 628 "ṕ": "p", 629 "Ṥ": "S", 630 "ṥ": "s", 631 "X́": "X", 632 "x́": "x", 633 "Ѓ": "Г", 634 "ѓ": "г", 635 "Ќ": "К", 636 "ќ": "к", 637 "A̋": "A", 638 "a̋": "a", 639 "E̋": "E", 640 "e̋": "e", 641 "I̋": "I", 642 "i̋": "i", 643 "Ǹ": "N", 644 "ǹ": "n", 645 "Ồ": "O", 646 "ồ": "o", 647 "Ṑ": "O", 648 "ṑ": "o", 649 "Ừ": "U", 650 "ừ": "u", 651 "Ẁ": "W", 652 "ẁ": "w", 653 "Ỳ": "Y", 654 "ỳ": "y", 655 "Ȁ": "A", 656 "ȁ": "a", 657 "Ȅ": "E", 658 "ȅ": "e", 659 "Ȉ": "I", 660 "ȉ": "i", 661 "Ȍ": "O", 662 "ȍ": "o", 663 "Ȑ": "R", 664 "ȑ": "r", 665 "Ȕ": "U", 666 "ȕ": "u", 667 "B̌": "B", 668 "b̌": "b", 669 "Č̣": "C", 670 "č̣": "c", 671 "Ê̌": "E", 672 "ê̌": "e", 673 "F̌": "F", 674 "f̌": "f", 675 "Ǧ": "G", 676 "ǧ": "g", 677 "Ȟ": "H", 678 "ȟ": "h", 679 "J̌": "J", 680 "ǰ": "j", 681 "Ǩ": "K", 682 "ǩ": "k", 683 "M̌": "M", 684 "m̌": "m", 685 "P̌": "P", 686 "p̌": "p", 687 "Q̌": "Q", 688 "q̌": "q", 689 "Ř̩": "R", 690 "ř̩": "r", 691 "Ṧ": "S", 692 "ṧ": "s", 693 "V̌": "V", 694 "v̌": "v", 695 "W̌": "W", 696 "w̌": "w", 697 "X̌": "X", 698 "x̌": "x", 699 "Y̌": "Y", 700 "y̌": "y", 701 "A̧": "A", 702 "a̧": "a", 703 "B̧": "B", 704 "b̧": "b", 705 "Ḑ": "D", 706 "ḑ": "d", 707 "Ȩ": "E", 708 "ȩ": "e", 709 "Ɛ̧": "E", 710 "ɛ̧": "e", 711 "Ḩ": "H", 712 "ḩ": "h", 713 "I̧": "I", 714 "i̧": "i", 715 "Ɨ̧": "I", 716 "ɨ̧": "i", 717 "M̧": "M", 718 "m̧": "m", 719 "O̧": "O", 720 "o̧": "o", 721 "Q̧": "Q", 722 "q̧": "q", 723 "U̧": "U", 724 "u̧": "u", 725 "X̧": "X", 726 "x̧": "x", 727 "Z̧": "Z", 728 "z̧": "z", 729 "й": "и", 730 "Й": "И", 731 "ё": "е", 732 "Ё": "Е" 733 }; 734 var chars = Object.keys(characterMap).join("|"); 735 var allAccents = new RegExp(chars, "g"); 736 var firstAccent = new RegExp(chars, ""); 737 function matcher(match2) { 738 return characterMap[match2]; 739 } 740 var removeAccents2 = function(string) { 741 return string.replace(allAccents, matcher); 742 }; 743 var hasAccents = function(string) { 744 return !!string.match(firstAccent); 745 }; 746 module.exports = removeAccents2; 747 module.exports.has = hasAccents; 748 module.exports.remove = removeAccents2; 749 } 750 }); 751 752 // node_modules/fast-deep-equal/es6/index.js 753 var require_es6 = __commonJS({ 754 "node_modules/fast-deep-equal/es6/index.js"(exports, module) { 755 "use strict"; 756 module.exports = function equal(a2, b2) { 757 if (a2 === b2) return true; 758 if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") { 759 if (a2.constructor !== b2.constructor) return false; 760 var length, i2, keys; 761 if (Array.isArray(a2)) { 762 length = a2.length; 763 if (length != b2.length) return false; 764 for (i2 = length; i2-- !== 0; ) 765 if (!equal(a2[i2], b2[i2])) return false; 766 return true; 767 } 768 if (a2 instanceof Map && b2 instanceof Map) { 769 if (a2.size !== b2.size) return false; 770 for (i2 of a2.entries()) 771 if (!b2.has(i2[0])) return false; 772 for (i2 of a2.entries()) 773 if (!equal(i2[1], b2.get(i2[0]))) return false; 774 return true; 775 } 776 if (a2 instanceof Set && b2 instanceof Set) { 777 if (a2.size !== b2.size) return false; 778 for (i2 of a2.entries()) 779 if (!b2.has(i2[0])) return false; 780 return true; 781 } 782 if (ArrayBuffer.isView(a2) && ArrayBuffer.isView(b2)) { 783 length = a2.length; 784 if (length != b2.length) return false; 785 for (i2 = length; i2-- !== 0; ) 786 if (a2[i2] !== b2[i2]) return false; 787 return true; 788 } 789 if (a2.constructor === RegExp) return a2.source === b2.source && a2.flags === b2.flags; 790 if (a2.valueOf !== Object.prototype.valueOf) return a2.valueOf() === b2.valueOf(); 791 if (a2.toString !== Object.prototype.toString) return a2.toString() === b2.toString(); 792 keys = Object.keys(a2); 793 length = keys.length; 794 if (length !== Object.keys(b2).length) return false; 795 for (i2 = length; i2-- !== 0; ) 796 if (!Object.prototype.hasOwnProperty.call(b2, keys[i2])) return false; 797 for (i2 = length; i2-- !== 0; ) { 798 var key = keys[i2]; 799 if (!equal(a2[key], b2[key])) return false; 800 } 801 return true; 802 } 803 return a2 !== a2 && b2 !== b2; 804 }; 805 } 806 }); 807 808 // package-external:@wordpress/date 809 var require_date = __commonJS({ 810 "package-external:@wordpress/date"(exports, module) { 811 module.exports = window.wp.date; 812 } 813 }); 814 815 // package-external:@wordpress/warning 816 var require_warning = __commonJS({ 817 "package-external:@wordpress/warning"(exports, module) { 818 module.exports = window.wp.warning; 819 } 820 }); 821 822 // package-external:@wordpress/rich-text 823 var require_rich_text = __commonJS({ 824 "package-external:@wordpress/rich-text"(exports, module) { 825 module.exports = window.wp.richText; 826 } 827 }); 828 829 // node_modules/deepmerge/dist/cjs.js 830 var require_cjs = __commonJS({ 831 "node_modules/deepmerge/dist/cjs.js"(exports, module) { 832 "use strict"; 833 var isMergeableObject = function isMergeableObject2(value) { 834 return isNonNullObject(value) && !isSpecial(value); 835 }; 836 function isNonNullObject(value) { 837 return !!value && typeof value === "object"; 838 } 839 function isSpecial(value) { 840 var stringValue = Object.prototype.toString.call(value); 841 return stringValue === "[object RegExp]" || stringValue === "[object Date]" || isReactElement(value); 842 } 843 var canUseSymbol = typeof Symbol === "function" && Symbol.for; 844 var REACT_ELEMENT_TYPE = canUseSymbol ? /* @__PURE__ */ Symbol.for("react.element") : 60103; 845 function isReactElement(value) { 846 return value.$$typeof === REACT_ELEMENT_TYPE; 847 } 848 function emptyTarget(val) { 849 return Array.isArray(val) ? [] : {}; 850 } 851 function cloneUnlessOtherwiseSpecified(value, options) { 852 return options.clone !== false && options.isMergeableObject(value) ? deepmerge(emptyTarget(value), value, options) : value; 853 } 854 function defaultArrayMerge(target, source, options) { 855 return target.concat(source).map(function(element) { 856 return cloneUnlessOtherwiseSpecified(element, options); 857 }); 858 } 859 function getMergeFunction(key, options) { 860 if (!options.customMerge) { 861 return deepmerge; 862 } 863 var customMerge = options.customMerge(key); 864 return typeof customMerge === "function" ? customMerge : deepmerge; 865 } 866 function getEnumerableOwnPropertySymbols(target) { 867 return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(target).filter(function(symbol3) { 868 return Object.propertyIsEnumerable.call(target, symbol3); 869 }) : []; 870 } 871 function getKeys2(target) { 872 return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target)); 873 } 874 function propertyIsOnObject(object, property) { 875 try { 876 return property in object; 877 } catch (_) { 878 return false; 879 } 880 } 881 function propertyIsUnsafe(target, key) { 882 return propertyIsOnObject(target, key) && !(Object.hasOwnProperty.call(target, key) && Object.propertyIsEnumerable.call(target, key)); 883 } 884 function mergeObject(target, source, options) { 885 var destination = {}; 886 if (options.isMergeableObject(target)) { 887 getKeys2(target).forEach(function(key) { 888 destination[key] = cloneUnlessOtherwiseSpecified(target[key], options); 889 }); 890 } 891 getKeys2(source).forEach(function(key) { 892 if (propertyIsUnsafe(target, key)) { 893 return; 894 } 895 if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) { 896 destination[key] = getMergeFunction(key, options)(target[key], source[key], options); 897 } else { 898 destination[key] = cloneUnlessOtherwiseSpecified(source[key], options); 899 } 900 }); 901 return destination; 902 } 903 function deepmerge(target, source, options) { 904 options = options || {}; 905 options.arrayMerge = options.arrayMerge || defaultArrayMerge; 906 options.isMergeableObject = options.isMergeableObject || isMergeableObject; 907 options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified; 908 var sourceIsArray = Array.isArray(source); 909 var targetIsArray = Array.isArray(target); 910 var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray; 911 if (!sourceAndTargetTypesMatch) { 912 return cloneUnlessOtherwiseSpecified(source, options); 913 } else if (sourceIsArray) { 914 return options.arrayMerge(target, source, options); 915 } else { 916 return mergeObject(target, source, options); 917 } 918 } 919 deepmerge.all = function deepmergeAll(array, options) { 920 if (!Array.isArray(array)) { 921 throw new Error("first argument should be an array"); 922 } 923 return array.reduce(function(prev, next) { 924 return deepmerge(prev, next, options); 925 }, {}); 926 }; 927 var deepmerge_1 = deepmerge; 928 module.exports = deepmerge_1; 929 } 930 }); 931 932 // package-external:@wordpress/core-data 933 var require_core_data = __commonJS({ 934 "package-external:@wordpress/core-data"(exports, module) { 935 module.exports = window.wp.coreData; 936 } 937 }); 938 939 // package-external:@wordpress/preferences 940 var require_preferences = __commonJS({ 941 "package-external:@wordpress/preferences"(exports, module) { 942 module.exports = window.wp.preferences; 943 } 944 }); 945 946 // package-external:@wordpress/notices 947 var require_notices = __commonJS({ 948 "package-external:@wordpress/notices"(exports, module) { 949 module.exports = window.wp.notices; 950 } 951 }); 952 953 // package-external:@wordpress/is-shallow-equal 954 var require_is_shallow_equal = __commonJS({ 955 "package-external:@wordpress/is-shallow-equal"(exports, module) { 956 module.exports = window.wp.isShallowEqual; 957 } 958 }); 959 960 // package-external:@wordpress/url 961 var require_url = __commonJS({ 962 "package-external:@wordpress/url"(exports, module) { 963 module.exports = window.wp.url; 964 } 965 }); 966 967 // packages/admin-ui/build-module/breadcrumbs/index.mjs 968 var import_i18n4 = __toESM(require_i18n(), 1); 969 import { Link as RouterLink } from "@wordpress/route"; 970 971 // node_modules/clsx/dist/clsx.mjs 972 function r(e2) { 973 var t2, f2, n2 = ""; 974 if ("string" == typeof e2 || "number" == typeof e2) n2 += e2; 975 else if ("object" == typeof e2) if (Array.isArray(e2)) { 976 var o2 = e2.length; 977 for (t2 = 0; t2 < o2; t2++) e2[t2] && (f2 = r(e2[t2])) && (n2 && (n2 += " "), n2 += f2); 978 } else for (f2 in e2) e2[f2] && (n2 && (n2 += " "), n2 += f2); 979 return n2; 980 } 981 function clsx() { 982 for (var e2, t2, f2 = 0, n2 = "", o2 = arguments.length; f2 < o2; f2++) (e2 = arguments[f2]) && (t2 = r(e2)) && (n2 && (n2 += " "), n2 += t2); 983 return n2; 984 } 985 var clsx_default = clsx; 986 987 // packages/ui/build-module/badge/badge.mjs 988 var import_element13 = __toESM(require_element(), 1); 989 990 // node_modules/@base-ui/utils/useControlled.mjs 991 var React = __toESM(require_react(), 1); 992 993 // node_modules/@base-ui/utils/error.mjs 994 var set; 995 if (true) { 996 set = /* @__PURE__ */ new Set(); 997 } 998 function error(...messages) { 999 if (true) { 1000 const messageKey = messages.join(" "); 1001 if (!set.has(messageKey)) { 1002 set.add(messageKey); 1003 console.error(`Base UI: $messageKey}`); 1004 } 1005 } 1006 } 1007 1008 // node_modules/@base-ui/utils/useControlled.mjs 1009 function useControlled({ 1010 controlled, 1011 default: defaultProp, 1012 name, 1013 state = "value" 1014 }) { 1015 const { 1016 current: isControlled 1017 } = React.useRef(controlled !== void 0); 1018 const [valueState, setValue] = React.useState(defaultProp); 1019 const value = isControlled ? controlled : valueState; 1020 if (true) { 1021 React.useEffect(() => { 1022 if (isControlled !== (controlled !== void 0)) { 1023 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")); 1024 } 1025 }, [state, name, controlled]); 1026 const { 1027 current: defaultValue2 1028 } = React.useRef(defaultProp); 1029 React.useEffect(() => { 1030 if (!isControlled && serializeToDevModeString(defaultValue2) !== serializeToDevModeString(defaultProp)) { 1031 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")); 1032 } 1033 }, [defaultProp]); 1034 } 1035 const setValueIfUncontrolled = React.useCallback((newValue) => { 1036 if (!isControlled) { 1037 setValue(newValue); 1038 } 1039 }, []); 1040 return [value, setValueIfUncontrolled]; 1041 } 1042 function serializeToDevModeString(input) { 1043 let nextId = 0; 1044 const seen = /* @__PURE__ */ new WeakMap(); 1045 try { 1046 const result = JSON.stringify(input, function replacer(key, value) { 1047 if (key === "_owner" && this != null && typeof this === "object" && "$$typeof" in this) { 1048 return void 0; 1049 } 1050 if (typeof value === "bigint") { 1051 return `__bigint__:$value}`; 1052 } 1053 if (value !== null && typeof value === "object") { 1054 const id = seen.get(value); 1055 if (id !== void 0) { 1056 return `__object__:$id}`; 1057 } 1058 seen.set(value, nextId); 1059 nextId += 1; 1060 } 1061 return value; 1062 }); 1063 return result ?? `__top__:$typeof input}`; 1064 } catch { 1065 return "__unserializable__"; 1066 } 1067 } 1068 1069 // node_modules/@base-ui/utils/safeReact.mjs 1070 var React2 = __toESM(require_react(), 1); 1071 var SafeReact = { 1072 ...React2 1073 }; 1074 1075 // node_modules/@base-ui/utils/useRefWithInit.mjs 1076 var React3 = __toESM(require_react(), 1); 1077 var UNINITIALIZED = {}; 1078 function useRefWithInit(init2, initArg) { 1079 const ref = React3.useRef(UNINITIALIZED); 1080 if (ref.current === UNINITIALIZED) { 1081 ref.current = init2(initArg); 1082 } 1083 return ref; 1084 } 1085 1086 // node_modules/@base-ui/utils/useStableCallback.mjs 1087 var useInsertionEffect = SafeReact.useInsertionEffect; 1088 var useSafeInsertionEffect = ( 1089 // React 17 doesn't have useInsertionEffect. 1090 useInsertionEffect && // Preact replaces useInsertionEffect with useLayoutEffect and fires too late. 1091 useInsertionEffect !== SafeReact.useLayoutEffect ? useInsertionEffect : (fn) => fn() 1092 ); 1093 function useStableCallback(callback) { 1094 const stable = useRefWithInit(createStableCallback).current; 1095 stable.next = callback; 1096 useSafeInsertionEffect(stable.effect); 1097 return stable.trampoline; 1098 } 1099 function createStableCallback() { 1100 const stable = { 1101 next: void 0, 1102 callback: assertNotCalled, 1103 trampoline: (...args) => stable.callback?.(...args), 1104 effect: () => { 1105 stable.callback = stable.next; 1106 } 1107 }; 1108 return stable; 1109 } 1110 function assertNotCalled() { 1111 if (true) { 1112 throw ( 1113 /* minify-error-disabled */ 1114 new Error("Base UI: Cannot call an event handler while rendering.") 1115 ); 1116 } 1117 } 1118 1119 // node_modules/@base-ui/utils/useIsoLayoutEffect.mjs 1120 var React4 = __toESM(require_react(), 1); 1121 var noop = () => { 1122 }; 1123 var useIsoLayoutEffect = typeof document !== "undefined" ? React4.useLayoutEffect : noop; 1124 1125 // node_modules/@base-ui/utils/warn.mjs 1126 var set2; 1127 if (true) { 1128 set2 = /* @__PURE__ */ new Set(); 1129 } 1130 function warn(...messages) { 1131 if (true) { 1132 const messageKey = messages.join(" "); 1133 if (!set2.has(messageKey)) { 1134 set2.add(messageKey); 1135 console.warn(`Base UI: $messageKey}`); 1136 } 1137 } 1138 } 1139 1140 // node_modules/@base-ui/react/internals/direction-context/DirectionContext.mjs 1141 var React5 = __toESM(require_react(), 1); 1142 var DirectionContext = /* @__PURE__ */ React5.createContext(void 0); 1143 if (true) DirectionContext.displayName = "DirectionContext"; 1144 function useDirection() { 1145 const context = React5.useContext(DirectionContext); 1146 return context?.direction ?? "ltr"; 1147 } 1148 1149 // node_modules/@base-ui/react/internals/useRenderElement.mjs 1150 var React8 = __toESM(require_react(), 1); 1151 1152 // node_modules/@base-ui/utils/useMergedRefs.mjs 1153 function useMergedRefs(a2, b2, c2, d2) { 1154 const forkRef = useRefWithInit(createForkRef).current; 1155 if (didChange(forkRef, a2, b2, c2, d2)) { 1156 update(forkRef, [a2, b2, c2, d2]); 1157 } 1158 return forkRef.callback; 1159 } 1160 function useMergedRefsN(refs) { 1161 const forkRef = useRefWithInit(createForkRef).current; 1162 if (didChangeN(forkRef, refs)) { 1163 update(forkRef, refs); 1164 } 1165 return forkRef.callback; 1166 } 1167 function createForkRef() { 1168 return { 1169 callback: null, 1170 cleanup: null, 1171 refs: [] 1172 }; 1173 } 1174 function didChange(forkRef, a2, b2, c2, d2) { 1175 return forkRef.refs[0] !== a2 || forkRef.refs[1] !== b2 || forkRef.refs[2] !== c2 || forkRef.refs[3] !== d2; 1176 } 1177 function didChangeN(forkRef, newRefs) { 1178 return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index2) => ref !== newRefs[index2]); 1179 } 1180 function update(forkRef, refs) { 1181 forkRef.refs = refs; 1182 if (refs.every((ref) => ref == null)) { 1183 forkRef.callback = null; 1184 return; 1185 } 1186 forkRef.callback = (instance) => { 1187 if (forkRef.cleanup) { 1188 forkRef.cleanup(); 1189 forkRef.cleanup = null; 1190 } 1191 if (instance != null) { 1192 const cleanupCallbacks = Array(refs.length).fill(null); 1193 for (let i2 = 0; i2 < refs.length; i2 += 1) { 1194 const ref = refs[i2]; 1195 if (ref == null) { 1196 continue; 1197 } 1198 switch (typeof ref) { 1199 case "function": { 1200 const refCleanup = ref(instance); 1201 if (typeof refCleanup === "function") { 1202 cleanupCallbacks[i2] = refCleanup; 1203 } 1204 break; 1205 } 1206 case "object": { 1207 ref.current = instance; 1208 break; 1209 } 1210 default: 1211 } 1212 } 1213 forkRef.cleanup = () => { 1214 for (let i2 = 0; i2 < refs.length; i2 += 1) { 1215 const ref = refs[i2]; 1216 if (ref == null) { 1217 continue; 1218 } 1219 switch (typeof ref) { 1220 case "function": { 1221 const cleanupCallback = cleanupCallbacks[i2]; 1222 if (typeof cleanupCallback === "function") { 1223 cleanupCallback(); 1224 } else { 1225 ref(null); 1226 } 1227 break; 1228 } 1229 case "object": { 1230 ref.current = null; 1231 break; 1232 } 1233 default: 1234 } 1235 } 1236 }; 1237 } 1238 }; 1239 } 1240 1241 // node_modules/@base-ui/utils/getReactElementRef.mjs 1242 var React7 = __toESM(require_react(), 1); 1243 1244 // node_modules/@base-ui/utils/reactVersion.mjs 1245 var React6 = __toESM(require_react(), 1); 1246 var majorVersion = parseInt(React6.version, 10); 1247 function isReactVersionAtLeast(reactVersionToCheck) { 1248 return majorVersion >= reactVersionToCheck; 1249 } 1250 1251 // node_modules/@base-ui/utils/getReactElementRef.mjs 1252 function getReactElementRef(element) { 1253 if (!/* @__PURE__ */ React7.isValidElement(element)) { 1254 return null; 1255 } 1256 const reactElement = element; 1257 const propsWithRef = reactElement.props; 1258 return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null; 1259 } 1260 1261 // node_modules/@base-ui/utils/mergeObjects.mjs 1262 function mergeObjects(a2, b2) { 1263 if (a2 && !b2) { 1264 return a2; 1265 } 1266 if (!a2 && b2) { 1267 return b2; 1268 } 1269 if (a2 || b2) { 1270 return { 1271 ...a2, 1272 ...b2 1273 }; 1274 } 1275 return void 0; 1276 } 1277 1278 // node_modules/@base-ui/utils/empty.mjs 1279 function NOOP() { 1280 } 1281 var EMPTY_ARRAY = Object.freeze([]); 1282 var EMPTY_OBJECT = Object.freeze({}); 1283 1284 // node_modules/@base-ui/react/internals/getStateAttributesProps.mjs 1285 function getStateAttributesProps(state, customMapping) { 1286 const props = {}; 1287 for (const key in state) { 1288 const value = state[key]; 1289 if (customMapping?.hasOwnProperty(key)) { 1290 const customProps = customMapping[key](value); 1291 if (customProps != null) { 1292 Object.assign(props, customProps); 1293 } 1294 continue; 1295 } 1296 if (value === true) { 1297 props[`data-$key.toLowerCase()}`] = ""; 1298 } else if (value) { 1299 props[`data-$key.toLowerCase()}`] = value.toString(); 1300 } 1301 } 1302 return props; 1303 } 1304 1305 // node_modules/@base-ui/react/utils/resolveClassName.mjs 1306 function resolveClassName(className, state) { 1307 return typeof className === "function" ? className(state) : className; 1308 } 1309 1310 // node_modules/@base-ui/react/utils/resolveStyle.mjs 1311 function resolveStyle(style, state) { 1312 return typeof style === "function" ? style(state) : style; 1313 } 1314 1315 // node_modules/@base-ui/react/merge-props/mergeProps.mjs 1316 var EMPTY_PROPS = {}; 1317 function mergeProps(a2, b2, c2, d2, e2) { 1318 if (!c2 && !d2 && !e2 && !a2) { 1319 return createInitialMergedProps(b2); 1320 } 1321 let merged = createInitialMergedProps(a2); 1322 if (b2) { 1323 merged = mergeInto(merged, b2); 1324 } 1325 if (c2) { 1326 merged = mergeInto(merged, c2); 1327 } 1328 if (d2) { 1329 merged = mergeInto(merged, d2); 1330 } 1331 if (e2) { 1332 merged = mergeInto(merged, e2); 1333 } 1334 return merged; 1335 } 1336 function mergePropsN(props) { 1337 if (props.length === 0) { 1338 return EMPTY_PROPS; 1339 } 1340 if (props.length === 1) { 1341 return createInitialMergedProps(props[0]); 1342 } 1343 let merged = createInitialMergedProps(props[0]); 1344 for (let i2 = 1; i2 < props.length; i2 += 1) { 1345 merged = mergeInto(merged, props[i2]); 1346 } 1347 return merged; 1348 } 1349 function createInitialMergedProps(inputProps) { 1350 if (isPropsGetter(inputProps)) { 1351 return { 1352 ...resolvePropsGetter(inputProps, EMPTY_PROPS) 1353 }; 1354 } 1355 return copyInitialProps(inputProps); 1356 } 1357 function mergeInto(merged, inputProps) { 1358 if (isPropsGetter(inputProps)) { 1359 return resolvePropsGetter(inputProps, merged); 1360 } 1361 return mutablyMergeInto(merged, inputProps); 1362 } 1363 function copyInitialProps(inputProps) { 1364 const copiedProps = { 1365 ...inputProps 1366 }; 1367 for (const propName in copiedProps) { 1368 const propValue = copiedProps[propName]; 1369 if (isEventHandler(propName, propValue)) { 1370 copiedProps[propName] = wrapEventHandler(propValue); 1371 } 1372 } 1373 return copiedProps; 1374 } 1375 function mutablyMergeInto(mergedProps, externalProps) { 1376 if (!externalProps) { 1377 return mergedProps; 1378 } 1379 for (const propName in externalProps) { 1380 const externalPropValue = externalProps[propName]; 1381 switch (propName) { 1382 case "style": { 1383 mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue); 1384 break; 1385 } 1386 case "className": { 1387 mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue); 1388 break; 1389 } 1390 default: { 1391 if (isEventHandler(propName, externalPropValue)) { 1392 mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue); 1393 } else { 1394 mergedProps[propName] = externalPropValue; 1395 } 1396 } 1397 } 1398 } 1399 return mergedProps; 1400 } 1401 function isEventHandler(key, value) { 1402 const code0 = key.charCodeAt(0); 1403 const code1 = key.charCodeAt(1); 1404 const code2 = key.charCodeAt(2); 1405 return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined"); 1406 } 1407 function isPropsGetter(inputProps) { 1408 return typeof inputProps === "function"; 1409 } 1410 function resolvePropsGetter(inputProps, previousProps) { 1411 if (isPropsGetter(inputProps)) { 1412 return inputProps(previousProps); 1413 } 1414 return inputProps ?? EMPTY_PROPS; 1415 } 1416 function mergeEventHandlers(ourHandler, theirHandler) { 1417 if (!theirHandler) { 1418 return ourHandler; 1419 } 1420 if (!ourHandler) { 1421 return wrapEventHandler(theirHandler); 1422 } 1423 return (...args) => { 1424 const event = args[0]; 1425 if (isSyntheticEvent(event)) { 1426 const baseUIEvent = event; 1427 makeEventPreventable(baseUIEvent); 1428 const result2 = theirHandler(...args); 1429 if (!baseUIEvent.baseUIHandlerPrevented) { 1430 ourHandler?.(...args); 1431 } 1432 return result2; 1433 } 1434 const result = theirHandler(...args); 1435 ourHandler?.(...args); 1436 return result; 1437 }; 1438 } 1439 function wrapEventHandler(handler) { 1440 if (!handler) { 1441 return handler; 1442 } 1443 return (...args) => { 1444 const event = args[0]; 1445 if (isSyntheticEvent(event)) { 1446 makeEventPreventable(event); 1447 } 1448 return handler(...args); 1449 }; 1450 } 1451 function makeEventPreventable(event) { 1452 event.preventBaseUIHandler = () => { 1453 event.baseUIHandlerPrevented = true; 1454 }; 1455 return event; 1456 } 1457 function mergeClassNames(ourClassName, theirClassName) { 1458 if (theirClassName) { 1459 if (ourClassName) { 1460 return theirClassName + " " + ourClassName; 1461 } 1462 return theirClassName; 1463 } 1464 return ourClassName; 1465 } 1466 function isSyntheticEvent(event) { 1467 return event != null && typeof event === "object" && "nativeEvent" in event; 1468 } 1469 1470 // node_modules/@base-ui/react/internals/useRenderElement.mjs 1471 var import_react = __toESM(require_react(), 1); 1472 function useRenderElement(element, componentProps, params = {}) { 1473 const renderProp = componentProps.render; 1474 const outProps = useRenderElementProps(componentProps, params); 1475 if (params.enabled === false) { 1476 return null; 1477 } 1478 const state = params.state ?? EMPTY_OBJECT; 1479 return evaluateRenderProp(element, renderProp, outProps, state); 1480 } 1481 function useRenderElementProps(componentProps, params = {}) { 1482 const { 1483 className: classNameProp, 1484 style: styleProp, 1485 render: renderProp 1486 } = componentProps; 1487 const { 1488 state = EMPTY_OBJECT, 1489 ref, 1490 props, 1491 stateAttributesMapping: stateAttributesMapping7, 1492 enabled = true 1493 } = params; 1494 const className = enabled ? resolveClassName(classNameProp, state) : void 0; 1495 const style = enabled ? resolveStyle(styleProp, state) : void 0; 1496 const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping7) : EMPTY_OBJECT; 1497 const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0; 1498 const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT; 1499 if (typeof document !== "undefined") { 1500 if (!enabled) { 1501 useMergedRefs(null, null); 1502 } else if (Array.isArray(ref)) { 1503 outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]); 1504 } else { 1505 outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref); 1506 } 1507 } 1508 if (!enabled) { 1509 return EMPTY_OBJECT; 1510 } 1511 if (className !== void 0) { 1512 outProps.className = mergeClassNames(outProps.className, className); 1513 } 1514 if (style !== void 0) { 1515 outProps.style = mergeObjects(outProps.style, style); 1516 } 1517 return outProps; 1518 } 1519 function resolveRenderFunctionProps(props) { 1520 if (Array.isArray(props)) { 1521 return mergePropsN(props); 1522 } 1523 return mergeProps(void 0, props); 1524 } 1525 var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy"); 1526 var COMPONENT_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9$]*$/; 1527 var LOWERCASE_CHARACTER_PATTERN = /[a-z]/; 1528 function evaluateRenderProp(element, render4, props, state) { 1529 if (render4) { 1530 if (typeof render4 === "function") { 1531 if (true) { 1532 warnIfRenderPropLooksLikeComponent(render4); 1533 } 1534 return render4(props, state); 1535 } 1536 const mergedProps = mergeProps(props, render4.props); 1537 mergedProps.ref = props.ref; 1538 let newElement = render4; 1539 if (newElement?.$$typeof === REACT_LAZY_TYPE) { 1540 const children = React8.Children.toArray(render4); 1541 newElement = children[0]; 1542 } 1543 if (true) { 1544 if (!/* @__PURE__ */ React8.isValidElement(newElement)) { 1545 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")); 1546 } 1547 } 1548 return /* @__PURE__ */ React8.cloneElement(newElement, mergedProps); 1549 } 1550 if (element) { 1551 if (typeof element === "string") { 1552 return renderTag(element, props); 1553 } 1554 } 1555 throw new Error(true ? "Base UI: Render element or function are not defined." : formatErrorMessage_default(8)); 1556 } 1557 function warnIfRenderPropLooksLikeComponent(renderFn) { 1558 const functionName = renderFn.name; 1559 if (functionName.length === 0) { 1560 return; 1561 } 1562 if (!COMPONENT_IDENTIFIER_PATTERN.test(functionName)) { 1563 return; 1564 } 1565 if (!LOWERCASE_CHARACTER_PATTERN.test(functionName)) { 1566 return; 1567 } 1568 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"); 1569 } 1570 function renderTag(Tag, props) { 1571 if (Tag === "button") { 1572 return /* @__PURE__ */ (0, import_react.createElement)("button", { 1573 type: "button", 1574 ...props, 1575 key: props.key 1576 }); 1577 } 1578 if (Tag === "img") { 1579 return /* @__PURE__ */ (0, import_react.createElement)("img", { 1580 alt: "", 1581 ...props, 1582 key: props.key 1583 }); 1584 } 1585 return /* @__PURE__ */ React8.createElement(Tag, props); 1586 } 1587 1588 // node_modules/@base-ui/utils/useId.mjs 1589 var React9 = __toESM(require_react(), 1); 1590 var globalId = 0; 1591 function useGlobalId(idOverride, prefix = "mui") { 1592 const [defaultId, setDefaultId] = React9.useState(idOverride); 1593 const id = idOverride || defaultId; 1594 React9.useEffect(() => { 1595 if (defaultId == null) { 1596 globalId += 1; 1597 setDefaultId(`$prefix}-$globalId}`); 1598 } 1599 }, [defaultId, prefix]); 1600 return id; 1601 } 1602 var maybeReactUseId = SafeReact.useId; 1603 function useId(idOverride, prefix) { 1604 if (maybeReactUseId !== void 0) { 1605 const reactId = maybeReactUseId(); 1606 return idOverride ?? (prefix ? `$prefix}-$reactId}` : reactId); 1607 } 1608 return useGlobalId(idOverride, prefix); 1609 } 1610 1611 // node_modules/@base-ui/react/internals/useBaseUiId.mjs 1612 function useBaseUiId(idOverride) { 1613 return useId(idOverride, "base-ui"); 1614 } 1615 1616 // node_modules/@base-ui/react/collapsible/root/useCollapsibleRoot.mjs 1617 var React12 = __toESM(require_react(), 1); 1618 1619 // node_modules/@base-ui/react/internals/reason-parts.mjs 1620 var reason_parts_exports = {}; 1621 __export(reason_parts_exports, { 1622 cancelOpen: () => cancelOpen, 1623 chipRemovePress: () => chipRemovePress, 1624 clearPress: () => clearPress, 1625 closePress: () => closePress, 1626 closeWatcher: () => closeWatcher, 1627 decrementPress: () => decrementPress, 1628 disabled: () => disabled, 1629 drag: () => drag, 1630 escapeKey: () => escapeKey, 1631 focusOut: () => focusOut, 1632 imperativeAction: () => imperativeAction, 1633 incrementPress: () => incrementPress, 1634 initial: () => initial, 1635 inputBlur: () => inputBlur, 1636 inputChange: () => inputChange, 1637 inputClear: () => inputClear, 1638 inputPaste: () => inputPaste, 1639 inputPress: () => inputPress, 1640 itemPress: () => itemPress, 1641 keyboard: () => keyboard, 1642 linkPress: () => linkPress, 1643 listNavigation: () => listNavigation, 1644 missing: () => missing, 1645 none: () => none, 1646 outsidePress: () => outsidePress, 1647 pointer: () => pointer, 1648 scrub: () => scrub, 1649 siblingOpen: () => siblingOpen, 1650 swipe: () => swipe, 1651 trackPress: () => trackPress, 1652 triggerFocus: () => triggerFocus, 1653 triggerHover: () => triggerHover, 1654 triggerPress: () => triggerPress, 1655 wheel: () => wheel, 1656 windowResize: () => windowResize 1657 }); 1658 var none = "none"; 1659 var triggerPress = "trigger-press"; 1660 var triggerHover = "trigger-hover"; 1661 var triggerFocus = "trigger-focus"; 1662 var outsidePress = "outside-press"; 1663 var itemPress = "item-press"; 1664 var closePress = "close-press"; 1665 var linkPress = "link-press"; 1666 var clearPress = "clear-press"; 1667 var chipRemovePress = "chip-remove-press"; 1668 var trackPress = "track-press"; 1669 var incrementPress = "increment-press"; 1670 var decrementPress = "decrement-press"; 1671 var inputChange = "input-change"; 1672 var inputClear = "input-clear"; 1673 var inputBlur = "input-blur"; 1674 var inputPaste = "input-paste"; 1675 var inputPress = "input-press"; 1676 var focusOut = "focus-out"; 1677 var escapeKey = "escape-key"; 1678 var closeWatcher = "close-watcher"; 1679 var listNavigation = "list-navigation"; 1680 var keyboard = "keyboard"; 1681 var pointer = "pointer"; 1682 var drag = "drag"; 1683 var wheel = "wheel"; 1684 var scrub = "scrub"; 1685 var cancelOpen = "cancel-open"; 1686 var siblingOpen = "sibling-open"; 1687 var disabled = "disabled"; 1688 var missing = "missing"; 1689 var initial = "initial"; 1690 var imperativeAction = "imperative-action"; 1691 var swipe = "swipe"; 1692 var windowResize = "window-resize"; 1693 1694 // node_modules/@base-ui/react/internals/createBaseUIEventDetails.mjs 1695 function createChangeEventDetails(reason, event, trigger, customProperties) { 1696 let canceled = false; 1697 let allowPropagation = false; 1698 const custom = customProperties ?? EMPTY_OBJECT; 1699 const details = { 1700 reason, 1701 event: event ?? new Event("base-ui"), 1702 cancel() { 1703 canceled = true; 1704 }, 1705 allowPropagation() { 1706 allowPropagation = true; 1707 }, 1708 get isCanceled() { 1709 return canceled; 1710 }, 1711 get isPropagationAllowed() { 1712 return allowPropagation; 1713 }, 1714 trigger, 1715 ...custom 1716 }; 1717 return details; 1718 } 1719 1720 // node_modules/@base-ui/react/internals/useTransitionStatus.mjs 1721 var React11 = __toESM(require_react(), 1); 1722 1723 // node_modules/@base-ui/utils/useOnMount.mjs 1724 var React10 = __toESM(require_react(), 1); 1725 var EMPTY = []; 1726 function useOnMount(fn) { 1727 React10.useEffect(fn, EMPTY); 1728 } 1729 1730 // node_modules/@base-ui/utils/useAnimationFrame.mjs 1731 var EMPTY2 = null; 1732 var LAST_RAF = globalThis.requestAnimationFrame; 1733 var Scheduler = class { 1734 /* This implementation uses an array as a backing data-structure for frame callbacks. 1735 * It allows `O(1)` callback cancelling by inserting a `null` in the array, though it 1736 * never calls the native `cancelAnimationFrame` if there are no frames left. This can 1737 * be much more efficient if there is a call pattern that alterns as 1738 * "request-cancel-request-cancel-…". 1739 * But in the case of "request-request-…-cancel-cancel-…", it leaves the final animation 1740 * frame to run anyway. We turn that frame into a `O(1)` no-op via `callbacksCount`. */ 1741 callbacks = []; 1742 callbacksCount = 0; 1743 nextId = 1; 1744 startId = 1; 1745 isScheduled = false; 1746 tick = (timestamp) => { 1747 this.isScheduled = false; 1748 const currentCallbacks = this.callbacks; 1749 const currentCallbacksCount = this.callbacksCount; 1750 this.callbacks = []; 1751 this.callbacksCount = 0; 1752 this.startId = this.nextId; 1753 if (currentCallbacksCount > 0) { 1754 for (let i2 = 0; i2 < currentCallbacks.length; i2 += 1) { 1755 currentCallbacks[i2]?.(timestamp); 1756 } 1757 } 1758 }; 1759 request(fn) { 1760 const id = this.nextId; 1761 this.nextId += 1; 1762 this.callbacks.push(fn); 1763 this.callbacksCount += 1; 1764 const didRAFChange = LAST_RAF !== requestAnimationFrame && (LAST_RAF = requestAnimationFrame, true); 1765 if (!this.isScheduled || didRAFChange) { 1766 requestAnimationFrame(this.tick); 1767 this.isScheduled = true; 1768 } 1769 return id; 1770 } 1771 cancel(id) { 1772 const index2 = id - this.startId; 1773 if (index2 < 0 || index2 >= this.callbacks.length) { 1774 return; 1775 } 1776 this.callbacks[index2] = null; 1777 this.callbacksCount -= 1; 1778 } 1779 }; 1780 var scheduler = new Scheduler(); 1781 var AnimationFrame = class _AnimationFrame { 1782 static create() { 1783 return new _AnimationFrame(); 1784 } 1785 static request(fn) { 1786 return scheduler.request(fn); 1787 } 1788 static cancel(id) { 1789 return scheduler.cancel(id); 1790 } 1791 currentId = EMPTY2; 1792 /** 1793 * Executes `fn` after `delay`, clearing any previously scheduled call. 1794 */ 1795 request(fn) { 1796 this.cancel(); 1797 this.currentId = scheduler.request(() => { 1798 this.currentId = EMPTY2; 1799 fn(); 1800 }); 1801 } 1802 cancel = () => { 1803 if (this.currentId !== EMPTY2) { 1804 scheduler.cancel(this.currentId); 1805 this.currentId = EMPTY2; 1806 } 1807 }; 1808 disposeEffect = () => { 1809 return this.cancel; 1810 }; 1811 }; 1812 function useAnimationFrame() { 1813 const timeout = useRefWithInit(AnimationFrame.create).current; 1814 useOnMount(timeout.disposeEffect); 1815 return timeout; 1816 } 1817 1818 // node_modules/@base-ui/react/internals/useTransitionStatus.mjs 1819 function useTransitionStatus(open, enableIdleState = false, deferEndingState = false) { 1820 const [transitionStatus, setTransitionStatus] = React11.useState(open && enableIdleState ? "idle" : void 0); 1821 const [mounted, setMounted] = React11.useState(open); 1822 if (open && !mounted) { 1823 setMounted(true); 1824 setTransitionStatus("starting"); 1825 } 1826 if (!open && mounted && transitionStatus !== "ending" && !deferEndingState) { 1827 setTransitionStatus("ending"); 1828 } 1829 if (!open && !mounted && transitionStatus === "ending") { 1830 setTransitionStatus(void 0); 1831 } 1832 useIsoLayoutEffect(() => { 1833 if (!open && mounted && transitionStatus !== "ending" && deferEndingState) { 1834 const frame = AnimationFrame.request(() => { 1835 setTransitionStatus("ending"); 1836 }); 1837 return () => { 1838 AnimationFrame.cancel(frame); 1839 }; 1840 } 1841 return void 0; 1842 }, [open, mounted, transitionStatus, deferEndingState]); 1843 useIsoLayoutEffect(() => { 1844 if (!open || enableIdleState) { 1845 return void 0; 1846 } 1847 const frame = AnimationFrame.request(() => { 1848 setTransitionStatus(void 0); 1849 }); 1850 return () => { 1851 AnimationFrame.cancel(frame); 1852 }; 1853 }, [enableIdleState, open]); 1854 useIsoLayoutEffect(() => { 1855 if (!open || !enableIdleState) { 1856 return void 0; 1857 } 1858 if (open && mounted && transitionStatus !== "idle") { 1859 setTransitionStatus("starting"); 1860 } 1861 const frame = AnimationFrame.request(() => { 1862 setTransitionStatus("idle"); 1863 }); 1864 return () => { 1865 AnimationFrame.cancel(frame); 1866 }; 1867 }, [enableIdleState, open, mounted, transitionStatus]); 1868 return { 1869 mounted, 1870 setMounted, 1871 transitionStatus 1872 }; 1873 } 1874 1875 // node_modules/@base-ui/react/collapsible/root/useCollapsibleRoot.mjs 1876 function useCollapsibleRoot(parameters) { 1877 const { 1878 open: openParam, 1879 defaultOpen, 1880 onOpenChange, 1881 disabled: disabled2 1882 } = parameters; 1883 const [open, setOpen] = useControlled({ 1884 controlled: openParam, 1885 default: defaultOpen, 1886 name: "Collapsible", 1887 state: "open" 1888 }); 1889 const { 1890 mounted, 1891 setMounted, 1892 transitionStatus 1893 } = useTransitionStatus(open, true, true); 1894 const defaultPanelId = useBaseUiId(); 1895 const [panelIdState, setPanelIdState] = React12.useState(); 1896 const panelId = panelIdState ?? defaultPanelId; 1897 const handleTrigger = useStableCallback((event) => { 1898 const nextOpen = !open; 1899 const eventDetails = createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent); 1900 onOpenChange(nextOpen, eventDetails); 1901 if (eventDetails.isCanceled) { 1902 return; 1903 } 1904 setOpen(nextOpen); 1905 }); 1906 return React12.useMemo(() => ({ 1907 disabled: disabled2, 1908 handleTrigger, 1909 mounted, 1910 open, 1911 panelId, 1912 setMounted, 1913 setOpen, 1914 setPanelIdState, 1915 transitionStatus 1916 }), [disabled2, handleTrigger, mounted, open, panelId, setMounted, setOpen, setPanelIdState, transitionStatus]); 1917 } 1918 1919 // node_modules/@base-ui/react/collapsible/root/CollapsibleRootContext.mjs 1920 var React13 = __toESM(require_react(), 1); 1921 var CollapsibleRootContext = /* @__PURE__ */ React13.createContext(void 0); 1922 if (true) CollapsibleRootContext.displayName = "CollapsibleRootContext"; 1923 function useCollapsibleRootContext() { 1924 const context = React13.useContext(CollapsibleRootContext); 1925 if (context === void 0) { 1926 throw new Error(true ? "Base UI: CollapsibleRootContext is missing. Collapsible parts must be placed within <Collapsible.Root>." : formatErrorMessage_default(15)); 1927 } 1928 return context; 1929 } 1930 1931 // node_modules/@base-ui/react/internals/stateAttributesMapping.mjs 1932 var TransitionStatusDataAttributes = /* @__PURE__ */ (function(TransitionStatusDataAttributes2) { 1933 TransitionStatusDataAttributes2["startingStyle"] = "data-starting-style"; 1934 TransitionStatusDataAttributes2["endingStyle"] = "data-ending-style"; 1935 return TransitionStatusDataAttributes2; 1936 })({}); 1937 var STARTING_HOOK = { 1938 [TransitionStatusDataAttributes.startingStyle]: "" 1939 }; 1940 var ENDING_HOOK = { 1941 [TransitionStatusDataAttributes.endingStyle]: "" 1942 }; 1943 var transitionStatusMapping = { 1944 transitionStatus(value) { 1945 if (value === "starting") { 1946 return STARTING_HOOK; 1947 } 1948 if (value === "ending") { 1949 return ENDING_HOOK; 1950 } 1951 return null; 1952 } 1953 }; 1954 1955 // node_modules/@base-ui/react/collapsible/panel/CollapsiblePanelDataAttributes.mjs 1956 var CollapsiblePanelDataAttributes = (function(CollapsiblePanelDataAttributes2) { 1957 CollapsiblePanelDataAttributes2["open"] = "data-open"; 1958 CollapsiblePanelDataAttributes2["closed"] = "data-closed"; 1959 CollapsiblePanelDataAttributes2[CollapsiblePanelDataAttributes2["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle"; 1960 CollapsiblePanelDataAttributes2[CollapsiblePanelDataAttributes2["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle"; 1961 return CollapsiblePanelDataAttributes2; 1962 })({}); 1963 1964 // node_modules/@base-ui/react/collapsible/trigger/CollapsibleTriggerDataAttributes.mjs 1965 var CollapsibleTriggerDataAttributes = /* @__PURE__ */ (function(CollapsibleTriggerDataAttributes2) { 1966 CollapsibleTriggerDataAttributes2["panelOpen"] = "data-panel-open"; 1967 return CollapsibleTriggerDataAttributes2; 1968 })({}); 1969 1970 // node_modules/@base-ui/react/utils/collapsibleOpenStateMapping.mjs 1971 var PANEL_OPEN_HOOK = { 1972 [CollapsiblePanelDataAttributes.open]: "" 1973 }; 1974 var PANEL_CLOSED_HOOK = { 1975 [CollapsiblePanelDataAttributes.closed]: "" 1976 }; 1977 var triggerOpenStateMapping = { 1978 open(value) { 1979 if (value) { 1980 return { 1981 [CollapsibleTriggerDataAttributes.panelOpen]: "" 1982 }; 1983 } 1984 return null; 1985 } 1986 }; 1987 var collapsibleOpenStateMapping = { 1988 open(value) { 1989 if (value) { 1990 return PANEL_OPEN_HOOK; 1991 } 1992 return PANEL_CLOSED_HOOK; 1993 } 1994 }; 1995 1996 // node_modules/@base-ui/react/internals/use-button/useButton.mjs 1997 var React16 = __toESM(require_react(), 1); 1998 1999 // node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs 2000 function hasWindow() { 2001 return typeof window !== "undefined"; 2002 } 2003 function getNodeName(node) { 2004 if (isNode(node)) { 2005 return (node.nodeName || "").toLowerCase(); 2006 } 2007 return "#document"; 2008 } 2009 function getWindow(node) { 2010 var _node$ownerDocument; 2011 return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window; 2012 } 2013 function getDocumentElement(node) { 2014 var _ref; 2015 return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement; 2016 } 2017 function isNode(value) { 2018 if (!hasWindow()) { 2019 return false; 2020 } 2021 return value instanceof Node || value instanceof getWindow(value).Node; 2022 } 2023 function isElement(value) { 2024 if (!hasWindow()) { 2025 return false; 2026 } 2027 return value instanceof Element || value instanceof getWindow(value).Element; 2028 } 2029 function isHTMLElement(value) { 2030 if (!hasWindow()) { 2031 return false; 2032 } 2033 return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement; 2034 } 2035 function isShadowRoot(value) { 2036 if (!hasWindow() || typeof ShadowRoot === "undefined") { 2037 return false; 2038 } 2039 return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot; 2040 } 2041 function isOverflowElement(element) { 2042 const { 2043 overflow, 2044 overflowX, 2045 overflowY, 2046 display 2047 } = getComputedStyle2(element); 2048 return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== "inline" && display !== "contents"; 2049 } 2050 function isTableElement(element) { 2051 return /^(table|td|th)$/.test(getNodeName(element)); 2052 } 2053 function isTopLayer(element) { 2054 try { 2055 if (element.matches(":popover-open")) { 2056 return true; 2057 } 2058 } catch (_e) { 2059 } 2060 try { 2061 return element.matches(":modal"); 2062 } catch (_e) { 2063 return false; 2064 } 2065 } 2066 var willChangeRe = /transform|translate|scale|rotate|perspective|filter/; 2067 var containRe = /paint|layout|strict|content/; 2068 var isNotNone = (value) => !!value && value !== "none"; 2069 var isWebKitValue; 2070 function isContainingBlock(elementOrCss) { 2071 const css = isElement(elementOrCss) ? getComputedStyle2(elementOrCss) : elementOrCss; 2072 return isNotNone(css.transform) || isNotNone(css.translate) || isNotNone(css.scale) || isNotNone(css.rotate) || isNotNone(css.perspective) || !isWebKit() && (isNotNone(css.backdropFilter) || isNotNone(css.filter)) || willChangeRe.test(css.willChange || "") || containRe.test(css.contain || ""); 2073 } 2074 function getContainingBlock(element) { 2075 let currentNode = getParentNode(element); 2076 while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) { 2077 if (isContainingBlock(currentNode)) { 2078 return currentNode; 2079 } else if (isTopLayer(currentNode)) { 2080 return null; 2081 } 2082 currentNode = getParentNode(currentNode); 2083 } 2084 return null; 2085 } 2086 function isWebKit() { 2087 if (isWebKitValue == null) { 2088 isWebKitValue = typeof CSS !== "undefined" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none"); 2089 } 2090 return isWebKitValue; 2091 } 2092 function isLastTraversableNode(node) { 2093 return /^(html|body|#document)$/.test(getNodeName(node)); 2094 } 2095 function getComputedStyle2(element) { 2096 return getWindow(element).getComputedStyle(element); 2097 } 2098 function getNodeScroll(element) { 2099 if (isElement(element)) { 2100 return { 2101 scrollLeft: element.scrollLeft, 2102 scrollTop: element.scrollTop 2103 }; 2104 } 2105 return { 2106 scrollLeft: element.scrollX, 2107 scrollTop: element.scrollY 2108 }; 2109 } 2110 function getParentNode(node) { 2111 if (getNodeName(node) === "html") { 2112 return node; 2113 } 2114 const result = ( 2115 // Step into the shadow DOM of the parent of a slotted node. 2116 node.assignedSlot || // DOM Element detected. 2117 node.parentNode || // ShadowRoot detected. 2118 isShadowRoot(node) && node.host || // Fallback. 2119 getDocumentElement(node) 2120 ); 2121 return isShadowRoot(result) ? result.host : result; 2122 } 2123 function getNearestOverflowAncestor(node) { 2124 const parentNode = getParentNode(node); 2125 if (isLastTraversableNode(parentNode)) { 2126 return node.ownerDocument ? node.ownerDocument.body : node.body; 2127 } 2128 if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) { 2129 return parentNode; 2130 } 2131 return getNearestOverflowAncestor(parentNode); 2132 } 2133 function getOverflowAncestors(node, list, traverseIframes) { 2134 var _node$ownerDocument2; 2135 if (list === void 0) { 2136 list = []; 2137 } 2138 if (traverseIframes === void 0) { 2139 traverseIframes = true; 2140 } 2141 const scrollableAncestor = getNearestOverflowAncestor(node); 2142 const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body); 2143 const win = getWindow(scrollableAncestor); 2144 if (isBody) { 2145 const frameElement = getFrameElement(win); 2146 return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []); 2147 } else { 2148 return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes)); 2149 } 2150 } 2151 function getFrameElement(win) { 2152 return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null; 2153 } 2154 2155 // node_modules/@base-ui/react/internals/composite/root/CompositeRootContext.mjs 2156 var React14 = __toESM(require_react(), 1); 2157 var CompositeRootContext = /* @__PURE__ */ React14.createContext(void 0); 2158 if (true) CompositeRootContext.displayName = "CompositeRootContext"; 2159 function useCompositeRootContext(optional = false) { 2160 const context = React14.useContext(CompositeRootContext); 2161 if (context === void 0 && !optional) { 2162 throw new Error(true ? "Base UI: CompositeRootContext is missing. Composite parts must be placed within <Composite.Root>." : formatErrorMessage_default(16)); 2163 } 2164 return context; 2165 } 2166 2167 // node_modules/@base-ui/react/utils/useFocusableWhenDisabled.mjs 2168 var React15 = __toESM(require_react(), 1); 2169 function useFocusableWhenDisabled(parameters) { 2170 const { 2171 focusableWhenDisabled, 2172 disabled: disabled2, 2173 composite = false, 2174 tabIndex: tabIndexProp = 0, 2175 isNativeButton 2176 } = parameters; 2177 const isFocusableComposite = composite && focusableWhenDisabled !== false; 2178 const isNonFocusableComposite = composite && focusableWhenDisabled === false; 2179 const props = React15.useMemo(() => { 2180 const additionalProps = { 2181 // allow Tabbing away from focusableWhenDisabled elements 2182 onKeyDown(event) { 2183 if (disabled2 && focusableWhenDisabled && event.key !== "Tab") { 2184 event.preventDefault(); 2185 } 2186 } 2187 }; 2188 if (!composite) { 2189 additionalProps.tabIndex = tabIndexProp; 2190 if (!isNativeButton && disabled2) { 2191 additionalProps.tabIndex = focusableWhenDisabled ? tabIndexProp : -1; 2192 } 2193 } 2194 if (isNativeButton && (focusableWhenDisabled || isFocusableComposite) || !isNativeButton && disabled2) { 2195 additionalProps["aria-disabled"] = disabled2; 2196 } 2197 if (isNativeButton && (!focusableWhenDisabled || isNonFocusableComposite)) { 2198 additionalProps.disabled = disabled2; 2199 } 2200 return additionalProps; 2201 }, [composite, disabled2, focusableWhenDisabled, isFocusableComposite, isNonFocusableComposite, isNativeButton, tabIndexProp]); 2202 return { 2203 props 2204 }; 2205 } 2206 2207 // node_modules/@base-ui/react/internals/use-button/useButton.mjs 2208 function useButton(parameters = {}) { 2209 const { 2210 disabled: disabled2 = false, 2211 focusableWhenDisabled, 2212 tabIndex = 0, 2213 native: isNativeButton = true, 2214 composite: compositeProp 2215 } = parameters; 2216 const elementRef = React16.useRef(null); 2217 const compositeRootContext = useCompositeRootContext(true); 2218 const isCompositeItem = compositeProp ?? compositeRootContext !== void 0; 2219 const { 2220 props: focusableWhenDisabledProps 2221 } = useFocusableWhenDisabled({ 2222 focusableWhenDisabled, 2223 disabled: disabled2, 2224 composite: isCompositeItem, 2225 tabIndex, 2226 isNativeButton 2227 }); 2228 if (true) { 2229 React16.useEffect(() => { 2230 if (!elementRef.current) { 2231 return; 2232 } 2233 const isButtonTag = isButtonElement(elementRef.current); 2234 if (isNativeButton) { 2235 if (!isButtonTag) { 2236 const ownerStackMessage = SafeReact.captureOwnerStack?.() || ""; 2237 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`."; 2238 error(`$message2}$ownerStackMessage}`); 2239 } 2240 } else if (isButtonTag) { 2241 const ownerStackMessage = SafeReact.captureOwnerStack?.() || ""; 2242 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`."; 2243 error(`$message2}$ownerStackMessage}`); 2244 } 2245 }, [isNativeButton]); 2246 } 2247 const updateDisabled = React16.useCallback(() => { 2248 const element = elementRef.current; 2249 if (!isButtonElement(element)) { 2250 return; 2251 } 2252 if (isCompositeItem && disabled2 && focusableWhenDisabledProps.disabled === void 0 && element.disabled) { 2253 element.disabled = false; 2254 } 2255 }, [disabled2, focusableWhenDisabledProps.disabled, isCompositeItem]); 2256 useIsoLayoutEffect(updateDisabled, [updateDisabled]); 2257 const getButtonProps = React16.useCallback((externalProps = {}) => { 2258 const { 2259 onClick: externalOnClick, 2260 onMouseDown: externalOnMouseDown, 2261 onKeyUp: externalOnKeyUp, 2262 onKeyDown: externalOnKeyDown, 2263 onPointerDown: externalOnPointerDown, 2264 ...otherExternalProps 2265 } = externalProps; 2266 return mergeProps({ 2267 onClick(event) { 2268 if (disabled2) { 2269 event.preventDefault(); 2270 return; 2271 } 2272 externalOnClick?.(event); 2273 }, 2274 onMouseDown(event) { 2275 if (!disabled2) { 2276 externalOnMouseDown?.(event); 2277 } 2278 }, 2279 onKeyDown(event) { 2280 if (disabled2) { 2281 return; 2282 } 2283 makeEventPreventable(event); 2284 externalOnKeyDown?.(event); 2285 if (event.baseUIHandlerPrevented) { 2286 return; 2287 } 2288 const isCurrentTarget = event.target === event.currentTarget; 2289 const currentTarget = event.currentTarget; 2290 const isButton2 = isButtonElement(currentTarget); 2291 const isLink = !isNativeButton && isValidLinkElement(currentTarget); 2292 const shouldClick = isCurrentTarget && (isNativeButton ? isButton2 : !isLink); 2293 const isEnterKey = event.key === "Enter"; 2294 const isSpaceKey = event.key === " "; 2295 const role = currentTarget.getAttribute("role"); 2296 const isTextNavigationRole = role?.startsWith("menuitem") || role === "option" || role === "gridcell"; 2297 if (isCurrentTarget && isCompositeItem && isSpaceKey) { 2298 if (event.defaultPrevented && isTextNavigationRole) { 2299 return; 2300 } 2301 event.preventDefault(); 2302 if (isLink || isNativeButton && isButton2) { 2303 currentTarget.click(); 2304 event.preventBaseUIHandler(); 2305 } else if (shouldClick) { 2306 externalOnClick?.(event); 2307 event.preventBaseUIHandler(); 2308 } 2309 return; 2310 } 2311 if (shouldClick) { 2312 if (!isNativeButton && (isSpaceKey || isEnterKey)) { 2313 event.preventDefault(); 2314 } 2315 if (!isNativeButton && isEnterKey) { 2316 externalOnClick?.(event); 2317 } 2318 } 2319 }, 2320 onKeyUp(event) { 2321 if (disabled2) { 2322 return; 2323 } 2324 makeEventPreventable(event); 2325 externalOnKeyUp?.(event); 2326 if (event.target === event.currentTarget && isNativeButton && isCompositeItem && isButtonElement(event.currentTarget) && event.key === " ") { 2327 event.preventDefault(); 2328 return; 2329 } 2330 if (event.baseUIHandlerPrevented) { 2331 return; 2332 } 2333 if (event.target === event.currentTarget && !isNativeButton && !isCompositeItem && event.key === " ") { 2334 externalOnClick?.(event); 2335 } 2336 }, 2337 onPointerDown(event) { 2338 if (disabled2) { 2339 event.preventDefault(); 2340 return; 2341 } 2342 externalOnPointerDown?.(event); 2343 } 2344 }, isNativeButton ? { 2345 type: "button" 2346 } : { 2347 role: "button" 2348 }, focusableWhenDisabledProps, otherExternalProps); 2349 }, [disabled2, focusableWhenDisabledProps, isCompositeItem, isNativeButton]); 2350 const buttonRef = useStableCallback((element) => { 2351 elementRef.current = element; 2352 updateDisabled(); 2353 }); 2354 return { 2355 getButtonProps, 2356 buttonRef 2357 }; 2358 } 2359 function isButtonElement(elem) { 2360 return isHTMLElement(elem) && elem.tagName === "BUTTON"; 2361 } 2362 function isValidLinkElement(elem) { 2363 return Boolean(elem?.tagName === "A" && elem?.href); 2364 } 2365 2366 // node_modules/@base-ui/react/collapsible/panel/useCollapsiblePanel.mjs 2367 var React18 = __toESM(require_react(), 1); 2368 2369 // node_modules/@base-ui/utils/addEventListener.mjs 2370 function addEventListener(target, type, listener, options) { 2371 target.addEventListener(type, listener, options); 2372 return () => { 2373 target.removeEventListener(type, listener, options); 2374 }; 2375 } 2376 2377 // node_modules/@base-ui/utils/useValueAsRef.mjs 2378 function useValueAsRef(value) { 2379 const latest = useRefWithInit(createLatestRef, value).current; 2380 latest.next = value; 2381 useIsoLayoutEffect(latest.effect); 2382 return latest; 2383 } 2384 function createLatestRef(value) { 2385 const latest = { 2386 current: value, 2387 next: value, 2388 effect: () => { 2389 latest.current = latest.next; 2390 } 2391 }; 2392 return latest; 2393 } 2394 2395 // node_modules/@base-ui/utils/owner.mjs 2396 function ownerDocument(node) { 2397 return node?.ownerDocument || document; 2398 } 2399 2400 // node_modules/@base-ui/react/internals/useOpenChangeComplete.mjs 2401 var React17 = __toESM(require_react(), 1); 2402 2403 // node_modules/@base-ui/react/internals/useAnimationsFinished.mjs 2404 var ReactDOM = __toESM(require_react_dom(), 1); 2405 2406 // node_modules/@base-ui/react/utils/resolveRef.mjs 2407 function resolveRef(maybeRef) { 2408 if (maybeRef == null) { 2409 return maybeRef; 2410 } 2411 return "current" in maybeRef ? maybeRef.current : maybeRef; 2412 } 2413 2414 // node_modules/@base-ui/react/internals/useAnimationsFinished.mjs 2415 function useAnimationsFinished(elementOrRef, waitForStartingStyleRemoved = false, treatAbortedAsFinished = true) { 2416 const frame = useAnimationFrame(); 2417 return useStableCallback((fnToExecute, signal = null) => { 2418 frame.cancel(); 2419 const element = resolveRef(elementOrRef); 2420 if (element == null) { 2421 return; 2422 } 2423 const resolvedElement = element; 2424 const done = () => { 2425 ReactDOM.flushSync(fnToExecute); 2426 }; 2427 if (typeof resolvedElement.getAnimations !== "function" || globalThis.BASE_UI_ANIMATIONS_DISABLED) { 2428 fnToExecute(); 2429 return; 2430 } 2431 function exec() { 2432 Promise.all(resolvedElement.getAnimations().map((animation) => animation.finished)).then(() => { 2433 if (!signal?.aborted) { 2434 done(); 2435 } 2436 }).catch(() => { 2437 if (treatAbortedAsFinished) { 2438 if (!signal?.aborted) { 2439 done(); 2440 } 2441 return; 2442 } 2443 const currentAnimations = resolvedElement.getAnimations(); 2444 if (!signal?.aborted && currentAnimations.length > 0 && currentAnimations.some((animation) => animation.pending || animation.playState !== "finished")) { 2445 exec(); 2446 } 2447 }); 2448 } 2449 if (waitForStartingStyleRemoved) { 2450 const startingStyleAttribute = TransitionStatusDataAttributes.startingStyle; 2451 if (!resolvedElement.hasAttribute(startingStyleAttribute)) { 2452 frame.request(exec); 2453 return; 2454 } 2455 const attributeObserver = new MutationObserver(() => { 2456 if (!resolvedElement.hasAttribute(startingStyleAttribute)) { 2457 attributeObserver.disconnect(); 2458 exec(); 2459 } 2460 }); 2461 attributeObserver.observe(resolvedElement, { 2462 attributes: true, 2463 attributeFilter: [startingStyleAttribute] 2464 }); 2465 signal?.addEventListener("abort", () => attributeObserver.disconnect(), { 2466 once: true 2467 }); 2468 return; 2469 } 2470 frame.request(exec); 2471 }); 2472 } 2473 2474 // node_modules/@base-ui/react/internals/useOpenChangeComplete.mjs 2475 function useOpenChangeComplete(parameters) { 2476 const { 2477 enabled = true, 2478 open, 2479 ref, 2480 onComplete: onCompleteParam 2481 } = parameters; 2482 const onComplete = useStableCallback(onCompleteParam); 2483 const runOnceAnimationsFinish = useAnimationsFinished(ref, open, false); 2484 React17.useEffect(() => { 2485 if (!enabled) { 2486 return void 0; 2487 } 2488 const abortController = new AbortController(); 2489 runOnceAnimationsFinish(onComplete, abortController.signal); 2490 return () => { 2491 abortController.abort(); 2492 }; 2493 }, [enabled, open, onComplete, runOnceAnimationsFinish]); 2494 } 2495 2496 // node_modules/@base-ui/react/collapsible/panel/useCollapsiblePanel.mjs 2497 var EMPTY_DIMENSIONS = { 2498 height: void 0, 2499 width: void 0 2500 }; 2501 function useCollapsiblePanel(parameters) { 2502 const { 2503 externalRef, 2504 hiddenUntilFound, 2505 id: idParam, 2506 keepMounted, 2507 mounted, 2508 onOpenChange, 2509 open, 2510 setMounted, 2511 setOpen, 2512 transitionStatus 2513 } = parameters; 2514 const panelRef = React18.useRef(null); 2515 const animationTypeRef = React18.useRef(null); 2516 const [dimensions, setDimensionsUnwrapped] = React18.useState(EMPTY_DIMENSIONS); 2517 const lastMeasuredDimensionsRef = React18.useRef(EMPTY_DIMENSIONS); 2518 const shouldSkipNextOpenRef = React18.useRef(false); 2519 const shouldPreventMountAnimationRef = React18.useRef(open); 2520 const shouldPreventActivityResumeAnimationRef = React18.useRef(false); 2521 const [forcePanelIdle, setForcePanelIdle] = React18.useState(false); 2522 const pendingTemporaryStyleRestoreRef = React18.useRef(null); 2523 const mergedPanelRef = useMergedRefs(externalRef, panelRef); 2524 const latestStateRef = useValueAsRef({ 2525 mounted, 2526 open 2527 }); 2528 const runOnceCloseAnimationsFinish = useAnimationsFinished(panelRef, false, false); 2529 const hidden = !open && !mounted; 2530 const panelTransitionStatus = forcePanelIdle ? "idle" : transitionStatus; 2531 const shouldPreventOpenAnimation = open && // These 2 refs are safe to read in render, they are only written from committed 2532 // layout/effect paths and gate one-shot motion suppression for the next open 2533 // lifecycle. They intentionally expose the last committed motion snapshot. 2534 (shouldPreventMountAnimationRef.current || shouldPreventActivityResumeAnimationRef.current); 2535 const renderedDimensions = !open && mounted && // These 2 refs are also safe to read in render, both hold the last committed 2536 // animation mode and measurement. This fallback only restores a previously 2537 // measured pixel size after the live dimensions state has been reset back to `auto`. 2538 animationTypeRef.current === "css-animation" && dimensions.height === void 0 && dimensions.width === void 0 ? lastMeasuredDimensionsRef.current : dimensions; 2539 const shouldPersistHiddenTransitionStyles = hiddenUntilFound && hidden && animationTypeRef.current !== "css-animation"; 2540 const setDimensions = useStableCallback((nextDimensions, shouldCacheMeasurement = true) => { 2541 if (shouldCacheMeasurement) { 2542 lastMeasuredDimensionsRef.current = nextDimensions; 2543 } 2544 setDimensionsUnwrapped(nextDimensions); 2545 }); 2546 const restorePendingTemporaryStyle = useStableCallback(() => { 2547 pendingTemporaryStyleRestoreRef.current?.(); 2548 pendingTemporaryStyleRestoreRef.current = null; 2549 }); 2550 const setPendingTemporaryStyleRestore = useStableCallback((restore) => { 2551 restorePendingTemporaryStyle(); 2552 pendingTemporaryStyleRestoreRef.current = () => { 2553 pendingTemporaryStyleRestoreRef.current = null; 2554 restore(); 2555 }; 2556 }); 2557 const markActivityResumeAnimationSuppressed = useStableCallback(() => { 2558 if (open && mounted && animationTypeRef.current === "css-animation") { 2559 shouldPreventActivityResumeAnimationRef.current = true; 2560 } 2561 }); 2562 useIsoLayoutEffect(() => { 2563 if (!forcePanelIdle || transitionStatus === "starting") { 2564 return; 2565 } 2566 setForcePanelIdle(false); 2567 }, [forcePanelIdle, transitionStatus]); 2568 React18.useEffect(() => { 2569 return () => { 2570 markActivityResumeAnimationSuppressed(); 2571 restorePendingTemporaryStyle(); 2572 }; 2573 }, [markActivityResumeAnimationSuppressed, restorePendingTemporaryStyle]); 2574 useIsoLayoutEffect(() => { 2575 const panel = panelRef.current; 2576 if (!panel) { 2577 return void 0; 2578 } 2579 if (!open && pendingTemporaryStyleRestoreRef.current) { 2580 restorePendingTemporaryStyle(); 2581 } 2582 const animationType = getAnimationType(panel, shouldPreventOpenAnimation); 2583 animationTypeRef.current = animationType; 2584 if (open && transitionStatus === "idle" && shouldPreventMountAnimationRef.current && animationType === "css-animation") { 2585 lastMeasuredDimensionsRef.current = getDimensions(panel); 2586 return void 0; 2587 } 2588 if (open && transitionStatus === "starting") { 2589 const skipNextOpen = shouldSkipNextOpenRef.current; 2590 shouldSkipNextOpenRef.current = false; 2591 if (animationType === "none") { 2592 setDimensions(getDimensions(panel)); 2593 setForcePanelIdle(true); 2594 return void 0; 2595 } 2596 if (animationType === "css-transition") { 2597 const restoreLayoutStyles = resetLayoutStyles(panel); 2598 setDimensions(getDimensions(panel)); 2599 if (!skipNextOpen) { 2600 return restoreLayoutStyles; 2601 } 2602 const restoreTransitionDuration = setTemporaryStyle(panel, "transition-duration", "0s"); 2603 setPendingTemporaryStyleRestore(restoreTransitionDuration); 2604 setForcePanelIdle(true); 2605 return restoreLayoutStyles; 2606 } 2607 if (animationType === "css-animation") { 2608 setDimensions(getDimensions(panel)); 2609 if (!skipNextOpen) { 2610 const restoreAnimationName2 = setTemporaryStyle(panel, "animation-name", "none"); 2611 restoreAnimationName2(); 2612 return void 0; 2613 } 2614 const restoreAnimationName = setTemporaryStyle(panel, "animation-name", "none"); 2615 const restoreAnimationDuration = setTemporaryStyle(panel, "animation-duration", "0s"); 2616 restoreAnimationName(); 2617 setPendingTemporaryStyleRestore(restoreAnimationDuration); 2618 setForcePanelIdle(true); 2619 return void 0; 2620 } 2621 } 2622 if (!open && mounted && (transitionStatus === "idle" || transitionStatus === "starting")) { 2623 shouldPreventMountAnimationRef.current = false; 2624 shouldPreventActivityResumeAnimationRef.current = false; 2625 if (animationType === "none") { 2626 setDimensions(EMPTY_DIMENSIONS, false); 2627 setMounted(false); 2628 return void 0; 2629 } 2630 setDimensions(getDimensions(panel)); 2631 return void 0; 2632 } 2633 if (transitionStatus !== "ending") { 2634 return void 0; 2635 } 2636 if (animationType === "none") { 2637 setMounted(false); 2638 return void 0; 2639 } 2640 const nextDimensions = getDimensions(panel); 2641 const hasMeasuredSize = (nextDimensions.height ?? 0) > 0 || (nextDimensions.width ?? 0) > 0; 2642 if (!hasMeasuredSize) { 2643 setMounted(false); 2644 return void 0; 2645 } 2646 setDimensions(nextDimensions); 2647 if (animationType === "css-animation") { 2648 const restoreAnimationName = setTemporaryStyle(panel, "animation-name", "none"); 2649 restoreAnimationName(); 2650 } 2651 return void 0; 2652 }, [mounted, open, restorePendingTemporaryStyle, setDimensions, setMounted, setPendingTemporaryStyleRestore, shouldPreventOpenAnimation, transitionStatus]); 2653 useOpenChangeComplete({ 2654 enabled: open && mounted && panelTransitionStatus === "idle", 2655 open: true, 2656 ref: panelRef, 2657 onComplete() { 2658 if (!open) { 2659 return; 2660 } 2661 setDimensions(EMPTY_DIMENSIONS, false); 2662 } 2663 }); 2664 React18.useEffect(() => { 2665 if (open || !mounted || panelTransitionStatus !== "ending") { 2666 return void 0; 2667 } 2668 const panel = panelRef.current; 2669 if (!panel) { 2670 return void 0; 2671 } 2672 const abortController = new AbortController(); 2673 let endingStyleFrame = -1; 2674 function handleComplete() { 2675 if (latestStateRef.current.open) { 2676 return; 2677 } 2678 setMounted(false); 2679 setDimensions(EMPTY_DIMENSIONS, false); 2680 } 2681 endingStyleFrame = AnimationFrame.request(() => { 2682 if (!abortController.signal.aborted) { 2683 runOnceCloseAnimationsFinish(handleComplete, abortController.signal); 2684 } 2685 }); 2686 return () => { 2687 AnimationFrame.cancel(endingStyleFrame); 2688 abortController.abort(); 2689 }; 2690 }, [latestStateRef, mounted, open, panelTransitionStatus, runOnceCloseAnimationsFinish, setDimensions, setMounted]); 2691 useIsoLayoutEffect(() => { 2692 const panel = panelRef.current; 2693 if (!panel || !hiddenUntilFound || !hidden) { 2694 return; 2695 } 2696 panel.setAttribute("hidden", "until-found"); 2697 }, [hidden, hiddenUntilFound]); 2698 React18.useEffect(function registerBeforeMatchListener() { 2699 const panel = panelRef.current; 2700 if (!panel) { 2701 return void 0; 2702 } 2703 function handleBeforeMatch(event) { 2704 const eventDetails = createChangeEventDetails(reason_parts_exports.none, event); 2705 onOpenChange(true, eventDetails); 2706 if (eventDetails.isCanceled) { 2707 return; 2708 } 2709 shouldSkipNextOpenRef.current = true; 2710 setOpen(true); 2711 } 2712 return addEventListener(panel, "beforematch", handleBeforeMatch); 2713 }, [onOpenChange, setOpen]); 2714 const shouldRender = keepMounted || hiddenUntilFound || mounted || open; 2715 return { 2716 height: renderedDimensions.height, 2717 props: { 2718 ...shouldPersistHiddenTransitionStyles ? { 2719 [CollapsiblePanelDataAttributes.startingStyle]: "" 2720 } : void 0, 2721 hidden, 2722 id: idParam 2723 }, 2724 ref: mergedPanelRef, 2725 shouldPreventOpenAnimation, 2726 shouldRender, 2727 transitionStatus: panelTransitionStatus, 2728 width: renderedDimensions.width 2729 }; 2730 } 2731 function getDimensions(element) { 2732 return { 2733 height: element.scrollHeight, 2734 width: element.scrollWidth 2735 }; 2736 } 2737 function getAnimationType(element, hasSuppressedMountAnimation = false) { 2738 const panelStyles = getWindow(element).getComputedStyle(element); 2739 const hasAnimation = (panelStyles.animationName.split(",").map((name) => name.trim()).some((name) => name !== "" && name !== "none") || hasSuppressedMountAnimation) && hasNonZeroDuration(panelStyles.animationDuration); 2740 const hasTransition = hasNonZeroDuration(panelStyles.transitionDuration); 2741 if (hasAnimation && hasTransition) { 2742 if (true) { 2743 warn("CSS transitions and CSS animations both detected on Collapsible or Accordion panel.", "Only one of either animation type should be used."); 2744 } 2745 return "css-transition"; 2746 } 2747 if (hasTransition) { 2748 return "css-transition"; 2749 } 2750 if (hasAnimation) { 2751 return "css-animation"; 2752 } 2753 return "none"; 2754 } 2755 function hasNonZeroDuration(value) { 2756 return value.split(",").map((part) => part.trim()).some((part) => part !== "" && Number.parseFloat(part) > 0); 2757 } 2758 function setTemporaryStyle(element, property, value) { 2759 const previousValue = element.style.getPropertyValue(property); 2760 const previousPriority = element.style.getPropertyPriority(property); 2761 element.style.setProperty(property, value); 2762 return () => { 2763 if (previousValue === "") { 2764 element.style.removeProperty(property); 2765 return; 2766 } 2767 element.style.setProperty(property, previousValue, previousPriority); 2768 }; 2769 } 2770 function resetLayoutStyles(element) { 2771 const originalLayoutStyles = { 2772 "justify-content": element.style.justifyContent, 2773 "align-items": element.style.alignItems, 2774 "align-content": element.style.alignContent, 2775 "justify-items": element.style.justifyItems 2776 }; 2777 Object.keys(originalLayoutStyles).forEach((key) => { 2778 element.style.setProperty(key, "initial", "important"); 2779 }); 2780 function restoreLayoutStyles() { 2781 Object.entries(originalLayoutStyles).forEach(([key, value]) => { 2782 if (value === "") { 2783 element.style.removeProperty(key); 2784 return; 2785 } 2786 element.style.setProperty(key, value); 2787 }); 2788 } 2789 const frame = AnimationFrame.request(restoreLayoutStyles); 2790 return () => { 2791 AnimationFrame.cancel(frame); 2792 restoreLayoutStyles(); 2793 }; 2794 } 2795 2796 // node_modules/@base-ui/utils/useOnFirstRender.mjs 2797 var React19 = __toESM(require_react(), 1); 2798 function useOnFirstRender(fn) { 2799 const ref = React19.useRef(true); 2800 if (ref.current) { 2801 ref.current = false; 2802 fn(); 2803 } 2804 } 2805 2806 // node_modules/@base-ui/utils/platform/parts.mjs 2807 var parts_exports = {}; 2808 __export(parts_exports, { 2809 engine: () => engine_exports, 2810 env: () => env_exports, 2811 os: () => os_exports, 2812 screenReader: () => screen_reader_exports 2813 }); 2814 2815 // node_modules/@base-ui/utils/platform/os.mjs 2816 var os_exports = {}; 2817 __export(os_exports, { 2818 android: () => android, 2819 apple: () => apple, 2820 ios: () => ios, 2821 linux: () => linux, 2822 mac: () => mac, 2823 windows: () => windows 2824 }); 2825 2826 // node_modules/@base-ui/utils/platform/shared.mjs 2827 function readRawData() { 2828 if (typeof navigator === "undefined") { 2829 return { 2830 userAgent: "", 2831 platform: "", 2832 maxTouchPoints: 0 2833 }; 2834 } 2835 if (true) { 2836 const uaData = navigator.userAgentData; 2837 if (uaData && Array.isArray(uaData.brands)) { 2838 return { 2839 userAgent: uaData.brands.map(({ 2840 brand, 2841 version: version2 2842 }) => `$brand}/$version2}`).join(" "), 2843 platform: uaData.platform ?? navigator.platform ?? "", 2844 maxTouchPoints: navigator.maxTouchPoints ?? 0 2845 }; 2846 } 2847 } 2848 return { 2849 userAgent: navigator.userAgent, 2850 platform: navigator.platform ?? "", 2851 maxTouchPoints: navigator.maxTouchPoints ?? 0 2852 }; 2853 } 2854 var { 2855 userAgent, 2856 platform, 2857 maxTouchPoints 2858 } = readRawData(); 2859 var lowerUserAgent = userAgent.toLowerCase(); 2860 var lowerPlatform = platform.toLowerCase(); 2861 2862 // node_modules/@base-ui/utils/platform/os.mjs 2863 var ios = /^i(os$|p)/.test(lowerPlatform) || lowerPlatform === "macintel" && maxTouchPoints > 1; 2864 var ANDROID_STRING = "android"; 2865 var android = lowerPlatform === ANDROID_STRING || lowerUserAgent.includes(ANDROID_STRING); 2866 var mac = !ios && lowerPlatform.startsWith("mac"); 2867 var windows = lowerPlatform.startsWith("win"); 2868 var linux = !android && /^(linux|chrome os)/.test(lowerPlatform); 2869 var apple = mac || ios; 2870 2871 // node_modules/@base-ui/utils/platform/engine.mjs 2872 var engine_exports = {}; 2873 __export(engine_exports, { 2874 blink: () => blink, 2875 gecko: () => gecko, 2876 webkit: () => webkit 2877 }); 2878 var webkit = typeof CSS !== "undefined" && !!CSS.supports?.("-webkit-backdrop-filter:none"); 2879 var gecko = !webkit && lowerUserAgent.includes("firefox"); 2880 var blink = !webkit && lowerUserAgent.includes("chrom"); 2881 2882 // node_modules/@base-ui/utils/platform/screen-reader.mjs 2883 var screen_reader_exports = {}; 2884 __export(screen_reader_exports, { 2885 voiceOver: () => voiceOver 2886 }); 2887 var voiceOver = apple; 2888 2889 // node_modules/@base-ui/utils/platform/env.mjs 2890 var env_exports = {}; 2891 __export(env_exports, { 2892 jsdom: () => jsdom 2893 }); 2894 var jsdom = /jsdom|happydom/.test(lowerUserAgent); 2895 2896 // node_modules/@base-ui/utils/useTimeout.mjs 2897 var EMPTY3 = 0; 2898 var Timeout = class _Timeout { 2899 static create() { 2900 return new _Timeout(); 2901 } 2902 currentId = EMPTY3; 2903 /** 2904 * Executes `fn` after `delay`, clearing any previously scheduled call. 2905 */ 2906 start(delay, fn) { 2907 this.clear(); 2908 this.currentId = setTimeout(() => { 2909 this.currentId = EMPTY3; 2910 fn(); 2911 }, delay); 2912 } 2913 isStarted() { 2914 return this.currentId !== EMPTY3; 2915 } 2916 clear = () => { 2917 if (this.currentId !== EMPTY3) { 2918 clearTimeout(this.currentId); 2919 this.currentId = EMPTY3; 2920 } 2921 }; 2922 disposeEffect = () => { 2923 return this.clear; 2924 }; 2925 }; 2926 function useTimeout() { 2927 const timeout = useRefWithInit(Timeout.create).current; 2928 useOnMount(timeout.disposeEffect); 2929 return timeout; 2930 } 2931 2932 // node_modules/@base-ui/utils/useScrollLock.mjs 2933 var originalHtmlStyles = {}; 2934 var originalBodyStyles = {}; 2935 var originalHtmlScrollBehavior = ""; 2936 function hasInsetScrollbars(referenceElement) { 2937 if (typeof document === "undefined") { 2938 return false; 2939 } 2940 const doc = ownerDocument(referenceElement); 2941 const win = getWindow(doc); 2942 return win.innerWidth - doc.documentElement.clientWidth > 0; 2943 } 2944 function supportsStableScrollbarGutter(referenceElement) { 2945 const supported = typeof CSS !== "undefined" && CSS.supports && CSS.supports("scrollbar-gutter", "stable"); 2946 if (!supported || typeof document === "undefined") { 2947 return false; 2948 } 2949 const doc = ownerDocument(referenceElement); 2950 const html = doc.documentElement; 2951 const body = doc.body; 2952 const scrollContainer = isOverflowElement(html) ? html : body; 2953 const originalScrollContainerOverflowY = scrollContainer.style.overflowY; 2954 const originalHtmlStyleGutter = html.style.scrollbarGutter; 2955 html.style.scrollbarGutter = "stable"; 2956 scrollContainer.style.overflowY = "scroll"; 2957 const before = scrollContainer.offsetWidth; 2958 scrollContainer.style.overflowY = "hidden"; 2959 const after = scrollContainer.offsetWidth; 2960 scrollContainer.style.overflowY = originalScrollContainerOverflowY; 2961 html.style.scrollbarGutter = originalHtmlStyleGutter; 2962 return before === after; 2963 } 2964 function preventScrollOverlayScrollbars(referenceElement) { 2965 const doc = ownerDocument(referenceElement); 2966 const html = doc.documentElement; 2967 const body = doc.body; 2968 const elementToLock = isOverflowElement(html) ? html : body; 2969 const originalElementToLockStyles = { 2970 overflowY: elementToLock.style.overflowY, 2971 overflowX: elementToLock.style.overflowX 2972 }; 2973 Object.assign(elementToLock.style, { 2974 overflowY: "hidden", 2975 overflowX: "hidden" 2976 }); 2977 return () => { 2978 Object.assign(elementToLock.style, originalElementToLockStyles); 2979 }; 2980 } 2981 function preventScrollInsetScrollbars(referenceElement) { 2982 const doc = ownerDocument(referenceElement); 2983 const html = doc.documentElement; 2984 const body = doc.body; 2985 const win = getWindow(html); 2986 let scrollTop = 0; 2987 let scrollLeft = 0; 2988 let updateGutterOnly = false; 2989 const resizeFrame = AnimationFrame.create(); 2990 if (parts_exports.engine.webkit && (win.visualViewport?.scale ?? 1) !== 1) { 2991 return () => { 2992 }; 2993 } 2994 function lockScroll() { 2995 const htmlStyles = win.getComputedStyle(html); 2996 const bodyStyles = win.getComputedStyle(body); 2997 const htmlScrollbarGutterValue = htmlStyles.scrollbarGutter || ""; 2998 const hasBothEdges = htmlScrollbarGutterValue.includes("both-edges"); 2999 const scrollbarGutterValue = hasBothEdges ? "stable both-edges" : "stable"; 3000 scrollTop = html.scrollTop; 3001 scrollLeft = html.scrollLeft; 3002 originalHtmlStyles = { 3003 scrollbarGutter: html.style.scrollbarGutter, 3004 overflowY: html.style.overflowY, 3005 overflowX: html.style.overflowX 3006 }; 3007 originalHtmlScrollBehavior = html.style.scrollBehavior; 3008 originalBodyStyles = { 3009 position: body.style.position, 3010 height: body.style.height, 3011 width: body.style.width, 3012 boxSizing: body.style.boxSizing, 3013 overflowY: body.style.overflowY, 3014 overflowX: body.style.overflowX, 3015 scrollBehavior: body.style.scrollBehavior 3016 }; 3017 const isScrollableY = html.scrollHeight > html.clientHeight; 3018 const isScrollableX = html.scrollWidth > html.clientWidth; 3019 const hasConstantOverflowY = htmlStyles.overflowY === "scroll" || bodyStyles.overflowY === "scroll"; 3020 const hasConstantOverflowX = htmlStyles.overflowX === "scroll" || bodyStyles.overflowX === "scroll"; 3021 const scrollbarWidth = Math.max(0, win.innerWidth - body.clientWidth); 3022 const scrollbarHeight = Math.max(0, win.innerHeight - body.clientHeight); 3023 const marginY = parseFloat(bodyStyles.marginTop) + parseFloat(bodyStyles.marginBottom); 3024 const marginX = parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight); 3025 const elementToLock = isOverflowElement(html) ? html : body; 3026 updateGutterOnly = supportsStableScrollbarGutter(referenceElement); 3027 if (updateGutterOnly) { 3028 html.style.scrollbarGutter = scrollbarGutterValue; 3029 elementToLock.style.overflowY = "hidden"; 3030 elementToLock.style.overflowX = "hidden"; 3031 return; 3032 } 3033 Object.assign(html.style, { 3034 scrollbarGutter: scrollbarGutterValue, 3035 overflowY: "hidden", 3036 overflowX: "hidden" 3037 }); 3038 if (isScrollableY || hasConstantOverflowY) { 3039 html.style.overflowY = "scroll"; 3040 } 3041 if (isScrollableX || hasConstantOverflowX) { 3042 html.style.overflowX = "scroll"; 3043 } 3044 Object.assign(body.style, { 3045 position: "relative", 3046 height: marginY || scrollbarHeight ? `calc(100dvh - $marginY + scrollbarHeight}px)` : "100dvh", 3047 width: marginX || scrollbarWidth ? `calc(100vw - $marginX + scrollbarWidth}px)` : "100vw", 3048 boxSizing: "border-box", 3049 overflow: "hidden", 3050 scrollBehavior: "unset" 3051 }); 3052 body.scrollTop = scrollTop; 3053 body.scrollLeft = scrollLeft; 3054 html.setAttribute("data-base-ui-scroll-locked", ""); 3055 html.style.scrollBehavior = "unset"; 3056 } 3057 function cleanup() { 3058 Object.assign(html.style, originalHtmlStyles); 3059 Object.assign(body.style, originalBodyStyles); 3060 if (!updateGutterOnly) { 3061 html.scrollTop = scrollTop; 3062 html.scrollLeft = scrollLeft; 3063 html.removeAttribute("data-base-ui-scroll-locked"); 3064 html.style.scrollBehavior = originalHtmlScrollBehavior; 3065 } 3066 } 3067 function handleResize() { 3068 cleanup(); 3069 resizeFrame.request(lockScroll); 3070 } 3071 lockScroll(); 3072 const unsubscribeResize = addEventListener(win, "resize", handleResize); 3073 return () => { 3074 resizeFrame.cancel(); 3075 cleanup(); 3076 if (typeof win.removeEventListener === "function") { 3077 unsubscribeResize(); 3078 } 3079 }; 3080 } 3081 var ScrollLocker = class { 3082 lockCount = 0; 3083 restore = null; 3084 timeoutLock = Timeout.create(); 3085 timeoutUnlock = Timeout.create(); 3086 acquire(referenceElement) { 3087 this.lockCount += 1; 3088 if (this.lockCount === 1 && this.restore === null) { 3089 this.timeoutLock.start(0, () => this.lock(referenceElement)); 3090 } 3091 return this.release; 3092 } 3093 release = () => { 3094 this.lockCount -= 1; 3095 if (this.lockCount === 0 && this.restore) { 3096 this.timeoutUnlock.start(0, this.unlock); 3097 } 3098 }; 3099 unlock = () => { 3100 if (this.lockCount === 0 && this.restore) { 3101 this.restore?.(); 3102 this.restore = null; 3103 } 3104 }; 3105 lock(referenceElement) { 3106 if (this.lockCount === 0 || this.restore !== null) { 3107 return; 3108 } 3109 const doc = ownerDocument(referenceElement); 3110 const html = doc.documentElement; 3111 const htmlOverflowY = getWindow(html).getComputedStyle(html).overflowY; 3112 if (htmlOverflowY === "hidden" || htmlOverflowY === "clip") { 3113 this.restore = NOOP; 3114 return; 3115 } 3116 const hasOverlayScrollbars = parts_exports.os.ios || !hasInsetScrollbars(referenceElement); 3117 this.restore = hasOverlayScrollbars ? preventScrollOverlayScrollbars(referenceElement) : preventScrollInsetScrollbars(referenceElement); 3118 } 3119 }; 3120 var SCROLL_LOCKER = new ScrollLocker(); 3121 function useScrollLock(enabled = true, referenceElement = null) { 3122 useIsoLayoutEffect(() => { 3123 if (!enabled) { 3124 return void 0; 3125 } 3126 return SCROLL_LOCKER.acquire(referenceElement); 3127 }, [enabled, referenceElement]); 3128 } 3129 3130 // node_modules/@base-ui/react/floating-ui-react/components/FloatingDelayGroup.mjs 3131 var React20 = __toESM(require_react(), 1); 3132 3133 // node_modules/@base-ui/react/floating-ui-react/utils/event.mjs 3134 function stopEvent(event) { 3135 event.preventDefault(); 3136 event.stopPropagation(); 3137 } 3138 function isReactEvent(event) { 3139 return "nativeEvent" in event; 3140 } 3141 function isVirtualClick(event) { 3142 if (event.pointerType === "" && event.isTrusted) { 3143 return true; 3144 } 3145 if (parts_exports.os.android && event.pointerType) { 3146 return event.type === "click" && event.buttons === 1; 3147 } 3148 return event.detail === 0 && !event.pointerType; 3149 } 3150 function isVirtualPointerEvent(event) { 3151 if (parts_exports.env.jsdom) { 3152 return false; 3153 } 3154 return !parts_exports.os.android && event.width === 0 && event.height === 0 || parts_exports.os.android && event.width === 1 && event.height === 1 && event.pressure === 0 && event.detail === 0 && event.pointerType === "mouse" || // iOS VoiceOver returns 0.333• for width/height. 3155 event.width < 1 && event.height < 1 && event.pressure === 0 && event.detail === 0 && event.pointerType === "touch"; 3156 } 3157 function isMouseLikePointerType(pointerType, strict) { 3158 const values = ["mouse", "pen"]; 3159 if (!strict) { 3160 values.push("", void 0); 3161 } 3162 return values.includes(pointerType); 3163 } 3164 function isClickLikeEvent(event) { 3165 const type = event.type; 3166 return type === "click" || type === "mousedown" || type === "keydown" || type === "keyup"; 3167 } 3168 3169 // node_modules/@base-ui/react/floating-ui-react/utils/constants.mjs 3170 var FOCUSABLE_ATTRIBUTE = "data-base-ui-focusable"; 3171 var TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])"; 3172 3173 // node_modules/@base-ui/react/internals/shadowDom.mjs 3174 function activeElement(doc) { 3175 let element = doc.activeElement; 3176 while (element?.shadowRoot?.activeElement != null) { 3177 element = element.shadowRoot.activeElement; 3178 } 3179 return element; 3180 } 3181 function contains(parent, child) { 3182 if (!parent || !child) { 3183 return false; 3184 } 3185 const rootNode = child.getRootNode?.(); 3186 if (parent.contains(child)) { 3187 return true; 3188 } 3189 if (rootNode && isShadowRoot(rootNode)) { 3190 let next = child; 3191 while (next) { 3192 if (parent === next) { 3193 return true; 3194 } 3195 next = next.parentNode || next.host; 3196 } 3197 } 3198 return false; 3199 } 3200 function getTarget(event) { 3201 if ("composedPath" in event) { 3202 return event.composedPath()[0]; 3203 } 3204 return event.target; 3205 } 3206 3207 // node_modules/@base-ui/react/floating-ui-react/utils/element.mjs 3208 function isTargetInsideEnabledTrigger(target, triggerElements) { 3209 if (!isElement(target)) { 3210 return false; 3211 } 3212 const targetElement = target; 3213 if (triggerElements.hasElement(targetElement)) { 3214 return !targetElement.hasAttribute("data-trigger-disabled"); 3215 } 3216 for (const [, trigger] of triggerElements.entries()) { 3217 if (contains(trigger, targetElement)) { 3218 return !trigger.hasAttribute("data-trigger-disabled"); 3219 } 3220 } 3221 return false; 3222 } 3223 function isEventTargetWithin(event, node) { 3224 if (node == null) { 3225 return false; 3226 } 3227 if ("composedPath" in event) { 3228 return event.composedPath().includes(node); 3229 } 3230 const eventAgain = event; 3231 return eventAgain.target != null && node.contains(eventAgain.target); 3232 } 3233 function isRootElement(element) { 3234 return element.matches("html,body"); 3235 } 3236 function isTypeableElement(element) { 3237 return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR); 3238 } 3239 function isInteractiveElement(element) { 3240 return element?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),$TYPEABLE_SELECTOR}`) != null; 3241 } 3242 function isTypeableCombobox(element) { 3243 if (!element) { 3244 return false; 3245 } 3246 return element.getAttribute("role") === "combobox" && isTypeableElement(element); 3247 } 3248 function matchesFocusVisible(element) { 3249 if (!element || parts_exports.env.jsdom) { 3250 return true; 3251 } 3252 try { 3253 return element.matches(":focus-visible"); 3254 } catch (_e) { 3255 return true; 3256 } 3257 } 3258 function getFloatingFocusElement(floatingElement) { 3259 if (!floatingElement) { 3260 return null; 3261 } 3262 return floatingElement.hasAttribute(FOCUSABLE_ATTRIBUTE) ? floatingElement : floatingElement.querySelector(`[$FOCUSABLE_ATTRIBUTE}]`) || floatingElement; 3263 } 3264 3265 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverShared.mjs 3266 function resolveValue(value, pointerType) { 3267 if (pointerType != null && !isMouseLikePointerType(pointerType)) { 3268 return 0; 3269 } 3270 if (typeof value === "function") { 3271 return value(); 3272 } 3273 return value; 3274 } 3275 function getDelay(value, prop, pointerType) { 3276 const result = resolveValue(value, pointerType); 3277 if (typeof result === "number") { 3278 return result; 3279 } 3280 return result?.[prop]; 3281 } 3282 function getRestMs(value) { 3283 if (typeof value === "function") { 3284 return value(); 3285 } 3286 return value; 3287 } 3288 function isClickLikeOpenEvent(openEventType, interactedInside) { 3289 return interactedInside || openEventType === "click" || openEventType === "mousedown"; 3290 } 3291 function isHoverOpenEvent(openEventType) { 3292 return openEventType?.includes("mouse") && openEventType !== "mousedown"; 3293 } 3294 3295 // node_modules/@base-ui/react/floating-ui-react/components/FloatingDelayGroup.mjs 3296 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1); 3297 var FloatingDelayGroupContext = /* @__PURE__ */ React20.createContext({ 3298 hasProvider: false, 3299 timeoutMs: 0, 3300 delayRef: { 3301 current: 0 3302 }, 3303 initialDelayRef: { 3304 current: 0 3305 }, 3306 timeout: new Timeout(), 3307 currentIdRef: { 3308 current: null 3309 }, 3310 currentContextRef: { 3311 current: null 3312 } 3313 }); 3314 if (true) FloatingDelayGroupContext.displayName = "FloatingDelayGroupContext"; 3315 function resetDelayRef(delayRef, initialDelayRef) { 3316 delayRef.current = initialDelayRef.current; 3317 } 3318 function FloatingDelayGroup(props) { 3319 const { 3320 children, 3321 delay, 3322 timeoutMs = 0 3323 } = props; 3324 const delayRef = React20.useRef(delay); 3325 const initialDelayRef = React20.useRef(delay); 3326 const currentIdRef = React20.useRef(null); 3327 const currentContextRef = React20.useRef(null); 3328 const timeout = useTimeout(); 3329 useIsoLayoutEffect(() => { 3330 initialDelayRef.current = delay; 3331 if (!currentIdRef.current) { 3332 delayRef.current = delay; 3333 return; 3334 } 3335 delayRef.current = { 3336 open: getDelay(delayRef.current, "open"), 3337 close: getDelay(delay, "close") 3338 }; 3339 }, [delay, currentIdRef, delayRef, initialDelayRef]); 3340 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FloatingDelayGroupContext.Provider, { 3341 value: React20.useMemo(() => ({ 3342 hasProvider: true, 3343 delayRef, 3344 initialDelayRef, 3345 currentIdRef, 3346 timeoutMs, 3347 currentContextRef, 3348 timeout 3349 }), [timeoutMs, timeout]), 3350 children 3351 }); 3352 } 3353 function useDelayGroup(context, options = { 3354 open: false 3355 }) { 3356 const { 3357 open 3358 } = options; 3359 const store = "rootStore" in context ? context.rootStore : context; 3360 const floatingId = store.useState("floatingId"); 3361 const groupContext = React20.useContext(FloatingDelayGroupContext); 3362 const { 3363 currentIdRef, 3364 delayRef, 3365 timeoutMs, 3366 initialDelayRef, 3367 currentContextRef, 3368 hasProvider, 3369 timeout 3370 } = groupContext; 3371 const [isInstantPhase, setIsInstantPhase] = React20.useState(false); 3372 const openRef = React20.useRef(open); 3373 const isUnmountedRef = React20.useRef(false); 3374 useIsoLayoutEffect(() => { 3375 openRef.current = open; 3376 }, [open]); 3377 useIsoLayoutEffect(() => { 3378 return () => { 3379 isUnmountedRef.current = true; 3380 }; 3381 }, []); 3382 useIsoLayoutEffect(() => { 3383 function unset() { 3384 if (!isUnmountedRef.current) { 3385 setIsInstantPhase(false); 3386 } 3387 currentContextRef.current?.setIsInstantPhase(false); 3388 currentIdRef.current = null; 3389 currentContextRef.current = null; 3390 delayRef.current = initialDelayRef.current; 3391 timeout.clear(); 3392 } 3393 if (!currentIdRef.current) { 3394 return void 0; 3395 } 3396 if (!open && currentIdRef.current === floatingId) { 3397 setIsInstantPhase(false); 3398 if (timeoutMs) { 3399 const closingId = floatingId; 3400 timeout.start(timeoutMs, () => { 3401 if (store.select("open") || currentIdRef.current && currentIdRef.current !== closingId) { 3402 return; 3403 } 3404 unset(); 3405 }); 3406 return () => { 3407 if (openRef.current || currentIdRef.current !== closingId) { 3408 timeout.clear(); 3409 } 3410 }; 3411 } 3412 unset(); 3413 } 3414 return void 0; 3415 }, [open, floatingId, currentIdRef, delayRef, timeoutMs, initialDelayRef, currentContextRef, timeout, store]); 3416 useIsoLayoutEffect(() => { 3417 if (!open) { 3418 return; 3419 } 3420 const prevContext = currentContextRef.current; 3421 const prevId = currentIdRef.current; 3422 timeout.clear(); 3423 currentContextRef.current = { 3424 onOpenChange: store.setOpen, 3425 setIsInstantPhase 3426 }; 3427 currentIdRef.current = floatingId; 3428 delayRef.current = { 3429 open: 0, 3430 close: getDelay(initialDelayRef.current, "close") 3431 }; 3432 if (prevId !== null && prevId !== floatingId) { 3433 setIsInstantPhase(true); 3434 prevContext?.setIsInstantPhase(true); 3435 prevContext?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.none)); 3436 } else { 3437 setIsInstantPhase(false); 3438 prevContext?.setIsInstantPhase(false); 3439 } 3440 }, [open, floatingId, store, currentIdRef, delayRef, initialDelayRef, currentContextRef, timeout]); 3441 useIsoLayoutEffect(() => { 3442 return () => { 3443 if (currentIdRef.current === floatingId) { 3444 currentContextRef.current = null; 3445 if (!openRef.current) { 3446 return; 3447 } 3448 currentIdRef.current = null; 3449 resetDelayRef(delayRef, initialDelayRef); 3450 timeout.clear(); 3451 } 3452 }; 3453 }, [currentContextRef, currentIdRef, delayRef, floatingId, initialDelayRef, timeout]); 3454 return React20.useMemo(() => ({ 3455 hasProvider, 3456 delayRef, 3457 isInstantPhase 3458 }), [hasProvider, delayRef, isInstantPhase]); 3459 } 3460 3461 // node_modules/@base-ui/react/floating-ui-react/components/FloatingFocusManager.mjs 3462 var React24 = __toESM(require_react(), 1); 3463 3464 // node_modules/@base-ui/utils/mergeCleanups.mjs 3465 function mergeCleanups(...cleanups) { 3466 return () => { 3467 for (let i2 = 0; i2 < cleanups.length; i2 += 1) { 3468 const cleanup = cleanups[i2]; 3469 if (cleanup) { 3470 cleanup(); 3471 } 3472 } 3473 }; 3474 } 3475 3476 // node_modules/@base-ui/react/utils/FocusGuard.mjs 3477 var React21 = __toESM(require_react(), 1); 3478 3479 // node_modules/@base-ui/utils/visuallyHidden.mjs 3480 var visuallyHiddenBase = { 3481 clipPath: "inset(50%)", 3482 overflow: "hidden", 3483 whiteSpace: "nowrap", 3484 border: 0, 3485 padding: 0, 3486 width: 1, 3487 height: 1, 3488 margin: -1 3489 }; 3490 var visuallyHidden = { 3491 ...visuallyHiddenBase, 3492 position: "fixed", 3493 top: 0, 3494 left: 0 3495 }; 3496 var visuallyHiddenInput = { 3497 ...visuallyHiddenBase, 3498 position: "absolute" 3499 }; 3500 3501 // node_modules/@base-ui/react/utils/FocusGuard.mjs 3502 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1); 3503 var FocusGuard = /* @__PURE__ */ React21.forwardRef(function FocusGuard2(props, ref) { 3504 const [role, setRole] = React21.useState(); 3505 useIsoLayoutEffect(() => { 3506 if (parts_exports.screenReader.voiceOver && parts_exports.engine.webkit) { 3507 setRole("button"); 3508 } 3509 }, []); 3510 const restProps = { 3511 tabIndex: 0, 3512 // Role is only for VoiceOver 3513 role 3514 }; 3515 return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { 3516 ...props, 3517 ref, 3518 style: visuallyHidden, 3519 "aria-hidden": role ? void 0 : true, 3520 ...restProps, 3521 "data-base-ui-focus-guard": "" 3522 }); 3523 }); 3524 if (true) FocusGuard.displayName = "FocusGuard"; 3525 3526 // node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs 3527 var sides = ["top", "right", "bottom", "left"]; 3528 var min = Math.min; 3529 var max = Math.max; 3530 var round = Math.round; 3531 var floor = Math.floor; 3532 var createCoords = (v2) => ({ 3533 x: v2, 3534 y: v2 3535 }); 3536 var oppositeSideMap = { 3537 left: "right", 3538 right: "left", 3539 bottom: "top", 3540 top: "bottom" 3541 }; 3542 function clamp(start, value, end) { 3543 return max(start, min(value, end)); 3544 } 3545 function evaluate(value, param) { 3546 return typeof value === "function" ? value(param) : value; 3547 } 3548 function getSide(placement) { 3549 return placement.split("-")[0]; 3550 } 3551 function getAlignment(placement) { 3552 return placement.split("-")[1]; 3553 } 3554 function getOppositeAxis(axis) { 3555 return axis === "x" ? "y" : "x"; 3556 } 3557 function getAxisLength(axis) { 3558 return axis === "y" ? "height" : "width"; 3559 } 3560 function getSideAxis(placement) { 3561 const firstChar = placement[0]; 3562 return firstChar === "t" || firstChar === "b" ? "y" : "x"; 3563 } 3564 function getAlignmentAxis(placement) { 3565 return getOppositeAxis(getSideAxis(placement)); 3566 } 3567 function getAlignmentSides(placement, rects, rtl) { 3568 if (rtl === void 0) { 3569 rtl = false; 3570 } 3571 const alignment = getAlignment(placement); 3572 const alignmentAxis = getAlignmentAxis(placement); 3573 const length = getAxisLength(alignmentAxis); 3574 let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top"; 3575 if (rects.reference[length] > rects.floating[length]) { 3576 mainAlignmentSide = getOppositePlacement(mainAlignmentSide); 3577 } 3578 return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)]; 3579 } 3580 function getExpandedPlacements(placement) { 3581 const oppositePlacement = getOppositePlacement(placement); 3582 return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)]; 3583 } 3584 function getOppositeAlignmentPlacement(placement) { 3585 return placement.includes("start") ? placement.replace("start", "end") : placement.replace("end", "start"); 3586 } 3587 var lrPlacement = ["left", "right"]; 3588 var rlPlacement = ["right", "left"]; 3589 var tbPlacement = ["top", "bottom"]; 3590 var btPlacement = ["bottom", "top"]; 3591 function getSideList(side, isStart, rtl) { 3592 switch (side) { 3593 case "top": 3594 case "bottom": 3595 if (rtl) return isStart ? rlPlacement : lrPlacement; 3596 return isStart ? lrPlacement : rlPlacement; 3597 case "left": 3598 case "right": 3599 return isStart ? tbPlacement : btPlacement; 3600 default: 3601 return []; 3602 } 3603 } 3604 function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) { 3605 const alignment = getAlignment(placement); 3606 let list = getSideList(getSide(placement), direction === "start", rtl); 3607 if (alignment) { 3608 list = list.map((side) => side + "-" + alignment); 3609 if (flipAlignment) { 3610 list = list.concat(list.map(getOppositeAlignmentPlacement)); 3611 } 3612 } 3613 return list; 3614 } 3615 function getOppositePlacement(placement) { 3616 const side = getSide(placement); 3617 return oppositeSideMap[side] + placement.slice(side.length); 3618 } 3619 function expandPaddingObject(padding) { 3620 return { 3621 top: 0, 3622 right: 0, 3623 bottom: 0, 3624 left: 0, 3625 ...padding 3626 }; 3627 } 3628 function getPaddingObject(padding) { 3629 return typeof padding !== "number" ? expandPaddingObject(padding) : { 3630 top: padding, 3631 right: padding, 3632 bottom: padding, 3633 left: padding 3634 }; 3635 } 3636 function rectToClientRect(rect) { 3637 const { 3638 x: x2, 3639 y: y2, 3640 width, 3641 height 3642 } = rect; 3643 return { 3644 width, 3645 height, 3646 top: y2, 3647 left: x2, 3648 right: x2 + width, 3649 bottom: y2 + height, 3650 x: x2, 3651 y: y2 3652 }; 3653 } 3654 3655 // node_modules/@base-ui/react/floating-ui-react/utils/composite.mjs 3656 function isHiddenByStyles(styles) { 3657 return styles.visibility === "hidden" || styles.visibility === "collapse"; 3658 } 3659 function isElementVisible(element, styles = element ? getComputedStyle2(element) : null) { 3660 if (!element || !element.isConnected || !styles || isHiddenByStyles(styles)) { 3661 return false; 3662 } 3663 if (typeof element.checkVisibility === "function") { 3664 return element.checkVisibility(); 3665 } 3666 return styles.display !== "none" && styles.display !== "contents"; 3667 } 3668 3669 // node_modules/@base-ui/react/floating-ui-react/utils/tabbable.mjs 3670 var CANDIDATE_SELECTOR = 'a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]'; 3671 function getParentElement(element) { 3672 const assignedSlot = element.assignedSlot; 3673 if (assignedSlot) { 3674 return assignedSlot; 3675 } 3676 if (element.parentElement) { 3677 return element.parentElement; 3678 } 3679 const rootNode = element.getRootNode(); 3680 return isShadowRoot(rootNode) ? rootNode.host : null; 3681 } 3682 function getDetailsSummary(details) { 3683 for (const child of Array.from(details.children)) { 3684 if (getNodeName(child) === "summary") { 3685 return child; 3686 } 3687 } 3688 return null; 3689 } 3690 function isWithinOpenDetailsSummary(element, details) { 3691 const summary = getDetailsSummary(details); 3692 return !!summary && (element === summary || contains(summary, element)); 3693 } 3694 function isFocusableCandidate(element) { 3695 const nodeName = element ? getNodeName(element) : ""; 3696 return element != null && element.matches(CANDIDATE_SELECTOR) && (nodeName !== "summary" || element.parentElement != null && getNodeName(element.parentElement) === "details" && getDetailsSummary(element.parentElement) === element) && (nodeName !== "details" || getDetailsSummary(element) == null) && (nodeName !== "input" || element.type !== "hidden"); 3697 } 3698 function isFocusableElement(element) { 3699 if (!isFocusableCandidate(element) || !element.isConnected || element.matches(":disabled")) { 3700 return false; 3701 } 3702 for (let current = element; current; current = getParentElement(current)) { 3703 const isAncestor = current !== element; 3704 const isSlot = getNodeName(current) === "slot"; 3705 if (current.hasAttribute("inert")) { 3706 return false; 3707 } 3708 if (isAncestor && getNodeName(current) === "details" && !current.open && !isWithinOpenDetailsSummary(element, current) || current.hasAttribute("hidden") || !isSlot && !isVisibleInTabbableTree(current, isAncestor)) { 3709 return false; 3710 } 3711 } 3712 return true; 3713 } 3714 function isVisibleInTabbableTree(element, isAncestor) { 3715 const styles = getComputedStyle2(element); 3716 if (!isAncestor) { 3717 return isElementVisible(element, styles); 3718 } 3719 return styles.display !== "none"; 3720 } 3721 function getTabIndex(element) { 3722 const tabIndex = element.tabIndex; 3723 if (tabIndex < 0) { 3724 const nodeName = getNodeName(element); 3725 if (nodeName === "details" || nodeName === "audio" || nodeName === "video" || isHTMLElement(element) && element.isContentEditable) { 3726 return 0; 3727 } 3728 } 3729 return tabIndex; 3730 } 3731 function getNamedRadioInput(element) { 3732 if (getNodeName(element) !== "input") { 3733 return null; 3734 } 3735 const input = element; 3736 return input.type === "radio" && input.name !== "" ? input : null; 3737 } 3738 function isTabbableRadio(element, candidates) { 3739 const input = getNamedRadioInput(element); 3740 if (!input) { 3741 return true; 3742 } 3743 const checkedRadio = candidates.find((candidate) => { 3744 const radio = getNamedRadioInput(candidate); 3745 return radio?.name === input.name && radio.form === input.form && radio.checked; 3746 }); 3747 if (checkedRadio) { 3748 return checkedRadio === input; 3749 } 3750 return candidates.find((candidate) => { 3751 const radio = getNamedRadioInput(candidate); 3752 return radio?.name === input.name && radio.form === input.form; 3753 }) === input; 3754 } 3755 function getComposedChildren(container) { 3756 if (isHTMLElement(container) && getNodeName(container) === "slot") { 3757 const assignedElements = container.assignedElements({ 3758 flatten: true 3759 }); 3760 if (assignedElements.length > 0) { 3761 return assignedElements; 3762 } 3763 } 3764 if (isHTMLElement(container) && container.shadowRoot) { 3765 return Array.from(container.shadowRoot.children); 3766 } 3767 return Array.from(container.children); 3768 } 3769 function appendCandidates(container, list) { 3770 getComposedChildren(container).forEach((child) => { 3771 if (isFocusableCandidate(child)) { 3772 list.push(child); 3773 } 3774 appendCandidates(child, list); 3775 }); 3776 } 3777 function appendMatchingElements(container, selector2, list) { 3778 getComposedChildren(container).forEach((child) => { 3779 if (isHTMLElement(child) && child.matches(selector2)) { 3780 list.push(child); 3781 } 3782 appendMatchingElements(child, selector2, list); 3783 }); 3784 } 3785 function isTabbable(element) { 3786 return isFocusableElement(element) && getTabIndex(element) >= 0; 3787 } 3788 function focusable(container) { 3789 const candidates = []; 3790 appendCandidates(container, candidates); 3791 return candidates.filter(isFocusableElement); 3792 } 3793 function tabbable(container) { 3794 const candidates = focusable(container); 3795 return candidates.filter((element) => getTabIndex(element) >= 0 && isTabbableRadio(element, candidates)); 3796 } 3797 function getTabbableIn(container, dir) { 3798 const list = tabbable(container); 3799 const len = list.length; 3800 if (len === 0) { 3801 return void 0; 3802 } 3803 const active = activeElement(ownerDocument(container)); 3804 const index2 = list.indexOf(active); 3805 const nextIndex = index2 === -1 ? dir === 1 ? 0 : len - 1 : index2 + dir; 3806 return list[nextIndex]; 3807 } 3808 function getNextTabbable(referenceElement) { 3809 return getTabbableIn(ownerDocument(referenceElement).body, 1) || referenceElement; 3810 } 3811 function getPreviousTabbable(referenceElement) { 3812 return getTabbableIn(ownerDocument(referenceElement).body, -1) || referenceElement; 3813 } 3814 function getTabbableNearElement(referenceElement, dir) { 3815 if (!referenceElement) { 3816 return null; 3817 } 3818 const list = tabbable(ownerDocument(referenceElement).body); 3819 const elementCount = list.length; 3820 if (elementCount === 0) { 3821 return null; 3822 } 3823 const index2 = list.indexOf(referenceElement); 3824 if (index2 === -1) { 3825 return null; 3826 } 3827 const nextIndex = (index2 + dir + elementCount) % elementCount; 3828 return list[nextIndex]; 3829 } 3830 function getTabbableAfterElement(referenceElement) { 3831 return getTabbableNearElement(referenceElement, 1); 3832 } 3833 function getTabbableBeforeElement(referenceElement) { 3834 return getTabbableNearElement(referenceElement, -1); 3835 } 3836 function isOutsideEvent(event, container) { 3837 const containerElement = container || event.currentTarget; 3838 const relatedTarget = event.relatedTarget; 3839 return !relatedTarget || !contains(containerElement, relatedTarget); 3840 } 3841 function disableFocusInside(container) { 3842 const tabbableElements = tabbable(container); 3843 tabbableElements.forEach((element) => { 3844 element.dataset.tabindex = element.getAttribute("tabindex") || ""; 3845 element.setAttribute("tabindex", "-1"); 3846 }); 3847 } 3848 function enableFocusInside(container) { 3849 const elements = []; 3850 appendMatchingElements(container, "[data-tabindex]", elements); 3851 elements.forEach((element) => { 3852 const tabindex = element.dataset.tabindex; 3853 delete element.dataset.tabindex; 3854 if (tabindex) { 3855 element.setAttribute("tabindex", tabindex); 3856 } else { 3857 element.removeAttribute("tabindex"); 3858 } 3859 }); 3860 } 3861 3862 // node_modules/@base-ui/react/floating-ui-react/utils/nodes.mjs 3863 function getNodeChildren(nodes, id, onlyOpenChildren = true) { 3864 const directChildren = nodes.filter((node) => node.parentId === id); 3865 return directChildren.flatMap((child) => [...!onlyOpenChildren || child.context?.open ? [child] : [], ...getNodeChildren(nodes, child.id, onlyOpenChildren)]); 3866 } 3867 function getNodeAncestors(nodes, id) { 3868 let allAncestors = []; 3869 let currentParentId = nodes.find((node) => node.id === id)?.parentId; 3870 while (currentParentId) { 3871 const currentNode = nodes.find((node) => node.id === currentParentId); 3872 currentParentId = currentNode?.parentId; 3873 if (currentNode) { 3874 allAncestors = allAncestors.concat(currentNode); 3875 } 3876 } 3877 return allAncestors; 3878 } 3879 3880 // node_modules/@base-ui/react/floating-ui-react/utils/createAttribute.mjs 3881 function createAttribute(name) { 3882 return `data-base-ui-$name}`; 3883 } 3884 3885 // node_modules/@base-ui/react/floating-ui-react/utils/enqueueFocus.mjs 3886 var rafId = 0; 3887 function enqueueFocus(el, options = {}) { 3888 const { 3889 preventScroll = false, 3890 sync: sync2 = false, 3891 shouldFocus 3892 } = options; 3893 cancelAnimationFrame(rafId); 3894 function exec() { 3895 if (shouldFocus && !shouldFocus()) { 3896 return; 3897 } 3898 el?.focus({ 3899 preventScroll 3900 }); 3901 } 3902 if (sync2) { 3903 exec(); 3904 return NOOP; 3905 } 3906 const currentRafId = requestAnimationFrame(exec); 3907 rafId = currentRafId; 3908 return () => { 3909 if (rafId === currentRafId) { 3910 cancelAnimationFrame(currentRafId); 3911 rafId = 0; 3912 } 3913 }; 3914 } 3915 3916 // node_modules/@base-ui/react/floating-ui-react/utils/markOthers.mjs 3917 var counters = { 3918 inert: /* @__PURE__ */ new WeakMap(), 3919 "aria-hidden": /* @__PURE__ */ new WeakMap() 3920 }; 3921 var markerName = "data-base-ui-inert"; 3922 var uncontrolledElementsSets = { 3923 inert: /* @__PURE__ */ new WeakSet(), 3924 "aria-hidden": /* @__PURE__ */ new WeakSet() 3925 }; 3926 var markerCounterMap = /* @__PURE__ */ new WeakMap(); 3927 var lockCount = 0; 3928 function getUncontrolledElementsSet(controlAttribute) { 3929 return uncontrolledElementsSets[controlAttribute]; 3930 } 3931 function unwrapHost(node) { 3932 if (!node) { 3933 return null; 3934 } 3935 return isShadowRoot(node) ? node.host : unwrapHost(node.parentNode); 3936 } 3937 var correctElements = (parent, targets) => targets.map((target) => { 3938 if (parent.contains(target)) { 3939 return target; 3940 } 3941 const correctedTarget = unwrapHost(target); 3942 if (parent.contains(correctedTarget)) { 3943 return correctedTarget; 3944 } 3945 return null; 3946 }).filter((x2) => x2 != null); 3947 var buildKeepSet = (targets) => { 3948 const keep = /* @__PURE__ */ new Set(); 3949 targets.forEach((target) => { 3950 let node = target; 3951 while (node && !keep.has(node)) { 3952 keep.add(node); 3953 node = node.parentNode; 3954 } 3955 }); 3956 return keep; 3957 }; 3958 var collectOutsideElements = (root, keepElements, stopElements) => { 3959 const outside = []; 3960 const walk = (parent) => { 3961 if (!parent || stopElements.has(parent)) { 3962 return; 3963 } 3964 Array.from(parent.children).forEach((node) => { 3965 if (getNodeName(node) === "script") { 3966 return; 3967 } 3968 if (keepElements.has(node)) { 3969 walk(node); 3970 } else { 3971 outside.push(node); 3972 } 3973 }); 3974 }; 3975 walk(root); 3976 return outside; 3977 }; 3978 function applyAttributeToOthers(uncorrectedAvoidElements, body, ariaHidden, inert, { 3979 mark = true 3980 }) { 3981 let controlAttribute = null; 3982 if (inert) { 3983 controlAttribute = "inert"; 3984 } else if (ariaHidden) { 3985 controlAttribute = "aria-hidden"; 3986 } 3987 let counterMap = null; 3988 let uncontrolledElementsSet = null; 3989 const avoidElements = correctElements(body, uncorrectedAvoidElements); 3990 const markerTargets = mark ? collectOutsideElements(body, buildKeepSet(avoidElements), new Set(avoidElements)) : []; 3991 const hiddenElements = []; 3992 const markedElements = []; 3993 if (controlAttribute) { 3994 const map = counters[controlAttribute]; 3995 const currentUncontrolledElementsSet = getUncontrolledElementsSet(controlAttribute); 3996 uncontrolledElementsSet = currentUncontrolledElementsSet; 3997 counterMap = map; 3998 const ariaLiveElements = correctElements(body, Array.from(body.querySelectorAll("[aria-live]"))); 3999 const controlElements = avoidElements.concat(ariaLiveElements); 4000 const controlTargets = collectOutsideElements(body, buildKeepSet(controlElements), new Set(controlElements)); 4001 controlTargets.forEach((node) => { 4002 const attr2 = node.getAttribute(controlAttribute); 4003 const alreadyHidden = attr2 !== null && attr2 !== "false"; 4004 const counterValue = (map.get(node) || 0) + 1; 4005 map.set(node, counterValue); 4006 hiddenElements.push(node); 4007 if (counterValue === 1 && alreadyHidden) { 4008 currentUncontrolledElementsSet.add(node); 4009 } 4010 if (!alreadyHidden) { 4011 node.setAttribute(controlAttribute, controlAttribute === "inert" ? "" : "true"); 4012 } 4013 }); 4014 } 4015 if (mark) { 4016 markerTargets.forEach((node) => { 4017 const markerValue = (markerCounterMap.get(node) || 0) + 1; 4018 markerCounterMap.set(node, markerValue); 4019 markedElements.push(node); 4020 if (markerValue === 1) { 4021 node.setAttribute(markerName, ""); 4022 } 4023 }); 4024 } 4025 lockCount += 1; 4026 return () => { 4027 if (counterMap) { 4028 hiddenElements.forEach((element) => { 4029 const currentCounterValue = counterMap.get(element) || 0; 4030 const counterValue = currentCounterValue - 1; 4031 counterMap.set(element, counterValue); 4032 if (!counterValue) { 4033 if (!uncontrolledElementsSet?.has(element) && controlAttribute) { 4034 element.removeAttribute(controlAttribute); 4035 } 4036 uncontrolledElementsSet?.delete(element); 4037 } 4038 }); 4039 } 4040 if (mark) { 4041 markedElements.forEach((element) => { 4042 const markerValue = (markerCounterMap.get(element) || 0) - 1; 4043 markerCounterMap.set(element, markerValue); 4044 if (!markerValue) { 4045 element.removeAttribute(markerName); 4046 } 4047 }); 4048 } 4049 lockCount -= 1; 4050 if (!lockCount) { 4051 counters.inert = /* @__PURE__ */ new WeakMap(); 4052 counters["aria-hidden"] = /* @__PURE__ */ new WeakMap(); 4053 uncontrolledElementsSets.inert = /* @__PURE__ */ new WeakSet(); 4054 uncontrolledElementsSets["aria-hidden"] = /* @__PURE__ */ new WeakSet(); 4055 markerCounterMap = /* @__PURE__ */ new WeakMap(); 4056 } 4057 }; 4058 } 4059 function markOthers(avoidElements, options = {}) { 4060 const { 4061 ariaHidden = false, 4062 inert = false, 4063 mark = true 4064 } = options; 4065 const body = ownerDocument(avoidElements[0]).body; 4066 return applyAttributeToOthers(avoidElements, body, ariaHidden, inert, { 4067 mark 4068 }); 4069 } 4070 4071 // node_modules/@base-ui/react/floating-ui-react/components/FloatingPortal.mjs 4072 var React22 = __toESM(require_react(), 1); 4073 var ReactDOM2 = __toESM(require_react_dom(), 1); 4074 4075 // node_modules/@base-ui/react/internals/constants.mjs 4076 var PATIENT_CLICK_THRESHOLD = 500; 4077 var DISABLED_TRANSITIONS_STYLE = { 4078 style: { 4079 transition: "none" 4080 } 4081 }; 4082 var CLICK_TRIGGER_IDENTIFIER = "data-base-ui-click-trigger"; 4083 var BASE_UI_SWIPE_IGNORE_ATTRIBUTE = "data-base-ui-swipe-ignore"; 4084 var LEGACY_SWIPE_IGNORE_ATTRIBUTE = "data-swipe-ignore"; 4085 var BASE_UI_SWIPE_IGNORE_SELECTOR = `[$BASE_UI_SWIPE_IGNORE_ATTRIBUTE}]`; 4086 var LEGACY_SWIPE_IGNORE_SELECTOR = `[$LEGACY_SWIPE_IGNORE_ATTRIBUTE}]`; 4087 var POPUP_COLLISION_AVOIDANCE = { 4088 fallbackAxisSide: "end" 4089 }; 4090 var ownerVisuallyHidden = { 4091 clipPath: "inset(50%)", 4092 position: "fixed", 4093 top: 0, 4094 left: 0 4095 }; 4096 4097 // node_modules/@base-ui/react/floating-ui-react/components/FloatingPortal.mjs 4098 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1); 4099 var PortalContext = /* @__PURE__ */ React22.createContext(null); 4100 if (true) PortalContext.displayName = "PortalContext"; 4101 var usePortalContext = () => React22.useContext(PortalContext); 4102 var attr = createAttribute("portal"); 4103 function useFloatingPortalNode(props = {}) { 4104 const { 4105 ref, 4106 container: containerProp, 4107 componentProps = EMPTY_OBJECT, 4108 elementProps 4109 } = props; 4110 const uniqueId = useId(); 4111 const portalContext = usePortalContext(); 4112 const parentPortalNode = portalContext?.portalNode; 4113 const [containerElement, setContainerElement] = React22.useState(null); 4114 const [portalNode, setPortalNode] = React22.useState(null); 4115 const setPortalNodeRef = useStableCallback((node) => { 4116 if (node !== null) { 4117 setPortalNode(node); 4118 } 4119 }); 4120 const containerRef = React22.useRef(null); 4121 useIsoLayoutEffect(() => { 4122 if (containerProp === null) { 4123 if (containerRef.current) { 4124 containerRef.current = null; 4125 setPortalNode(null); 4126 setContainerElement(null); 4127 } 4128 return; 4129 } 4130 if (uniqueId == null) { 4131 return; 4132 } 4133 const resolvedContainer = (containerProp && (isNode(containerProp) ? containerProp : containerProp.current)) ?? parentPortalNode ?? document.body; 4134 if (resolvedContainer == null) { 4135 if (containerRef.current) { 4136 containerRef.current = null; 4137 setPortalNode(null); 4138 setContainerElement(null); 4139 } 4140 return; 4141 } 4142 if (containerRef.current !== resolvedContainer) { 4143 containerRef.current = resolvedContainer; 4144 setPortalNode(null); 4145 setContainerElement(resolvedContainer); 4146 } 4147 }, [containerProp, parentPortalNode, uniqueId]); 4148 const portalElement = useRenderElement("div", componentProps, { 4149 ref: [ref, setPortalNodeRef], 4150 props: [{ 4151 id: uniqueId, 4152 [attr]: "" 4153 }, elementProps] 4154 }); 4155 const portalSubtree = containerElement && portalElement ? /* @__PURE__ */ ReactDOM2.createPortal(portalElement, containerElement) : null; 4156 return { 4157 portalNode, 4158 portalSubtree 4159 }; 4160 } 4161 var FloatingPortal = /* @__PURE__ */ React22.forwardRef(function FloatingPortal2(componentProps, forwardedRef) { 4162 const { 4163 render: render4, 4164 className, 4165 style, 4166 children, 4167 container, 4168 renderGuards, 4169 ...elementProps 4170 } = componentProps; 4171 const { 4172 portalNode, 4173 portalSubtree 4174 } = useFloatingPortalNode({ 4175 container, 4176 ref: forwardedRef, 4177 componentProps, 4178 elementProps 4179 }); 4180 const beforeOutsideRef = React22.useRef(null); 4181 const afterOutsideRef = React22.useRef(null); 4182 const beforeInsideRef = React22.useRef(null); 4183 const afterInsideRef = React22.useRef(null); 4184 const [focusManagerState, setFocusManagerState] = React22.useState(null); 4185 const focusInsideDisabledRef = React22.useRef(false); 4186 const modal = focusManagerState?.modal; 4187 const open = focusManagerState?.open; 4188 const shouldRenderGuards = typeof renderGuards === "boolean" ? renderGuards : !!focusManagerState && !focusManagerState.modal && focusManagerState.open && !!portalNode; 4189 React22.useEffect(() => { 4190 if (!portalNode || modal) { 4191 return void 0; 4192 } 4193 function onFocus(event) { 4194 if (portalNode && event.relatedTarget && isOutsideEvent(event)) { 4195 if (event.type === "focusin") { 4196 if (focusInsideDisabledRef.current) { 4197 enableFocusInside(portalNode); 4198 focusInsideDisabledRef.current = false; 4199 } 4200 } else { 4201 disableFocusInside(portalNode); 4202 focusInsideDisabledRef.current = true; 4203 } 4204 } 4205 } 4206 return mergeCleanups(addEventListener(portalNode, "focusin", onFocus, true), addEventListener(portalNode, "focusout", onFocus, true)); 4207 }, [portalNode, modal]); 4208 useIsoLayoutEffect(() => { 4209 if (!portalNode || open !== true || !focusInsideDisabledRef.current) { 4210 return; 4211 } 4212 enableFocusInside(portalNode); 4213 focusInsideDisabledRef.current = false; 4214 }, [open, portalNode]); 4215 const portalContextValue = React22.useMemo(() => ({ 4216 beforeOutsideRef, 4217 afterOutsideRef, 4218 beforeInsideRef, 4219 afterInsideRef, 4220 portalNode, 4221 setFocusManagerState 4222 }), [portalNode]); 4223 return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(React22.Fragment, { 4224 children: [portalSubtree, /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(PortalContext.Provider, { 4225 value: portalContextValue, 4226 children: [shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, { 4227 "data-type": "outside", 4228 ref: beforeOutsideRef, 4229 onFocus: (event) => { 4230 if (isOutsideEvent(event, portalNode)) { 4231 beforeInsideRef.current?.focus(); 4232 } else { 4233 const domReference = focusManagerState ? focusManagerState.domReference : null; 4234 const prevTabbable = getPreviousTabbable(domReference); 4235 prevTabbable?.focus(); 4236 } 4237 } 4238 }), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { 4239 "aria-owns": portalNode.id, 4240 style: ownerVisuallyHidden 4241 }), portalNode && /* @__PURE__ */ ReactDOM2.createPortal(children, portalNode), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, { 4242 "data-type": "outside", 4243 ref: afterOutsideRef, 4244 onFocus: (event) => { 4245 if (isOutsideEvent(event, portalNode)) { 4246 afterInsideRef.current?.focus(); 4247 } else { 4248 const domReference = focusManagerState ? focusManagerState.domReference : null; 4249 const nextTabbable = getNextTabbable(domReference); 4250 nextTabbable?.focus(); 4251 if (focusManagerState?.closeOnFocusOut) { 4252 focusManagerState?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.focusOut, event.nativeEvent)); 4253 } 4254 } 4255 } 4256 })] 4257 })] 4258 }); 4259 }); 4260 if (true) FloatingPortal.displayName = "FloatingPortal"; 4261 4262 // node_modules/@base-ui/react/floating-ui-react/components/FloatingTree.mjs 4263 var React23 = __toESM(require_react(), 1); 4264 4265 // node_modules/@base-ui/react/floating-ui-react/utils/createEventEmitter.mjs 4266 function createEventEmitter() { 4267 const map = /* @__PURE__ */ new Map(); 4268 return { 4269 emit(event, data) { 4270 map.get(event)?.forEach((listener) => listener(data)); 4271 }, 4272 on(event, listener) { 4273 if (!map.has(event)) { 4274 map.set(event, /* @__PURE__ */ new Set()); 4275 } 4276 map.get(event).add(listener); 4277 }, 4278 off(event, listener) { 4279 map.get(event)?.delete(listener); 4280 } 4281 }; 4282 } 4283 4284 // node_modules/@base-ui/react/floating-ui-react/components/FloatingTreeStore.mjs 4285 var FloatingTreeStore = class { 4286 nodesRef = { 4287 current: [] 4288 }; 4289 events = createEventEmitter(); 4290 addNode(node) { 4291 this.nodesRef.current.push(node); 4292 } 4293 removeNode(node) { 4294 const index2 = this.nodesRef.current.findIndex((n2) => n2 === node); 4295 if (index2 !== -1) { 4296 this.nodesRef.current.splice(index2, 1); 4297 } 4298 } 4299 }; 4300 4301 // node_modules/@base-ui/react/floating-ui-react/components/FloatingTree.mjs 4302 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1); 4303 var FloatingNodeContext = /* @__PURE__ */ React23.createContext(null); 4304 if (true) FloatingNodeContext.displayName = "FloatingNodeContext"; 4305 var FloatingTreeContext = /* @__PURE__ */ React23.createContext(null); 4306 if (true) FloatingTreeContext.displayName = "FloatingTreeContext"; 4307 var useFloatingParentNodeId = () => React23.useContext(FloatingNodeContext)?.id || null; 4308 var useFloatingTree = (externalTree) => { 4309 const contextTree = React23.useContext(FloatingTreeContext); 4310 return externalTree ?? contextTree; 4311 }; 4312 function useFloatingNodeId(externalTree) { 4313 const id = useId(); 4314 const tree = useFloatingTree(externalTree); 4315 const parentId = useFloatingParentNodeId(); 4316 useIsoLayoutEffect(() => { 4317 if (!id) { 4318 return void 0; 4319 } 4320 const node = { 4321 id, 4322 parentId 4323 }; 4324 tree?.addNode(node); 4325 return () => { 4326 tree?.removeNode(node); 4327 }; 4328 }, [tree, id, parentId]); 4329 return id; 4330 } 4331 function FloatingNode(props) { 4332 const { 4333 children, 4334 id 4335 } = props; 4336 const parentId = useFloatingParentNodeId(); 4337 return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(FloatingNodeContext.Provider, { 4338 value: React23.useMemo(() => ({ 4339 id, 4340 parentId 4341 }), [id, parentId]), 4342 children 4343 }); 4344 } 4345 function FloatingTree(props) { 4346 const { 4347 children, 4348 externalTree 4349 } = props; 4350 const tree = useRefWithInit(() => externalTree ?? new FloatingTreeStore()).current; 4351 return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(FloatingTreeContext.Provider, { 4352 value: tree, 4353 children 4354 }); 4355 } 4356 4357 // node_modules/@base-ui/react/floating-ui-react/components/FloatingFocusManager.mjs 4358 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1); 4359 function getEventType(event, lastInteractionType) { 4360 const win = getWindow(getTarget(event)); 4361 if (event instanceof win.KeyboardEvent) { 4362 return "keyboard"; 4363 } 4364 if (event instanceof win.FocusEvent) { 4365 return lastInteractionType || "keyboard"; 4366 } 4367 if ("pointerType" in event) { 4368 return event.pointerType || "keyboard"; 4369 } 4370 if ("touches" in event) { 4371 return "touch"; 4372 } 4373 if (event instanceof win.MouseEvent) { 4374 return lastInteractionType || (event.detail === 0 ? "keyboard" : "mouse"); 4375 } 4376 return ""; 4377 } 4378 var LIST_LIMIT = 20; 4379 var previouslyFocusedElements = []; 4380 function clearDisconnectedPreviouslyFocusedElements() { 4381 previouslyFocusedElements = previouslyFocusedElements.filter((entry) => { 4382 return entry.deref()?.isConnected; 4383 }); 4384 } 4385 function addPreviouslyFocusedElement(element) { 4386 clearDisconnectedPreviouslyFocusedElements(); 4387 if (element && getNodeName(element) !== "body") { 4388 previouslyFocusedElements.push(new WeakRef(element)); 4389 if (previouslyFocusedElements.length > LIST_LIMIT) { 4390 previouslyFocusedElements = previouslyFocusedElements.slice(-LIST_LIMIT); 4391 } 4392 } 4393 } 4394 function getPreviouslyFocusedElement() { 4395 clearDisconnectedPreviouslyFocusedElements(); 4396 return previouslyFocusedElements[previouslyFocusedElements.length - 1]?.deref(); 4397 } 4398 function getFirstTabbableElement(container) { 4399 if (!container) { 4400 return null; 4401 } 4402 if (isTabbable(container)) { 4403 return container; 4404 } 4405 return tabbable(container)[0] || container; 4406 } 4407 function handleTabIndex(floatingFocusElement) { 4408 if (floatingFocusElement.hasAttribute("tabindex") && !floatingFocusElement.hasAttribute("data-tabindex")) { 4409 return; 4410 } 4411 if (!floatingFocusElement.getAttribute("role")?.includes("dialog")) { 4412 return; 4413 } 4414 const focusableElements = focusable(floatingFocusElement); 4415 const tabbableContent = focusableElements.filter((element) => { 4416 const dataTabIndex = element.getAttribute("data-tabindex") || ""; 4417 return isTabbable(element) || element.hasAttribute("data-tabindex") && !dataTabIndex.startsWith("-"); 4418 }); 4419 const tabIndex = floatingFocusElement.getAttribute("tabindex"); 4420 if (tabbableContent.length === 0) { 4421 if (tabIndex !== "0") { 4422 floatingFocusElement.setAttribute("tabindex", "0"); 4423 floatingFocusElement.setAttribute("data-tabindex", "0"); 4424 } 4425 } else if (tabIndex !== "-1" || floatingFocusElement.hasAttribute("data-tabindex") && floatingFocusElement.getAttribute("data-tabindex") !== "-1") { 4426 floatingFocusElement.setAttribute("tabindex", "-1"); 4427 floatingFocusElement.setAttribute("data-tabindex", "-1"); 4428 } 4429 } 4430 function FloatingFocusManager(props) { 4431 const { 4432 context, 4433 children, 4434 disabled: disabled2 = false, 4435 initialFocus = true, 4436 returnFocus = true, 4437 restoreFocus = false, 4438 modal = true, 4439 closeOnFocusOut = true, 4440 openInteractionType = "", 4441 nextFocusableElement, 4442 previousFocusableElement, 4443 beforeContentFocusGuardRef, 4444 externalTree, 4445 getInsideElements 4446 } = props; 4447 const store = "rootStore" in context ? context.rootStore : context; 4448 const open = store.useState("open"); 4449 const domReference = store.useState("domReferenceElement"); 4450 const floating = store.useState("floatingElement"); 4451 const { 4452 events, 4453 dataRef 4454 } = store.context; 4455 const getNodeId = useStableCallback(() => dataRef.current.floatingContext?.nodeId); 4456 const ignoreInitialFocus = initialFocus === false; 4457 const isUntrappedTypeableCombobox = isTypeableCombobox(domReference) && ignoreInitialFocus; 4458 const initialFocusRef = useValueAsRef(initialFocus); 4459 const returnFocusRef = useValueAsRef(returnFocus); 4460 const openInteractionTypeRef = useValueAsRef(openInteractionType); 4461 const openRef = useValueAsRef(open); 4462 const tree = useFloatingTree(externalTree); 4463 const portalContext = usePortalContext(); 4464 const preventReturnFocusRef = React24.useRef(false); 4465 const isPointerDownRef = React24.useRef(false); 4466 const pointerDownOutsideRef = React24.useRef(false); 4467 const lastFocusedTabbableRef = React24.useRef(null); 4468 const closeTypeRef = React24.useRef(""); 4469 const lastInteractionTypeRef = React24.useRef(""); 4470 const beforeGuardRef = React24.useRef(null); 4471 const afterGuardRef = React24.useRef(null); 4472 const mergedBeforeGuardRef = useMergedRefs(beforeGuardRef, beforeContentFocusGuardRef, portalContext?.beforeInsideRef); 4473 const mergedAfterGuardRef = useMergedRefs(afterGuardRef, portalContext?.afterInsideRef); 4474 const blurTimeout = useTimeout(); 4475 const pointerDownTimeout = useTimeout(); 4476 const restoreFocusFrame = useAnimationFrame(); 4477 const isInsidePortal = portalContext != null; 4478 const floatingFocusElement = getFloatingFocusElement(floating); 4479 const getTabbableContent = useStableCallback((container = floatingFocusElement) => { 4480 return container ? tabbable(container) : []; 4481 }); 4482 const getResolvedInsideElements = useStableCallback(() => getInsideElements?.().filter((element) => element != null) ?? []); 4483 React24.useEffect(() => { 4484 if (disabled2 || !modal) { 4485 return void 0; 4486 } 4487 function onKeyDown(event) { 4488 if (event.key === "Tab") { 4489 if (contains(floatingFocusElement, activeElement(ownerDocument(floatingFocusElement))) && getTabbableContent().length === 0 && !isUntrappedTypeableCombobox) { 4490 stopEvent(event); 4491 } 4492 } 4493 } 4494 const doc = ownerDocument(floatingFocusElement); 4495 return addEventListener(doc, "keydown", onKeyDown); 4496 }, [disabled2, floatingFocusElement, modal, isUntrappedTypeableCombobox, getTabbableContent]); 4497 React24.useEffect(() => { 4498 if (disabled2 || !open) { 4499 return void 0; 4500 } 4501 const doc = ownerDocument(floatingFocusElement); 4502 function clearPointerDownOutside() { 4503 pointerDownOutsideRef.current = false; 4504 } 4505 function onPointerDown(event) { 4506 const target = getTarget(event); 4507 const insideElements = getResolvedInsideElements(); 4508 const pointerTargetInside = contains(floating, target) || contains(domReference, target) || contains(portalContext?.portalNode, target) || insideElements.some((element) => element === target || contains(element, target)); 4509 pointerDownOutsideRef.current = !pointerTargetInside; 4510 lastInteractionTypeRef.current = event.pointerType || "keyboard"; 4511 if (target?.closest(`[$CLICK_TRIGGER_IDENTIFIER}]`)) { 4512 isPointerDownRef.current = true; 4513 pointerDownTimeout.start(0, () => { 4514 isPointerDownRef.current = false; 4515 }); 4516 } 4517 } 4518 function onKeyDown() { 4519 lastInteractionTypeRef.current = "keyboard"; 4520 } 4521 return mergeCleanups( 4522 addEventListener(doc, "pointerdown", onPointerDown, true), 4523 addEventListener(doc, "pointerup", clearPointerDownOutside, true), 4524 addEventListener(doc, "pointercancel", clearPointerDownOutside, true), 4525 addEventListener(doc, "keydown", onKeyDown, true), 4526 // Avoid a stale `true` leaking into the next open (e.g. keep-mounted popups) 4527 // if the popup dismissed between pointerdown and pointerup. 4528 clearPointerDownOutside 4529 ); 4530 }, [disabled2, floating, domReference, floatingFocusElement, open, portalContext, pointerDownTimeout, getResolvedInsideElements]); 4531 React24.useEffect(() => { 4532 if (disabled2 || !closeOnFocusOut) { 4533 return void 0; 4534 } 4535 const doc = ownerDocument(floatingFocusElement); 4536 function handlePointerDown() { 4537 isPointerDownRef.current = true; 4538 pointerDownTimeout.start(0, () => { 4539 isPointerDownRef.current = false; 4540 }); 4541 } 4542 function handleFocusIn(event) { 4543 const target = getTarget(event); 4544 if (isTabbable(target)) { 4545 lastFocusedTabbableRef.current = target; 4546 } 4547 } 4548 function handleFocusOutside(event) { 4549 const relatedTarget = event.relatedTarget; 4550 const currentTarget = event.currentTarget; 4551 const target = getTarget(event); 4552 if (modal && relatedTarget == null && target != null && contains(floating, target)) { 4553 addPreviouslyFocusedElement(target); 4554 } 4555 queueMicrotask(() => { 4556 const nodeId = getNodeId(); 4557 const triggers = store.context.triggerElements; 4558 const insideElements = getResolvedInsideElements(); 4559 const isRelatedFocusGuard = relatedTarget?.hasAttribute(createAttribute("focus-guard")) && [beforeGuardRef.current, afterGuardRef.current, portalContext?.beforeInsideRef.current, portalContext?.afterInsideRef.current, portalContext?.beforeOutsideRef.current, portalContext?.afterOutsideRef.current, resolveRef(previousFocusableElement), resolveRef(nextFocusableElement)].includes(relatedTarget); 4560 const movedToUnrelatedNode = !(contains(domReference, relatedTarget) || contains(floating, relatedTarget) || contains(relatedTarget, floating) || contains(portalContext?.portalNode, relatedTarget) || insideElements.some((element) => element === relatedTarget || contains(element, relatedTarget)) || relatedTarget != null && triggers.hasElement(relatedTarget) || triggers.hasMatchingElement((trigger) => contains(trigger, relatedTarget)) || isRelatedFocusGuard || tree && (getNodeChildren(tree.nodesRef.current, nodeId).find((node) => contains(node.context?.elements.floating, relatedTarget) || contains(node.context?.elements.domReference, relatedTarget)) || getNodeAncestors(tree.nodesRef.current, nodeId).find((node) => [node.context?.elements.floating, getFloatingFocusElement(node.context?.elements.floating)].includes(relatedTarget) || node.context?.elements.domReference === relatedTarget))); 4561 if (currentTarget === domReference && floatingFocusElement) { 4562 handleTabIndex(floatingFocusElement); 4563 } 4564 if (restoreFocus && currentTarget !== domReference && !isElementVisible(target) && activeElement(doc) === doc.body) { 4565 if (isHTMLElement(floatingFocusElement)) { 4566 floatingFocusElement.focus(); 4567 if (restoreFocus === "popup") { 4568 restoreFocusFrame.request(() => { 4569 floatingFocusElement.focus(); 4570 }); 4571 return; 4572 } 4573 } 4574 const tabbableContent = getTabbableContent(); 4575 const prevTabbable = lastFocusedTabbableRef.current; 4576 const nodeToFocus = (prevTabbable && tabbableContent.includes(prevTabbable) ? prevTabbable : null) || tabbableContent[tabbableContent.length - 1] || floatingFocusElement; 4577 if (isHTMLElement(nodeToFocus)) { 4578 nodeToFocus.focus(); 4579 } 4580 } 4581 if (dataRef.current.insideReactTree) { 4582 dataRef.current.insideReactTree = false; 4583 return; 4584 } 4585 if ((isUntrappedTypeableCombobox ? true : !modal) && relatedTarget && movedToUnrelatedNode && !isPointerDownRef.current && // Fix React 18 Strict Mode returnFocus due to double rendering. 4586 // For an "untrapped" typeable combobox (input role=combobox with 4587 // initialFocus=false), re-opening the popup and tabbing out should still close it even 4588 // when the previously focused element (e.g. the next tabbable outside the popup) is 4589 // focused again. Otherwise, the popup remains open on the second Tab sequence: 4590 // click input -> Tab (closes) -> click input -> Tab. 4591 // Allow closing when `isUntrappedTypeableCombobox` regardless of the previously focused element. 4592 (isUntrappedTypeableCombobox || relatedTarget !== getPreviouslyFocusedElement())) { 4593 preventReturnFocusRef.current = true; 4594 store.setOpen(false, createChangeEventDetails(reason_parts_exports.focusOut, event)); 4595 } 4596 }); 4597 } 4598 function markInsideReactTree() { 4599 if (pointerDownOutsideRef.current) { 4600 return; 4601 } 4602 dataRef.current.insideReactTree = true; 4603 blurTimeout.start(0, () => { 4604 dataRef.current.insideReactTree = false; 4605 }); 4606 } 4607 const domReferenceElement = isHTMLElement(domReference) ? domReference : null; 4608 if (!floating && !domReferenceElement) { 4609 return void 0; 4610 } 4611 return mergeCleanups(domReferenceElement && addEventListener(domReferenceElement, "focusout", handleFocusOutside), domReferenceElement && addEventListener(domReferenceElement, "pointerdown", handlePointerDown), floating && addEventListener(floating, "focusin", handleFocusIn), floating && addEventListener(floating, "focusout", handleFocusOutside), floating && portalContext && addEventListener(floating, "focusout", markInsideReactTree, true)); 4612 }, [disabled2, domReference, floating, floatingFocusElement, modal, tree, portalContext, store, closeOnFocusOut, restoreFocus, getTabbableContent, isUntrappedTypeableCombobox, getNodeId, dataRef, blurTimeout, pointerDownTimeout, restoreFocusFrame, nextFocusableElement, previousFocusableElement, getResolvedInsideElements]); 4613 React24.useEffect(() => { 4614 if (disabled2 || !floating || !open) { 4615 return void 0; 4616 } 4617 const portalNodes = Array.from(portalContext?.portalNode?.querySelectorAll(`[$createAttribute("portal")}]`) || []); 4618 const ancestors = tree ? getNodeAncestors(tree.nodesRef.current, getNodeId()) : []; 4619 const rootAncestorComboboxDomReference = ancestors.find((node) => isTypeableCombobox(node.context?.elements.domReference || null))?.context?.elements.domReference; 4620 const controlInsideElements = [floating, ...portalNodes, beforeGuardRef.current, afterGuardRef.current, portalContext?.beforeOutsideRef.current, portalContext?.afterOutsideRef.current, ...getResolvedInsideElements()]; 4621 const insideElements = [...controlInsideElements, rootAncestorComboboxDomReference, resolveRef(previousFocusableElement), resolveRef(nextFocusableElement), isUntrappedTypeableCombobox ? domReference : null].filter((x2) => x2 != null); 4622 const ariaHiddenCleanup = markOthers(insideElements, { 4623 ariaHidden: modal || isUntrappedTypeableCombobox, 4624 mark: false 4625 }); 4626 const markerInsideElements = [floating, ...portalNodes].filter((x2) => x2 != null); 4627 const markerCleanup = markOthers(markerInsideElements); 4628 return () => { 4629 markerCleanup(); 4630 ariaHiddenCleanup(); 4631 }; 4632 }, [open, disabled2, domReference, floating, modal, portalContext, isUntrappedTypeableCombobox, tree, getNodeId, nextFocusableElement, previousFocusableElement, getResolvedInsideElements]); 4633 useIsoLayoutEffect(() => { 4634 if (!open || disabled2 || !isHTMLElement(floatingFocusElement)) { 4635 return; 4636 } 4637 const doc = ownerDocument(floatingFocusElement); 4638 const previouslyFocusedElement = activeElement(doc); 4639 queueMicrotask(() => { 4640 const initialFocusValueOrFn = initialFocusRef.current; 4641 const resolvedInitialFocus = typeof initialFocusValueOrFn === "function" ? initialFocusValueOrFn(openInteractionTypeRef.current || "") : initialFocusValueOrFn; 4642 if (resolvedInitialFocus === void 0 || resolvedInitialFocus === false) { 4643 return; 4644 } 4645 const focusAlreadyInsideFloatingEl = contains(floatingFocusElement, previouslyFocusedElement); 4646 if (focusAlreadyInsideFloatingEl) { 4647 return; 4648 } 4649 let focusableElements = null; 4650 const getDefaultFocusElement = () => { 4651 if (focusableElements == null) { 4652 focusableElements = getTabbableContent(floatingFocusElement); 4653 } 4654 return focusableElements[0] || floatingFocusElement; 4655 }; 4656 let elToFocus; 4657 if (resolvedInitialFocus === true || resolvedInitialFocus === null) { 4658 elToFocus = getDefaultFocusElement(); 4659 } else { 4660 elToFocus = resolveRef(resolvedInitialFocus); 4661 } 4662 elToFocus = elToFocus || getDefaultFocusElement(); 4663 const hadFocusInside = contains(floatingFocusElement, activeElement(doc)); 4664 enqueueFocus(elToFocus, { 4665 preventScroll: elToFocus === floatingFocusElement, 4666 shouldFocus() { 4667 if (!openRef.current) { 4668 return false; 4669 } 4670 if (hadFocusInside) { 4671 return true; 4672 } 4673 const currentActiveElement = activeElement(doc); 4674 const focusMovedInside = currentActiveElement !== elToFocus && contains(floatingFocusElement, currentActiveElement); 4675 return !focusMovedInside; 4676 } 4677 }); 4678 }); 4679 }, [disabled2, open, floatingFocusElement, getTabbableContent, initialFocusRef, openInteractionTypeRef, openRef]); 4680 useIsoLayoutEffect(() => { 4681 if (disabled2 || !floatingFocusElement) { 4682 return void 0; 4683 } 4684 const doc = ownerDocument(floatingFocusElement); 4685 const elementFocusedBeforeOpen = activeElement(doc); 4686 const preferPreviousFocus = openInteractionTypeRef.current == null; 4687 addPreviouslyFocusedElement(elementFocusedBeforeOpen); 4688 function onOpenChangeLocal(details) { 4689 if (!details.open) { 4690 closeTypeRef.current = getEventType(details.nativeEvent, lastInteractionTypeRef.current); 4691 } 4692 if (details.reason === reason_parts_exports.triggerHover && details.nativeEvent.type === "mouseleave") { 4693 preventReturnFocusRef.current = true; 4694 } 4695 if (details.reason !== reason_parts_exports.outsidePress) { 4696 return; 4697 } 4698 if (details.nested) { 4699 preventReturnFocusRef.current = false; 4700 } else if (isVirtualClick(details.nativeEvent) || isVirtualPointerEvent(details.nativeEvent)) { 4701 preventReturnFocusRef.current = false; 4702 } else { 4703 let isPreventScrollSupported = false; 4704 ownerDocument(floatingFocusElement).createElement("div").focus({ 4705 get preventScroll() { 4706 isPreventScrollSupported = true; 4707 return false; 4708 } 4709 }); 4710 if (isPreventScrollSupported) { 4711 preventReturnFocusRef.current = false; 4712 } else { 4713 preventReturnFocusRef.current = true; 4714 } 4715 } 4716 } 4717 events.on("openchange", onOpenChangeLocal); 4718 function getReturnElement() { 4719 const returnFocusValueOrFn = returnFocusRef.current; 4720 let resolvedReturnFocusValue = typeof returnFocusValueOrFn === "function" ? returnFocusValueOrFn(closeTypeRef.current) : returnFocusValueOrFn; 4721 if (resolvedReturnFocusValue === void 0 || resolvedReturnFocusValue === false) { 4722 return null; 4723 } 4724 if (resolvedReturnFocusValue === null) { 4725 resolvedReturnFocusValue = true; 4726 } 4727 const referenceReturnElement = domReference?.isConnected ? domReference : null; 4728 const previousReturnElement = elementFocusedBeforeOpen?.isConnected && getNodeName(elementFocusedBeforeOpen) !== "body" ? elementFocusedBeforeOpen : null; 4729 let defaultReturnElement = preferPreviousFocus ? previousReturnElement || referenceReturnElement : referenceReturnElement || previousReturnElement; 4730 if (!defaultReturnElement) { 4731 defaultReturnElement = getPreviouslyFocusedElement() || null; 4732 } 4733 if (typeof resolvedReturnFocusValue === "boolean") { 4734 return defaultReturnElement; 4735 } 4736 return resolveRef(resolvedReturnFocusValue) || defaultReturnElement || null; 4737 } 4738 return () => { 4739 events.off("openchange", onOpenChangeLocal); 4740 const activeEl = activeElement(doc); 4741 const insideElements = getResolvedInsideElements(); 4742 const isFocusInsideFloatingTree = contains(floating, activeEl) || insideElements.some((element) => element === activeEl || contains(element, activeEl)) || tree && getNodeChildren(tree.nodesRef.current, getNodeId(), false).some((node) => contains(node.context?.elements.floating, activeEl)); 4743 const returnFocusValueOrFn = returnFocusRef.current; 4744 const returnElement = getReturnElement(); 4745 queueMicrotask(() => { 4746 const tabbableReturnElement = getFirstTabbableElement(returnElement); 4747 const hasExplicitReturnFocus = typeof returnFocusValueOrFn !== "boolean"; 4748 if (returnFocusValueOrFn && !preventReturnFocusRef.current && isHTMLElement(tabbableReturnElement) && // If the focus moved somewhere else after mount, avoid returning focus 4749 // since it likely entered a different element which should be 4750 // respected: https://github.com/floating-ui/floating-ui/issues/2607 4751 (!hasExplicitReturnFocus && tabbableReturnElement !== activeEl && activeEl !== doc.body ? isFocusInsideFloatingTree : true)) { 4752 tabbableReturnElement.focus({ 4753 preventScroll: true 4754 }); 4755 } 4756 preventReturnFocusRef.current = false; 4757 }); 4758 }; 4759 }, [disabled2, floating, floatingFocusElement, returnFocusRef, openInteractionTypeRef, events, tree, domReference, getNodeId, getResolvedInsideElements]); 4760 useIsoLayoutEffect(() => { 4761 if (!parts_exports.engine.webkit || open || !floating) { 4762 return; 4763 } 4764 const activeEl = activeElement(ownerDocument(floating)); 4765 if (!isHTMLElement(activeEl) || !isTypeableElement(activeEl)) { 4766 return; 4767 } 4768 if (contains(floating, activeEl)) { 4769 activeEl.blur(); 4770 } 4771 }, [open, floating]); 4772 useIsoLayoutEffect(() => { 4773 if (disabled2 || !portalContext) { 4774 return void 0; 4775 } 4776 portalContext.setFocusManagerState({ 4777 modal, 4778 closeOnFocusOut, 4779 open, 4780 onOpenChange: store.setOpen, 4781 domReference 4782 }); 4783 return () => { 4784 portalContext.setFocusManagerState(null); 4785 }; 4786 }, [disabled2, portalContext, modal, open, store, closeOnFocusOut, domReference]); 4787 useIsoLayoutEffect(() => { 4788 if (disabled2 || !floatingFocusElement) { 4789 return void 0; 4790 } 4791 handleTabIndex(floatingFocusElement); 4792 return () => { 4793 queueMicrotask(clearDisconnectedPreviouslyFocusedElements); 4794 }; 4795 }, [disabled2, floatingFocusElement]); 4796 const shouldRenderGuards = !disabled2 && (modal ? !isUntrappedTypeableCombobox : true) && (isInsidePortal || modal); 4797 return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(React24.Fragment, { 4798 children: [shouldRenderGuards && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(FocusGuard, { 4799 "data-type": "inside", 4800 ref: mergedBeforeGuardRef, 4801 onFocus: (event) => { 4802 if (modal) { 4803 const els = getTabbableContent(); 4804 enqueueFocus(els[els.length - 1]); 4805 } else if (portalContext?.portalNode) { 4806 preventReturnFocusRef.current = false; 4807 if (isOutsideEvent(event, portalContext.portalNode)) { 4808 const nextTabbable = getNextTabbable(domReference); 4809 nextTabbable?.focus(); 4810 } else { 4811 resolveRef(previousFocusableElement ?? portalContext.beforeOutsideRef)?.focus(); 4812 } 4813 } 4814 } 4815 }), children, shouldRenderGuards && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(FocusGuard, { 4816 "data-type": "inside", 4817 ref: mergedAfterGuardRef, 4818 onFocus: (event) => { 4819 if (modal) { 4820 enqueueFocus(getTabbableContent()[0]); 4821 } else if (portalContext?.portalNode) { 4822 if (closeOnFocusOut) { 4823 preventReturnFocusRef.current = true; 4824 } 4825 if (isOutsideEvent(event, portalContext.portalNode)) { 4826 const prevTabbable = getPreviousTabbable(domReference); 4827 prevTabbable?.focus(); 4828 } else { 4829 resolveRef(nextFocusableElement ?? portalContext.afterOutsideRef)?.focus(); 4830 } 4831 } 4832 } 4833 })] 4834 }); 4835 } 4836 4837 // node_modules/@base-ui/react/floating-ui-react/hooks/useClick.mjs 4838 var React25 = __toESM(require_react(), 1); 4839 function useClick(context, props = {}) { 4840 const { 4841 enabled = true, 4842 event: eventOption = "click", 4843 toggle = true, 4844 ignoreMouse = false, 4845 stickIfOpen = true, 4846 touchOpenDelay = 0, 4847 reason = reason_parts_exports.triggerPress 4848 } = props; 4849 const store = "rootStore" in context ? context.rootStore : context; 4850 const dataRef = store.context.dataRef; 4851 const pointerTypeRef = React25.useRef(void 0); 4852 const frame = useAnimationFrame(); 4853 const touchOpenTimeout = useTimeout(); 4854 const reference = React25.useMemo(() => { 4855 function setOpenWithTouchDelay(nextOpen, nativeEvent, target, pointerType) { 4856 const details = createChangeEventDetails(reason, nativeEvent, target); 4857 if (nextOpen && pointerType === "touch" && touchOpenDelay > 0) { 4858 touchOpenTimeout.start(touchOpenDelay, () => { 4859 store.setOpen(true, details); 4860 }); 4861 } else { 4862 store.setOpen(nextOpen, details); 4863 } 4864 } 4865 function getNextOpen(open, currentTarget, isClickLikeOpenEvent2) { 4866 const openEvent = dataRef.current.openEvent; 4867 const hasClickedOnInactiveTrigger = store.select("domReferenceElement") !== currentTarget; 4868 if (open && hasClickedOnInactiveTrigger) { 4869 return true; 4870 } 4871 if (!open) { 4872 return true; 4873 } 4874 if (!toggle) { 4875 return true; 4876 } 4877 if (openEvent && stickIfOpen) { 4878 return !isClickLikeOpenEvent2(openEvent.type); 4879 } 4880 return false; 4881 } 4882 return { 4883 onPointerDown(event) { 4884 pointerTypeRef.current = event.pointerType; 4885 }, 4886 onMouseDown(event) { 4887 const pointerType = pointerTypeRef.current; 4888 const nativeEvent = event.nativeEvent; 4889 const open = store.select("open"); 4890 if (event.button !== 0 || eventOption === "click" || isMouseLikePointerType(pointerType, true) && ignoreMouse) { 4891 return; 4892 } 4893 const nextOpen = getNextOpen(open, event.currentTarget, (openEventType) => openEventType === "click" || openEventType === "mousedown"); 4894 const target = getTarget(nativeEvent); 4895 if (isTypeableElement(target)) { 4896 setOpenWithTouchDelay(nextOpen, nativeEvent, target, pointerType); 4897 return; 4898 } 4899 const eventCurrentTarget = event.currentTarget; 4900 frame.request(() => { 4901 setOpenWithTouchDelay(nextOpen, nativeEvent, eventCurrentTarget, pointerType); 4902 }); 4903 }, 4904 onClick(event) { 4905 if (eventOption === "mousedown-only") { 4906 return; 4907 } 4908 const pointerType = pointerTypeRef.current; 4909 if (eventOption === "mousedown" && pointerType) { 4910 pointerTypeRef.current = void 0; 4911 return; 4912 } 4913 if (isMouseLikePointerType(pointerType, true) && ignoreMouse) { 4914 return; 4915 } 4916 const open = store.select("open"); 4917 const nextOpen = getNextOpen(open, event.currentTarget, (openEventType) => openEventType === "click" || openEventType === "mousedown" || openEventType === "keydown" || openEventType === "keyup"); 4918 setOpenWithTouchDelay(nextOpen, event.nativeEvent, event.currentTarget, pointerType); 4919 }, 4920 onKeyDown() { 4921 pointerTypeRef.current = void 0; 4922 } 4923 }; 4924 }, [dataRef, eventOption, ignoreMouse, reason, store, stickIfOpen, toggle, frame, touchOpenTimeout, touchOpenDelay]); 4925 return React25.useMemo(() => enabled ? { 4926 reference 4927 } : EMPTY_OBJECT, [enabled, reference]); 4928 } 4929 4930 // node_modules/@base-ui/react/floating-ui-react/hooks/useClientPoint.mjs 4931 var React26 = __toESM(require_react(), 1); 4932 function createVirtualElement(domElement, data) { 4933 let offsetX = null; 4934 let offsetY = null; 4935 let isAutoUpdateEvent = false; 4936 return { 4937 contextElement: domElement || void 0, 4938 getBoundingClientRect() { 4939 const domRect = domElement?.getBoundingClientRect() || { 4940 width: 0, 4941 height: 0, 4942 x: 0, 4943 y: 0 4944 }; 4945 const isXAxis = data.axis === "x" || data.axis === "both"; 4946 const isYAxis = data.axis === "y" || data.axis === "both"; 4947 const canTrackCursorOnAutoUpdate = ["mouseenter", "mousemove"].includes(data.dataRef.current.openEvent?.type || "") && data.pointerType !== "touch"; 4948 let width = domRect.width; 4949 let height = domRect.height; 4950 let x2 = domRect.x; 4951 let y2 = domRect.y; 4952 if (offsetX == null && data.x && isXAxis) { 4953 offsetX = domRect.x - data.x; 4954 } 4955 if (offsetY == null && data.y && isYAxis) { 4956 offsetY = domRect.y - data.y; 4957 } 4958 x2 -= offsetX || 0; 4959 y2 -= offsetY || 0; 4960 width = 0; 4961 height = 0; 4962 if (!isAutoUpdateEvent || canTrackCursorOnAutoUpdate) { 4963 width = data.axis === "y" ? domRect.width : 0; 4964 height = data.axis === "x" ? domRect.height : 0; 4965 x2 = isXAxis && data.x != null ? data.x : x2; 4966 y2 = isYAxis && data.y != null ? data.y : y2; 4967 } else if (isAutoUpdateEvent && !canTrackCursorOnAutoUpdate) { 4968 height = data.axis === "x" ? domRect.height : height; 4969 width = data.axis === "y" ? domRect.width : width; 4970 } 4971 isAutoUpdateEvent = true; 4972 return { 4973 width, 4974 height, 4975 x: x2, 4976 y: y2, 4977 top: y2, 4978 right: x2 + width, 4979 bottom: y2 + height, 4980 left: x2 4981 }; 4982 } 4983 }; 4984 } 4985 function isMouseBasedEvent(event) { 4986 return event != null && event.clientX != null; 4987 } 4988 function useClientPoint(context, props = {}) { 4989 const { 4990 enabled = true, 4991 axis = "both" 4992 } = props; 4993 const store = "rootStore" in context ? context.rootStore : context; 4994 const open = store.useState("open"); 4995 const floating = store.useState("floatingElement"); 4996 const domReference = store.useState("domReferenceElement"); 4997 const dataRef = store.context.dataRef; 4998 const initialRef = React26.useRef(false); 4999 const cleanupListenerRef = React26.useRef(null); 5000 const [pointerType, setPointerType] = React26.useState(); 5001 const [reactive, setReactive] = React26.useState([]); 5002 const resetReference = useStableCallback((reference2) => { 5003 store.set("positionReference", reference2); 5004 }); 5005 const setReference = useStableCallback((newX, newY, referenceElement) => { 5006 if (initialRef.current) { 5007 return; 5008 } 5009 if (dataRef.current.openEvent && !isMouseBasedEvent(dataRef.current.openEvent)) { 5010 return; 5011 } 5012 store.set("positionReference", createVirtualElement(referenceElement ?? domReference, { 5013 x: newX, 5014 y: newY, 5015 axis, 5016 dataRef, 5017 pointerType 5018 })); 5019 }); 5020 const handleReferenceEnterOrMove = useStableCallback((event) => { 5021 if (!open) { 5022 setReference(event.clientX, event.clientY, event.currentTarget); 5023 } else if (!cleanupListenerRef.current) { 5024 setReference(event.clientX, event.clientY, event.currentTarget); 5025 setReactive([]); 5026 } 5027 }); 5028 const openCheck = isMouseLikePointerType(pointerType) ? floating : open; 5029 React26.useEffect(() => { 5030 if (!enabled) { 5031 resetReference(domReference); 5032 return void 0; 5033 } 5034 if (!openCheck) { 5035 return void 0; 5036 } 5037 function cleanupListener() { 5038 cleanupListenerRef.current?.(); 5039 cleanupListenerRef.current = null; 5040 } 5041 const win = getWindow(floating); 5042 function handleMouseMove(event) { 5043 const target = getTarget(event); 5044 if (!contains(floating, target)) { 5045 setReference(event.clientX, event.clientY); 5046 } else { 5047 cleanupListener(); 5048 } 5049 } 5050 if (!dataRef.current.openEvent || isMouseBasedEvent(dataRef.current.openEvent)) { 5051 cleanupListenerRef.current = addEventListener(win, "mousemove", handleMouseMove); 5052 } else { 5053 resetReference(domReference); 5054 } 5055 return cleanupListener; 5056 }, [openCheck, enabled, floating, dataRef, domReference, store, setReference, resetReference, reactive]); 5057 React26.useEffect(() => () => { 5058 store.set("positionReference", null); 5059 }, [store]); 5060 React26.useEffect(() => { 5061 if (enabled && !floating) { 5062 initialRef.current = false; 5063 } 5064 }, [enabled, floating]); 5065 React26.useEffect(() => { 5066 if (!enabled && open) { 5067 initialRef.current = true; 5068 } 5069 }, [enabled, open]); 5070 const reference = React26.useMemo(() => { 5071 function setPointerTypeRef(event) { 5072 setPointerType(event.pointerType); 5073 } 5074 return { 5075 onPointerDown: setPointerTypeRef, 5076 onPointerEnter: setPointerTypeRef, 5077 onMouseMove: handleReferenceEnterOrMove, 5078 onMouseEnter: handleReferenceEnterOrMove 5079 }; 5080 }, [handleReferenceEnterOrMove]); 5081 return React26.useMemo(() => enabled ? { 5082 reference, 5083 trigger: reference 5084 } : {}, [enabled, reference]); 5085 } 5086 5087 // node_modules/@base-ui/react/floating-ui-react/hooks/useDismiss.mjs 5088 var React27 = __toESM(require_react(), 1); 5089 function alwaysFalse() { 5090 return false; 5091 } 5092 function normalizeProp(normalizable) { 5093 return { 5094 escapeKey: typeof normalizable === "boolean" ? normalizable : normalizable?.escapeKey ?? false, 5095 outsidePress: typeof normalizable === "boolean" ? normalizable : normalizable?.outsidePress ?? true 5096 }; 5097 } 5098 function useDismiss(context, props = {}) { 5099 const { 5100 enabled = true, 5101 escapeKey: escapeKey2 = true, 5102 outsidePress: outsidePressProp = true, 5103 outsidePressEvent = "sloppy", 5104 referencePress = alwaysFalse, 5105 bubbles, 5106 externalTree 5107 } = props; 5108 const store = "rootStore" in context ? context.rootStore : context; 5109 const open = store.useState("open"); 5110 const floatingElement = store.useState("floatingElement"); 5111 const { 5112 dataRef 5113 } = store.context; 5114 const tree = useFloatingTree(externalTree); 5115 const outsidePressFn = useStableCallback(typeof outsidePressProp === "function" ? outsidePressProp : () => false); 5116 const outsidePress2 = typeof outsidePressProp === "function" ? outsidePressFn : outsidePressProp; 5117 const outsidePressEnabled = outsidePress2 !== false; 5118 const getOutsidePressEventProp = useStableCallback(() => outsidePressEvent); 5119 const { 5120 escapeKey: escapeKeyBubbles, 5121 outsidePress: outsidePressBubbles 5122 } = normalizeProp(bubbles); 5123 const pressStartedInsideRef = React27.useRef(false); 5124 const pressStartPreventedRef = React27.useRef(false); 5125 const suppressNextOutsideClickRef = React27.useRef(false); 5126 const isComposingRef = React27.useRef(false); 5127 const currentPointerTypeRef = React27.useRef(""); 5128 const touchStateRef = React27.useRef(null); 5129 const cancelDismissOnEndTimeout = useTimeout(); 5130 const clearInsideReactTreeTimeout = useTimeout(); 5131 const clearInsideReactTree = useStableCallback(() => { 5132 clearInsideReactTreeTimeout.clear(); 5133 dataRef.current.insideReactTree = false; 5134 }); 5135 const hasBlockingChild = useStableCallback((bubbleKey) => { 5136 const nodeId = dataRef.current.floatingContext?.nodeId; 5137 const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : []; 5138 return children.some((child) => child.context?.open && !child.context.dataRef.current[bubbleKey]); 5139 }); 5140 const isEventWithinOwnElements = useStableCallback((event) => { 5141 return isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement")); 5142 }); 5143 const closeOnReferencePress = useStableCallback((event) => { 5144 if (!referencePress()) { 5145 return; 5146 } 5147 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent)); 5148 }); 5149 const closeOnEscapeKeyDown = useStableCallback((event) => { 5150 if (!open || !enabled || !escapeKey2 || event.key !== "Escape") { 5151 return; 5152 } 5153 if (isComposingRef.current) { 5154 return; 5155 } 5156 if (!escapeKeyBubbles && hasBlockingChild("__escapeKeyBubbles")) { 5157 return; 5158 } 5159 const native = isReactEvent(event) ? event.nativeEvent : event; 5160 const eventDetails = createChangeEventDetails(reason_parts_exports.escapeKey, native); 5161 store.setOpen(false, eventDetails); 5162 if (!eventDetails.isCanceled) { 5163 event.preventDefault(); 5164 } 5165 if (!escapeKeyBubbles && !eventDetails.isPropagationAllowed) { 5166 event.stopPropagation(); 5167 } 5168 }); 5169 const markInsideReactTree = useStableCallback(() => { 5170 dataRef.current.insideReactTree = true; 5171 clearInsideReactTreeTimeout.start(0, clearInsideReactTree); 5172 }); 5173 const markPressStartedInsideReactTree = useStableCallback((event) => { 5174 if (!open || !enabled || event.button !== 0) { 5175 return; 5176 } 5177 const target = getTarget(event.nativeEvent); 5178 if (!contains(store.select("floatingElement"), target)) { 5179 return; 5180 } 5181 if (!pressStartedInsideRef.current) { 5182 pressStartedInsideRef.current = true; 5183 pressStartPreventedRef.current = false; 5184 } 5185 }); 5186 const markInsidePressStartPrevented = useStableCallback((event) => { 5187 if (!open || !enabled) { 5188 return; 5189 } 5190 if (!(event.defaultPrevented || event.nativeEvent.defaultPrevented)) { 5191 return; 5192 } 5193 if (pressStartedInsideRef.current) { 5194 pressStartPreventedRef.current = true; 5195 } 5196 }); 5197 React27.useEffect(() => { 5198 if (!open || !enabled) { 5199 return void 0; 5200 } 5201 dataRef.current.__escapeKeyBubbles = escapeKeyBubbles; 5202 dataRef.current.__outsidePressBubbles = outsidePressBubbles; 5203 const compositionTimeout = new Timeout(); 5204 const preventedPressSuppressionTimeout = new Timeout(); 5205 function handleCompositionStart() { 5206 compositionTimeout.clear(); 5207 isComposingRef.current = true; 5208 } 5209 function handleCompositionEnd() { 5210 compositionTimeout.start( 5211 // 0ms or 1ms don't work in Safari. 5ms appears to consistently work. 5212 // Only apply to WebKit for the test to remain 0ms. 5213 parts_exports.engine.webkit ? 5 : 0, 5214 () => { 5215 isComposingRef.current = false; 5216 } 5217 ); 5218 } 5219 function suppressImmediateOutsideClickAfterPreventedStart() { 5220 suppressNextOutsideClickRef.current = true; 5221 preventedPressSuppressionTimeout.start(0, () => { 5222 suppressNextOutsideClickRef.current = false; 5223 }); 5224 } 5225 function resetPressStartState() { 5226 pressStartedInsideRef.current = false; 5227 pressStartPreventedRef.current = false; 5228 } 5229 function getOutsidePressEvent() { 5230 const type = currentPointerTypeRef.current; 5231 const computedType = type === "pen" || !type ? "mouse" : type; 5232 const outsidePressEventValue = getOutsidePressEventProp(); 5233 const resolved = typeof outsidePressEventValue === "function" ? outsidePressEventValue() : outsidePressEventValue; 5234 if (typeof resolved === "string") { 5235 return resolved; 5236 } 5237 return resolved[computedType]; 5238 } 5239 function shouldIgnoreEvent(event) { 5240 const computedOutsidePressEvent = getOutsidePressEvent(); 5241 return computedOutsidePressEvent === "intentional" && event.type !== "click" || computedOutsidePressEvent === "sloppy" && event.type === "click"; 5242 } 5243 function isEventWithinFloatingTree(event) { 5244 const nodeId = dataRef.current.floatingContext?.nodeId; 5245 const targetIsInsideChildren = tree && getNodeChildren(tree.nodesRef.current, nodeId).some((node) => isEventTargetWithin(event, node.context?.elements.floating)); 5246 return isEventWithinOwnElements(event) || targetIsInsideChildren; 5247 } 5248 function closeOnPressOutside(event) { 5249 if (shouldIgnoreEvent(event)) { 5250 if (event.type !== "click" && !isEventWithinOwnElements(event)) { 5251 preventedPressSuppressionTimeout.clear(); 5252 suppressNextOutsideClickRef.current = false; 5253 } 5254 clearInsideReactTree(); 5255 return; 5256 } 5257 if (dataRef.current.insideReactTree) { 5258 clearInsideReactTree(); 5259 return; 5260 } 5261 const target = getTarget(event); 5262 const inertSelector = `[$createAttribute("inert")}]`; 5263 const targetRoot = isElement(target) ? target.getRootNode() : null; 5264 const markers = Array.from((isShadowRoot(targetRoot) ? targetRoot : ownerDocument(store.select("floatingElement"))).querySelectorAll(inertSelector)); 5265 const triggers = store.context.triggerElements; 5266 if (target && (triggers.hasElement(target) || triggers.hasMatchingElement((trigger) => contains(trigger, target)))) { 5267 return; 5268 } 5269 let targetRootAncestor = isElement(target) ? target : null; 5270 while (targetRootAncestor && !isLastTraversableNode(targetRootAncestor)) { 5271 const nextParent = getParentNode(targetRootAncestor); 5272 if (isLastTraversableNode(nextParent) || !isElement(nextParent)) { 5273 break; 5274 } 5275 targetRootAncestor = nextParent; 5276 } 5277 if (markers.length && isElement(target) && !isRootElement(target) && // Clicked on a direct ancestor (e.g. FloatingOverlay). 5278 !contains(target, store.select("floatingElement")) && // If the target root element contains none of the markers, then the 5279 // element was injected after the floating element rendered. 5280 markers.every((marker) => !contains(targetRootAncestor, marker))) { 5281 return; 5282 } 5283 if (isHTMLElement(target) && !("touches" in event)) { 5284 const lastTraversableNode = isLastTraversableNode(target); 5285 const style = getComputedStyle2(target); 5286 const scrollRe = /auto|scroll/; 5287 const isScrollableX = lastTraversableNode || scrollRe.test(style.overflowX); 5288 const isScrollableY = lastTraversableNode || scrollRe.test(style.overflowY); 5289 const canScrollX = isScrollableX && target.clientWidth > 0 && target.scrollWidth > target.clientWidth; 5290 const canScrollY = isScrollableY && target.clientHeight > 0 && target.scrollHeight > target.clientHeight; 5291 const isRTL7 = style.direction === "rtl"; 5292 const pressedVerticalScrollbar = canScrollY && (isRTL7 ? event.offsetX <= target.offsetWidth - target.clientWidth : event.offsetX > target.clientWidth); 5293 const pressedHorizontalScrollbar = canScrollX && event.offsetY > target.clientHeight; 5294 if (pressedVerticalScrollbar || pressedHorizontalScrollbar) { 5295 return; 5296 } 5297 } 5298 if (isEventWithinFloatingTree(event)) { 5299 return; 5300 } 5301 if (getOutsidePressEvent() === "intentional" && suppressNextOutsideClickRef.current) { 5302 preventedPressSuppressionTimeout.clear(); 5303 suppressNextOutsideClickRef.current = false; 5304 return; 5305 } 5306 if (typeof outsidePress2 === "function" && !outsidePress2(event)) { 5307 return; 5308 } 5309 if (hasBlockingChild("__outsidePressBubbles")) { 5310 return; 5311 } 5312 store.setOpen(false, createChangeEventDetails(reason_parts_exports.outsidePress, event)); 5313 clearInsideReactTree(); 5314 } 5315 function handlePointerDown(event) { 5316 if (getOutsidePressEvent() !== "sloppy" || event.pointerType === "touch" || !store.select("open") || !enabled || isEventWithinOwnElements(event)) { 5317 return; 5318 } 5319 closeOnPressOutside(event); 5320 } 5321 function handleTouchStart(event) { 5322 if (getOutsidePressEvent() !== "sloppy" || !store.select("open") || !enabled || isEventWithinOwnElements(event)) { 5323 return; 5324 } 5325 const touch = event.touches[0]; 5326 if (touch) { 5327 touchStateRef.current = { 5328 startTime: Date.now(), 5329 startX: touch.clientX, 5330 startY: touch.clientY, 5331 dismissOnTouchEnd: false, 5332 dismissOnMouseDown: true 5333 }; 5334 cancelDismissOnEndTimeout.start(1e3, () => { 5335 if (touchStateRef.current) { 5336 touchStateRef.current.dismissOnTouchEnd = false; 5337 touchStateRef.current.dismissOnMouseDown = false; 5338 } 5339 }); 5340 } 5341 } 5342 function addTargetEventListenerOnce(event, listener) { 5343 const target = getTarget(event); 5344 if (!target) { 5345 return; 5346 } 5347 const unsubscribe2 = addEventListener(target, event.type, () => { 5348 listener(event); 5349 unsubscribe2(); 5350 }); 5351 } 5352 function handleTouchStartCapture(event) { 5353 currentPointerTypeRef.current = "touch"; 5354 addTargetEventListenerOnce(event, handleTouchStart); 5355 } 5356 function closeOnPressOutsideCapture(event) { 5357 cancelDismissOnEndTimeout.clear(); 5358 if (event.type === "pointerdown") { 5359 currentPointerTypeRef.current = event.pointerType; 5360 } 5361 if (event.type === "mousedown" && touchStateRef.current && !touchStateRef.current.dismissOnMouseDown) { 5362 return; 5363 } 5364 addTargetEventListenerOnce(event, (targetEvent) => { 5365 if (targetEvent.type === "pointerdown") { 5366 handlePointerDown(targetEvent); 5367 } else { 5368 closeOnPressOutside(targetEvent); 5369 } 5370 }); 5371 } 5372 function handlePressEndCapture(event) { 5373 if (!pressStartedInsideRef.current) { 5374 return; 5375 } 5376 const pressStartedInsideDefaultPrevented = pressStartPreventedRef.current; 5377 resetPressStartState(); 5378 if (getOutsidePressEvent() !== "intentional") { 5379 return; 5380 } 5381 if (event.type === "pointercancel") { 5382 if (pressStartedInsideDefaultPrevented) { 5383 suppressImmediateOutsideClickAfterPreventedStart(); 5384 } 5385 return; 5386 } 5387 if (isEventWithinFloatingTree(event)) { 5388 return; 5389 } 5390 if (pressStartedInsideDefaultPrevented) { 5391 suppressImmediateOutsideClickAfterPreventedStart(); 5392 return; 5393 } 5394 if (typeof outsidePress2 === "function" && !outsidePress2(event)) { 5395 return; 5396 } 5397 preventedPressSuppressionTimeout.clear(); 5398 suppressNextOutsideClickRef.current = true; 5399 clearInsideReactTree(); 5400 } 5401 function handleTouchMove(event) { 5402 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) { 5403 return; 5404 } 5405 const touch = event.touches[0]; 5406 if (!touch) { 5407 return; 5408 } 5409 const deltaX = Math.abs(touch.clientX - touchStateRef.current.startX); 5410 const deltaY = Math.abs(touch.clientY - touchStateRef.current.startY); 5411 const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY); 5412 if (distance > 5) { 5413 touchStateRef.current.dismissOnTouchEnd = true; 5414 } 5415 if (distance > 10) { 5416 closeOnPressOutside(event); 5417 cancelDismissOnEndTimeout.clear(); 5418 touchStateRef.current = null; 5419 } 5420 } 5421 function handleTouchMoveCapture(event) { 5422 addTargetEventListenerOnce(event, handleTouchMove); 5423 } 5424 function handleTouchEnd(event) { 5425 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) { 5426 return; 5427 } 5428 if (touchStateRef.current.dismissOnTouchEnd) { 5429 closeOnPressOutside(event); 5430 } 5431 cancelDismissOnEndTimeout.clear(); 5432 touchStateRef.current = null; 5433 } 5434 function handleTouchEndCapture(event) { 5435 addTargetEventListenerOnce(event, handleTouchEnd); 5436 } 5437 const doc = ownerDocument(floatingElement); 5438 const unsubscribe = mergeCleanups(escapeKey2 && mergeCleanups(addEventListener(doc, "keydown", closeOnEscapeKeyDown), addEventListener(doc, "compositionstart", handleCompositionStart), addEventListener(doc, "compositionend", handleCompositionEnd)), outsidePressEnabled && mergeCleanups(addEventListener(doc, "click", closeOnPressOutsideCapture, true), addEventListener(doc, "pointerdown", closeOnPressOutsideCapture, true), addEventListener(doc, "pointerup", handlePressEndCapture, true), addEventListener(doc, "pointercancel", handlePressEndCapture, true), addEventListener(doc, "mousedown", closeOnPressOutsideCapture, true), addEventListener(doc, "mouseup", handlePressEndCapture, true), addEventListener(doc, "touchstart", handleTouchStartCapture, true), addEventListener(doc, "touchmove", handleTouchMoveCapture, true), addEventListener(doc, "touchend", handleTouchEndCapture, true))); 5439 return () => { 5440 unsubscribe(); 5441 compositionTimeout.clear(); 5442 preventedPressSuppressionTimeout.clear(); 5443 resetPressStartState(); 5444 suppressNextOutsideClickRef.current = false; 5445 }; 5446 }, [dataRef, floatingElement, escapeKey2, outsidePressEnabled, outsidePress2, open, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, clearInsideReactTree, getOutsidePressEventProp, hasBlockingChild, isEventWithinOwnElements, tree, store, cancelDismissOnEndTimeout]); 5447 React27.useEffect(clearInsideReactTree, [outsidePress2, clearInsideReactTree]); 5448 const reference = React27.useMemo(() => ({ 5449 onKeyDown: closeOnEscapeKeyDown, 5450 onPointerDown: closeOnReferencePress, 5451 onClick: closeOnReferencePress 5452 }), [closeOnEscapeKeyDown, closeOnReferencePress]); 5453 const floating = React27.useMemo(() => ({ 5454 onKeyDown: closeOnEscapeKeyDown, 5455 // `onMouseDown` may be blocked if `event.preventDefault()` is called in 5456 // `onPointerDown`, such as with <NumberField.ScrubArea>. 5457 // See https://github.com/mui/base-ui/pull/3379 5458 onPointerDown: markInsidePressStartPrevented, 5459 onMouseDown: markInsidePressStartPrevented, 5460 onClickCapture: markInsideReactTree, 5461 onMouseDownCapture(event) { 5462 markInsideReactTree(); 5463 markPressStartedInsideReactTree(event); 5464 }, 5465 onPointerDownCapture(event) { 5466 markInsideReactTree(); 5467 markPressStartedInsideReactTree(event); 5468 }, 5469 onMouseUpCapture: markInsideReactTree, 5470 onTouchEndCapture: markInsideReactTree, 5471 onTouchMoveCapture: markInsideReactTree 5472 }), [closeOnEscapeKeyDown, markInsideReactTree, markPressStartedInsideReactTree, markInsidePressStartPrevented]); 5473 return React27.useMemo(() => enabled ? { 5474 reference, 5475 floating, 5476 trigger: reference 5477 } : {}, [enabled, reference, floating]); 5478 } 5479 5480 // node_modules/@base-ui/react/floating-ui-react/hooks/useFloating.mjs 5481 var React34 = __toESM(require_react(), 1); 5482 5483 // node_modules/@floating-ui/core/dist/floating-ui.core.mjs 5484 function computeCoordsFromPlacement(_ref, placement, rtl) { 5485 let { 5486 reference, 5487 floating 5488 } = _ref; 5489 const sideAxis = getSideAxis(placement); 5490 const alignmentAxis = getAlignmentAxis(placement); 5491 const alignLength = getAxisLength(alignmentAxis); 5492 const side = getSide(placement); 5493 const isVertical = sideAxis === "y"; 5494 const commonX = reference.x + reference.width / 2 - floating.width / 2; 5495 const commonY = reference.y + reference.height / 2 - floating.height / 2; 5496 const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2; 5497 let coords; 5498 switch (side) { 5499 case "top": 5500 coords = { 5501 x: commonX, 5502 y: reference.y - floating.height 5503 }; 5504 break; 5505 case "bottom": 5506 coords = { 5507 x: commonX, 5508 y: reference.y + reference.height 5509 }; 5510 break; 5511 case "right": 5512 coords = { 5513 x: reference.x + reference.width, 5514 y: commonY 5515 }; 5516 break; 5517 case "left": 5518 coords = { 5519 x: reference.x - floating.width, 5520 y: commonY 5521 }; 5522 break; 5523 default: 5524 coords = { 5525 x: reference.x, 5526 y: reference.y 5527 }; 5528 } 5529 switch (getAlignment(placement)) { 5530 case "start": 5531 coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1); 5532 break; 5533 case "end": 5534 coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1); 5535 break; 5536 } 5537 return coords; 5538 } 5539 async function detectOverflow(state, options) { 5540 var _await$platform$isEle; 5541 if (options === void 0) { 5542 options = {}; 5543 } 5544 const { 5545 x: x2, 5546 y: y2, 5547 platform: platform3, 5548 rects, 5549 elements, 5550 strategy 5551 } = state; 5552 const { 5553 boundary = "clippingAncestors", 5554 rootBoundary = "viewport", 5555 elementContext = "floating", 5556 altBoundary = false, 5557 padding = 0 5558 } = evaluate(options, state); 5559 const paddingObject = getPaddingObject(padding); 5560 const altContext = elementContext === "floating" ? "reference" : "floating"; 5561 const element = elements[altBoundary ? altContext : elementContext]; 5562 const clippingClientRect = rectToClientRect(await platform3.getClippingRect({ 5563 element: ((_await$platform$isEle = await (platform3.isElement == null ? void 0 : platform3.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || await (platform3.getDocumentElement == null ? void 0 : platform3.getDocumentElement(elements.floating)), 5564 boundary, 5565 rootBoundary, 5566 strategy 5567 })); 5568 const rect = elementContext === "floating" ? { 5569 x: x2, 5570 y: y2, 5571 width: rects.floating.width, 5572 height: rects.floating.height 5573 } : rects.reference; 5574 const offsetParent = await (platform3.getOffsetParent == null ? void 0 : platform3.getOffsetParent(elements.floating)); 5575 const offsetScale = await (platform3.isElement == null ? void 0 : platform3.isElement(offsetParent)) ? await (platform3.getScale == null ? void 0 : platform3.getScale(offsetParent)) || { 5576 x: 1, 5577 y: 1 5578 } : { 5579 x: 1, 5580 y: 1 5581 }; 5582 const elementClientRect = rectToClientRect(platform3.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform3.convertOffsetParentRelativeRectToViewportRelativeRect({ 5583 elements, 5584 rect, 5585 offsetParent, 5586 strategy 5587 }) : rect); 5588 return { 5589 top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y, 5590 bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y, 5591 left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x, 5592 right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x 5593 }; 5594 } 5595 var MAX_RESET_COUNT = 50; 5596 var computePosition = async (reference, floating, config) => { 5597 const { 5598 placement = "bottom", 5599 strategy = "absolute", 5600 middleware = [], 5601 platform: platform3 5602 } = config; 5603 const platformWithDetectOverflow = platform3.detectOverflow ? platform3 : { 5604 ...platform3, 5605 detectOverflow 5606 }; 5607 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(floating)); 5608 let rects = await platform3.getElementRects({ 5609 reference, 5610 floating, 5611 strategy 5612 }); 5613 let { 5614 x: x2, 5615 y: y2 5616 } = computeCoordsFromPlacement(rects, placement, rtl); 5617 let statefulPlacement = placement; 5618 let resetCount = 0; 5619 const middlewareData = {}; 5620 for (let i2 = 0; i2 < middleware.length; i2++) { 5621 const currentMiddleware = middleware[i2]; 5622 if (!currentMiddleware) { 5623 continue; 5624 } 5625 const { 5626 name, 5627 fn 5628 } = currentMiddleware; 5629 const { 5630 x: nextX, 5631 y: nextY, 5632 data, 5633 reset 5634 } = await fn({ 5635 x: x2, 5636 y: y2, 5637 initialPlacement: placement, 5638 placement: statefulPlacement, 5639 strategy, 5640 middlewareData, 5641 rects, 5642 platform: platformWithDetectOverflow, 5643 elements: { 5644 reference, 5645 floating 5646 } 5647 }); 5648 x2 = nextX != null ? nextX : x2; 5649 y2 = nextY != null ? nextY : y2; 5650 middlewareData[name] = { 5651 ...middlewareData[name], 5652 ...data 5653 }; 5654 if (reset && resetCount < MAX_RESET_COUNT) { 5655 resetCount++; 5656 if (typeof reset === "object") { 5657 if (reset.placement) { 5658 statefulPlacement = reset.placement; 5659 } 5660 if (reset.rects) { 5661 rects = reset.rects === true ? await platform3.getElementRects({ 5662 reference, 5663 floating, 5664 strategy 5665 }) : reset.rects; 5666 } 5667 ({ 5668 x: x2, 5669 y: y2 5670 } = computeCoordsFromPlacement(rects, statefulPlacement, rtl)); 5671 } 5672 i2 = -1; 5673 } 5674 } 5675 return { 5676 x: x2, 5677 y: y2, 5678 placement: statefulPlacement, 5679 strategy, 5680 middlewareData 5681 }; 5682 }; 5683 var flip = function(options) { 5684 if (options === void 0) { 5685 options = {}; 5686 } 5687 return { 5688 name: "flip", 5689 options, 5690 async fn(state) { 5691 var _middlewareData$arrow, _middlewareData$flip; 5692 const { 5693 placement, 5694 middlewareData, 5695 rects, 5696 initialPlacement, 5697 platform: platform3, 5698 elements 5699 } = state; 5700 const { 5701 mainAxis: checkMainAxis = true, 5702 crossAxis: checkCrossAxis = true, 5703 fallbackPlacements: specifiedFallbackPlacements, 5704 fallbackStrategy = "bestFit", 5705 fallbackAxisSideDirection = "none", 5706 flipAlignment = true, 5707 ...detectOverflowOptions 5708 } = evaluate(options, state); 5709 if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) { 5710 return {}; 5711 } 5712 const side = getSide(placement); 5713 const initialSideAxis = getSideAxis(initialPlacement); 5714 const isBasePlacement = getSide(initialPlacement) === initialPlacement; 5715 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating)); 5716 const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement)); 5717 const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none"; 5718 if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) { 5719 fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl)); 5720 } 5721 const placements2 = [initialPlacement, ...fallbackPlacements]; 5722 const overflow = await platform3.detectOverflow(state, detectOverflowOptions); 5723 const overflows = []; 5724 let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || []; 5725 if (checkMainAxis) { 5726 overflows.push(overflow[side]); 5727 } 5728 if (checkCrossAxis) { 5729 const sides2 = getAlignmentSides(placement, rects, rtl); 5730 overflows.push(overflow[sides2[0]], overflow[sides2[1]]); 5731 } 5732 overflowsData = [...overflowsData, { 5733 placement, 5734 overflows 5735 }]; 5736 if (!overflows.every((side2) => side2 <= 0)) { 5737 var _middlewareData$flip2, _overflowsData$filter; 5738 const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1; 5739 const nextPlacement = placements2[nextIndex]; 5740 if (nextPlacement) { 5741 const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false; 5742 if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis 5743 // overflows the main axis. 5744 overflowsData.every((d2) => getSideAxis(d2.placement) === initialSideAxis ? d2.overflows[0] > 0 : true)) { 5745 return { 5746 data: { 5747 index: nextIndex, 5748 overflows: overflowsData 5749 }, 5750 reset: { 5751 placement: nextPlacement 5752 } 5753 }; 5754 } 5755 } 5756 let resetPlacement = (_overflowsData$filter = overflowsData.filter((d2) => d2.overflows[0] <= 0).sort((a2, b2) => a2.overflows[1] - b2.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement; 5757 if (!resetPlacement) { 5758 switch (fallbackStrategy) { 5759 case "bestFit": { 5760 var _overflowsData$filter2; 5761 const placement2 = (_overflowsData$filter2 = overflowsData.filter((d2) => { 5762 if (hasFallbackAxisSideDirection) { 5763 const currentSideAxis = getSideAxis(d2.placement); 5764 return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal 5765 // reading directions favoring greater width. 5766 currentSideAxis === "y"; 5767 } 5768 return true; 5769 }).map((d2) => [d2.placement, d2.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0)]).sort((a2, b2) => a2[1] - b2[1])[0]) == null ? void 0 : _overflowsData$filter2[0]; 5770 if (placement2) { 5771 resetPlacement = placement2; 5772 } 5773 break; 5774 } 5775 case "initialPlacement": 5776 resetPlacement = initialPlacement; 5777 break; 5778 } 5779 } 5780 if (placement !== resetPlacement) { 5781 return { 5782 reset: { 5783 placement: resetPlacement 5784 } 5785 }; 5786 } 5787 } 5788 return {}; 5789 } 5790 }; 5791 }; 5792 function getSideOffsets(overflow, rect) { 5793 return { 5794 top: overflow.top - rect.height, 5795 right: overflow.right - rect.width, 5796 bottom: overflow.bottom - rect.height, 5797 left: overflow.left - rect.width 5798 }; 5799 } 5800 function isAnySideFullyClipped(overflow) { 5801 return sides.some((side) => overflow[side] >= 0); 5802 } 5803 var hide = function(options) { 5804 if (options === void 0) { 5805 options = {}; 5806 } 5807 return { 5808 name: "hide", 5809 options, 5810 async fn(state) { 5811 const { 5812 rects, 5813 platform: platform3 5814 } = state; 5815 const { 5816 strategy = "referenceHidden", 5817 ...detectOverflowOptions 5818 } = evaluate(options, state); 5819 switch (strategy) { 5820 case "referenceHidden": { 5821 const overflow = await platform3.detectOverflow(state, { 5822 ...detectOverflowOptions, 5823 elementContext: "reference" 5824 }); 5825 const offsets = getSideOffsets(overflow, rects.reference); 5826 return { 5827 data: { 5828 referenceHiddenOffsets: offsets, 5829 referenceHidden: isAnySideFullyClipped(offsets) 5830 } 5831 }; 5832 } 5833 case "escaped": { 5834 const overflow = await platform3.detectOverflow(state, { 5835 ...detectOverflowOptions, 5836 altBoundary: true 5837 }); 5838 const offsets = getSideOffsets(overflow, rects.floating); 5839 return { 5840 data: { 5841 escapedOffsets: offsets, 5842 escaped: isAnySideFullyClipped(offsets) 5843 } 5844 }; 5845 } 5846 default: { 5847 return {}; 5848 } 5849 } 5850 } 5851 }; 5852 }; 5853 var originSides = /* @__PURE__ */ new Set(["left", "top"]); 5854 async function convertValueToCoords(state, options) { 5855 const { 5856 placement, 5857 platform: platform3, 5858 elements 5859 } = state; 5860 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating)); 5861 const side = getSide(placement); 5862 const alignment = getAlignment(placement); 5863 const isVertical = getSideAxis(placement) === "y"; 5864 const mainAxisMulti = originSides.has(side) ? -1 : 1; 5865 const crossAxisMulti = rtl && isVertical ? -1 : 1; 5866 const rawValue = evaluate(options, state); 5867 let { 5868 mainAxis, 5869 crossAxis, 5870 alignmentAxis 5871 } = typeof rawValue === "number" ? { 5872 mainAxis: rawValue, 5873 crossAxis: 0, 5874 alignmentAxis: null 5875 } : { 5876 mainAxis: rawValue.mainAxis || 0, 5877 crossAxis: rawValue.crossAxis || 0, 5878 alignmentAxis: rawValue.alignmentAxis 5879 }; 5880 if (alignment && typeof alignmentAxis === "number") { 5881 crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis; 5882 } 5883 return isVertical ? { 5884 x: crossAxis * crossAxisMulti, 5885 y: mainAxis * mainAxisMulti 5886 } : { 5887 x: mainAxis * mainAxisMulti, 5888 y: crossAxis * crossAxisMulti 5889 }; 5890 } 5891 var offset = function(options) { 5892 if (options === void 0) { 5893 options = 0; 5894 } 5895 return { 5896 name: "offset", 5897 options, 5898 async fn(state) { 5899 var _middlewareData$offse, _middlewareData$arrow; 5900 const { 5901 x: x2, 5902 y: y2, 5903 placement, 5904 middlewareData 5905 } = state; 5906 const diffCoords = await convertValueToCoords(state, options); 5907 if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) { 5908 return {}; 5909 } 5910 return { 5911 x: x2 + diffCoords.x, 5912 y: y2 + diffCoords.y, 5913 data: { 5914 ...diffCoords, 5915 placement 5916 } 5917 }; 5918 } 5919 }; 5920 }; 5921 var shift = function(options) { 5922 if (options === void 0) { 5923 options = {}; 5924 } 5925 return { 5926 name: "shift", 5927 options, 5928 async fn(state) { 5929 const { 5930 x: x2, 5931 y: y2, 5932 placement, 5933 platform: platform3 5934 } = state; 5935 const { 5936 mainAxis: checkMainAxis = true, 5937 crossAxis: checkCrossAxis = false, 5938 limiter = { 5939 fn: (_ref) => { 5940 let { 5941 x: x3, 5942 y: y3 5943 } = _ref; 5944 return { 5945 x: x3, 5946 y: y3 5947 }; 5948 } 5949 }, 5950 ...detectOverflowOptions 5951 } = evaluate(options, state); 5952 const coords = { 5953 x: x2, 5954 y: y2 5955 }; 5956 const overflow = await platform3.detectOverflow(state, detectOverflowOptions); 5957 const crossAxis = getSideAxis(getSide(placement)); 5958 const mainAxis = getOppositeAxis(crossAxis); 5959 let mainAxisCoord = coords[mainAxis]; 5960 let crossAxisCoord = coords[crossAxis]; 5961 if (checkMainAxis) { 5962 const minSide = mainAxis === "y" ? "top" : "left"; 5963 const maxSide = mainAxis === "y" ? "bottom" : "right"; 5964 const min2 = mainAxisCoord + overflow[minSide]; 5965 const max2 = mainAxisCoord - overflow[maxSide]; 5966 mainAxisCoord = clamp(min2, mainAxisCoord, max2); 5967 } 5968 if (checkCrossAxis) { 5969 const minSide = crossAxis === "y" ? "top" : "left"; 5970 const maxSide = crossAxis === "y" ? "bottom" : "right"; 5971 const min2 = crossAxisCoord + overflow[minSide]; 5972 const max2 = crossAxisCoord - overflow[maxSide]; 5973 crossAxisCoord = clamp(min2, crossAxisCoord, max2); 5974 } 5975 const limitedCoords = limiter.fn({ 5976 ...state, 5977 [mainAxis]: mainAxisCoord, 5978 [crossAxis]: crossAxisCoord 5979 }); 5980 return { 5981 ...limitedCoords, 5982 data: { 5983 x: limitedCoords.x - x2, 5984 y: limitedCoords.y - y2, 5985 enabled: { 5986 [mainAxis]: checkMainAxis, 5987 [crossAxis]: checkCrossAxis 5988 } 5989 } 5990 }; 5991 } 5992 }; 5993 }; 5994 var limitShift = function(options) { 5995 if (options === void 0) { 5996 options = {}; 5997 } 5998 return { 5999 options, 6000 fn(state) { 6001 const { 6002 x: x2, 6003 y: y2, 6004 placement, 6005 rects, 6006 middlewareData 6007 } = state; 6008 const { 6009 offset: offset4 = 0, 6010 mainAxis: checkMainAxis = true, 6011 crossAxis: checkCrossAxis = true 6012 } = evaluate(options, state); 6013 const coords = { 6014 x: x2, 6015 y: y2 6016 }; 6017 const crossAxis = getSideAxis(placement); 6018 const mainAxis = getOppositeAxis(crossAxis); 6019 let mainAxisCoord = coords[mainAxis]; 6020 let crossAxisCoord = coords[crossAxis]; 6021 const rawOffset = evaluate(offset4, state); 6022 const computedOffset = typeof rawOffset === "number" ? { 6023 mainAxis: rawOffset, 6024 crossAxis: 0 6025 } : { 6026 mainAxis: 0, 6027 crossAxis: 0, 6028 ...rawOffset 6029 }; 6030 if (checkMainAxis) { 6031 const len = mainAxis === "y" ? "height" : "width"; 6032 const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis; 6033 const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis; 6034 if (mainAxisCoord < limitMin) { 6035 mainAxisCoord = limitMin; 6036 } else if (mainAxisCoord > limitMax) { 6037 mainAxisCoord = limitMax; 6038 } 6039 } 6040 if (checkCrossAxis) { 6041 var _middlewareData$offse, _middlewareData$offse2; 6042 const len = mainAxis === "y" ? "width" : "height"; 6043 const isOriginSide = originSides.has(getSide(placement)); 6044 const limitMin = rects.reference[crossAxis] - rects.floating[len] + (isOriginSide ? ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse[crossAxis]) || 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis); 6045 const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : ((_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[crossAxis]) || 0) - (isOriginSide ? computedOffset.crossAxis : 0); 6046 if (crossAxisCoord < limitMin) { 6047 crossAxisCoord = limitMin; 6048 } else if (crossAxisCoord > limitMax) { 6049 crossAxisCoord = limitMax; 6050 } 6051 } 6052 return { 6053 [mainAxis]: mainAxisCoord, 6054 [crossAxis]: crossAxisCoord 6055 }; 6056 } 6057 }; 6058 }; 6059 var size = function(options) { 6060 if (options === void 0) { 6061 options = {}; 6062 } 6063 return { 6064 name: "size", 6065 options, 6066 async fn(state) { 6067 var _state$middlewareData, _state$middlewareData2; 6068 const { 6069 placement, 6070 rects, 6071 platform: platform3, 6072 elements 6073 } = state; 6074 const { 6075 apply = () => { 6076 }, 6077 ...detectOverflowOptions 6078 } = evaluate(options, state); 6079 const overflow = await platform3.detectOverflow(state, detectOverflowOptions); 6080 const side = getSide(placement); 6081 const alignment = getAlignment(placement); 6082 const isYAxis = getSideAxis(placement) === "y"; 6083 const { 6084 width, 6085 height 6086 } = rects.floating; 6087 let heightSide; 6088 let widthSide; 6089 if (side === "top" || side === "bottom") { 6090 heightSide = side; 6091 widthSide = alignment === (await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right"; 6092 } else { 6093 widthSide = side; 6094 heightSide = alignment === "end" ? "top" : "bottom"; 6095 } 6096 const maximumClippingHeight = height - overflow.top - overflow.bottom; 6097 const maximumClippingWidth = width - overflow.left - overflow.right; 6098 const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight); 6099 const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth); 6100 const noShift = !state.middlewareData.shift; 6101 let availableHeight = overflowAvailableHeight; 6102 let availableWidth = overflowAvailableWidth; 6103 if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) { 6104 availableWidth = maximumClippingWidth; 6105 } 6106 if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) { 6107 availableHeight = maximumClippingHeight; 6108 } 6109 if (noShift && !alignment) { 6110 const xMin = max(overflow.left, 0); 6111 const xMax = max(overflow.right, 0); 6112 const yMin = max(overflow.top, 0); 6113 const yMax = max(overflow.bottom, 0); 6114 if (isYAxis) { 6115 availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right)); 6116 } else { 6117 availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom)); 6118 } 6119 } 6120 await apply({ 6121 ...state, 6122 availableWidth, 6123 availableHeight 6124 }); 6125 const nextDimensions = await platform3.getDimensions(elements.floating); 6126 if (width !== nextDimensions.width || height !== nextDimensions.height) { 6127 return { 6128 reset: { 6129 rects: true 6130 } 6131 }; 6132 } 6133 return {}; 6134 } 6135 }; 6136 }; 6137 6138 // node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs 6139 function getCssDimensions(element) { 6140 const css = getComputedStyle2(element); 6141 let width = parseFloat(css.width) || 0; 6142 let height = parseFloat(css.height) || 0; 6143 const hasOffset = isHTMLElement(element); 6144 const offsetWidth = hasOffset ? element.offsetWidth : width; 6145 const offsetHeight = hasOffset ? element.offsetHeight : height; 6146 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight; 6147 if (shouldFallback) { 6148 width = offsetWidth; 6149 height = offsetHeight; 6150 } 6151 return { 6152 width, 6153 height, 6154 $: shouldFallback 6155 }; 6156 } 6157 function unwrapElement(element) { 6158 return !isElement(element) ? element.contextElement : element; 6159 } 6160 function getScale(element) { 6161 const domElement = unwrapElement(element); 6162 if (!isHTMLElement(domElement)) { 6163 return createCoords(1); 6164 } 6165 const rect = domElement.getBoundingClientRect(); 6166 const { 6167 width, 6168 height, 6169 $: $2 6170 } = getCssDimensions(domElement); 6171 let x2 = ($2 ? round(rect.width) : rect.width) / width; 6172 let y2 = ($2 ? round(rect.height) : rect.height) / height; 6173 if (!x2 || !Number.isFinite(x2)) { 6174 x2 = 1; 6175 } 6176 if (!y2 || !Number.isFinite(y2)) { 6177 y2 = 1; 6178 } 6179 return { 6180 x: x2, 6181 y: y2 6182 }; 6183 } 6184 var noOffsets = /* @__PURE__ */ createCoords(0); 6185 function getVisualOffsets(element) { 6186 const win = getWindow(element); 6187 if (!isWebKit() || !win.visualViewport) { 6188 return noOffsets; 6189 } 6190 return { 6191 x: win.visualViewport.offsetLeft, 6192 y: win.visualViewport.offsetTop 6193 }; 6194 } 6195 function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) { 6196 if (isFixed === void 0) { 6197 isFixed = false; 6198 } 6199 if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) { 6200 return false; 6201 } 6202 return isFixed; 6203 } 6204 function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) { 6205 if (includeScale === void 0) { 6206 includeScale = false; 6207 } 6208 if (isFixedStrategy === void 0) { 6209 isFixedStrategy = false; 6210 } 6211 const clientRect = element.getBoundingClientRect(); 6212 const domElement = unwrapElement(element); 6213 let scale = createCoords(1); 6214 if (includeScale) { 6215 if (offsetParent) { 6216 if (isElement(offsetParent)) { 6217 scale = getScale(offsetParent); 6218 } 6219 } else { 6220 scale = getScale(element); 6221 } 6222 } 6223 const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0); 6224 let x2 = (clientRect.left + visualOffsets.x) / scale.x; 6225 let y2 = (clientRect.top + visualOffsets.y) / scale.y; 6226 let width = clientRect.width / scale.x; 6227 let height = clientRect.height / scale.y; 6228 if (domElement) { 6229 const win = getWindow(domElement); 6230 const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent; 6231 let currentWin = win; 6232 let currentIFrame = getFrameElement(currentWin); 6233 while (currentIFrame && offsetParent && offsetWin !== currentWin) { 6234 const iframeScale = getScale(currentIFrame); 6235 const iframeRect = currentIFrame.getBoundingClientRect(); 6236 const css = getComputedStyle2(currentIFrame); 6237 const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x; 6238 const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y; 6239 x2 *= iframeScale.x; 6240 y2 *= iframeScale.y; 6241 width *= iframeScale.x; 6242 height *= iframeScale.y; 6243 x2 += left; 6244 y2 += top; 6245 currentWin = getWindow(currentIFrame); 6246 currentIFrame = getFrameElement(currentWin); 6247 } 6248 } 6249 return rectToClientRect({ 6250 width, 6251 height, 6252 x: x2, 6253 y: y2 6254 }); 6255 } 6256 function getWindowScrollBarX(element, rect) { 6257 const leftScroll = getNodeScroll(element).scrollLeft; 6258 if (!rect) { 6259 return getBoundingClientRect(getDocumentElement(element)).left + leftScroll; 6260 } 6261 return rect.left + leftScroll; 6262 } 6263 function getHTMLOffset(documentElement, scroll) { 6264 const htmlRect = documentElement.getBoundingClientRect(); 6265 const x2 = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect); 6266 const y2 = htmlRect.top + scroll.scrollTop; 6267 return { 6268 x: x2, 6269 y: y2 6270 }; 6271 } 6272 function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) { 6273 let { 6274 elements, 6275 rect, 6276 offsetParent, 6277 strategy 6278 } = _ref; 6279 const isFixed = strategy === "fixed"; 6280 const documentElement = getDocumentElement(offsetParent); 6281 const topLayer = elements ? isTopLayer(elements.floating) : false; 6282 if (offsetParent === documentElement || topLayer && isFixed) { 6283 return rect; 6284 } 6285 let scroll = { 6286 scrollLeft: 0, 6287 scrollTop: 0 6288 }; 6289 let scale = createCoords(1); 6290 const offsets = createCoords(0); 6291 const isOffsetParentAnElement = isHTMLElement(offsetParent); 6292 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) { 6293 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) { 6294 scroll = getNodeScroll(offsetParent); 6295 } 6296 if (isOffsetParentAnElement) { 6297 const offsetRect = getBoundingClientRect(offsetParent); 6298 scale = getScale(offsetParent); 6299 offsets.x = offsetRect.x + offsetParent.clientLeft; 6300 offsets.y = offsetRect.y + offsetParent.clientTop; 6301 } 6302 } 6303 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0); 6304 return { 6305 width: rect.width * scale.x, 6306 height: rect.height * scale.y, 6307 x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x, 6308 y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y 6309 }; 6310 } 6311 function getClientRects(element) { 6312 return Array.from(element.getClientRects()); 6313 } 6314 function getDocumentRect(element) { 6315 const html = getDocumentElement(element); 6316 const scroll = getNodeScroll(element); 6317 const body = element.ownerDocument.body; 6318 const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth); 6319 const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight); 6320 let x2 = -scroll.scrollLeft + getWindowScrollBarX(element); 6321 const y2 = -scroll.scrollTop; 6322 if (getComputedStyle2(body).direction === "rtl") { 6323 x2 += max(html.clientWidth, body.clientWidth) - width; 6324 } 6325 return { 6326 width, 6327 height, 6328 x: x2, 6329 y: y2 6330 }; 6331 } 6332 var SCROLLBAR_MAX = 25; 6333 function getViewportRect(element, strategy) { 6334 const win = getWindow(element); 6335 const html = getDocumentElement(element); 6336 const visualViewport = win.visualViewport; 6337 let width = html.clientWidth; 6338 let height = html.clientHeight; 6339 let x2 = 0; 6340 let y2 = 0; 6341 if (visualViewport) { 6342 width = visualViewport.width; 6343 height = visualViewport.height; 6344 const visualViewportBased = isWebKit(); 6345 if (!visualViewportBased || visualViewportBased && strategy === "fixed") { 6346 x2 = visualViewport.offsetLeft; 6347 y2 = visualViewport.offsetTop; 6348 } 6349 } 6350 const windowScrollbarX = getWindowScrollBarX(html); 6351 if (windowScrollbarX <= 0) { 6352 const doc = html.ownerDocument; 6353 const body = doc.body; 6354 const bodyStyles = getComputedStyle(body); 6355 const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0; 6356 const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline); 6357 if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) { 6358 width -= clippingStableScrollbarWidth; 6359 } 6360 } else if (windowScrollbarX <= SCROLLBAR_MAX) { 6361 width += windowScrollbarX; 6362 } 6363 return { 6364 width, 6365 height, 6366 x: x2, 6367 y: y2 6368 }; 6369 } 6370 function getInnerBoundingClientRect(element, strategy) { 6371 const clientRect = getBoundingClientRect(element, true, strategy === "fixed"); 6372 const top = clientRect.top + element.clientTop; 6373 const left = clientRect.left + element.clientLeft; 6374 const scale = isHTMLElement(element) ? getScale(element) : createCoords(1); 6375 const width = element.clientWidth * scale.x; 6376 const height = element.clientHeight * scale.y; 6377 const x2 = left * scale.x; 6378 const y2 = top * scale.y; 6379 return { 6380 width, 6381 height, 6382 x: x2, 6383 y: y2 6384 }; 6385 } 6386 function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) { 6387 let rect; 6388 if (clippingAncestor === "viewport") { 6389 rect = getViewportRect(element, strategy); 6390 } else if (clippingAncestor === "document") { 6391 rect = getDocumentRect(getDocumentElement(element)); 6392 } else if (isElement(clippingAncestor)) { 6393 rect = getInnerBoundingClientRect(clippingAncestor, strategy); 6394 } else { 6395 const visualOffsets = getVisualOffsets(element); 6396 rect = { 6397 x: clippingAncestor.x - visualOffsets.x, 6398 y: clippingAncestor.y - visualOffsets.y, 6399 width: clippingAncestor.width, 6400 height: clippingAncestor.height 6401 }; 6402 } 6403 return rectToClientRect(rect); 6404 } 6405 function hasFixedPositionAncestor(element, stopNode) { 6406 const parentNode = getParentNode(element); 6407 if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) { 6408 return false; 6409 } 6410 return getComputedStyle2(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode); 6411 } 6412 function getClippingElementAncestors(element, cache) { 6413 const cachedResult = cache.get(element); 6414 if (cachedResult) { 6415 return cachedResult; 6416 } 6417 let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body"); 6418 let currentContainingBlockComputedStyle = null; 6419 const elementIsFixed = getComputedStyle2(element).position === "fixed"; 6420 let currentNode = elementIsFixed ? getParentNode(element) : element; 6421 while (isElement(currentNode) && !isLastTraversableNode(currentNode)) { 6422 const computedStyle = getComputedStyle2(currentNode); 6423 const currentNodeIsContaining = isContainingBlock(currentNode); 6424 if (!currentNodeIsContaining && computedStyle.position === "fixed") { 6425 currentContainingBlockComputedStyle = null; 6426 } 6427 const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && (currentContainingBlockComputedStyle.position === "absolute" || currentContainingBlockComputedStyle.position === "fixed") || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode); 6428 if (shouldDropCurrentNode) { 6429 result = result.filter((ancestor) => ancestor !== currentNode); 6430 } else { 6431 currentContainingBlockComputedStyle = computedStyle; 6432 } 6433 currentNode = getParentNode(currentNode); 6434 } 6435 cache.set(element, result); 6436 return result; 6437 } 6438 function getClippingRect(_ref) { 6439 let { 6440 element, 6441 boundary, 6442 rootBoundary, 6443 strategy 6444 } = _ref; 6445 const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary); 6446 const clippingAncestors = [...elementClippingAncestors, rootBoundary]; 6447 const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy); 6448 let top = firstRect.top; 6449 let right = firstRect.right; 6450 let bottom = firstRect.bottom; 6451 let left = firstRect.left; 6452 for (let i2 = 1; i2 < clippingAncestors.length; i2++) { 6453 const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i2], strategy); 6454 top = max(rect.top, top); 6455 right = min(rect.right, right); 6456 bottom = min(rect.bottom, bottom); 6457 left = max(rect.left, left); 6458 } 6459 return { 6460 width: right - left, 6461 height: bottom - top, 6462 x: left, 6463 y: top 6464 }; 6465 } 6466 function getDimensions2(element) { 6467 const { 6468 width, 6469 height 6470 } = getCssDimensions(element); 6471 return { 6472 width, 6473 height 6474 }; 6475 } 6476 function getRectRelativeToOffsetParent(element, offsetParent, strategy) { 6477 const isOffsetParentAnElement = isHTMLElement(offsetParent); 6478 const documentElement = getDocumentElement(offsetParent); 6479 const isFixed = strategy === "fixed"; 6480 const rect = getBoundingClientRect(element, true, isFixed, offsetParent); 6481 let scroll = { 6482 scrollLeft: 0, 6483 scrollTop: 0 6484 }; 6485 const offsets = createCoords(0); 6486 function setLeftRTLScrollbarOffset() { 6487 offsets.x = getWindowScrollBarX(documentElement); 6488 } 6489 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) { 6490 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) { 6491 scroll = getNodeScroll(offsetParent); 6492 } 6493 if (isOffsetParentAnElement) { 6494 const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent); 6495 offsets.x = offsetRect.x + offsetParent.clientLeft; 6496 offsets.y = offsetRect.y + offsetParent.clientTop; 6497 } else if (documentElement) { 6498 setLeftRTLScrollbarOffset(); 6499 } 6500 } 6501 if (isFixed && !isOffsetParentAnElement && documentElement) { 6502 setLeftRTLScrollbarOffset(); 6503 } 6504 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0); 6505 const x2 = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x; 6506 const y2 = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y; 6507 return { 6508 x: x2, 6509 y: y2, 6510 width: rect.width, 6511 height: rect.height 6512 }; 6513 } 6514 function isStaticPositioned(element) { 6515 return getComputedStyle2(element).position === "static"; 6516 } 6517 function getTrueOffsetParent(element, polyfill) { 6518 if (!isHTMLElement(element) || getComputedStyle2(element).position === "fixed") { 6519 return null; 6520 } 6521 if (polyfill) { 6522 return polyfill(element); 6523 } 6524 let rawOffsetParent = element.offsetParent; 6525 if (getDocumentElement(element) === rawOffsetParent) { 6526 rawOffsetParent = rawOffsetParent.ownerDocument.body; 6527 } 6528 return rawOffsetParent; 6529 } 6530 function getOffsetParent(element, polyfill) { 6531 const win = getWindow(element); 6532 if (isTopLayer(element)) { 6533 return win; 6534 } 6535 if (!isHTMLElement(element)) { 6536 let svgOffsetParent = getParentNode(element); 6537 while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) { 6538 if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) { 6539 return svgOffsetParent; 6540 } 6541 svgOffsetParent = getParentNode(svgOffsetParent); 6542 } 6543 return win; 6544 } 6545 let offsetParent = getTrueOffsetParent(element, polyfill); 6546 while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) { 6547 offsetParent = getTrueOffsetParent(offsetParent, polyfill); 6548 } 6549 if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) { 6550 return win; 6551 } 6552 return offsetParent || getContainingBlock(element) || win; 6553 } 6554 var getElementRects = async function(data) { 6555 const getOffsetParentFn = this.getOffsetParent || getOffsetParent; 6556 const getDimensionsFn = this.getDimensions; 6557 const floatingDimensions = await getDimensionsFn(data.floating); 6558 return { 6559 reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy), 6560 floating: { 6561 x: 0, 6562 y: 0, 6563 width: floatingDimensions.width, 6564 height: floatingDimensions.height 6565 } 6566 }; 6567 }; 6568 function isRTL(element) { 6569 return getComputedStyle2(element).direction === "rtl"; 6570 } 6571 var platform2 = { 6572 convertOffsetParentRelativeRectToViewportRelativeRect, 6573 getDocumentElement, 6574 getClippingRect, 6575 getOffsetParent, 6576 getElementRects, 6577 getClientRects, 6578 getDimensions: getDimensions2, 6579 getScale, 6580 isElement, 6581 isRTL 6582 }; 6583 function rectsAreEqual(a2, b2) { 6584 return a2.x === b2.x && a2.y === b2.y && a2.width === b2.width && a2.height === b2.height; 6585 } 6586 function observeMove(element, onMove) { 6587 let io = null; 6588 let timeoutId; 6589 const root = getDocumentElement(element); 6590 function cleanup() { 6591 var _io; 6592 clearTimeout(timeoutId); 6593 (_io = io) == null || _io.disconnect(); 6594 io = null; 6595 } 6596 function refresh(skip, threshold) { 6597 if (skip === void 0) { 6598 skip = false; 6599 } 6600 if (threshold === void 0) { 6601 threshold = 1; 6602 } 6603 cleanup(); 6604 const elementRectForRootMargin = element.getBoundingClientRect(); 6605 const { 6606 left, 6607 top, 6608 width, 6609 height 6610 } = elementRectForRootMargin; 6611 if (!skip) { 6612 onMove(); 6613 } 6614 if (!width || !height) { 6615 return; 6616 } 6617 const insetTop = floor(top); 6618 const insetRight = floor(root.clientWidth - (left + width)); 6619 const insetBottom = floor(root.clientHeight - (top + height)); 6620 const insetLeft = floor(left); 6621 const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px"; 6622 const options = { 6623 rootMargin, 6624 threshold: max(0, min(1, threshold)) || 1 6625 }; 6626 let isFirstUpdate = true; 6627 function handleObserve(entries) { 6628 const ratio = entries[0].intersectionRatio; 6629 if (ratio !== threshold) { 6630 if (!isFirstUpdate) { 6631 return refresh(); 6632 } 6633 if (!ratio) { 6634 timeoutId = setTimeout(() => { 6635 refresh(false, 1e-7); 6636 }, 1e3); 6637 } else { 6638 refresh(false, ratio); 6639 } 6640 } 6641 if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) { 6642 refresh(); 6643 } 6644 isFirstUpdate = false; 6645 } 6646 try { 6647 io = new IntersectionObserver(handleObserve, { 6648 ...options, 6649 // Handle <iframe>s 6650 root: root.ownerDocument 6651 }); 6652 } catch (_e) { 6653 io = new IntersectionObserver(handleObserve, options); 6654 } 6655 io.observe(element); 6656 } 6657 refresh(true); 6658 return cleanup; 6659 } 6660 function autoUpdate(reference, floating, update2, options) { 6661 if (options === void 0) { 6662 options = {}; 6663 } 6664 const { 6665 ancestorScroll = true, 6666 ancestorResize = true, 6667 elementResize = typeof ResizeObserver === "function", 6668 layoutShift = typeof IntersectionObserver === "function", 6669 animationFrame = false 6670 } = options; 6671 const referenceEl = unwrapElement(reference); 6672 const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...floating ? getOverflowAncestors(floating) : []] : []; 6673 ancestors.forEach((ancestor) => { 6674 ancestorScroll && ancestor.addEventListener("scroll", update2, { 6675 passive: true 6676 }); 6677 ancestorResize && ancestor.addEventListener("resize", update2); 6678 }); 6679 const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update2) : null; 6680 let reobserveFrame = -1; 6681 let resizeObserver = null; 6682 if (elementResize) { 6683 resizeObserver = new ResizeObserver((_ref) => { 6684 let [firstEntry] = _ref; 6685 if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) { 6686 resizeObserver.unobserve(floating); 6687 cancelAnimationFrame(reobserveFrame); 6688 reobserveFrame = requestAnimationFrame(() => { 6689 var _resizeObserver; 6690 (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating); 6691 }); 6692 } 6693 update2(); 6694 }); 6695 if (referenceEl && !animationFrame) { 6696 resizeObserver.observe(referenceEl); 6697 } 6698 if (floating) { 6699 resizeObserver.observe(floating); 6700 } 6701 } 6702 let frameId; 6703 let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null; 6704 if (animationFrame) { 6705 frameLoop(); 6706 } 6707 function frameLoop() { 6708 const nextRefRect = getBoundingClientRect(reference); 6709 if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) { 6710 update2(); 6711 } 6712 prevRefRect = nextRefRect; 6713 frameId = requestAnimationFrame(frameLoop); 6714 } 6715 update2(); 6716 return () => { 6717 var _resizeObserver2; 6718 ancestors.forEach((ancestor) => { 6719 ancestorScroll && ancestor.removeEventListener("scroll", update2); 6720 ancestorResize && ancestor.removeEventListener("resize", update2); 6721 }); 6722 cleanupIo == null || cleanupIo(); 6723 (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect(); 6724 resizeObserver = null; 6725 if (animationFrame) { 6726 cancelAnimationFrame(frameId); 6727 } 6728 }; 6729 } 6730 var offset2 = offset; 6731 var shift2 = shift; 6732 var flip2 = flip; 6733 var size2 = size; 6734 var hide2 = hide; 6735 var limitShift2 = limitShift; 6736 var computePosition2 = (reference, floating, options) => { 6737 const cache = /* @__PURE__ */ new Map(); 6738 const mergedOptions = { 6739 platform: platform2, 6740 ...options 6741 }; 6742 const platformWithCache = { 6743 ...mergedOptions.platform, 6744 _c: cache 6745 }; 6746 return computePosition(reference, floating, { 6747 ...mergedOptions, 6748 platform: platformWithCache 6749 }); 6750 }; 6751 6752 // node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.mjs 6753 var React28 = __toESM(require_react(), 1); 6754 var import_react2 = __toESM(require_react(), 1); 6755 var ReactDOM3 = __toESM(require_react_dom(), 1); 6756 var isClient = typeof document !== "undefined"; 6757 var noop2 = function noop3() { 6758 }; 6759 var index = isClient ? import_react2.useLayoutEffect : noop2; 6760 function deepEqual(a2, b2) { 6761 if (a2 === b2) { 6762 return true; 6763 } 6764 if (typeof a2 !== typeof b2) { 6765 return false; 6766 } 6767 if (typeof a2 === "function" && a2.toString() === b2.toString()) { 6768 return true; 6769 } 6770 let length; 6771 let i2; 6772 let keys; 6773 if (a2 && b2 && typeof a2 === "object") { 6774 if (Array.isArray(a2)) { 6775 length = a2.length; 6776 if (length !== b2.length) return false; 6777 for (i2 = length; i2-- !== 0; ) { 6778 if (!deepEqual(a2[i2], b2[i2])) { 6779 return false; 6780 } 6781 } 6782 return true; 6783 } 6784 keys = Object.keys(a2); 6785 length = keys.length; 6786 if (length !== Object.keys(b2).length) { 6787 return false; 6788 } 6789 for (i2 = length; i2-- !== 0; ) { 6790 if (!{}.hasOwnProperty.call(b2, keys[i2])) { 6791 return false; 6792 } 6793 } 6794 for (i2 = length; i2-- !== 0; ) { 6795 const key = keys[i2]; 6796 if (key === "_owner" && a2.$$typeof) { 6797 continue; 6798 } 6799 if (!deepEqual(a2[key], b2[key])) { 6800 return false; 6801 } 6802 } 6803 return true; 6804 } 6805 return a2 !== a2 && b2 !== b2; 6806 } 6807 function getDPR(element) { 6808 if (typeof window === "undefined") { 6809 return 1; 6810 } 6811 const win = element.ownerDocument.defaultView || window; 6812 return win.devicePixelRatio || 1; 6813 } 6814 function roundByDPR(element, value) { 6815 const dpr = getDPR(element); 6816 return Math.round(value * dpr) / dpr; 6817 } 6818 function useLatestRef(value) { 6819 const ref = React28.useRef(value); 6820 index(() => { 6821 ref.current = value; 6822 }); 6823 return ref; 6824 } 6825 function useFloating(options) { 6826 if (options === void 0) { 6827 options = {}; 6828 } 6829 const { 6830 placement = "bottom", 6831 strategy = "absolute", 6832 middleware = [], 6833 platform: platform3, 6834 elements: { 6835 reference: externalReference, 6836 floating: externalFloating 6837 } = {}, 6838 transform = true, 6839 whileElementsMounted, 6840 open 6841 } = options; 6842 const [data, setData] = React28.useState({ 6843 x: 0, 6844 y: 0, 6845 strategy, 6846 placement, 6847 middlewareData: {}, 6848 isPositioned: false 6849 }); 6850 const [latestMiddleware, setLatestMiddleware] = React28.useState(middleware); 6851 if (!deepEqual(latestMiddleware, middleware)) { 6852 setLatestMiddleware(middleware); 6853 } 6854 const [_reference, _setReference] = React28.useState(null); 6855 const [_floating, _setFloating] = React28.useState(null); 6856 const setReference = React28.useCallback((node) => { 6857 if (node !== referenceRef.current) { 6858 referenceRef.current = node; 6859 _setReference(node); 6860 } 6861 }, []); 6862 const setFloating = React28.useCallback((node) => { 6863 if (node !== floatingRef.current) { 6864 floatingRef.current = node; 6865 _setFloating(node); 6866 } 6867 }, []); 6868 const referenceEl = externalReference || _reference; 6869 const floatingEl = externalFloating || _floating; 6870 const referenceRef = React28.useRef(null); 6871 const floatingRef = React28.useRef(null); 6872 const dataRef = React28.useRef(data); 6873 const hasWhileElementsMounted = whileElementsMounted != null; 6874 const whileElementsMountedRef = useLatestRef(whileElementsMounted); 6875 const platformRef = useLatestRef(platform3); 6876 const openRef = useLatestRef(open); 6877 const update2 = React28.useCallback(() => { 6878 if (!referenceRef.current || !floatingRef.current) { 6879 return; 6880 } 6881 const config = { 6882 placement, 6883 strategy, 6884 middleware: latestMiddleware 6885 }; 6886 if (platformRef.current) { 6887 config.platform = platformRef.current; 6888 } 6889 computePosition2(referenceRef.current, floatingRef.current, config).then((data2) => { 6890 const fullData = { 6891 ...data2, 6892 // The floating element's position may be recomputed while it's closed 6893 // but still mounted (such as when transitioning out). To ensure 6894 // `isPositioned` will be `false` initially on the next open, avoid 6895 // setting it to `true` when `open === false` (must be specified). 6896 isPositioned: openRef.current !== false 6897 }; 6898 if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) { 6899 dataRef.current = fullData; 6900 ReactDOM3.flushSync(() => { 6901 setData(fullData); 6902 }); 6903 } 6904 }); 6905 }, [latestMiddleware, placement, strategy, platformRef, openRef]); 6906 index(() => { 6907 if (open === false && dataRef.current.isPositioned) { 6908 dataRef.current.isPositioned = false; 6909 setData((data2) => ({ 6910 ...data2, 6911 isPositioned: false 6912 })); 6913 } 6914 }, [open]); 6915 const isMountedRef = React28.useRef(false); 6916 index(() => { 6917 isMountedRef.current = true; 6918 return () => { 6919 isMountedRef.current = false; 6920 }; 6921 }, []); 6922 index(() => { 6923 if (referenceEl) referenceRef.current = referenceEl; 6924 if (floatingEl) floatingRef.current = floatingEl; 6925 if (referenceEl && floatingEl) { 6926 if (whileElementsMountedRef.current) { 6927 return whileElementsMountedRef.current(referenceEl, floatingEl, update2); 6928 } 6929 update2(); 6930 } 6931 }, [referenceEl, floatingEl, update2, whileElementsMountedRef, hasWhileElementsMounted]); 6932 const refs = React28.useMemo(() => ({ 6933 reference: referenceRef, 6934 floating: floatingRef, 6935 setReference, 6936 setFloating 6937 }), [setReference, setFloating]); 6938 const elements = React28.useMemo(() => ({ 6939 reference: referenceEl, 6940 floating: floatingEl 6941 }), [referenceEl, floatingEl]); 6942 const floatingStyles = React28.useMemo(() => { 6943 const initialStyles = { 6944 position: strategy, 6945 left: 0, 6946 top: 0 6947 }; 6948 if (!elements.floating) { 6949 return initialStyles; 6950 } 6951 const x2 = roundByDPR(elements.floating, data.x); 6952 const y2 = roundByDPR(elements.floating, data.y); 6953 if (transform) { 6954 return { 6955 ...initialStyles, 6956 transform: "translate(" + x2 + "px, " + y2 + "px)", 6957 ...getDPR(elements.floating) >= 1.5 && { 6958 willChange: "transform" 6959 } 6960 }; 6961 } 6962 return { 6963 position: strategy, 6964 left: x2, 6965 top: y2 6966 }; 6967 }, [strategy, transform, elements.floating, data.x, data.y]); 6968 return React28.useMemo(() => ({ 6969 ...data, 6970 update: update2, 6971 refs, 6972 elements, 6973 floatingStyles 6974 }), [data, update2, refs, elements, floatingStyles]); 6975 } 6976 var offset3 = (options, deps) => { 6977 const result = offset2(options); 6978 return { 6979 name: result.name, 6980 fn: result.fn, 6981 options: [options, deps] 6982 }; 6983 }; 6984 var shift3 = (options, deps) => { 6985 const result = shift2(options); 6986 return { 6987 name: result.name, 6988 fn: result.fn, 6989 options: [options, deps] 6990 }; 6991 }; 6992 var limitShift3 = (options, deps) => { 6993 const result = limitShift2(options); 6994 return { 6995 fn: result.fn, 6996 options: [options, deps] 6997 }; 6998 }; 6999 var flip3 = (options, deps) => { 7000 const result = flip2(options); 7001 return { 7002 name: result.name, 7003 fn: result.fn, 7004 options: [options, deps] 7005 }; 7006 }; 7007 var size3 = (options, deps) => { 7008 const result = size2(options); 7009 return { 7010 name: result.name, 7011 fn: result.fn, 7012 options: [options, deps] 7013 }; 7014 }; 7015 var hide3 = (options, deps) => { 7016 const result = hide2(options); 7017 return { 7018 name: result.name, 7019 fn: result.fn, 7020 options: [options, deps] 7021 }; 7022 }; 7023 7024 // node_modules/@base-ui/react/utils/popups/popupStoreUtils.mjs 7025 var React33 = __toESM(require_react(), 1); 7026 var ReactDOM4 = __toESM(require_react_dom(), 1); 7027 7028 // node_modules/@base-ui/react/floating-ui-react/hooks/useSyncedFloatingRootContext.mjs 7029 var React32 = __toESM(require_react(), 1); 7030 7031 // node_modules/@base-ui/utils/store/createSelector.mjs 7032 var createSelector = (a2, b2, c2, d2, e2, f2, ...other) => { 7033 if (other.length > 0) { 7034 throw new Error(true ? "Unsupported number of selectors" : formatErrorMessage_default(1)); 7035 } 7036 let selector2; 7037 if (a2 && b2 && c2 && d2 && e2 && f2) { 7038 selector2 = (state, a1, a22, a3) => { 7039 const va = a2(state, a1, a22, a3); 7040 const vb = b2(state, a1, a22, a3); 7041 const vc = c2(state, a1, a22, a3); 7042 const vd = d2(state, a1, a22, a3); 7043 const ve = e2(state, a1, a22, a3); 7044 return f2(va, vb, vc, vd, ve, a1, a22, a3); 7045 }; 7046 } else if (a2 && b2 && c2 && d2 && e2) { 7047 selector2 = (state, a1, a22, a3) => { 7048 const va = a2(state, a1, a22, a3); 7049 const vb = b2(state, a1, a22, a3); 7050 const vc = c2(state, a1, a22, a3); 7051 const vd = d2(state, a1, a22, a3); 7052 return e2(va, vb, vc, vd, a1, a22, a3); 7053 }; 7054 } else if (a2 && b2 && c2 && d2) { 7055 selector2 = (state, a1, a22, a3) => { 7056 const va = a2(state, a1, a22, a3); 7057 const vb = b2(state, a1, a22, a3); 7058 const vc = c2(state, a1, a22, a3); 7059 return d2(va, vb, vc, a1, a22, a3); 7060 }; 7061 } else if (a2 && b2 && c2) { 7062 selector2 = (state, a1, a22, a3) => { 7063 const va = a2(state, a1, a22, a3); 7064 const vb = b2(state, a1, a22, a3); 7065 return c2(va, vb, a1, a22, a3); 7066 }; 7067 } else if (a2 && b2) { 7068 selector2 = (state, a1, a22, a3) => { 7069 const va = a2(state, a1, a22, a3); 7070 return b2(va, a1, a22, a3); 7071 }; 7072 } else if (a2) { 7073 selector2 = a2; 7074 } else { 7075 throw ( 7076 /* minify-error-disabled */ 7077 new Error("Missing arguments") 7078 ); 7079 } 7080 return selector2; 7081 }; 7082 7083 // node_modules/@base-ui/utils/store/useStore.mjs 7084 var React30 = __toESM(require_react(), 1); 7085 var import_shim = __toESM(require_shim(), 1); 7086 var import_with_selector = __toESM(require_with_selector(), 1); 7087 7088 // node_modules/@base-ui/utils/fastHooks.mjs 7089 var React29 = __toESM(require_react(), 1); 7090 var hooks = []; 7091 var currentInstance = void 0; 7092 function getInstance() { 7093 return currentInstance; 7094 } 7095 function register(hook) { 7096 hooks.push(hook); 7097 } 7098 function fastComponent(fn) { 7099 const FastComponent = (props, forwardedRef) => { 7100 const instance = useRefWithInit(createInstance).current; 7101 let result; 7102 try { 7103 currentInstance = instance; 7104 for (const hook of hooks) { 7105 hook.before(instance); 7106 } 7107 result = fn(props, forwardedRef); 7108 for (const hook of hooks) { 7109 hook.after(instance); 7110 } 7111 instance.didInitialize = true; 7112 } finally { 7113 currentInstance = void 0; 7114 } 7115 return result; 7116 }; 7117 FastComponent.displayName = fn.displayName || fn.name; 7118 return FastComponent; 7119 } 7120 function fastComponentRef(fn) { 7121 return /* @__PURE__ */ React29.forwardRef(fastComponent(fn)); 7122 } 7123 function createInstance() { 7124 return { 7125 didInitialize: false 7126 }; 7127 } 7128 7129 // node_modules/@base-ui/utils/store/useStore.mjs 7130 var canUseRawUseSyncExternalStore = isReactVersionAtLeast(19); 7131 var useStoreImplementation = canUseRawUseSyncExternalStore ? useStoreFast : useStoreLegacy; 7132 function useStore(store, selector2, a1, a2, a3) { 7133 return useStoreImplementation(store, selector2, a1, a2, a3); 7134 } 7135 function useStoreR19(store, selector2, a1, a2, a3) { 7136 const getSelection = React30.useCallback(() => selector2(store.getSnapshot(), a1, a2, a3), [store, selector2, a1, a2, a3]); 7137 return (0, import_shim.useSyncExternalStore)(store.subscribe, getSelection, getSelection); 7138 } 7139 register({ 7140 before(instance) { 7141 instance.syncIndex = 0; 7142 if (!instance.didInitialize) { 7143 instance.syncTick = 1; 7144 instance.syncHooks = []; 7145 instance.didChangeStore = true; 7146 instance.getSnapshot = () => { 7147 let didChange2 = false; 7148 for (let i2 = 0; i2 < instance.syncHooks.length; i2 += 1) { 7149 const hook = instance.syncHooks[i2]; 7150 const value = hook.selector(hook.store.state, hook.a1, hook.a2, hook.a3); 7151 if (!Object.is(hook.value, value)) { 7152 didChange2 = true; 7153 hook.value = value; 7154 } 7155 } 7156 if (didChange2) { 7157 instance.syncTick += 1; 7158 } 7159 return instance.syncTick; 7160 }; 7161 } 7162 }, 7163 after(instance) { 7164 if (instance.syncHooks.length > 0) { 7165 if (instance.didChangeStore) { 7166 instance.didChangeStore = false; 7167 instance.subscribe = (onStoreChange) => { 7168 const stores = /* @__PURE__ */ new Set(); 7169 for (const hook of instance.syncHooks) { 7170 stores.add(hook.store); 7171 } 7172 const unsubscribes = []; 7173 for (const store of stores) { 7174 unsubscribes.push(store.subscribe(onStoreChange)); 7175 } 7176 return () => { 7177 for (const unsubscribe of unsubscribes) { 7178 unsubscribe(); 7179 } 7180 }; 7181 }; 7182 } 7183 (0, import_shim.useSyncExternalStore)(instance.subscribe, instance.getSnapshot, instance.getSnapshot); 7184 } 7185 } 7186 }); 7187 function useStoreFast(store, selector2, a1, a2, a3) { 7188 const instance = getInstance(); 7189 if (!instance) { 7190 return useStoreR19(store, selector2, a1, a2, a3); 7191 } 7192 const index2 = instance.syncIndex; 7193 instance.syncIndex += 1; 7194 let hook; 7195 if (!instance.didInitialize) { 7196 hook = { 7197 store, 7198 selector: selector2, 7199 a1, 7200 a2, 7201 a3, 7202 value: selector2(store.getSnapshot(), a1, a2, a3) 7203 }; 7204 instance.syncHooks.push(hook); 7205 } else { 7206 hook = instance.syncHooks[index2]; 7207 if (hook.store !== store || hook.selector !== selector2 || !Object.is(hook.a1, a1) || !Object.is(hook.a2, a2) || !Object.is(hook.a3, a3)) { 7208 if (hook.store !== store) { 7209 instance.didChangeStore = true; 7210 } 7211 hook.store = store; 7212 hook.selector = selector2; 7213 hook.a1 = a1; 7214 hook.a2 = a2; 7215 hook.a3 = a3; 7216 hook.value = selector2(store.getSnapshot(), a1, a2, a3); 7217 } 7218 } 7219 return hook.value; 7220 } 7221 function useStoreLegacy(store, selector2, a1, a2, a3) { 7222 return (0, import_with_selector.useSyncExternalStoreWithSelector)(store.subscribe, store.getSnapshot, store.getSnapshot, (state) => selector2(state, a1, a2, a3)); 7223 } 7224 7225 // node_modules/@base-ui/utils/store/Store.mjs 7226 var Store = class { 7227 /** 7228 * The current state of the store. 7229 * This property is updated immediately when the state changes as a result of calling {@link setState}, {@link update}, or {@link set}. 7230 * To subscribe to state changes, use the {@link useState} method. The value returned by {@link useState} is updated after the component renders (similarly to React's useState). 7231 * The values can be used directly (to avoid subscribing to the store) in effects or event handlers. 7232 * 7233 * Do not modify properties in state directly. Instead, use the provided methods to ensure proper state management and listener notification. 7234 */ 7235 // Internal state to handle recursive `setState()` calls 7236 constructor(state) { 7237 this.state = state; 7238 this.listeners = /* @__PURE__ */ new Set(); 7239 this.updateTick = 0; 7240 } 7241 /** 7242 * Registers a listener that will be called whenever the store's state changes. 7243 * 7244 * @param fn The listener function to be called on state changes. 7245 * @returns A function to unsubscribe the listener. 7246 */ 7247 subscribe = (fn) => { 7248 this.listeners.add(fn); 7249 return () => { 7250 this.listeners.delete(fn); 7251 }; 7252 }; 7253 /** 7254 * Returns the current state of the store. 7255 */ 7256 getSnapshot = () => { 7257 return this.state; 7258 }; 7259 /** 7260 * Updates the entire store's state and notifies all registered listeners. 7261 * 7262 * @param newState The new state to set for the store. 7263 */ 7264 setState(newState) { 7265 if (this.state === newState) { 7266 return; 7267 } 7268 this.state = newState; 7269 this.updateTick += 1; 7270 const currentTick = this.updateTick; 7271 for (const listener of this.listeners) { 7272 if (currentTick !== this.updateTick) { 7273 return; 7274 } 7275 listener(newState); 7276 } 7277 } 7278 /** 7279 * Merges the provided changes into the current state and notifies listeners if there are changes. 7280 * 7281 * @param changes An object containing the changes to apply to the current state. 7282 */ 7283 update(changes) { 7284 for (const key in changes) { 7285 if (!Object.is(this.state[key], changes[key])) { 7286 this.setState({ 7287 ...this.state, 7288 ...changes 7289 }); 7290 return; 7291 } 7292 } 7293 } 7294 /** 7295 * Sets a specific key in the store's state to a new value and notifies listeners if the value has changed. 7296 * 7297 * @param key The key in the store's state to update. 7298 * @param value The new value to set for the specified key. 7299 */ 7300 set(key, value) { 7301 if (!Object.is(this.state[key], value)) { 7302 this.setState({ 7303 ...this.state, 7304 [key]: value 7305 }); 7306 } 7307 } 7308 /** 7309 * Gives the state a new reference and updates all registered listeners. 7310 */ 7311 notifyAll() { 7312 const newState = { 7313 ...this.state 7314 }; 7315 this.setState(newState); 7316 } 7317 use(selector2, a1, a2, a3) { 7318 return useStore(this, selector2, a1, a2, a3); 7319 } 7320 }; 7321 7322 // node_modules/@base-ui/utils/store/ReactStore.mjs 7323 var React31 = __toESM(require_react(), 1); 7324 var ReactStore = class extends Store { 7325 /** 7326 * Creates a new ReactStore instance. 7327 * 7328 * @param state Initial state of the store. 7329 * @param context Non-reactive context values. 7330 * @param selectors Optional selectors for use with `useState`. 7331 */ 7332 constructor(state, context = {}, selectors4) { 7333 super(state); 7334 this.context = context; 7335 this.selectors = selectors4; 7336 } 7337 /** 7338 * Non-reactive values such as refs, callbacks, etc. 7339 */ 7340 /** 7341 * Synchronizes a single external value into the store. 7342 * 7343 * Note that the while the value in `state` is updated immediately, the value returned 7344 * by `useState` is updated before the next render (similarly to React's `useState`). 7345 */ 7346 useSyncedValue(key, value) { 7347 React31.useDebugValue(key); 7348 const store = this; 7349 useIsoLayoutEffect(() => { 7350 if (store.state[key] !== value) { 7351 store.set(key, value); 7352 } 7353 }, [store, key, value]); 7354 } 7355 /** 7356 * Synchronizes a single external value into the store and 7357 * cleans it up (sets to `undefined`) on unmount. 7358 * 7359 * Note that the while the value in `state` is updated immediately, the value returned 7360 * by `useState` is updated before the next render (similarly to React's `useState`). 7361 */ 7362 useSyncedValueWithCleanup(key, value) { 7363 const store = this; 7364 useIsoLayoutEffect(() => { 7365 if (store.state[key] !== value) { 7366 store.set(key, value); 7367 } 7368 return () => { 7369 store.set(key, void 0); 7370 }; 7371 }, [store, key, value]); 7372 } 7373 /** 7374 * Synchronizes multiple external values into the store. 7375 * 7376 * Note that the while the values in `state` are updated immediately, the values returned 7377 * by `useState` are updated before the next render (similarly to React's `useState`). 7378 */ 7379 useSyncedValues(statePart) { 7380 const store = this; 7381 if (true) { 7382 React31.useDebugValue(statePart, (p2) => Object.keys(p2)); 7383 const keys = React31.useRef(Object.keys(statePart)).current; 7384 const nextKeys = Object.keys(statePart); 7385 if (keys.length !== nextKeys.length || keys.some((key, index2) => key !== nextKeys[index2])) { 7386 console.error("ReactStore.useSyncedValues expects the same prop keys on every render. Keys should be stable."); 7387 } 7388 } 7389 const dependencies = Object.values(statePart); 7390 useIsoLayoutEffect(() => { 7391 store.update(statePart); 7392 }, [store, ...dependencies]); 7393 } 7394 /** 7395 * Registers a controllable prop pair (`controlled`, `defaultValue`) for a specific key. If `controlled` 7396 * is non-undefined, the store's state at `key` is updated to match `controlled`. 7397 */ 7398 useControlledProp(key, controlled) { 7399 React31.useDebugValue(key); 7400 const store = this; 7401 const isControlled = controlled !== void 0; 7402 useIsoLayoutEffect(() => { 7403 if (isControlled && !Object.is(store.state[key], controlled)) { 7404 store.setState({ 7405 ...store.state, 7406 [key]: controlled 7407 }); 7408 } 7409 }, [store, key, controlled, isControlled]); 7410 if (true) { 7411 const cache = this.controlledValues ??= /* @__PURE__ */ new Map(); 7412 if (!cache.has(key)) { 7413 cache.set(key, isControlled); 7414 } 7415 const previouslyControlled = cache.get(key); 7416 if (previouslyControlled !== void 0 && previouslyControlled !== isControlled) { 7417 console.error(`A component is changing the $isControlled ? "" : "un"}controlled state of $key.toString()} to be $isControlled ? "un" : ""}controlled. Elements should not switch from uncontrolled to controlled (or vice versa).`); 7418 } 7419 } 7420 } 7421 /** Gets the current value from the store using a selector with the provided key. 7422 * 7423 * @param key Key of the selector to use. 7424 */ 7425 select(key, a1, a2, a3) { 7426 const selector2 = this.selectors[key]; 7427 return selector2(this.state, a1, a2, a3); 7428 } 7429 /** 7430 * Returns a value from the store's state using a selector function. 7431 * Used to subscribe to specific parts of the state. 7432 * This methods causes a rerender whenever the selected state changes. 7433 * 7434 * @param key Key of the selector to use. 7435 */ 7436 useState(key, a1, a2, a3) { 7437 React31.useDebugValue(key); 7438 return useStore(this, this.selectors[key], a1, a2, a3); 7439 } 7440 /** 7441 * Wraps a function with `useStableCallback` to ensure it has a stable reference 7442 * and assigns it to the context. 7443 * 7444 * @param key Key of the event callback. Must be a function in the context. 7445 * @param fn Function to assign. 7446 */ 7447 useContextCallback(key, fn) { 7448 React31.useDebugValue(key); 7449 const stableFunction = useStableCallback(fn ?? NOOP); 7450 this.context[key] = stableFunction; 7451 } 7452 /** 7453 * Returns a stable setter function for a specific key in the store's state. 7454 * It's commonly used to pass as a ref callback to React elements. 7455 * 7456 * @param key Key of the state to set. 7457 */ 7458 useStateSetter(key) { 7459 const ref = React31.useRef(void 0); 7460 if (ref.current === void 0) { 7461 ref.current = (value) => { 7462 this.set(key, value); 7463 }; 7464 } 7465 return ref.current; 7466 } 7467 /** 7468 * Observes changes derived from the store's selectors and calls the listener when the selected value changes. 7469 * 7470 * @param key Key of the selector to observe. 7471 * @param listener Listener function called when the selector result changes. 7472 */ 7473 observe(selector2, listener) { 7474 let selectFn; 7475 if (typeof selector2 === "function") { 7476 selectFn = selector2; 7477 } else { 7478 selectFn = this.selectors[selector2]; 7479 } 7480 let prevValue = selectFn(this.state); 7481 listener(prevValue, prevValue, this); 7482 return this.subscribe((nextState) => { 7483 const nextValue = selectFn(nextState); 7484 if (!Object.is(prevValue, nextValue)) { 7485 const oldValue = prevValue; 7486 prevValue = nextValue; 7487 listener(nextValue, oldValue, this); 7488 } 7489 }); 7490 } 7491 }; 7492 7493 // node_modules/@base-ui/react/floating-ui-react/components/FloatingRootStore.mjs 7494 var selectors = { 7495 open: createSelector((state) => state.open), 7496 transitionStatus: createSelector((state) => state.transitionStatus), 7497 domReferenceElement: createSelector((state) => state.domReferenceElement), 7498 referenceElement: createSelector((state) => state.positionReference ?? state.referenceElement), 7499 floatingElement: createSelector((state) => state.floatingElement), 7500 floatingId: createSelector((state) => state.floatingId) 7501 }; 7502 var FloatingRootStore = class extends ReactStore { 7503 constructor(options) { 7504 const { 7505 syncOnly, 7506 nested, 7507 onOpenChange, 7508 triggerElements, 7509 ...initialState 7510 } = options; 7511 super({ 7512 ...initialState, 7513 positionReference: initialState.referenceElement, 7514 domReferenceElement: initialState.referenceElement 7515 }, { 7516 onOpenChange, 7517 dataRef: { 7518 current: {} 7519 }, 7520 events: createEventEmitter(), 7521 nested, 7522 triggerElements 7523 }, selectors); 7524 this.syncOnly = syncOnly; 7525 } 7526 /** 7527 * Syncs the event used by hover logic to distinguish hover-open from click-like interaction. 7528 */ 7529 syncOpenEvent = (newOpen, event) => { 7530 if (!newOpen || !this.state.open || // Prevent a pending hover-open from overwriting a click-open event, while allowing 7531 // click events to upgrade a hover-open. 7532 event != null && isClickLikeEvent(event)) { 7533 this.context.dataRef.current.openEvent = newOpen ? event : void 0; 7534 } 7535 }; 7536 /** 7537 * Runs the root-owned side effects for an open state change. 7538 */ 7539 dispatchOpenChange = (newOpen, eventDetails) => { 7540 this.syncOpenEvent(newOpen, eventDetails.event); 7541 const details = { 7542 open: newOpen, 7543 reason: eventDetails.reason, 7544 nativeEvent: eventDetails.event, 7545 nested: this.context.nested, 7546 triggerElement: eventDetails.trigger 7547 }; 7548 this.context.events.emit("openchange", details); 7549 }; 7550 /** 7551 * Emits the `openchange` event through the internal event emitter and calls the `onOpenChange` handler with the provided arguments. 7552 * 7553 * @param newOpen The new open state. 7554 * @param eventDetails Details about the event that triggered the open state change. 7555 */ 7556 setOpen = (newOpen, eventDetails) => { 7557 if (this.syncOnly) { 7558 this.context.onOpenChange?.(newOpen, eventDetails); 7559 return; 7560 } 7561 this.dispatchOpenChange(newOpen, eventDetails); 7562 this.context.onOpenChange?.(newOpen, eventDetails); 7563 }; 7564 }; 7565 7566 // node_modules/@base-ui/react/floating-ui-react/hooks/useSyncedFloatingRootContext.mjs 7567 function useSyncedFloatingRootContext(options) { 7568 const { 7569 popupStore, 7570 treatPopupAsFloatingElement = false, 7571 floatingRootContext: floatingRootContextProp, 7572 floatingId, 7573 nested, 7574 onOpenChange 7575 } = options; 7576 const open = popupStore.useState("open"); 7577 const referenceElement = popupStore.useState("activeTriggerElement"); 7578 const floatingElement = popupStore.useState(treatPopupAsFloatingElement ? "popupElement" : "positionerElement"); 7579 const triggerElements = popupStore.context.triggerElements; 7580 const handleOpenChange = onOpenChange; 7581 const internalStoreRef = React32.useRef(null); 7582 if (floatingRootContextProp === void 0 && internalStoreRef.current === null) { 7583 internalStoreRef.current = new FloatingRootStore({ 7584 open, 7585 transitionStatus: void 0, 7586 referenceElement, 7587 floatingElement, 7588 triggerElements, 7589 onOpenChange: handleOpenChange, 7590 floatingId, 7591 syncOnly: true, 7592 nested 7593 }); 7594 } 7595 const store = floatingRootContextProp ?? internalStoreRef.current; 7596 popupStore.useSyncedValue("floatingId", floatingId); 7597 useIsoLayoutEffect(() => { 7598 const valuesToSync = { 7599 open, 7600 floatingId, 7601 referenceElement, 7602 floatingElement 7603 }; 7604 if (isElement(referenceElement)) { 7605 valuesToSync.domReferenceElement = referenceElement; 7606 } 7607 if (store.state.positionReference === store.state.referenceElement) { 7608 valuesToSync.positionReference = referenceElement; 7609 } 7610 store.update(valuesToSync); 7611 }, [open, floatingId, referenceElement, floatingElement, store]); 7612 store.context.onOpenChange = handleOpenChange; 7613 store.context.nested = nested; 7614 return store; 7615 } 7616 7617 // node_modules/@base-ui/react/utils/popups/popupStoreUtils.mjs 7618 var FOCUSABLE_POPUP_PROPS = { 7619 tabIndex: -1, 7620 [FOCUSABLE_ATTRIBUTE]: "" 7621 }; 7622 function createDefaultInitialFocus(popupRef) { 7623 return (interactionType) => interactionType === "touch" ? popupRef.current : true; 7624 } 7625 function usePopupStore(externalStore, createStore2, treatPopupAsFloatingElement = false) { 7626 const floatingId = useId(); 7627 const nested = useFloatingParentNodeId() != null; 7628 const internalStoreRef = React33.useRef(null); 7629 if (externalStore === void 0 && internalStoreRef.current === null) { 7630 internalStoreRef.current = createStore2(floatingId, nested); 7631 } 7632 const store = externalStore ?? internalStoreRef.current; 7633 useSyncedFloatingRootContext({ 7634 popupStore: store, 7635 treatPopupAsFloatingElement, 7636 floatingRootContext: store.state.floatingRootContext, 7637 floatingId, 7638 nested, 7639 onOpenChange: store.setOpen 7640 }); 7641 return { 7642 store, 7643 internalStore: internalStoreRef.current 7644 }; 7645 } 7646 function useTriggerRegistration(id, store) { 7647 const registeredElementIdRef = React33.useRef(null); 7648 const registeredElementRef = React33.useRef(null); 7649 return React33.useCallback((element) => { 7650 if (id === void 0) { 7651 return; 7652 } 7653 let shouldSyncTriggerCount = false; 7654 if (registeredElementIdRef.current !== null) { 7655 const registeredId = registeredElementIdRef.current; 7656 const registeredElement = registeredElementRef.current; 7657 const currentElement = store.context.triggerElements.getById(registeredId); 7658 if (registeredElement && currentElement === registeredElement) { 7659 store.context.triggerElements.delete(registeredId); 7660 shouldSyncTriggerCount = true; 7661 } 7662 registeredElementIdRef.current = null; 7663 registeredElementRef.current = null; 7664 } 7665 if (element !== null) { 7666 registeredElementIdRef.current = id; 7667 registeredElementRef.current = element; 7668 store.context.triggerElements.add(id, element); 7669 shouldSyncTriggerCount = true; 7670 } 7671 if (shouldSyncTriggerCount) { 7672 const triggerCount = store.context.triggerElements.size; 7673 if (store.select("open") && store.state.triggerCount !== triggerCount) { 7674 store.set("triggerCount", triggerCount); 7675 } 7676 } 7677 }, [store, id]); 7678 } 7679 function setPopupOpenState(state, open, trigger, preventUnmountOnClose = false) { 7680 if (open) { 7681 state.preventUnmountingOnClose = false; 7682 } else if (preventUnmountOnClose) { 7683 state.preventUnmountingOnClose = true; 7684 } 7685 const triggerId = trigger?.id ?? null; 7686 if (triggerId || open) { 7687 state.activeTriggerId = triggerId; 7688 state.activeTriggerElement = trigger ?? null; 7689 } 7690 } 7691 function attachPreventUnmountOnClose(eventDetails) { 7692 let preventUnmountOnClose = false; 7693 eventDetails.preventUnmountOnClose = () => { 7694 preventUnmountOnClose = true; 7695 }; 7696 return () => preventUnmountOnClose; 7697 } 7698 function applyPopupOpenChange(store, nextOpen, eventDetails, options = {}) { 7699 const reason = eventDetails.reason; 7700 const isHover = reason === reason_parts_exports.triggerHover; 7701 const isFocusOpen = nextOpen && reason === reason_parts_exports.triggerFocus; 7702 const isDismissClose = !nextOpen && (reason === reason_parts_exports.triggerPress || reason === reason_parts_exports.escapeKey); 7703 const shouldPreventUnmountOnClose = attachPreventUnmountOnClose(eventDetails); 7704 store.context.onOpenChange?.(nextOpen, eventDetails); 7705 if (eventDetails.isCanceled) { 7706 return; 7707 } 7708 options.onBeforeDispatch?.(); 7709 store.state.floatingRootContext.dispatchOpenChange(nextOpen, eventDetails); 7710 const changeState = () => { 7711 const updatedState = { 7712 ...options.extraState, 7713 open: nextOpen 7714 }; 7715 if (isFocusOpen) { 7716 updatedState.instantType = "focus"; 7717 } else if (isDismissClose) { 7718 updatedState.instantType = "dismiss"; 7719 } else if (isHover) { 7720 updatedState.instantType = void 0; 7721 } 7722 setPopupOpenState(updatedState, nextOpen, eventDetails.trigger, shouldPreventUnmountOnClose()); 7723 store.update(updatedState); 7724 }; 7725 if (isHover) { 7726 ReactDOM4.flushSync(changeState); 7727 } else { 7728 changeState(); 7729 } 7730 } 7731 function useInitialOpenSync(store, openProp, defaultOpen, defaultTriggerId) { 7732 useOnFirstRender(() => { 7733 if (openProp === void 0 && store.state.open === false && defaultOpen) { 7734 store.state = { 7735 ...store.state, 7736 open: true, 7737 activeTriggerId: defaultTriggerId, 7738 preventUnmountingOnClose: false 7739 }; 7740 } 7741 }); 7742 } 7743 function useTriggerDataForwarding(triggerId, triggerElementRef, store, stateUpdates) { 7744 const isMountedByThisTrigger = store.useState("isMountedByTrigger", triggerId); 7745 const baseRegisterTrigger = useTriggerRegistration(triggerId, store); 7746 const registerTrigger = useStableCallback((element) => { 7747 baseRegisterTrigger(element); 7748 if (!element) { 7749 return; 7750 } 7751 const open = store.select("open"); 7752 const activeTriggerId = store.select("activeTriggerId"); 7753 if (activeTriggerId === triggerId) { 7754 store.update({ 7755 activeTriggerElement: element, 7756 ...open ? stateUpdates : null 7757 }); 7758 return; 7759 } 7760 if (activeTriggerId == null && open) { 7761 store.update({ 7762 activeTriggerId: triggerId, 7763 activeTriggerElement: element, 7764 ...stateUpdates 7765 }); 7766 } 7767 }); 7768 useIsoLayoutEffect(() => { 7769 if (isMountedByThisTrigger) { 7770 store.update({ 7771 activeTriggerElement: triggerElementRef.current, 7772 ...stateUpdates 7773 }); 7774 } 7775 }, [isMountedByThisTrigger, store, triggerElementRef, ...Object.values(stateUpdates)]); 7776 return { 7777 registerTrigger, 7778 isMountedByThisTrigger 7779 }; 7780 } 7781 function useImplicitActiveTrigger(store, options = {}) { 7782 const { 7783 closeOnActiveTriggerUnmount = false 7784 } = options; 7785 const open = store.useState("open"); 7786 const reactiveTriggerCount = store.useState("triggerCount"); 7787 useIsoLayoutEffect(() => { 7788 if (!open) { 7789 if (store.state.triggerCount !== 0) { 7790 store.set("triggerCount", 0); 7791 } 7792 return; 7793 } 7794 const triggerCount = store.context.triggerElements.size; 7795 const stateUpdates = {}; 7796 if (store.state.triggerCount !== triggerCount) { 7797 stateUpdates.triggerCount = triggerCount; 7798 } 7799 const activeTriggerId = store.select("activeTriggerId"); 7800 let lostActiveTriggerId = null; 7801 if (activeTriggerId) { 7802 const activeTriggerElement = store.context.triggerElements.getById(activeTriggerId); 7803 if (!activeTriggerElement) { 7804 lostActiveTriggerId = activeTriggerId; 7805 } else if (activeTriggerElement !== store.state.activeTriggerElement) { 7806 stateUpdates.activeTriggerElement = activeTriggerElement; 7807 } 7808 } 7809 if (!lostActiveTriggerId && !activeTriggerId && triggerCount === 1) { 7810 const iteratorResult = store.context.triggerElements.entries().next(); 7811 if (!iteratorResult.done) { 7812 const [implicitTriggerId, implicitTriggerElement] = iteratorResult.value; 7813 stateUpdates.activeTriggerId = implicitTriggerId; 7814 stateUpdates.activeTriggerElement = implicitTriggerElement; 7815 } 7816 } 7817 if (stateUpdates.triggerCount !== void 0 || stateUpdates.activeTriggerId !== void 0 || stateUpdates.activeTriggerElement !== void 0) { 7818 store.update(stateUpdates); 7819 } 7820 if (lostActiveTriggerId) { 7821 if (closeOnActiveTriggerUnmount) { 7822 queueMicrotask(() => { 7823 if (store.select("open") && store.select("activeTriggerId") === lostActiveTriggerId && !store.context.triggerElements.getById(lostActiveTriggerId)) { 7824 const eventDetails = createChangeEventDetails(reason_parts_exports.none); 7825 store.setOpen(false, eventDetails); 7826 if (!eventDetails.isCanceled) { 7827 store.update({ 7828 activeTriggerId: null, 7829 activeTriggerElement: null 7830 }); 7831 } 7832 } 7833 }); 7834 } 7835 } 7836 }, [open, store, reactiveTriggerCount, closeOnActiveTriggerUnmount]); 7837 } 7838 function useOpenStateTransitions(open, store, onUnmount) { 7839 const { 7840 mounted, 7841 setMounted, 7842 transitionStatus 7843 } = useTransitionStatus(open); 7844 const preventUnmountingOnClose = store.useState("preventUnmountingOnClose"); 7845 const syncedPreventUnmountingOnClose = open ? false : preventUnmountingOnClose; 7846 store.useSyncedValues({ 7847 mounted, 7848 transitionStatus, 7849 preventUnmountingOnClose: syncedPreventUnmountingOnClose 7850 }); 7851 const forceUnmount = useStableCallback(() => { 7852 setMounted(false); 7853 store.update({ 7854 activeTriggerId: null, 7855 activeTriggerElement: null, 7856 mounted: false, 7857 preventUnmountingOnClose: false 7858 }); 7859 onUnmount?.(); 7860 store.context.onOpenChangeComplete?.(false); 7861 }); 7862 useOpenChangeComplete({ 7863 enabled: mounted && !open && !syncedPreventUnmountingOnClose, 7864 open, 7865 ref: store.context.popupRef, 7866 onComplete() { 7867 if (!open) { 7868 forceUnmount(); 7869 } 7870 } 7871 }); 7872 return { 7873 forceUnmount, 7874 transitionStatus 7875 }; 7876 } 7877 function usePopupInteractionProps(store, statePart) { 7878 store.useSyncedValues(statePart); 7879 useIsoLayoutEffect(() => () => { 7880 store.update({ 7881 activeTriggerProps: EMPTY_OBJECT, 7882 inactiveTriggerProps: EMPTY_OBJECT, 7883 popupProps: EMPTY_OBJECT 7884 }); 7885 }, [store]); 7886 } 7887 function usePopupRootSync(store, open) { 7888 useIsoLayoutEffect(() => { 7889 if (!open && store.state.openMethod !== null) { 7890 store.set("openMethod", null); 7891 } 7892 }, [open, store]); 7893 useIsoLayoutEffect(() => () => { 7894 if (store.state.openMethod !== null) { 7895 store.set("openMethod", null); 7896 } 7897 }, [store]); 7898 } 7899 7900 // node_modules/@base-ui/react/utils/popups/popupTriggerMap.mjs 7901 var PopupTriggerMap = class { 7902 constructor() { 7903 this.elementsSet = /* @__PURE__ */ new Set(); 7904 this.idMap = /* @__PURE__ */ new Map(); 7905 } 7906 /** 7907 * Adds a trigger element with the given ID. 7908 * 7909 * Note: The provided element is assumed to not be registered under multiple IDs. 7910 */ 7911 add(id, element) { 7912 const existingElement = this.idMap.get(id); 7913 if (existingElement === element) { 7914 return; 7915 } 7916 if (existingElement !== void 0) { 7917 this.elementsSet.delete(existingElement); 7918 } 7919 this.elementsSet.add(element); 7920 this.idMap.set(id, element); 7921 if (true) { 7922 if (this.elementsSet.size !== this.idMap.size) { 7923 throw new Error("Base UI: A trigger element cannot be registered under multiple IDs in PopupTriggerMap."); 7924 } 7925 } 7926 } 7927 /** 7928 * Removes the trigger element with the given ID. 7929 */ 7930 delete(id) { 7931 const element = this.idMap.get(id); 7932 if (element) { 7933 this.elementsSet.delete(element); 7934 this.idMap.delete(id); 7935 } 7936 } 7937 /** 7938 * Whether the given element is registered as a trigger. 7939 */ 7940 hasElement(element) { 7941 return this.elementsSet.has(element); 7942 } 7943 /** 7944 * Whether there is a registered trigger element matching the given predicate. 7945 */ 7946 hasMatchingElement(predicate) { 7947 for (const element of this.elementsSet) { 7948 if (predicate(element)) { 7949 return true; 7950 } 7951 } 7952 return false; 7953 } 7954 /** 7955 * Returns the trigger element associated with the given ID, or undefined if no such element exists. 7956 */ 7957 getById(id) { 7958 return this.idMap.get(id); 7959 } 7960 /** 7961 * Returns an iterable of all registered trigger entries, where each entry is a tuple of [id, element]. 7962 */ 7963 entries() { 7964 return this.idMap.entries(); 7965 } 7966 /** 7967 * Returns an iterable of all registered trigger elements. 7968 */ 7969 elements() { 7970 return this.elementsSet.values(); 7971 } 7972 /** 7973 * Returns the number of registered trigger elements. 7974 */ 7975 get size() { 7976 return this.idMap.size; 7977 } 7978 }; 7979 7980 // node_modules/@base-ui/react/floating-ui-react/utils/getEmptyRootContext.mjs 7981 function getEmptyRootContext() { 7982 return new FloatingRootStore({ 7983 open: false, 7984 transitionStatus: void 0, 7985 floatingElement: null, 7986 referenceElement: null, 7987 triggerElements: new PopupTriggerMap(), 7988 floatingId: void 0, 7989 syncOnly: false, 7990 nested: false, 7991 onOpenChange: void 0 7992 }); 7993 } 7994 7995 // node_modules/@base-ui/react/utils/popups/store.mjs 7996 function createInitialPopupStoreState() { 7997 return { 7998 open: false, 7999 openProp: void 0, 8000 mounted: false, 8001 transitionStatus: void 0, 8002 floatingRootContext: getEmptyRootContext(), 8003 floatingId: void 0, 8004 triggerCount: 0, 8005 preventUnmountingOnClose: false, 8006 payload: void 0, 8007 activeTriggerId: null, 8008 activeTriggerElement: null, 8009 triggerIdProp: void 0, 8010 popupElement: null, 8011 positionerElement: null, 8012 activeTriggerProps: EMPTY_OBJECT, 8013 inactiveTriggerProps: EMPTY_OBJECT, 8014 popupProps: EMPTY_OBJECT 8015 }; 8016 } 8017 function createPopupFloatingRootContext(triggerElements, floatingId, nested = false) { 8018 return new FloatingRootStore({ 8019 open: false, 8020 transitionStatus: void 0, 8021 floatingElement: null, 8022 referenceElement: null, 8023 triggerElements, 8024 floatingId, 8025 syncOnly: true, 8026 nested, 8027 onOpenChange: void 0 8028 }); 8029 } 8030 var activeTriggerIdSelector = createSelector((state) => state.triggerIdProp ?? state.activeTriggerId); 8031 var openSelector = createSelector((state) => state.openProp ?? state.open); 8032 var popupIdSelector = createSelector((state) => { 8033 const popupId = state.popupElement?.id ?? state.floatingId; 8034 return popupId || void 0; 8035 }); 8036 function triggerOwnsOpenPopup(state, triggerId) { 8037 return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) === triggerId; 8038 } 8039 function triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) { 8040 if (triggerOwnsOpenPopup(state, triggerId)) { 8041 return true; 8042 } 8043 return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) == null && state.triggerCount === 1; 8044 } 8045 var popupStoreSelectors = { 8046 open: openSelector, 8047 mounted: createSelector((state) => state.mounted), 8048 transitionStatus: createSelector((state) => state.transitionStatus), 8049 floatingRootContext: createSelector((state) => state.floatingRootContext), 8050 triggerCount: createSelector((state) => state.triggerCount), 8051 preventUnmountingOnClose: createSelector((state) => state.preventUnmountingOnClose), 8052 payload: createSelector((state) => state.payload), 8053 activeTriggerId: activeTriggerIdSelector, 8054 activeTriggerElement: createSelector((state) => state.mounted ? state.activeTriggerElement : null), 8055 popupId: popupIdSelector, 8056 /** 8057 * Whether the trigger with the given ID was used to open the popup. 8058 */ 8059 isTriggerActive: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId), 8060 /** 8061 * Whether the popup is open and was activated by a trigger with the given ID. 8062 */ 8063 isOpenedByTrigger: createSelector((state, triggerId) => triggerOwnsOpenPopup(state, triggerId)), 8064 /** 8065 * Whether the popup is mounted and was activated by a trigger with the given ID. 8066 */ 8067 isMountedByTrigger: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId && state.mounted), 8068 triggerProps: createSelector((state, isActive) => isActive ? state.activeTriggerProps : state.inactiveTriggerProps), 8069 /** 8070 * Popup id for the trigger that currently owns the open popup. 8071 */ 8072 triggerPopupId: createSelector((state, triggerId) => triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) ? popupIdSelector(state) : void 0), 8073 popupProps: createSelector((state) => state.popupProps), 8074 popupElement: createSelector((state) => state.popupElement), 8075 positionerElement: createSelector((state) => state.positionerElement) 8076 }; 8077 8078 // node_modules/@base-ui/react/floating-ui-react/hooks/useFloatingRootContext.mjs 8079 function useFloatingRootContext(options) { 8080 const { 8081 open = false, 8082 onOpenChange, 8083 elements = {} 8084 } = options; 8085 const floatingId = useId(); 8086 const nested = useFloatingParentNodeId() != null; 8087 if (true) { 8088 const optionDomReference = elements.reference; 8089 if (optionDomReference && !isElement(optionDomReference)) { 8090 console.error("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `context.setPositionReference()`", "instead."); 8091 } 8092 } 8093 const store = useRefWithInit(() => new FloatingRootStore({ 8094 open, 8095 transitionStatus: void 0, 8096 onOpenChange, 8097 referenceElement: elements.reference ?? null, 8098 floatingElement: elements.floating ?? null, 8099 triggerElements: new PopupTriggerMap(), 8100 floatingId, 8101 syncOnly: false, 8102 nested 8103 })).current; 8104 useIsoLayoutEffect(() => { 8105 const valuesToSync = { 8106 open, 8107 floatingId 8108 }; 8109 if (elements.reference !== void 0) { 8110 valuesToSync.referenceElement = elements.reference; 8111 valuesToSync.domReferenceElement = isElement(elements.reference) ? elements.reference : null; 8112 } 8113 if (elements.floating !== void 0) { 8114 valuesToSync.floatingElement = elements.floating; 8115 } 8116 store.update(valuesToSync); 8117 }, [open, floatingId, elements.reference, elements.floating, store]); 8118 store.context.onOpenChange = onOpenChange; 8119 store.context.nested = nested; 8120 return store; 8121 } 8122 8123 // node_modules/@base-ui/react/floating-ui-react/hooks/useFloating.mjs 8124 function useFloating2(options = {}) { 8125 const { 8126 nodeId, 8127 externalTree 8128 } = options; 8129 const internalStore = useFloatingRootContext(options); 8130 const store = options.rootContext || internalStore; 8131 const referenceElement = store.useState("referenceElement"); 8132 const floatingElement = store.useState("floatingElement"); 8133 const domReferenceElement = store.useState("domReferenceElement"); 8134 const open = store.useState("open"); 8135 const floatingId = store.useState("floatingId"); 8136 const [positionReference, setPositionReferenceRaw] = React34.useState(null); 8137 const [localDomReference, setLocalDomReference] = React34.useState(void 0); 8138 const [localFloatingElement, setLocalFloatingElement] = React34.useState(void 0); 8139 const domReferenceRef = React34.useRef(null); 8140 const tree = useFloatingTree(externalTree); 8141 const storeElements = React34.useMemo(() => ({ 8142 reference: referenceElement, 8143 floating: floatingElement, 8144 domReference: domReferenceElement 8145 }), [referenceElement, floatingElement, domReferenceElement]); 8146 const position = useFloating({ 8147 ...options, 8148 elements: { 8149 ...storeElements, 8150 ...positionReference && { 8151 reference: positionReference 8152 } 8153 } 8154 }); 8155 const localDomReferenceElement = isElement(localDomReference) ? localDomReference : null; 8156 const syncedFloatingElement = localFloatingElement === void 0 ? store.state.floatingElement : localFloatingElement; 8157 store.useSyncedValue("referenceElement", localDomReference ?? null); 8158 store.useSyncedValue("domReferenceElement", localDomReference === void 0 ? domReferenceElement : localDomReferenceElement); 8159 store.useSyncedValue("floatingElement", syncedFloatingElement); 8160 const setPositionReference = React34.useCallback((node) => { 8161 const computedPositionReference = isElement(node) ? { 8162 getBoundingClientRect: () => node.getBoundingClientRect(), 8163 getClientRects: () => node.getClientRects(), 8164 contextElement: node 8165 } : node; 8166 setPositionReferenceRaw(computedPositionReference); 8167 position.refs.setReference(computedPositionReference); 8168 }, [position.refs]); 8169 const setReference = React34.useCallback((node) => { 8170 if (isElement(node) || node === null) { 8171 domReferenceRef.current = node; 8172 setLocalDomReference(node); 8173 } 8174 if (isElement(position.refs.reference.current) || position.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to 8175 // `null` to support `positionReference` + an unstable `reference` 8176 // callback ref. 8177 node !== null && !isElement(node)) { 8178 position.refs.setReference(node); 8179 } 8180 }, [position.refs, setLocalDomReference]); 8181 const setFloating = React34.useCallback((node) => { 8182 setLocalFloatingElement(node); 8183 position.refs.setFloating(node); 8184 }, [position.refs]); 8185 const refs = React34.useMemo(() => ({ 8186 ...position.refs, 8187 setReference, 8188 setFloating, 8189 setPositionReference, 8190 domReference: domReferenceRef 8191 }), [position.refs, setReference, setFloating, setPositionReference]); 8192 const elements = React34.useMemo(() => ({ 8193 ...position.elements, 8194 domReference: domReferenceElement 8195 }), [position.elements, domReferenceElement]); 8196 const context = React34.useMemo(() => ({ 8197 ...position, 8198 dataRef: store.context.dataRef, 8199 open, 8200 onOpenChange: store.setOpen, 8201 events: store.context.events, 8202 floatingId, 8203 refs, 8204 elements, 8205 nodeId, 8206 rootStore: store 8207 }), [position, refs, elements, nodeId, store, open, floatingId]); 8208 useIsoLayoutEffect(() => { 8209 if (domReferenceElement) { 8210 domReferenceRef.current = domReferenceElement; 8211 } 8212 }, [domReferenceElement]); 8213 useIsoLayoutEffect(() => { 8214 store.context.dataRef.current.floatingContext = context; 8215 const node = tree?.nodesRef.current.find((n2) => n2.id === nodeId); 8216 if (node) { 8217 node.context = context; 8218 } 8219 }); 8220 return React34.useMemo(() => ({ 8221 ...position, 8222 context, 8223 refs, 8224 elements, 8225 rootStore: store 8226 }), [position, refs, elements, context, store]); 8227 } 8228 8229 // node_modules/@base-ui/react/floating-ui-react/hooks/useFocus.mjs 8230 var React35 = __toESM(require_react(), 1); 8231 var isMacSafari = parts_exports.os.mac && parts_exports.engine.webkit; 8232 function useFocus(context, props = {}) { 8233 const { 8234 enabled = true, 8235 delay 8236 } = props; 8237 const store = "rootStore" in context ? context.rootStore : context; 8238 const { 8239 events, 8240 dataRef 8241 } = store.context; 8242 const blockFocusRef = React35.useRef(false); 8243 const blockedReferenceRef = React35.useRef(null); 8244 const keyboardModalityRef = React35.useRef(true); 8245 const timeout = useTimeout(); 8246 React35.useEffect(() => { 8247 const domReference = store.select("domReferenceElement"); 8248 if (!enabled) { 8249 return void 0; 8250 } 8251 const win = getWindow(domReference); 8252 function onBlur() { 8253 const currentDomReference = store.select("domReferenceElement"); 8254 if (!store.select("open") && isHTMLElement(currentDomReference) && currentDomReference === activeElement(ownerDocument(currentDomReference))) { 8255 blockFocusRef.current = true; 8256 } 8257 } 8258 function onKeyDown() { 8259 keyboardModalityRef.current = true; 8260 } 8261 function onPointerDown() { 8262 keyboardModalityRef.current = false; 8263 } 8264 return mergeCleanups(addEventListener(win, "blur", onBlur), isMacSafari && addEventListener(win, "keydown", onKeyDown, true), isMacSafari && addEventListener(win, "pointerdown", onPointerDown, true)); 8265 }, [store, enabled]); 8266 React35.useEffect(() => { 8267 if (!enabled) { 8268 return void 0; 8269 } 8270 function onOpenChangeLocal(details) { 8271 if (details.reason === reason_parts_exports.triggerPress || details.reason === reason_parts_exports.escapeKey) { 8272 const referenceElement = store.select("domReferenceElement"); 8273 if (isElement(referenceElement)) { 8274 blockedReferenceRef.current = referenceElement; 8275 blockFocusRef.current = true; 8276 } 8277 } 8278 } 8279 events.on("openchange", onOpenChangeLocal); 8280 return () => { 8281 events.off("openchange", onOpenChangeLocal); 8282 }; 8283 }, [events, enabled, store]); 8284 const reference = React35.useMemo(() => { 8285 function resetBlockedFocus() { 8286 blockFocusRef.current = false; 8287 blockedReferenceRef.current = null; 8288 } 8289 return { 8290 onMouseLeave() { 8291 resetBlockedFocus(); 8292 }, 8293 onFocus(event) { 8294 const focusTarget = event.currentTarget; 8295 if (blockFocusRef.current) { 8296 if (blockedReferenceRef.current === focusTarget) { 8297 return; 8298 } 8299 resetBlockedFocus(); 8300 } 8301 const target = getTarget(event.nativeEvent); 8302 if (isElement(target)) { 8303 if (isMacSafari && !event.relatedTarget) { 8304 if (!keyboardModalityRef.current && !isTypeableElement(target)) { 8305 return; 8306 } 8307 } else if (!matchesFocusVisible(target)) { 8308 return; 8309 } 8310 } 8311 const movedFromOtherEnabledTrigger = isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements); 8312 const { 8313 nativeEvent, 8314 currentTarget 8315 } = event; 8316 const delayValue = typeof delay === "function" ? delay() : delay; 8317 if (store.select("open") && movedFromOtherEnabledTrigger || delayValue === 0 || delayValue === void 0) { 8318 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget)); 8319 return; 8320 } 8321 timeout.start(delayValue, () => { 8322 if (blockFocusRef.current) { 8323 return; 8324 } 8325 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget)); 8326 }); 8327 }, 8328 onBlur(event) { 8329 resetBlockedFocus(); 8330 const relatedTarget = event.relatedTarget; 8331 const nativeEvent = event.nativeEvent; 8332 const movedToFocusGuard = isElement(relatedTarget) && relatedTarget.hasAttribute(createAttribute("focus-guard")) && relatedTarget.getAttribute("data-type") === "outside"; 8333 timeout.start(0, () => { 8334 const domReference = store.select("domReferenceElement"); 8335 const activeEl = activeElement(ownerDocument(domReference)); 8336 if (!relatedTarget && activeEl === domReference) { 8337 return; 8338 } 8339 if (contains(dataRef.current.floatingContext?.refs.floating.current, activeEl) || contains(domReference, activeEl) || movedToFocusGuard) { 8340 return; 8341 } 8342 const nextFocusedElement = relatedTarget ?? activeEl; 8343 if (isTargetInsideEnabledTrigger(nextFocusedElement, store.context.triggerElements)) { 8344 return; 8345 } 8346 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent)); 8347 }); 8348 } 8349 }; 8350 }, [dataRef, delay, store, timeout]); 8351 return React35.useMemo(() => enabled ? { 8352 reference, 8353 trigger: reference 8354 } : {}, [enabled, reference]); 8355 } 8356 8357 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverFloatingInteraction.mjs 8358 var React36 = __toESM(require_react(), 1); 8359 8360 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverInteractionSharedState.mjs 8361 var HoverInteraction = class _HoverInteraction { 8362 constructor() { 8363 this.pointerType = void 0; 8364 this.interactedInside = false; 8365 this.handler = void 0; 8366 this.blockMouseMove = true; 8367 this.performedPointerEventsMutation = false; 8368 this.pointerEventsScopeElement = null; 8369 this.pointerEventsReferenceElement = null; 8370 this.pointerEventsFloatingElement = null; 8371 this.restTimeoutPending = false; 8372 this.openChangeTimeout = new Timeout(); 8373 this.restTimeout = new Timeout(); 8374 this.handleCloseOptions = void 0; 8375 } 8376 static create() { 8377 return new _HoverInteraction(); 8378 } 8379 dispose = () => { 8380 this.openChangeTimeout.clear(); 8381 this.restTimeout.clear(); 8382 }; 8383 disposeEffect = () => { 8384 return this.dispose; 8385 }; 8386 }; 8387 var pointerEventsMutationOwnerByScopeElement = /* @__PURE__ */ new WeakMap(); 8388 function clearSafePolygonPointerEventsMutation(instance) { 8389 if (!instance.performedPointerEventsMutation) { 8390 return; 8391 } 8392 const scopeElement = instance.pointerEventsScopeElement; 8393 if (scopeElement && pointerEventsMutationOwnerByScopeElement.get(scopeElement) === instance) { 8394 instance.pointerEventsScopeElement?.style.removeProperty("pointer-events"); 8395 instance.pointerEventsReferenceElement?.style.removeProperty("pointer-events"); 8396 instance.pointerEventsFloatingElement?.style.removeProperty("pointer-events"); 8397 pointerEventsMutationOwnerByScopeElement.delete(scopeElement); 8398 } 8399 instance.performedPointerEventsMutation = false; 8400 instance.pointerEventsScopeElement = null; 8401 instance.pointerEventsReferenceElement = null; 8402 instance.pointerEventsFloatingElement = null; 8403 } 8404 function applySafePolygonPointerEventsMutation(instance, options) { 8405 const { 8406 scopeElement, 8407 referenceElement, 8408 floatingElement 8409 } = options; 8410 const existingOwner = pointerEventsMutationOwnerByScopeElement.get(scopeElement); 8411 if (existingOwner && existingOwner !== instance) { 8412 clearSafePolygonPointerEventsMutation(existingOwner); 8413 } 8414 clearSafePolygonPointerEventsMutation(instance); 8415 instance.performedPointerEventsMutation = true; 8416 instance.pointerEventsScopeElement = scopeElement; 8417 instance.pointerEventsReferenceElement = referenceElement; 8418 instance.pointerEventsFloatingElement = floatingElement; 8419 pointerEventsMutationOwnerByScopeElement.set(scopeElement, instance); 8420 scopeElement.style.pointerEvents = "none"; 8421 referenceElement.style.pointerEvents = "auto"; 8422 floatingElement.style.pointerEvents = "auto"; 8423 } 8424 function useHoverInteractionSharedState(store) { 8425 const data = store.context.dataRef.current; 8426 const instance = useRefWithInit(() => data.hoverInteractionState ?? HoverInteraction.create()).current; 8427 if (!data.hoverInteractionState) { 8428 data.hoverInteractionState = instance; 8429 } 8430 useOnMount(data.hoverInteractionState.disposeEffect); 8431 return data.hoverInteractionState; 8432 } 8433 8434 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverFloatingInteraction.mjs 8435 function useHoverFloatingInteraction(context, parameters = {}) { 8436 const { 8437 enabled = true, 8438 closeDelay: closeDelayProp = 0, 8439 nodeId: nodeIdProp 8440 } = parameters; 8441 const store = "rootStore" in context ? context.rootStore : context; 8442 const open = store.useState("open"); 8443 const floatingElement = store.useState("floatingElement"); 8444 const domReferenceElement = store.useState("domReferenceElement"); 8445 const { 8446 dataRef 8447 } = store.context; 8448 const tree = useFloatingTree(); 8449 const parentId = useFloatingParentNodeId(); 8450 const instance = useHoverInteractionSharedState(store); 8451 const childClosedTimeout = useTimeout(); 8452 const isClickLikeOpenEvent2 = useStableCallback(() => { 8453 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside); 8454 }); 8455 const isHoverOpen = useStableCallback(() => { 8456 return isHoverOpenEvent(dataRef.current.openEvent?.type); 8457 }); 8458 const clearPointerEvents = useStableCallback(() => { 8459 clearSafePolygonPointerEventsMutation(instance); 8460 }); 8461 useIsoLayoutEffect(() => { 8462 if (!open) { 8463 instance.pointerType = void 0; 8464 instance.restTimeoutPending = false; 8465 instance.interactedInside = false; 8466 clearPointerEvents(); 8467 } 8468 }, [open, instance, clearPointerEvents]); 8469 React36.useEffect(() => { 8470 return clearPointerEvents; 8471 }, [clearPointerEvents]); 8472 useIsoLayoutEffect(() => { 8473 if (!enabled) { 8474 return void 0; 8475 } 8476 if (open && instance.handleCloseOptions?.blockPointerEvents && isHoverOpen() && isElement(domReferenceElement) && floatingElement) { 8477 const ref = domReferenceElement; 8478 const floatingEl = floatingElement; 8479 const doc = ownerDocument(floatingElement); 8480 const parentFloating = tree?.nodesRef.current.find((node) => node.id === parentId)?.context?.elements.floating; 8481 if (parentFloating) { 8482 parentFloating.style.pointerEvents = ""; 8483 } 8484 const cachedScopeElement = instance.pointerEventsScopeElement !== floatingEl ? instance.pointerEventsScopeElement : null; 8485 const parentScopeElement = parentFloating !== floatingEl ? parentFloating : null; 8486 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? cachedScopeElement ?? parentScopeElement ?? ref.closest("[data-rootownerid]") ?? doc.body; 8487 applySafePolygonPointerEventsMutation(instance, { 8488 scopeElement, 8489 referenceElement: ref, 8490 floatingElement: floatingEl 8491 }); 8492 return () => { 8493 clearPointerEvents(); 8494 }; 8495 } 8496 return void 0; 8497 }, [enabled, open, domReferenceElement, floatingElement, instance, isHoverOpen, tree, parentId, clearPointerEvents]); 8498 React36.useEffect(() => { 8499 if (!enabled) { 8500 return void 0; 8501 } 8502 function hasParentChildren() { 8503 return !!(tree && parentId && getNodeChildren(tree.nodesRef.current, parentId).length > 0); 8504 } 8505 function closeWithDelay(event) { 8506 const closeDelay = getDelay(closeDelayProp, "close", instance.pointerType); 8507 const close = () => { 8508 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event)); 8509 tree?.events.emit("floating.closed", event); 8510 }; 8511 if (closeDelay) { 8512 instance.openChangeTimeout.start(closeDelay, close); 8513 } else { 8514 instance.openChangeTimeout.clear(); 8515 close(); 8516 } 8517 } 8518 function handleInteractInside(event) { 8519 const target = getTarget(event); 8520 if (!isInteractiveElement(target)) { 8521 instance.interactedInside = false; 8522 return; 8523 } 8524 instance.interactedInside = target?.closest("[aria-haspopup]") != null; 8525 } 8526 function onFloatingMouseEnter() { 8527 instance.openChangeTimeout.clear(); 8528 childClosedTimeout.clear(); 8529 tree?.events.off("floating.closed", onNodeClosed); 8530 clearPointerEvents(); 8531 } 8532 function onFloatingMouseLeave(event) { 8533 if (hasParentChildren() && tree) { 8534 tree.events.on("floating.closed", onNodeClosed); 8535 return; 8536 } 8537 if (isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements)) { 8538 return; 8539 } 8540 const currentNodeId = dataRef.current.floatingContext?.nodeId ?? nodeIdProp; 8541 const relatedTarget = event.relatedTarget; 8542 const isMovingIntoDescendantFloating = tree && currentNodeId && isElement(relatedTarget) && getNodeChildren(tree.nodesRef.current, currentNodeId, false).some((node) => contains(node.context?.elements.floating, relatedTarget)); 8543 if (isMovingIntoDescendantFloating) { 8544 return; 8545 } 8546 if (instance.handler) { 8547 instance.handler(event); 8548 return; 8549 } 8550 clearPointerEvents(); 8551 if (isHoverOpen() && !isClickLikeOpenEvent2()) { 8552 closeWithDelay(event); 8553 } 8554 } 8555 function onNodeClosed(event) { 8556 if (!tree || !parentId || hasParentChildren()) { 8557 return; 8558 } 8559 childClosedTimeout.start(0, () => { 8560 tree.events.off("floating.closed", onNodeClosed); 8561 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event)); 8562 tree.events.emit("floating.closed", event); 8563 }); 8564 } 8565 const floating = floatingElement; 8566 return mergeCleanups(floating && addEventListener(floating, "mouseenter", onFloatingMouseEnter), floating && addEventListener(floating, "mouseleave", onFloatingMouseLeave), floating && addEventListener(floating, "pointerdown", handleInteractInside, true), () => { 8567 tree?.events.off("floating.closed", onNodeClosed); 8568 }); 8569 }, [enabled, floatingElement, store, dataRef, closeDelayProp, nodeIdProp, isHoverOpen, isClickLikeOpenEvent2, clearPointerEvents, instance, tree, parentId, childClosedTimeout]); 8570 } 8571 8572 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverReferenceInteraction.mjs 8573 var React37 = __toESM(require_react(), 1); 8574 var ReactDOM5 = __toESM(require_react_dom(), 1); 8575 var EMPTY_REF = { 8576 current: null 8577 }; 8578 function useHoverReferenceInteraction(context, props = {}) { 8579 const { 8580 enabled = true, 8581 delay = 0, 8582 handleClose = null, 8583 mouseOnly = false, 8584 restMs = 0, 8585 move = true, 8586 triggerElementRef = EMPTY_REF, 8587 externalTree, 8588 isActiveTrigger = true, 8589 getHandleCloseContext, 8590 isClosing, 8591 shouldOpen: shouldOpenProp 8592 } = props; 8593 const store = "rootStore" in context ? context.rootStore : context; 8594 const { 8595 dataRef, 8596 events 8597 } = store.context; 8598 const tree = useFloatingTree(externalTree); 8599 const instance = useHoverInteractionSharedState(store); 8600 const isHoverCloseActiveRef = React37.useRef(false); 8601 const handleCloseRef = useValueAsRef(handleClose); 8602 const delayRef = useValueAsRef(delay); 8603 const restMsRef = useValueAsRef(restMs); 8604 const enabledRef = useValueAsRef(enabled); 8605 const shouldOpenRef = useValueAsRef(shouldOpenProp); 8606 const isClosingRef = useValueAsRef(isClosing); 8607 const isClickLikeOpenEvent2 = useStableCallback(() => { 8608 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside); 8609 }); 8610 const checkShouldOpen = useStableCallback(() => { 8611 return shouldOpenRef.current?.() !== false; 8612 }); 8613 const isOverInactiveTrigger = useStableCallback((currentDomReference, currentTarget, target) => { 8614 const allTriggers = store.context.triggerElements; 8615 if (allTriggers.hasElement(currentTarget)) { 8616 return !currentDomReference || !contains(currentDomReference, currentTarget); 8617 } 8618 if (!isElement(target)) { 8619 return false; 8620 } 8621 const targetElement = target; 8622 return allTriggers.hasMatchingElement((trigger) => contains(trigger, targetElement)) && (!currentDomReference || !contains(currentDomReference, targetElement)); 8623 }); 8624 const cleanupMouseMoveHandler = useStableCallback(() => { 8625 if (!instance.handler) { 8626 return; 8627 } 8628 const doc = ownerDocument(store.select("domReferenceElement")); 8629 doc.removeEventListener("mousemove", instance.handler); 8630 instance.handler = void 0; 8631 }); 8632 const clearPointerEvents = useStableCallback(() => { 8633 clearSafePolygonPointerEventsMutation(instance); 8634 }); 8635 if (isActiveTrigger) { 8636 instance.handleCloseOptions = handleCloseRef.current?.__options; 8637 } 8638 React37.useEffect(() => cleanupMouseMoveHandler, [cleanupMouseMoveHandler]); 8639 React37.useEffect(() => { 8640 if (!enabled) { 8641 return void 0; 8642 } 8643 function onOpenChangeLocal(details) { 8644 if (!details.open) { 8645 isHoverCloseActiveRef.current = details.reason === reason_parts_exports.triggerHover; 8646 cleanupMouseMoveHandler(); 8647 instance.openChangeTimeout.clear(); 8648 instance.restTimeout.clear(); 8649 instance.blockMouseMove = true; 8650 instance.restTimeoutPending = false; 8651 } else { 8652 isHoverCloseActiveRef.current = false; 8653 } 8654 } 8655 events.on("openchange", onOpenChangeLocal); 8656 return () => { 8657 events.off("openchange", onOpenChangeLocal); 8658 }; 8659 }, [enabled, events, instance, cleanupMouseMoveHandler]); 8660 React37.useEffect(() => { 8661 if (!enabled) { 8662 return void 0; 8663 } 8664 function closeWithDelay(event, runElseBranch = true) { 8665 const closeDelay = getDelay(delayRef.current, "close", instance.pointerType); 8666 if (closeDelay) { 8667 instance.openChangeTimeout.start(closeDelay, () => { 8668 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event)); 8669 tree?.events.emit("floating.closed", event); 8670 }); 8671 } else if (runElseBranch) { 8672 instance.openChangeTimeout.clear(); 8673 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event)); 8674 tree?.events.emit("floating.closed", event); 8675 } 8676 } 8677 const trigger = triggerElementRef.current ?? (isActiveTrigger ? store.select("domReferenceElement") : null); 8678 if (!isElement(trigger)) { 8679 return void 0; 8680 } 8681 function onMouseEnter(event) { 8682 instance.openChangeTimeout.clear(); 8683 instance.blockMouseMove = false; 8684 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) { 8685 return; 8686 } 8687 const restMsValue = getRestMs(restMsRef.current); 8688 const openDelay = getDelay(delayRef.current, "open", instance.pointerType); 8689 const eventTarget = getTarget(event); 8690 const currentTarget = event.currentTarget ?? null; 8691 const currentDomReference = store.select("domReferenceElement"); 8692 let triggerNode = currentTarget; 8693 if (isElement(eventTarget) && !store.context.triggerElements.hasElement(eventTarget)) { 8694 for (const triggerElement of store.context.triggerElements.elements()) { 8695 if (contains(triggerElement, eventTarget)) { 8696 triggerNode = triggerElement; 8697 break; 8698 } 8699 } 8700 } 8701 if (isElement(currentTarget) && isElement(currentDomReference) && !store.context.triggerElements.hasElement(currentTarget) && contains(currentTarget, currentDomReference)) { 8702 triggerNode = currentDomReference; 8703 } 8704 const isOverInactive = triggerNode == null ? false : isOverInactiveTrigger(currentDomReference, triggerNode, eventTarget); 8705 const isOpen = store.select("open"); 8706 const isInClosingTransition = isClosingRef.current?.() ?? store.select("transitionStatus") === "ending"; 8707 const isHoverCloseTransition = !isOpen && isInClosingTransition && isHoverCloseActiveRef.current; 8708 const isReenteringSameTriggerDuringCloseTransition = !isOverInactive && isElement(triggerNode) && isElement(currentDomReference) && contains(currentDomReference, triggerNode) && isHoverCloseTransition; 8709 const isRestOnlyDelay = restMsValue > 0 && !openDelay; 8710 const shouldOpenImmediately = isOverInactive && (isOpen || isHoverCloseTransition) || isReenteringSameTriggerDuringCloseTransition; 8711 const shouldOpen = !isOpen || isOverInactive; 8712 if (shouldOpenImmediately) { 8713 if (checkShouldOpen()) { 8714 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode)); 8715 } 8716 return; 8717 } 8718 if (isRestOnlyDelay) { 8719 return; 8720 } 8721 if (openDelay) { 8722 instance.openChangeTimeout.start(openDelay, () => { 8723 if (shouldOpen && checkShouldOpen()) { 8724 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode)); 8725 } 8726 }); 8727 } else if (shouldOpen) { 8728 if (checkShouldOpen()) { 8729 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode)); 8730 } 8731 } 8732 } 8733 function onMouseLeave(event) { 8734 if (isClickLikeOpenEvent2()) { 8735 clearPointerEvents(); 8736 return; 8737 } 8738 cleanupMouseMoveHandler(); 8739 const domReferenceElement = store.select("domReferenceElement"); 8740 const doc = ownerDocument(domReferenceElement); 8741 instance.restTimeout.clear(); 8742 instance.restTimeoutPending = false; 8743 const handleCloseContextBase = dataRef.current.floatingContext ?? getHandleCloseContext?.(); 8744 if (isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements)) { 8745 return; 8746 } 8747 if (handleCloseRef.current && handleCloseContextBase) { 8748 if (!store.select("open")) { 8749 instance.openChangeTimeout.clear(); 8750 } 8751 const currentTrigger = triggerElementRef.current; 8752 instance.handler = handleCloseRef.current({ 8753 ...handleCloseContextBase, 8754 tree, 8755 x: event.clientX, 8756 y: event.clientY, 8757 onClose() { 8758 clearPointerEvents(); 8759 cleanupMouseMoveHandler(); 8760 if (enabledRef.current && !isClickLikeOpenEvent2() && currentTrigger === store.select("domReferenceElement")) { 8761 closeWithDelay(event, true); 8762 } 8763 } 8764 }); 8765 doc.addEventListener("mousemove", instance.handler); 8766 instance.handler(event); 8767 return; 8768 } 8769 const shouldClose = instance.pointerType === "touch" ? !contains(store.select("floatingElement"), event.relatedTarget) : true; 8770 if (shouldClose) { 8771 closeWithDelay(event); 8772 } 8773 } 8774 if (move) { 8775 return mergeCleanups(addEventListener(trigger, "mousemove", onMouseEnter, { 8776 once: true 8777 }), addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave)); 8778 } 8779 return mergeCleanups(addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave)); 8780 }, [cleanupMouseMoveHandler, clearPointerEvents, dataRef, delayRef, store, enabled, handleCloseRef, instance, isActiveTrigger, isOverInactiveTrigger, isClickLikeOpenEvent2, mouseOnly, move, restMsRef, triggerElementRef, tree, enabledRef, getHandleCloseContext, isClosingRef, checkShouldOpen]); 8781 return React37.useMemo(() => { 8782 if (!enabled) { 8783 return void 0; 8784 } 8785 function setPointerRef(event) { 8786 instance.pointerType = event.pointerType; 8787 } 8788 return { 8789 onPointerDown: setPointerRef, 8790 onPointerEnter: setPointerRef, 8791 onMouseMove(event) { 8792 const { 8793 nativeEvent 8794 } = event; 8795 const trigger = event.currentTarget; 8796 const currentDomReference = store.select("domReferenceElement"); 8797 const currentOpen = store.select("open"); 8798 const isOverInactive = isOverInactiveTrigger(currentDomReference, trigger, event.target); 8799 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) { 8800 return; 8801 } 8802 if (currentOpen && isOverInactive && instance.handleCloseOptions?.blockPointerEvents) { 8803 const floatingElement = store.select("floatingElement"); 8804 if (floatingElement) { 8805 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? trigger.ownerDocument.body; 8806 applySafePolygonPointerEventsMutation(instance, { 8807 scopeElement, 8808 referenceElement: trigger, 8809 floatingElement 8810 }); 8811 } 8812 } 8813 const restMsValue = getRestMs(restMsRef.current); 8814 if (currentOpen && !isOverInactive || restMsValue === 0) { 8815 return; 8816 } 8817 if (!isOverInactive && instance.restTimeoutPending && event.movementX ** 2 + event.movementY ** 2 < 2) { 8818 return; 8819 } 8820 instance.restTimeout.clear(); 8821 function handleMouseMove() { 8822 instance.restTimeoutPending = false; 8823 if (isClickLikeOpenEvent2()) { 8824 return; 8825 } 8826 const latestOpen = store.select("open"); 8827 if (!instance.blockMouseMove && (!latestOpen || isOverInactive) && checkShouldOpen()) { 8828 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, nativeEvent, trigger)); 8829 } 8830 } 8831 if (instance.pointerType === "touch") { 8832 ReactDOM5.flushSync(() => { 8833 handleMouseMove(); 8834 }); 8835 } else if (isOverInactive && currentOpen) { 8836 handleMouseMove(); 8837 } else { 8838 instance.restTimeoutPending = true; 8839 instance.restTimeout.start(restMsValue, handleMouseMove); 8840 } 8841 } 8842 }; 8843 }, [enabled, instance, isClickLikeOpenEvent2, isOverInactiveTrigger, mouseOnly, store, restMsRef, checkShouldOpen]); 8844 } 8845 8846 // node_modules/@base-ui/react/floating-ui-react/safePolygon.mjs 8847 var CURSOR_SPEED_THRESHOLD = 0.1; 8848 var CURSOR_SPEED_THRESHOLD_SQUARED = CURSOR_SPEED_THRESHOLD * CURSOR_SPEED_THRESHOLD; 8849 var POLYGON_BUFFER = 0.5; 8850 function hasIntersectingEdge(pointX, pointY, xi, yi, xj, yj) { 8851 return yi >= pointY !== yj >= pointY && pointX <= (xj - xi) * (pointY - yi) / (yj - yi) + xi; 8852 } 8853 function isPointInQuadrilateral(pointX, pointY, x1, y1, x2, y2, x3, y3, x4, y4) { 8854 let isInsideValue = false; 8855 if (hasIntersectingEdge(pointX, pointY, x1, y1, x2, y2)) { 8856 isInsideValue = !isInsideValue; 8857 } 8858 if (hasIntersectingEdge(pointX, pointY, x2, y2, x3, y3)) { 8859 isInsideValue = !isInsideValue; 8860 } 8861 if (hasIntersectingEdge(pointX, pointY, x3, y3, x4, y4)) { 8862 isInsideValue = !isInsideValue; 8863 } 8864 if (hasIntersectingEdge(pointX, pointY, x4, y4, x1, y1)) { 8865 isInsideValue = !isInsideValue; 8866 } 8867 return isInsideValue; 8868 } 8869 function isInsideRect(pointX, pointY, rect) { 8870 return pointX >= rect.x && pointX <= rect.x + rect.width && pointY >= rect.y && pointY <= rect.y + rect.height; 8871 } 8872 function isInsideAxisAlignedRect(pointX, pointY, x1, y1, x2, y2) { 8873 const minX = Math.min(x1, x2); 8874 const maxX = Math.max(x1, x2); 8875 const minY = Math.min(y1, y2); 8876 const maxY = Math.max(y1, y2); 8877 return pointX >= minX && pointX <= maxX && pointY >= minY && pointY <= maxY; 8878 } 8879 function safePolygon(options = {}) { 8880 const { 8881 blockPointerEvents = false 8882 } = options; 8883 const timeout = new Timeout(); 8884 const fn = ({ 8885 x: x2, 8886 y: y2, 8887 placement, 8888 elements, 8889 onClose, 8890 nodeId, 8891 tree 8892 }) => { 8893 const side = placement?.split("-")[0]; 8894 let hasLanded = false; 8895 let lastX = null; 8896 let lastY = null; 8897 let lastCursorTime = typeof performance !== "undefined" ? performance.now() : 0; 8898 function isCursorMovingSlowly(nextX, nextY) { 8899 const currentTime = performance.now(); 8900 const elapsedTime = currentTime - lastCursorTime; 8901 if (lastX === null || lastY === null || elapsedTime === 0) { 8902 lastX = nextX; 8903 lastY = nextY; 8904 lastCursorTime = currentTime; 8905 return false; 8906 } 8907 const deltaX = nextX - lastX; 8908 const deltaY = nextY - lastY; 8909 const distanceSquared = deltaX * deltaX + deltaY * deltaY; 8910 const thresholdSquared = elapsedTime * elapsedTime * CURSOR_SPEED_THRESHOLD_SQUARED; 8911 lastX = nextX; 8912 lastY = nextY; 8913 lastCursorTime = currentTime; 8914 return distanceSquared < thresholdSquared; 8915 } 8916 function close() { 8917 timeout.clear(); 8918 onClose(); 8919 } 8920 return function onMouseMove(event) { 8921 timeout.clear(); 8922 const domReference = elements.domReference; 8923 const floating = elements.floating; 8924 if (!domReference || !floating || side == null || x2 == null || y2 == null) { 8925 return void 0; 8926 } 8927 const { 8928 clientX, 8929 clientY 8930 } = event; 8931 const target = getTarget(event); 8932 const isLeave = event.type === "mouseleave"; 8933 const isOverFloatingEl = contains(floating, target); 8934 const isOverReferenceEl = contains(domReference, target); 8935 if (isOverFloatingEl) { 8936 hasLanded = true; 8937 if (!isLeave) { 8938 return void 0; 8939 } 8940 } 8941 if (isOverReferenceEl) { 8942 hasLanded = false; 8943 if (!isLeave) { 8944 hasLanded = true; 8945 return void 0; 8946 } 8947 } 8948 if (isLeave && isElement(event.relatedTarget) && contains(floating, event.relatedTarget)) { 8949 return void 0; 8950 } 8951 function hasOpenChildNode() { 8952 return Boolean(tree && getNodeChildren(tree.nodesRef.current, nodeId).length > 0); 8953 } 8954 function closeIfNoOpenChild() { 8955 if (!hasOpenChildNode()) { 8956 close(); 8957 } 8958 } 8959 if (hasOpenChildNode()) { 8960 return void 0; 8961 } 8962 const refRect = domReference.getBoundingClientRect(); 8963 const rect = floating.getBoundingClientRect(); 8964 const cursorLeaveFromRight = x2 > rect.right - rect.width / 2; 8965 const cursorLeaveFromBottom = y2 > rect.bottom - rect.height / 2; 8966 const isFloatingWider = rect.width > refRect.width; 8967 const isFloatingTaller = rect.height > refRect.height; 8968 const left = (isFloatingWider ? refRect : rect).left; 8969 const right = (isFloatingWider ? refRect : rect).right; 8970 const top = (isFloatingTaller ? refRect : rect).top; 8971 const bottom = (isFloatingTaller ? refRect : rect).bottom; 8972 if (side === "top" && y2 >= refRect.bottom - 1 || side === "bottom" && y2 <= refRect.top + 1 || side === "left" && x2 >= refRect.right - 1 || side === "right" && x2 <= refRect.left + 1) { 8973 closeIfNoOpenChild(); 8974 return void 0; 8975 } 8976 let isInsideTroughRect = false; 8977 switch (side) { 8978 case "top": 8979 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, refRect.top + 1, right, rect.bottom - 1); 8980 break; 8981 case "bottom": 8982 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, rect.top + 1, right, refRect.bottom - 1); 8983 break; 8984 case "left": 8985 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, rect.right - 1, bottom, refRect.left + 1, top); 8986 break; 8987 case "right": 8988 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, refRect.right - 1, bottom, rect.left + 1, top); 8989 break; 8990 default: 8991 } 8992 if (isInsideTroughRect) { 8993 return void 0; 8994 } 8995 if (hasLanded && !isInsideRect(clientX, clientY, refRect)) { 8996 closeIfNoOpenChild(); 8997 return void 0; 8998 } 8999 if (!isLeave && isCursorMovingSlowly(clientX, clientY)) { 9000 closeIfNoOpenChild(); 9001 return void 0; 9002 } 9003 let isInsidePolygon = false; 9004 switch (side) { 9005 case "top": { 9006 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4; 9007 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset; 9008 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset; 9009 const cursorPointY = y2 + POLYGON_BUFFER + 1; 9010 const commonYLeft = cursorLeaveFromRight ? rect.bottom - POLYGON_BUFFER : isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top; 9011 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top : rect.bottom - POLYGON_BUFFER; 9012 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight); 9013 break; 9014 } 9015 case "bottom": { 9016 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4; 9017 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset; 9018 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset; 9019 const cursorPointY = y2 - POLYGON_BUFFER; 9020 const commonYLeft = cursorLeaveFromRight ? rect.top + POLYGON_BUFFER : isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom; 9021 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom : rect.top + POLYGON_BUFFER; 9022 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight); 9023 break; 9024 } 9025 case "left": { 9026 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4; 9027 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset; 9028 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset; 9029 const cursorPointX = x2 + POLYGON_BUFFER + 1; 9030 const commonXTop = cursorLeaveFromBottom ? rect.right - POLYGON_BUFFER : isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left; 9031 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left : rect.right - POLYGON_BUFFER; 9032 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, commonXTop, rect.top, commonXBottom, rect.bottom, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY); 9033 break; 9034 } 9035 case "right": { 9036 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4; 9037 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset; 9038 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset; 9039 const cursorPointX = x2 - POLYGON_BUFFER; 9040 const commonXTop = cursorLeaveFromBottom ? rect.left + POLYGON_BUFFER : isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right; 9041 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right : rect.left + POLYGON_BUFFER; 9042 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY, commonXTop, rect.top, commonXBottom, rect.bottom); 9043 break; 9044 } 9045 default: 9046 } 9047 if (!isInsidePolygon) { 9048 closeIfNoOpenChild(); 9049 } else if (!hasLanded) { 9050 timeout.start(40, closeIfNoOpenChild); 9051 } 9052 return void 0; 9053 }; 9054 }; 9055 fn.__options = { 9056 ...options, 9057 blockPointerEvents 9058 }; 9059 return fn; 9060 } 9061 9062 // node_modules/@base-ui/react/utils/popupStateMapping.mjs 9063 var CommonPopupDataAttributes = (function(CommonPopupDataAttributes2) { 9064 CommonPopupDataAttributes2["open"] = "data-open"; 9065 CommonPopupDataAttributes2["closed"] = "data-closed"; 9066 CommonPopupDataAttributes2[CommonPopupDataAttributes2["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle"; 9067 CommonPopupDataAttributes2[CommonPopupDataAttributes2["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle"; 9068 CommonPopupDataAttributes2["anchorHidden"] = "data-anchor-hidden"; 9069 CommonPopupDataAttributes2["side"] = "data-side"; 9070 CommonPopupDataAttributes2["align"] = "data-align"; 9071 return CommonPopupDataAttributes2; 9072 })({}); 9073 var CommonTriggerDataAttributes = /* @__PURE__ */ (function(CommonTriggerDataAttributes2) { 9074 CommonTriggerDataAttributes2["popupOpen"] = "data-popup-open"; 9075 CommonTriggerDataAttributes2["pressed"] = "data-pressed"; 9076 return CommonTriggerDataAttributes2; 9077 })({}); 9078 var TRIGGER_HOOK = { 9079 [CommonTriggerDataAttributes.popupOpen]: "" 9080 }; 9081 var PRESSABLE_TRIGGER_HOOK = { 9082 [CommonTriggerDataAttributes.popupOpen]: "", 9083 [CommonTriggerDataAttributes.pressed]: "" 9084 }; 9085 var POPUP_OPEN_HOOK = { 9086 [CommonPopupDataAttributes.open]: "" 9087 }; 9088 var POPUP_CLOSED_HOOK = { 9089 [CommonPopupDataAttributes.closed]: "" 9090 }; 9091 var ANCHOR_HIDDEN_HOOK = { 9092 [CommonPopupDataAttributes.anchorHidden]: "" 9093 }; 9094 var triggerOpenStateMapping2 = { 9095 open(value) { 9096 if (value) { 9097 return TRIGGER_HOOK; 9098 } 9099 return null; 9100 } 9101 }; 9102 var pressableTriggerOpenStateMapping = { 9103 open(value) { 9104 if (value) { 9105 return PRESSABLE_TRIGGER_HOOK; 9106 } 9107 return null; 9108 } 9109 }; 9110 var popupStateMapping = { 9111 open(value) { 9112 if (value) { 9113 return POPUP_OPEN_HOOK; 9114 } 9115 return POPUP_CLOSED_HOOK; 9116 }, 9117 anchorHidden(value) { 9118 if (value) { 9119 return ANCHOR_HIDDEN_HOOK; 9120 } 9121 return null; 9122 } 9123 }; 9124 9125 // node_modules/@base-ui/react/internals/composite/composite.mjs 9126 var ARROW_UP = "ArrowUp"; 9127 var ARROW_DOWN = "ArrowDown"; 9128 var ARROW_LEFT = "ArrowLeft"; 9129 var ARROW_RIGHT = "ArrowRight"; 9130 var HOME = "Home"; 9131 var END = "End"; 9132 var HORIZONTAL_KEYS = /* @__PURE__ */ new Set([ARROW_LEFT, ARROW_RIGHT]); 9133 var VERTICAL_KEYS = /* @__PURE__ */ new Set([ARROW_UP, ARROW_DOWN]); 9134 var ARROW_KEYS = /* @__PURE__ */ new Set([...HORIZONTAL_KEYS, ...VERTICAL_KEYS]); 9135 var COMPOSITE_KEYS = /* @__PURE__ */ new Set([...ARROW_KEYS, HOME, END]); 9136 9137 // node_modules/@base-ui/utils/inertValue.mjs 9138 function inertValue(value) { 9139 if (isReactVersionAtLeast(19)) { 9140 return value; 9141 } 9142 return value ? "true" : void 0; 9143 } 9144 9145 // node_modules/@base-ui/react/utils/InternalBackdrop.mjs 9146 var React38 = __toESM(require_react(), 1); 9147 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1); 9148 var InternalBackdrop = /* @__PURE__ */ React38.forwardRef(function InternalBackdrop2(props, ref) { 9149 const { 9150 cutout, 9151 ...otherProps 9152 } = props; 9153 let clipPath; 9154 if (cutout) { 9155 const rect = cutout.getBoundingClientRect(); 9156 clipPath = `polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,$rect.left}px $rect.top}px,$rect.left}px $rect.bottom}px,$rect.right}px $rect.bottom}px,$rect.right}px $rect.top}px,$rect.left}px $rect.top}px)`; 9157 } 9158 return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { 9159 ref, 9160 role: "presentation", 9161 "data-base-ui-inert": "", 9162 ...otherProps, 9163 style: { 9164 position: "fixed", 9165 inset: 0, 9166 userSelect: "none", 9167 WebkitUserSelect: "none", 9168 clipPath 9169 } 9170 }); 9171 }); 9172 if (true) InternalBackdrop.displayName = "InternalBackdrop"; 9173 9174 // node_modules/@base-ui/react/utils/useOpenInteractionType.mjs 9175 var React40 = __toESM(require_react(), 1); 9176 9177 // node_modules/@base-ui/utils/useEnhancedClickHandler.mjs 9178 var React39 = __toESM(require_react(), 1); 9179 function useEnhancedClickHandler(handler) { 9180 const lastClickInteractionTypeRef = React39.useRef(""); 9181 const handlePointerDown = React39.useCallback((event) => { 9182 if (event.defaultPrevented) { 9183 return; 9184 } 9185 lastClickInteractionTypeRef.current = event.pointerType; 9186 handler(event, event.pointerType); 9187 }, [handler]); 9188 const handleClick = React39.useCallback((event) => { 9189 if (event.detail === 0) { 9190 handler(event, "keyboard"); 9191 return; 9192 } 9193 if ("pointerType" in event) { 9194 handler(event, event.pointerType); 9195 } else { 9196 handler(event, lastClickInteractionTypeRef.current); 9197 } 9198 lastClickInteractionTypeRef.current = ""; 9199 }, [handler]); 9200 return { 9201 onClick: handleClick, 9202 onPointerDown: handlePointerDown 9203 }; 9204 } 9205 9206 // node_modules/@base-ui/react/utils/useOpenInteractionType.mjs 9207 function useOpenMethodTriggerProps(open, setOpenMethod) { 9208 const handleTriggerClick = useStableCallback((_, interactionType) => { 9209 const isOpen = typeof open === "function" ? open() : open; 9210 if (!isOpen) { 9211 setOpenMethod(interactionType || // On iOS Safari, the hitslop around touch targets means tapping outside an element's 9212 // bounds does not fire `pointerdown` but does fire `mousedown`. The `interactionType` 9213 // will be "" in that case. 9214 (parts_exports.os.ios ? "touch" : "")); 9215 } 9216 }); 9217 const { 9218 onClick, 9219 onPointerDown 9220 } = useEnhancedClickHandler(handleTriggerClick); 9221 return React40.useMemo(() => ({ 9222 onClick, 9223 onPointerDown 9224 }), [onClick, onPointerDown]); 9225 } 9226 9227 // node_modules/@base-ui/react/utils/useAnchorPositioning.mjs 9228 var React41 = __toESM(require_react(), 1); 9229 9230 // node_modules/@base-ui/react/floating-ui-react/middleware/arrow.mjs 9231 var baseArrow = (options) => ({ 9232 name: "arrow", 9233 options, 9234 async fn(state) { 9235 const { 9236 x: x2, 9237 y: y2, 9238 placement, 9239 rects, 9240 platform: platform3, 9241 elements, 9242 middlewareData 9243 } = state; 9244 const { 9245 element, 9246 padding = 0, 9247 offsetParent = "real" 9248 } = evaluate(options, state) || {}; 9249 if (element == null) { 9250 return {}; 9251 } 9252 const paddingObject = getPaddingObject(padding); 9253 const coords = { 9254 x: x2, 9255 y: y2 9256 }; 9257 const axis = getAlignmentAxis(placement); 9258 const length = getAxisLength(axis); 9259 const arrowDimensions = await platform3.getDimensions(element); 9260 const isYAxis = axis === "y"; 9261 const minProp = isYAxis ? "top" : "left"; 9262 const maxProp = isYAxis ? "bottom" : "right"; 9263 const clientProp = isYAxis ? "clientHeight" : "clientWidth"; 9264 const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length]; 9265 const startDiff = coords[axis] - rects.reference[axis]; 9266 const arrowOffsetParent = offsetParent === "real" ? await platform3.getOffsetParent?.(element) : elements.floating; 9267 let clientSize = elements.floating[clientProp] || rects.floating[length]; 9268 if (!clientSize || !await platform3.isElement?.(arrowOffsetParent)) { 9269 clientSize = elements.floating[clientProp] || rects.floating[length]; 9270 } 9271 const centerToReference = endDiff / 2 - startDiff / 2; 9272 const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1; 9273 const minPadding = Math.min(paddingObject[minProp], largestPossiblePadding); 9274 const maxPadding = Math.min(paddingObject[maxProp], largestPossiblePadding); 9275 const min2 = minPadding; 9276 const max2 = clientSize - arrowDimensions[length] - maxPadding; 9277 const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference; 9278 const offset4 = clamp(min2, center, max2); 9279 const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset4 && rects.reference[length] / 2 - (center < min2 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0; 9280 const alignmentOffset = shouldAddOffset ? center < min2 ? center - min2 : center - max2 : 0; 9281 return { 9282 [axis]: coords[axis] + alignmentOffset, 9283 data: { 9284 [axis]: offset4, 9285 centerOffset: center - offset4 - alignmentOffset, 9286 ...shouldAddOffset && { 9287 alignmentOffset 9288 } 9289 }, 9290 reset: shouldAddOffset 9291 }; 9292 } 9293 }); 9294 var arrow4 = (options, deps) => ({ 9295 ...baseArrow(options), 9296 options: [options, deps] 9297 }); 9298 9299 // node_modules/@base-ui/react/utils/hideMiddleware.mjs 9300 var nativeHideFn = hide3().fn; 9301 var hide4 = { 9302 name: "hide", 9303 async fn(state) { 9304 const { 9305 width, 9306 height, 9307 x: x2, 9308 y: y2 9309 } = state.rects.reference; 9310 const anchorHidden = width === 0 && height === 0 && x2 === 0 && y2 === 0; 9311 const nativeHideResult = await nativeHideFn(state); 9312 return { 9313 data: { 9314 referenceHidden: nativeHideResult.data?.referenceHidden || anchorHidden 9315 } 9316 }; 9317 } 9318 }; 9319 9320 // node_modules/@base-ui/react/utils/adaptiveOriginMiddleware.mjs 9321 var DEFAULT_SIDES = { 9322 sideX: "left", 9323 sideY: "top" 9324 }; 9325 var adaptiveOrigin = { 9326 name: "adaptiveOrigin", 9327 async fn(state) { 9328 const { 9329 x: rawX, 9330 y: rawY, 9331 rects: { 9332 floating: floatRect 9333 }, 9334 elements: { 9335 floating 9336 }, 9337 platform: platform3, 9338 strategy, 9339 placement 9340 } = state; 9341 const win = getWindow(floating); 9342 const styles = win.getComputedStyle(floating); 9343 const hasTransition = styles.transitionDuration !== "0s" && styles.transitionDuration !== ""; 9344 if (!hasTransition) { 9345 return { 9346 x: rawX, 9347 y: rawY, 9348 data: DEFAULT_SIDES 9349 }; 9350 } 9351 const offsetParent = await platform3.getOffsetParent?.(floating); 9352 let offsetDimensions = { 9353 width: 0, 9354 height: 0 9355 }; 9356 if (strategy === "fixed" && win?.visualViewport) { 9357 offsetDimensions = { 9358 width: win.visualViewport.width, 9359 height: win.visualViewport.height 9360 }; 9361 } else if (offsetParent === win) { 9362 const doc = ownerDocument(floating); 9363 offsetDimensions = { 9364 width: doc.documentElement.clientWidth, 9365 height: doc.documentElement.clientHeight 9366 }; 9367 } else if (await platform3.isElement?.(offsetParent)) { 9368 offsetDimensions = await platform3.getDimensions(offsetParent); 9369 } 9370 const currentSide = getSide(placement); 9371 let x2 = rawX; 9372 let y2 = rawY; 9373 if (currentSide === "left") { 9374 x2 = offsetDimensions.width - (rawX + floatRect.width); 9375 } 9376 if (currentSide === "top") { 9377 y2 = offsetDimensions.height - (rawY + floatRect.height); 9378 } 9379 const sideX = currentSide === "left" ? "right" : DEFAULT_SIDES.sideX; 9380 const sideY = currentSide === "top" ? "bottom" : DEFAULT_SIDES.sideY; 9381 return { 9382 x: x2, 9383 y: y2, 9384 data: { 9385 sideX, 9386 sideY 9387 } 9388 }; 9389 } 9390 }; 9391 9392 // node_modules/@base-ui/react/utils/useAnchorPositioning.mjs 9393 function getLogicalSide(sideParam, renderedSide, isRtl) { 9394 const isLogicalSideParam = sideParam === "inline-start" || sideParam === "inline-end"; 9395 const logicalRight = isRtl ? "inline-start" : "inline-end"; 9396 const logicalLeft = isRtl ? "inline-end" : "inline-start"; 9397 return { 9398 top: "top", 9399 right: isLogicalSideParam ? logicalRight : "right", 9400 bottom: "bottom", 9401 left: isLogicalSideParam ? logicalLeft : "left" 9402 }[renderedSide]; 9403 } 9404 function getOffsetData(state, sideParam, isRtl) { 9405 const { 9406 rects, 9407 placement 9408 } = state; 9409 const data = { 9410 side: getLogicalSide(sideParam, getSide(placement), isRtl), 9411 align: getAlignment(placement) || "center", 9412 anchor: { 9413 width: rects.reference.width, 9414 height: rects.reference.height 9415 }, 9416 positioner: { 9417 width: rects.floating.width, 9418 height: rects.floating.height 9419 } 9420 }; 9421 return data; 9422 } 9423 function useAnchorPositioning(params) { 9424 const { 9425 // Public parameters 9426 anchor, 9427 positionMethod = "absolute", 9428 side: sideParam = "bottom", 9429 sideOffset = 0, 9430 align = "center", 9431 alignOffset = 0, 9432 collisionBoundary, 9433 collisionPadding: collisionPaddingParam = 5, 9434 sticky = false, 9435 arrowPadding = 5, 9436 disableAnchorTracking = false, 9437 inline: inlineMiddleware, 9438 // Private parameters 9439 keepMounted = false, 9440 floatingRootContext, 9441 mounted, 9442 collisionAvoidance, 9443 shiftCrossAxis = false, 9444 nodeId, 9445 adaptiveOrigin: adaptiveOrigin2, 9446 lazyFlip = false, 9447 externalTree 9448 } = params; 9449 const [mountSide, setMountSide] = React41.useState(null); 9450 if (!mounted && mountSide !== null) { 9451 setMountSide(null); 9452 } 9453 const collisionAvoidanceSide = collisionAvoidance.side || "flip"; 9454 const collisionAvoidanceAlign = collisionAvoidance.align || "flip"; 9455 const collisionAvoidanceFallbackAxisSide = collisionAvoidance.fallbackAxisSide || "end"; 9456 const anchorFn = typeof anchor === "function" ? anchor : void 0; 9457 const anchorFnCallback = useStableCallback(anchorFn); 9458 const anchorDep = anchorFn ? anchorFnCallback : anchor; 9459 const anchorValueRef = useValueAsRef(anchor); 9460 const mountedRef = useValueAsRef(mounted); 9461 const direction = useDirection(); 9462 const isRtl = direction === "rtl"; 9463 const side = mountSide || { 9464 top: "top", 9465 right: "right", 9466 bottom: "bottom", 9467 left: "left", 9468 "inline-end": isRtl ? "left" : "right", 9469 "inline-start": isRtl ? "right" : "left" 9470 }[sideParam]; 9471 const placement = align === "center" ? side : `$side}-$align}`; 9472 let collisionPadding = collisionPaddingParam; 9473 const bias = 1; 9474 const biasTop = sideParam === "bottom" ? bias : 0; 9475 const biasBottom = sideParam === "top" ? bias : 0; 9476 const biasLeft = sideParam === "right" ? bias : 0; 9477 const biasRight = sideParam === "left" ? bias : 0; 9478 if (typeof collisionPadding === "number") { 9479 collisionPadding = { 9480 top: collisionPadding + biasTop, 9481 right: collisionPadding + biasRight, 9482 bottom: collisionPadding + biasBottom, 9483 left: collisionPadding + biasLeft 9484 }; 9485 } else if (collisionPadding) { 9486 collisionPadding = { 9487 top: (collisionPadding.top || 0) + biasTop, 9488 right: (collisionPadding.right || 0) + biasRight, 9489 bottom: (collisionPadding.bottom || 0) + biasBottom, 9490 left: (collisionPadding.left || 0) + biasLeft 9491 }; 9492 } 9493 const commonCollisionProps = { 9494 boundary: collisionBoundary === "clipping-ancestors" ? "clippingAncestors" : collisionBoundary, 9495 padding: collisionPadding 9496 }; 9497 const arrowRef = React41.useRef(null); 9498 const sideOffsetRef = useValueAsRef(sideOffset); 9499 const alignOffsetRef = useValueAsRef(alignOffset); 9500 const sideOffsetDep = typeof sideOffset !== "function" ? sideOffset : 0; 9501 const alignOffsetDep = typeof alignOffset !== "function" ? alignOffset : 0; 9502 const middleware = []; 9503 if (inlineMiddleware) { 9504 middleware.push(inlineMiddleware); 9505 } 9506 middleware.push(offset3((state) => { 9507 const data = getOffsetData(state, sideParam, isRtl); 9508 const sideAxis = typeof sideOffsetRef.current === "function" ? sideOffsetRef.current(data) : sideOffsetRef.current; 9509 const alignAxis = typeof alignOffsetRef.current === "function" ? alignOffsetRef.current(data) : alignOffsetRef.current; 9510 return { 9511 mainAxis: sideAxis, 9512 crossAxis: alignAxis, 9513 alignmentAxis: alignAxis 9514 }; 9515 }, [sideOffsetDep, alignOffsetDep, isRtl, sideParam])); 9516 const shiftDisabled = collisionAvoidanceAlign === "none" && collisionAvoidanceSide !== "shift"; 9517 const crossAxisShiftEnabled = !shiftDisabled && (sticky || shiftCrossAxis || collisionAvoidanceSide === "shift"); 9518 const flipMiddleware = collisionAvoidanceSide === "none" ? null : flip3({ 9519 ...commonCollisionProps, 9520 // Ensure the popup flips if it's been limited by its --available-height and it resizes. 9521 // Since the size() padding is smaller than the flip() padding, flip() will take precedence. 9522 padding: { 9523 top: collisionPadding.top + bias, 9524 right: collisionPadding.right + bias, 9525 bottom: collisionPadding.bottom + bias, 9526 left: collisionPadding.left + bias 9527 }, 9528 mainAxis: !shiftCrossAxis && collisionAvoidanceSide === "flip", 9529 crossAxis: collisionAvoidanceAlign === "flip" ? "alignment" : false, 9530 fallbackAxisSideDirection: collisionAvoidanceFallbackAxisSide 9531 }); 9532 const shiftMiddleware = shiftDisabled ? null : shift3((data) => { 9533 const html = ownerDocument(data.elements.floating).documentElement; 9534 return { 9535 ...commonCollisionProps, 9536 // Use the Layout Viewport to avoid shifting around when pinch-zooming 9537 // for context menus. 9538 rootBoundary: shiftCrossAxis ? { 9539 x: 0, 9540 y: 0, 9541 width: html.clientWidth, 9542 height: html.clientHeight 9543 } : void 0, 9544 mainAxis: collisionAvoidanceAlign !== "none", 9545 crossAxis: crossAxisShiftEnabled, 9546 limiter: sticky || shiftCrossAxis ? void 0 : limitShift3((limitData) => { 9547 if (!arrowRef.current) { 9548 return {}; 9549 } 9550 const { 9551 width, 9552 height 9553 } = arrowRef.current.getBoundingClientRect(); 9554 const sideAxis = getSideAxis(getSide(limitData.placement)); 9555 const arrowSize = sideAxis === "y" ? width : height; 9556 const offsetAmount = sideAxis === "y" ? collisionPadding.left + collisionPadding.right : collisionPadding.top + collisionPadding.bottom; 9557 return { 9558 offset: arrowSize / 2 + offsetAmount / 2 9559 }; 9560 }) 9561 }; 9562 }, [commonCollisionProps, sticky, shiftCrossAxis, collisionPadding, collisionAvoidanceAlign]); 9563 if (collisionAvoidanceSide === "shift" || collisionAvoidanceAlign === "shift" || align === "center") { 9564 middleware.push(shiftMiddleware, flipMiddleware); 9565 } else { 9566 middleware.push(flipMiddleware, shiftMiddleware); 9567 } 9568 middleware.push(size3({ 9569 ...commonCollisionProps, 9570 apply({ 9571 elements: { 9572 floating 9573 }, 9574 availableWidth, 9575 availableHeight, 9576 rects 9577 }) { 9578 if (!mountedRef.current) { 9579 return; 9580 } 9581 const floatingStyle = floating.style; 9582 floatingStyle.setProperty("--available-width", `$availableWidth}px`); 9583 floatingStyle.setProperty("--available-height", `$availableHeight}px`); 9584 const dpr = getWindow(floating).devicePixelRatio || 1; 9585 const { 9586 x: x3, 9587 y: y3, 9588 width, 9589 height 9590 } = rects.reference; 9591 const anchorWidth = (Math.round((x3 + width) * dpr) - Math.round(x3 * dpr)) / dpr; 9592 const anchorHeight = (Math.round((y3 + height) * dpr) - Math.round(y3 * dpr)) / dpr; 9593 floatingStyle.setProperty("--anchor-width", `$anchorWidth}px`); 9594 floatingStyle.setProperty("--anchor-height", `$anchorHeight}px`); 9595 } 9596 }), arrow4((state) => ({ 9597 // `transform-origin` calculations rely on an element existing. If the arrow hasn't been set, 9598 // we'll create a fake element. 9599 element: arrowRef.current || ownerDocument(state.elements.floating).createElement("div"), 9600 padding: arrowPadding, 9601 offsetParent: "floating" 9602 }), [arrowPadding]), { 9603 name: "transformOrigin", 9604 fn(state) { 9605 const { 9606 elements: elements2, 9607 middlewareData: middlewareData2, 9608 placement: renderedPlacement2, 9609 rects, 9610 y: y3 9611 } = state; 9612 const currentRenderedSide = getSide(renderedPlacement2); 9613 const currentRenderedAxis = getSideAxis(currentRenderedSide); 9614 const arrowEl = arrowRef.current; 9615 const arrowX = middlewareData2.arrow?.x || 0; 9616 const arrowY = middlewareData2.arrow?.y || 0; 9617 const arrowWidth = arrowEl?.clientWidth || 0; 9618 const arrowHeight = arrowEl?.clientHeight || 0; 9619 const transformX = arrowX + arrowWidth / 2; 9620 const transformY = arrowY + arrowHeight / 2; 9621 const shiftY = Math.abs(middlewareData2.shift?.y || 0); 9622 const halfAnchorHeight = rects.reference.height / 2; 9623 const sideOffsetValue = typeof sideOffset === "function" ? sideOffset(getOffsetData(state, sideParam, isRtl)) : sideOffset; 9624 const isOverlappingAnchor = shiftY > sideOffsetValue; 9625 const adjacentTransformOrigin = { 9626 top: `$transformX}px calc(100% + $sideOffsetValue}px)`, 9627 bottom: `$transformX}px ${-sideOffsetValue}px`, 9628 left: `calc(100% + $sideOffsetValue}px) $transformY}px`, 9629 right: `${-sideOffsetValue}px $transformY}px` 9630 }[currentRenderedSide]; 9631 const overlapTransformOrigin = `$transformX}px $rects.reference.y + halfAnchorHeight - y3}px`; 9632 elements2.floating.style.setProperty("--transform-origin", crossAxisShiftEnabled && currentRenderedAxis === "y" && isOverlappingAnchor ? overlapTransformOrigin : adjacentTransformOrigin); 9633 return {}; 9634 } 9635 }, hide4, adaptiveOrigin2); 9636 useIsoLayoutEffect(() => { 9637 if (!mounted && floatingRootContext) { 9638 floatingRootContext.update({ 9639 referenceElement: null, 9640 floatingElement: null, 9641 domReferenceElement: null, 9642 positionReference: null 9643 }); 9644 } 9645 }, [mounted, floatingRootContext]); 9646 const autoUpdateOptions = React41.useMemo(() => ({ 9647 elementResize: !disableAnchorTracking && typeof ResizeObserver !== "undefined", 9648 layoutShift: !disableAnchorTracking && typeof IntersectionObserver !== "undefined" 9649 }), [disableAnchorTracking]); 9650 const { 9651 refs, 9652 elements, 9653 x: x2, 9654 y: y2, 9655 middlewareData, 9656 update: update2, 9657 placement: renderedPlacement, 9658 context, 9659 isPositioned, 9660 floatingStyles: originalFloatingStyles 9661 } = useFloating2({ 9662 rootContext: floatingRootContext, 9663 open: keepMounted ? mounted : void 0, 9664 placement, 9665 middleware, 9666 strategy: positionMethod, 9667 whileElementsMounted: keepMounted ? void 0 : (...args) => autoUpdate(...args, autoUpdateOptions), 9668 nodeId, 9669 externalTree 9670 }); 9671 const { 9672 sideX, 9673 sideY 9674 } = middlewareData.adaptiveOrigin || DEFAULT_SIDES; 9675 const resolvedPosition = isPositioned ? positionMethod : "fixed"; 9676 const floatingStyles = React41.useMemo(() => { 9677 const base = adaptiveOrigin2 ? { 9678 position: resolvedPosition, 9679 [sideX]: x2, 9680 [sideY]: y2 9681 } : { 9682 position: resolvedPosition, 9683 ...originalFloatingStyles 9684 }; 9685 if (!isPositioned) { 9686 base.opacity = 0; 9687 } 9688 return base; 9689 }, [adaptiveOrigin2, resolvedPosition, sideX, x2, sideY, y2, originalFloatingStyles, isPositioned]); 9690 const registeredPositionReferenceRef = React41.useRef(null); 9691 useIsoLayoutEffect(() => { 9692 if (!mounted) { 9693 return; 9694 } 9695 const anchorValue = anchorValueRef.current; 9696 const resolvedAnchor = typeof anchorValue === "function" ? anchorValue() : anchorValue; 9697 const unwrappedElement = (isRef(resolvedAnchor) ? resolvedAnchor.current : resolvedAnchor) || null; 9698 const finalAnchor = unwrappedElement || null; 9699 if (finalAnchor !== registeredPositionReferenceRef.current) { 9700 refs.setPositionReference(finalAnchor); 9701 registeredPositionReferenceRef.current = finalAnchor; 9702 } 9703 }, [mounted, refs, anchorDep, anchorValueRef]); 9704 React41.useEffect(() => { 9705 if (!mounted) { 9706 return; 9707 } 9708 const anchorValue = anchorValueRef.current; 9709 if (typeof anchorValue === "function") { 9710 return; 9711 } 9712 if (isRef(anchorValue) && anchorValue.current !== registeredPositionReferenceRef.current) { 9713 refs.setPositionReference(anchorValue.current); 9714 registeredPositionReferenceRef.current = anchorValue.current; 9715 } 9716 }, [mounted, refs, anchorDep, anchorValueRef]); 9717 React41.useEffect(() => { 9718 if (keepMounted && mounted && elements.reference && elements.floating) { 9719 return autoUpdate(elements.reference, elements.floating, update2, autoUpdateOptions); 9720 } 9721 return void 0; 9722 }, [keepMounted, mounted, elements, update2, autoUpdateOptions]); 9723 const renderedSide = getSide(renderedPlacement); 9724 const logicalRenderedSide = getLogicalSide(sideParam, renderedSide, isRtl); 9725 const renderedAlign = getAlignment(renderedPlacement) || "center"; 9726 const anchorHidden = Boolean(middlewareData.hide?.referenceHidden); 9727 useIsoLayoutEffect(() => { 9728 if (lazyFlip && mounted && isPositioned) { 9729 setMountSide(renderedSide); 9730 } 9731 }, [lazyFlip, mounted, isPositioned, renderedSide]); 9732 const arrowStyles = React41.useMemo(() => ({ 9733 position: "absolute", 9734 top: middlewareData.arrow?.y, 9735 left: middlewareData.arrow?.x 9736 }), [middlewareData.arrow]); 9737 const arrowUncentered = middlewareData.arrow?.centerOffset !== 0; 9738 return React41.useMemo(() => ({ 9739 positionerStyles: floatingStyles, 9740 arrowStyles, 9741 arrowRef, 9742 arrowUncentered, 9743 side: logicalRenderedSide, 9744 align: renderedAlign, 9745 physicalSide: renderedSide, 9746 anchorHidden, 9747 refs, 9748 context, 9749 isPositioned, 9750 update: update2 9751 }), [floatingStyles, arrowStyles, arrowRef, arrowUncentered, logicalRenderedSide, renderedAlign, renderedSide, anchorHidden, refs, context, isPositioned, update2]); 9752 } 9753 function isRef(param) { 9754 return param != null && "current" in param; 9755 } 9756 9757 // node_modules/@base-ui/react/utils/getDisabledMountTransitionStyles.mjs 9758 function getDisabledMountTransitionStyles(transitionStatus) { 9759 return transitionStatus === "starting" ? DISABLED_TRANSITIONS_STYLE : EMPTY_OBJECT; 9760 } 9761 9762 // node_modules/@base-ui/react/utils/usePositioner.mjs 9763 function usePositioner(componentProps, state, { 9764 styles, 9765 transitionStatus, 9766 props, 9767 refs, 9768 hidden, 9769 inert = false 9770 }) { 9771 const style = { 9772 ...styles 9773 }; 9774 if (inert) { 9775 style.pointerEvents = "none"; 9776 } 9777 return useRenderElement("div", componentProps, { 9778 state, 9779 ref: refs, 9780 props: [{ 9781 role: "presentation", 9782 hidden, 9783 style 9784 }, getDisabledMountTransitionStyles(transitionStatus), props], 9785 stateAttributesMapping: popupStateMapping 9786 }); 9787 } 9788 9789 // node_modules/@base-ui/react/utils/useAnchoredPopupScrollLock.mjs 9790 var React42 = __toESM(require_react(), 1); 9791 var VIEWPORT_WIDTH_TOLERANCE_PX = 20; 9792 function useAnchoredPopupScrollLock(enabled, touchOpen, positionerElement, referenceElement) { 9793 const [touchOpenShouldLockScroll, setTouchOpenShouldLockScroll] = React42.useState(false); 9794 useIsoLayoutEffect(() => { 9795 if (!enabled || !touchOpen || positionerElement == null) { 9796 setTouchOpenShouldLockScroll(false); 9797 return; 9798 } 9799 const viewportWidth = ownerDocument(positionerElement).documentElement.clientWidth; 9800 const popupWidth = positionerElement.offsetWidth; 9801 setTouchOpenShouldLockScroll(viewportWidth > 0 && popupWidth > 0 && popupWidth >= viewportWidth - VIEWPORT_WIDTH_TOLERANCE_PX); 9802 }, [enabled, touchOpen, positionerElement]); 9803 useScrollLock(enabled && (!touchOpen || touchOpenShouldLockScroll), referenceElement); 9804 } 9805 9806 // node_modules/@base-ui/react/button/Button.mjs 9807 var React43 = __toESM(require_react(), 1); 9808 var Button = /* @__PURE__ */ React43.forwardRef(function Button2(componentProps, forwardedRef) { 9809 const { 9810 render: render4, 9811 className, 9812 disabled: disabled2 = false, 9813 focusableWhenDisabled = false, 9814 nativeButton = true, 9815 style, 9816 ...elementProps 9817 } = componentProps; 9818 const { 9819 getButtonProps, 9820 buttonRef 9821 } = useButton({ 9822 disabled: disabled2, 9823 focusableWhenDisabled, 9824 native: nativeButton 9825 }); 9826 const state = { 9827 disabled: disabled2 9828 }; 9829 return useRenderElement("button", componentProps, { 9830 state, 9831 ref: [forwardedRef, buttonRef], 9832 props: [elementProps, getButtonProps] 9833 }); 9834 }); 9835 if (true) Button.displayName = "Button"; 9836 9837 // node_modules/@base-ui/react/collapsible/index.parts.mjs 9838 var index_parts_exports = {}; 9839 __export(index_parts_exports, { 9840 Panel: () => CollapsiblePanel, 9841 Root: () => CollapsibleRoot, 9842 Trigger: () => CollapsibleTrigger 9843 }); 9844 9845 // node_modules/@base-ui/react/collapsible/root/CollapsibleRoot.mjs 9846 var React44 = __toESM(require_react(), 1); 9847 9848 // node_modules/@base-ui/react/collapsible/root/stateAttributesMapping.mjs 9849 var collapsibleStateAttributesMapping = { 9850 ...collapsibleOpenStateMapping, 9851 ...transitionStatusMapping 9852 }; 9853 9854 // node_modules/@base-ui/react/collapsible/root/CollapsibleRoot.mjs 9855 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1); 9856 var CollapsibleRoot = /* @__PURE__ */ React44.forwardRef(function CollapsibleRoot2(componentProps, forwardedRef) { 9857 const { 9858 render: render4, 9859 className, 9860 defaultOpen = false, 9861 disabled: disabled2 = false, 9862 onOpenChange: onOpenChangeProp, 9863 open, 9864 style, 9865 ...elementProps 9866 } = componentProps; 9867 const onOpenChange = useStableCallback(onOpenChangeProp); 9868 const collapsible = useCollapsibleRoot({ 9869 open, 9870 defaultOpen, 9871 onOpenChange, 9872 disabled: disabled2 9873 }); 9874 const state = React44.useMemo(() => ({ 9875 open: collapsible.open, 9876 disabled: collapsible.disabled, 9877 transitionStatus: collapsible.transitionStatus 9878 }), [collapsible.open, collapsible.disabled, collapsible.transitionStatus]); 9879 const contextValue = React44.useMemo(() => ({ 9880 ...collapsible, 9881 onOpenChange, 9882 state 9883 }), [collapsible, onOpenChange, state]); 9884 const element = useRenderElement("div", componentProps, { 9885 state, 9886 ref: forwardedRef, 9887 props: elementProps, 9888 stateAttributesMapping: collapsibleStateAttributesMapping 9889 }); 9890 return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CollapsibleRootContext.Provider, { 9891 value: contextValue, 9892 children: element 9893 }); 9894 }); 9895 if (true) CollapsibleRoot.displayName = "CollapsibleRoot"; 9896 9897 // node_modules/@base-ui/react/collapsible/trigger/CollapsibleTrigger.mjs 9898 var React45 = __toESM(require_react(), 1); 9899 var stateAttributesMapping = { 9900 ...triggerOpenStateMapping, 9901 ...transitionStatusMapping 9902 }; 9903 var CollapsibleTrigger = /* @__PURE__ */ React45.forwardRef(function CollapsibleTrigger2(componentProps, forwardedRef) { 9904 const { 9905 panelId, 9906 open, 9907 handleTrigger, 9908 state, 9909 disabled: contextDisabled 9910 } = useCollapsibleRootContext(); 9911 const { 9912 className, 9913 disabled: disabled2 = contextDisabled, 9914 render: render4, 9915 nativeButton = true, 9916 style, 9917 ...elementProps 9918 } = componentProps; 9919 const { 9920 getButtonProps, 9921 buttonRef 9922 } = useButton({ 9923 disabled: disabled2, 9924 focusableWhenDisabled: true, 9925 native: nativeButton 9926 }); 9927 const element = useRenderElement("button", componentProps, { 9928 state, 9929 ref: [forwardedRef, buttonRef], 9930 props: [{ 9931 "aria-controls": open ? panelId : void 0, 9932 "aria-expanded": open, 9933 onClick: handleTrigger 9934 }, elementProps, getButtonProps], 9935 stateAttributesMapping 9936 }); 9937 return element; 9938 }); 9939 if (true) CollapsibleTrigger.displayName = "CollapsibleTrigger"; 9940 9941 // node_modules/@base-ui/react/collapsible/panel/CollapsiblePanel.mjs 9942 var React46 = __toESM(require_react(), 1); 9943 9944 // node_modules/@base-ui/react/collapsible/panel/CollapsiblePanelCssVars.mjs 9945 var CollapsiblePanelCssVars = /* @__PURE__ */ (function(CollapsiblePanelCssVars2) { 9946 CollapsiblePanelCssVars2["collapsiblePanelHeight"] = "--collapsible-panel-height"; 9947 CollapsiblePanelCssVars2["collapsiblePanelWidth"] = "--collapsible-panel-width"; 9948 return CollapsiblePanelCssVars2; 9949 })({}); 9950 9951 // node_modules/@base-ui/react/collapsible/panel/CollapsiblePanel.mjs 9952 var CollapsiblePanel = /* @__PURE__ */ React46.forwardRef(function CollapsiblePanel2(componentProps, forwardedRef) { 9953 const { 9954 className, 9955 hiddenUntilFound: hiddenUntilFoundProp, 9956 keepMounted: keepMountedProp, 9957 render: render4, 9958 id: idProp, 9959 style, 9960 ...elementProps 9961 } = componentProps; 9962 if (true) { 9963 useIsoLayoutEffect(() => { 9964 if (hiddenUntilFoundProp && keepMountedProp === false) { 9965 warn("The `keepMounted={false}` prop on `Collapsible.Panel` is ignored when `hiddenUntilFound` is enabled, since the panel must remain mounted while closed."); 9966 } 9967 }, [hiddenUntilFoundProp, keepMountedProp]); 9968 } 9969 const { 9970 mounted, 9971 onOpenChange, 9972 open, 9973 panelId, 9974 setMounted, 9975 setPanelIdState, 9976 setOpen, 9977 state, 9978 transitionStatus 9979 } = useCollapsibleRootContext(); 9980 const hiddenUntilFound = hiddenUntilFoundProp ?? false; 9981 const keepMounted = keepMountedProp ?? false; 9982 useIsoLayoutEffect(() => { 9983 if (idProp) { 9984 setPanelIdState(idProp); 9985 return () => { 9986 setPanelIdState(void 0); 9987 }; 9988 } 9989 return void 0; 9990 }, [idProp, setPanelIdState]); 9991 const { 9992 height, 9993 props, 9994 ref, 9995 shouldPreventOpenAnimation, 9996 shouldRender, 9997 transitionStatus: panelTransitionStatus, 9998 width 9999 } = useCollapsiblePanel({ 10000 externalRef: forwardedRef, 10001 hiddenUntilFound, 10002 id: panelId, 10003 keepMounted, 10004 mounted, 10005 onOpenChange, 10006 open, 10007 setMounted, 10008 setOpen, 10009 transitionStatus 10010 }); 10011 const panelState = { 10012 ...state, 10013 transitionStatus: panelTransitionStatus 10014 }; 10015 const resolvedStyle = resolveStyle(style, panelState); 10016 const element = useRenderElement("div", { 10017 ...componentProps, 10018 style: void 0 10019 }, { 10020 state: panelState, 10021 ref, 10022 props: [ 10023 props, 10024 { 10025 style: { 10026 [CollapsiblePanelCssVars.collapsiblePanelHeight]: height === void 0 ? "auto" : `$height}px`, 10027 [CollapsiblePanelCssVars.collapsiblePanelWidth]: width === void 0 ? "auto" : `$width}px` 10028 } 10029 }, 10030 elementProps, 10031 resolvedStyle ? { 10032 style: resolvedStyle 10033 } : void 0, 10034 // Resolve the public `style` prop so temporary `animationName: 'none'` 10035 // can still win after user's inline styles have been merged. 10036 shouldPreventOpenAnimation ? { 10037 style: { 10038 animationName: "none" 10039 } 10040 } : void 0 10041 ], 10042 stateAttributesMapping: collapsibleStateAttributesMapping 10043 }); 10044 if (!shouldRender) { 10045 return null; 10046 } 10047 return element; 10048 }); 10049 if (true) CollapsiblePanel.displayName = "CollapsiblePanel"; 10050 10051 // node_modules/@base-ui/react/toolbar/root/ToolbarRootContext.mjs 10052 var React47 = __toESM(require_react(), 1); 10053 var ToolbarRootContext = /* @__PURE__ */ React47.createContext(void 0); 10054 if (true) ToolbarRootContext.displayName = "ToolbarRootContext"; 10055 function useToolbarRootContext(optional) { 10056 const context = React47.useContext(ToolbarRootContext); 10057 if (context === void 0 && !optional) { 10058 throw new Error(true ? "Base UI: ToolbarRootContext is missing. Toolbar parts must be placed within <Toolbar.Root>." : formatErrorMessage_default(69)); 10059 } 10060 return context; 10061 } 10062 10063 // node_modules/@base-ui/react/utils/popups/useTriggerFocusGuards.mjs 10064 var React48 = __toESM(require_react(), 1); 10065 var ReactDOM6 = __toESM(require_react_dom(), 1); 10066 function useTriggerFocusGuards(store, triggerElementRef) { 10067 const preFocusGuardRef = React48.useRef(null); 10068 function handlePreFocusGuardFocus(event) { 10069 ReactDOM6.flushSync(() => { 10070 store.setOpen(false, createChangeEventDetails(reason_parts_exports.focusOut, event.nativeEvent, event.currentTarget)); 10071 }); 10072 const previousTabbable = getTabbableBeforeElement(preFocusGuardRef.current); 10073 previousTabbable?.focus(); 10074 } 10075 function handleFocusTargetFocus(event) { 10076 const positionerElement = store.select("positionerElement"); 10077 if (positionerElement && isOutsideEvent(event, positionerElement)) { 10078 store.context.beforeContentFocusGuardRef.current?.focus(); 10079 } else { 10080 ReactDOM6.flushSync(() => { 10081 store.setOpen(false, createChangeEventDetails(reason_parts_exports.focusOut, event.nativeEvent, event.currentTarget)); 10082 }); 10083 let nextTabbable = getTabbableAfterElement(store.context.triggerFocusTargetRef.current || triggerElementRef.current); 10084 while (nextTabbable !== null && contains(positionerElement, nextTabbable)) { 10085 const prevTabbable = nextTabbable; 10086 nextTabbable = getNextTabbable(nextTabbable); 10087 if (nextTabbable === prevTabbable) { 10088 break; 10089 } 10090 } 10091 nextTabbable?.focus(); 10092 } 10093 } 10094 return { 10095 preFocusGuardRef, 10096 handlePreFocusGuardFocus, 10097 handleFocusTargetFocus 10098 }; 10099 } 10100 10101 // node_modules/@base-ui/react/utils/usePopupViewport.mjs 10102 var React51 = __toESM(require_react(), 1); 10103 var ReactDOM7 = __toESM(require_react_dom(), 1); 10104 10105 // node_modules/@base-ui/utils/usePreviousValue.mjs 10106 var React49 = __toESM(require_react(), 1); 10107 function usePreviousValue(value) { 10108 const [state, setState] = React49.useState({ 10109 current: value, 10110 previous: null 10111 }); 10112 if (value !== state.current) { 10113 setState({ 10114 current: value, 10115 previous: state.current 10116 }); 10117 } 10118 return state.previous; 10119 } 10120 10121 // node_modules/@base-ui/react/utils/usePopupAutoResize.mjs 10122 var React50 = __toESM(require_react(), 1); 10123 10124 // node_modules/@base-ui/react/utils/getCssDimensions.mjs 10125 function getCssDimensions2(element) { 10126 const css = getComputedStyle2(element); 10127 let width = parseFloat(css.width) || 0; 10128 let height = parseFloat(css.height) || 0; 10129 const hasOffset = isHTMLElement(element); 10130 const offsetWidth = hasOffset ? element.offsetWidth : width; 10131 const offsetHeight = hasOffset ? element.offsetHeight : height; 10132 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight; 10133 if (shouldFallback) { 10134 width = offsetWidth; 10135 height = offsetHeight; 10136 } 10137 return { 10138 width, 10139 height 10140 }; 10141 } 10142 10143 // node_modules/@base-ui/react/utils/usePopupAutoResize.mjs 10144 function usePopupAutoResize(parameters) { 10145 const { 10146 popupElement, 10147 positionerElement, 10148 content, 10149 mounted, 10150 onMeasureLayout: onMeasureLayoutParam, 10151 onMeasureLayoutComplete: onMeasureLayoutCompleteParam, 10152 side, 10153 direction 10154 } = parameters; 10155 const runOnceAnimationsFinish = useAnimationsFinished(popupElement, true, false); 10156 const animationFrame = useAnimationFrame(); 10157 const committedDimensionsRef = React50.useRef(null); 10158 const isInitialRenderRef = React50.useRef(true); 10159 const restoreAnchoringStylesRef = React50.useRef(NOOP); 10160 const onMeasureLayout = useStableCallback(onMeasureLayoutParam); 10161 const onMeasureLayoutComplete = useStableCallback(onMeasureLayoutCompleteParam); 10162 const anchoringStyles = React50.useMemo(() => { 10163 let isOriginSide = side === "top"; 10164 let isPhysicalLeft = side === "left"; 10165 if (direction === "rtl") { 10166 isOriginSide = isOriginSide || side === "inline-end"; 10167 isPhysicalLeft = isPhysicalLeft || side === "inline-end"; 10168 } else { 10169 isOriginSide = isOriginSide || side === "inline-start"; 10170 isPhysicalLeft = isPhysicalLeft || side === "inline-start"; 10171 } 10172 return isOriginSide ? { 10173 position: "absolute", 10174 [side === "top" ? "bottom" : "top"]: "0", 10175 [isPhysicalLeft ? "right" : "left"]: "0" 10176 } : EMPTY_OBJECT; 10177 }, [side, direction]); 10178 useIsoLayoutEffect(() => { 10179 if (!mounted) { 10180 restoreAnchoringStylesRef.current = NOOP; 10181 isInitialRenderRef.current = true; 10182 committedDimensionsRef.current = null; 10183 return void 0; 10184 } 10185 if (!popupElement || !positionerElement) { 10186 return void 0; 10187 } 10188 restoreAnchoringStylesRef.current = applyElementStyles(popupElement, anchoringStyles); 10189 setPopupCssSize(popupElement, "auto"); 10190 const restorePopupPosition = overrideElementStyle(popupElement, "position", "static"); 10191 const restorePopupTransform = overrideElementStyle(popupElement, "transform", "none"); 10192 const restorePopupScale = overrideElementStyle(popupElement, "scale", "1"); 10193 const restorePositionerAvailableSize = applyElementStyles(positionerElement, { 10194 "--available-width": "max-content", 10195 "--available-height": "max-content" 10196 }); 10197 function restoreMeasurementOverrides() { 10198 restorePopupPosition(); 10199 restorePopupTransform(); 10200 restorePositionerAvailableSize(); 10201 } 10202 function restoreMeasurementOverridesIncludingScale() { 10203 restoreMeasurementOverrides(); 10204 restorePopupScale(); 10205 } 10206 onMeasureLayout?.(); 10207 if (isInitialRenderRef.current || committedDimensionsRef.current === null) { 10208 setPositionerCssSize(positionerElement, "max-content"); 10209 const dimensions = getCssDimensions2(popupElement); 10210 committedDimensionsRef.current = dimensions; 10211 setPositionerCssSize(positionerElement, dimensions); 10212 restoreMeasurementOverridesIncludingScale(); 10213 onMeasureLayoutComplete?.(null, dimensions); 10214 isInitialRenderRef.current = false; 10215 return () => { 10216 restoreAnchoringStylesRef.current(); 10217 restoreAnchoringStylesRef.current = NOOP; 10218 }; 10219 } 10220 setPositionerCssSize(positionerElement, "max-content"); 10221 const previousDimensions = committedDimensionsRef.current; 10222 const newDimensions = getCssDimensions2(popupElement); 10223 committedDimensionsRef.current = newDimensions; 10224 setPopupCssSize(popupElement, previousDimensions); 10225 restoreMeasurementOverridesIncludingScale(); 10226 onMeasureLayoutComplete?.(previousDimensions, newDimensions); 10227 setPositionerCssSize(positionerElement, newDimensions); 10228 const abortController = new AbortController(); 10229 animationFrame.request(() => { 10230 setPopupCssSize(popupElement, newDimensions); 10231 runOnceAnimationsFinish(() => { 10232 popupElement.style.setProperty("--popup-width", "auto"); 10233 popupElement.style.setProperty("--popup-height", "auto"); 10234 }, abortController.signal); 10235 }); 10236 return () => { 10237 abortController.abort(); 10238 animationFrame.cancel(); 10239 restoreAnchoringStylesRef.current(); 10240 restoreAnchoringStylesRef.current = NOOP; 10241 }; 10242 }, [content, popupElement, positionerElement, runOnceAnimationsFinish, animationFrame, mounted, onMeasureLayout, onMeasureLayoutComplete, anchoringStyles]); 10243 } 10244 function overrideElementStyle(element, property, value) { 10245 const originalValue = element.style.getPropertyValue(property); 10246 element.style.setProperty(property, value); 10247 return () => { 10248 element.style.setProperty(property, originalValue); 10249 }; 10250 } 10251 function applyElementStyles(element, styles) { 10252 const restorers = []; 10253 for (const [key, value] of Object.entries(styles)) { 10254 restorers.push(overrideElementStyle(element, key, value)); 10255 } 10256 return restorers.length ? () => { 10257 restorers.forEach((restore) => restore()); 10258 } : NOOP; 10259 } 10260 function setPopupCssSize(popupElement, size4) { 10261 const width = size4 === "auto" ? "auto" : `$size4.width}px`; 10262 const height = size4 === "auto" ? "auto" : `$size4.height}px`; 10263 popupElement.style.setProperty("--popup-width", width); 10264 popupElement.style.setProperty("--popup-height", height); 10265 } 10266 function setPositionerCssSize(positionerElement, size4) { 10267 const width = size4 === "max-content" ? "max-content" : `$size4.width}px`; 10268 const height = size4 === "max-content" ? "max-content" : `$size4.height}px`; 10269 positionerElement.style.setProperty("--positioner-width", width); 10270 positionerElement.style.setProperty("--positioner-height", height); 10271 } 10272 10273 // node_modules/@base-ui/react/utils/usePopupViewport.mjs 10274 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1); 10275 function usePopupViewport(parameters) { 10276 const { 10277 store, 10278 side, 10279 cssVars, 10280 children 10281 } = parameters; 10282 const direction = useDirection(); 10283 const activeTrigger = store.useState("activeTriggerElement"); 10284 const activeTriggerId = store.useState("activeTriggerId"); 10285 const open = store.useState("open"); 10286 const payload = store.useState("payload"); 10287 const mounted = store.useState("mounted"); 10288 const popupElement = store.useState("popupElement"); 10289 const positionerElement = store.useState("positionerElement"); 10290 const previousActiveTrigger = usePreviousValue(open ? activeTrigger : null); 10291 const currentContentKey = usePopupContentKey(activeTriggerId, payload); 10292 const capturedNodeRef = React51.useRef(null); 10293 const [previousContentNode, setPreviousContentNode] = React51.useState(null); 10294 const [newTriggerOffset, setNewTriggerOffset] = React51.useState(null); 10295 const currentContainerRef = React51.useRef(null); 10296 const previousContainerRef = React51.useRef(null); 10297 const onAnimationsFinished = useAnimationsFinished(currentContainerRef, true, false); 10298 const cleanupFrame = useAnimationFrame(); 10299 const [previousContentDimensions, setPreviousContentDimensions] = React51.useState(null); 10300 const [showStartingStyleAttribute, setShowStartingStyleAttribute] = React51.useState(false); 10301 useIsoLayoutEffect(() => { 10302 store.set("hasViewport", true); 10303 return () => { 10304 store.set("hasViewport", false); 10305 }; 10306 }, [store]); 10307 const handleMeasureLayout = useStableCallback(() => { 10308 currentContainerRef.current?.style.setProperty("animation", "none"); 10309 currentContainerRef.current?.style.setProperty("transition", "none"); 10310 previousContainerRef.current?.style.setProperty("display", "none"); 10311 }); 10312 const handleMeasureLayoutComplete = useStableCallback((previousDimensions) => { 10313 currentContainerRef.current?.style.removeProperty("animation"); 10314 currentContainerRef.current?.style.removeProperty("transition"); 10315 previousContainerRef.current?.style.removeProperty("display"); 10316 if (previousDimensions) { 10317 setPreviousContentDimensions(previousDimensions); 10318 } 10319 }); 10320 const lastHandledTriggerRef = React51.useRef(null); 10321 useIsoLayoutEffect(() => { 10322 if (!open || !mounted) { 10323 lastHandledTriggerRef.current = null; 10324 } 10325 }, [open, mounted]); 10326 useIsoLayoutEffect(() => { 10327 if (activeTrigger && previousActiveTrigger && activeTrigger !== previousActiveTrigger && lastHandledTriggerRef.current !== activeTrigger && capturedNodeRef.current) { 10328 setPreviousContentNode(capturedNodeRef.current); 10329 setShowStartingStyleAttribute(true); 10330 const offset4 = calculateRelativePosition(previousActiveTrigger, activeTrigger); 10331 setNewTriggerOffset(offset4); 10332 cleanupFrame.request(() => { 10333 ReactDOM7.flushSync(() => { 10334 setShowStartingStyleAttribute(false); 10335 }); 10336 onAnimationsFinished(() => { 10337 setPreviousContentNode(null); 10338 setPreviousContentDimensions(null); 10339 capturedNodeRef.current = null; 10340 }); 10341 }); 10342 lastHandledTriggerRef.current = activeTrigger; 10343 } 10344 }, [activeTrigger, previousActiveTrigger, previousContentNode, onAnimationsFinished, cleanupFrame]); 10345 useIsoLayoutEffect(() => { 10346 const source = currentContainerRef.current; 10347 if (!source) { 10348 return; 10349 } 10350 const wrapper = ownerDocument(source).createElement("div"); 10351 for (const child of Array.from(source.childNodes)) { 10352 wrapper.appendChild(child.cloneNode(true)); 10353 } 10354 capturedNodeRef.current = wrapper; 10355 }); 10356 const isTransitioning = previousContentNode != null; 10357 let childrenToRender; 10358 if (!isTransitioning) { 10359 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { 10360 "data-current": true, 10361 ref: currentContainerRef, 10362 children 10363 }, currentContentKey); 10364 } else { 10365 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(React51.Fragment, { 10366 children: [/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { 10367 "data-previous": true, 10368 inert: inertValue(true), 10369 ref: previousContainerRef, 10370 style: { 10371 ...previousContentDimensions ? { 10372 [cssVars.popupWidth]: `$previousContentDimensions.width}px`, 10373 [cssVars.popupHeight]: `$previousContentDimensions.height}px` 10374 } : null, 10375 position: "absolute" 10376 }, 10377 "data-ending-style": showStartingStyleAttribute ? void 0 : "" 10378 }, "previous"), /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { 10379 "data-current": true, 10380 ref: currentContainerRef, 10381 "data-starting-style": showStartingStyleAttribute ? "" : void 0, 10382 children 10383 }, currentContentKey)] 10384 }); 10385 } 10386 useIsoLayoutEffect(() => { 10387 const container = previousContainerRef.current; 10388 if (!container || !previousContentNode) { 10389 return; 10390 } 10391 container.replaceChildren(...Array.from(previousContentNode.childNodes)); 10392 }, [previousContentNode]); 10393 usePopupAutoResize({ 10394 popupElement, 10395 positionerElement, 10396 mounted, 10397 content: payload, 10398 onMeasureLayout: handleMeasureLayout, 10399 onMeasureLayoutComplete: handleMeasureLayoutComplete, 10400 side, 10401 direction 10402 }); 10403 const state = { 10404 activationDirection: getActivationDirection(newTriggerOffset), 10405 transitioning: isTransitioning 10406 }; 10407 return { 10408 children: childrenToRender, 10409 state 10410 }; 10411 } 10412 function getActivationDirection(offset4) { 10413 if (!offset4) { 10414 return void 0; 10415 } 10416 return `$getValueWithTolerance(offset4.horizontal, 5, "right", "left")} $getValueWithTolerance(offset4.vertical, 5, "down", "up")}`; 10417 } 10418 function getValueWithTolerance(value, tolerance, positiveLabel, negativeLabel) { 10419 if (value > tolerance) { 10420 return positiveLabel; 10421 } 10422 if (value < -tolerance) { 10423 return negativeLabel; 10424 } 10425 return ""; 10426 } 10427 function calculateRelativePosition(from, to) { 10428 const fromRect = from.getBoundingClientRect(); 10429 const toRect = to.getBoundingClientRect(); 10430 const fromCenter = { 10431 x: fromRect.left + fromRect.width / 2, 10432 y: fromRect.top + fromRect.height / 2 10433 }; 10434 const toCenter = { 10435 x: toRect.left + toRect.width / 2, 10436 y: toRect.top + toRect.height / 2 10437 }; 10438 return { 10439 horizontal: toCenter.x - fromCenter.x, 10440 vertical: toCenter.y - fromCenter.y 10441 }; 10442 } 10443 function usePopupContentKey(activeTriggerId, payload) { 10444 const [contentKey, setContentKey] = React51.useState(0); 10445 const previousActiveTriggerIdRef = React51.useRef(activeTriggerId); 10446 const previousPayloadRef = React51.useRef(payload); 10447 const pendingPayloadUpdateRef = React51.useRef(false); 10448 useIsoLayoutEffect(() => { 10449 const previousActiveTriggerId = previousActiveTriggerIdRef.current; 10450 const previousPayload = previousPayloadRef.current; 10451 const triggerIdChanged = activeTriggerId !== previousActiveTriggerId; 10452 const payloadChanged = payload !== previousPayload; 10453 if (triggerIdChanged) { 10454 setContentKey((value) => value + 1); 10455 pendingPayloadUpdateRef.current = !payloadChanged; 10456 } else if (pendingPayloadUpdateRef.current && payloadChanged) { 10457 setContentKey((value) => value + 1); 10458 pendingPayloadUpdateRef.current = false; 10459 } 10460 previousActiveTriggerIdRef.current = activeTriggerId; 10461 previousPayloadRef.current = payload; 10462 }, [activeTriggerId, payload]); 10463 return `$activeTriggerId ?? "current"}-$contentKey}`; 10464 } 10465 10466 // node_modules/@base-ui/react/popover/index.parts.mjs 10467 var index_parts_exports2 = {}; 10468 __export(index_parts_exports2, { 10469 Arrow: () => PopoverArrow, 10470 Backdrop: () => PopoverBackdrop, 10471 Close: () => PopoverClose, 10472 Description: () => PopoverDescription, 10473 Handle: () => PopoverHandle, 10474 Popup: () => PopoverPopup, 10475 Portal: () => PopoverPortal, 10476 Positioner: () => PopoverPositioner, 10477 Root: () => PopoverRoot, 10478 Title: () => PopoverTitle, 10479 Trigger: () => PopoverTrigger, 10480 Viewport: () => PopoverViewport, 10481 createHandle: () => createPopoverHandle 10482 }); 10483 10484 // node_modules/@base-ui/react/popover/root/PopoverRoot.mjs 10485 var React54 = __toESM(require_react(), 1); 10486 10487 // node_modules/@base-ui/react/popover/root/PopoverRootContext.mjs 10488 var React52 = __toESM(require_react(), 1); 10489 var PopoverRootContext = /* @__PURE__ */ React52.createContext(void 0); 10490 if (true) PopoverRootContext.displayName = "PopoverRootContext"; 10491 function usePopoverRootContext(optional) { 10492 const context = React52.useContext(PopoverRootContext); 10493 if (context === void 0 && !optional) { 10494 throw new Error(true ? "Base UI: PopoverRootContext is missing. Popover parts must be placed within <Popover.Root>." : formatErrorMessage_default(47)); 10495 } 10496 return context; 10497 } 10498 10499 // node_modules/@base-ui/react/popover/store/PopoverStore.mjs 10500 var React53 = __toESM(require_react(), 1); 10501 var ReactDOM8 = __toESM(require_react_dom(), 1); 10502 function createInitialState() { 10503 return { 10504 ...createInitialPopupStoreState(), 10505 disabled: false, 10506 modal: false, 10507 focusManagerModal: false, 10508 instantType: void 0, 10509 openMethod: null, 10510 openChangeReason: null, 10511 titleElementId: void 0, 10512 descriptionElementId: void 0, 10513 stickIfOpen: true, 10514 nested: false, 10515 openOnHover: false, 10516 closeDelay: 0, 10517 hasViewport: false 10518 }; 10519 } 10520 var selectors2 = { 10521 ...popupStoreSelectors, 10522 disabled: createSelector((state) => state.disabled), 10523 instantType: createSelector((state) => state.instantType), 10524 openMethod: createSelector((state) => state.openMethod), 10525 openChangeReason: createSelector((state) => state.openChangeReason), 10526 modal: createSelector((state) => state.modal), 10527 focusManagerModal: createSelector((state) => state.focusManagerModal), 10528 stickIfOpen: createSelector((state) => state.stickIfOpen), 10529 titleElementId: createSelector((state) => state.titleElementId), 10530 descriptionElementId: createSelector((state) => state.descriptionElementId), 10531 openOnHover: createSelector((state) => state.openOnHover), 10532 closeDelay: createSelector((state) => state.closeDelay), 10533 hasViewport: createSelector((state) => state.hasViewport) 10534 }; 10535 var PopoverStore = class _PopoverStore extends ReactStore { 10536 constructor(initialState, floatingId, nested = false) { 10537 const initial2 = { 10538 ...createInitialState(), 10539 ...initialState 10540 }; 10541 const triggerElements = new PopupTriggerMap(); 10542 if (initial2.open && initialState?.mounted === void 0) { 10543 initial2.mounted = true; 10544 } 10545 initial2.floatingRootContext = createPopupFloatingRootContext(triggerElements, floatingId, nested); 10546 super(initial2, { 10547 popupRef: /* @__PURE__ */ React53.createRef(), 10548 backdropRef: /* @__PURE__ */ React53.createRef(), 10549 internalBackdropRef: /* @__PURE__ */ React53.createRef(), 10550 onOpenChange: void 0, 10551 onOpenChangeComplete: void 0, 10552 triggerFocusTargetRef: /* @__PURE__ */ React53.createRef(), 10553 beforeContentFocusGuardRef: /* @__PURE__ */ React53.createRef(), 10554 stickIfOpenTimeout: new Timeout(), 10555 triggerElements 10556 }, selectors2); 10557 } 10558 setOpen = (nextOpen, eventDetails) => { 10559 const isHover = eventDetails.reason === reason_parts_exports.triggerHover; 10560 const isKeyboardClick = eventDetails.reason === reason_parts_exports.triggerPress && eventDetails.event.detail === 0; 10561 const isDismissClose = !nextOpen && (eventDetails.reason === reason_parts_exports.escapeKey || eventDetails.reason == null); 10562 const shouldPreventUnmountOnClose = attachPreventUnmountOnClose(eventDetails); 10563 const activeTriggerId = this.select("activeTriggerId"); 10564 if (!nextOpen && eventDetails.reason === reason_parts_exports.closePress && eventDetails.trigger == null && activeTriggerId != null) { 10565 eventDetails.trigger = this.context.triggerElements.getById(activeTriggerId) ?? this.select("activeTriggerElement") ?? void 0; 10566 } 10567 this.context.onOpenChange?.(nextOpen, eventDetails); 10568 if (eventDetails.isCanceled) { 10569 return; 10570 } 10571 this.state.floatingRootContext.dispatchOpenChange(nextOpen, eventDetails); 10572 const changeState = () => { 10573 const updatedState = { 10574 open: nextOpen, 10575 openChangeReason: eventDetails.reason 10576 }; 10577 setPopupOpenState(updatedState, nextOpen, eventDetails.trigger, shouldPreventUnmountOnClose()); 10578 this.update(updatedState); 10579 }; 10580 if (isHover) { 10581 this.set("stickIfOpen", true); 10582 this.context.stickIfOpenTimeout.start(PATIENT_CLICK_THRESHOLD, () => { 10583 this.set("stickIfOpen", false); 10584 }); 10585 ReactDOM8.flushSync(changeState); 10586 } else { 10587 changeState(); 10588 } 10589 if (isKeyboardClick || isDismissClose) { 10590 this.set("instantType", isKeyboardClick ? "click" : "dismiss"); 10591 } else if (eventDetails.reason === reason_parts_exports.focusOut) { 10592 this.set("instantType", "focus"); 10593 } else { 10594 this.set("instantType", void 0); 10595 } 10596 }; 10597 static useStore(externalStore, initialState) { 10598 const { 10599 store, 10600 internalStore 10601 } = usePopupStore(externalStore, (floatingId, nested) => new _PopoverStore(initialState, floatingId, nested)); 10602 React53.useEffect(() => internalStore?.disposeEffect(), [internalStore]); 10603 return store; 10604 } 10605 disposeEffect = () => { 10606 return this.context.stickIfOpenTimeout.disposeEffect(); 10607 }; 10608 }; 10609 10610 // node_modules/@base-ui/react/popover/root/PopoverRoot.mjs 10611 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1); 10612 function PopoverRootComponent({ 10613 props 10614 }) { 10615 const { 10616 children, 10617 open: openProp, 10618 defaultOpen = false, 10619 onOpenChange, 10620 onOpenChangeComplete, 10621 modal = false, 10622 handle, 10623 triggerId: triggerIdProp, 10624 defaultTriggerId: defaultTriggerIdProp = null 10625 } = props; 10626 const store = PopoverStore.useStore(handle?.store, { 10627 modal, 10628 open: defaultOpen, 10629 openProp, 10630 activeTriggerId: defaultTriggerIdProp, 10631 triggerIdProp 10632 }); 10633 useInitialOpenSync(store, openProp, defaultOpen, defaultTriggerIdProp); 10634 store.useControlledProp("openProp", openProp); 10635 store.useControlledProp("triggerIdProp", triggerIdProp); 10636 const open = store.useState("open"); 10637 const mounted = store.useState("mounted"); 10638 const payload = store.useState("payload"); 10639 const nested = useFloatingParentNodeId() != null; 10640 store.useContextCallback("onOpenChange", onOpenChange); 10641 store.useContextCallback("onOpenChangeComplete", onOpenChangeComplete); 10642 usePopupRootSync(store, open); 10643 useImplicitActiveTrigger(store); 10644 const { 10645 forceUnmount 10646 } = useOpenStateTransitions(open, store, () => { 10647 store.update({ 10648 stickIfOpen: true, 10649 openChangeReason: null 10650 }); 10651 }); 10652 store.useSyncedValues({ 10653 modal, 10654 nested 10655 }); 10656 React54.useEffect(() => { 10657 if (!open) { 10658 store.context.stickIfOpenTimeout.clear(); 10659 } 10660 }, [store, open]); 10661 const handleImperativeClose = React54.useCallback(() => { 10662 store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction)); 10663 }, [store]); 10664 React54.useImperativeHandle(props.actionsRef, () => ({ 10665 unmount: forceUnmount, 10666 close: handleImperativeClose 10667 }), [forceUnmount, handleImperativeClose]); 10668 const shouldRenderInteractions = open || mounted; 10669 const popoverContext = React54.useMemo(() => ({ 10670 store 10671 }), [store]); 10672 return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(PopoverRootContext.Provider, { 10673 value: popoverContext, 10674 children: [shouldRenderInteractions && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(PopoverInteractions, { 10675 store, 10676 modal 10677 }), typeof children === "function" ? children({ 10678 payload 10679 }) : children] 10680 }); 10681 } 10682 function PopoverRoot(props) { 10683 if (usePopoverRootContext(true)) { 10684 return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(PopoverRootComponent, { 10685 props 10686 }); 10687 } 10688 return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(FloatingTree, { 10689 children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(PopoverRootComponent, { 10690 props 10691 }) 10692 }); 10693 } 10694 function PopoverInteractions({ 10695 store, 10696 modal 10697 }) { 10698 const floatingRootContext = store.useState("floatingRootContext"); 10699 const dismiss = useDismiss(floatingRootContext, { 10700 outsidePressEvent: { 10701 // Ensure `aria-hidden` on outside elements is removed immediately 10702 // on outside press when trapping focus. 10703 mouse: modal === "trap-focus" ? "sloppy" : "intentional", 10704 touch: "sloppy" 10705 } 10706 }); 10707 const activeTriggerProps = dismiss.reference ?? EMPTY_OBJECT; 10708 const inactiveTriggerProps = dismiss.trigger ?? EMPTY_OBJECT; 10709 const popupProps = React54.useMemo(() => mergeProps(FOCUSABLE_POPUP_PROPS, dismiss.floating), [dismiss.floating]); 10710 usePopupInteractionProps(store, { 10711 activeTriggerProps, 10712 inactiveTriggerProps, 10713 popupProps 10714 }); 10715 return null; 10716 } 10717 10718 // node_modules/@base-ui/react/popover/trigger/PopoverTrigger.mjs 10719 var React55 = __toESM(require_react(), 1); 10720 10721 // node_modules/@base-ui/react/popover/utils/constants.mjs 10722 var OPEN_DELAY = 300; 10723 10724 // node_modules/@base-ui/react/popover/trigger/PopoverTrigger.mjs 10725 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1); 10726 var PopoverTrigger = /* @__PURE__ */ React55.forwardRef(function PopoverTrigger2(componentProps, forwardedRef) { 10727 const { 10728 render: render4, 10729 className, 10730 style, 10731 disabled: disabled2 = false, 10732 nativeButton = true, 10733 handle, 10734 payload, 10735 openOnHover = false, 10736 delay = OPEN_DELAY, 10737 closeDelay = 0, 10738 id: idProp, 10739 ...elementProps 10740 } = componentProps; 10741 const rootContext = usePopoverRootContext(true); 10742 const store = handle?.store ?? rootContext?.store; 10743 if (!store) { 10744 throw new Error(true ? "Base UI: <Popover.Trigger> must be either used within a <Popover.Root> component or provided with a handle." : formatErrorMessage_default(74)); 10745 } 10746 const thisTriggerId = useBaseUiId(idProp); 10747 const isTriggerActive = store.useState("isTriggerActive", thisTriggerId); 10748 const floatingContext = store.useState("floatingRootContext"); 10749 const isOpenedByThisTrigger = store.useState("isOpenedByTrigger", thisTriggerId); 10750 const popupId = store.useState("triggerPopupId", thisTriggerId); 10751 const triggerElementRef = React55.useRef(null); 10752 const { 10753 registerTrigger, 10754 isMountedByThisTrigger 10755 } = useTriggerDataForwarding(thisTriggerId, triggerElementRef, store, { 10756 payload, 10757 disabled: disabled2, 10758 openOnHover, 10759 closeDelay 10760 }); 10761 const openReason = store.useState("openChangeReason"); 10762 const stickIfOpen = store.useState("stickIfOpen"); 10763 const openMethod = store.useState("openMethod"); 10764 const focusManagerModal = store.useState("focusManagerModal"); 10765 const hoverProps = useHoverReferenceInteraction(floatingContext, { 10766 enabled: !disabled2 && floatingContext != null && openOnHover && (openMethod !== "touch" || openReason !== reason_parts_exports.triggerPress), 10767 mouseOnly: true, 10768 move: false, 10769 handleClose: safePolygon(), 10770 restMs: delay, 10771 delay: { 10772 close: closeDelay 10773 }, 10774 triggerElementRef, 10775 isActiveTrigger: isTriggerActive, 10776 isClosing: () => store.select("transitionStatus") === "ending" 10777 }); 10778 const click = useClick(floatingContext, { 10779 enabled: floatingContext != null, 10780 stickIfOpen 10781 }); 10782 const interactionTypeProps = useOpenMethodTriggerProps(() => store.select("open"), (interactionType) => { 10783 store.set("openMethod", interactionType); 10784 }); 10785 const rootTriggerProps = store.useState("triggerProps", isMountedByThisTrigger); 10786 const { 10787 getButtonProps, 10788 buttonRef 10789 } = useButton({ 10790 disabled: disabled2, 10791 native: nativeButton 10792 }); 10793 const stateAttributesMapping7 = { 10794 open(value) { 10795 if (value && openReason === reason_parts_exports.triggerPress) { 10796 return pressableTriggerOpenStateMapping.open(value); 10797 } 10798 return triggerOpenStateMapping2.open(value); 10799 } 10800 }; 10801 const { 10802 preFocusGuardRef, 10803 handlePreFocusGuardFocus, 10804 handleFocusTargetFocus 10805 } = useTriggerFocusGuards(store, triggerElementRef); 10806 const state = { 10807 disabled: disabled2, 10808 open: isOpenedByThisTrigger 10809 }; 10810 const element = useRenderElement("button", componentProps, { 10811 state, 10812 ref: [buttonRef, forwardedRef, registerTrigger, triggerElementRef], 10813 props: [click.reference, hoverProps, rootTriggerProps, interactionTypeProps, { 10814 [CLICK_TRIGGER_IDENTIFIER]: "", 10815 id: thisTriggerId, 10816 "aria-haspopup": "dialog", 10817 "aria-expanded": isOpenedByThisTrigger, 10818 "aria-controls": popupId 10819 }, elementProps, getButtonProps], 10820 stateAttributesMapping: stateAttributesMapping7 10821 }); 10822 if (isMountedByThisTrigger && !focusManagerModal) { 10823 return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(React55.Fragment, { 10824 children: [/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(FocusGuard, { 10825 ref: preFocusGuardRef, 10826 onFocus: handlePreFocusGuardFocus 10827 }), /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(React55.Fragment, { 10828 children: element 10829 }, thisTriggerId), /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(FocusGuard, { 10830 ref: store.context.triggerFocusTargetRef, 10831 onFocus: handleFocusTargetFocus 10832 })] 10833 }); 10834 } 10835 return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(React55.Fragment, { 10836 children: element 10837 }, thisTriggerId); 10838 }); 10839 if (true) PopoverTrigger.displayName = "PopoverTrigger"; 10840 10841 // node_modules/@base-ui/react/popover/portal/PopoverPortal.mjs 10842 var React57 = __toESM(require_react(), 1); 10843 10844 // node_modules/@base-ui/react/popover/portal/PopoverPortalContext.mjs 10845 var React56 = __toESM(require_react(), 1); 10846 var PopoverPortalContext = /* @__PURE__ */ React56.createContext(void 0); 10847 if (true) PopoverPortalContext.displayName = "PopoverPortalContext"; 10848 function usePopoverPortalContext() { 10849 const value = React56.useContext(PopoverPortalContext); 10850 if (value === void 0) { 10851 throw new Error(true ? "Base UI: <Popover.Portal> is missing." : formatErrorMessage_default(45)); 10852 } 10853 return value; 10854 } 10855 10856 // node_modules/@base-ui/react/popover/portal/PopoverPortal.mjs 10857 var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1); 10858 var PopoverPortal = /* @__PURE__ */ React57.forwardRef(function PopoverPortal2(props, forwardedRef) { 10859 const { 10860 keepMounted = false, 10861 ...portalProps 10862 } = props; 10863 const { 10864 store 10865 } = usePopoverRootContext(); 10866 const mounted = store.useState("mounted"); 10867 const shouldRender = mounted || keepMounted; 10868 if (!shouldRender) { 10869 return null; 10870 } 10871 return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(PopoverPortalContext.Provider, { 10872 value: keepMounted, 10873 children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(FloatingPortal, { 10874 ref: forwardedRef, 10875 ...portalProps 10876 }) 10877 }); 10878 }); 10879 if (true) PopoverPortal.displayName = "PopoverPortal"; 10880 10881 // node_modules/@base-ui/react/popover/positioner/PopoverPositioner.mjs 10882 var React59 = __toESM(require_react(), 1); 10883 10884 // node_modules/@base-ui/react/popover/positioner/PopoverPositionerContext.mjs 10885 var React58 = __toESM(require_react(), 1); 10886 var PopoverPositionerContext = /* @__PURE__ */ React58.createContext(void 0); 10887 if (true) PopoverPositionerContext.displayName = "PopoverPositionerContext"; 10888 function usePopoverPositionerContext() { 10889 const context = React58.useContext(PopoverPositionerContext); 10890 if (!context) { 10891 throw new Error(true ? "Base UI: PopoverPositionerContext is missing. PopoverPositioner parts must be placed within <Popover.Positioner>." : formatErrorMessage_default(46)); 10892 } 10893 return context; 10894 } 10895 10896 // node_modules/@base-ui/react/popover/positioner/PopoverPositioner.mjs 10897 var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1); 10898 var PopoverPositioner = /* @__PURE__ */ React59.forwardRef(function PopoverPositioner2(componentProps, forwardedRef) { 10899 const { 10900 render: render4, 10901 className, 10902 style, 10903 anchor, 10904 positionMethod = "absolute", 10905 side = "bottom", 10906 align = "center", 10907 sideOffset = 0, 10908 alignOffset = 0, 10909 collisionBoundary = "clipping-ancestors", 10910 collisionPadding = 5, 10911 arrowPadding = 5, 10912 sticky = false, 10913 disableAnchorTracking = false, 10914 collisionAvoidance = POPUP_COLLISION_AVOIDANCE, 10915 ...elementProps 10916 } = componentProps; 10917 const { 10918 store 10919 } = usePopoverRootContext(); 10920 const keepMounted = usePopoverPortalContext(); 10921 const nodeId = useFloatingNodeId(); 10922 const floatingRootContext = store.useState("floatingRootContext"); 10923 const mounted = store.useState("mounted"); 10924 const open = store.useState("open"); 10925 const openReason = store.useState("openChangeReason"); 10926 const triggerElement = store.useState("activeTriggerElement"); 10927 const modal = store.useState("modal"); 10928 const openMethod = store.useState("openMethod"); 10929 const positionerElement = store.useState("positionerElement"); 10930 const instantType = store.useState("instantType"); 10931 const transitionStatus = store.useState("transitionStatus"); 10932 const hasViewport = store.useState("hasViewport"); 10933 const prevTriggerElementRef = React59.useRef(null); 10934 const runOnceAnimationsFinish = useAnimationsFinished(positionerElement, false, false); 10935 const positioning = useAnchorPositioning({ 10936 anchor, 10937 floatingRootContext, 10938 positionMethod, 10939 mounted, 10940 side, 10941 sideOffset, 10942 align, 10943 alignOffset, 10944 arrowPadding, 10945 collisionBoundary, 10946 collisionPadding, 10947 sticky, 10948 disableAnchorTracking, 10949 keepMounted, 10950 nodeId, 10951 collisionAvoidance, 10952 adaptiveOrigin: hasViewport ? adaptiveOrigin : void 0 10953 }); 10954 const domReference = floatingRootContext.useState("domReferenceElement"); 10955 useIsoLayoutEffect(() => { 10956 const currentTriggerElement = domReference; 10957 const prevTriggerElement = prevTriggerElementRef.current; 10958 if (currentTriggerElement) { 10959 prevTriggerElementRef.current = currentTriggerElement; 10960 } 10961 if (prevTriggerElement && currentTriggerElement && currentTriggerElement !== prevTriggerElement) { 10962 store.set("instantType", void 0); 10963 const ac = new AbortController(); 10964 runOnceAnimationsFinish(() => { 10965 store.set("instantType", "trigger-change"); 10966 }, ac.signal); 10967 return () => { 10968 ac.abort(); 10969 }; 10970 } 10971 return void 0; 10972 }, [domReference, runOnceAnimationsFinish, store]); 10973 useAnchoredPopupScrollLock(open && modal === true && openReason !== reason_parts_exports.triggerHover, openMethod === "touch", positionerElement, triggerElement); 10974 const setPositionerElement = React59.useCallback((element2) => { 10975 store.set("positionerElement", element2); 10976 }, [store]); 10977 const state = { 10978 open, 10979 side: positioning.side, 10980 align: positioning.align, 10981 anchorHidden: positioning.anchorHidden, 10982 instant: instantType 10983 }; 10984 const element = usePositioner(componentProps, state, { 10985 styles: positioning.positionerStyles, 10986 transitionStatus, 10987 props: elementProps, 10988 refs: [forwardedRef, setPositionerElement], 10989 hidden: !mounted, 10990 inert: !open 10991 }); 10992 return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(PopoverPositionerContext.Provider, { 10993 value: positioning, 10994 children: [mounted && modal === true && openReason !== reason_parts_exports.triggerHover && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(InternalBackdrop, { 10995 ref: store.context.internalBackdropRef, 10996 inert: inertValue(!open), 10997 cutout: triggerElement 10998 }), /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(FloatingNode, { 10999 id: nodeId, 11000 children: element 11001 })] 11002 }); 11003 }); 11004 if (true) PopoverPositioner.displayName = "PopoverPositioner"; 11005 11006 // node_modules/@base-ui/react/popover/popup/PopoverPopup.mjs 11007 var React61 = __toESM(require_react(), 1); 11008 11009 // node_modules/@base-ui/react/utils/closePart.mjs 11010 var React60 = __toESM(require_react(), 1); 11011 var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1); 11012 var ClosePartContext = /* @__PURE__ */ React60.createContext(void 0); 11013 if (true) ClosePartContext.displayName = "ClosePartContext"; 11014 function useClosePartCount() { 11015 const [closePartCount, setClosePartCount] = React60.useState(0); 11016 const register2 = useStableCallback(() => { 11017 setClosePartCount((count) => count + 1); 11018 return () => { 11019 setClosePartCount((count) => Math.max(0, count - 1)); 11020 }; 11021 }); 11022 const context = React60.useMemo(() => ({ 11023 register: register2 11024 }), [register2]); 11025 return { 11026 context, 11027 hasClosePart: closePartCount > 0 11028 }; 11029 } 11030 function ClosePartProvider(props) { 11031 const { 11032 value, 11033 children 11034 } = props; 11035 return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ClosePartContext.Provider, { 11036 value, 11037 children 11038 }); 11039 } 11040 function useClosePartRegistration() { 11041 const context = React60.useContext(ClosePartContext); 11042 useIsoLayoutEffect(() => { 11043 return context?.register(); 11044 }, [context]); 11045 } 11046 11047 // node_modules/@base-ui/react/popover/popup/PopoverPopup.mjs 11048 var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1); 11049 var stateAttributesMapping2 = { 11050 ...popupStateMapping, 11051 ...transitionStatusMapping 11052 }; 11053 var PopoverPopup = /* @__PURE__ */ React61.forwardRef(function PopoverPopup2(componentProps, forwardedRef) { 11054 const { 11055 render: render4, 11056 className, 11057 style, 11058 initialFocus, 11059 finalFocus, 11060 ...elementProps 11061 } = componentProps; 11062 const { 11063 store 11064 } = usePopoverRootContext(); 11065 const positioner = usePopoverPositionerContext(); 11066 const insideToolbar = useToolbarRootContext(true) != null; 11067 const { 11068 context: closePartContext, 11069 hasClosePart 11070 } = useClosePartCount(); 11071 const open = store.useState("open"); 11072 const openMethod = store.useState("openMethod"); 11073 const instantType = store.useState("instantType"); 11074 const transitionStatus = store.useState("transitionStatus"); 11075 const popupProps = store.useState("popupProps"); 11076 const titleId = store.useState("titleElementId"); 11077 const descriptionId = store.useState("descriptionElementId"); 11078 const modal = store.useState("modal"); 11079 const mounted = store.useState("mounted"); 11080 const openReason = store.useState("openChangeReason"); 11081 const activeTriggerElement = store.useState("activeTriggerElement"); 11082 const floatingContext = store.useState("floatingRootContext"); 11083 const floatingId = floatingContext.useState("floatingId"); 11084 const disabled2 = store.useState("disabled"); 11085 const openOnHover = store.useState("openOnHover"); 11086 const closeDelay = store.useState("closeDelay"); 11087 const popupId = elementProps.id ?? floatingId; 11088 useOpenChangeComplete({ 11089 open, 11090 ref: store.context.popupRef, 11091 onComplete() { 11092 if (open) { 11093 store.context.onOpenChangeComplete?.(true); 11094 } 11095 } 11096 }); 11097 useHoverFloatingInteraction(floatingContext, { 11098 enabled: openOnHover && !disabled2, 11099 closeDelay 11100 }); 11101 const resolvedInitialFocus = initialFocus === void 0 ? createDefaultInitialFocus(store.context.popupRef) : initialFocus; 11102 const focusManagerModal = modal !== false && hasClosePart; 11103 store.useSyncedValue("focusManagerModal", focusManagerModal); 11104 const setPopupElement = React61.useCallback((element2) => { 11105 store.set("popupElement", element2); 11106 }, [store]); 11107 const state = { 11108 open, 11109 side: positioner.side, 11110 align: positioner.align, 11111 instant: instantType, 11112 transitionStatus 11113 }; 11114 const element = useRenderElement("div", componentProps, { 11115 state, 11116 ref: [forwardedRef, store.context.popupRef, setPopupElement], 11117 props: [popupProps, { 11118 id: popupId, 11119 role: "dialog", 11120 ...FOCUSABLE_POPUP_PROPS, 11121 "aria-labelledby": titleId, 11122 "aria-describedby": descriptionId, 11123 onKeyDown(event) { 11124 if (insideToolbar && COMPOSITE_KEYS.has(event.key)) { 11125 event.stopPropagation(); 11126 } 11127 } 11128 }, getDisabledMountTransitionStyles(transitionStatus), elementProps], 11129 stateAttributesMapping: stateAttributesMapping2 11130 }); 11131 return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(FloatingFocusManager, { 11132 context: floatingContext, 11133 openInteractionType: openMethod, 11134 modal: focusManagerModal, 11135 disabled: !mounted || openReason === reason_parts_exports.triggerHover, 11136 initialFocus: resolvedInitialFocus, 11137 returnFocus: finalFocus, 11138 restoreFocus: "popup", 11139 previousFocusableElement: isHTMLElement(activeTriggerElement) ? activeTriggerElement : void 0, 11140 nextFocusableElement: store.context.triggerFocusTargetRef, 11141 beforeContentFocusGuardRef: store.context.beforeContentFocusGuardRef, 11142 children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ClosePartProvider, { 11143 value: closePartContext, 11144 children: element 11145 }) 11146 }); 11147 }); 11148 if (true) PopoverPopup.displayName = "PopoverPopup"; 11149 11150 // node_modules/@base-ui/react/popover/arrow/PopoverArrow.mjs 11151 var React62 = __toESM(require_react(), 1); 11152 var PopoverArrow = /* @__PURE__ */ React62.forwardRef(function PopoverArrow2(componentProps, forwardedRef) { 11153 const { 11154 render: render4, 11155 className, 11156 style, 11157 ...elementProps 11158 } = componentProps; 11159 const { 11160 store 11161 } = usePopoverRootContext(); 11162 const open = store.useState("open"); 11163 const { 11164 arrowRef, 11165 side, 11166 align, 11167 arrowUncentered, 11168 arrowStyles 11169 } = usePopoverPositionerContext(); 11170 const state = { 11171 open, 11172 side, 11173 align, 11174 uncentered: arrowUncentered 11175 }; 11176 const element = useRenderElement("div", componentProps, { 11177 state, 11178 ref: [forwardedRef, arrowRef], 11179 props: [{ 11180 style: arrowStyles, 11181 "aria-hidden": true 11182 }, elementProps], 11183 stateAttributesMapping: popupStateMapping 11184 }); 11185 return element; 11186 }); 11187 if (true) PopoverArrow.displayName = "PopoverArrow"; 11188 11189 // node_modules/@base-ui/react/popover/backdrop/PopoverBackdrop.mjs 11190 var React63 = __toESM(require_react(), 1); 11191 var stateAttributesMapping3 = { 11192 ...popupStateMapping, 11193 ...transitionStatusMapping 11194 }; 11195 var PopoverBackdrop = /* @__PURE__ */ React63.forwardRef(function PopoverBackdrop2(props, forwardedRef) { 11196 const { 11197 render: render4, 11198 className, 11199 style, 11200 ...elementProps 11201 } = props; 11202 const { 11203 store 11204 } = usePopoverRootContext(); 11205 const open = store.useState("open"); 11206 const mounted = store.useState("mounted"); 11207 const transitionStatus = store.useState("transitionStatus"); 11208 const openReason = store.useState("openChangeReason"); 11209 const state = { 11210 open, 11211 transitionStatus 11212 }; 11213 const element = useRenderElement("div", props, { 11214 state, 11215 ref: [store.context.backdropRef, forwardedRef], 11216 props: [{ 11217 role: "presentation", 11218 hidden: !mounted, 11219 style: { 11220 pointerEvents: openReason === reason_parts_exports.triggerHover ? "none" : void 0, 11221 userSelect: "none", 11222 WebkitUserSelect: "none" 11223 } 11224 }, elementProps], 11225 stateAttributesMapping: stateAttributesMapping3 11226 }); 11227 return element; 11228 }); 11229 if (true) PopoverBackdrop.displayName = "PopoverBackdrop"; 11230 11231 // node_modules/@base-ui/react/popover/title/PopoverTitle.mjs 11232 var React64 = __toESM(require_react(), 1); 11233 var PopoverTitle = /* @__PURE__ */ React64.forwardRef(function PopoverTitle2(componentProps, forwardedRef) { 11234 const { 11235 render: render4, 11236 className, 11237 style, 11238 ...elementProps 11239 } = componentProps; 11240 const { 11241 store 11242 } = usePopoverRootContext(); 11243 const id = useBaseUiId(elementProps.id); 11244 store.useSyncedValueWithCleanup("titleElementId", id); 11245 const element = useRenderElement("h2", componentProps, { 11246 ref: forwardedRef, 11247 props: [{ 11248 id 11249 }, elementProps] 11250 }); 11251 return element; 11252 }); 11253 if (true) PopoverTitle.displayName = "PopoverTitle"; 11254 11255 // node_modules/@base-ui/react/popover/description/PopoverDescription.mjs 11256 var React65 = __toESM(require_react(), 1); 11257 var PopoverDescription = /* @__PURE__ */ React65.forwardRef(function PopoverDescription2(componentProps, forwardedRef) { 11258 const { 11259 render: render4, 11260 className, 11261 style, 11262 ...elementProps 11263 } = componentProps; 11264 const { 11265 store 11266 } = usePopoverRootContext(); 11267 const id = useBaseUiId(elementProps.id); 11268 store.useSyncedValueWithCleanup("descriptionElementId", id); 11269 const element = useRenderElement("p", componentProps, { 11270 ref: forwardedRef, 11271 props: [{ 11272 id 11273 }, elementProps] 11274 }); 11275 return element; 11276 }); 11277 if (true) PopoverDescription.displayName = "PopoverDescription"; 11278 11279 // node_modules/@base-ui/react/popover/close/PopoverClose.mjs 11280 var React66 = __toESM(require_react(), 1); 11281 var PopoverClose = /* @__PURE__ */ React66.forwardRef(function PopoverClose2(componentProps, forwardedRef) { 11282 const { 11283 render: render4, 11284 className, 11285 style, 11286 disabled: disabled2 = false, 11287 nativeButton = true, 11288 ...elementProps 11289 } = componentProps; 11290 const { 11291 buttonRef, 11292 getButtonProps 11293 } = useButton({ 11294 disabled: disabled2, 11295 focusableWhenDisabled: false, 11296 native: nativeButton 11297 }); 11298 const { 11299 store 11300 } = usePopoverRootContext(); 11301 useClosePartRegistration(); 11302 const element = useRenderElement("button", componentProps, { 11303 ref: [forwardedRef, buttonRef], 11304 props: [{ 11305 onClick(event) { 11306 store.setOpen(false, createChangeEventDetails(reason_parts_exports.closePress, event.nativeEvent)); 11307 } 11308 }, elementProps, getButtonProps] 11309 }); 11310 return element; 11311 }); 11312 if (true) PopoverClose.displayName = "PopoverClose"; 11313 11314 // node_modules/@base-ui/react/popover/viewport/PopoverViewport.mjs 11315 var React67 = __toESM(require_react(), 1); 11316 11317 // node_modules/@base-ui/react/popover/viewport/PopoverViewportCssVars.mjs 11318 var PopoverViewportCssVars = /* @__PURE__ */ (function(PopoverViewportCssVars2) { 11319 PopoverViewportCssVars2["popupWidth"] = "--popup-width"; 11320 PopoverViewportCssVars2["popupHeight"] = "--popup-height"; 11321 return PopoverViewportCssVars2; 11322 })({}); 11323 11324 // node_modules/@base-ui/react/popover/viewport/PopoverViewport.mjs 11325 var stateAttributesMapping4 = { 11326 activationDirection: (value) => value ? { 11327 "data-activation-direction": value 11328 } : null 11329 }; 11330 var PopoverViewport = /* @__PURE__ */ React67.forwardRef(function PopoverViewport2(componentProps, forwardedRef) { 11331 const { 11332 render: render4, 11333 className, 11334 style, 11335 children, 11336 ...elementProps 11337 } = componentProps; 11338 const { 11339 store 11340 } = usePopoverRootContext(); 11341 const { 11342 side 11343 } = usePopoverPositionerContext(); 11344 const instantType = store.useState("instantType"); 11345 const { 11346 children: childrenToRender, 11347 state: viewportState 11348 } = usePopupViewport({ 11349 store, 11350 side, 11351 cssVars: PopoverViewportCssVars, 11352 children 11353 }); 11354 const state = { 11355 activationDirection: viewportState.activationDirection, 11356 transitioning: viewportState.transitioning, 11357 instant: instantType 11358 }; 11359 return useRenderElement("div", componentProps, { 11360 state, 11361 ref: forwardedRef, 11362 props: [elementProps, { 11363 children: childrenToRender 11364 }], 11365 stateAttributesMapping: stateAttributesMapping4 11366 }); 11367 }); 11368 if (true) PopoverViewport.displayName = "PopoverViewport"; 11369 11370 // node_modules/@base-ui/react/popover/store/PopoverHandle.mjs 11371 var PopoverHandle = class { 11372 /** 11373 * Internal store holding the popover's state. 11374 * @internal 11375 */ 11376 constructor() { 11377 this.store = new PopoverStore(); 11378 } 11379 /** 11380 * Opens the popover and associates it with the trigger with the given id. 11381 * The trigger must be a Popover.Trigger component with this handle passed as a prop. 11382 * 11383 * @param triggerId ID of the trigger to associate with the popover. 11384 */ 11385 open(triggerId) { 11386 const triggerElement = triggerId ? this.store.context.triggerElements.getById(triggerId) ?? void 0 : void 0; 11387 if (triggerId && !triggerElement) { 11388 throw new Error(true ? `Base UI: PopoverHandle.open: No trigger found with id "$triggerId}".` : formatErrorMessage_default(80, triggerId)); 11389 } 11390 this.store.setOpen(true, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, triggerElement)); 11391 } 11392 /** 11393 * Closes the popover. 11394 */ 11395 close() { 11396 this.store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, void 0)); 11397 } 11398 /** 11399 * Indicates whether the popover is currently open. 11400 */ 11401 get isOpen() { 11402 return this.store.select("open"); 11403 } 11404 }; 11405 function createPopoverHandle() { 11406 return new PopoverHandle(); 11407 } 11408 11409 // node_modules/@base-ui/react/utils/FloatingPortalLite.mjs 11410 var React68 = __toESM(require_react(), 1); 11411 var ReactDOM9 = __toESM(require_react_dom(), 1); 11412 var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1); 11413 var FloatingPortalLite = /* @__PURE__ */ React68.forwardRef(function FloatingPortalLite2(componentProps, forwardedRef) { 11414 const { 11415 children, 11416 container, 11417 className, 11418 render: render4, 11419 style, 11420 ...elementProps 11421 } = componentProps; 11422 const { 11423 portalNode, 11424 portalSubtree 11425 } = useFloatingPortalNode({ 11426 container, 11427 ref: forwardedRef, 11428 componentProps, 11429 elementProps 11430 }); 11431 if (!portalSubtree && !portalNode) { 11432 return null; 11433 } 11434 return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(React68.Fragment, { 11435 children: [portalSubtree, portalNode && /* @__PURE__ */ ReactDOM9.createPortal(children, portalNode)] 11436 }); 11437 }); 11438 if (true) FloatingPortalLite.displayName = "FloatingPortalLite"; 11439 11440 // node_modules/@base-ui/react/tooltip/index.parts.mjs 11441 var index_parts_exports3 = {}; 11442 __export(index_parts_exports3, { 11443 Arrow: () => TooltipArrow, 11444 Handle: () => TooltipHandle, 11445 Popup: () => TooltipPopup, 11446 Portal: () => TooltipPortal, 11447 Positioner: () => TooltipPositioner, 11448 Provider: () => TooltipProvider, 11449 Root: () => TooltipRoot, 11450 Trigger: () => TooltipTrigger, 11451 Viewport: () => TooltipViewport, 11452 createHandle: () => createTooltipHandle 11453 }); 11454 11455 // node_modules/@base-ui/react/tooltip/root/TooltipRoot.mjs 11456 var React71 = __toESM(require_react(), 1); 11457 11458 // node_modules/@base-ui/react/tooltip/root/TooltipRootContext.mjs 11459 var React69 = __toESM(require_react(), 1); 11460 var TooltipRootContext = /* @__PURE__ */ React69.createContext(void 0); 11461 if (true) TooltipRootContext.displayName = "TooltipRootContext"; 11462 function useTooltipRootContext(optional) { 11463 const context = React69.useContext(TooltipRootContext); 11464 if (context === void 0 && !optional) { 11465 throw new Error(true ? "Base UI: TooltipRootContext is missing. Tooltip parts must be placed within <Tooltip.Root>." : formatErrorMessage_default(72)); 11466 } 11467 return context; 11468 } 11469 11470 // node_modules/@base-ui/react/tooltip/store/TooltipStore.mjs 11471 var React70 = __toESM(require_react(), 1); 11472 var selectors3 = { 11473 ...popupStoreSelectors, 11474 disabled: createSelector((state) => state.disabled), 11475 instantType: createSelector((state) => state.instantType), 11476 isInstantPhase: createSelector((state) => state.isInstantPhase), 11477 trackCursorAxis: createSelector((state) => state.trackCursorAxis), 11478 disableHoverablePopup: createSelector((state) => state.disableHoverablePopup), 11479 lastOpenChangeReason: createSelector((state) => state.openChangeReason), 11480 closeOnClick: createSelector((state) => state.closeOnClick), 11481 closeDelay: createSelector((state) => state.closeDelay), 11482 hasViewport: createSelector((state) => state.hasViewport) 11483 }; 11484 var TooltipStore = class _TooltipStore extends ReactStore { 11485 constructor(initialState, floatingId, nested = false) { 11486 const triggerElements = new PopupTriggerMap(); 11487 const state = { 11488 ...createInitialState2(), 11489 ...initialState 11490 }; 11491 state.floatingRootContext = createPopupFloatingRootContext(triggerElements, floatingId, nested); 11492 super(state, { 11493 popupRef: /* @__PURE__ */ React70.createRef(), 11494 onOpenChange: void 0, 11495 onOpenChangeComplete: void 0, 11496 triggerElements 11497 }, selectors3); 11498 } 11499 setOpen = (nextOpen, eventDetails) => { 11500 applyPopupOpenChange(this, nextOpen, eventDetails, { 11501 extraState: { 11502 openChangeReason: eventDetails.reason 11503 } 11504 }); 11505 }; 11506 // Used by trigger clicks to clear a delayed hover open without reporting a public open-state change. 11507 cancelPendingOpen(event) { 11508 this.state.floatingRootContext.dispatchOpenChange(false, createChangeEventDetails(reason_parts_exports.triggerPress, event)); 11509 } 11510 static useStore(externalStore, initialState) { 11511 const store = usePopupStore(externalStore, (floatingId, nested) => new _TooltipStore(initialState, floatingId, nested)).store; 11512 return store; 11513 } 11514 }; 11515 function createInitialState2() { 11516 return { 11517 ...createInitialPopupStoreState(), 11518 disabled: false, 11519 instantType: void 0, 11520 isInstantPhase: false, 11521 trackCursorAxis: "none", 11522 disableHoverablePopup: false, 11523 openChangeReason: null, 11524 closeOnClick: true, 11525 closeDelay: 0, 11526 hasViewport: false 11527 }; 11528 } 11529 11530 // node_modules/@base-ui/react/tooltip/root/TooltipRoot.mjs 11531 var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1); 11532 var TooltipRoot = fastComponent(function TooltipRoot2(props) { 11533 const { 11534 disabled: disabled2 = false, 11535 defaultOpen = false, 11536 open: openProp, 11537 disableHoverablePopup = false, 11538 trackCursorAxis = "none", 11539 actionsRef, 11540 onOpenChange, 11541 onOpenChangeComplete, 11542 handle, 11543 triggerId: triggerIdProp, 11544 defaultTriggerId: defaultTriggerIdProp = null, 11545 children 11546 } = props; 11547 const store = TooltipStore.useStore(handle?.store, { 11548 open: defaultOpen, 11549 openProp, 11550 activeTriggerId: defaultTriggerIdProp, 11551 triggerIdProp 11552 }); 11553 useInitialOpenSync(store, openProp, defaultOpen, defaultTriggerIdProp); 11554 store.useControlledProp("openProp", openProp); 11555 store.useControlledProp("triggerIdProp", triggerIdProp); 11556 store.useContextCallback("onOpenChange", onOpenChange); 11557 store.useContextCallback("onOpenChangeComplete", onOpenChangeComplete); 11558 const openState = store.useState("open"); 11559 const open = !disabled2 && openState; 11560 const activeTriggerId = store.useState("activeTriggerId"); 11561 const mounted = store.useState("mounted"); 11562 const payload = store.useState("payload"); 11563 store.useSyncedValues({ 11564 trackCursorAxis, 11565 disableHoverablePopup 11566 }); 11567 store.useSyncedValue("disabled", disabled2); 11568 useImplicitActiveTrigger(store, { 11569 closeOnActiveTriggerUnmount: true 11570 }); 11571 const { 11572 forceUnmount, 11573 transitionStatus 11574 } = useOpenStateTransitions(open, store); 11575 const isInstantPhase = store.useState("isInstantPhase"); 11576 const instantType = store.useState("instantType"); 11577 const lastOpenChangeReason = store.useState("lastOpenChangeReason"); 11578 const previousInstantTypeRef = React71.useRef(null); 11579 useIsoLayoutEffect(() => { 11580 if (openState && disabled2) { 11581 store.setOpen(false, createChangeEventDetails(reason_parts_exports.disabled)); 11582 } 11583 }, [openState, disabled2, store]); 11584 useIsoLayoutEffect(() => { 11585 if (transitionStatus === "ending" && lastOpenChangeReason === reason_parts_exports.none || transitionStatus !== "ending" && isInstantPhase) { 11586 if (instantType !== "delay") { 11587 previousInstantTypeRef.current = instantType; 11588 } 11589 store.set("instantType", "delay"); 11590 } else if (previousInstantTypeRef.current !== null) { 11591 store.set("instantType", previousInstantTypeRef.current); 11592 previousInstantTypeRef.current = null; 11593 } 11594 }, [transitionStatus, isInstantPhase, lastOpenChangeReason, instantType, store]); 11595 useIsoLayoutEffect(() => { 11596 if (open) { 11597 if (activeTriggerId == null) { 11598 store.set("payload", void 0); 11599 } 11600 } 11601 }, [store, activeTriggerId, open]); 11602 const handleImperativeClose = React71.useCallback(() => { 11603 store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction)); 11604 }, [store]); 11605 React71.useImperativeHandle(actionsRef, () => ({ 11606 unmount: forceUnmount, 11607 close: handleImperativeClose 11608 }), [forceUnmount, handleImperativeClose]); 11609 const shouldRenderInteractions = open || mounted || !disabled2 && trackCursorAxis !== "none"; 11610 return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(TooltipRootContext.Provider, { 11611 value: store, 11612 children: [shouldRenderInteractions && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(TooltipInteractions, { 11613 store, 11614 disabled: disabled2, 11615 trackCursorAxis 11616 }), typeof children === "function" ? children({ 11617 payload 11618 }) : children] 11619 }); 11620 }); 11621 if (true) TooltipRoot.displayName = "TooltipRoot"; 11622 function TooltipInteractions({ 11623 store, 11624 disabled: disabled2, 11625 trackCursorAxis 11626 }) { 11627 const floatingRootContext = store.useState("floatingRootContext"); 11628 const dismiss = useDismiss(floatingRootContext, { 11629 enabled: !disabled2, 11630 referencePress: () => store.select("closeOnClick") 11631 }); 11632 const clientPoint = useClientPoint(floatingRootContext, { 11633 enabled: !disabled2 && trackCursorAxis !== "none", 11634 axis: trackCursorAxis === "none" ? void 0 : trackCursorAxis 11635 }); 11636 const activeTriggerProps = React71.useMemo(() => mergeProps(clientPoint.reference, dismiss.reference), [clientPoint.reference, dismiss.reference]); 11637 const inactiveTriggerProps = React71.useMemo(() => mergeProps(clientPoint.trigger, dismiss.trigger), [clientPoint.trigger, dismiss.trigger]); 11638 const popupProps = React71.useMemo(() => mergeProps(FOCUSABLE_POPUP_PROPS, clientPoint.floating, dismiss.floating), [clientPoint.floating, dismiss.floating]); 11639 usePopupInteractionProps(store, { 11640 activeTriggerProps, 11641 inactiveTriggerProps, 11642 popupProps 11643 }); 11644 return null; 11645 } 11646 11647 // node_modules/@base-ui/react/tooltip/trigger/TooltipTrigger.mjs 11648 var React73 = __toESM(require_react(), 1); 11649 11650 // node_modules/@base-ui/react/tooltip/provider/TooltipProviderContext.mjs 11651 var React72 = __toESM(require_react(), 1); 11652 var TooltipProviderContext = /* @__PURE__ */ React72.createContext(void 0); 11653 if (true) TooltipProviderContext.displayName = "TooltipProviderContext"; 11654 function useTooltipProviderContext() { 11655 return React72.useContext(TooltipProviderContext); 11656 } 11657 11658 // node_modules/@base-ui/react/tooltip/trigger/TooltipTriggerDataAttributes.mjs 11659 var TooltipTriggerDataAttributes = (function(TooltipTriggerDataAttributes2) { 11660 TooltipTriggerDataAttributes2[TooltipTriggerDataAttributes2["popupOpen"] = CommonTriggerDataAttributes.popupOpen] = "popupOpen"; 11661 TooltipTriggerDataAttributes2["triggerDisabled"] = "data-trigger-disabled"; 11662 return TooltipTriggerDataAttributes2; 11663 })({}); 11664 11665 // node_modules/@base-ui/react/tooltip/utils/constants.mjs 11666 var OPEN_DELAY2 = 600; 11667 11668 // node_modules/@base-ui/react/tooltip/trigger/TooltipTrigger.mjs 11669 var TOOLTIP_TRIGGER_IDENTIFIER = "data-base-ui-tooltip-trigger"; 11670 function getTargetElement(event) { 11671 if ("composedPath" in event) { 11672 const path = event.composedPath(); 11673 for (let i2 = 0; i2 < path.length; i2 += 1) { 11674 const element = path[i2]; 11675 if (isElement(element)) { 11676 return element; 11677 } 11678 } 11679 } 11680 const target = event.target; 11681 if (isElement(target)) { 11682 return target; 11683 } 11684 return null; 11685 } 11686 function closestEnabledTooltipTrigger(element) { 11687 let current = element; 11688 while (current) { 11689 if (current.hasAttribute(TOOLTIP_TRIGGER_IDENTIFIER)) { 11690 return current; 11691 } 11692 const parentElement = current.parentElement; 11693 if (parentElement) { 11694 current = parentElement; 11695 continue; 11696 } 11697 const root = current.getRootNode(); 11698 current = "host" in root && isElement(root.host) ? root.host : null; 11699 } 11700 return null; 11701 } 11702 var TooltipTrigger = fastComponentRef(function TooltipTrigger2(componentProps, forwardedRef) { 11703 const { 11704 render: render4, 11705 className, 11706 style, 11707 handle, 11708 payload, 11709 disabled: disabledProp, 11710 delay, 11711 closeOnClick = true, 11712 closeDelay, 11713 id: idProp, 11714 ...elementProps 11715 } = componentProps; 11716 const rootContext = useTooltipRootContext(true); 11717 const store = handle?.store ?? rootContext; 11718 if (!store) { 11719 throw new Error(true ? "Base UI: <Tooltip.Trigger> must be either used within a <Tooltip.Root> component or provided with a handle." : formatErrorMessage_default(82)); 11720 } 11721 const thisTriggerId = useBaseUiId(idProp); 11722 const isTriggerActive = store.useState("isTriggerActive", thisTriggerId); 11723 const isOpenedByThisTrigger = store.useState("isOpenedByTrigger", thisTriggerId); 11724 const floatingRootContext = store.useState("floatingRootContext"); 11725 const triggerElementRef = React73.useRef(null); 11726 const delayWithDefault = delay ?? OPEN_DELAY2; 11727 const closeDelayWithDefault = closeDelay ?? 0; 11728 const { 11729 registerTrigger, 11730 isMountedByThisTrigger 11731 } = useTriggerDataForwarding(thisTriggerId, triggerElementRef, store, { 11732 payload, 11733 closeOnClick, 11734 closeDelay: closeDelayWithDefault 11735 }); 11736 const providerContext = useTooltipProviderContext(); 11737 const { 11738 delayRef, 11739 isInstantPhase, 11740 hasProvider 11741 } = useDelayGroup(floatingRootContext, { 11742 open: isOpenedByThisTrigger 11743 }); 11744 const hoverInteraction = useHoverInteractionSharedState(floatingRootContext); 11745 store.useSyncedValue("isInstantPhase", isInstantPhase); 11746 const rootDisabled = store.useState("disabled"); 11747 const disabled2 = disabledProp ?? rootDisabled; 11748 const disabledRef = useValueAsRef(disabled2); 11749 const trackCursorAxis = store.useState("trackCursorAxis"); 11750 const disableHoverablePopup = store.useState("disableHoverablePopup"); 11751 const isNestedTriggerHoveredRef = React73.useRef(false); 11752 const nestedTriggerOpenTimeout = useTimeout(); 11753 const pointerTypeRef = React73.useRef(void 0); 11754 function getOpenDelay() { 11755 const providerDelay = providerContext?.delay; 11756 const groupOpenValue = typeof delayRef.current === "object" ? delayRef.current.open : void 0; 11757 let computedOpenDelay = delayWithDefault; 11758 if (hasProvider) { 11759 if (groupOpenValue !== 0) { 11760 computedOpenDelay = delay ?? providerDelay ?? delayWithDefault; 11761 } else { 11762 computedOpenDelay = 0; 11763 } 11764 } 11765 return computedOpenDelay; 11766 } 11767 function isEnabledNestedTriggerTarget(target) { 11768 const triggerEl = triggerElementRef.current; 11769 if (!triggerEl || !target) { 11770 return false; 11771 } 11772 const nearestTrigger = closestEnabledTooltipTrigger(target); 11773 return nearestTrigger !== null && nearestTrigger !== triggerEl && contains(triggerEl, nearestTrigger); 11774 } 11775 function detectNestedTriggerHover(target) { 11776 const nestedTriggerHovered = isEnabledNestedTriggerTarget(target); 11777 isNestedTriggerHoveredRef.current = nestedTriggerHovered; 11778 if (nestedTriggerHovered) { 11779 hoverInteraction.openChangeTimeout.clear(); 11780 hoverInteraction.restTimeout.clear(); 11781 hoverInteraction.restTimeoutPending = false; 11782 nestedTriggerOpenTimeout.clear(); 11783 } 11784 return nestedTriggerHovered; 11785 } 11786 const hoverProps = useHoverReferenceInteraction(floatingRootContext, { 11787 enabled: !disabled2, 11788 mouseOnly: true, 11789 move: false, 11790 handleClose: !disableHoverablePopup && trackCursorAxis !== "both" ? safePolygon() : null, 11791 restMs: getOpenDelay, 11792 delay() { 11793 const closeValue = typeof delayRef.current === "object" ? delayRef.current.close : void 0; 11794 let computedCloseDelay = closeDelayWithDefault; 11795 if (closeDelay == null && hasProvider) { 11796 computedCloseDelay = closeValue; 11797 } 11798 return { 11799 close: computedCloseDelay 11800 }; 11801 }, 11802 triggerElementRef, 11803 isActiveTrigger: isTriggerActive, 11804 isClosing: () => store.select("transitionStatus") === "ending", 11805 shouldOpen() { 11806 return !isNestedTriggerHoveredRef.current; 11807 } 11808 }); 11809 const focusProps = useFocus(floatingRootContext, { 11810 enabled: !disabled2 11811 }).reference; 11812 const handleNestedTriggerHover = (event) => { 11813 const wasNestedTriggerHovered = isNestedTriggerHoveredRef.current; 11814 const target = getTargetElement(event); 11815 const nestedTriggerHovered = detectNestedTriggerHover(target); 11816 const triggerEl = triggerElementRef.current; 11817 const targetInsideTrigger = triggerEl && target && contains(triggerEl, target); 11818 if (nestedTriggerHovered && store.select("open") && store.select("lastOpenChangeReason") === reason_parts_exports.triggerHover) { 11819 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event)); 11820 return; 11821 } 11822 if (wasNestedTriggerHovered && !nestedTriggerHovered && targetInsideTrigger && !disabledRef.current && !store.select("open") && triggerEl && // Match the hover hook's non-strict mouse fallback for mouse-only event sequences. 11823 isMouseLikePointerType(pointerTypeRef.current)) { 11824 const open = () => { 11825 if (!isNestedTriggerHoveredRef.current && !disabledRef.current && !store.select("open")) { 11826 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerEl)); 11827 } 11828 }; 11829 const openDelay = getOpenDelay(); 11830 if (openDelay === 0) { 11831 nestedTriggerOpenTimeout.clear(); 11832 open(); 11833 } else { 11834 nestedTriggerOpenTimeout.start(openDelay, open); 11835 } 11836 } 11837 }; 11838 const rootTriggerProps = store.useState("triggerProps", isMountedByThisTrigger); 11839 const shouldApplyRootTriggerProps = isMountedByThisTrigger || trackCursorAxis !== "none"; 11840 const state = { 11841 open: isOpenedByThisTrigger 11842 }; 11843 const element = useRenderElement("button", componentProps, { 11844 state, 11845 ref: [forwardedRef, registerTrigger, triggerElementRef], 11846 props: [hoverProps, focusProps, shouldApplyRootTriggerProps ? rootTriggerProps : void 0, { 11847 onMouseOver(event) { 11848 handleNestedTriggerHover(event.nativeEvent); 11849 }, 11850 onFocus(event) { 11851 if (isEnabledNestedTriggerTarget(getTargetElement(event.nativeEvent))) { 11852 event.preventBaseUIHandler(); 11853 } 11854 }, 11855 onMouseLeave() { 11856 isNestedTriggerHoveredRef.current = false; 11857 nestedTriggerOpenTimeout.clear(); 11858 pointerTypeRef.current = void 0; 11859 }, 11860 onPointerEnter(event) { 11861 pointerTypeRef.current = event.pointerType; 11862 }, 11863 onPointerDown(event) { 11864 pointerTypeRef.current = event.pointerType; 11865 store.set("closeOnClick", closeOnClick); 11866 if (closeOnClick && !store.select("open")) { 11867 store.cancelPendingOpen(event.nativeEvent); 11868 } 11869 }, 11870 onClick(event) { 11871 if (closeOnClick && !store.select("open")) { 11872 store.cancelPendingOpen(event.nativeEvent); 11873 } 11874 }, 11875 id: thisTriggerId, 11876 [TooltipTriggerDataAttributes.triggerDisabled]: disabled2 ? "" : void 0, 11877 [TOOLTIP_TRIGGER_IDENTIFIER]: disabled2 ? void 0 : "" 11878 }, elementProps], 11879 stateAttributesMapping: triggerOpenStateMapping2 11880 }); 11881 return element; 11882 }); 11883 if (true) TooltipTrigger.displayName = "TooltipTrigger"; 11884 11885 // node_modules/@base-ui/react/tooltip/portal/TooltipPortal.mjs 11886 var React75 = __toESM(require_react(), 1); 11887 11888 // node_modules/@base-ui/react/tooltip/portal/TooltipPortalContext.mjs 11889 var React74 = __toESM(require_react(), 1); 11890 var TooltipPortalContext = /* @__PURE__ */ React74.createContext(void 0); 11891 if (true) TooltipPortalContext.displayName = "TooltipPortalContext"; 11892 function useTooltipPortalContext() { 11893 const value = React74.useContext(TooltipPortalContext); 11894 if (value === void 0) { 11895 throw new Error(true ? "Base UI: <Tooltip.Portal> is missing." : formatErrorMessage_default(70)); 11896 } 11897 return value; 11898 } 11899 11900 // node_modules/@base-ui/react/tooltip/portal/TooltipPortal.mjs 11901 var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1); 11902 var TooltipPortal = /* @__PURE__ */ React75.forwardRef(function TooltipPortal2(props, forwardedRef) { 11903 const { 11904 keepMounted = false, 11905 ...portalProps 11906 } = props; 11907 const store = useTooltipRootContext(); 11908 const mounted = store.useState("mounted"); 11909 const shouldRender = mounted || keepMounted; 11910 if (!shouldRender) { 11911 return null; 11912 } 11913 return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(TooltipPortalContext.Provider, { 11914 value: keepMounted, 11915 children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(FloatingPortalLite, { 11916 ref: forwardedRef, 11917 ...portalProps 11918 }) 11919 }); 11920 }); 11921 if (true) TooltipPortal.displayName = "TooltipPortal"; 11922 11923 // node_modules/@base-ui/react/tooltip/positioner/TooltipPositioner.mjs 11924 var React77 = __toESM(require_react(), 1); 11925 11926 // node_modules/@base-ui/react/tooltip/positioner/TooltipPositionerContext.mjs 11927 var React76 = __toESM(require_react(), 1); 11928 var TooltipPositionerContext = /* @__PURE__ */ React76.createContext(void 0); 11929 if (true) TooltipPositionerContext.displayName = "TooltipPositionerContext"; 11930 function useTooltipPositionerContext() { 11931 const context = React76.useContext(TooltipPositionerContext); 11932 if (context === void 0) { 11933 throw new Error(true ? "Base UI: TooltipPositionerContext is missing. TooltipPositioner parts must be placed within <Tooltip.Positioner>." : formatErrorMessage_default(71)); 11934 } 11935 return context; 11936 } 11937 11938 // node_modules/@base-ui/react/tooltip/positioner/TooltipPositioner.mjs 11939 var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1); 11940 var TooltipPositioner = /* @__PURE__ */ React77.forwardRef(function TooltipPositioner2(componentProps, forwardedRef) { 11941 const { 11942 render: render4, 11943 className, 11944 anchor, 11945 positionMethod = "absolute", 11946 side = "top", 11947 align = "center", 11948 sideOffset = 0, 11949 alignOffset = 0, 11950 collisionBoundary = "clipping-ancestors", 11951 collisionPadding = 5, 11952 arrowPadding = 5, 11953 sticky = false, 11954 disableAnchorTracking = false, 11955 collisionAvoidance = POPUP_COLLISION_AVOIDANCE, 11956 style, 11957 ...elementProps 11958 } = componentProps; 11959 const store = useTooltipRootContext(); 11960 const keepMounted = useTooltipPortalContext(); 11961 const open = store.useState("open"); 11962 const mounted = store.useState("mounted"); 11963 const trackCursorAxis = store.useState("trackCursorAxis"); 11964 const disableHoverablePopup = store.useState("disableHoverablePopup"); 11965 const floatingRootContext = store.useState("floatingRootContext"); 11966 const instantType = store.useState("instantType"); 11967 const transitionStatus = store.useState("transitionStatus"); 11968 const hasViewport = store.useState("hasViewport"); 11969 const positioning = useAnchorPositioning({ 11970 anchor, 11971 positionMethod, 11972 floatingRootContext, 11973 mounted, 11974 side, 11975 sideOffset, 11976 align, 11977 alignOffset, 11978 collisionBoundary, 11979 collisionPadding, 11980 sticky, 11981 arrowPadding, 11982 disableAnchorTracking, 11983 keepMounted, 11984 collisionAvoidance, 11985 adaptiveOrigin: hasViewport ? adaptiveOrigin : void 0 11986 }); 11987 const state = React77.useMemo(() => ({ 11988 open, 11989 side: positioning.side, 11990 align: positioning.align, 11991 anchorHidden: positioning.anchorHidden, 11992 instant: trackCursorAxis !== "none" ? "tracking-cursor" : instantType 11993 }), [open, positioning.side, positioning.align, positioning.anchorHidden, trackCursorAxis, instantType]); 11994 const element = usePositioner(componentProps, state, { 11995 styles: positioning.positionerStyles, 11996 transitionStatus, 11997 props: elementProps, 11998 refs: [forwardedRef, store.useStateSetter("positionerElement")], 11999 hidden: !mounted, 12000 inert: !open || trackCursorAxis === "both" || disableHoverablePopup 12001 }); 12002 return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(TooltipPositionerContext.Provider, { 12003 value: positioning, 12004 children: element 12005 }); 12006 }); 12007 if (true) TooltipPositioner.displayName = "TooltipPositioner"; 12008 12009 // node_modules/@base-ui/react/tooltip/popup/TooltipPopup.mjs 12010 var React78 = __toESM(require_react(), 1); 12011 var stateAttributesMapping5 = { 12012 ...popupStateMapping, 12013 ...transitionStatusMapping 12014 }; 12015 var TooltipPopup = /* @__PURE__ */ React78.forwardRef(function TooltipPopup2(componentProps, forwardedRef) { 12016 const { 12017 render: render4, 12018 className, 12019 style, 12020 ...elementProps 12021 } = componentProps; 12022 const store = useTooltipRootContext(); 12023 const { 12024 side, 12025 align 12026 } = useTooltipPositionerContext(); 12027 const open = store.useState("open"); 12028 const instantType = store.useState("instantType"); 12029 const transitionStatus = store.useState("transitionStatus"); 12030 const popupProps = store.useState("popupProps"); 12031 const floatingContext = store.useState("floatingRootContext"); 12032 const disabled2 = store.useState("disabled"); 12033 const closeDelay = store.useState("closeDelay"); 12034 useOpenChangeComplete({ 12035 open, 12036 ref: store.context.popupRef, 12037 onComplete() { 12038 if (open) { 12039 store.context.onOpenChangeComplete?.(true); 12040 } 12041 } 12042 }); 12043 useHoverFloatingInteraction(floatingContext, { 12044 enabled: !disabled2, 12045 closeDelay 12046 }); 12047 const setPopupElement = store.useStateSetter("popupElement"); 12048 const state = { 12049 open, 12050 side, 12051 align, 12052 instant: instantType, 12053 transitionStatus 12054 }; 12055 const element = useRenderElement("div", componentProps, { 12056 state, 12057 ref: [forwardedRef, store.context.popupRef, setPopupElement], 12058 props: [popupProps, getDisabledMountTransitionStyles(transitionStatus), elementProps], 12059 stateAttributesMapping: stateAttributesMapping5 12060 }); 12061 return element; 12062 }); 12063 if (true) TooltipPopup.displayName = "TooltipPopup"; 12064 12065 // node_modules/@base-ui/react/tooltip/arrow/TooltipArrow.mjs 12066 var React79 = __toESM(require_react(), 1); 12067 var TooltipArrow = /* @__PURE__ */ React79.forwardRef(function TooltipArrow2(componentProps, forwardedRef) { 12068 const { 12069 render: render4, 12070 className, 12071 style, 12072 ...elementProps 12073 } = componentProps; 12074 const store = useTooltipRootContext(); 12075 const { 12076 arrowRef, 12077 side, 12078 align, 12079 arrowUncentered, 12080 arrowStyles 12081 } = useTooltipPositionerContext(); 12082 const open = store.useState("open"); 12083 const instantType = store.useState("instantType"); 12084 const state = { 12085 open, 12086 side, 12087 align, 12088 uncentered: arrowUncentered, 12089 instant: instantType 12090 }; 12091 const element = useRenderElement("div", componentProps, { 12092 state, 12093 ref: [forwardedRef, arrowRef], 12094 props: [{ 12095 style: arrowStyles, 12096 "aria-hidden": true 12097 }, elementProps], 12098 stateAttributesMapping: popupStateMapping 12099 }); 12100 return element; 12101 }); 12102 if (true) TooltipArrow.displayName = "TooltipArrow"; 12103 12104 // node_modules/@base-ui/react/tooltip/provider/TooltipProvider.mjs 12105 var React80 = __toESM(require_react(), 1); 12106 var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1); 12107 var TooltipProvider = function TooltipProvider2(props) { 12108 const { 12109 delay, 12110 closeDelay, 12111 timeout = 400 12112 } = props; 12113 const contextValue = React80.useMemo(() => ({ 12114 delay, 12115 closeDelay 12116 }), [delay, closeDelay]); 12117 const delayValue = React80.useMemo(() => ({ 12118 open: delay, 12119 close: closeDelay 12120 }), [delay, closeDelay]); 12121 return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(TooltipProviderContext.Provider, { 12122 value: contextValue, 12123 children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(FloatingDelayGroup, { 12124 delay: delayValue, 12125 timeoutMs: timeout, 12126 children: props.children 12127 }) 12128 }); 12129 }; 12130 if (true) TooltipProvider.displayName = "TooltipProvider"; 12131 12132 // node_modules/@base-ui/react/tooltip/viewport/TooltipViewport.mjs 12133 var React81 = __toESM(require_react(), 1); 12134 12135 // node_modules/@base-ui/react/tooltip/viewport/TooltipViewportCssVars.mjs 12136 var TooltipViewportCssVars = /* @__PURE__ */ (function(TooltipViewportCssVars2) { 12137 TooltipViewportCssVars2["popupWidth"] = "--popup-width"; 12138 TooltipViewportCssVars2["popupHeight"] = "--popup-height"; 12139 return TooltipViewportCssVars2; 12140 })({}); 12141 12142 // node_modules/@base-ui/react/tooltip/viewport/TooltipViewport.mjs 12143 var stateAttributesMapping6 = { 12144 activationDirection: (value) => value ? { 12145 "data-activation-direction": value 12146 } : null 12147 }; 12148 var TooltipViewport = /* @__PURE__ */ React81.forwardRef(function TooltipViewport2(componentProps, forwardedRef) { 12149 const { 12150 render: render4, 12151 className, 12152 style, 12153 children, 12154 ...elementProps 12155 } = componentProps; 12156 const store = useTooltipRootContext(); 12157 const positioner = useTooltipPositionerContext(); 12158 const instantType = store.useState("instantType"); 12159 const { 12160 children: childrenToRender, 12161 state: viewportState 12162 } = usePopupViewport({ 12163 store, 12164 side: positioner.side, 12165 cssVars: TooltipViewportCssVars, 12166 children 12167 }); 12168 const state = { 12169 activationDirection: viewportState.activationDirection, 12170 transitioning: viewportState.transitioning, 12171 instant: instantType 12172 }; 12173 return useRenderElement("div", componentProps, { 12174 state, 12175 ref: forwardedRef, 12176 props: [elementProps, { 12177 children: childrenToRender 12178 }], 12179 stateAttributesMapping: stateAttributesMapping6 12180 }); 12181 }); 12182 if (true) TooltipViewport.displayName = "TooltipViewport"; 12183 12184 // node_modules/@base-ui/react/tooltip/store/TooltipHandle.mjs 12185 var TooltipHandle = class { 12186 /** 12187 * Internal store holding the tooltip state. 12188 * @internal 12189 */ 12190 constructor() { 12191 this.store = new TooltipStore(); 12192 } 12193 /** 12194 * Opens the tooltip and associates it with the trigger with the given ID. 12195 * The trigger must be a Tooltip.Trigger component with this handle passed as a prop. 12196 * 12197 * This method should only be called in an event handler or an effect (not during rendering). 12198 * 12199 * @param triggerId ID of the trigger to associate with the tooltip. 12200 */ 12201 open(triggerId) { 12202 const triggerElement = triggerId ? this.store.context.triggerElements.getById(triggerId) : void 0; 12203 if (triggerId && !triggerElement) { 12204 throw new Error(true ? `Base UI: TooltipHandle.open: No trigger found with id "$triggerId}".` : formatErrorMessage_default(81, triggerId)); 12205 } 12206 this.store.setOpen(true, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, triggerElement)); 12207 } 12208 /** 12209 * Closes the tooltip. 12210 */ 12211 close() { 12212 this.store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, void 0)); 12213 } 12214 /** 12215 * Indicates whether the tooltip is currently open. 12216 */ 12217 get isOpen() { 12218 return this.store.select("open"); 12219 } 12220 }; 12221 function createTooltipHandle() { 12222 return new TooltipHandle(); 12223 } 12224 12225 // node_modules/@base-ui/react/use-render/useRender.mjs 12226 function useRender(params) { 12227 return useRenderElement(params.defaultTagName ?? "div", params, params); 12228 } 12229 12230 // packages/ui/build-module/text/text.mjs 12231 var import_element12 = __toESM(require_element(), 1); 12232 var STYLE_HASH_ATTRIBUTE = "data-wp-hash"; 12233 function getRuntime() { 12234 const globalScope = globalThis; 12235 if (globalScope.__wpStyleRuntime) { 12236 return globalScope.__wpStyleRuntime; 12237 } 12238 globalScope.__wpStyleRuntime = { 12239 documents: /* @__PURE__ */ new Map(), 12240 styles: /* @__PURE__ */ new Map(), 12241 injectedStyles: /* @__PURE__ */ new WeakMap() 12242 }; 12243 if (typeof document !== "undefined") { 12244 registerDocument(document); 12245 } 12246 return globalScope.__wpStyleRuntime; 12247 } 12248 function documentContainsStyleHash(targetDocument, hash) { 12249 if (!targetDocument.head) { 12250 return false; 12251 } 12252 for (const style of targetDocument.head.querySelectorAll( 12253 `style[$STYLE_HASH_ATTRIBUTE}]` 12254 )) { 12255 if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) { 12256 return true; 12257 } 12258 } 12259 return false; 12260 } 12261 function injectStyle(targetDocument, hash, css) { 12262 if (!targetDocument.head) { 12263 return; 12264 } 12265 const runtime = getRuntime(); 12266 let injectedStyles = runtime.injectedStyles.get(targetDocument); 12267 if (!injectedStyles) { 12268 injectedStyles = /* @__PURE__ */ new Set(); 12269 runtime.injectedStyles.set(targetDocument, injectedStyles); 12270 } 12271 if (injectedStyles.has(hash)) { 12272 return; 12273 } 12274 if (documentContainsStyleHash(targetDocument, hash)) { 12275 injectedStyles.add(hash); 12276 return; 12277 } 12278 const style = targetDocument.createElement("style"); 12279 style.setAttribute(STYLE_HASH_ATTRIBUTE, hash); 12280 style.appendChild(targetDocument.createTextNode(css)); 12281 targetDocument.head.appendChild(style); 12282 injectedStyles.add(hash); 12283 } 12284 function registerDocument(targetDocument) { 12285 const runtime = getRuntime(); 12286 runtime.documents.set( 12287 targetDocument, 12288 (runtime.documents.get(targetDocument) ?? 0) + 1 12289 ); 12290 for (const [hash, css] of runtime.styles) { 12291 injectStyle(targetDocument, hash, css); 12292 } 12293 return () => { 12294 const count = runtime.documents.get(targetDocument); 12295 if (count === void 0) { 12296 return; 12297 } 12298 if (count <= 1) { 12299 runtime.documents.delete(targetDocument); 12300 return; 12301 } 12302 runtime.documents.set(targetDocument, count - 1); 12303 }; 12304 } 12305 function registerStyle(hash, css) { 12306 const runtime = getRuntime(); 12307 runtime.styles.set(hash, css); 12308 for (const targetDocument of runtime.documents.keys()) { 12309 injectStyle(targetDocument, hash, css); 12310 } 12311 } 12312 if (typeof process === "undefined" || true) { 12313 registerStyle("a495f9d138", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._83ed8a8da5dd50ea__text{margin:0}._14437cfb77831647__heading-2xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-2xl,32px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-emphasis,600);--_gcd-p-font-size:var(--wpds-typography-font-size-2xl,32px);--_gcd-p-line-height:var(--wpds-typography-line-height-2xl,40px);font-size:var(--wpds-typography-font-size-2xl,32px);line-height:var(--wpds-typography-line-height-2xl,40px)}._14437cfb77831647__heading-2xl,._3c78b7fa9b4072dd__heading-xl{font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-emphasis,600)}._3c78b7fa9b4072dd__heading-xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-emphasis,600);--_gcd-p-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-p-line-height:var(--wpds-typography-line-height-md,24px);font-size:var(--wpds-typography-font-size-xl,20px);line-height:var(--wpds-typography-line-height-md,24px)}.aa58f227716bcde2__heading-lg{--_gcd-heading-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-emphasis,600);--_gcd-p-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-lg,15px)}.aa58f227716bcde2__heading-lg,.fc4da56d8dfe52c4__heading-md{font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-emphasis,600);line-height:var(--wpds-typography-line-height-sm,20px)}.fc4da56d8dfe52c4__heading-md{--_gcd-heading-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-emphasis,600);--_gcd-p-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-md,13px)}.a9b78c7c82e8dff7__heading-sm{--_gcd-heading-font-size:var(--wpds-typography-font-size-xs,11px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-emphasis,600);--_gcd-p-font-size:var(--wpds-typography-font-size-xs,11px);--_gcd-p-line-height:var(--wpds-typography-line-height-xs,16px);font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-xs,11px);font-weight:var(--wpds-typography-font-weight-emphasis,600);line-height:var(--wpds-typography-line-height-xs,16px);text-transform:uppercase}._305ff559e52180d5__body-xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-default,400);--_gcd-p-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-p-line-height:var(--wpds-typography-line-height-xl,32px);font-size:var(--wpds-typography-font-size-xl,20px);line-height:var(--wpds-typography-line-height-xl,32px)}._305ff559e52180d5__body-xl,.ca1aa3fc2029e958__body-lg{font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-default,400)}.ca1aa3fc2029e958__body-lg{--_gcd-heading-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-default,400);--_gcd-p-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-p-line-height:var(--wpds-typography-line-height-md,24px);font-size:var(--wpds-typography-font-size-lg,15px);line-height:var(--wpds-typography-line-height-md,24px)}._131101940be12424__body-md{--_gcd-heading-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-default,400);--_gcd-p-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-md,13px);line-height:var(--wpds-typography-line-height-sm,20px)}._0e8d87a42c1f75fa__body-sm,._131101940be12424__body-md{font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-default,400)}._0e8d87a42c1f75fa__body-sm{--_gcd-heading-font-size:var(--wpds-typography-font-size-sm,12px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-default,400);--_gcd-p-font-size:var(--wpds-typography-font-size-sm,12px);--_gcd-p-line-height:var(--wpds-typography-line-height-xs,16px);font-size:var(--wpds-typography-font-size-sm,12px);line-height:var(--wpds-typography-line-height-xs,16px)}}}'); 12314 } 12315 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" }; 12316 if (typeof process === "undefined" || true) { 12317 registerStyle("af6d9984a6", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,transparent);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 transparent);color:var(--_gcd-input-color,var(--wpds-color-foreground-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,transparent);border-color:var(--_gcd-input-border-color-disabled,transparent);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid transparent)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-foreground-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-emphasis,600));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid transparent);transition:var(--_gcd-a-transition,none)}"); 12318 } 12319 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" }; 12320 var Text = (0, import_element12.forwardRef)(function Text2({ variant = "body-md", render: render4, className, ...props }, ref) { 12321 const element = useRender({ 12322 render: render4, 12323 defaultTagName: "span", 12324 ref, 12325 props: mergeProps(props, { 12326 className: clsx_default( 12327 style_default.text, 12328 global_css_defense_default.heading, 12329 global_css_defense_default.p, 12330 style_default[variant], 12331 className 12332 ) 12333 }) 12334 }); 12335 return element; 12336 }); 12337 12338 // packages/ui/build-module/badge/badge.mjs 12339 var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1); 12340 var STYLE_HASH_ATTRIBUTE2 = "data-wp-hash"; 12341 function getRuntime2() { 12342 const globalScope = globalThis; 12343 if (globalScope.__wpStyleRuntime) { 12344 return globalScope.__wpStyleRuntime; 12345 } 12346 globalScope.__wpStyleRuntime = { 12347 documents: /* @__PURE__ */ new Map(), 12348 styles: /* @__PURE__ */ new Map(), 12349 injectedStyles: /* @__PURE__ */ new WeakMap() 12350 }; 12351 if (typeof document !== "undefined") { 12352 registerDocument2(document); 12353 } 12354 return globalScope.__wpStyleRuntime; 12355 } 12356 function documentContainsStyleHash2(targetDocument, hash) { 12357 if (!targetDocument.head) { 12358 return false; 12359 } 12360 for (const style of targetDocument.head.querySelectorAll( 12361 `style[$STYLE_HASH_ATTRIBUTE2}]` 12362 )) { 12363 if (style.getAttribute(STYLE_HASH_ATTRIBUTE2) === hash) { 12364 return true; 12365 } 12366 } 12367 return false; 12368 } 12369 function injectStyle2(targetDocument, hash, css) { 12370 if (!targetDocument.head) { 12371 return; 12372 } 12373 const runtime = getRuntime2(); 12374 let injectedStyles = runtime.injectedStyles.get(targetDocument); 12375 if (!injectedStyles) { 12376 injectedStyles = /* @__PURE__ */ new Set(); 12377 runtime.injectedStyles.set(targetDocument, injectedStyles); 12378 } 12379 if (injectedStyles.has(hash)) { 12380 return; 12381 } 12382 if (documentContainsStyleHash2(targetDocument, hash)) { 12383 injectedStyles.add(hash); 12384 return; 12385 } 12386 const style = targetDocument.createElement("style"); 12387 style.setAttribute(STYLE_HASH_ATTRIBUTE2, hash); 12388 style.appendChild(targetDocument.createTextNode(css)); 12389 targetDocument.head.appendChild(style); 12390 injectedStyles.add(hash); 12391 } 12392 function registerDocument2(targetDocument) { 12393 const runtime = getRuntime2(); 12394 runtime.documents.set( 12395 targetDocument, 12396 (runtime.documents.get(targetDocument) ?? 0) + 1 12397 ); 12398 for (const [hash, css] of runtime.styles) { 12399 injectStyle2(targetDocument, hash, css); 12400 } 12401 return () => { 12402 const count = runtime.documents.get(targetDocument); 12403 if (count === void 0) { 12404 return; 12405 } 12406 if (count <= 1) { 12407 runtime.documents.delete(targetDocument); 12408 return; 12409 } 12410 runtime.documents.set(targetDocument, count - 1); 12411 }; 12412 } 12413 function registerStyle2(hash, css) { 12414 const runtime = getRuntime2(); 12415 runtime.styles.set(hash, css); 12416 for (const targetDocument of runtime.documents.keys()) { 12417 injectStyle2(targetDocument, hash, css); 12418 } 12419 } 12420 if (typeof process === "undefined" || true) { 12421 registerStyle2("9db2873e7f", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._96e6251aad1a6136__badge{border-radius:var(--wpds-border-radius-lg,8px);padding-block:var(--wpds-dimension-padding-xs,4px);padding-inline:var(--wpds-dimension-padding-sm,8px)}._99f7158cb520f750__is-high-intent{background-color:var(--wpds-color-background-surface-error,#f6e6e3);color:var(--wpds-color-foreground-content-error,#470000)}.c20ebef2365bc8b7__is-medium-intent{background-color:var(--wpds-color-background-surface-warning,#fde6be);color:var(--wpds-color-foreground-content-warning,#2e1900)}._365e1626c6202e52__is-low-intent{background-color:var(--wpds-color-background-surface-caution,#fee995);color:var(--wpds-color-foreground-content-caution,#281d00)}._33f8198127ddf4ef__is-stable-intent{background-color:var(--wpds-color-background-surface-success,#c6f7cd);color:var(--wpds-color-foreground-content-success,#002900)}._04c1aca8fc449412__is-informational-intent{background-color:var(--wpds-color-background-surface-info,#deebfa);color:var(--wpds-color-foreground-content-info,#001b4f)}._90726e69d495ec19__is-draft-intent{background-color:var(--wpds-color-background-surface-neutral-weak,#f4f4f4);color:var(--wpds-color-foreground-content-neutral,#1e1e1e)}._898f4a544993bd39__is-none-intent{background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral,#dbdbdb);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);padding-block:calc(var(--wpds-dimension-padding-xs, 4px) - var(--wpds-border-width-xs, 1px));padding-inline:calc(var(--wpds-dimension-padding-sm, 8px) - var(--wpds-border-width-xs, 1px))}}}"); 12422 } 12423 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" }; 12424 var Badge = (0, import_element13.forwardRef)(function Badge2({ intent = "none", className, ...props }, ref) { 12425 return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)( 12426 Text, 12427 { 12428 ref, 12429 className: clsx_default( 12430 style_default2.badge, 12431 style_default2[`is-$intent}-intent`], 12432 className 12433 ), 12434 ...props, 12435 variant: "body-sm" 12436 } 12437 ); 12438 }); 12439 12440 // packages/ui/build-module/button/button.mjs 12441 var import_element14 = __toESM(require_element(), 1); 12442 var import_i18n = __toESM(require_i18n(), 1); 12443 var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1); 12444 import { speak } from "@wordpress/a11y"; 12445 var STYLE_HASH_ATTRIBUTE3 = "data-wp-hash"; 12446 function getRuntime3() { 12447 const globalScope = globalThis; 12448 if (globalScope.__wpStyleRuntime) { 12449 return globalScope.__wpStyleRuntime; 12450 } 12451 globalScope.__wpStyleRuntime = { 12452 documents: /* @__PURE__ */ new Map(), 12453 styles: /* @__PURE__ */ new Map(), 12454 injectedStyles: /* @__PURE__ */ new WeakMap() 12455 }; 12456 if (typeof document !== "undefined") { 12457 registerDocument3(document); 12458 } 12459 return globalScope.__wpStyleRuntime; 12460 } 12461 function documentContainsStyleHash3(targetDocument, hash) { 12462 if (!targetDocument.head) { 12463 return false; 12464 } 12465 for (const style of targetDocument.head.querySelectorAll( 12466 `style[$STYLE_HASH_ATTRIBUTE3}]` 12467 )) { 12468 if (style.getAttribute(STYLE_HASH_ATTRIBUTE3) === hash) { 12469 return true; 12470 } 12471 } 12472 return false; 12473 } 12474 function injectStyle3(targetDocument, hash, css) { 12475 if (!targetDocument.head) { 12476 return; 12477 } 12478 const runtime = getRuntime3(); 12479 let injectedStyles = runtime.injectedStyles.get(targetDocument); 12480 if (!injectedStyles) { 12481 injectedStyles = /* @__PURE__ */ new Set(); 12482 runtime.injectedStyles.set(targetDocument, injectedStyles); 12483 } 12484 if (injectedStyles.has(hash)) { 12485 return; 12486 } 12487 if (documentContainsStyleHash3(targetDocument, hash)) { 12488 injectedStyles.add(hash); 12489 return; 12490 } 12491 const style = targetDocument.createElement("style"); 12492 style.setAttribute(STYLE_HASH_ATTRIBUTE3, hash); 12493 style.appendChild(targetDocument.createTextNode(css)); 12494 targetDocument.head.appendChild(style); 12495 injectedStyles.add(hash); 12496 } 12497 function registerDocument3(targetDocument) { 12498 const runtime = getRuntime3(); 12499 runtime.documents.set( 12500 targetDocument, 12501 (runtime.documents.get(targetDocument) ?? 0) + 1 12502 ); 12503 for (const [hash, css] of runtime.styles) { 12504 injectStyle3(targetDocument, hash, css); 12505 } 12506 return () => { 12507 const count = runtime.documents.get(targetDocument); 12508 if (count === void 0) { 12509 return; 12510 } 12511 if (count <= 1) { 12512 runtime.documents.delete(targetDocument); 12513 return; 12514 } 12515 runtime.documents.set(targetDocument, count - 1); 12516 }; 12517 } 12518 function registerStyle3(hash, css) { 12519 const runtime = getRuntime3(); 12520 runtime.styles.set(hash, css); 12521 for (const targetDocument of runtime.documents.keys()) { 12522 injectStyle3(targetDocument, hash, css); 12523 } 12524 } 12525 if (typeof process === "undefined" || true) { 12526 registerStyle3("b74f1ac304", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._97b0fc33c028be1a__button,.abbb272e2ce49bd6__is-unstyled{appearance:none;padding:0}._97b0fc33c028be1a__button{--wp-ui-button-font-weight:var(--wpds-typography-font-weight-emphasis,600);--wp-ui-button-background-color:var(--wpds-color-background-interactive-brand-strong,var(--wp-admin-theme-color,#3858e9));--wp-ui-button-background-color-active:var(--wpds-color-background-interactive-brand-strong-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 93%,#000));--wp-ui-button-background-color-disabled:var(--wpds-color-background-interactive-brand-strong-disabled,#e6e6e6);--wp-ui-button-foreground-color:var(--wpds-color-foreground-interactive-brand-strong,#fff);--wp-ui-button-foreground-color-active:var(--wpds-color-foreground-interactive-brand-strong-active,#fff);--wp-ui-button-foreground-color-disabled:var(--wpds-color-foreground-interactive-brand-strong-disabled,#8d8d8d);--wp-ui-button-padding-block:var(--wpds-dimension-padding-xs,4px);--wp-ui-button-padding-inline:var(--wpds-dimension-padding-md,12px);--wp-ui-button-height:var(--wpds-dimension-size-lg,40px);--wp-ui-button-aspect-ratio:auto;--wp-ui-button-font-size:var(--wpds-typography-font-size-md,13px);--wp-ui-button-min-width:calc(4ch + var(--wp-ui-button-padding-inline)*2);--wp-ui-button-icon-margin:calc((var(--wpds-dimension-size-2xs, 16px) - var(--wpds-dimension-size-sm, 24px))/2);--wp-ui-button-border-color:var(--wp-ui-button-background-color);--wp-ui-button-border-color-active:var(--wp-ui-button-background-color-active);--wp-ui-button-border-color-disabled:var(--wp-ui-button-background-color-disabled);--_gcd-button-font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);--_gcd-button-font-size:var(--wp-ui-button-font-size);--_gcd-button-font-weight:var(--wp-ui-button-font-weight);align-items:center;aspect-ratio:var(--wp-ui-button-aspect-ratio);background-clip:border-box;background-color:var(--wp-ui-button-background-color);border-color:var(--wp-ui-button-border-color);border-radius:var(--wpds-border-radius-sm,2px);border-style:solid;border-width:1px;color:var(--wp-ui-button-foreground-color);display:inline-flex;font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wp-ui-button-font-size);font-weight:var(--wp-ui-button-font-weight);gap:var(--wpds-dimension-gap-sm,8px);justify-content:center;line-height:var(--wpds-typography-line-height-sm,20px);max-width:100%;min-height:var(--wp-ui-button-height);min-width:var(--wp-ui-button-min-width);overflow-wrap:anywhere;padding-block:var(--wp-ui-button-padding-block);padding-inline:var(--wp-ui-button-padding-inline);position:relative;text-align:center;text-decoration:none;&:not([data-disabled]){cursor:var(--wpds-cursor-control,pointer)}@media not (prefers-reduced-motion){transition:color .1s ease-out;*{transition:opacity .1s ease-out}}&[href]{cursor:pointer}[href]{color:inherit;text-decoration:inherit}&:not([data-disabled]):is(:hover,:active,:focus){background-color:var(--wp-ui-button-background-color-active);border-color:var(--wp-ui-button-border-color-active);color:var(--wp-ui-button-foreground-color-active)}&[data-disabled]:not(._914b42f315c0e580__is-loading){background-color:var(--wp-ui-button-background-color-disabled);border-color:var(--wp-ui-button-border-color-disabled);color:var(--wp-ui-button-foreground-color-disabled);@media (forced-colors:active){border-bottom-color:GrayText;border-left-color:GrayText;border-right-color:GrayText;border-top-color:GrayText;color:GrayText}}&:before{aspect-ratio:1;border:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid;border-block-end-color:transparent;border-block-start-color:var(--wp-ui-button-foreground-color);border-inline-end-color:var(--wp-ui-button-foreground-color);border-inline-start-color:transparent;border-radius:50%;box-sizing:border-box;content:"";display:block;height:var(--wp-ui-button-font-size);inset-inline-start:50%;opacity:0;pointer-events:none;position:absolute;top:50%;transform:translate(-50%,-50%);@media not (prefers-reduced-motion){transition:opacity .1s ease-out}@media (forced-colors:active){border-block-end-style:none;border-bottom-color:ButtonText;border-inline-start-style:none;border-left-color:ButtonText;border-right-color:ButtonText;border-top-color:ButtonText}}}._908205475f9f2a92__is-small{--wp-ui-button-padding-block:0px;--wp-ui-button-padding-inline:var(--wpds-dimension-padding-sm,8px);--wp-ui-button-height:var(--wpds-dimension-size-sm,24px)}._9f6fc6553aeb36fe__icon{margin:var(--wp-ui-button-icon-margin)}.dd460c965226cc77__is-brand{&._62d5a778b7b258ee__is-outline,&.ad0619a3217c6a5b__is-minimal{--wp-ui-button-foreground-color:var(--wpds-color-foreground-interactive-brand,var(--wp-admin-theme-color,#3858e9));--wp-ui-button-foreground-color-active:var(--wpds-color-foreground-interactive-brand-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 52%,#000));--wp-ui-button-foreground-color-disabled:var(--wpds-color-foreground-interactive-brand-disabled,#8d8d8d)}&._62d5a778b7b258ee__is-outline{--wp-ui-button-background-color:var(--wpds-color-background-interactive-brand-weak,#0000);--wp-ui-button-background-color-active:var(--wpds-color-background-interactive-brand-weak-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 12%,#fff));--wp-ui-button-background-color-disabled:var(--wpds-color-background-interactive-brand-weak-disabled,#0000);--wp-ui-button-border-color:var(--wpds-color-stroke-interactive-brand,var(--wp-admin-theme-color,#3858e9));--wp-ui-button-border-color-active:var(--wpds-color-stroke-interactive-brand-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 85%,#000));--wp-ui-button-border-color-disabled:var(--wpds-color-stroke-interactive-brand-disabled,#dbdbdb)}&.ad0619a3217c6a5b__is-minimal{--wp-ui-button-background-color:var(--wpds-color-background-interactive-brand-weak,#0000);--wp-ui-button-background-color-active:var(--wpds-color-background-interactive-brand-weak-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 12%,#fff));--wp-ui-button-background-color-disabled:var(--wpds-color-background-interactive-brand-weak-disabled,#0000)}}.e722a8f96726aa99__is-neutral{&.ad0619a3217c6a5b__is-minimal[aria-pressed=true],&.b50b3358c5fb4d0b__is-solid{--wp-ui-button-background-color:var(--wpds-color-background-interactive-neutral-strong,#2d2d2d);--wp-ui-button-background-color-active:var(--wpds-color-background-interactive-neutral-strong-active,#1e1e1e);--wp-ui-button-background-color-disabled:var(--wpds-color-background-interactive-neutral-strong-disabled,#e6e6e6);--wp-ui-button-foreground-color:var(--wpds-color-foreground-interactive-neutral-strong,#f0f0f0);--wp-ui-button-foreground-color-active:var(--wpds-color-foreground-interactive-neutral-strong-active,#f0f0f0);--wp-ui-button-foreground-color-disabled:var(--wpds-color-foreground-interactive-neutral-strong-disabled,#8d8d8d)}&._62d5a778b7b258ee__is-outline,&.ad0619a3217c6a5b__is-minimal:not([aria-pressed=true]){--wp-ui-button-foreground-color:var(--wpds-color-foreground-interactive-neutral,#1e1e1e);--wp-ui-button-foreground-color-active:var(--wpds-color-foreground-interactive-neutral-active,#1e1e1e);--wp-ui-button-foreground-color-disabled:var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d)}&._62d5a778b7b258ee__is-outline{--wp-ui-button-background-color:var(--wpds-color-background-interactive-neutral-weak,#0000);--wp-ui-button-background-color-active:var(--wpds-color-background-interactive-neutral-weak-active,#ededed);--wp-ui-button-background-color-disabled:var(--wpds-color-background-interactive-neutral-weak-disabled,#0000);--wp-ui-button-border-color:var(--wpds-color-stroke-interactive-neutral,#8d8d8d);--wp-ui-button-border-color-active:var(--wpds-color-stroke-interactive-neutral-active,#6e6e6e);--wp-ui-button-border-color-disabled:var(--wpds-color-stroke-interactive-neutral-disabled,#dbdbdb)}&.ad0619a3217c6a5b__is-minimal:not([aria-pressed=true]){--wp-ui-button-background-color:var(--wpds-color-background-interactive-neutral-weak,#0000);--wp-ui-button-background-color-active:var(--wpds-color-background-interactive-neutral-weak-active,#ededed);--wp-ui-button-background-color-disabled:var(--wpds-color-background-interactive-neutral-weak-disabled,#0000)}}.abbb272e2ce49bd6__is-unstyled{background:none;border:none;min-width:unset}.cf59cf1b69629838__is-compact{--wp-ui-button-height:var(--wpds-dimension-size-md,32px)}._914b42f315c0e580__is-loading:not(.abbb272e2ce49bd6__is-unstyled){color:transparent;&:not([data-disabled]):is(:hover,:active,:focus){color:transparent}@media (forced-colors:active){color:ButtonFace}*{opacity:0}&:before{opacity:1;transition-delay:.05s;@media not (prefers-reduced-motion){animation:_5a1d53da6f830c8d__loading-animation 1s linear infinite}}}}@keyframes _5a1d53da6f830c8d__loading-animation{0%{transform:translate(-50%,-50%) rotate(0deg)}to{transform:translate(-50%,-50%) rotate(1turn)}}}'); 12527 } 12528 var style_default3 = { "button": "_97b0fc33c028be1a__button", "is-unstyled": "abbb272e2ce49bd6__is-unstyled", "is-loading": "_914b42f315c0e580__is-loading", "is-small": "_908205475f9f2a92__is-small", "icon": "_9f6fc6553aeb36fe__icon", "is-brand": "dd460c965226cc77__is-brand", "is-outline": "_62d5a778b7b258ee__is-outline", "is-minimal": "ad0619a3217c6a5b__is-minimal", "is-neutral": "e722a8f96726aa99__is-neutral", "is-solid": "b50b3358c5fb4d0b__is-solid", "is-compact": "cf59cf1b69629838__is-compact", "loading-animation": "_5a1d53da6f830c8d__loading-animation" }; 12529 if (typeof process === "undefined" || true) { 12530 registerStyle3("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}"); 12531 } 12532 var resets_default = { "box-sizing": "_336cd3e4e743482f__box-sizing" }; 12533 if (typeof process === "undefined" || true) { 12534 registerStyle3("da99a163ac", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._08e8a2e44959f892__outset-ring--focus:focus,.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,:focus-visible .ecadb9e080e2dfa5__outset-ring--focus-parent-visible{--_gcd-a-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9));--_gcd-div-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9));outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9));outline-offset:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px))}._970d04df7376df67__outset-ring--focus-within-except-active:focus-within,.e25b2bdd7aa21721__outset-ring--focus-except-active:focus{outline:none}._970d04df7376df67__outset-ring--focus-within-except-active:focus-within:not(:has(:active)),.e25b2bdd7aa21721__outset-ring--focus-except-active:focus:not(:active){@include mixins.focus-ring()}}}"); 12535 } 12536 var focus_default = { "outset-ring--focus": "_08e8a2e44959f892__outset-ring--focus", "outset-ring--focus-visible": "d0541bc9dd9dc7b6__outset-ring--focus-visible", "outset-ring--focus-within": "cd83dfc2126a0846__outset-ring--focus-within", "outset-ring--focus-within-visible": "c5cb3ee4bddaa8e4__outset-ring--focus-within-visible", "outset-ring--focus-parent-visible": "ecadb9e080e2dfa5__outset-ring--focus-parent-visible", "outset-ring--focus-except-active": "e25b2bdd7aa21721__outset-ring--focus-except-active", "outset-ring--focus-within-except-active": "_970d04df7376df67__outset-ring--focus-within-except-active" }; 12537 if (typeof process === "undefined" || true) { 12538 registerStyle3("af6d9984a6", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,transparent);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 transparent);color:var(--_gcd-input-color,var(--wpds-color-foreground-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,transparent);border-color:var(--_gcd-input-border-color-disabled,transparent);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid transparent)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-foreground-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-emphasis,600));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid transparent);transition:var(--_gcd-a-transition,none)}"); 12539 } 12540 var global_css_defense_default2 = { "button": "_6defc79820e382c6__button", "input": "d2cff2e5dea83bd1__input", "textarea": "_547d86373d02e108__textarea", "div": "_8c15fd0ed9f28ba4__div", "p": "_43cec3e1eec1066d__p", "heading": "e97669c6d9a38497__heading", "a": "_2c0831b0499dbd6e__a" }; 12541 var Button3 = (0, import_element14.forwardRef)( 12542 function Button22({ 12543 tone = "brand", 12544 variant = "solid", 12545 size: size4 = "default", 12546 className, 12547 focusableWhenDisabled = true, 12548 disabled: disabled2, 12549 loading, 12550 loadingAnnouncement = (0, import_i18n.__)("Loading"), 12551 children, 12552 ...props 12553 }, ref) { 12554 const mergedClassName = clsx_default( 12555 global_css_defense_default2.button, 12556 resets_default["box-sizing"], 12557 focus_default["outset-ring--focus-except-active"], 12558 variant !== "unstyled" && style_default3.button, 12559 style_default3[`is-$tone}`], 12560 style_default3[`is-$variant}`], 12561 style_default3[`is-$size4}`], 12562 loading && style_default3["is-loading"], 12563 className 12564 ); 12565 (0, import_element14.useEffect)(() => { 12566 if (loading && loadingAnnouncement) { 12567 speak(loadingAnnouncement); 12568 } 12569 }, [loading, loadingAnnouncement]); 12570 return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)( 12571 Button, 12572 { 12573 ref, 12574 className: mergedClassName, 12575 focusableWhenDisabled, 12576 disabled: disabled2 ?? loading, 12577 ...props, 12578 children 12579 } 12580 ); 12581 } 12582 ); 12583 12584 // packages/ui/build-module/button/icon.mjs 12585 var import_element16 = __toESM(require_element(), 1); 12586 12587 // packages/ui/build-module/icon/icon.mjs 12588 var import_element15 = __toESM(require_element(), 1); 12589 var import_primitives = __toESM(require_primitives(), 1); 12590 var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1); 12591 var Icon = (0, import_element15.forwardRef)(function Icon2({ icon, size: size4 = 24, ...restProps }, ref) { 12592 return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)( 12593 import_primitives.SVG, 12594 { 12595 ref, 12596 ...icon.props, 12597 ...restProps, 12598 width: size4, 12599 height: size4 12600 } 12601 ); 12602 }); 12603 12604 // packages/ui/build-module/button/icon.mjs 12605 var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1); 12606 var STYLE_HASH_ATTRIBUTE4 = "data-wp-hash"; 12607 function getRuntime4() { 12608 const globalScope = globalThis; 12609 if (globalScope.__wpStyleRuntime) { 12610 return globalScope.__wpStyleRuntime; 12611 } 12612 globalScope.__wpStyleRuntime = { 12613 documents: /* @__PURE__ */ new Map(), 12614 styles: /* @__PURE__ */ new Map(), 12615 injectedStyles: /* @__PURE__ */ new WeakMap() 12616 }; 12617 if (typeof document !== "undefined") { 12618 registerDocument4(document); 12619 } 12620 return globalScope.__wpStyleRuntime; 12621 } 12622 function documentContainsStyleHash4(targetDocument, hash) { 12623 if (!targetDocument.head) { 12624 return false; 12625 } 12626 for (const style of targetDocument.head.querySelectorAll( 12627 `style[$STYLE_HASH_ATTRIBUTE4}]` 12628 )) { 12629 if (style.getAttribute(STYLE_HASH_ATTRIBUTE4) === hash) { 12630 return true; 12631 } 12632 } 12633 return false; 12634 } 12635 function injectStyle4(targetDocument, hash, css) { 12636 if (!targetDocument.head) { 12637 return; 12638 } 12639 const runtime = getRuntime4(); 12640 let injectedStyles = runtime.injectedStyles.get(targetDocument); 12641 if (!injectedStyles) { 12642 injectedStyles = /* @__PURE__ */ new Set(); 12643 runtime.injectedStyles.set(targetDocument, injectedStyles); 12644 } 12645 if (injectedStyles.has(hash)) { 12646 return; 12647 } 12648 if (documentContainsStyleHash4(targetDocument, hash)) { 12649 injectedStyles.add(hash); 12650 return; 12651 } 12652 const style = targetDocument.createElement("style"); 12653 style.setAttribute(STYLE_HASH_ATTRIBUTE4, hash); 12654 style.appendChild(targetDocument.createTextNode(css)); 12655 targetDocument.head.appendChild(style); 12656 injectedStyles.add(hash); 12657 } 12658 function registerDocument4(targetDocument) { 12659 const runtime = getRuntime4(); 12660 runtime.documents.set( 12661 targetDocument, 12662 (runtime.documents.get(targetDocument) ?? 0) + 1 12663 ); 12664 for (const [hash, css] of runtime.styles) { 12665 injectStyle4(targetDocument, hash, css); 12666 } 12667 return () => { 12668 const count = runtime.documents.get(targetDocument); 12669 if (count === void 0) { 12670 return; 12671 } 12672 if (count <= 1) { 12673 runtime.documents.delete(targetDocument); 12674 return; 12675 } 12676 runtime.documents.set(targetDocument, count - 1); 12677 }; 12678 } 12679 function registerStyle4(hash, css) { 12680 const runtime = getRuntime4(); 12681 runtime.styles.set(hash, css); 12682 for (const targetDocument of runtime.documents.keys()) { 12683 injectStyle4(targetDocument, hash, css); 12684 } 12685 } 12686 if (typeof process === "undefined" || true) { 12687 registerStyle4("b74f1ac304", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._97b0fc33c028be1a__button,.abbb272e2ce49bd6__is-unstyled{appearance:none;padding:0}._97b0fc33c028be1a__button{--wp-ui-button-font-weight:var(--wpds-typography-font-weight-emphasis,600);--wp-ui-button-background-color:var(--wpds-color-background-interactive-brand-strong,var(--wp-admin-theme-color,#3858e9));--wp-ui-button-background-color-active:var(--wpds-color-background-interactive-brand-strong-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 93%,#000));--wp-ui-button-background-color-disabled:var(--wpds-color-background-interactive-brand-strong-disabled,#e6e6e6);--wp-ui-button-foreground-color:var(--wpds-color-foreground-interactive-brand-strong,#fff);--wp-ui-button-foreground-color-active:var(--wpds-color-foreground-interactive-brand-strong-active,#fff);--wp-ui-button-foreground-color-disabled:var(--wpds-color-foreground-interactive-brand-strong-disabled,#8d8d8d);--wp-ui-button-padding-block:var(--wpds-dimension-padding-xs,4px);--wp-ui-button-padding-inline:var(--wpds-dimension-padding-md,12px);--wp-ui-button-height:var(--wpds-dimension-size-lg,40px);--wp-ui-button-aspect-ratio:auto;--wp-ui-button-font-size:var(--wpds-typography-font-size-md,13px);--wp-ui-button-min-width:calc(4ch + var(--wp-ui-button-padding-inline)*2);--wp-ui-button-icon-margin:calc((var(--wpds-dimension-size-2xs, 16px) - var(--wpds-dimension-size-sm, 24px))/2);--wp-ui-button-border-color:var(--wp-ui-button-background-color);--wp-ui-button-border-color-active:var(--wp-ui-button-background-color-active);--wp-ui-button-border-color-disabled:var(--wp-ui-button-background-color-disabled);--_gcd-button-font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);--_gcd-button-font-size:var(--wp-ui-button-font-size);--_gcd-button-font-weight:var(--wp-ui-button-font-weight);align-items:center;aspect-ratio:var(--wp-ui-button-aspect-ratio);background-clip:border-box;background-color:var(--wp-ui-button-background-color);border-color:var(--wp-ui-button-border-color);border-radius:var(--wpds-border-radius-sm,2px);border-style:solid;border-width:1px;color:var(--wp-ui-button-foreground-color);display:inline-flex;font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wp-ui-button-font-size);font-weight:var(--wp-ui-button-font-weight);gap:var(--wpds-dimension-gap-sm,8px);justify-content:center;line-height:var(--wpds-typography-line-height-sm,20px);max-width:100%;min-height:var(--wp-ui-button-height);min-width:var(--wp-ui-button-min-width);overflow-wrap:anywhere;padding-block:var(--wp-ui-button-padding-block);padding-inline:var(--wp-ui-button-padding-inline);position:relative;text-align:center;text-decoration:none;&:not([data-disabled]){cursor:var(--wpds-cursor-control,pointer)}@media not (prefers-reduced-motion){transition:color .1s ease-out;*{transition:opacity .1s ease-out}}&[href]{cursor:pointer}[href]{color:inherit;text-decoration:inherit}&:not([data-disabled]):is(:hover,:active,:focus){background-color:var(--wp-ui-button-background-color-active);border-color:var(--wp-ui-button-border-color-active);color:var(--wp-ui-button-foreground-color-active)}&[data-disabled]:not(._914b42f315c0e580__is-loading){background-color:var(--wp-ui-button-background-color-disabled);border-color:var(--wp-ui-button-border-color-disabled);color:var(--wp-ui-button-foreground-color-disabled);@media (forced-colors:active){border-bottom-color:GrayText;border-left-color:GrayText;border-right-color:GrayText;border-top-color:GrayText;color:GrayText}}&:before{aspect-ratio:1;border:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid;border-block-end-color:transparent;border-block-start-color:var(--wp-ui-button-foreground-color);border-inline-end-color:var(--wp-ui-button-foreground-color);border-inline-start-color:transparent;border-radius:50%;box-sizing:border-box;content:"";display:block;height:var(--wp-ui-button-font-size);inset-inline-start:50%;opacity:0;pointer-events:none;position:absolute;top:50%;transform:translate(-50%,-50%);@media not (prefers-reduced-motion){transition:opacity .1s ease-out}@media (forced-colors:active){border-block-end-style:none;border-bottom-color:ButtonText;border-inline-start-style:none;border-left-color:ButtonText;border-right-color:ButtonText;border-top-color:ButtonText}}}._908205475f9f2a92__is-small{--wp-ui-button-padding-block:0px;--wp-ui-button-padding-inline:var(--wpds-dimension-padding-sm,8px);--wp-ui-button-height:var(--wpds-dimension-size-sm,24px)}._9f6fc6553aeb36fe__icon{margin:var(--wp-ui-button-icon-margin)}.dd460c965226cc77__is-brand{&._62d5a778b7b258ee__is-outline,&.ad0619a3217c6a5b__is-minimal{--wp-ui-button-foreground-color:var(--wpds-color-foreground-interactive-brand,var(--wp-admin-theme-color,#3858e9));--wp-ui-button-foreground-color-active:var(--wpds-color-foreground-interactive-brand-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 52%,#000));--wp-ui-button-foreground-color-disabled:var(--wpds-color-foreground-interactive-brand-disabled,#8d8d8d)}&._62d5a778b7b258ee__is-outline{--wp-ui-button-background-color:var(--wpds-color-background-interactive-brand-weak,#0000);--wp-ui-button-background-color-active:var(--wpds-color-background-interactive-brand-weak-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 12%,#fff));--wp-ui-button-background-color-disabled:var(--wpds-color-background-interactive-brand-weak-disabled,#0000);--wp-ui-button-border-color:var(--wpds-color-stroke-interactive-brand,var(--wp-admin-theme-color,#3858e9));--wp-ui-button-border-color-active:var(--wpds-color-stroke-interactive-brand-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 85%,#000));--wp-ui-button-border-color-disabled:var(--wpds-color-stroke-interactive-brand-disabled,#dbdbdb)}&.ad0619a3217c6a5b__is-minimal{--wp-ui-button-background-color:var(--wpds-color-background-interactive-brand-weak,#0000);--wp-ui-button-background-color-active:var(--wpds-color-background-interactive-brand-weak-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 12%,#fff));--wp-ui-button-background-color-disabled:var(--wpds-color-background-interactive-brand-weak-disabled,#0000)}}.e722a8f96726aa99__is-neutral{&.ad0619a3217c6a5b__is-minimal[aria-pressed=true],&.b50b3358c5fb4d0b__is-solid{--wp-ui-button-background-color:var(--wpds-color-background-interactive-neutral-strong,#2d2d2d);--wp-ui-button-background-color-active:var(--wpds-color-background-interactive-neutral-strong-active,#1e1e1e);--wp-ui-button-background-color-disabled:var(--wpds-color-background-interactive-neutral-strong-disabled,#e6e6e6);--wp-ui-button-foreground-color:var(--wpds-color-foreground-interactive-neutral-strong,#f0f0f0);--wp-ui-button-foreground-color-active:var(--wpds-color-foreground-interactive-neutral-strong-active,#f0f0f0);--wp-ui-button-foreground-color-disabled:var(--wpds-color-foreground-interactive-neutral-strong-disabled,#8d8d8d)}&._62d5a778b7b258ee__is-outline,&.ad0619a3217c6a5b__is-minimal:not([aria-pressed=true]){--wp-ui-button-foreground-color:var(--wpds-color-foreground-interactive-neutral,#1e1e1e);--wp-ui-button-foreground-color-active:var(--wpds-color-foreground-interactive-neutral-active,#1e1e1e);--wp-ui-button-foreground-color-disabled:var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d)}&._62d5a778b7b258ee__is-outline{--wp-ui-button-background-color:var(--wpds-color-background-interactive-neutral-weak,#0000);--wp-ui-button-background-color-active:var(--wpds-color-background-interactive-neutral-weak-active,#ededed);--wp-ui-button-background-color-disabled:var(--wpds-color-background-interactive-neutral-weak-disabled,#0000);--wp-ui-button-border-color:var(--wpds-color-stroke-interactive-neutral,#8d8d8d);--wp-ui-button-border-color-active:var(--wpds-color-stroke-interactive-neutral-active,#6e6e6e);--wp-ui-button-border-color-disabled:var(--wpds-color-stroke-interactive-neutral-disabled,#dbdbdb)}&.ad0619a3217c6a5b__is-minimal:not([aria-pressed=true]){--wp-ui-button-background-color:var(--wpds-color-background-interactive-neutral-weak,#0000);--wp-ui-button-background-color-active:var(--wpds-color-background-interactive-neutral-weak-active,#ededed);--wp-ui-button-background-color-disabled:var(--wpds-color-background-interactive-neutral-weak-disabled,#0000)}}.abbb272e2ce49bd6__is-unstyled{background:none;border:none;min-width:unset}.cf59cf1b69629838__is-compact{--wp-ui-button-height:var(--wpds-dimension-size-md,32px)}._914b42f315c0e580__is-loading:not(.abbb272e2ce49bd6__is-unstyled){color:transparent;&:not([data-disabled]):is(:hover,:active,:focus){color:transparent}@media (forced-colors:active){color:ButtonFace}*{opacity:0}&:before{opacity:1;transition-delay:.05s;@media not (prefers-reduced-motion){animation:_5a1d53da6f830c8d__loading-animation 1s linear infinite}}}}@keyframes _5a1d53da6f830c8d__loading-animation{0%{transform:translate(-50%,-50%) rotate(0deg)}to{transform:translate(-50%,-50%) rotate(1turn)}}}'); 12688 } 12689 var style_default4 = { "button": "_97b0fc33c028be1a__button", "is-unstyled": "abbb272e2ce49bd6__is-unstyled", "is-loading": "_914b42f315c0e580__is-loading", "is-small": "_908205475f9f2a92__is-small", "icon": "_9f6fc6553aeb36fe__icon", "is-brand": "dd460c965226cc77__is-brand", "is-outline": "_62d5a778b7b258ee__is-outline", "is-minimal": "ad0619a3217c6a5b__is-minimal", "is-neutral": "e722a8f96726aa99__is-neutral", "is-solid": "b50b3358c5fb4d0b__is-solid", "is-compact": "cf59cf1b69629838__is-compact", "loading-animation": "_5a1d53da6f830c8d__loading-animation" }; 12690 var ButtonIcon = (0, import_element16.forwardRef)( 12691 function ButtonIcon2({ className, icon, ...props }, ref) { 12692 return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)( 12693 Icon, 12694 { 12695 ref, 12696 icon, 12697 className: clsx_default(style_default4.icon, className), 12698 size: 24, 12699 ...props 12700 } 12701 ); 12702 } 12703 ); 12704 12705 // packages/ui/build-module/button/index.mjs 12706 ButtonIcon.displayName = "Button.Icon"; 12707 var Button4 = Object.assign(Button3, { 12708 /** 12709 * An icon component specifically designed to work well when rendered inside 12710 * a `Button` component. 12711 */ 12712 Icon: ButtonIcon 12713 }); 12714 12715 // packages/ui/build-module/card/index.mjs 12716 var card_exports = {}; 12717 __export(card_exports, { 12718 Content: () => Content, 12719 FullBleed: () => FullBleed, 12720 Header: () => Header, 12721 Root: () => Root, 12722 Title: () => Title 12723 }); 12724 12725 // packages/ui/build-module/card/root.mjs 12726 var import_element17 = __toESM(require_element(), 1); 12727 var STYLE_HASH_ATTRIBUTE5 = "data-wp-hash"; 12728 function getRuntime5() { 12729 const globalScope = globalThis; 12730 if (globalScope.__wpStyleRuntime) { 12731 return globalScope.__wpStyleRuntime; 12732 } 12733 globalScope.__wpStyleRuntime = { 12734 documents: /* @__PURE__ */ new Map(), 12735 styles: /* @__PURE__ */ new Map(), 12736 injectedStyles: /* @__PURE__ */ new WeakMap() 12737 }; 12738 if (typeof document !== "undefined") { 12739 registerDocument5(document); 12740 } 12741 return globalScope.__wpStyleRuntime; 12742 } 12743 function documentContainsStyleHash5(targetDocument, hash) { 12744 if (!targetDocument.head) { 12745 return false; 12746 } 12747 for (const style of targetDocument.head.querySelectorAll( 12748 `style[$STYLE_HASH_ATTRIBUTE5}]` 12749 )) { 12750 if (style.getAttribute(STYLE_HASH_ATTRIBUTE5) === hash) { 12751 return true; 12752 } 12753 } 12754 return false; 12755 } 12756 function injectStyle5(targetDocument, hash, css) { 12757 if (!targetDocument.head) { 12758 return; 12759 } 12760 const runtime = getRuntime5(); 12761 let injectedStyles = runtime.injectedStyles.get(targetDocument); 12762 if (!injectedStyles) { 12763 injectedStyles = /* @__PURE__ */ new Set(); 12764 runtime.injectedStyles.set(targetDocument, injectedStyles); 12765 } 12766 if (injectedStyles.has(hash)) { 12767 return; 12768 } 12769 if (documentContainsStyleHash5(targetDocument, hash)) { 12770 injectedStyles.add(hash); 12771 return; 12772 } 12773 const style = targetDocument.createElement("style"); 12774 style.setAttribute(STYLE_HASH_ATTRIBUTE5, hash); 12775 style.appendChild(targetDocument.createTextNode(css)); 12776 targetDocument.head.appendChild(style); 12777 injectedStyles.add(hash); 12778 } 12779 function registerDocument5(targetDocument) { 12780 const runtime = getRuntime5(); 12781 runtime.documents.set( 12782 targetDocument, 12783 (runtime.documents.get(targetDocument) ?? 0) + 1 12784 ); 12785 for (const [hash, css] of runtime.styles) { 12786 injectStyle5(targetDocument, hash, css); 12787 } 12788 return () => { 12789 const count = runtime.documents.get(targetDocument); 12790 if (count === void 0) { 12791 return; 12792 } 12793 if (count <= 1) { 12794 runtime.documents.delete(targetDocument); 12795 return; 12796 } 12797 runtime.documents.set(targetDocument, count - 1); 12798 }; 12799 } 12800 function registerStyle5(hash, css) { 12801 const runtime = getRuntime5(); 12802 runtime.styles.set(hash, css); 12803 for (const targetDocument of runtime.documents.keys()) { 12804 injectStyle5(targetDocument, hash, css); 12805 } 12806 } 12807 if (typeof process === "undefined" || true) { 12808 registerStyle5("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}"); 12809 } 12810 var resets_default2 = { "box-sizing": "_336cd3e4e743482f__box-sizing" }; 12811 if (typeof process === "undefined" || true) { 12812 registerStyle5("5d38cbdd27", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._02872bf298eadc43__root{--wp-ui-card-padding:var(--wpds-dimension-padding-2xl,24px);--wp-ui-card-header-content-gap:var(--wpds-dimension-gap-xl,24px);--wp-ui-card-header-content-margin:calc(var(--wp-ui-card-header-content-gap) - var(--wp-ui-card-padding));background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);border-radius:var(--wpds-border-radius-lg,8px);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:flex;flex-direction:column;overflow:clip}._5dffdaf2a6e669ac__content,.bbccc92e6ba5662d__header{padding:var(--wp-ui-card-padding);&:not(:first-child):not(:last-child){padding-block-end:0}}.bbccc92e6ba5662d__header+._5dffdaf2a6e669ac__content{margin-block-start:var(--wp-ui-card-header-content-margin);padding-block-start:0}.c1fa192587e1b4a6__fullbleed{margin-inline:calc(var(--wp-ui-card-padding)*-1);width:calc(100% + var(--wp-ui-card-padding)*2)}._02872bf298eadc43__root>:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):first-child>.c1fa192587e1b4a6__fullbleed:first-child{margin-block-start:calc(var(--wp-ui-card-padding)*-1)}:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):last-child>.c1fa192587e1b4a6__fullbleed:last-child{margin-block-end:calc(var(--wp-ui-card-padding)*-1)}}}"); 12813 } 12814 var style_default5 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" }; 12815 var Root = (0, import_element17.forwardRef)(function Card({ render: render4, ...restProps }, ref) { 12816 const mergedClassName = clsx_default(style_default5.root, resets_default2["box-sizing"]); 12817 const element = useRender({ 12818 defaultTagName: "div", 12819 render: render4, 12820 ref, 12821 props: mergeProps({ className: mergedClassName }, restProps) 12822 }); 12823 return element; 12824 }); 12825 12826 // packages/ui/build-module/card/header.mjs 12827 var import_element18 = __toESM(require_element(), 1); 12828 var STYLE_HASH_ATTRIBUTE6 = "data-wp-hash"; 12829 function getRuntime6() { 12830 const globalScope = globalThis; 12831 if (globalScope.__wpStyleRuntime) { 12832 return globalScope.__wpStyleRuntime; 12833 } 12834 globalScope.__wpStyleRuntime = { 12835 documents: /* @__PURE__ */ new Map(), 12836 styles: /* @__PURE__ */ new Map(), 12837 injectedStyles: /* @__PURE__ */ new WeakMap() 12838 }; 12839 if (typeof document !== "undefined") { 12840 registerDocument6(document); 12841 } 12842 return globalScope.__wpStyleRuntime; 12843 } 12844 function documentContainsStyleHash6(targetDocument, hash) { 12845 if (!targetDocument.head) { 12846 return false; 12847 } 12848 for (const style of targetDocument.head.querySelectorAll( 12849 `style[$STYLE_HASH_ATTRIBUTE6}]` 12850 )) { 12851 if (style.getAttribute(STYLE_HASH_ATTRIBUTE6) === hash) { 12852 return true; 12853 } 12854 } 12855 return false; 12856 } 12857 function injectStyle6(targetDocument, hash, css) { 12858 if (!targetDocument.head) { 12859 return; 12860 } 12861 const runtime = getRuntime6(); 12862 let injectedStyles = runtime.injectedStyles.get(targetDocument); 12863 if (!injectedStyles) { 12864 injectedStyles = /* @__PURE__ */ new Set(); 12865 runtime.injectedStyles.set(targetDocument, injectedStyles); 12866 } 12867 if (injectedStyles.has(hash)) { 12868 return; 12869 } 12870 if (documentContainsStyleHash6(targetDocument, hash)) { 12871 injectedStyles.add(hash); 12872 return; 12873 } 12874 const style = targetDocument.createElement("style"); 12875 style.setAttribute(STYLE_HASH_ATTRIBUTE6, hash); 12876 style.appendChild(targetDocument.createTextNode(css)); 12877 targetDocument.head.appendChild(style); 12878 injectedStyles.add(hash); 12879 } 12880 function registerDocument6(targetDocument) { 12881 const runtime = getRuntime6(); 12882 runtime.documents.set( 12883 targetDocument, 12884 (runtime.documents.get(targetDocument) ?? 0) + 1 12885 ); 12886 for (const [hash, css] of runtime.styles) { 12887 injectStyle6(targetDocument, hash, css); 12888 } 12889 return () => { 12890 const count = runtime.documents.get(targetDocument); 12891 if (count === void 0) { 12892 return; 12893 } 12894 if (count <= 1) { 12895 runtime.documents.delete(targetDocument); 12896 return; 12897 } 12898 runtime.documents.set(targetDocument, count - 1); 12899 }; 12900 } 12901 function registerStyle6(hash, css) { 12902 const runtime = getRuntime6(); 12903 runtime.styles.set(hash, css); 12904 for (const targetDocument of runtime.documents.keys()) { 12905 injectStyle6(targetDocument, hash, css); 12906 } 12907 } 12908 if (typeof process === "undefined" || true) { 12909 registerStyle6("5d38cbdd27", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._02872bf298eadc43__root{--wp-ui-card-padding:var(--wpds-dimension-padding-2xl,24px);--wp-ui-card-header-content-gap:var(--wpds-dimension-gap-xl,24px);--wp-ui-card-header-content-margin:calc(var(--wp-ui-card-header-content-gap) - var(--wp-ui-card-padding));background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);border-radius:var(--wpds-border-radius-lg,8px);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:flex;flex-direction:column;overflow:clip}._5dffdaf2a6e669ac__content,.bbccc92e6ba5662d__header{padding:var(--wp-ui-card-padding);&:not(:first-child):not(:last-child){padding-block-end:0}}.bbccc92e6ba5662d__header+._5dffdaf2a6e669ac__content{margin-block-start:var(--wp-ui-card-header-content-margin);padding-block-start:0}.c1fa192587e1b4a6__fullbleed{margin-inline:calc(var(--wp-ui-card-padding)*-1);width:calc(100% + var(--wp-ui-card-padding)*2)}._02872bf298eadc43__root>:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):first-child>.c1fa192587e1b4a6__fullbleed:first-child{margin-block-start:calc(var(--wp-ui-card-padding)*-1)}:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):last-child>.c1fa192587e1b4a6__fullbleed:last-child{margin-block-end:calc(var(--wp-ui-card-padding)*-1)}}}"); 12910 } 12911 var style_default6 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" }; 12912 var Header = (0, import_element18.forwardRef)( 12913 function CardHeader({ render: render4, ...props }, ref) { 12914 const element = useRender({ 12915 defaultTagName: "div", 12916 render: render4, 12917 ref, 12918 props: mergeProps({ className: style_default6.header }, props) 12919 }); 12920 return element; 12921 } 12922 ); 12923 12924 // packages/ui/build-module/card/content.mjs 12925 var import_element19 = __toESM(require_element(), 1); 12926 var STYLE_HASH_ATTRIBUTE7 = "data-wp-hash"; 12927 function getRuntime7() { 12928 const globalScope = globalThis; 12929 if (globalScope.__wpStyleRuntime) { 12930 return globalScope.__wpStyleRuntime; 12931 } 12932 globalScope.__wpStyleRuntime = { 12933 documents: /* @__PURE__ */ new Map(), 12934 styles: /* @__PURE__ */ new Map(), 12935 injectedStyles: /* @__PURE__ */ new WeakMap() 12936 }; 12937 if (typeof document !== "undefined") { 12938 registerDocument7(document); 12939 } 12940 return globalScope.__wpStyleRuntime; 12941 } 12942 function documentContainsStyleHash7(targetDocument, hash) { 12943 if (!targetDocument.head) { 12944 return false; 12945 } 12946 for (const style of targetDocument.head.querySelectorAll( 12947 `style[$STYLE_HASH_ATTRIBUTE7}]` 12948 )) { 12949 if (style.getAttribute(STYLE_HASH_ATTRIBUTE7) === hash) { 12950 return true; 12951 } 12952 } 12953 return false; 12954 } 12955 function injectStyle7(targetDocument, hash, css) { 12956 if (!targetDocument.head) { 12957 return; 12958 } 12959 const runtime = getRuntime7(); 12960 let injectedStyles = runtime.injectedStyles.get(targetDocument); 12961 if (!injectedStyles) { 12962 injectedStyles = /* @__PURE__ */ new Set(); 12963 runtime.injectedStyles.set(targetDocument, injectedStyles); 12964 } 12965 if (injectedStyles.has(hash)) { 12966 return; 12967 } 12968 if (documentContainsStyleHash7(targetDocument, hash)) { 12969 injectedStyles.add(hash); 12970 return; 12971 } 12972 const style = targetDocument.createElement("style"); 12973 style.setAttribute(STYLE_HASH_ATTRIBUTE7, hash); 12974 style.appendChild(targetDocument.createTextNode(css)); 12975 targetDocument.head.appendChild(style); 12976 injectedStyles.add(hash); 12977 } 12978 function registerDocument7(targetDocument) { 12979 const runtime = getRuntime7(); 12980 runtime.documents.set( 12981 targetDocument, 12982 (runtime.documents.get(targetDocument) ?? 0) + 1 12983 ); 12984 for (const [hash, css] of runtime.styles) { 12985 injectStyle7(targetDocument, hash, css); 12986 } 12987 return () => { 12988 const count = runtime.documents.get(targetDocument); 12989 if (count === void 0) { 12990 return; 12991 } 12992 if (count <= 1) { 12993 runtime.documents.delete(targetDocument); 12994 return; 12995 } 12996 runtime.documents.set(targetDocument, count - 1); 12997 }; 12998 } 12999 function registerStyle7(hash, css) { 13000 const runtime = getRuntime7(); 13001 runtime.styles.set(hash, css); 13002 for (const targetDocument of runtime.documents.keys()) { 13003 injectStyle7(targetDocument, hash, css); 13004 } 13005 } 13006 if (typeof process === "undefined" || true) { 13007 registerStyle7("5d38cbdd27", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._02872bf298eadc43__root{--wp-ui-card-padding:var(--wpds-dimension-padding-2xl,24px);--wp-ui-card-header-content-gap:var(--wpds-dimension-gap-xl,24px);--wp-ui-card-header-content-margin:calc(var(--wp-ui-card-header-content-gap) - var(--wp-ui-card-padding));background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);border-radius:var(--wpds-border-radius-lg,8px);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:flex;flex-direction:column;overflow:clip}._5dffdaf2a6e669ac__content,.bbccc92e6ba5662d__header{padding:var(--wp-ui-card-padding);&:not(:first-child):not(:last-child){padding-block-end:0}}.bbccc92e6ba5662d__header+._5dffdaf2a6e669ac__content{margin-block-start:var(--wp-ui-card-header-content-margin);padding-block-start:0}.c1fa192587e1b4a6__fullbleed{margin-inline:calc(var(--wp-ui-card-padding)*-1);width:calc(100% + var(--wp-ui-card-padding)*2)}._02872bf298eadc43__root>:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):first-child>.c1fa192587e1b4a6__fullbleed:first-child{margin-block-start:calc(var(--wp-ui-card-padding)*-1)}:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):last-child>.c1fa192587e1b4a6__fullbleed:last-child{margin-block-end:calc(var(--wp-ui-card-padding)*-1)}}}"); 13008 } 13009 var style_default7 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" }; 13010 var Content = (0, import_element19.forwardRef)( 13011 function CardContent({ render: render4, ...props }, ref) { 13012 const element = useRender({ 13013 defaultTagName: "div", 13014 render: render4, 13015 ref, 13016 props: mergeProps({ className: style_default7.content }, props) 13017 }); 13018 return element; 13019 } 13020 ); 13021 13022 // packages/ui/build-module/card/full-bleed.mjs 13023 var import_element20 = __toESM(require_element(), 1); 13024 var STYLE_HASH_ATTRIBUTE8 = "data-wp-hash"; 13025 function getRuntime8() { 13026 const globalScope = globalThis; 13027 if (globalScope.__wpStyleRuntime) { 13028 return globalScope.__wpStyleRuntime; 13029 } 13030 globalScope.__wpStyleRuntime = { 13031 documents: /* @__PURE__ */ new Map(), 13032 styles: /* @__PURE__ */ new Map(), 13033 injectedStyles: /* @__PURE__ */ new WeakMap() 13034 }; 13035 if (typeof document !== "undefined") { 13036 registerDocument8(document); 13037 } 13038 return globalScope.__wpStyleRuntime; 13039 } 13040 function documentContainsStyleHash8(targetDocument, hash) { 13041 if (!targetDocument.head) { 13042 return false; 13043 } 13044 for (const style of targetDocument.head.querySelectorAll( 13045 `style[$STYLE_HASH_ATTRIBUTE8}]` 13046 )) { 13047 if (style.getAttribute(STYLE_HASH_ATTRIBUTE8) === hash) { 13048 return true; 13049 } 13050 } 13051 return false; 13052 } 13053 function injectStyle8(targetDocument, hash, css) { 13054 if (!targetDocument.head) { 13055 return; 13056 } 13057 const runtime = getRuntime8(); 13058 let injectedStyles = runtime.injectedStyles.get(targetDocument); 13059 if (!injectedStyles) { 13060 injectedStyles = /* @__PURE__ */ new Set(); 13061 runtime.injectedStyles.set(targetDocument, injectedStyles); 13062 } 13063 if (injectedStyles.has(hash)) { 13064 return; 13065 } 13066 if (documentContainsStyleHash8(targetDocument, hash)) { 13067 injectedStyles.add(hash); 13068 return; 13069 } 13070 const style = targetDocument.createElement("style"); 13071 style.setAttribute(STYLE_HASH_ATTRIBUTE8, hash); 13072 style.appendChild(targetDocument.createTextNode(css)); 13073 targetDocument.head.appendChild(style); 13074 injectedStyles.add(hash); 13075 } 13076 function registerDocument8(targetDocument) { 13077 const runtime = getRuntime8(); 13078 runtime.documents.set( 13079 targetDocument, 13080 (runtime.documents.get(targetDocument) ?? 0) + 1 13081 ); 13082 for (const [hash, css] of runtime.styles) { 13083 injectStyle8(targetDocument, hash, css); 13084 } 13085 return () => { 13086 const count = runtime.documents.get(targetDocument); 13087 if (count === void 0) { 13088 return; 13089 } 13090 if (count <= 1) { 13091 runtime.documents.delete(targetDocument); 13092 return; 13093 } 13094 runtime.documents.set(targetDocument, count - 1); 13095 }; 13096 } 13097 function registerStyle8(hash, css) { 13098 const runtime = getRuntime8(); 13099 runtime.styles.set(hash, css); 13100 for (const targetDocument of runtime.documents.keys()) { 13101 injectStyle8(targetDocument, hash, css); 13102 } 13103 } 13104 if (typeof process === "undefined" || true) { 13105 registerStyle8("5d38cbdd27", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._02872bf298eadc43__root{--wp-ui-card-padding:var(--wpds-dimension-padding-2xl,24px);--wp-ui-card-header-content-gap:var(--wpds-dimension-gap-xl,24px);--wp-ui-card-header-content-margin:calc(var(--wp-ui-card-header-content-gap) - var(--wp-ui-card-padding));background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);border-radius:var(--wpds-border-radius-lg,8px);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:flex;flex-direction:column;overflow:clip}._5dffdaf2a6e669ac__content,.bbccc92e6ba5662d__header{padding:var(--wp-ui-card-padding);&:not(:first-child):not(:last-child){padding-block-end:0}}.bbccc92e6ba5662d__header+._5dffdaf2a6e669ac__content{margin-block-start:var(--wp-ui-card-header-content-margin);padding-block-start:0}.c1fa192587e1b4a6__fullbleed{margin-inline:calc(var(--wp-ui-card-padding)*-1);width:calc(100% + var(--wp-ui-card-padding)*2)}._02872bf298eadc43__root>:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):first-child>.c1fa192587e1b4a6__fullbleed:first-child{margin-block-start:calc(var(--wp-ui-card-padding)*-1)}:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):last-child>.c1fa192587e1b4a6__fullbleed:last-child{margin-block-end:calc(var(--wp-ui-card-padding)*-1)}}}"); 13106 } 13107 var style_default8 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" }; 13108 var FullBleed = (0, import_element20.forwardRef)( 13109 function CardFullBleed({ render: render4, ...props }, ref) { 13110 const element = useRender({ 13111 defaultTagName: "div", 13112 render: render4, 13113 ref, 13114 props: mergeProps( 13115 { className: style_default8.fullbleed }, 13116 props 13117 ) 13118 }); 13119 return element; 13120 } 13121 ); 13122 13123 // packages/ui/build-module/card/title.mjs 13124 var import_element21 = __toESM(require_element(), 1); 13125 var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1); 13126 var DEFAULT_TAG = /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", {}); 13127 var Title = (0, import_element21.forwardRef)( 13128 function CardTitle({ render: render4 = DEFAULT_TAG, children, ...props }, ref) { 13129 return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)( 13130 Text, 13131 { 13132 ref, 13133 variant: "heading-lg", 13134 render: render4, 13135 ...props, 13136 children 13137 } 13138 ); 13139 } 13140 ); 13141 13142 // packages/ui/build-module/collapsible/panel.mjs 13143 var import_element22 = __toESM(require_element(), 1); 13144 var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1); 13145 var Panel = (0, import_element22.forwardRef)( 13146 function CollapsiblePanel3(props, forwardedRef) { 13147 return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(index_parts_exports.Panel, { ref: forwardedRef, ...props }); 13148 } 13149 ); 13150 13151 // packages/ui/build-module/collapsible/root.mjs 13152 var import_element23 = __toESM(require_element(), 1); 13153 var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1); 13154 var Root2 = (0, import_element23.forwardRef)( 13155 function CollapsibleRoot3(props, forwardedRef) { 13156 return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(index_parts_exports.Root, { ref: forwardedRef, ...props }); 13157 } 13158 ); 13159 13160 // packages/ui/build-module/collapsible/trigger.mjs 13161 var import_element24 = __toESM(require_element(), 1); 13162 var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1); 13163 var Trigger = (0, import_element24.forwardRef)( 13164 function CollapsibleTrigger3(props, forwardedRef) { 13165 return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(index_parts_exports.Trigger, { ref: forwardedRef, ...props }); 13166 } 13167 ); 13168 13169 // packages/ui/build-module/collapsible-card/index.mjs 13170 var collapsible_card_exports = {}; 13171 __export(collapsible_card_exports, { 13172 Content: () => Content2, 13173 Header: () => Header2, 13174 HeaderDescription: () => HeaderDescription, 13175 Root: () => Root3 13176 }); 13177 13178 // packages/ui/build-module/collapsible-card/root.mjs 13179 var import_element25 = __toESM(require_element(), 1); 13180 var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1); 13181 var Root3 = (0, import_element25.forwardRef)( 13182 function CollapsibleCardRoot({ render: render4, ...restProps }, ref) { 13183 return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)( 13184 Root2, 13185 { 13186 ref, 13187 render: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Root, { render: render4 }), 13188 ...restProps 13189 } 13190 ); 13191 } 13192 ); 13193 13194 // packages/ui/build-module/collapsible-card/header.mjs 13195 var import_element27 = __toESM(require_element(), 1); 13196 13197 // packages/icons/build-module/library/arrow-down.mjs 13198 var import_primitives2 = __toESM(require_primitives(), 1); 13199 var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1); 13200 var arrow_down_default = /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives2.Path, { d: "m16.5 13.5-3.7 3.7V4h-1.5v13.2l-3.8-3.7-1 1 5.5 5.6 5.5-5.6z" }) }); 13201 13202 // packages/icons/build-module/library/arrow-left.mjs 13203 var import_primitives3 = __toESM(require_primitives(), 1); 13204 var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1); 13205 var arrow_left_default = /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives3.Path, { d: "M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z" }) }); 13206 13207 // packages/icons/build-module/library/arrow-right.mjs 13208 var import_primitives4 = __toESM(require_primitives(), 1); 13209 var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1); 13210 var arrow_right_default = /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_primitives4.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_primitives4.Path, { d: "m14.5 6.5-1 1 3.7 3.7H4v1.6h13.2l-3.7 3.7 1 1 5.6-5.5z" }) }); 13211 13212 // packages/icons/build-module/library/arrow-up.mjs 13213 var import_primitives5 = __toESM(require_primitives(), 1); 13214 var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1); 13215 var arrow_up_default = /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_primitives5.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_primitives5.Path, { d: "M12 3.9 6.5 9.5l1 1 3.8-3.7V20h1.5V6.8l3.7 3.7 1-1z" }) }); 13216 13217 // packages/icons/build-module/library/block-table.mjs 13218 var import_primitives6 = __toESM(require_primitives(), 1); 13219 var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1); 13220 var block_table_default = /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_primitives6.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_primitives6.Path, { d: "M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM5 4.5h14c.3 0 .5.2.5.5v3.5h-15V5c0-.3.2-.5.5-.5zm8 5.5h6.5v3.5H13V10zm-1.5 3.5h-7V10h7v3.5zm-7 5.5v-4h7v4.5H5c-.3 0-.5-.2-.5-.5zm14.5.5h-6V15h6.5v4c0 .3-.2.5-.5.5z" }) }); 13221 13222 // packages/icons/build-module/library/category.mjs 13223 var import_primitives7 = __toESM(require_primitives(), 1); 13224 var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1); 13225 var category_default = /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_primitives7.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_primitives7.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M6 5.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5H6a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM4 6a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2H6a2 2 0 01-2-2V6zm11-.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5h-3a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM13 6a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2h-3a2 2 0 01-2-2V6zm5 8.5h-3a.5.5 0 00-.5.5v3a.5.5 0 00.5.5h3a.5.5 0 00.5-.5v-3a.5.5 0 00-.5-.5zM15 13a2 2 0 00-2 2v3a2 2 0 002 2h3a2 2 0 002-2v-3a2 2 0 00-2-2h-3zm-9 1.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5H6a.5.5 0 01-.5-.5v-3a.5.5 0 01.5-.5zM4 15a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2H6a2 2 0 01-2-2v-3z" }) }); 13226 13227 // packages/icons/build-module/library/caution.mjs 13228 var import_primitives8 = __toESM(require_primitives(), 1); 13229 var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1); 13230 var caution_default = /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_primitives8.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_primitives8.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M5.5 12a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0ZM12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16Zm-.75 12v-1.5h1.5V16h-1.5Zm0-8v5h1.5V8h-1.5Z" }) }); 13231 13232 // packages/icons/build-module/library/check.mjs 13233 var import_primitives9 = __toESM(require_primitives(), 1); 13234 var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1); 13235 var check_default = /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_primitives9.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_primitives9.Path, { d: "M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z" }) }); 13236 13237 // packages/icons/build-module/library/chevron-down.mjs 13238 var import_primitives10 = __toESM(require_primitives(), 1); 13239 var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1); 13240 var chevron_down_default = /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_primitives10.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_primitives10.Path, { d: "M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z" }) }); 13241 13242 // packages/icons/build-module/library/close-small.mjs 13243 var import_primitives11 = __toESM(require_primitives(), 1); 13244 var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1); 13245 var close_small_default = /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_primitives11.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_primitives11.Path, { d: "M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z" }) }); 13246 13247 // packages/icons/build-module/library/cog.mjs 13248 var import_primitives12 = __toESM(require_primitives(), 1); 13249 var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1); 13250 var cog_default = /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_primitives12.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_primitives12.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M10.289 4.836A1 1 0 0111.275 4h1.306a1 1 0 01.987.836l.244 1.466c.787.26 1.503.679 2.108 1.218l1.393-.522a1 1 0 011.216.437l.653 1.13a1 1 0 01-.23 1.273l-1.148.944a6.025 6.025 0 010 2.435l1.149.946a1 1 0 01.23 1.272l-.653 1.13a1 1 0 01-1.216.437l-1.394-.522c-.605.54-1.32.958-2.108 1.218l-.244 1.466a1 1 0 01-.987.836h-1.306a1 1 0 01-.986-.836l-.244-1.466a5.995 5.995 0 01-2.108-1.218l-1.394.522a1 1 0 01-1.217-.436l-.653-1.131a1 1 0 01.23-1.272l1.149-.946a6.026 6.026 0 010-2.435l-1.148-.944a1 1 0 01-.23-1.272l.653-1.131a1 1 0 011.217-.437l1.393.522a5.994 5.994 0 012.108-1.218l.244-1.466zM14.929 12a3 3 0 11-6 0 3 3 0 016 0z" }) }); 13251 13252 // packages/icons/build-module/library/copy.mjs 13253 var import_primitives13 = __toESM(require_primitives(), 1); 13254 var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1); 13255 var copy_default = /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_primitives13.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_primitives13.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M5 4.5h11a.5.5 0 0 1 .5.5v11a.5.5 0 0 1-.5.5H5a.5.5 0 0 1-.5-.5V5a.5.5 0 0 1 .5-.5ZM3 5a2 2 0 0 1 2-2h11a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5Zm17 3v10.75c0 .69-.56 1.25-1.25 1.25H6v1.5h12.75a2.75 2.75 0 0 0 2.75-2.75V8H20Z" }) }); 13256 13257 // packages/icons/build-module/library/envelope.mjs 13258 var import_primitives14 = __toESM(require_primitives(), 1); 13259 var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1); 13260 var envelope_default = /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_primitives14.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_primitives14.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M3 7c0-1.1.9-2 2-2h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7Zm2-.5h14c.3 0 .5.2.5.5v1L12 13.5 4.5 7.9V7c0-.3.2-.5.5-.5Zm-.5 3.3V17c0 .3.2.5.5.5h14c.3 0 .5-.2.5-.5V9.8L12 15.4 4.5 9.8Z" }) }); 13261 13262 // packages/icons/build-module/library/error.mjs 13263 var import_primitives15 = __toESM(require_primitives(), 1); 13264 var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1); 13265 var error_default = /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_primitives15.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_primitives15.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M12.218 5.377a.25.25 0 0 0-.436 0l-7.29 12.96a.25.25 0 0 0 .218.373h14.58a.25.25 0 0 0 .218-.372l-7.29-12.96Zm-1.743-.735c.669-1.19 2.381-1.19 3.05 0l7.29 12.96a1.75 1.75 0 0 1-1.525 2.608H4.71a1.75 1.75 0 0 1-1.525-2.608l7.29-12.96ZM12.75 17.46h-1.5v-1.5h1.5v1.5Zm-1.5-3h1.5v-5h-1.5v5Z" }) }); 13266 13267 // packages/icons/build-module/library/format-list-bullets-rtl.mjs 13268 var import_primitives16 = __toESM(require_primitives(), 1); 13269 var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1); 13270 var format_list_bullets_rtl_default = /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_primitives16.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_primitives16.Path, { d: "M4 8.8h8.9V7.2H4v1.6zm0 7h8.9v-1.5H4v1.5zM18 13c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-3c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2z" }) }); 13271 13272 // packages/icons/build-module/library/format-list-bullets.mjs 13273 var import_primitives17 = __toESM(require_primitives(), 1); 13274 var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1); 13275 var format_list_bullets_default = /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_primitives17.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_primitives17.Path, { d: "M11.1 15.8H20v-1.5h-8.9v1.5zm0-8.6v1.5H20V7.2h-8.9zM6 13c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-7c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z" }) }); 13276 13277 // packages/icons/build-module/library/funnel.mjs 13278 var import_primitives18 = __toESM(require_primitives(), 1); 13279 var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1); 13280 var funnel_default = /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_primitives18.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_primitives18.Path, { d: "M10 17.5H14V16H10V17.5ZM6 6V7.5H18V6H6ZM8 12.5H16V11H8V12.5Z" }) }); 13281 13282 // packages/icons/build-module/library/info.mjs 13283 var import_primitives19 = __toESM(require_primitives(), 1); 13284 var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1); 13285 var info_default = /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_primitives19.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_primitives19.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M5.5 12a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0ZM12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16Zm.75 4v1.5h-1.5V8h1.5Zm0 8v-5h-1.5v5h1.5Z" }) }); 13286 13287 // packages/icons/build-module/library/link.mjs 13288 var import_primitives20 = __toESM(require_primitives(), 1); 13289 var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1); 13290 var link_default = /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_primitives20.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_primitives20.Path, { d: "M10 17.389H8.444A5.194 5.194 0 1 1 8.444 7H10v1.5H8.444a3.694 3.694 0 0 0 0 7.389H10v1.5ZM14 7h1.556a5.194 5.194 0 0 1 0 10.39H14v-1.5h1.556a3.694 3.694 0 0 0 0-7.39H14V7Zm-4.5 6h5v-1.5h-5V13Z" }) }); 13291 13292 // packages/icons/build-module/library/mobile.mjs 13293 var import_primitives21 = __toESM(require_primitives(), 1); 13294 var import_jsx_runtime48 = __toESM(require_jsx_runtime(), 1); 13295 var mobile_default = /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_primitives21.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_primitives21.Path, { d: "M15 4H9c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h6c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm.5 14c0 .3-.2.5-.5.5H9c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h6c.3 0 .5.2.5.5v12zm-4.5-.5h2V16h-2v1.5z" }) }); 13296 13297 // packages/icons/build-module/library/more-vertical.mjs 13298 var import_primitives22 = __toESM(require_primitives(), 1); 13299 var import_jsx_runtime49 = __toESM(require_jsx_runtime(), 1); 13300 var more_vertical_default = /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_primitives22.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_primitives22.Path, { d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" }) }); 13301 13302 // packages/icons/build-module/library/next.mjs 13303 var import_primitives23 = __toESM(require_primitives(), 1); 13304 var import_jsx_runtime50 = __toESM(require_jsx_runtime(), 1); 13305 var next_default = /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_primitives23.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_primitives23.Path, { d: "M6.6 6L5.4 7l4.5 5-4.5 5 1.1 1 5.5-6-5.4-6zm6 0l-1.1 1 4.5 5-4.5 5 1.1 1 5.5-6-5.5-6z" }) }); 13306 13307 // packages/icons/build-module/library/pencil.mjs 13308 var import_primitives24 = __toESM(require_primitives(), 1); 13309 var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1); 13310 var pencil_default = /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_primitives24.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_primitives24.Path, { d: "m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z" }) }); 13311 13312 // packages/icons/build-module/library/previous.mjs 13313 var import_primitives25 = __toESM(require_primitives(), 1); 13314 var import_jsx_runtime52 = __toESM(require_jsx_runtime(), 1); 13315 var previous_default = /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_primitives25.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_primitives25.Path, { d: "M11.6 7l-1.1-1L5 12l5.5 6 1.1-1L7 12l4.6-5zm6 0l-1.1-1-5.5 6 5.5 6 1.1-1-4.6-5 4.6-5z" }) }); 13316 13317 // packages/icons/build-module/library/published.mjs 13318 var import_primitives26 = __toESM(require_primitives(), 1); 13319 var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1); 13320 var published_default = /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_primitives26.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_primitives26.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M12 18.5a6.5 6.5 0 1 1 0-13 6.5 6.5 0 0 1 0 13ZM4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Zm11.53-1.47-1.06-1.06L11 12.94l-1.47-1.47-1.06 1.06L11 15.06l4.53-4.53Z" }) }); 13321 13322 // packages/icons/build-module/library/scheduled.mjs 13323 var import_primitives27 = __toESM(require_primitives(), 1); 13324 var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1); 13325 var scheduled_default = /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_primitives27.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_primitives27.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M12 18.5a6.5 6.5 0 1 1 0-13 6.5 6.5 0 0 1 0 13ZM4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Zm9 1V8h-1.5v3.5h-2V13H13Z" }) }); 13326 13327 // packages/icons/build-module/library/search.mjs 13328 var import_primitives28 = __toESM(require_primitives(), 1); 13329 var import_jsx_runtime55 = __toESM(require_jsx_runtime(), 1); 13330 var search_default = /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_primitives28.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_primitives28.Path, { d: "M13 5c-3.3 0-6 2.7-6 6 0 1.4.5 2.7 1.3 3.7l-3.8 3.8 1.1 1.1 3.8-3.8c1 .8 2.3 1.3 3.7 1.3 3.3 0 6-2.7 6-6S16.3 5 13 5zm0 10.5c-2.5 0-4.5-2-4.5-4.5s2-4.5 4.5-4.5 4.5 2 4.5 4.5-2 4.5-4.5 4.5z" }) }); 13331 13332 // packages/icons/build-module/library/seen.mjs 13333 var import_primitives29 = __toESM(require_primitives(), 1); 13334 var import_jsx_runtime56 = __toESM(require_jsx_runtime(), 1); 13335 var seen_default = /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_primitives29.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_primitives29.Path, { d: "M3.99961 13C4.67043 13.3354 4.6703 13.3357 4.67017 13.3359L4.67298 13.3305C4.67621 13.3242 4.68184 13.3135 4.68988 13.2985C4.70595 13.2686 4.7316 13.2218 4.76695 13.1608C4.8377 13.0385 4.94692 12.8592 5.09541 12.6419C5.39312 12.2062 5.84436 11.624 6.45435 11.0431C7.67308 9.88241 9.49719 8.75 11.9996 8.75C14.502 8.75 16.3261 9.88241 17.5449 11.0431C18.1549 11.624 18.6061 12.2062 18.9038 12.6419C19.0523 12.8592 19.1615 13.0385 19.2323 13.1608C19.2676 13.2218 19.2933 13.2686 19.3093 13.2985C19.3174 13.3135 19.323 13.3242 19.3262 13.3305L19.3291 13.3359C19.3289 13.3357 19.3288 13.3354 19.9996 13C20.6704 12.6646 20.6703 12.6643 20.6701 12.664L20.6697 12.6632L20.6688 12.6614L20.6662 12.6563L20.6583 12.6408C20.6517 12.6282 20.6427 12.6108 20.631 12.5892C20.6078 12.5459 20.5744 12.4852 20.5306 12.4096C20.4432 12.2584 20.3141 12.0471 20.1423 11.7956C19.7994 11.2938 19.2819 10.626 18.5794 9.9569C17.1731 8.61759 14.9972 7.25 11.9996 7.25C9.00203 7.25 6.82614 8.61759 5.41987 9.9569C4.71736 10.626 4.19984 11.2938 3.85694 11.7956C3.68511 12.0471 3.55605 12.2584 3.4686 12.4096C3.42484 12.4852 3.39142 12.5459 3.36818 12.5892C3.35656 12.6108 3.34748 12.6282 3.34092 12.6408L3.33297 12.6563L3.33041 12.6614L3.32948 12.6632L3.32911 12.664C3.32894 12.6643 3.32879 12.6646 3.99961 13ZM11.9996 16C13.9326 16 15.4996 14.433 15.4996 12.5C15.4996 10.567 13.9326 9 11.9996 9C10.0666 9 8.49961 10.567 8.49961 12.5C8.49961 14.433 10.0666 16 11.9996 16Z" }) }); 13336 13337 // packages/icons/build-module/library/trash.mjs 13338 var import_primitives30 = __toESM(require_primitives(), 1); 13339 var import_jsx_runtime57 = __toESM(require_jsx_runtime(), 1); 13340 var trash_default = /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(import_primitives30.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(import_primitives30.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M12 5.5A2.25 2.25 0 0 0 9.878 7h4.244A2.251 2.251 0 0 0 12 5.5ZM12 4a3.751 3.751 0 0 0-3.675 3H5v1.5h1.27l.818 8.997a2.75 2.75 0 0 0 2.739 2.501h4.347a2.75 2.75 0 0 0 2.738-2.5L17.73 8.5H19V7h-3.325A3.751 3.751 0 0 0 12 4Zm4.224 4.5H7.776l.806 8.861a1.25 1.25 0 0 0 1.245 1.137h4.347a1.25 1.25 0 0 0 1.245-1.137l.805-8.861Z" }) }); 13341 13342 // packages/icons/build-module/library/unseen.mjs 13343 var import_primitives31 = __toESM(require_primitives(), 1); 13344 var import_jsx_runtime58 = __toESM(require_jsx_runtime(), 1); 13345 var unseen_default = /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_primitives31.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_primitives31.Path, { d: "M20.7 12.7s0-.1-.1-.2c0-.2-.2-.4-.4-.6-.3-.5-.9-1.2-1.6-1.8-.7-.6-1.5-1.3-2.6-1.8l-.6 1.4c.9.4 1.6 1 2.1 1.5.6.6 1.1 1.2 1.4 1.6.1.2.3.4.3.5v.1l.7-.3.7-.3Zm-5.2-9.3-1.8 4c-.5-.1-1.1-.2-1.7-.2-3 0-5.2 1.4-6.6 2.7-.7.7-1.2 1.3-1.6 1.8-.2.3-.3.5-.4.6 0 0 0 .1-.1.2s0 0 .7.3l.7.3V13c0-.1.2-.3.3-.5.3-.4.7-1 1.4-1.6 1.2-1.2 3-2.3 5.5-2.3H13v.3c-.4 0-.8-.1-1.1-.1-1.9 0-3.5 1.6-3.5 3.5s.6 2.3 1.6 2.9l-2 4.4.9.4 7.6-16.2-.9-.4Zm-3 12.6c1.7-.2 3-1.7 3-3.5s-.2-1.4-.6-1.9L12.4 16Z" }) }); 13346 13347 // packages/ui/build-module/collapsible-card/context.mjs 13348 var import_element26 = __toESM(require_element(), 1); 13349 var HeaderDescriptionIdContext = (0, import_element26.createContext)({ 13350 setDescriptionId: () => { 13351 } 13352 }); 13353 13354 // packages/ui/build-module/collapsible-card/header.mjs 13355 var import_jsx_runtime59 = __toESM(require_jsx_runtime(), 1); 13356 var STYLE_HASH_ATTRIBUTE9 = "data-wp-hash"; 13357 function getRuntime9() { 13358 const globalScope = globalThis; 13359 if (globalScope.__wpStyleRuntime) { 13360 return globalScope.__wpStyleRuntime; 13361 } 13362 globalScope.__wpStyleRuntime = { 13363 documents: /* @__PURE__ */ new Map(), 13364 styles: /* @__PURE__ */ new Map(), 13365 injectedStyles: /* @__PURE__ */ new WeakMap() 13366 }; 13367 if (typeof document !== "undefined") { 13368 registerDocument9(document); 13369 } 13370 return globalScope.__wpStyleRuntime; 13371 } 13372 function documentContainsStyleHash9(targetDocument, hash) { 13373 if (!targetDocument.head) { 13374 return false; 13375 } 13376 for (const style of targetDocument.head.querySelectorAll( 13377 `style[$STYLE_HASH_ATTRIBUTE9}]` 13378 )) { 13379 if (style.getAttribute(STYLE_HASH_ATTRIBUTE9) === hash) { 13380 return true; 13381 } 13382 } 13383 return false; 13384 } 13385 function injectStyle9(targetDocument, hash, css) { 13386 if (!targetDocument.head) { 13387 return; 13388 } 13389 const runtime = getRuntime9(); 13390 let injectedStyles = runtime.injectedStyles.get(targetDocument); 13391 if (!injectedStyles) { 13392 injectedStyles = /* @__PURE__ */ new Set(); 13393 runtime.injectedStyles.set(targetDocument, injectedStyles); 13394 } 13395 if (injectedStyles.has(hash)) { 13396 return; 13397 } 13398 if (documentContainsStyleHash9(targetDocument, hash)) { 13399 injectedStyles.add(hash); 13400 return; 13401 } 13402 const style = targetDocument.createElement("style"); 13403 style.setAttribute(STYLE_HASH_ATTRIBUTE9, hash); 13404 style.appendChild(targetDocument.createTextNode(css)); 13405 targetDocument.head.appendChild(style); 13406 injectedStyles.add(hash); 13407 } 13408 function registerDocument9(targetDocument) { 13409 const runtime = getRuntime9(); 13410 runtime.documents.set( 13411 targetDocument, 13412 (runtime.documents.get(targetDocument) ?? 0) + 1 13413 ); 13414 for (const [hash, css] of runtime.styles) { 13415 injectStyle9(targetDocument, hash, css); 13416 } 13417 return () => { 13418 const count = runtime.documents.get(targetDocument); 13419 if (count === void 0) { 13420 return; 13421 } 13422 if (count <= 1) { 13423 runtime.documents.delete(targetDocument); 13424 return; 13425 } 13426 runtime.documents.set(targetDocument, count - 1); 13427 }; 13428 } 13429 function registerStyle9(hash, css) { 13430 const runtime = getRuntime9(); 13431 runtime.styles.set(hash, css); 13432 for (const targetDocument of runtime.documents.keys()) { 13433 injectStyle9(targetDocument, hash, css); 13434 } 13435 } 13436 if (typeof process === "undefined" || true) { 13437 registerStyle9("78199613cf", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._626190151275d6d3__heading-wrapper{--_gcd-heading-color:inherit;--_gcd-heading-font-size:inherit;--_gcd-heading-font-weight:inherit;--_gcd-heading-margin:0;font-family:inherit;line-height:inherit}.cab17c7a373cb60d__header-content{flex:1;min-width:0}.dd89d27c4f15912d__header-trigger-positioner{align-self:center;flex-shrink:0;max-height:0;overflow:visible}.bcfab5f2448bafef__header-trigger-wrapper{border-radius:var(--wpds-border-radius-sm,2px);display:flex;translate:0 -50%}._3106f8d2b0330faa__header-trigger{@media not (prefers-reduced-motion){transition:rotate .15s ease-out}}._5d2dfcb4085c6d0f__header[data-panel-open] ._3106f8d2b0330faa__header-trigger{rotate:180deg}._5d2dfcb4085c6d0f__header[data-disabled] ._3106f8d2b0330faa__header-trigger{color:var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d)}.e34cf37ccd0d81e0__content{height:var(--collapsible-panel-height);margin-block-start:var(--wp-ui-card-header-content-margin);overflow:hidden;&._03cfdbcd710393c9__overflow-visible{overflow:visible}&[hidden]:not([hidden=until-found]){display:none}&[data-ending-style],&[data-starting-style]{height:0}@media not (prefers-reduced-motion){transition:all .15s ease-out}}}@layer compositions{._41bfdbf7b6c087c2__content-inner{padding-block-start:0}._5d2dfcb4085c6d0f__header{align-items:stretch;display:flex;flex-direction:row;gap:var(--wpds-dimension-gap-sm,8px);outline:none;&:not([data-disabled]){cursor:var(--wpds-cursor-control,pointer)}}}}"); 13438 } 13439 var style_default9 = { "heading-wrapper": "_626190151275d6d3__heading-wrapper", "header-content": "cab17c7a373cb60d__header-content", "header-trigger-positioner": "dd89d27c4f15912d__header-trigger-positioner", "header-trigger-wrapper": "bcfab5f2448bafef__header-trigger-wrapper", "header-trigger": "_3106f8d2b0330faa__header-trigger", "header": "_5d2dfcb4085c6d0f__header", "content": "e34cf37ccd0d81e0__content", "overflow-visible": "_03cfdbcd710393c9__overflow-visible", "content-inner": "_41bfdbf7b6c087c2__content-inner" }; 13440 if (typeof process === "undefined" || true) { 13441 registerStyle9("af6d9984a6", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,transparent);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 transparent);color:var(--_gcd-input-color,var(--wpds-color-foreground-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,transparent);border-color:var(--_gcd-input-border-color-disabled,transparent);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid transparent)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-foreground-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-emphasis,600));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid transparent);transition:var(--_gcd-a-transition,none)}"); 13442 } 13443 var global_css_defense_default3 = { "button": "_6defc79820e382c6__button", "input": "d2cff2e5dea83bd1__input", "textarea": "_547d86373d02e108__textarea", "div": "_8c15fd0ed9f28ba4__div", "p": "_43cec3e1eec1066d__p", "heading": "e97669c6d9a38497__heading", "a": "_2c0831b0499dbd6e__a" }; 13444 if (typeof process === "undefined" || true) { 13445 registerStyle9("da99a163ac", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._08e8a2e44959f892__outset-ring--focus:focus,.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,:focus-visible .ecadb9e080e2dfa5__outset-ring--focus-parent-visible{--_gcd-a-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9));--_gcd-div-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9));outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9));outline-offset:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px))}._970d04df7376df67__outset-ring--focus-within-except-active:focus-within,.e25b2bdd7aa21721__outset-ring--focus-except-active:focus{outline:none}._970d04df7376df67__outset-ring--focus-within-except-active:focus-within:not(:has(:active)),.e25b2bdd7aa21721__outset-ring--focus-except-active:focus:not(:active){@include mixins.focus-ring()}}}"); 13446 } 13447 var focus_default2 = { "outset-ring--focus": "_08e8a2e44959f892__outset-ring--focus", "outset-ring--focus-visible": "d0541bc9dd9dc7b6__outset-ring--focus-visible", "outset-ring--focus-within": "cd83dfc2126a0846__outset-ring--focus-within", "outset-ring--focus-within-visible": "c5cb3ee4bddaa8e4__outset-ring--focus-within-visible", "outset-ring--focus-parent-visible": "ecadb9e080e2dfa5__outset-ring--focus-parent-visible", "outset-ring--focus-except-active": "e25b2bdd7aa21721__outset-ring--focus-except-active", "outset-ring--focus-within-except-active": "_970d04df7376df67__outset-ring--focus-within-except-active" }; 13448 var Header2 = (0, import_element27.forwardRef)( 13449 function CollapsibleCardHeader({ children, className, render: render4, ...restProps }, ref) { 13450 const [descriptionId, setDescriptionId] = (0, import_element27.useState)(); 13451 const contextValue = (0, import_element27.useMemo)( 13452 () => ({ setDescriptionId }), 13453 [setDescriptionId] 13454 ); 13455 return useRender({ 13456 defaultTagName: "div", 13457 render: render4, 13458 ref, 13459 props: mergeProps(restProps, { 13460 className: clsx_default( 13461 global_css_defense_default3.heading, 13462 style_default9["heading-wrapper"], 13463 className 13464 ), 13465 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(HeaderDescriptionIdContext.Provider, { value: contextValue, children: /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)( 13466 Trigger, 13467 { 13468 className: style_default9.header, 13469 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(Header, {}), 13470 nativeButton: false, 13471 "aria-describedby": descriptionId, 13472 children: [ 13473 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className: style_default9["header-content"], children }), 13474 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 13475 "div", 13476 { 13477 className: clsx_default( 13478 style_default9["header-trigger-positioner"] 13479 ), 13480 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 13481 "div", 13482 { 13483 className: clsx_default( 13484 style_default9["header-trigger-wrapper"], 13485 global_css_defense_default3.div, 13486 // While the interactive trigger element is the whole header, 13487 // the focus ring will be displayed only on the icon to visually 13488 // emulate it being the button. 13489 focus_default2["outset-ring--focus-parent-visible"] 13490 ), 13491 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 13492 Icon, 13493 { 13494 icon: chevron_down_default, 13495 className: style_default9["header-trigger"] 13496 } 13497 ) 13498 } 13499 ) 13500 } 13501 ) 13502 ] 13503 } 13504 ) }) 13505 }) 13506 }); 13507 } 13508 ); 13509 13510 // packages/ui/build-module/collapsible-card/header-description.mjs 13511 var import_element28 = __toESM(require_element(), 1); 13512 var import_jsx_runtime60 = __toESM(require_jsx_runtime(), 1); 13513 var HeaderDescription = (0, import_element28.forwardRef)(function CollapsibleCardHeaderDescription({ children, className, ...restProps }, ref) { 13514 const descriptionId = (0, import_element28.useId)(); 13515 const { setDescriptionId } = (0, import_element28.useContext)(HeaderDescriptionIdContext); 13516 (0, import_element28.useEffect)(() => { 13517 setDescriptionId(descriptionId); 13518 return () => setDescriptionId(void 0); 13519 }, [descriptionId, setDescriptionId]); 13520 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)( 13521 "div", 13522 { 13523 ref, 13524 id: descriptionId, 13525 "aria-hidden": "true", 13526 className, 13527 ...restProps, 13528 children 13529 } 13530 ); 13531 }); 13532 13533 // packages/ui/build-module/collapsible-card/content.mjs 13534 var import_element29 = __toESM(require_element(), 1); 13535 var import_jsx_runtime61 = __toESM(require_jsx_runtime(), 1); 13536 var STYLE_HASH_ATTRIBUTE10 = "data-wp-hash"; 13537 function getRuntime10() { 13538 const globalScope = globalThis; 13539 if (globalScope.__wpStyleRuntime) { 13540 return globalScope.__wpStyleRuntime; 13541 } 13542 globalScope.__wpStyleRuntime = { 13543 documents: /* @__PURE__ */ new Map(), 13544 styles: /* @__PURE__ */ new Map(), 13545 injectedStyles: /* @__PURE__ */ new WeakMap() 13546 }; 13547 if (typeof document !== "undefined") { 13548 registerDocument10(document); 13549 } 13550 return globalScope.__wpStyleRuntime; 13551 } 13552 function documentContainsStyleHash10(targetDocument, hash) { 13553 if (!targetDocument.head) { 13554 return false; 13555 } 13556 for (const style of targetDocument.head.querySelectorAll( 13557 `style[$STYLE_HASH_ATTRIBUTE10}]` 13558 )) { 13559 if (style.getAttribute(STYLE_HASH_ATTRIBUTE10) === hash) { 13560 return true; 13561 } 13562 } 13563 return false; 13564 } 13565 function injectStyle10(targetDocument, hash, css) { 13566 if (!targetDocument.head) { 13567 return; 13568 } 13569 const runtime = getRuntime10(); 13570 let injectedStyles = runtime.injectedStyles.get(targetDocument); 13571 if (!injectedStyles) { 13572 injectedStyles = /* @__PURE__ */ new Set(); 13573 runtime.injectedStyles.set(targetDocument, injectedStyles); 13574 } 13575 if (injectedStyles.has(hash)) { 13576 return; 13577 } 13578 if (documentContainsStyleHash10(targetDocument, hash)) { 13579 injectedStyles.add(hash); 13580 return; 13581 } 13582 const style = targetDocument.createElement("style"); 13583 style.setAttribute(STYLE_HASH_ATTRIBUTE10, hash); 13584 style.appendChild(targetDocument.createTextNode(css)); 13585 targetDocument.head.appendChild(style); 13586 injectedStyles.add(hash); 13587 } 13588 function registerDocument10(targetDocument) { 13589 const runtime = getRuntime10(); 13590 runtime.documents.set( 13591 targetDocument, 13592 (runtime.documents.get(targetDocument) ?? 0) + 1 13593 ); 13594 for (const [hash, css] of runtime.styles) { 13595 injectStyle10(targetDocument, hash, css); 13596 } 13597 return () => { 13598 const count = runtime.documents.get(targetDocument); 13599 if (count === void 0) { 13600 return; 13601 } 13602 if (count <= 1) { 13603 runtime.documents.delete(targetDocument); 13604 return; 13605 } 13606 runtime.documents.set(targetDocument, count - 1); 13607 }; 13608 } 13609 function registerStyle10(hash, css) { 13610 const runtime = getRuntime10(); 13611 runtime.styles.set(hash, css); 13612 for (const targetDocument of runtime.documents.keys()) { 13613 injectStyle10(targetDocument, hash, css); 13614 } 13615 } 13616 if (typeof process === "undefined" || true) { 13617 registerStyle10("78199613cf", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._626190151275d6d3__heading-wrapper{--_gcd-heading-color:inherit;--_gcd-heading-font-size:inherit;--_gcd-heading-font-weight:inherit;--_gcd-heading-margin:0;font-family:inherit;line-height:inherit}.cab17c7a373cb60d__header-content{flex:1;min-width:0}.dd89d27c4f15912d__header-trigger-positioner{align-self:center;flex-shrink:0;max-height:0;overflow:visible}.bcfab5f2448bafef__header-trigger-wrapper{border-radius:var(--wpds-border-radius-sm,2px);display:flex;translate:0 -50%}._3106f8d2b0330faa__header-trigger{@media not (prefers-reduced-motion){transition:rotate .15s ease-out}}._5d2dfcb4085c6d0f__header[data-panel-open] ._3106f8d2b0330faa__header-trigger{rotate:180deg}._5d2dfcb4085c6d0f__header[data-disabled] ._3106f8d2b0330faa__header-trigger{color:var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d)}.e34cf37ccd0d81e0__content{height:var(--collapsible-panel-height);margin-block-start:var(--wp-ui-card-header-content-margin);overflow:hidden;&._03cfdbcd710393c9__overflow-visible{overflow:visible}&[hidden]:not([hidden=until-found]){display:none}&[data-ending-style],&[data-starting-style]{height:0}@media not (prefers-reduced-motion){transition:all .15s ease-out}}}@layer compositions{._41bfdbf7b6c087c2__content-inner{padding-block-start:0}._5d2dfcb4085c6d0f__header{align-items:stretch;display:flex;flex-direction:row;gap:var(--wpds-dimension-gap-sm,8px);outline:none;&:not([data-disabled]){cursor:var(--wpds-cursor-control,pointer)}}}}"); 13618 } 13619 var style_default10 = { "heading-wrapper": "_626190151275d6d3__heading-wrapper", "header-content": "cab17c7a373cb60d__header-content", "header-trigger-positioner": "dd89d27c4f15912d__header-trigger-positioner", "header-trigger-wrapper": "bcfab5f2448bafef__header-trigger-wrapper", "header-trigger": "_3106f8d2b0330faa__header-trigger", "header": "_5d2dfcb4085c6d0f__header", "content": "e34cf37ccd0d81e0__content", "overflow-visible": "_03cfdbcd710393c9__overflow-visible", "content-inner": "_41bfdbf7b6c087c2__content-inner" }; 13620 var Content2 = (0, import_element29.forwardRef)( 13621 function CollapsibleCardContent({ className, render: render4, children, hiddenUntilFound = true, ...restProps }, ref) { 13622 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 13623 Panel, 13624 { 13625 ref, 13626 className: (state) => clsx_default( 13627 style_default10.content, 13628 state.open && state.transitionStatus === "idle" && style_default10["overflow-visible"], 13629 className 13630 ), 13631 hiddenUntilFound, 13632 ...restProps, 13633 children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 13634 Content, 13635 { 13636 className: style_default10["content-inner"], 13637 render: render4, 13638 children 13639 } 13640 ) 13641 } 13642 ); 13643 } 13644 ); 13645 13646 // packages/ui/build-module/utils/render-slot-with-children.mjs 13647 var import_element30 = __toESM(require_element(), 1); 13648 function renderSlotWithChildren(slot, defaultSlot, children) { 13649 return (0, import_element30.cloneElement)(slot ?? defaultSlot, { children }); 13650 } 13651 13652 // packages/ui/build-module/utils/use-deprioritized-initial-focus.mjs 13653 var import_element31 = __toESM(require_element(), 1); 13654 13655 // node_modules/tabbable/dist/index.esm.js 13656 var candidateSelectors = ["input:not([inert]):not([inert] *)", "select:not([inert]):not([inert] *)", "textarea:not([inert]):not([inert] *)", "a[href]:not([inert]):not([inert] *)", "button:not([inert]):not([inert] *)", "[tabindex]:not(slot):not([inert]):not([inert] *)", "audio[controls]:not([inert]):not([inert] *)", "video[controls]:not([inert]):not([inert] *)", '[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)', "details>summary:first-of-type:not([inert]):not([inert] *)", "details:not([inert]):not([inert] *)"]; 13657 var candidateSelector = /* @__PURE__ */ candidateSelectors.join(","); 13658 var NoElement = typeof Element === "undefined"; 13659 var matches = NoElement ? function() { 13660 } : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector; 13661 var getRootNode = !NoElement && Element.prototype.getRootNode ? function(element) { 13662 var _element$getRootNode; 13663 return element === null || element === void 0 ? void 0 : (_element$getRootNode = element.getRootNode) === null || _element$getRootNode === void 0 ? void 0 : _element$getRootNode.call(element); 13664 } : function(element) { 13665 return element === null || element === void 0 ? void 0 : element.ownerDocument; 13666 }; 13667 var _isInert = function isInert(node, lookUp) { 13668 var _node$getAttribute; 13669 if (lookUp === void 0) { 13670 lookUp = true; 13671 } 13672 var inertAtt = node === null || node === void 0 ? void 0 : (_node$getAttribute = node.getAttribute) === null || _node$getAttribute === void 0 ? void 0 : _node$getAttribute.call(node, "inert"); 13673 var inert = inertAtt === "" || inertAtt === "true"; 13674 var result = inert || lookUp && node && // closest does not exist on shadow roots, so we fall back to a manual 13675 // lookup upward, in case it is not defined. 13676 (typeof node.closest === "function" ? node.closest("[inert]") : _isInert(node.parentNode)); 13677 return result; 13678 }; 13679 var isContentEditable = function isContentEditable2(node) { 13680 var _node$getAttribute2; 13681 var attValue = node === null || node === void 0 ? void 0 : (_node$getAttribute2 = node.getAttribute) === null || _node$getAttribute2 === void 0 ? void 0 : _node$getAttribute2.call(node, "contenteditable"); 13682 return attValue === "" || attValue === "true"; 13683 }; 13684 var getCandidates = function getCandidates2(el, includeContainer, filter) { 13685 if (_isInert(el)) { 13686 return []; 13687 } 13688 var candidates = Array.prototype.slice.apply(el.querySelectorAll(candidateSelector)); 13689 if (includeContainer && matches.call(el, candidateSelector)) { 13690 candidates.unshift(el); 13691 } 13692 candidates = candidates.filter(filter); 13693 return candidates; 13694 }; 13695 var _getCandidatesIteratively = function getCandidatesIteratively(elements, includeContainer, options) { 13696 var candidates = []; 13697 var elementsToCheck = Array.from(elements); 13698 while (elementsToCheck.length) { 13699 var element = elementsToCheck.shift(); 13700 if (_isInert(element, false)) { 13701 continue; 13702 } 13703 if (element.tagName === "SLOT") { 13704 var assigned = element.assignedElements(); 13705 var content = assigned.length ? assigned : element.children; 13706 var nestedCandidates = _getCandidatesIteratively(content, true, options); 13707 if (options.flatten) { 13708 candidates.push.apply(candidates, nestedCandidates); 13709 } else { 13710 candidates.push({ 13711 scopeParent: element, 13712 candidates: nestedCandidates 13713 }); 13714 } 13715 } else { 13716 var validCandidate = matches.call(element, candidateSelector); 13717 if (validCandidate && options.filter(element) && (includeContainer || !elements.includes(element))) { 13718 candidates.push(element); 13719 } 13720 var shadowRoot = element.shadowRoot || // check for an undisclosed shadow 13721 typeof options.getShadowRoot === "function" && options.getShadowRoot(element); 13722 var validShadowRoot = !_isInert(shadowRoot, false) && (!options.shadowRootFilter || options.shadowRootFilter(element)); 13723 if (shadowRoot && validShadowRoot) { 13724 var _nestedCandidates = _getCandidatesIteratively(shadowRoot === true ? element.children : shadowRoot.children, true, options); 13725 if (options.flatten) { 13726 candidates.push.apply(candidates, _nestedCandidates); 13727 } else { 13728 candidates.push({ 13729 scopeParent: element, 13730 candidates: _nestedCandidates 13731 }); 13732 } 13733 } else { 13734 elementsToCheck.unshift.apply(elementsToCheck, element.children); 13735 } 13736 } 13737 } 13738 return candidates; 13739 }; 13740 var hasTabIndex = function hasTabIndex2(node) { 13741 return !isNaN(parseInt(node.getAttribute("tabindex"), 10)); 13742 }; 13743 var getTabIndex2 = function getTabIndex3(node) { 13744 if (!node) { 13745 throw new Error("No node provided"); 13746 } 13747 if (node.tabIndex < 0) { 13748 if ((/^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName) || isContentEditable(node)) && !hasTabIndex(node)) { 13749 return 0; 13750 } 13751 } 13752 return node.tabIndex; 13753 }; 13754 var getSortOrderTabIndex = function getSortOrderTabIndex2(node, isScope) { 13755 var tabIndex = getTabIndex2(node); 13756 if (tabIndex < 0 && isScope && !hasTabIndex(node)) { 13757 return 0; 13758 } 13759 return tabIndex; 13760 }; 13761 var sortOrderedTabbables = function sortOrderedTabbables2(a2, b2) { 13762 return a2.tabIndex === b2.tabIndex ? a2.documentOrder - b2.documentOrder : a2.tabIndex - b2.tabIndex; 13763 }; 13764 var isInput = function isInput2(node) { 13765 return node.tagName === "INPUT"; 13766 }; 13767 var isHiddenInput = function isHiddenInput2(node) { 13768 return isInput(node) && node.type === "hidden"; 13769 }; 13770 var isDetailsWithSummary = function isDetailsWithSummary2(node) { 13771 var r3 = node.tagName === "DETAILS" && Array.prototype.slice.apply(node.children).some(function(child) { 13772 return child.tagName === "SUMMARY"; 13773 }); 13774 return r3; 13775 }; 13776 var getCheckedRadio = function getCheckedRadio2(nodes, form) { 13777 for (var i2 = 0; i2 < nodes.length; i2++) { 13778 if (nodes[i2].checked && nodes[i2].form === form) { 13779 return nodes[i2]; 13780 } 13781 } 13782 }; 13783 var isTabbableRadio2 = function isTabbableRadio3(node) { 13784 if (!node.name) { 13785 return true; 13786 } 13787 var radioScope = node.form || getRootNode(node); 13788 var queryRadios = function queryRadios2(name) { 13789 return radioScope.querySelectorAll('input[type="radio"][name="' + name + '"]'); 13790 }; 13791 var radioSet; 13792 if (typeof window !== "undefined" && typeof window.CSS !== "undefined" && typeof window.CSS.escape === "function") { 13793 radioSet = queryRadios(window.CSS.escape(node.name)); 13794 } else { 13795 try { 13796 radioSet = queryRadios(node.name); 13797 } catch (err) { 13798 console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s", err.message); 13799 return false; 13800 } 13801 } 13802 var checked = getCheckedRadio(radioSet, node.form); 13803 return !checked || checked === node; 13804 }; 13805 var isRadio = function isRadio2(node) { 13806 return isInput(node) && node.type === "radio"; 13807 }; 13808 var isNonTabbableRadio = function isNonTabbableRadio2(node) { 13809 return isRadio(node) && !isTabbableRadio2(node); 13810 }; 13811 var isNodeAttached = function isNodeAttached2(node) { 13812 var _nodeRoot; 13813 var nodeRoot = node && getRootNode(node); 13814 var nodeRootHost = (_nodeRoot = nodeRoot) === null || _nodeRoot === void 0 ? void 0 : _nodeRoot.host; 13815 var attached = false; 13816 if (nodeRoot && nodeRoot !== node) { 13817 var _nodeRootHost, _nodeRootHost$ownerDo, _node$ownerDocument; 13818 attached = !!((_nodeRootHost = nodeRootHost) !== null && _nodeRootHost !== void 0 && (_nodeRootHost$ownerDo = _nodeRootHost.ownerDocument) !== null && _nodeRootHost$ownerDo !== void 0 && _nodeRootHost$ownerDo.contains(nodeRootHost) || node !== null && node !== void 0 && (_node$ownerDocument = node.ownerDocument) !== null && _node$ownerDocument !== void 0 && _node$ownerDocument.contains(node)); 13819 while (!attached && nodeRootHost) { 13820 var _nodeRoot2, _nodeRootHost2, _nodeRootHost2$ownerD; 13821 nodeRoot = getRootNode(nodeRootHost); 13822 nodeRootHost = (_nodeRoot2 = nodeRoot) === null || _nodeRoot2 === void 0 ? void 0 : _nodeRoot2.host; 13823 attached = !!((_nodeRootHost2 = nodeRootHost) !== null && _nodeRootHost2 !== void 0 && (_nodeRootHost2$ownerD = _nodeRootHost2.ownerDocument) !== null && _nodeRootHost2$ownerD !== void 0 && _nodeRootHost2$ownerD.contains(nodeRootHost)); 13824 } 13825 } 13826 return attached; 13827 }; 13828 var isZeroArea = function isZeroArea2(node) { 13829 var _node$getBoundingClie = node.getBoundingClientRect(), width = _node$getBoundingClie.width, height = _node$getBoundingClie.height; 13830 return width === 0 && height === 0; 13831 }; 13832 var isHidden = function isHidden2(node, _ref) { 13833 var displayCheck = _ref.displayCheck, getShadowRoot = _ref.getShadowRoot; 13834 if (displayCheck === "full-native") { 13835 if ("checkVisibility" in node) { 13836 var visible = node.checkVisibility({ 13837 // Checking opacity might be desirable for some use cases, but natively, 13838 // opacity zero elements _are_ focusable and tabbable. 13839 checkOpacity: false, 13840 opacityProperty: false, 13841 contentVisibilityAuto: true, 13842 visibilityProperty: true, 13843 // This is an alias for `visibilityProperty`. Contemporary browsers 13844 // support both. However, this alias has wider browser support (Chrome 13845 // >= 105 and Firefox >= 106, vs. Chrome >= 121 and Firefox >= 122), so 13846 // we include it anyway. 13847 checkVisibilityCSS: true 13848 }); 13849 return !visible; 13850 } 13851 } 13852 if (getComputedStyle(node).visibility === "hidden") { 13853 return true; 13854 } 13855 var isDirectSummary = matches.call(node, "details>summary:first-of-type"); 13856 var nodeUnderDetails = isDirectSummary ? node.parentElement : node; 13857 if (matches.call(nodeUnderDetails, "details:not([open]) *")) { 13858 return true; 13859 } 13860 if (!displayCheck || displayCheck === "full" || // full-native can run this branch when it falls through in case 13861 // Element#checkVisibility is unsupported 13862 displayCheck === "full-native" || displayCheck === "legacy-full") { 13863 if (typeof getShadowRoot === "function") { 13864 var originalNode = node; 13865 while (node) { 13866 var parentElement = node.parentElement; 13867 var rootNode = getRootNode(node); 13868 if (parentElement && !parentElement.shadowRoot && getShadowRoot(parentElement) === true) { 13869 return isZeroArea(node); 13870 } else if (node.assignedSlot) { 13871 node = node.assignedSlot; 13872 } else if (!parentElement && rootNode !== node.ownerDocument) { 13873 node = rootNode.host; 13874 } else { 13875 node = parentElement; 13876 } 13877 } 13878 node = originalNode; 13879 } 13880 if (isNodeAttached(node)) { 13881 return !node.getClientRects().length; 13882 } 13883 if (displayCheck !== "legacy-full") { 13884 return true; 13885 } 13886 } else if (displayCheck === "non-zero-area") { 13887 return isZeroArea(node); 13888 } 13889 return false; 13890 }; 13891 var isDisabledFromFieldset = function isDisabledFromFieldset2(node) { 13892 if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(node.tagName)) { 13893 var parentNode = node.parentElement; 13894 while (parentNode) { 13895 if (parentNode.tagName === "FIELDSET" && parentNode.disabled) { 13896 for (var i2 = 0; i2 < parentNode.children.length; i2++) { 13897 var child = parentNode.children.item(i2); 13898 if (child.tagName === "LEGEND") { 13899 return matches.call(parentNode, "fieldset[disabled] *") ? true : !child.contains(node); 13900 } 13901 } 13902 return true; 13903 } 13904 parentNode = parentNode.parentElement; 13905 } 13906 } 13907 return false; 13908 }; 13909 var isNodeMatchingSelectorFocusable = function isNodeMatchingSelectorFocusable2(options, node) { 13910 if (node.disabled || isHiddenInput(node) || isHidden(node, options) || // For a details element with a summary, the summary element gets the focus 13911 isDetailsWithSummary(node) || isDisabledFromFieldset(node)) { 13912 return false; 13913 } 13914 return true; 13915 }; 13916 var isNodeMatchingSelectorTabbable = function isNodeMatchingSelectorTabbable2(options, node) { 13917 if (isNonTabbableRadio(node) || getTabIndex2(node) < 0 || !isNodeMatchingSelectorFocusable(options, node)) { 13918 return false; 13919 } 13920 return true; 13921 }; 13922 var isShadowRootTabbable = function isShadowRootTabbable2(shadowHostNode) { 13923 var tabIndex = parseInt(shadowHostNode.getAttribute("tabindex"), 10); 13924 if (isNaN(tabIndex) || tabIndex >= 0) { 13925 return true; 13926 } 13927 return false; 13928 }; 13929 var _sortByOrder = function sortByOrder(candidates) { 13930 var regularTabbables = []; 13931 var orderedTabbables = []; 13932 candidates.forEach(function(item, i2) { 13933 var isScope = !!item.scopeParent; 13934 var element = isScope ? item.scopeParent : item; 13935 var candidateTabindex = getSortOrderTabIndex(element, isScope); 13936 var elements = isScope ? _sortByOrder(item.candidates) : element; 13937 if (candidateTabindex === 0) { 13938 isScope ? regularTabbables.push.apply(regularTabbables, elements) : regularTabbables.push(element); 13939 } else { 13940 orderedTabbables.push({ 13941 documentOrder: i2, 13942 tabIndex: candidateTabindex, 13943 item, 13944 isScope, 13945 content: elements 13946 }); 13947 } 13948 }); 13949 return orderedTabbables.sort(sortOrderedTabbables).reduce(function(acc, sortable) { 13950 sortable.isScope ? acc.push.apply(acc, sortable.content) : acc.push(sortable.content); 13951 return acc; 13952 }, []).concat(regularTabbables); 13953 }; 13954 var tabbable2 = function tabbable3(container, options) { 13955 options = options || {}; 13956 var candidates; 13957 if (options.getShadowRoot) { 13958 candidates = _getCandidatesIteratively([container], options.includeContainer, { 13959 filter: isNodeMatchingSelectorTabbable.bind(null, options), 13960 flatten: false, 13961 getShadowRoot: options.getShadowRoot, 13962 shadowRootFilter: isShadowRootTabbable 13963 }); 13964 } else { 13965 candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorTabbable.bind(null, options)); 13966 } 13967 return _sortByOrder(candidates); 13968 }; 13969 13970 // packages/ui/build-module/utils/use-deprioritized-initial-focus.mjs 13971 var getTabbableOptions = () => ({ 13972 getShadowRoot: true, 13973 displayCheck: typeof ResizeObserver === "function" && ResizeObserver.toString().includes("[native code]") ? "full" : "none" 13974 }); 13975 function useDeprioritizedInitialFocus({ 13976 initialFocus, 13977 deprioritizedAttributes 13978 }) { 13979 const popupRef = (0, import_element31.useRef)(null); 13980 let resolvedInitialFocus = initialFocus; 13981 if (initialFocus === void 0 || initialFocus === true) { 13982 resolvedInitialFocus = (interactionType) => { 13983 if (interactionType === "touch") { 13984 return popupRef.current ?? true; 13985 } 13986 const popup = popupRef.current; 13987 if (!popup) { 13988 return true; 13989 } 13990 const tabbables = tabbable2(popup, getTabbableOptions()); 13991 for (const el of tabbables) { 13992 if (el instanceof HTMLElement && !deprioritizedAttributes.some( 13993 (attr2) => el.hasAttribute(attr2) 13994 )) { 13995 return el; 13996 } 13997 } 13998 return true; 13999 }; 14000 } 14001 return { resolvedInitialFocus, popupRef }; 14002 } 14003 14004 // packages/ui/build-module/utils/theme-provider.mjs 14005 var theme = __toESM(require_theme(), 1); 14006 14007 // packages/ui/build-module/lock-unlock.mjs 14008 var import_private_apis = __toESM(require_private_apis(), 1); 14009 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)( 14010 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.", 14011 "@wordpress/ui" 14012 ); 14013 14014 // packages/ui/build-module/utils/theme-provider.mjs 14015 function getThemeProvider() { 14016 const themePackage = theme; 14017 if (themePackage.ThemeProvider) { 14018 return themePackage.ThemeProvider; 14019 } 14020 if (!themePackage.privateApis) { 14021 throw new Error( 14022 "@wordpress/ui: @wordpress/theme must expose `ThemeProvider` or `privateApis.ThemeProvider`." 14023 ); 14024 } 14025 return unlock( 14026 themePackage.privateApis 14027 ).ThemeProvider; 14028 } 14029 var ThemeProvider = getThemeProvider(); 14030 14031 // packages/ui/build-module/stack/stack.mjs 14032 var import_element32 = __toESM(require_element(), 1); 14033 var STYLE_HASH_ATTRIBUTE11 = "data-wp-hash"; 14034 function getRuntime11() { 14035 const globalScope = globalThis; 14036 if (globalScope.__wpStyleRuntime) { 14037 return globalScope.__wpStyleRuntime; 14038 } 14039 globalScope.__wpStyleRuntime = { 14040 documents: /* @__PURE__ */ new Map(), 14041 styles: /* @__PURE__ */ new Map(), 14042 injectedStyles: /* @__PURE__ */ new WeakMap() 14043 }; 14044 if (typeof document !== "undefined") { 14045 registerDocument11(document); 14046 } 14047 return globalScope.__wpStyleRuntime; 14048 } 14049 function documentContainsStyleHash11(targetDocument, hash) { 14050 if (!targetDocument.head) { 14051 return false; 14052 } 14053 for (const style of targetDocument.head.querySelectorAll( 14054 `style[$STYLE_HASH_ATTRIBUTE11}]` 14055 )) { 14056 if (style.getAttribute(STYLE_HASH_ATTRIBUTE11) === hash) { 14057 return true; 14058 } 14059 } 14060 return false; 14061 } 14062 function injectStyle11(targetDocument, hash, css) { 14063 if (!targetDocument.head) { 14064 return; 14065 } 14066 const runtime = getRuntime11(); 14067 let injectedStyles = runtime.injectedStyles.get(targetDocument); 14068 if (!injectedStyles) { 14069 injectedStyles = /* @__PURE__ */ new Set(); 14070 runtime.injectedStyles.set(targetDocument, injectedStyles); 14071 } 14072 if (injectedStyles.has(hash)) { 14073 return; 14074 } 14075 if (documentContainsStyleHash11(targetDocument, hash)) { 14076 injectedStyles.add(hash); 14077 return; 14078 } 14079 const style = targetDocument.createElement("style"); 14080 style.setAttribute(STYLE_HASH_ATTRIBUTE11, hash); 14081 style.appendChild(targetDocument.createTextNode(css)); 14082 targetDocument.head.appendChild(style); 14083 injectedStyles.add(hash); 14084 } 14085 function registerDocument11(targetDocument) { 14086 const runtime = getRuntime11(); 14087 runtime.documents.set( 14088 targetDocument, 14089 (runtime.documents.get(targetDocument) ?? 0) + 1 14090 ); 14091 for (const [hash, css] of runtime.styles) { 14092 injectStyle11(targetDocument, hash, css); 14093 } 14094 return () => { 14095 const count = runtime.documents.get(targetDocument); 14096 if (count === void 0) { 14097 return; 14098 } 14099 if (count <= 1) { 14100 runtime.documents.delete(targetDocument); 14101 return; 14102 } 14103 runtime.documents.set(targetDocument, count - 1); 14104 }; 14105 } 14106 function registerStyle11(hash, css) { 14107 const runtime = getRuntime11(); 14108 runtime.styles.set(hash, css); 14109 for (const targetDocument of runtime.documents.keys()) { 14110 injectStyle11(targetDocument, hash, css); 14111 } 14112 } 14113 if (typeof process === "undefined" || true) { 14114 registerStyle11("32aba35fe1", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._19ce0419607e1896__stack{display:flex}}}"); 14115 } 14116 var style_default11 = { "stack": "_19ce0419607e1896__stack" }; 14117 var gapTokens = { 14118 xs: "var(--wpds-dimension-gap-xs, 4px)", 14119 sm: "var(--wpds-dimension-gap-sm, 8px)", 14120 md: "var(--wpds-dimension-gap-md, 12px)", 14121 lg: "var(--wpds-dimension-gap-lg, 16px)", 14122 xl: "var(--wpds-dimension-gap-xl, 24px)", 14123 "2xl": "var(--wpds-dimension-gap-2xl, 32px)", 14124 "3xl": "var(--wpds-dimension-gap-3xl, 40px)" 14125 }; 14126 var Stack = (0, import_element32.forwardRef)(function Stack2({ direction, gap, align, justify, wrap, render: render4, ...props }, ref) { 14127 const style = { 14128 gap: gap && gapTokens[gap], 14129 alignItems: align, 14130 justifyContent: justify, 14131 flexDirection: direction, 14132 flexWrap: wrap 14133 }; 14134 const element = useRender({ 14135 render: render4, 14136 ref, 14137 props: mergeProps(props, { style, className: style_default11.stack }) 14138 }); 14139 return element; 14140 }); 14141 14142 // packages/ui/build-module/icon-button/icon-button.mjs 14143 var import_element37 = __toESM(require_element(), 1); 14144 14145 // packages/ui/build-module/tooltip/index.mjs 14146 var tooltip_exports = {}; 14147 __export(tooltip_exports, { 14148 Popup: () => Popup, 14149 Portal: () => Portal, 14150 Positioner: () => Positioner, 14151 Provider: () => Provider, 14152 Root: () => Root4, 14153 Trigger: () => Trigger2 14154 }); 14155 14156 // packages/ui/build-module/tooltip/popup.mjs 14157 var import_element35 = __toESM(require_element(), 1); 14158 14159 // packages/ui/build-module/tooltip/portal.mjs 14160 var import_element33 = __toESM(require_element(), 1); 14161 14162 // packages/ui/build-module/utils/wp-compat-overlay-slot.mjs 14163 var STYLE_HASH_ATTRIBUTE12 = "data-wp-hash"; 14164 function getRuntime12() { 14165 const globalScope = globalThis; 14166 if (globalScope.__wpStyleRuntime) { 14167 return globalScope.__wpStyleRuntime; 14168 } 14169 globalScope.__wpStyleRuntime = { 14170 documents: /* @__PURE__ */ new Map(), 14171 styles: /* @__PURE__ */ new Map(), 14172 injectedStyles: /* @__PURE__ */ new WeakMap() 14173 }; 14174 if (typeof document !== "undefined") { 14175 registerDocument12(document); 14176 } 14177 return globalScope.__wpStyleRuntime; 14178 } 14179 function documentContainsStyleHash12(targetDocument, hash) { 14180 if (!targetDocument.head) { 14181 return false; 14182 } 14183 for (const style of targetDocument.head.querySelectorAll( 14184 `style[$STYLE_HASH_ATTRIBUTE12}]` 14185 )) { 14186 if (style.getAttribute(STYLE_HASH_ATTRIBUTE12) === hash) { 14187 return true; 14188 } 14189 } 14190 return false; 14191 } 14192 function injectStyle12(targetDocument, hash, css) { 14193 if (!targetDocument.head) { 14194 return; 14195 } 14196 const runtime = getRuntime12(); 14197 let injectedStyles = runtime.injectedStyles.get(targetDocument); 14198 if (!injectedStyles) { 14199 injectedStyles = /* @__PURE__ */ new Set(); 14200 runtime.injectedStyles.set(targetDocument, injectedStyles); 14201 } 14202 if (injectedStyles.has(hash)) { 14203 return; 14204 } 14205 if (documentContainsStyleHash12(targetDocument, hash)) { 14206 injectedStyles.add(hash); 14207 return; 14208 } 14209 const style = targetDocument.createElement("style"); 14210 style.setAttribute(STYLE_HASH_ATTRIBUTE12, hash); 14211 style.appendChild(targetDocument.createTextNode(css)); 14212 targetDocument.head.appendChild(style); 14213 injectedStyles.add(hash); 14214 } 14215 function registerDocument12(targetDocument) { 14216 const runtime = getRuntime12(); 14217 runtime.documents.set( 14218 targetDocument, 14219 (runtime.documents.get(targetDocument) ?? 0) + 1 14220 ); 14221 for (const [hash, css] of runtime.styles) { 14222 injectStyle12(targetDocument, hash, css); 14223 } 14224 return () => { 14225 const count = runtime.documents.get(targetDocument); 14226 if (count === void 0) { 14227 return; 14228 } 14229 if (count <= 1) { 14230 runtime.documents.delete(targetDocument); 14231 return; 14232 } 14233 runtime.documents.set(targetDocument, count - 1); 14234 }; 14235 } 14236 function registerStyle12(hash, css) { 14237 const runtime = getRuntime12(); 14238 runtime.styles.set(hash, css); 14239 for (const targetDocument of runtime.documents.keys()) { 14240 injectStyle12(targetDocument, hash, css); 14241 } 14242 } 14243 if (typeof process === "undefined" || true) { 14244 registerStyle12("be37f31c1e", "._11fc52b637ff8a7e__slot{inset:0;isolation:isolate;pointer-events:none;position:fixed;z-index:1000000003}@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._11fc52b637ff8a7e__slot>*{pointer-events:auto}}}"); 14245 } 14246 var wp_compat_overlay_slot_default = { "slot": "_11fc52b637ff8a7e__slot" }; 14247 var WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE = "data-wp-compat-overlay-slot"; 14248 function resolveOwnerDocument() { 14249 return typeof document === "undefined" ? null : document; 14250 } 14251 function isInWordPressEnvironment() { 14252 let topWp; 14253 try { 14254 topWp = window.top?.wp; 14255 } catch { 14256 } 14257 const wp = topWp ?? window.wp; 14258 return typeof wp?.components === "object" && wp.components !== null; 14259 } 14260 var cachedSlot = null; 14261 function ensureSlotIsAccessible(element) { 14262 element.setAttribute("aria-hidden", "false"); 14263 return element; 14264 } 14265 function createSlot(ownerDocument2) { 14266 const element = ownerDocument2.createElement("div"); 14267 element.setAttribute(WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE, ""); 14268 if (wp_compat_overlay_slot_default.slot) { 14269 element.classList.add(wp_compat_overlay_slot_default.slot); 14270 } 14271 ownerDocument2.body.appendChild(element); 14272 return element; 14273 } 14274 function getWpCompatOverlaySlot() { 14275 if (typeof window === "undefined") { 14276 return void 0; 14277 } 14278 if (!isInWordPressEnvironment() && window.__wpUiCompatOverlaySlotEnabled !== true) { 14279 return void 0; 14280 } 14281 const ownerDocument2 = resolveOwnerDocument(); 14282 if (!ownerDocument2 || !ownerDocument2.body) { 14283 return void 0; 14284 } 14285 if (cachedSlot && cachedSlot.ownerDocument === ownerDocument2 && cachedSlot.isConnected) { 14286 return ensureSlotIsAccessible(cachedSlot); 14287 } 14288 const existing = ownerDocument2.querySelector( 14289 `[$WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE}]` 14290 ); 14291 if (existing instanceof HTMLDivElement) { 14292 cachedSlot = ensureSlotIsAccessible(existing); 14293 return cachedSlot; 14294 } 14295 if (cachedSlot?.isConnected) { 14296 cachedSlot.remove(); 14297 } 14298 cachedSlot = ensureSlotIsAccessible(createSlot(ownerDocument2)); 14299 return cachedSlot; 14300 } 14301 14302 // packages/ui/build-module/tooltip/portal.mjs 14303 var import_jsx_runtime62 = __toESM(require_jsx_runtime(), 1); 14304 var Portal = (0, import_element33.forwardRef)( 14305 function TooltipPortal3({ container, ...restProps }, ref) { 14306 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)( 14307 index_parts_exports3.Portal, 14308 { 14309 container: container ?? getWpCompatOverlaySlot(), 14310 ...restProps, 14311 ref 14312 } 14313 ); 14314 } 14315 ); 14316 14317 // packages/ui/build-module/tooltip/positioner.mjs 14318 var import_element34 = __toESM(require_element(), 1); 14319 var import_jsx_runtime63 = __toESM(require_jsx_runtime(), 1); 14320 var STYLE_HASH_ATTRIBUTE13 = "data-wp-hash"; 14321 function getRuntime13() { 14322 const globalScope = globalThis; 14323 if (globalScope.__wpStyleRuntime) { 14324 return globalScope.__wpStyleRuntime; 14325 } 14326 globalScope.__wpStyleRuntime = { 14327 documents: /* @__PURE__ */ new Map(), 14328 styles: /* @__PURE__ */ new Map(), 14329 injectedStyles: /* @__PURE__ */ new WeakMap() 14330 }; 14331 if (typeof document !== "undefined") { 14332 registerDocument13(document); 14333 } 14334 return globalScope.__wpStyleRuntime; 14335 } 14336 function documentContainsStyleHash13(targetDocument, hash) { 14337 if (!targetDocument.head) { 14338 return false; 14339 } 14340 for (const style of targetDocument.head.querySelectorAll( 14341 `style[$STYLE_HASH_ATTRIBUTE13}]` 14342 )) { 14343 if (style.getAttribute(STYLE_HASH_ATTRIBUTE13) === hash) { 14344 return true; 14345 } 14346 } 14347 return false; 14348 } 14349 function injectStyle13(targetDocument, hash, css) { 14350 if (!targetDocument.head) { 14351 return; 14352 } 14353 const runtime = getRuntime13(); 14354 let injectedStyles = runtime.injectedStyles.get(targetDocument); 14355 if (!injectedStyles) { 14356 injectedStyles = /* @__PURE__ */ new Set(); 14357 runtime.injectedStyles.set(targetDocument, injectedStyles); 14358 } 14359 if (injectedStyles.has(hash)) { 14360 return; 14361 } 14362 if (documentContainsStyleHash13(targetDocument, hash)) { 14363 injectedStyles.add(hash); 14364 return; 14365 } 14366 const style = targetDocument.createElement("style"); 14367 style.setAttribute(STYLE_HASH_ATTRIBUTE13, hash); 14368 style.appendChild(targetDocument.createTextNode(css)); 14369 targetDocument.head.appendChild(style); 14370 injectedStyles.add(hash); 14371 } 14372 function registerDocument13(targetDocument) { 14373 const runtime = getRuntime13(); 14374 runtime.documents.set( 14375 targetDocument, 14376 (runtime.documents.get(targetDocument) ?? 0) + 1 14377 ); 14378 for (const [hash, css] of runtime.styles) { 14379 injectStyle13(targetDocument, hash, css); 14380 } 14381 return () => { 14382 const count = runtime.documents.get(targetDocument); 14383 if (count === void 0) { 14384 return; 14385 } 14386 if (count <= 1) { 14387 runtime.documents.delete(targetDocument); 14388 return; 14389 } 14390 runtime.documents.set(targetDocument, count - 1); 14391 }; 14392 } 14393 function registerStyle13(hash, css) { 14394 const runtime = getRuntime13(); 14395 runtime.styles.set(hash, css); 14396 for (const targetDocument of runtime.documents.keys()) { 14397 injectStyle13(targetDocument, hash, css); 14398 } 14399 } 14400 if (typeof process === "undefined" || true) { 14401 registerStyle13("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}"); 14402 } 14403 var resets_default3 = { "box-sizing": "_336cd3e4e743482f__box-sizing" }; 14404 if (typeof process === "undefined" || true) { 14405 registerStyle13("19fcc06039", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{--_wp-ui-elevation-sm:0 1px 2px rgba(0,0,0,.05),0 2px 3px rgba(0,0,0,.04),0 6px 6px rgba(0,0,0,.03),0 8px 8px rgba(0,0,0,.02);background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-md,4px);box-shadow:var(--_wp-ui-elevation-sm);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-sm,12px);line-height:1.4;padding:var(--wpds-dimension-padding-xs,4px) var(--wpds-dimension-padding-sm,8px);@media (forced-colors:active){border-bottom-color:CanvasText;border-bottom-style:solid;border-bottom-width:1px;border-left-color:CanvasText;border-left-style:solid;border-left-width:1px;border-right-color:CanvasText;border-right-style:solid;border-right-width:1px;border-top-color:CanvasText;border-top-style:solid;border-top-width:1px}}}}'); 14406 } 14407 var style_default12 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" }; 14408 var Positioner = (0, import_element34.forwardRef)( 14409 function TooltipPositioner3({ align = "center", className, side = "top", sideOffset = 4, ...props }, ref) { 14410 return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)( 14411 index_parts_exports3.Positioner, 14412 { 14413 ref, 14414 align, 14415 side, 14416 sideOffset, 14417 ...props, 14418 className: clsx_default( 14419 resets_default3["box-sizing"], 14420 style_default12.positioner, 14421 className 14422 ) 14423 } 14424 ); 14425 } 14426 ); 14427 14428 // packages/ui/build-module/tooltip/popup.mjs 14429 var import_jsx_runtime64 = __toESM(require_jsx_runtime(), 1); 14430 var STYLE_HASH_ATTRIBUTE14 = "data-wp-hash"; 14431 function getRuntime14() { 14432 const globalScope = globalThis; 14433 if (globalScope.__wpStyleRuntime) { 14434 return globalScope.__wpStyleRuntime; 14435 } 14436 globalScope.__wpStyleRuntime = { 14437 documents: /* @__PURE__ */ new Map(), 14438 styles: /* @__PURE__ */ new Map(), 14439 injectedStyles: /* @__PURE__ */ new WeakMap() 14440 }; 14441 if (typeof document !== "undefined") { 14442 registerDocument14(document); 14443 } 14444 return globalScope.__wpStyleRuntime; 14445 } 14446 function documentContainsStyleHash14(targetDocument, hash) { 14447 if (!targetDocument.head) { 14448 return false; 14449 } 14450 for (const style of targetDocument.head.querySelectorAll( 14451 `style[$STYLE_HASH_ATTRIBUTE14}]` 14452 )) { 14453 if (style.getAttribute(STYLE_HASH_ATTRIBUTE14) === hash) { 14454 return true; 14455 } 14456 } 14457 return false; 14458 } 14459 function injectStyle14(targetDocument, hash, css) { 14460 if (!targetDocument.head) { 14461 return; 14462 } 14463 const runtime = getRuntime14(); 14464 let injectedStyles = runtime.injectedStyles.get(targetDocument); 14465 if (!injectedStyles) { 14466 injectedStyles = /* @__PURE__ */ new Set(); 14467 runtime.injectedStyles.set(targetDocument, injectedStyles); 14468 } 14469 if (injectedStyles.has(hash)) { 14470 return; 14471 } 14472 if (documentContainsStyleHash14(targetDocument, hash)) { 14473 injectedStyles.add(hash); 14474 return; 14475 } 14476 const style = targetDocument.createElement("style"); 14477 style.setAttribute(STYLE_HASH_ATTRIBUTE14, hash); 14478 style.appendChild(targetDocument.createTextNode(css)); 14479 targetDocument.head.appendChild(style); 14480 injectedStyles.add(hash); 14481 } 14482 function registerDocument14(targetDocument) { 14483 const runtime = getRuntime14(); 14484 runtime.documents.set( 14485 targetDocument, 14486 (runtime.documents.get(targetDocument) ?? 0) + 1 14487 ); 14488 for (const [hash, css] of runtime.styles) { 14489 injectStyle14(targetDocument, hash, css); 14490 } 14491 return () => { 14492 const count = runtime.documents.get(targetDocument); 14493 if (count === void 0) { 14494 return; 14495 } 14496 if (count <= 1) { 14497 runtime.documents.delete(targetDocument); 14498 return; 14499 } 14500 runtime.documents.set(targetDocument, count - 1); 14501 }; 14502 } 14503 function registerStyle14(hash, css) { 14504 const runtime = getRuntime14(); 14505 runtime.styles.set(hash, css); 14506 for (const targetDocument of runtime.documents.keys()) { 14507 injectStyle14(targetDocument, hash, css); 14508 } 14509 } 14510 if (typeof process === "undefined" || true) { 14511 registerStyle14("19fcc06039", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{--_wp-ui-elevation-sm:0 1px 2px rgba(0,0,0,.05),0 2px 3px rgba(0,0,0,.04),0 6px 6px rgba(0,0,0,.03),0 8px 8px rgba(0,0,0,.02);background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-md,4px);box-shadow:var(--_wp-ui-elevation-sm);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-sm,12px);line-height:1.4;padding:var(--wpds-dimension-padding-xs,4px) var(--wpds-dimension-padding-sm,8px);@media (forced-colors:active){border-bottom-color:CanvasText;border-bottom-style:solid;border-bottom-width:1px;border-left-color:CanvasText;border-left-style:solid;border-left-width:1px;border-right-color:CanvasText;border-right-style:solid;border-right-width:1px;border-top-color:CanvasText;border-top-style:solid;border-top-width:1px}}}}'); 14512 } 14513 var style_default13 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" }; 14514 var POPUP_COLOR = { background: "#1e1e1e" }; 14515 var Popup = (0, import_element35.forwardRef)(function TooltipPopup3({ portal, positioner, children, className, ...props }, ref) { 14516 const popupContent = /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(ThemeProvider, { color: POPUP_COLOR, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)( 14517 index_parts_exports3.Popup, 14518 { 14519 ref, 14520 className: clsx_default(style_default13.popup, className), 14521 ...props, 14522 children 14523 } 14524 ) }); 14525 const positionedPopup = renderSlotWithChildren( 14526 positioner, 14527 /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Positioner, {}), 14528 popupContent 14529 ); 14530 return renderSlotWithChildren(portal, /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Portal, {}), positionedPopup); 14531 }); 14532 14533 // packages/ui/build-module/tooltip/trigger.mjs 14534 var import_element36 = __toESM(require_element(), 1); 14535 var import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1); 14536 var Trigger2 = (0, import_element36.forwardRef)( 14537 function TooltipTrigger3(props, ref) { 14538 return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(index_parts_exports3.Trigger, { ref, ...props }); 14539 } 14540 ); 14541 14542 // packages/ui/build-module/tooltip/root.mjs 14543 var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1); 14544 function Root4(props) { 14545 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(index_parts_exports3.Root, { ...props }); 14546 } 14547 14548 // packages/ui/build-module/tooltip/provider.mjs 14549 var import_jsx_runtime67 = __toESM(require_jsx_runtime(), 1); 14550 function Provider({ ...props }) { 14551 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(index_parts_exports3.Provider, { ...props }); 14552 } 14553 14554 // packages/ui/build-module/icon-button/icon-button.mjs 14555 var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1); 14556 var STYLE_HASH_ATTRIBUTE15 = "data-wp-hash"; 14557 function getRuntime15() { 14558 const globalScope = globalThis; 14559 if (globalScope.__wpStyleRuntime) { 14560 return globalScope.__wpStyleRuntime; 14561 } 14562 globalScope.__wpStyleRuntime = { 14563 documents: /* @__PURE__ */ new Map(), 14564 styles: /* @__PURE__ */ new Map(), 14565 injectedStyles: /* @__PURE__ */ new WeakMap() 14566 }; 14567 if (typeof document !== "undefined") { 14568 registerDocument15(document); 14569 } 14570 return globalScope.__wpStyleRuntime; 14571 } 14572 function documentContainsStyleHash15(targetDocument, hash) { 14573 if (!targetDocument.head) { 14574 return false; 14575 } 14576 for (const style of targetDocument.head.querySelectorAll( 14577 `style[$STYLE_HASH_ATTRIBUTE15}]` 14578 )) { 14579 if (style.getAttribute(STYLE_HASH_ATTRIBUTE15) === hash) { 14580 return true; 14581 } 14582 } 14583 return false; 14584 } 14585 function injectStyle15(targetDocument, hash, css) { 14586 if (!targetDocument.head) { 14587 return; 14588 } 14589 const runtime = getRuntime15(); 14590 let injectedStyles = runtime.injectedStyles.get(targetDocument); 14591 if (!injectedStyles) { 14592 injectedStyles = /* @__PURE__ */ new Set(); 14593 runtime.injectedStyles.set(targetDocument, injectedStyles); 14594 } 14595 if (injectedStyles.has(hash)) { 14596 return; 14597 } 14598 if (documentContainsStyleHash15(targetDocument, hash)) { 14599 injectedStyles.add(hash); 14600 return; 14601 } 14602 const style = targetDocument.createElement("style"); 14603 style.setAttribute(STYLE_HASH_ATTRIBUTE15, hash); 14604 style.appendChild(targetDocument.createTextNode(css)); 14605 targetDocument.head.appendChild(style); 14606 injectedStyles.add(hash); 14607 } 14608 function registerDocument15(targetDocument) { 14609 const runtime = getRuntime15(); 14610 runtime.documents.set( 14611 targetDocument, 14612 (runtime.documents.get(targetDocument) ?? 0) + 1 14613 ); 14614 for (const [hash, css] of runtime.styles) { 14615 injectStyle15(targetDocument, hash, css); 14616 } 14617 return () => { 14618 const count = runtime.documents.get(targetDocument); 14619 if (count === void 0) { 14620 return; 14621 } 14622 if (count <= 1) { 14623 runtime.documents.delete(targetDocument); 14624 return; 14625 } 14626 runtime.documents.set(targetDocument, count - 1); 14627 }; 14628 } 14629 function registerStyle15(hash, css) { 14630 const runtime = getRuntime15(); 14631 runtime.styles.set(hash, css); 14632 for (const targetDocument of runtime.documents.keys()) { 14633 injectStyle15(targetDocument, hash, css); 14634 } 14635 } 14636 if (typeof process === "undefined" || true) { 14637 registerStyle15("c5cdafb1bc", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer compositions{._28cfdc260e755391__icon-button{--wp-ui-button-aspect-ratio:1;--wp-ui-button-padding-inline:0px;--wp-ui-button-min-width:unset}.f1c70d719989a85a__icon{margin:-1px}}}"); 14638 } 14639 var style_default14 = { "icon-button": "_28cfdc260e755391__icon-button", "icon": "f1c70d719989a85a__icon" }; 14640 var IconButton = (0, import_element37.forwardRef)( 14641 function IconButton2({ 14642 label, 14643 className, 14644 // Prevent accidental forwarding of `children` 14645 children: _children, 14646 disabled: disabled2, 14647 focusableWhenDisabled = true, 14648 icon, 14649 size: size4, 14650 shortcut, 14651 positioner, 14652 ...restProps 14653 }, ref) { 14654 const classes = clsx_default(style_default14["icon-button"], className); 14655 return /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(Root4, { children: [ 14656 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)( 14657 Trigger2, 14658 { 14659 ref, 14660 disabled: disabled2 && !focusableWhenDisabled, 14661 render: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)( 14662 Button4, 14663 { 14664 ...restProps, 14665 size: size4, 14666 "aria-label": label, 14667 "aria-keyshortcuts": shortcut?.ariaKeyShortcut, 14668 disabled: disabled2, 14669 focusableWhenDisabled 14670 } 14671 ), 14672 className: classes, 14673 children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Icon, { icon, size: 24, className: style_default14.icon }) 14674 } 14675 ), 14676 /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(Popup, { positioner, children: [ 14677 label, 14678 shortcut && /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(import_jsx_runtime68.Fragment, { children: [ 14679 " ", 14680 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("span", { "aria-hidden": "true", children: shortcut.displayShortcut }) 14681 ] }) 14682 ] }) 14683 ] }); 14684 } 14685 ); 14686 14687 // packages/ui/build-module/utils/create-overlay-title-validation.mjs 14688 var import_element39 = __toESM(require_element(), 1); 14689 14690 // packages/ui/build-module/utils/use-schedule-validation.mjs 14691 var import_element38 = __toESM(require_element(), 1); 14692 function useScheduleValidation(validate) { 14693 const validateRef = (0, import_element38.useRef)(validate); 14694 validateRef.current = validate; 14695 const timerRef = (0, import_element38.useRef)(null); 14696 const unmountedRef = (0, import_element38.useRef)(false); 14697 const scheduleValidation = (0, import_element38.useCallback)(() => { 14698 if (unmountedRef.current) { 14699 return; 14700 } 14701 if (timerRef.current) { 14702 clearTimeout(timerRef.current); 14703 } 14704 timerRef.current = setTimeout(() => { 14705 validateRef.current(); 14706 timerRef.current = null; 14707 }, 0); 14708 }, []); 14709 (0, import_element38.useEffect)(() => { 14710 unmountedRef.current = false; 14711 return () => { 14712 unmountedRef.current = true; 14713 if (timerRef.current) { 14714 clearTimeout(timerRef.current); 14715 } 14716 }; 14717 }, []); 14718 return scheduleValidation; 14719 } 14720 14721 // packages/ui/build-module/utils/create-overlay-title-validation.mjs 14722 var import_jsx_runtime69 = __toESM(require_jsx_runtime(), 1); 14723 var VALIDATION_ENABLED = true; 14724 function createOverlayTitleValidation(componentName) { 14725 const componentNameLowerCase = componentName.toLowerCase(); 14726 const OverlayValidationContext = VALIDATION_ENABLED ? (0, import_element39.createContext)(null) : null; 14727 function useValidationContextDev() { 14728 return (0, import_element39.useContext)(OverlayValidationContext); 14729 } 14730 function useValidationContextProd() { 14731 return null; 14732 } 14733 const useValidationContext = VALIDATION_ENABLED ? useValidationContextDev : useValidationContextProd; 14734 function ValidationProviderDev({ 14735 children 14736 }) { 14737 const titleElementRef = (0, import_element39.useRef)(null); 14738 const scheduleValidation = useScheduleValidation(() => { 14739 const titleElement = titleElementRef.current; 14740 if (!titleElement) { 14741 throw new Error( 14742 `$componentName}: Missing <$componentName}.Title>. For accessibility, every $componentNameLowerCase} requires a title. If needed, the title can be visually hidden but must not be omitted.` 14743 ); 14744 } 14745 const textContent = titleElement.textContent?.trim(); 14746 if (!textContent) { 14747 throw new Error( 14748 `$componentName}: <$componentName}.Title> cannot be empty. Provide meaningful text content for the $componentNameLowerCase} title.` 14749 ); 14750 } 14751 }); 14752 const registerTitle = (0, import_element39.useCallback)( 14753 (element) => { 14754 titleElementRef.current = element; 14755 scheduleValidation(); 14756 return () => { 14757 titleElementRef.current = null; 14758 scheduleValidation(); 14759 }; 14760 }, 14761 [scheduleValidation] 14762 ); 14763 const contextValue = (0, import_element39.useMemo)( 14764 () => ({ registerTitle }), 14765 [registerTitle] 14766 ); 14767 (0, import_element39.useEffect)(() => { 14768 scheduleValidation(); 14769 }, [scheduleValidation]); 14770 return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(OverlayValidationContext.Provider, { value: contextValue, children }); 14771 } 14772 function ValidationProviderProd({ 14773 children 14774 }) { 14775 return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(import_jsx_runtime69.Fragment, { children }); 14776 } 14777 const ValidationProvider = VALIDATION_ENABLED ? ValidationProviderDev : ValidationProviderProd; 14778 return { 14779 ValidationProvider, 14780 useValidationContext 14781 }; 14782 } 14783 14784 // packages/ui/build-module/visually-hidden/visually-hidden.mjs 14785 var import_element40 = __toESM(require_element(), 1); 14786 var STYLE_HASH_ATTRIBUTE16 = "data-wp-hash"; 14787 function getRuntime16() { 14788 const globalScope = globalThis; 14789 if (globalScope.__wpStyleRuntime) { 14790 return globalScope.__wpStyleRuntime; 14791 } 14792 globalScope.__wpStyleRuntime = { 14793 documents: /* @__PURE__ */ new Map(), 14794 styles: /* @__PURE__ */ new Map(), 14795 injectedStyles: /* @__PURE__ */ new WeakMap() 14796 }; 14797 if (typeof document !== "undefined") { 14798 registerDocument16(document); 14799 } 14800 return globalScope.__wpStyleRuntime; 14801 } 14802 function documentContainsStyleHash16(targetDocument, hash) { 14803 if (!targetDocument.head) { 14804 return false; 14805 } 14806 for (const style of targetDocument.head.querySelectorAll( 14807 `style[$STYLE_HASH_ATTRIBUTE16}]` 14808 )) { 14809 if (style.getAttribute(STYLE_HASH_ATTRIBUTE16) === hash) { 14810 return true; 14811 } 14812 } 14813 return false; 14814 } 14815 function injectStyle16(targetDocument, hash, css) { 14816 if (!targetDocument.head) { 14817 return; 14818 } 14819 const runtime = getRuntime16(); 14820 let injectedStyles = runtime.injectedStyles.get(targetDocument); 14821 if (!injectedStyles) { 14822 injectedStyles = /* @__PURE__ */ new Set(); 14823 runtime.injectedStyles.set(targetDocument, injectedStyles); 14824 } 14825 if (injectedStyles.has(hash)) { 14826 return; 14827 } 14828 if (documentContainsStyleHash16(targetDocument, hash)) { 14829 injectedStyles.add(hash); 14830 return; 14831 } 14832 const style = targetDocument.createElement("style"); 14833 style.setAttribute(STYLE_HASH_ATTRIBUTE16, hash); 14834 style.appendChild(targetDocument.createTextNode(css)); 14835 targetDocument.head.appendChild(style); 14836 injectedStyles.add(hash); 14837 } 14838 function registerDocument16(targetDocument) { 14839 const runtime = getRuntime16(); 14840 runtime.documents.set( 14841 targetDocument, 14842 (runtime.documents.get(targetDocument) ?? 0) + 1 14843 ); 14844 for (const [hash, css] of runtime.styles) { 14845 injectStyle16(targetDocument, hash, css); 14846 } 14847 return () => { 14848 const count = runtime.documents.get(targetDocument); 14849 if (count === void 0) { 14850 return; 14851 } 14852 if (count <= 1) { 14853 runtime.documents.delete(targetDocument); 14854 return; 14855 } 14856 runtime.documents.set(targetDocument, count - 1); 14857 }; 14858 } 14859 function registerStyle16(hash, css) { 14860 const runtime = getRuntime16(); 14861 runtime.styles.set(hash, css); 14862 for (const targetDocument of runtime.documents.keys()) { 14863 injectStyle16(targetDocument, hash, css); 14864 } 14865 } 14866 if (typeof process === "undefined" || true) { 14867 registerStyle16("fa606a57ae", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{.f37b9e2e191ebd66__visually-hidden{word-wrap:normal;border:0;clip-path:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;word-break:normal}}}"); 14868 } 14869 var style_default15 = { "visually-hidden": "f37b9e2e191ebd66__visually-hidden" }; 14870 var VisuallyHidden = (0, import_element40.forwardRef)( 14871 function VisuallyHidden2({ render: render4, ...restProps }, ref) { 14872 const element = useRender({ 14873 render: render4, 14874 ref, 14875 props: mergeProps( 14876 { className: style_default15["visually-hidden"] }, 14877 restProps, 14878 { 14879 // @ts-expect-error Arbitrary data-* attributes aren't indexable on the typed div props. Kept hardcoded so consumers can't change or remove it. 14880 "data-visually-hidden": "" 14881 } 14882 ) 14883 }); 14884 return element; 14885 } 14886 ); 14887 14888 // packages/ui/build-module/link/link.mjs 14889 var import_element41 = __toESM(require_element(), 1); 14890 var import_i18n2 = __toESM(require_i18n(), 1); 14891 var import_jsx_runtime70 = __toESM(require_jsx_runtime(), 1); 14892 var STYLE_HASH_ATTRIBUTE17 = "data-wp-hash"; 14893 function getRuntime17() { 14894 const globalScope = globalThis; 14895 if (globalScope.__wpStyleRuntime) { 14896 return globalScope.__wpStyleRuntime; 14897 } 14898 globalScope.__wpStyleRuntime = { 14899 documents: /* @__PURE__ */ new Map(), 14900 styles: /* @__PURE__ */ new Map(), 14901 injectedStyles: /* @__PURE__ */ new WeakMap() 14902 }; 14903 if (typeof document !== "undefined") { 14904 registerDocument17(document); 14905 } 14906 return globalScope.__wpStyleRuntime; 14907 } 14908 function documentContainsStyleHash17(targetDocument, hash) { 14909 if (!targetDocument.head) { 14910 return false; 14911 } 14912 for (const style of targetDocument.head.querySelectorAll( 14913 `style[$STYLE_HASH_ATTRIBUTE17}]` 14914 )) { 14915 if (style.getAttribute(STYLE_HASH_ATTRIBUTE17) === hash) { 14916 return true; 14917 } 14918 } 14919 return false; 14920 } 14921 function injectStyle17(targetDocument, hash, css) { 14922 if (!targetDocument.head) { 14923 return; 14924 } 14925 const runtime = getRuntime17(); 14926 let injectedStyles = runtime.injectedStyles.get(targetDocument); 14927 if (!injectedStyles) { 14928 injectedStyles = /* @__PURE__ */ new Set(); 14929 runtime.injectedStyles.set(targetDocument, injectedStyles); 14930 } 14931 if (injectedStyles.has(hash)) { 14932 return; 14933 } 14934 if (documentContainsStyleHash17(targetDocument, hash)) { 14935 injectedStyles.add(hash); 14936 return; 14937 } 14938 const style = targetDocument.createElement("style"); 14939 style.setAttribute(STYLE_HASH_ATTRIBUTE17, hash); 14940 style.appendChild(targetDocument.createTextNode(css)); 14941 targetDocument.head.appendChild(style); 14942 injectedStyles.add(hash); 14943 } 14944 function registerDocument17(targetDocument) { 14945 const runtime = getRuntime17(); 14946 runtime.documents.set( 14947 targetDocument, 14948 (runtime.documents.get(targetDocument) ?? 0) + 1 14949 ); 14950 for (const [hash, css] of runtime.styles) { 14951 injectStyle17(targetDocument, hash, css); 14952 } 14953 return () => { 14954 const count = runtime.documents.get(targetDocument); 14955 if (count === void 0) { 14956 return; 14957 } 14958 if (count <= 1) { 14959 runtime.documents.delete(targetDocument); 14960 return; 14961 } 14962 runtime.documents.set(targetDocument, count - 1); 14963 }; 14964 } 14965 function registerStyle17(hash, css) { 14966 const runtime = getRuntime17(); 14967 runtime.styles.set(hash, css); 14968 for (const targetDocument of runtime.documents.keys()) { 14969 injectStyle17(targetDocument, hash, css); 14970 } 14971 } 14972 if (typeof process === "undefined" || true) { 14973 registerStyle17("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}"); 14974 } 14975 var resets_default4 = { "box-sizing": "_336cd3e4e743482f__box-sizing" }; 14976 if (typeof process === "undefined" || true) { 14977 registerStyle17("da99a163ac", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._08e8a2e44959f892__outset-ring--focus:focus,.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,:focus-visible .ecadb9e080e2dfa5__outset-ring--focus-parent-visible{--_gcd-a-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9));--_gcd-div-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9));outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9));outline-offset:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px))}._970d04df7376df67__outset-ring--focus-within-except-active:focus-within,.e25b2bdd7aa21721__outset-ring--focus-except-active:focus{outline:none}._970d04df7376df67__outset-ring--focus-within-except-active:focus-within:not(:has(:active)),.e25b2bdd7aa21721__outset-ring--focus-except-active:focus:not(:active){@include mixins.focus-ring()}}}"); 14978 } 14979 var focus_default3 = { "outset-ring--focus": "_08e8a2e44959f892__outset-ring--focus", "outset-ring--focus-visible": "d0541bc9dd9dc7b6__outset-ring--focus-visible", "outset-ring--focus-within": "cd83dfc2126a0846__outset-ring--focus-within", "outset-ring--focus-within-visible": "c5cb3ee4bddaa8e4__outset-ring--focus-within-visible", "outset-ring--focus-parent-visible": "ecadb9e080e2dfa5__outset-ring--focus-parent-visible", "outset-ring--focus-except-active": "e25b2bdd7aa21721__outset-ring--focus-except-active", "outset-ring--focus-within-except-active": "_970d04df7376df67__outset-ring--focus-within-except-active" }; 14980 if (typeof process === "undefined" || true) { 14981 registerStyle17("e8e6a9be37", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{.d4250949359b05ce__link{text-decoration-thickness:from-font;text-underline-offset:.2em}.c6055659b8e2cd2c__is-brand,.c6055659b8e2cd2c__is-brand:visited{--_gcd-a-color:var(--wpds-color-foreground-interactive-brand,var(--wp-admin-theme-color,#3858e9));color:var(--wpds-color-foreground-interactive-brand,var(--wp-admin-theme-color,#3858e9))}.c6055659b8e2cd2c__is-brand:active,.c6055659b8e2cd2c__is-brand:hover{--_gcd-a-color:var(--wpds-color-foreground-interactive-brand-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 52%,#000));color:var(--wpds-color-foreground-interactive-brand-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 52%,#000))}._92e0dfcaeee15b88__is-neutral,._92e0dfcaeee15b88__is-neutral:visited{--_gcd-a-color:var(--wpds-color-foreground-interactive-neutral,#1e1e1e);color:var(--wpds-color-foreground-interactive-neutral,#1e1e1e);text-decoration-color:var(--wpds-color-stroke-interactive-neutral,#8d8d8d)}._92e0dfcaeee15b88__is-neutral:active,._92e0dfcaeee15b88__is-neutral:hover{--_gcd-a-color:var(--wpds-color-foreground-interactive-neutral-active,#1e1e1e);color:var(--wpds-color-foreground-interactive-neutral-active,#1e1e1e)}.cf122a9bf1035d42__is-unstyled{--_gcd-a-color:inherit;color:inherit;text-decoration:none}._0cb411afac4c86c7__link-icon{display:inline-block;font-weight:var(--wpds-typography-font-weight-default,400);line-height:1;margin-inline-start:var(--wpds-dimension-padding-xs,4px);text-decoration:none}._0cb411afac4c86c7__link-icon:after{content:"\\2197"}._0cb411afac4c86c7__link-icon:dir(rtl):after{content:"\\2196"}}}'); 14982 } 14983 var style_default16 = { "link": "d4250949359b05ce__link", "is-brand": "c6055659b8e2cd2c__is-brand", "is-neutral": "_92e0dfcaeee15b88__is-neutral", "is-unstyled": "cf122a9bf1035d42__is-unstyled", "link-icon": "_0cb411afac4c86c7__link-icon" }; 14984 if (typeof process === "undefined" || true) { 14985 registerStyle17("af6d9984a6", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,transparent);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 transparent);color:var(--_gcd-input-color,var(--wpds-color-foreground-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,transparent);border-color:var(--_gcd-input-border-color-disabled,transparent);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid transparent)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-foreground-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-emphasis,600));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid transparent);transition:var(--_gcd-a-transition,none)}"); 14986 } 14987 var global_css_defense_default4 = { "button": "_6defc79820e382c6__button", "input": "d2cff2e5dea83bd1__input", "textarea": "_547d86373d02e108__textarea", "div": "_8c15fd0ed9f28ba4__div", "p": "_43cec3e1eec1066d__p", "heading": "e97669c6d9a38497__heading", "a": "_2c0831b0499dbd6e__a" }; 14988 var Link = (0, import_element41.forwardRef)(function Link2({ 14989 children, 14990 variant = "default", 14991 tone = "brand", 14992 openInNewTab = false, 14993 render: render4, 14994 className, 14995 ...props 14996 }, ref) { 14997 const element = useRender({ 14998 render: render4, 14999 defaultTagName: "a", 15000 ref, 15001 props: mergeProps(props, { 15002 className: clsx_default( 15003 global_css_defense_default4.a, 15004 resets_default4["box-sizing"], 15005 focus_default3["outset-ring--focus-except-active"], 15006 variant !== "unstyled" && style_default16.link, 15007 variant !== "unstyled" && style_default16[`is-$tone}`], 15008 variant === "unstyled" && style_default16["is-unstyled"], 15009 className 15010 ), 15011 target: openInNewTab ? "_blank" : void 0, 15012 children: /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(import_jsx_runtime70.Fragment, { children: [ 15013 children, 15014 openInNewTab && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)( 15015 "span", 15016 { 15017 className: style_default16["link-icon"], 15018 role: "img", 15019 "aria-label": ( 15020 /* translators: accessibility text appended to link text */ 15021 (0, import_i18n2.__)("(opens in a new tab)") 15022 ) 15023 } 15024 ) 15025 ] }) 15026 }) 15027 }); 15028 return element; 15029 }); 15030 15031 // packages/ui/build-module/notice/index.mjs 15032 var notice_exports = {}; 15033 __export(notice_exports, { 15034 ActionButton: () => ActionButton, 15035 ActionLink: () => ActionLink, 15036 Actions: () => Actions, 15037 CloseIcon: () => CloseIcon, 15038 Description: () => Description, 15039 Root: () => Root5, 15040 Title: () => Title2 15041 }); 15042 15043 // packages/ui/build-module/notice/root.mjs 15044 var import_element42 = __toESM(require_element(), 1); 15045 import { speak as speak2 } from "@wordpress/a11y"; 15046 var import_jsx_runtime71 = __toESM(require_jsx_runtime(), 1); 15047 var STYLE_HASH_ATTRIBUTE18 = "data-wp-hash"; 15048 function getRuntime18() { 15049 const globalScope = globalThis; 15050 if (globalScope.__wpStyleRuntime) { 15051 return globalScope.__wpStyleRuntime; 15052 } 15053 globalScope.__wpStyleRuntime = { 15054 documents: /* @__PURE__ */ new Map(), 15055 styles: /* @__PURE__ */ new Map(), 15056 injectedStyles: /* @__PURE__ */ new WeakMap() 15057 }; 15058 if (typeof document !== "undefined") { 15059 registerDocument18(document); 15060 } 15061 return globalScope.__wpStyleRuntime; 15062 } 15063 function documentContainsStyleHash18(targetDocument, hash) { 15064 if (!targetDocument.head) { 15065 return false; 15066 } 15067 for (const style of targetDocument.head.querySelectorAll( 15068 `style[$STYLE_HASH_ATTRIBUTE18}]` 15069 )) { 15070 if (style.getAttribute(STYLE_HASH_ATTRIBUTE18) === hash) { 15071 return true; 15072 } 15073 } 15074 return false; 15075 } 15076 function injectStyle18(targetDocument, hash, css) { 15077 if (!targetDocument.head) { 15078 return; 15079 } 15080 const runtime = getRuntime18(); 15081 let injectedStyles = runtime.injectedStyles.get(targetDocument); 15082 if (!injectedStyles) { 15083 injectedStyles = /* @__PURE__ */ new Set(); 15084 runtime.injectedStyles.set(targetDocument, injectedStyles); 15085 } 15086 if (injectedStyles.has(hash)) { 15087 return; 15088 } 15089 if (documentContainsStyleHash18(targetDocument, hash)) { 15090 injectedStyles.add(hash); 15091 return; 15092 } 15093 const style = targetDocument.createElement("style"); 15094 style.setAttribute(STYLE_HASH_ATTRIBUTE18, hash); 15095 style.appendChild(targetDocument.createTextNode(css)); 15096 targetDocument.head.appendChild(style); 15097 injectedStyles.add(hash); 15098 } 15099 function registerDocument18(targetDocument) { 15100 const runtime = getRuntime18(); 15101 runtime.documents.set( 15102 targetDocument, 15103 (runtime.documents.get(targetDocument) ?? 0) + 1 15104 ); 15105 for (const [hash, css] of runtime.styles) { 15106 injectStyle18(targetDocument, hash, css); 15107 } 15108 return () => { 15109 const count = runtime.documents.get(targetDocument); 15110 if (count === void 0) { 15111 return; 15112 } 15113 if (count <= 1) { 15114 runtime.documents.delete(targetDocument); 15115 return; 15116 } 15117 runtime.documents.set(targetDocument, count - 1); 15118 }; 15119 } 15120 function registerStyle18(hash, css) { 15121 const runtime = getRuntime18(); 15122 runtime.styles.set(hash, css); 15123 for (const targetDocument of runtime.documents.keys()) { 15124 injectStyle18(targetDocument, hash, css); 15125 } 15126 } 15127 if (typeof process === "undefined" || true) { 15128 registerStyle18("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}"); 15129 } 15130 var resets_default5 = { "box-sizing": "_336cd3e4e743482f__box-sizing" }; 15131 if (typeof process === "undefined" || true) { 15132 registerStyle18("726c480820", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._4145abab73d17514__notice{--icon-height:var(--wpds-dimension-size-sm,24px);--text-vertical-padding:calc((var(--icon-height) - var(--wpds-typography-line-height-sm, 20px))/2);--wp-ui-notice-background-color:var(--wpds-color-background-surface-neutral-weak,#f4f4f4);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-neutral,#dbdbdb);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-neutral,#1e1e1e);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-neutral,#1e1e1e);align-items:start;background-color:var(--wp-ui-notice-background-color);border:1px solid var(--wp-ui-notice-border-color);border-radius:var(--wpds-border-radius-lg,8px);container-type:inline-size;display:grid;grid-template-columns:auto 1fr auto;padding:var(--wpds-dimension-padding-md,12px)}.d0a25570cb528528__icon{color:var(--wp-ui-notice-decorative-icon-color);grid-column:1;grid-row:1;margin-inline-end:var(--wpds-dimension-gap-xs,4px)}._1904b570a89bb815__description,.b5397fb9d05389e3__title{color:var(--wp-ui-notice-text-color);grid-column:2;padding-block:var(--text-vertical-padding)}._1904b570a89bb815__description{text-wrap:pretty}._0a1270dcdd79c031__actions{display:flex;flex-wrap:wrap;gap:var(--wpds-dimension-gap-md,12px);grid-column:2}._4145abab73d17514__notice:has(._1904b570a89bb815__description) ._0a1270dcdd79c031__actions,._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._0a1270dcdd79c031__actions{margin-block-start:var(--wpds-dimension-gap-sm,8px)}._983740ab855c4e09__action-button{flex-shrink:0}.d329e7416d368d31__action-link{flex-shrink:0;&:not(:first-child){margin-inline-start:var(--wpds-dimension-gap-xs,4px)}&:not(:last-child){margin-inline-end:var(--wpds-dimension-gap-xs,4px)}}._487e6a5c1375f7dc__close-icon{grid-column:3;grid-row:1;margin-inline-start:var(--wpds-dimension-gap-xs,4px)}._531c140826094795__is-info{--wp-ui-notice-background-color:var(--wpds-color-background-surface-info-weak,#f3f9ff);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-info,#a9c6e7);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-info,#001b4f);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-info-weak,#006bd7)}.ae2e1004697cce95__is-warning{--wp-ui-notice-background-color:var(--wpds-color-background-surface-warning-weak,#fff7e1);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-warning,#e1bc7c);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-warning,#2e1900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-warning-weak,#926300)}._2e614a76af494837__is-success{--wp-ui-notice-background-color:var(--wpds-color-background-surface-success-weak,#ebffed);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-success,#94d29e);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-success,#002900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-success-weak,#008030)}.af00331ae17a0065__is-error{--wp-ui-notice-background-color:var(--wpds-color-background-surface-error-weak,#fff6f5);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-error,#dab1aa);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-error,#470000);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-error-weak,#cc1818)}@container (max-width: 320px){._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._0a1270dcdd79c031__actions,._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._1904b570a89bb815__description{grid-column:1/3}}}@layer compositions{.d329e7416d368d31__action-link{margin-block:auto}._487e6a5c1375f7dc__close-icon,._983740ab855c4e09__action-button:is(._8ddb8fb33fbf3d38__is-action-button-outline,._77bbde495a8a0af3__is-action-button-minimal){--wp-ui-button-background-color-active:color-mix(in srgb,transparent 50%,var(--wpds-color-background-interactive-neutral-weak-active,#ededed))}}}"); 15133 } 15134 var style_default17 = { "notice": "_4145abab73d17514__notice", "icon": "d0a25570cb528528__icon", "title": "b5397fb9d05389e3__title", "description": "_1904b570a89bb815__description", "actions": "_0a1270dcdd79c031__actions", "action-button": "_983740ab855c4e09__action-button", "action-link": "d329e7416d368d31__action-link", "close-icon": "_487e6a5c1375f7dc__close-icon", "is-info": "_531c140826094795__is-info", "is-warning": "ae2e1004697cce95__is-warning", "is-success": "_2e614a76af494837__is-success", "is-error": "af00331ae17a0065__is-error", "is-action-button-outline": "_8ddb8fb33fbf3d38__is-action-button-outline", "is-action-button-minimal": "_77bbde495a8a0af3__is-action-button-minimal" }; 15135 var icons = { 15136 neutral: null, 15137 info: info_default, 15138 warning: caution_default, 15139 success: published_default, 15140 error: error_default 15141 }; 15142 function getDefaultPoliteness(intent) { 15143 return intent === "error" ? "assertive" : "polite"; 15144 } 15145 function safeRenderToString(message2) { 15146 if (!message2) { 15147 return void 0; 15148 } 15149 if (typeof message2 === "string") { 15150 return message2; 15151 } 15152 try { 15153 return (0, import_element42.renderToString)(message2); 15154 } catch { 15155 return void 0; 15156 } 15157 } 15158 function useSpokenMessage(message2, politeness) { 15159 const spokenMessage = safeRenderToString(message2); 15160 (0, import_element42.useEffect)(() => { 15161 if (spokenMessage) { 15162 speak2(spokenMessage, politeness); 15163 } 15164 }, [spokenMessage, politeness]); 15165 } 15166 var Root5 = (0, import_element42.forwardRef)(function Notice({ 15167 intent = "neutral", 15168 children, 15169 icon, 15170 spokenMessage = children, 15171 politeness = getDefaultPoliteness(intent), 15172 render: render4, 15173 ...restProps 15174 }, ref) { 15175 useSpokenMessage(spokenMessage, politeness); 15176 const iconElement = icon === null ? null : icon ?? icons[intent]; 15177 const mergedClassName = clsx_default( 15178 style_default17.notice, 15179 style_default17[`is-$intent}`], 15180 resets_default5["box-sizing"] 15181 ); 15182 const element = useRender({ 15183 defaultTagName: "div", 15184 render: render4, 15185 ref, 15186 props: mergeProps( 15187 { 15188 className: mergedClassName, 15189 children: /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(import_jsx_runtime71.Fragment, { children: [ 15190 children, 15191 iconElement && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 15192 Icon, 15193 { 15194 className: style_default17.icon, 15195 icon: iconElement 15196 } 15197 ) 15198 ] }) 15199 }, 15200 restProps 15201 ) 15202 }); 15203 return element; 15204 }); 15205 15206 // packages/ui/build-module/notice/title.mjs 15207 var import_element43 = __toESM(require_element(), 1); 15208 var import_jsx_runtime72 = __toESM(require_jsx_runtime(), 1); 15209 var STYLE_HASH_ATTRIBUTE19 = "data-wp-hash"; 15210 function getRuntime19() { 15211 const globalScope = globalThis; 15212 if (globalScope.__wpStyleRuntime) { 15213 return globalScope.__wpStyleRuntime; 15214 } 15215 globalScope.__wpStyleRuntime = { 15216 documents: /* @__PURE__ */ new Map(), 15217 styles: /* @__PURE__ */ new Map(), 15218 injectedStyles: /* @__PURE__ */ new WeakMap() 15219 }; 15220 if (typeof document !== "undefined") { 15221 registerDocument19(document); 15222 } 15223 return globalScope.__wpStyleRuntime; 15224 } 15225 function documentContainsStyleHash19(targetDocument, hash) { 15226 if (!targetDocument.head) { 15227 return false; 15228 } 15229 for (const style of targetDocument.head.querySelectorAll( 15230 `style[$STYLE_HASH_ATTRIBUTE19}]` 15231 )) { 15232 if (style.getAttribute(STYLE_HASH_ATTRIBUTE19) === hash) { 15233 return true; 15234 } 15235 } 15236 return false; 15237 } 15238 function injectStyle19(targetDocument, hash, css) { 15239 if (!targetDocument.head) { 15240 return; 15241 } 15242 const runtime = getRuntime19(); 15243 let injectedStyles = runtime.injectedStyles.get(targetDocument); 15244 if (!injectedStyles) { 15245 injectedStyles = /* @__PURE__ */ new Set(); 15246 runtime.injectedStyles.set(targetDocument, injectedStyles); 15247 } 15248 if (injectedStyles.has(hash)) { 15249 return; 15250 } 15251 if (documentContainsStyleHash19(targetDocument, hash)) { 15252 injectedStyles.add(hash); 15253 return; 15254 } 15255 const style = targetDocument.createElement("style"); 15256 style.setAttribute(STYLE_HASH_ATTRIBUTE19, hash); 15257 style.appendChild(targetDocument.createTextNode(css)); 15258 targetDocument.head.appendChild(style); 15259 injectedStyles.add(hash); 15260 } 15261 function registerDocument19(targetDocument) { 15262 const runtime = getRuntime19(); 15263 runtime.documents.set( 15264 targetDocument, 15265 (runtime.documents.get(targetDocument) ?? 0) + 1 15266 ); 15267 for (const [hash, css] of runtime.styles) { 15268 injectStyle19(targetDocument, hash, css); 15269 } 15270 return () => { 15271 const count = runtime.documents.get(targetDocument); 15272 if (count === void 0) { 15273 return; 15274 } 15275 if (count <= 1) { 15276 runtime.documents.delete(targetDocument); 15277 return; 15278 } 15279 runtime.documents.set(targetDocument, count - 1); 15280 }; 15281 } 15282 function registerStyle19(hash, css) { 15283 const runtime = getRuntime19(); 15284 runtime.styles.set(hash, css); 15285 for (const targetDocument of runtime.documents.keys()) { 15286 injectStyle19(targetDocument, hash, css); 15287 } 15288 } 15289 if (typeof process === "undefined" || true) { 15290 registerStyle19("726c480820", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._4145abab73d17514__notice{--icon-height:var(--wpds-dimension-size-sm,24px);--text-vertical-padding:calc((var(--icon-height) - var(--wpds-typography-line-height-sm, 20px))/2);--wp-ui-notice-background-color:var(--wpds-color-background-surface-neutral-weak,#f4f4f4);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-neutral,#dbdbdb);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-neutral,#1e1e1e);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-neutral,#1e1e1e);align-items:start;background-color:var(--wp-ui-notice-background-color);border:1px solid var(--wp-ui-notice-border-color);border-radius:var(--wpds-border-radius-lg,8px);container-type:inline-size;display:grid;grid-template-columns:auto 1fr auto;padding:var(--wpds-dimension-padding-md,12px)}.d0a25570cb528528__icon{color:var(--wp-ui-notice-decorative-icon-color);grid-column:1;grid-row:1;margin-inline-end:var(--wpds-dimension-gap-xs,4px)}._1904b570a89bb815__description,.b5397fb9d05389e3__title{color:var(--wp-ui-notice-text-color);grid-column:2;padding-block:var(--text-vertical-padding)}._1904b570a89bb815__description{text-wrap:pretty}._0a1270dcdd79c031__actions{display:flex;flex-wrap:wrap;gap:var(--wpds-dimension-gap-md,12px);grid-column:2}._4145abab73d17514__notice:has(._1904b570a89bb815__description) ._0a1270dcdd79c031__actions,._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._0a1270dcdd79c031__actions{margin-block-start:var(--wpds-dimension-gap-sm,8px)}._983740ab855c4e09__action-button{flex-shrink:0}.d329e7416d368d31__action-link{flex-shrink:0;&:not(:first-child){margin-inline-start:var(--wpds-dimension-gap-xs,4px)}&:not(:last-child){margin-inline-end:var(--wpds-dimension-gap-xs,4px)}}._487e6a5c1375f7dc__close-icon{grid-column:3;grid-row:1;margin-inline-start:var(--wpds-dimension-gap-xs,4px)}._531c140826094795__is-info{--wp-ui-notice-background-color:var(--wpds-color-background-surface-info-weak,#f3f9ff);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-info,#a9c6e7);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-info,#001b4f);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-info-weak,#006bd7)}.ae2e1004697cce95__is-warning{--wp-ui-notice-background-color:var(--wpds-color-background-surface-warning-weak,#fff7e1);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-warning,#e1bc7c);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-warning,#2e1900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-warning-weak,#926300)}._2e614a76af494837__is-success{--wp-ui-notice-background-color:var(--wpds-color-background-surface-success-weak,#ebffed);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-success,#94d29e);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-success,#002900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-success-weak,#008030)}.af00331ae17a0065__is-error{--wp-ui-notice-background-color:var(--wpds-color-background-surface-error-weak,#fff6f5);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-error,#dab1aa);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-error,#470000);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-error-weak,#cc1818)}@container (max-width: 320px){._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._0a1270dcdd79c031__actions,._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._1904b570a89bb815__description{grid-column:1/3}}}@layer compositions{.d329e7416d368d31__action-link{margin-block:auto}._487e6a5c1375f7dc__close-icon,._983740ab855c4e09__action-button:is(._8ddb8fb33fbf3d38__is-action-button-outline,._77bbde495a8a0af3__is-action-button-minimal){--wp-ui-button-background-color-active:color-mix(in srgb,transparent 50%,var(--wpds-color-background-interactive-neutral-weak-active,#ededed))}}}"); 15291 } 15292 var style_default18 = { "notice": "_4145abab73d17514__notice", "icon": "d0a25570cb528528__icon", "title": "b5397fb9d05389e3__title", "description": "_1904b570a89bb815__description", "actions": "_0a1270dcdd79c031__actions", "action-button": "_983740ab855c4e09__action-button", "action-link": "d329e7416d368d31__action-link", "close-icon": "_487e6a5c1375f7dc__close-icon", "is-info": "_531c140826094795__is-info", "is-warning": "ae2e1004697cce95__is-warning", "is-success": "_2e614a76af494837__is-success", "is-error": "af00331ae17a0065__is-error", "is-action-button-outline": "_8ddb8fb33fbf3d38__is-action-button-outline", "is-action-button-minimal": "_77bbde495a8a0af3__is-action-button-minimal" }; 15293 var Title2 = (0, import_element43.forwardRef)( 15294 function NoticeTitle({ className, ...props }, ref) { 15295 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)( 15296 Text, 15297 { 15298 ref, 15299 variant: "heading-md", 15300 className: clsx_default(style_default18.title, className), 15301 ...props 15302 } 15303 ); 15304 } 15305 ); 15306 15307 // packages/ui/build-module/notice/description.mjs 15308 var import_element44 = __toESM(require_element(), 1); 15309 var import_jsx_runtime73 = __toESM(require_jsx_runtime(), 1); 15310 var STYLE_HASH_ATTRIBUTE20 = "data-wp-hash"; 15311 function getRuntime20() { 15312 const globalScope = globalThis; 15313 if (globalScope.__wpStyleRuntime) { 15314 return globalScope.__wpStyleRuntime; 15315 } 15316 globalScope.__wpStyleRuntime = { 15317 documents: /* @__PURE__ */ new Map(), 15318 styles: /* @__PURE__ */ new Map(), 15319 injectedStyles: /* @__PURE__ */ new WeakMap() 15320 }; 15321 if (typeof document !== "undefined") { 15322 registerDocument20(document); 15323 } 15324 return globalScope.__wpStyleRuntime; 15325 } 15326 function documentContainsStyleHash20(targetDocument, hash) { 15327 if (!targetDocument.head) { 15328 return false; 15329 } 15330 for (const style of targetDocument.head.querySelectorAll( 15331 `style[$STYLE_HASH_ATTRIBUTE20}]` 15332 )) { 15333 if (style.getAttribute(STYLE_HASH_ATTRIBUTE20) === hash) { 15334 return true; 15335 } 15336 } 15337 return false; 15338 } 15339 function injectStyle20(targetDocument, hash, css) { 15340 if (!targetDocument.head) { 15341 return; 15342 } 15343 const runtime = getRuntime20(); 15344 let injectedStyles = runtime.injectedStyles.get(targetDocument); 15345 if (!injectedStyles) { 15346 injectedStyles = /* @__PURE__ */ new Set(); 15347 runtime.injectedStyles.set(targetDocument, injectedStyles); 15348 } 15349 if (injectedStyles.has(hash)) { 15350 return; 15351 } 15352 if (documentContainsStyleHash20(targetDocument, hash)) { 15353 injectedStyles.add(hash); 15354 return; 15355 } 15356 const style = targetDocument.createElement("style"); 15357 style.setAttribute(STYLE_HASH_ATTRIBUTE20, hash); 15358 style.appendChild(targetDocument.createTextNode(css)); 15359 targetDocument.head.appendChild(style); 15360 injectedStyles.add(hash); 15361 } 15362 function registerDocument20(targetDocument) { 15363 const runtime = getRuntime20(); 15364 runtime.documents.set( 15365 targetDocument, 15366 (runtime.documents.get(targetDocument) ?? 0) + 1 15367 ); 15368 for (const [hash, css] of runtime.styles) { 15369 injectStyle20(targetDocument, hash, css); 15370 } 15371 return () => { 15372 const count = runtime.documents.get(targetDocument); 15373 if (count === void 0) { 15374 return; 15375 } 15376 if (count <= 1) { 15377 runtime.documents.delete(targetDocument); 15378 return; 15379 } 15380 runtime.documents.set(targetDocument, count - 1); 15381 }; 15382 } 15383 function registerStyle20(hash, css) { 15384 const runtime = getRuntime20(); 15385 runtime.styles.set(hash, css); 15386 for (const targetDocument of runtime.documents.keys()) { 15387 injectStyle20(targetDocument, hash, css); 15388 } 15389 } 15390 if (typeof process === "undefined" || true) { 15391 registerStyle20("726c480820", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._4145abab73d17514__notice{--icon-height:var(--wpds-dimension-size-sm,24px);--text-vertical-padding:calc((var(--icon-height) - var(--wpds-typography-line-height-sm, 20px))/2);--wp-ui-notice-background-color:var(--wpds-color-background-surface-neutral-weak,#f4f4f4);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-neutral,#dbdbdb);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-neutral,#1e1e1e);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-neutral,#1e1e1e);align-items:start;background-color:var(--wp-ui-notice-background-color);border:1px solid var(--wp-ui-notice-border-color);border-radius:var(--wpds-border-radius-lg,8px);container-type:inline-size;display:grid;grid-template-columns:auto 1fr auto;padding:var(--wpds-dimension-padding-md,12px)}.d0a25570cb528528__icon{color:var(--wp-ui-notice-decorative-icon-color);grid-column:1;grid-row:1;margin-inline-end:var(--wpds-dimension-gap-xs,4px)}._1904b570a89bb815__description,.b5397fb9d05389e3__title{color:var(--wp-ui-notice-text-color);grid-column:2;padding-block:var(--text-vertical-padding)}._1904b570a89bb815__description{text-wrap:pretty}._0a1270dcdd79c031__actions{display:flex;flex-wrap:wrap;gap:var(--wpds-dimension-gap-md,12px);grid-column:2}._4145abab73d17514__notice:has(._1904b570a89bb815__description) ._0a1270dcdd79c031__actions,._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._0a1270dcdd79c031__actions{margin-block-start:var(--wpds-dimension-gap-sm,8px)}._983740ab855c4e09__action-button{flex-shrink:0}.d329e7416d368d31__action-link{flex-shrink:0;&:not(:first-child){margin-inline-start:var(--wpds-dimension-gap-xs,4px)}&:not(:last-child){margin-inline-end:var(--wpds-dimension-gap-xs,4px)}}._487e6a5c1375f7dc__close-icon{grid-column:3;grid-row:1;margin-inline-start:var(--wpds-dimension-gap-xs,4px)}._531c140826094795__is-info{--wp-ui-notice-background-color:var(--wpds-color-background-surface-info-weak,#f3f9ff);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-info,#a9c6e7);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-info,#001b4f);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-info-weak,#006bd7)}.ae2e1004697cce95__is-warning{--wp-ui-notice-background-color:var(--wpds-color-background-surface-warning-weak,#fff7e1);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-warning,#e1bc7c);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-warning,#2e1900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-warning-weak,#926300)}._2e614a76af494837__is-success{--wp-ui-notice-background-color:var(--wpds-color-background-surface-success-weak,#ebffed);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-success,#94d29e);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-success,#002900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-success-weak,#008030)}.af00331ae17a0065__is-error{--wp-ui-notice-background-color:var(--wpds-color-background-surface-error-weak,#fff6f5);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-error,#dab1aa);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-error,#470000);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-error-weak,#cc1818)}@container (max-width: 320px){._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._0a1270dcdd79c031__actions,._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._1904b570a89bb815__description{grid-column:1/3}}}@layer compositions{.d329e7416d368d31__action-link{margin-block:auto}._487e6a5c1375f7dc__close-icon,._983740ab855c4e09__action-button:is(._8ddb8fb33fbf3d38__is-action-button-outline,._77bbde495a8a0af3__is-action-button-minimal){--wp-ui-button-background-color-active:color-mix(in srgb,transparent 50%,var(--wpds-color-background-interactive-neutral-weak-active,#ededed))}}}"); 15392 } 15393 var style_default19 = { "notice": "_4145abab73d17514__notice", "icon": "d0a25570cb528528__icon", "title": "b5397fb9d05389e3__title", "description": "_1904b570a89bb815__description", "actions": "_0a1270dcdd79c031__actions", "action-button": "_983740ab855c4e09__action-button", "action-link": "d329e7416d368d31__action-link", "close-icon": "_487e6a5c1375f7dc__close-icon", "is-info": "_531c140826094795__is-info", "is-warning": "ae2e1004697cce95__is-warning", "is-success": "_2e614a76af494837__is-success", "is-error": "af00331ae17a0065__is-error", "is-action-button-outline": "_8ddb8fb33fbf3d38__is-action-button-outline", "is-action-button-minimal": "_77bbde495a8a0af3__is-action-button-minimal" }; 15394 var Description = (0, import_element44.forwardRef)( 15395 function NoticeDescription({ className, ...props }, ref) { 15396 return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)( 15397 Text, 15398 { 15399 ref, 15400 variant: "body-md", 15401 className: clsx_default(style_default19.description, className), 15402 ...props 15403 } 15404 ); 15405 } 15406 ); 15407 15408 // packages/ui/build-module/notice/actions.mjs 15409 var import_element45 = __toESM(require_element(), 1); 15410 var STYLE_HASH_ATTRIBUTE21 = "data-wp-hash"; 15411 function getRuntime21() { 15412 const globalScope = globalThis; 15413 if (globalScope.__wpStyleRuntime) { 15414 return globalScope.__wpStyleRuntime; 15415 } 15416 globalScope.__wpStyleRuntime = { 15417 documents: /* @__PURE__ */ new Map(), 15418 styles: /* @__PURE__ */ new Map(), 15419 injectedStyles: /* @__PURE__ */ new WeakMap() 15420 }; 15421 if (typeof document !== "undefined") { 15422 registerDocument21(document); 15423 } 15424 return globalScope.__wpStyleRuntime; 15425 } 15426 function documentContainsStyleHash21(targetDocument, hash) { 15427 if (!targetDocument.head) { 15428 return false; 15429 } 15430 for (const style of targetDocument.head.querySelectorAll( 15431 `style[$STYLE_HASH_ATTRIBUTE21}]` 15432 )) { 15433 if (style.getAttribute(STYLE_HASH_ATTRIBUTE21) === hash) { 15434 return true; 15435 } 15436 } 15437 return false; 15438 } 15439 function injectStyle21(targetDocument, hash, css) { 15440 if (!targetDocument.head) { 15441 return; 15442 } 15443 const runtime = getRuntime21(); 15444 let injectedStyles = runtime.injectedStyles.get(targetDocument); 15445 if (!injectedStyles) { 15446 injectedStyles = /* @__PURE__ */ new Set(); 15447 runtime.injectedStyles.set(targetDocument, injectedStyles); 15448 } 15449 if (injectedStyles.has(hash)) { 15450 return; 15451 } 15452 if (documentContainsStyleHash21(targetDocument, hash)) { 15453 injectedStyles.add(hash); 15454 return; 15455 } 15456 const style = targetDocument.createElement("style"); 15457 style.setAttribute(STYLE_HASH_ATTRIBUTE21, hash); 15458 style.appendChild(targetDocument.createTextNode(css)); 15459 targetDocument.head.appendChild(style); 15460 injectedStyles.add(hash); 15461 } 15462 function registerDocument21(targetDocument) { 15463 const runtime = getRuntime21(); 15464 runtime.documents.set( 15465 targetDocument, 15466 (runtime.documents.get(targetDocument) ?? 0) + 1 15467 ); 15468 for (const [hash, css] of runtime.styles) { 15469 injectStyle21(targetDocument, hash, css); 15470 } 15471 return () => { 15472 const count = runtime.documents.get(targetDocument); 15473 if (count === void 0) { 15474 return; 15475 } 15476 if (count <= 1) { 15477 runtime.documents.delete(targetDocument); 15478 return; 15479 } 15480 runtime.documents.set(targetDocument, count - 1); 15481 }; 15482 } 15483 function registerStyle21(hash, css) { 15484 const runtime = getRuntime21(); 15485 runtime.styles.set(hash, css); 15486 for (const targetDocument of runtime.documents.keys()) { 15487 injectStyle21(targetDocument, hash, css); 15488 } 15489 } 15490 if (typeof process === "undefined" || true) { 15491 registerStyle21("726c480820", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._4145abab73d17514__notice{--icon-height:var(--wpds-dimension-size-sm,24px);--text-vertical-padding:calc((var(--icon-height) - var(--wpds-typography-line-height-sm, 20px))/2);--wp-ui-notice-background-color:var(--wpds-color-background-surface-neutral-weak,#f4f4f4);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-neutral,#dbdbdb);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-neutral,#1e1e1e);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-neutral,#1e1e1e);align-items:start;background-color:var(--wp-ui-notice-background-color);border:1px solid var(--wp-ui-notice-border-color);border-radius:var(--wpds-border-radius-lg,8px);container-type:inline-size;display:grid;grid-template-columns:auto 1fr auto;padding:var(--wpds-dimension-padding-md,12px)}.d0a25570cb528528__icon{color:var(--wp-ui-notice-decorative-icon-color);grid-column:1;grid-row:1;margin-inline-end:var(--wpds-dimension-gap-xs,4px)}._1904b570a89bb815__description,.b5397fb9d05389e3__title{color:var(--wp-ui-notice-text-color);grid-column:2;padding-block:var(--text-vertical-padding)}._1904b570a89bb815__description{text-wrap:pretty}._0a1270dcdd79c031__actions{display:flex;flex-wrap:wrap;gap:var(--wpds-dimension-gap-md,12px);grid-column:2}._4145abab73d17514__notice:has(._1904b570a89bb815__description) ._0a1270dcdd79c031__actions,._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._0a1270dcdd79c031__actions{margin-block-start:var(--wpds-dimension-gap-sm,8px)}._983740ab855c4e09__action-button{flex-shrink:0}.d329e7416d368d31__action-link{flex-shrink:0;&:not(:first-child){margin-inline-start:var(--wpds-dimension-gap-xs,4px)}&:not(:last-child){margin-inline-end:var(--wpds-dimension-gap-xs,4px)}}._487e6a5c1375f7dc__close-icon{grid-column:3;grid-row:1;margin-inline-start:var(--wpds-dimension-gap-xs,4px)}._531c140826094795__is-info{--wp-ui-notice-background-color:var(--wpds-color-background-surface-info-weak,#f3f9ff);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-info,#a9c6e7);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-info,#001b4f);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-info-weak,#006bd7)}.ae2e1004697cce95__is-warning{--wp-ui-notice-background-color:var(--wpds-color-background-surface-warning-weak,#fff7e1);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-warning,#e1bc7c);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-warning,#2e1900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-warning-weak,#926300)}._2e614a76af494837__is-success{--wp-ui-notice-background-color:var(--wpds-color-background-surface-success-weak,#ebffed);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-success,#94d29e);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-success,#002900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-success-weak,#008030)}.af00331ae17a0065__is-error{--wp-ui-notice-background-color:var(--wpds-color-background-surface-error-weak,#fff6f5);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-error,#dab1aa);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-error,#470000);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-error-weak,#cc1818)}@container (max-width: 320px){._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._0a1270dcdd79c031__actions,._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._1904b570a89bb815__description{grid-column:1/3}}}@layer compositions{.d329e7416d368d31__action-link{margin-block:auto}._487e6a5c1375f7dc__close-icon,._983740ab855c4e09__action-button:is(._8ddb8fb33fbf3d38__is-action-button-outline,._77bbde495a8a0af3__is-action-button-minimal){--wp-ui-button-background-color-active:color-mix(in srgb,transparent 50%,var(--wpds-color-background-interactive-neutral-weak-active,#ededed))}}}"); 15492 } 15493 var style_default20 = { "notice": "_4145abab73d17514__notice", "icon": "d0a25570cb528528__icon", "title": "b5397fb9d05389e3__title", "description": "_1904b570a89bb815__description", "actions": "_0a1270dcdd79c031__actions", "action-button": "_983740ab855c4e09__action-button", "action-link": "d329e7416d368d31__action-link", "close-icon": "_487e6a5c1375f7dc__close-icon", "is-info": "_531c140826094795__is-info", "is-warning": "ae2e1004697cce95__is-warning", "is-success": "_2e614a76af494837__is-success", "is-error": "af00331ae17a0065__is-error", "is-action-button-outline": "_8ddb8fb33fbf3d38__is-action-button-outline", "is-action-button-minimal": "_77bbde495a8a0af3__is-action-button-minimal" }; 15494 var Actions = (0, import_element45.forwardRef)( 15495 function NoticeActions({ render: render4, ...props }, ref) { 15496 const element = useRender({ 15497 defaultTagName: "div", 15498 render: render4, 15499 ref, 15500 props: mergeProps( 15501 { 15502 className: style_default20.actions 15503 }, 15504 props 15505 ) 15506 }); 15507 return element; 15508 } 15509 ); 15510 15511 // packages/ui/build-module/notice/close-icon.mjs 15512 var import_element46 = __toESM(require_element(), 1); 15513 var import_i18n3 = __toESM(require_i18n(), 1); 15514 var import_jsx_runtime74 = __toESM(require_jsx_runtime(), 1); 15515 var STYLE_HASH_ATTRIBUTE22 = "data-wp-hash"; 15516 function getRuntime22() { 15517 const globalScope = globalThis; 15518 if (globalScope.__wpStyleRuntime) { 15519 return globalScope.__wpStyleRuntime; 15520 } 15521 globalScope.__wpStyleRuntime = { 15522 documents: /* @__PURE__ */ new Map(), 15523 styles: /* @__PURE__ */ new Map(), 15524 injectedStyles: /* @__PURE__ */ new WeakMap() 15525 }; 15526 if (typeof document !== "undefined") { 15527 registerDocument22(document); 15528 } 15529 return globalScope.__wpStyleRuntime; 15530 } 15531 function documentContainsStyleHash22(targetDocument, hash) { 15532 if (!targetDocument.head) { 15533 return false; 15534 } 15535 for (const style of targetDocument.head.querySelectorAll( 15536 `style[$STYLE_HASH_ATTRIBUTE22}]` 15537 )) { 15538 if (style.getAttribute(STYLE_HASH_ATTRIBUTE22) === hash) { 15539 return true; 15540 } 15541 } 15542 return false; 15543 } 15544 function injectStyle22(targetDocument, hash, css) { 15545 if (!targetDocument.head) { 15546 return; 15547 } 15548 const runtime = getRuntime22(); 15549 let injectedStyles = runtime.injectedStyles.get(targetDocument); 15550 if (!injectedStyles) { 15551 injectedStyles = /* @__PURE__ */ new Set(); 15552 runtime.injectedStyles.set(targetDocument, injectedStyles); 15553 } 15554 if (injectedStyles.has(hash)) { 15555 return; 15556 } 15557 if (documentContainsStyleHash22(targetDocument, hash)) { 15558 injectedStyles.add(hash); 15559 return; 15560 } 15561 const style = targetDocument.createElement("style"); 15562 style.setAttribute(STYLE_HASH_ATTRIBUTE22, hash); 15563 style.appendChild(targetDocument.createTextNode(css)); 15564 targetDocument.head.appendChild(style); 15565 injectedStyles.add(hash); 15566 } 15567 function registerDocument22(targetDocument) { 15568 const runtime = getRuntime22(); 15569 runtime.documents.set( 15570 targetDocument, 15571 (runtime.documents.get(targetDocument) ?? 0) + 1 15572 ); 15573 for (const [hash, css] of runtime.styles) { 15574 injectStyle22(targetDocument, hash, css); 15575 } 15576 return () => { 15577 const count = runtime.documents.get(targetDocument); 15578 if (count === void 0) { 15579 return; 15580 } 15581 if (count <= 1) { 15582 runtime.documents.delete(targetDocument); 15583 return; 15584 } 15585 runtime.documents.set(targetDocument, count - 1); 15586 }; 15587 } 15588 function registerStyle22(hash, css) { 15589 const runtime = getRuntime22(); 15590 runtime.styles.set(hash, css); 15591 for (const targetDocument of runtime.documents.keys()) { 15592 injectStyle22(targetDocument, hash, css); 15593 } 15594 } 15595 if (typeof process === "undefined" || true) { 15596 registerStyle22("726c480820", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._4145abab73d17514__notice{--icon-height:var(--wpds-dimension-size-sm,24px);--text-vertical-padding:calc((var(--icon-height) - var(--wpds-typography-line-height-sm, 20px))/2);--wp-ui-notice-background-color:var(--wpds-color-background-surface-neutral-weak,#f4f4f4);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-neutral,#dbdbdb);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-neutral,#1e1e1e);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-neutral,#1e1e1e);align-items:start;background-color:var(--wp-ui-notice-background-color);border:1px solid var(--wp-ui-notice-border-color);border-radius:var(--wpds-border-radius-lg,8px);container-type:inline-size;display:grid;grid-template-columns:auto 1fr auto;padding:var(--wpds-dimension-padding-md,12px)}.d0a25570cb528528__icon{color:var(--wp-ui-notice-decorative-icon-color);grid-column:1;grid-row:1;margin-inline-end:var(--wpds-dimension-gap-xs,4px)}._1904b570a89bb815__description,.b5397fb9d05389e3__title{color:var(--wp-ui-notice-text-color);grid-column:2;padding-block:var(--text-vertical-padding)}._1904b570a89bb815__description{text-wrap:pretty}._0a1270dcdd79c031__actions{display:flex;flex-wrap:wrap;gap:var(--wpds-dimension-gap-md,12px);grid-column:2}._4145abab73d17514__notice:has(._1904b570a89bb815__description) ._0a1270dcdd79c031__actions,._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._0a1270dcdd79c031__actions{margin-block-start:var(--wpds-dimension-gap-sm,8px)}._983740ab855c4e09__action-button{flex-shrink:0}.d329e7416d368d31__action-link{flex-shrink:0;&:not(:first-child){margin-inline-start:var(--wpds-dimension-gap-xs,4px)}&:not(:last-child){margin-inline-end:var(--wpds-dimension-gap-xs,4px)}}._487e6a5c1375f7dc__close-icon{grid-column:3;grid-row:1;margin-inline-start:var(--wpds-dimension-gap-xs,4px)}._531c140826094795__is-info{--wp-ui-notice-background-color:var(--wpds-color-background-surface-info-weak,#f3f9ff);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-info,#a9c6e7);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-info,#001b4f);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-info-weak,#006bd7)}.ae2e1004697cce95__is-warning{--wp-ui-notice-background-color:var(--wpds-color-background-surface-warning-weak,#fff7e1);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-warning,#e1bc7c);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-warning,#2e1900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-warning-weak,#926300)}._2e614a76af494837__is-success{--wp-ui-notice-background-color:var(--wpds-color-background-surface-success-weak,#ebffed);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-success,#94d29e);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-success,#002900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-success-weak,#008030)}.af00331ae17a0065__is-error{--wp-ui-notice-background-color:var(--wpds-color-background-surface-error-weak,#fff6f5);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-error,#dab1aa);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-error,#470000);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-error-weak,#cc1818)}@container (max-width: 320px){._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._0a1270dcdd79c031__actions,._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._1904b570a89bb815__description{grid-column:1/3}}}@layer compositions{.d329e7416d368d31__action-link{margin-block:auto}._487e6a5c1375f7dc__close-icon,._983740ab855c4e09__action-button:is(._8ddb8fb33fbf3d38__is-action-button-outline,._77bbde495a8a0af3__is-action-button-minimal){--wp-ui-button-background-color-active:color-mix(in srgb,transparent 50%,var(--wpds-color-background-interactive-neutral-weak-active,#ededed))}}}"); 15597 } 15598 var style_default21 = { "notice": "_4145abab73d17514__notice", "icon": "d0a25570cb528528__icon", "title": "b5397fb9d05389e3__title", "description": "_1904b570a89bb815__description", "actions": "_0a1270dcdd79c031__actions", "action-button": "_983740ab855c4e09__action-button", "action-link": "d329e7416d368d31__action-link", "close-icon": "_487e6a5c1375f7dc__close-icon", "is-info": "_531c140826094795__is-info", "is-warning": "ae2e1004697cce95__is-warning", "is-success": "_2e614a76af494837__is-success", "is-error": "af00331ae17a0065__is-error", "is-action-button-outline": "_8ddb8fb33fbf3d38__is-action-button-outline", "is-action-button-minimal": "_77bbde495a8a0af3__is-action-button-minimal" }; 15599 var CloseIcon = (0, import_element46.forwardRef)( 15600 function NoticeCloseIcon({ className, icon = close_small_default, label = (0, import_i18n3.__)("Dismiss"), ...props }, ref) { 15601 return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)( 15602 IconButton, 15603 { 15604 ...props, 15605 ref, 15606 className: clsx_default(style_default21["close-icon"], className), 15607 variant: "minimal", 15608 size: "small", 15609 tone: "neutral", 15610 icon, 15611 label 15612 } 15613 ); 15614 } 15615 ); 15616 15617 // packages/ui/build-module/notice/action-button.mjs 15618 var import_element47 = __toESM(require_element(), 1); 15619 var import_jsx_runtime75 = __toESM(require_jsx_runtime(), 1); 15620 var STYLE_HASH_ATTRIBUTE23 = "data-wp-hash"; 15621 function getRuntime23() { 15622 const globalScope = globalThis; 15623 if (globalScope.__wpStyleRuntime) { 15624 return globalScope.__wpStyleRuntime; 15625 } 15626 globalScope.__wpStyleRuntime = { 15627 documents: /* @__PURE__ */ new Map(), 15628 styles: /* @__PURE__ */ new Map(), 15629 injectedStyles: /* @__PURE__ */ new WeakMap() 15630 }; 15631 if (typeof document !== "undefined") { 15632 registerDocument23(document); 15633 } 15634 return globalScope.__wpStyleRuntime; 15635 } 15636 function documentContainsStyleHash23(targetDocument, hash) { 15637 if (!targetDocument.head) { 15638 return false; 15639 } 15640 for (const style of targetDocument.head.querySelectorAll( 15641 `style[$STYLE_HASH_ATTRIBUTE23}]` 15642 )) { 15643 if (style.getAttribute(STYLE_HASH_ATTRIBUTE23) === hash) { 15644 return true; 15645 } 15646 } 15647 return false; 15648 } 15649 function injectStyle23(targetDocument, hash, css) { 15650 if (!targetDocument.head) { 15651 return; 15652 } 15653 const runtime = getRuntime23(); 15654 let injectedStyles = runtime.injectedStyles.get(targetDocument); 15655 if (!injectedStyles) { 15656 injectedStyles = /* @__PURE__ */ new Set(); 15657 runtime.injectedStyles.set(targetDocument, injectedStyles); 15658 } 15659 if (injectedStyles.has(hash)) { 15660 return; 15661 } 15662 if (documentContainsStyleHash23(targetDocument, hash)) { 15663 injectedStyles.add(hash); 15664 return; 15665 } 15666 const style = targetDocument.createElement("style"); 15667 style.setAttribute(STYLE_HASH_ATTRIBUTE23, hash); 15668 style.appendChild(targetDocument.createTextNode(css)); 15669 targetDocument.head.appendChild(style); 15670 injectedStyles.add(hash); 15671 } 15672 function registerDocument23(targetDocument) { 15673 const runtime = getRuntime23(); 15674 runtime.documents.set( 15675 targetDocument, 15676 (runtime.documents.get(targetDocument) ?? 0) + 1 15677 ); 15678 for (const [hash, css] of runtime.styles) { 15679 injectStyle23(targetDocument, hash, css); 15680 } 15681 return () => { 15682 const count = runtime.documents.get(targetDocument); 15683 if (count === void 0) { 15684 return; 15685 } 15686 if (count <= 1) { 15687 runtime.documents.delete(targetDocument); 15688 return; 15689 } 15690 runtime.documents.set(targetDocument, count - 1); 15691 }; 15692 } 15693 function registerStyle23(hash, css) { 15694 const runtime = getRuntime23(); 15695 runtime.styles.set(hash, css); 15696 for (const targetDocument of runtime.documents.keys()) { 15697 injectStyle23(targetDocument, hash, css); 15698 } 15699 } 15700 if (typeof process === "undefined" || true) { 15701 registerStyle23("726c480820", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._4145abab73d17514__notice{--icon-height:var(--wpds-dimension-size-sm,24px);--text-vertical-padding:calc((var(--icon-height) - var(--wpds-typography-line-height-sm, 20px))/2);--wp-ui-notice-background-color:var(--wpds-color-background-surface-neutral-weak,#f4f4f4);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-neutral,#dbdbdb);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-neutral,#1e1e1e);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-neutral,#1e1e1e);align-items:start;background-color:var(--wp-ui-notice-background-color);border:1px solid var(--wp-ui-notice-border-color);border-radius:var(--wpds-border-radius-lg,8px);container-type:inline-size;display:grid;grid-template-columns:auto 1fr auto;padding:var(--wpds-dimension-padding-md,12px)}.d0a25570cb528528__icon{color:var(--wp-ui-notice-decorative-icon-color);grid-column:1;grid-row:1;margin-inline-end:var(--wpds-dimension-gap-xs,4px)}._1904b570a89bb815__description,.b5397fb9d05389e3__title{color:var(--wp-ui-notice-text-color);grid-column:2;padding-block:var(--text-vertical-padding)}._1904b570a89bb815__description{text-wrap:pretty}._0a1270dcdd79c031__actions{display:flex;flex-wrap:wrap;gap:var(--wpds-dimension-gap-md,12px);grid-column:2}._4145abab73d17514__notice:has(._1904b570a89bb815__description) ._0a1270dcdd79c031__actions,._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._0a1270dcdd79c031__actions{margin-block-start:var(--wpds-dimension-gap-sm,8px)}._983740ab855c4e09__action-button{flex-shrink:0}.d329e7416d368d31__action-link{flex-shrink:0;&:not(:first-child){margin-inline-start:var(--wpds-dimension-gap-xs,4px)}&:not(:last-child){margin-inline-end:var(--wpds-dimension-gap-xs,4px)}}._487e6a5c1375f7dc__close-icon{grid-column:3;grid-row:1;margin-inline-start:var(--wpds-dimension-gap-xs,4px)}._531c140826094795__is-info{--wp-ui-notice-background-color:var(--wpds-color-background-surface-info-weak,#f3f9ff);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-info,#a9c6e7);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-info,#001b4f);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-info-weak,#006bd7)}.ae2e1004697cce95__is-warning{--wp-ui-notice-background-color:var(--wpds-color-background-surface-warning-weak,#fff7e1);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-warning,#e1bc7c);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-warning,#2e1900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-warning-weak,#926300)}._2e614a76af494837__is-success{--wp-ui-notice-background-color:var(--wpds-color-background-surface-success-weak,#ebffed);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-success,#94d29e);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-success,#002900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-success-weak,#008030)}.af00331ae17a0065__is-error{--wp-ui-notice-background-color:var(--wpds-color-background-surface-error-weak,#fff6f5);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-error,#dab1aa);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-error,#470000);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-error-weak,#cc1818)}@container (max-width: 320px){._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._0a1270dcdd79c031__actions,._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._1904b570a89bb815__description{grid-column:1/3}}}@layer compositions{.d329e7416d368d31__action-link{margin-block:auto}._487e6a5c1375f7dc__close-icon,._983740ab855c4e09__action-button:is(._8ddb8fb33fbf3d38__is-action-button-outline,._77bbde495a8a0af3__is-action-button-minimal){--wp-ui-button-background-color-active:color-mix(in srgb,transparent 50%,var(--wpds-color-background-interactive-neutral-weak-active,#ededed))}}}"); 15702 } 15703 var style_default22 = { "notice": "_4145abab73d17514__notice", "icon": "d0a25570cb528528__icon", "title": "b5397fb9d05389e3__title", "description": "_1904b570a89bb815__description", "actions": "_0a1270dcdd79c031__actions", "action-button": "_983740ab855c4e09__action-button", "action-link": "d329e7416d368d31__action-link", "close-icon": "_487e6a5c1375f7dc__close-icon", "is-info": "_531c140826094795__is-info", "is-warning": "ae2e1004697cce95__is-warning", "is-success": "_2e614a76af494837__is-success", "is-error": "af00331ae17a0065__is-error", "is-action-button-outline": "_8ddb8fb33fbf3d38__is-action-button-outline", "is-action-button-minimal": "_77bbde495a8a0af3__is-action-button-minimal" }; 15704 var ActionButton = (0, import_element47.forwardRef)( 15705 function NoticeActionButton({ className, loading, loadingAnnouncement, variant, ...props }, ref) { 15706 const loadingProps = loading !== void 0 ? { loading, loadingAnnouncement: loadingAnnouncement ?? "" } : {}; 15707 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)( 15708 Button4, 15709 { 15710 ...props, 15711 ...loadingProps, 15712 ref, 15713 size: "compact", 15714 tone: "neutral", 15715 variant, 15716 className: clsx_default( 15717 style_default22["action-button"], 15718 style_default22[`is-action-button-$variant}`], 15719 className 15720 ) 15721 } 15722 ); 15723 } 15724 ); 15725 15726 // packages/ui/build-module/notice/action-link.mjs 15727 var import_element48 = __toESM(require_element(), 1); 15728 var import_jsx_runtime76 = __toESM(require_jsx_runtime(), 1); 15729 var STYLE_HASH_ATTRIBUTE24 = "data-wp-hash"; 15730 function getRuntime24() { 15731 const globalScope = globalThis; 15732 if (globalScope.__wpStyleRuntime) { 15733 return globalScope.__wpStyleRuntime; 15734 } 15735 globalScope.__wpStyleRuntime = { 15736 documents: /* @__PURE__ */ new Map(), 15737 styles: /* @__PURE__ */ new Map(), 15738 injectedStyles: /* @__PURE__ */ new WeakMap() 15739 }; 15740 if (typeof document !== "undefined") { 15741 registerDocument24(document); 15742 } 15743 return globalScope.__wpStyleRuntime; 15744 } 15745 function documentContainsStyleHash24(targetDocument, hash) { 15746 if (!targetDocument.head) { 15747 return false; 15748 } 15749 for (const style of targetDocument.head.querySelectorAll( 15750 `style[$STYLE_HASH_ATTRIBUTE24}]` 15751 )) { 15752 if (style.getAttribute(STYLE_HASH_ATTRIBUTE24) === hash) { 15753 return true; 15754 } 15755 } 15756 return false; 15757 } 15758 function injectStyle24(targetDocument, hash, css) { 15759 if (!targetDocument.head) { 15760 return; 15761 } 15762 const runtime = getRuntime24(); 15763 let injectedStyles = runtime.injectedStyles.get(targetDocument); 15764 if (!injectedStyles) { 15765 injectedStyles = /* @__PURE__ */ new Set(); 15766 runtime.injectedStyles.set(targetDocument, injectedStyles); 15767 } 15768 if (injectedStyles.has(hash)) { 15769 return; 15770 } 15771 if (documentContainsStyleHash24(targetDocument, hash)) { 15772 injectedStyles.add(hash); 15773 return; 15774 } 15775 const style = targetDocument.createElement("style"); 15776 style.setAttribute(STYLE_HASH_ATTRIBUTE24, hash); 15777 style.appendChild(targetDocument.createTextNode(css)); 15778 targetDocument.head.appendChild(style); 15779 injectedStyles.add(hash); 15780 } 15781 function registerDocument24(targetDocument) { 15782 const runtime = getRuntime24(); 15783 runtime.documents.set( 15784 targetDocument, 15785 (runtime.documents.get(targetDocument) ?? 0) + 1 15786 ); 15787 for (const [hash, css] of runtime.styles) { 15788 injectStyle24(targetDocument, hash, css); 15789 } 15790 return () => { 15791 const count = runtime.documents.get(targetDocument); 15792 if (count === void 0) { 15793 return; 15794 } 15795 if (count <= 1) { 15796 runtime.documents.delete(targetDocument); 15797 return; 15798 } 15799 runtime.documents.set(targetDocument, count - 1); 15800 }; 15801 } 15802 function registerStyle24(hash, css) { 15803 const runtime = getRuntime24(); 15804 runtime.styles.set(hash, css); 15805 for (const targetDocument of runtime.documents.keys()) { 15806 injectStyle24(targetDocument, hash, css); 15807 } 15808 } 15809 if (typeof process === "undefined" || true) { 15810 registerStyle24("726c480820", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._4145abab73d17514__notice{--icon-height:var(--wpds-dimension-size-sm,24px);--text-vertical-padding:calc((var(--icon-height) - var(--wpds-typography-line-height-sm, 20px))/2);--wp-ui-notice-background-color:var(--wpds-color-background-surface-neutral-weak,#f4f4f4);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-neutral,#dbdbdb);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-neutral,#1e1e1e);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-neutral,#1e1e1e);align-items:start;background-color:var(--wp-ui-notice-background-color);border:1px solid var(--wp-ui-notice-border-color);border-radius:var(--wpds-border-radius-lg,8px);container-type:inline-size;display:grid;grid-template-columns:auto 1fr auto;padding:var(--wpds-dimension-padding-md,12px)}.d0a25570cb528528__icon{color:var(--wp-ui-notice-decorative-icon-color);grid-column:1;grid-row:1;margin-inline-end:var(--wpds-dimension-gap-xs,4px)}._1904b570a89bb815__description,.b5397fb9d05389e3__title{color:var(--wp-ui-notice-text-color);grid-column:2;padding-block:var(--text-vertical-padding)}._1904b570a89bb815__description{text-wrap:pretty}._0a1270dcdd79c031__actions{display:flex;flex-wrap:wrap;gap:var(--wpds-dimension-gap-md,12px);grid-column:2}._4145abab73d17514__notice:has(._1904b570a89bb815__description) ._0a1270dcdd79c031__actions,._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._0a1270dcdd79c031__actions{margin-block-start:var(--wpds-dimension-gap-sm,8px)}._983740ab855c4e09__action-button{flex-shrink:0}.d329e7416d368d31__action-link{flex-shrink:0;&:not(:first-child){margin-inline-start:var(--wpds-dimension-gap-xs,4px)}&:not(:last-child){margin-inline-end:var(--wpds-dimension-gap-xs,4px)}}._487e6a5c1375f7dc__close-icon{grid-column:3;grid-row:1;margin-inline-start:var(--wpds-dimension-gap-xs,4px)}._531c140826094795__is-info{--wp-ui-notice-background-color:var(--wpds-color-background-surface-info-weak,#f3f9ff);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-info,#a9c6e7);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-info,#001b4f);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-info-weak,#006bd7)}.ae2e1004697cce95__is-warning{--wp-ui-notice-background-color:var(--wpds-color-background-surface-warning-weak,#fff7e1);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-warning,#e1bc7c);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-warning,#2e1900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-warning-weak,#926300)}._2e614a76af494837__is-success{--wp-ui-notice-background-color:var(--wpds-color-background-surface-success-weak,#ebffed);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-success,#94d29e);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-success,#002900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-success-weak,#008030)}.af00331ae17a0065__is-error{--wp-ui-notice-background-color:var(--wpds-color-background-surface-error-weak,#fff6f5);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-error,#dab1aa);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-error,#470000);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-error-weak,#cc1818)}@container (max-width: 320px){._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._0a1270dcdd79c031__actions,._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._1904b570a89bb815__description{grid-column:1/3}}}@layer compositions{.d329e7416d368d31__action-link{margin-block:auto}._487e6a5c1375f7dc__close-icon,._983740ab855c4e09__action-button:is(._8ddb8fb33fbf3d38__is-action-button-outline,._77bbde495a8a0af3__is-action-button-minimal){--wp-ui-button-background-color-active:color-mix(in srgb,transparent 50%,var(--wpds-color-background-interactive-neutral-weak-active,#ededed))}}}"); 15811 } 15812 var style_default23 = { "notice": "_4145abab73d17514__notice", "icon": "d0a25570cb528528__icon", "title": "b5397fb9d05389e3__title", "description": "_1904b570a89bb815__description", "actions": "_0a1270dcdd79c031__actions", "action-button": "_983740ab855c4e09__action-button", "action-link": "d329e7416d368d31__action-link", "close-icon": "_487e6a5c1375f7dc__close-icon", "is-info": "_531c140826094795__is-info", "is-warning": "ae2e1004697cce95__is-warning", "is-success": "_2e614a76af494837__is-success", "is-error": "af00331ae17a0065__is-error", "is-action-button-outline": "_8ddb8fb33fbf3d38__is-action-button-outline", "is-action-button-minimal": "_77bbde495a8a0af3__is-action-button-minimal" }; 15813 var ActionLink = (0, import_element48.forwardRef)( 15814 function NoticeActionLink({ className, render: render4, ...props }, ref) { 15815 return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)( 15816 Text, 15817 { 15818 ref, 15819 className: clsx_default(style_default23["action-link"], className), 15820 ...props, 15821 variant: "body-md", 15822 render: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(Link, { tone: "neutral", variant: "default", render: render4 }) 15823 } 15824 ); 15825 } 15826 ); 15827 15828 // packages/ui/build-module/popover/index.mjs 15829 var popover_exports = {}; 15830 __export(popover_exports, { 15831 Arrow: () => Arrow, 15832 Close: () => Close, 15833 Description: () => Description2, 15834 Popup: () => Popup2, 15835 Portal: () => Portal2, 15836 Positioner: () => Positioner2, 15837 Root: () => Root6, 15838 Title: () => Title3, 15839 Trigger: () => Trigger3 15840 }); 15841 15842 // packages/ui/build-module/popover/arrow.mjs 15843 var import_element49 = __toESM(require_element(), 1); 15844 var import_jsx_runtime77 = __toESM(require_jsx_runtime(), 1); 15845 var STYLE_HASH_ATTRIBUTE25 = "data-wp-hash"; 15846 function getRuntime25() { 15847 const globalScope = globalThis; 15848 if (globalScope.__wpStyleRuntime) { 15849 return globalScope.__wpStyleRuntime; 15850 } 15851 globalScope.__wpStyleRuntime = { 15852 documents: /* @__PURE__ */ new Map(), 15853 styles: /* @__PURE__ */ new Map(), 15854 injectedStyles: /* @__PURE__ */ new WeakMap() 15855 }; 15856 if (typeof document !== "undefined") { 15857 registerDocument25(document); 15858 } 15859 return globalScope.__wpStyleRuntime; 15860 } 15861 function documentContainsStyleHash25(targetDocument, hash) { 15862 if (!targetDocument.head) { 15863 return false; 15864 } 15865 for (const style of targetDocument.head.querySelectorAll( 15866 `style[$STYLE_HASH_ATTRIBUTE25}]` 15867 )) { 15868 if (style.getAttribute(STYLE_HASH_ATTRIBUTE25) === hash) { 15869 return true; 15870 } 15871 } 15872 return false; 15873 } 15874 function injectStyle25(targetDocument, hash, css) { 15875 if (!targetDocument.head) { 15876 return; 15877 } 15878 const runtime = getRuntime25(); 15879 let injectedStyles = runtime.injectedStyles.get(targetDocument); 15880 if (!injectedStyles) { 15881 injectedStyles = /* @__PURE__ */ new Set(); 15882 runtime.injectedStyles.set(targetDocument, injectedStyles); 15883 } 15884 if (injectedStyles.has(hash)) { 15885 return; 15886 } 15887 if (documentContainsStyleHash25(targetDocument, hash)) { 15888 injectedStyles.add(hash); 15889 return; 15890 } 15891 const style = targetDocument.createElement("style"); 15892 style.setAttribute(STYLE_HASH_ATTRIBUTE25, hash); 15893 style.appendChild(targetDocument.createTextNode(css)); 15894 targetDocument.head.appendChild(style); 15895 injectedStyles.add(hash); 15896 } 15897 function registerDocument25(targetDocument) { 15898 const runtime = getRuntime25(); 15899 runtime.documents.set( 15900 targetDocument, 15901 (runtime.documents.get(targetDocument) ?? 0) + 1 15902 ); 15903 for (const [hash, css] of runtime.styles) { 15904 injectStyle25(targetDocument, hash, css); 15905 } 15906 return () => { 15907 const count = runtime.documents.get(targetDocument); 15908 if (count === void 0) { 15909 return; 15910 } 15911 if (count <= 1) { 15912 runtime.documents.delete(targetDocument); 15913 return; 15914 } 15915 runtime.documents.set(targetDocument, count - 1); 15916 }; 15917 } 15918 function registerStyle25(hash, css) { 15919 const runtime = getRuntime25(); 15920 runtime.styles.set(hash, css); 15921 for (const targetDocument of runtime.documents.keys()) { 15922 injectStyle25(targetDocument, hash, css); 15923 } 15924 } 15925 if (typeof process === "undefined" || true) { 15926 registerStyle25("e53c8c48f6", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._380b81b8f79fb10f__dropdown-motion{--wp-ui-dropdown-slide-distance:4px;--wp-ui-dropdown-slide-duration:var(--wpds-motion-duration-md,200ms);--wp-ui-dropdown-slide-easing:var(--wpds-motion-easing-expressive,cubic-bezier(0.25,0,0,1));--wp-ui-dropdown-fade-duration:var(--wpds-motion-duration-sm,100ms);--wp-ui-dropdown-fade-easing:linear;@media not (prefers-reduced-motion){transition-duration:var(--wp-ui-dropdown-slide-duration),var(--wp-ui-dropdown-fade-duration);transition-property:transform,opacity;transition-timing-function:var(--wp-ui-dropdown-slide-easing),var(--wp-ui-dropdown-fade-easing);will-change:transform,opacity}opacity:1;transform:translate(0);&[data-instant]{transition:none}&[data-ending-style],&[data-starting-style]{opacity:0}&[data-side=bottom][data-ending-style],&[data-side=bottom][data-starting-style]{transform:translateY(calc(var(--wp-ui-dropdown-slide-distance)*-1))}&[data-side=top][data-ending-style],&[data-side=top][data-starting-style]{transform:translateY(var(--wp-ui-dropdown-slide-distance))}&[data-side=left][data-ending-style],&[data-side=left][data-starting-style]{transform:translateX(var(--wp-ui-dropdown-slide-distance))}&[data-side=right][data-ending-style],&[data-side=right][data-starting-style]{transform:translateX(calc(var(--wp-ui-dropdown-slide-distance)*-1))}}}}@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._10450722b9676f78__positioner{z-index:var(--wp-ui-popover-z-index,initial)}._84e8f597bcf683b8__popup{outline:0}._972134b6cd5808d8__surface{--_wp-ui-elevation-md:0 2px 3px rgba(0,0,0,.05),0 4px 5px rgba(0,0,0,.04),0 12px 12px rgba(0,0,0,.03),0 16px 16px rgba(0,0,0,.02);background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral,#dbdbdb);border-radius:var(--wpds-border-radius-md,4px);box-shadow:var(--_wp-ui-elevation-md);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-md,13px);line-height:var(--wpds-typography-line-height-md,24px);padding:var(--wpds-dimension-padding-lg,16px)}.e4d544aa033f05c6__backdrop~* ._972134b6cd5808d8__surface{border-color:transparent}@media (forced-colors:active){._972134b6cd5808d8__surface,.e4d544aa033f05c6__backdrop~* ._972134b6cd5808d8__surface{border-color:CanvasText}}.ca05d3eb89321fcd__arrow{display:flex;&[data-side=top]{bottom:-8px;rotate:180deg}&[data-side=bottom]{rotate:0deg;top:-8px}&[data-side=left]{inset-inline-end:-13px;rotate:90deg}&[data-side=right]{inset-inline-start:-13px;rotate:-90deg}}._12d8edd9eb946b5f__arrow-fill{fill:var(--wpds-color-background-surface-neutral-strong,#fff)}._6ddab482bd929dad__arrow-stroke{fill:var(--wpds-color-stroke-surface-neutral,#dbdbdb)}._6d7e4729cd96960e__title{--_gcd-heading-color:var(--wpds-color-foreground-content-neutral,#1e1e1e);color:var(--wpds-color-foreground-content-neutral,#1e1e1e)}.e4d544aa033f05c6__backdrop{background-color:rgba(0,0,0,.15);inset:0;opacity:1;position:fixed;z-index:var(--wp-ui-popover-z-index,initial);&[data-ending-style],&[data-starting-style]{opacity:0}@media not (prefers-reduced-motion){transition:opacity var(--wpds-motion-duration-sm,.1s) var(--wpds-motion-easing-subtle,cubic-bezier(.15,0,.15,1))}}}}'); 15927 } 15928 var style_default24 = { "positioner": "_10450722b9676f78__positioner", "popup": "_84e8f597bcf683b8__popup _380b81b8f79fb10f__dropdown-motion", "surface": "_972134b6cd5808d8__surface", "backdrop": "e4d544aa033f05c6__backdrop", "arrow": "ca05d3eb89321fcd__arrow", "arrow-fill": "_12d8edd9eb946b5f__arrow-fill", "arrow-stroke": "_6ddab482bd929dad__arrow-stroke", "title": "_6d7e4729cd96960e__title" }; 15929 function DefaultArrowSvg(props) { 15930 return /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)( 15931 "svg", 15932 { 15933 width: "20", 15934 height: "10", 15935 viewBox: "0 0 20 10", 15936 fill: "none", 15937 ...props, 15938 children: [ 15939 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)( 15940 "path", 15941 { 15942 d: "M20 10H0V8h1.465a4 4 0 0 0 2.676-1.027l5.19-4.388c.378-.341.96-.341 1.338 0l5.19 4.388A4 4 0 0 0 18.535 8H20z", 15943 className: style_default24["arrow-fill"] 15944 } 15945 ), 15946 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)( 15947 "path", 15948 { 15949 d: "M10 3.097 4.81 7.486A5 5 0 0 1 1.465 8.77H0V8h1.465a4 4 0 0 0 2.676-1.027l5.19-4.388c.378-.341.96-.341 1.338 0l5.19 4.388A4 4 0 0 0 18.535 8H20v.77h-1.465a5 5 0 0 1-3.345-1.284z", 15950 className: style_default24["arrow-stroke"] 15951 } 15952 ) 15953 ] 15954 } 15955 ); 15956 } 15957 var Arrow = (0, import_element49.forwardRef)(function PopoverArrow3({ children, className, ...props }, ref) { 15958 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)( 15959 index_parts_exports2.Arrow, 15960 { 15961 ref, 15962 className: clsx_default(style_default24.arrow, className), 15963 ...props, 15964 children: children ?? /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(DefaultArrowSvg, {}) 15965 } 15966 ); 15967 }); 15968 15969 // packages/ui/build-module/popover/close.mjs 15970 var import_element50 = __toESM(require_element(), 1); 15971 var import_jsx_runtime78 = __toESM(require_jsx_runtime(), 1); 15972 var Close = (0, import_element50.forwardRef)( 15973 function PopoverClose3(props, ref) { 15974 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)( 15975 index_parts_exports2.Close, 15976 { 15977 ref, 15978 "data-wp-ui-popover-close": "", 15979 ...props 15980 } 15981 ); 15982 } 15983 ); 15984 15985 // packages/ui/build-module/popover/description.mjs 15986 var import_element51 = __toESM(require_element(), 1); 15987 var import_jsx_runtime79 = __toESM(require_jsx_runtime(), 1); 15988 var Description2 = (0, import_element51.forwardRef)( 15989 function PopoverDescription3({ children, ...props }, ref) { 15990 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)( 15991 Text, 15992 { 15993 ref, 15994 variant: "body-md", 15995 render: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(index_parts_exports2.Description, { ...props }), 15996 children 15997 } 15998 ); 15999 } 16000 ); 16001 16002 // packages/ui/build-module/popover/popup.mjs 16003 var import_element54 = __toESM(require_element(), 1); 16004 var import_compose = __toESM(require_compose(), 1); 16005 16006 // packages/ui/build-module/popover/context.mjs 16007 var popoverTitleValidation = createOverlayTitleValidation("Popover"); 16008 var usePopoverValidationContext = popoverTitleValidation.useValidationContext; 16009 var PopoverValidationProvider = popoverTitleValidation.ValidationProvider; 16010 16011 // packages/ui/build-module/popover/portal.mjs 16012 var import_element52 = __toESM(require_element(), 1); 16013 var import_jsx_runtime80 = __toESM(require_jsx_runtime(), 1); 16014 var Portal2 = (0, import_element52.forwardRef)( 16015 function PopoverPortal3({ container, ...restProps }, ref) { 16016 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)( 16017 index_parts_exports2.Portal, 16018 { 16019 container: container ?? getWpCompatOverlaySlot(), 16020 ...restProps, 16021 ref 16022 } 16023 ); 16024 } 16025 ); 16026 16027 // packages/ui/build-module/popover/positioner.mjs 16028 var import_element53 = __toESM(require_element(), 1); 16029 var import_jsx_runtime81 = __toESM(require_jsx_runtime(), 1); 16030 var STYLE_HASH_ATTRIBUTE26 = "data-wp-hash"; 16031 function getRuntime26() { 16032 const globalScope = globalThis; 16033 if (globalScope.__wpStyleRuntime) { 16034 return globalScope.__wpStyleRuntime; 16035 } 16036 globalScope.__wpStyleRuntime = { 16037 documents: /* @__PURE__ */ new Map(), 16038 styles: /* @__PURE__ */ new Map(), 16039 injectedStyles: /* @__PURE__ */ new WeakMap() 16040 }; 16041 if (typeof document !== "undefined") { 16042 registerDocument26(document); 16043 } 16044 return globalScope.__wpStyleRuntime; 16045 } 16046 function documentContainsStyleHash26(targetDocument, hash) { 16047 if (!targetDocument.head) { 16048 return false; 16049 } 16050 for (const style of targetDocument.head.querySelectorAll( 16051 `style[$STYLE_HASH_ATTRIBUTE26}]` 16052 )) { 16053 if (style.getAttribute(STYLE_HASH_ATTRIBUTE26) === hash) { 16054 return true; 16055 } 16056 } 16057 return false; 16058 } 16059 function injectStyle26(targetDocument, hash, css) { 16060 if (!targetDocument.head) { 16061 return; 16062 } 16063 const runtime = getRuntime26(); 16064 let injectedStyles = runtime.injectedStyles.get(targetDocument); 16065 if (!injectedStyles) { 16066 injectedStyles = /* @__PURE__ */ new Set(); 16067 runtime.injectedStyles.set(targetDocument, injectedStyles); 16068 } 16069 if (injectedStyles.has(hash)) { 16070 return; 16071 } 16072 if (documentContainsStyleHash26(targetDocument, hash)) { 16073 injectedStyles.add(hash); 16074 return; 16075 } 16076 const style = targetDocument.createElement("style"); 16077 style.setAttribute(STYLE_HASH_ATTRIBUTE26, hash); 16078 style.appendChild(targetDocument.createTextNode(css)); 16079 targetDocument.head.appendChild(style); 16080 injectedStyles.add(hash); 16081 } 16082 function registerDocument26(targetDocument) { 16083 const runtime = getRuntime26(); 16084 runtime.documents.set( 16085 targetDocument, 16086 (runtime.documents.get(targetDocument) ?? 0) + 1 16087 ); 16088 for (const [hash, css] of runtime.styles) { 16089 injectStyle26(targetDocument, hash, css); 16090 } 16091 return () => { 16092 const count = runtime.documents.get(targetDocument); 16093 if (count === void 0) { 16094 return; 16095 } 16096 if (count <= 1) { 16097 runtime.documents.delete(targetDocument); 16098 return; 16099 } 16100 runtime.documents.set(targetDocument, count - 1); 16101 }; 16102 } 16103 function registerStyle26(hash, css) { 16104 const runtime = getRuntime26(); 16105 runtime.styles.set(hash, css); 16106 for (const targetDocument of runtime.documents.keys()) { 16107 injectStyle26(targetDocument, hash, css); 16108 } 16109 } 16110 if (typeof process === "undefined" || true) { 16111 registerStyle26("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}"); 16112 } 16113 var resets_default6 = { "box-sizing": "_336cd3e4e743482f__box-sizing" }; 16114 if (typeof process === "undefined" || true) { 16115 registerStyle26("e53c8c48f6", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._380b81b8f79fb10f__dropdown-motion{--wp-ui-dropdown-slide-distance:4px;--wp-ui-dropdown-slide-duration:var(--wpds-motion-duration-md,200ms);--wp-ui-dropdown-slide-easing:var(--wpds-motion-easing-expressive,cubic-bezier(0.25,0,0,1));--wp-ui-dropdown-fade-duration:var(--wpds-motion-duration-sm,100ms);--wp-ui-dropdown-fade-easing:linear;@media not (prefers-reduced-motion){transition-duration:var(--wp-ui-dropdown-slide-duration),var(--wp-ui-dropdown-fade-duration);transition-property:transform,opacity;transition-timing-function:var(--wp-ui-dropdown-slide-easing),var(--wp-ui-dropdown-fade-easing);will-change:transform,opacity}opacity:1;transform:translate(0);&[data-instant]{transition:none}&[data-ending-style],&[data-starting-style]{opacity:0}&[data-side=bottom][data-ending-style],&[data-side=bottom][data-starting-style]{transform:translateY(calc(var(--wp-ui-dropdown-slide-distance)*-1))}&[data-side=top][data-ending-style],&[data-side=top][data-starting-style]{transform:translateY(var(--wp-ui-dropdown-slide-distance))}&[data-side=left][data-ending-style],&[data-side=left][data-starting-style]{transform:translateX(var(--wp-ui-dropdown-slide-distance))}&[data-side=right][data-ending-style],&[data-side=right][data-starting-style]{transform:translateX(calc(var(--wp-ui-dropdown-slide-distance)*-1))}}}}@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._10450722b9676f78__positioner{z-index:var(--wp-ui-popover-z-index,initial)}._84e8f597bcf683b8__popup{outline:0}._972134b6cd5808d8__surface{--_wp-ui-elevation-md:0 2px 3px rgba(0,0,0,.05),0 4px 5px rgba(0,0,0,.04),0 12px 12px rgba(0,0,0,.03),0 16px 16px rgba(0,0,0,.02);background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral,#dbdbdb);border-radius:var(--wpds-border-radius-md,4px);box-shadow:var(--_wp-ui-elevation-md);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-md,13px);line-height:var(--wpds-typography-line-height-md,24px);padding:var(--wpds-dimension-padding-lg,16px)}.e4d544aa033f05c6__backdrop~* ._972134b6cd5808d8__surface{border-color:transparent}@media (forced-colors:active){._972134b6cd5808d8__surface,.e4d544aa033f05c6__backdrop~* ._972134b6cd5808d8__surface{border-color:CanvasText}}.ca05d3eb89321fcd__arrow{display:flex;&[data-side=top]{bottom:-8px;rotate:180deg}&[data-side=bottom]{rotate:0deg;top:-8px}&[data-side=left]{inset-inline-end:-13px;rotate:90deg}&[data-side=right]{inset-inline-start:-13px;rotate:-90deg}}._12d8edd9eb946b5f__arrow-fill{fill:var(--wpds-color-background-surface-neutral-strong,#fff)}._6ddab482bd929dad__arrow-stroke{fill:var(--wpds-color-stroke-surface-neutral,#dbdbdb)}._6d7e4729cd96960e__title{--_gcd-heading-color:var(--wpds-color-foreground-content-neutral,#1e1e1e);color:var(--wpds-color-foreground-content-neutral,#1e1e1e)}.e4d544aa033f05c6__backdrop{background-color:rgba(0,0,0,.15);inset:0;opacity:1;position:fixed;z-index:var(--wp-ui-popover-z-index,initial);&[data-ending-style],&[data-starting-style]{opacity:0}@media not (prefers-reduced-motion){transition:opacity var(--wpds-motion-duration-sm,.1s) var(--wpds-motion-easing-subtle,cubic-bezier(.15,0,.15,1))}}}}'); 16116 } 16117 var style_default25 = { "positioner": "_10450722b9676f78__positioner", "popup": "_84e8f597bcf683b8__popup _380b81b8f79fb10f__dropdown-motion", "surface": "_972134b6cd5808d8__surface", "backdrop": "e4d544aa033f05c6__backdrop", "arrow": "ca05d3eb89321fcd__arrow", "arrow-fill": "_12d8edd9eb946b5f__arrow-fill", "arrow-stroke": "_6ddab482bd929dad__arrow-stroke", "title": "_6d7e4729cd96960e__title" }; 16118 var Positioner2 = (0, import_element53.forwardRef)( 16119 function PopoverPositioner3({ 16120 align = "center", 16121 // Matches the popup's border-radius (--wpds-border-radius-md). 16122 arrowPadding = 8, 16123 className, 16124 side = "bottom", 16125 sideOffset = 8, 16126 ...props 16127 }, ref) { 16128 return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)( 16129 index_parts_exports2.Positioner, 16130 { 16131 ref, 16132 align, 16133 arrowPadding, 16134 side, 16135 sideOffset, 16136 ...props, 16137 className: clsx_default( 16138 resets_default6["box-sizing"], 16139 style_default25.positioner, 16140 className 16141 ) 16142 } 16143 ); 16144 } 16145 ); 16146 16147 // packages/ui/build-module/popover/popup.mjs 16148 var import_jsx_runtime82 = __toESM(require_jsx_runtime(), 1); 16149 var STYLE_HASH_ATTRIBUTE27 = "data-wp-hash"; 16150 function getRuntime27() { 16151 const globalScope = globalThis; 16152 if (globalScope.__wpStyleRuntime) { 16153 return globalScope.__wpStyleRuntime; 16154 } 16155 globalScope.__wpStyleRuntime = { 16156 documents: /* @__PURE__ */ new Map(), 16157 styles: /* @__PURE__ */ new Map(), 16158 injectedStyles: /* @__PURE__ */ new WeakMap() 16159 }; 16160 if (typeof document !== "undefined") { 16161 registerDocument27(document); 16162 } 16163 return globalScope.__wpStyleRuntime; 16164 } 16165 function documentContainsStyleHash27(targetDocument, hash) { 16166 if (!targetDocument.head) { 16167 return false; 16168 } 16169 for (const style of targetDocument.head.querySelectorAll( 16170 `style[$STYLE_HASH_ATTRIBUTE27}]` 16171 )) { 16172 if (style.getAttribute(STYLE_HASH_ATTRIBUTE27) === hash) { 16173 return true; 16174 } 16175 } 16176 return false; 16177 } 16178 function injectStyle27(targetDocument, hash, css) { 16179 if (!targetDocument.head) { 16180 return; 16181 } 16182 const runtime = getRuntime27(); 16183 let injectedStyles = runtime.injectedStyles.get(targetDocument); 16184 if (!injectedStyles) { 16185 injectedStyles = /* @__PURE__ */ new Set(); 16186 runtime.injectedStyles.set(targetDocument, injectedStyles); 16187 } 16188 if (injectedStyles.has(hash)) { 16189 return; 16190 } 16191 if (documentContainsStyleHash27(targetDocument, hash)) { 16192 injectedStyles.add(hash); 16193 return; 16194 } 16195 const style = targetDocument.createElement("style"); 16196 style.setAttribute(STYLE_HASH_ATTRIBUTE27, hash); 16197 style.appendChild(targetDocument.createTextNode(css)); 16198 targetDocument.head.appendChild(style); 16199 injectedStyles.add(hash); 16200 } 16201 function registerDocument27(targetDocument) { 16202 const runtime = getRuntime27(); 16203 runtime.documents.set( 16204 targetDocument, 16205 (runtime.documents.get(targetDocument) ?? 0) + 1 16206 ); 16207 for (const [hash, css] of runtime.styles) { 16208 injectStyle27(targetDocument, hash, css); 16209 } 16210 return () => { 16211 const count = runtime.documents.get(targetDocument); 16212 if (count === void 0) { 16213 return; 16214 } 16215 if (count <= 1) { 16216 runtime.documents.delete(targetDocument); 16217 return; 16218 } 16219 runtime.documents.set(targetDocument, count - 1); 16220 }; 16221 } 16222 function registerStyle27(hash, css) { 16223 const runtime = getRuntime27(); 16224 runtime.styles.set(hash, css); 16225 for (const targetDocument of runtime.documents.keys()) { 16226 injectStyle27(targetDocument, hash, css); 16227 } 16228 } 16229 if (typeof process === "undefined" || true) { 16230 registerStyle27("e53c8c48f6", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._380b81b8f79fb10f__dropdown-motion{--wp-ui-dropdown-slide-distance:4px;--wp-ui-dropdown-slide-duration:var(--wpds-motion-duration-md,200ms);--wp-ui-dropdown-slide-easing:var(--wpds-motion-easing-expressive,cubic-bezier(0.25,0,0,1));--wp-ui-dropdown-fade-duration:var(--wpds-motion-duration-sm,100ms);--wp-ui-dropdown-fade-easing:linear;@media not (prefers-reduced-motion){transition-duration:var(--wp-ui-dropdown-slide-duration),var(--wp-ui-dropdown-fade-duration);transition-property:transform,opacity;transition-timing-function:var(--wp-ui-dropdown-slide-easing),var(--wp-ui-dropdown-fade-easing);will-change:transform,opacity}opacity:1;transform:translate(0);&[data-instant]{transition:none}&[data-ending-style],&[data-starting-style]{opacity:0}&[data-side=bottom][data-ending-style],&[data-side=bottom][data-starting-style]{transform:translateY(calc(var(--wp-ui-dropdown-slide-distance)*-1))}&[data-side=top][data-ending-style],&[data-side=top][data-starting-style]{transform:translateY(var(--wp-ui-dropdown-slide-distance))}&[data-side=left][data-ending-style],&[data-side=left][data-starting-style]{transform:translateX(var(--wp-ui-dropdown-slide-distance))}&[data-side=right][data-ending-style],&[data-side=right][data-starting-style]{transform:translateX(calc(var(--wp-ui-dropdown-slide-distance)*-1))}}}}@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._10450722b9676f78__positioner{z-index:var(--wp-ui-popover-z-index,initial)}._84e8f597bcf683b8__popup{outline:0}._972134b6cd5808d8__surface{--_wp-ui-elevation-md:0 2px 3px rgba(0,0,0,.05),0 4px 5px rgba(0,0,0,.04),0 12px 12px rgba(0,0,0,.03),0 16px 16px rgba(0,0,0,.02);background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral,#dbdbdb);border-radius:var(--wpds-border-radius-md,4px);box-shadow:var(--_wp-ui-elevation-md);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-md,13px);line-height:var(--wpds-typography-line-height-md,24px);padding:var(--wpds-dimension-padding-lg,16px)}.e4d544aa033f05c6__backdrop~* ._972134b6cd5808d8__surface{border-color:transparent}@media (forced-colors:active){._972134b6cd5808d8__surface,.e4d544aa033f05c6__backdrop~* ._972134b6cd5808d8__surface{border-color:CanvasText}}.ca05d3eb89321fcd__arrow{display:flex;&[data-side=top]{bottom:-8px;rotate:180deg}&[data-side=bottom]{rotate:0deg;top:-8px}&[data-side=left]{inset-inline-end:-13px;rotate:90deg}&[data-side=right]{inset-inline-start:-13px;rotate:-90deg}}._12d8edd9eb946b5f__arrow-fill{fill:var(--wpds-color-background-surface-neutral-strong,#fff)}._6ddab482bd929dad__arrow-stroke{fill:var(--wpds-color-stroke-surface-neutral,#dbdbdb)}._6d7e4729cd96960e__title{--_gcd-heading-color:var(--wpds-color-foreground-content-neutral,#1e1e1e);color:var(--wpds-color-foreground-content-neutral,#1e1e1e)}.e4d544aa033f05c6__backdrop{background-color:rgba(0,0,0,.15);inset:0;opacity:1;position:fixed;z-index:var(--wp-ui-popover-z-index,initial);&[data-ending-style],&[data-starting-style]{opacity:0}@media not (prefers-reduced-motion){transition:opacity var(--wpds-motion-duration-sm,.1s) var(--wpds-motion-easing-subtle,cubic-bezier(.15,0,.15,1))}}}}'); 16231 } 16232 var style_default26 = { "positioner": "_10450722b9676f78__positioner", "popup": "_84e8f597bcf683b8__popup _380b81b8f79fb10f__dropdown-motion", "surface": "_972134b6cd5808d8__surface", "backdrop": "e4d544aa033f05c6__backdrop", "arrow": "ca05d3eb89321fcd__arrow", "arrow-fill": "_12d8edd9eb946b5f__arrow-fill", "arrow-stroke": "_6ddab482bd929dad__arrow-stroke", "title": "_6d7e4729cd96960e__title" }; 16233 var CLOSE_ATTR = "data-wp-ui-popover-close"; 16234 var Popup2 = (0, import_element54.forwardRef)(function PopoverPopup3({ 16235 backdrop = false, 16236 children, 16237 className, 16238 portal, 16239 positioner, 16240 finalFocus, 16241 initialFocus, 16242 variant = "default", 16243 ...props 16244 }, ref) { 16245 const { resolvedInitialFocus, popupRef } = useDeprioritizedInitialFocus({ 16246 initialFocus, 16247 deprioritizedAttributes: [CLOSE_ATTR] 16248 }); 16249 const mergedPopupRef = (0, import_compose.useMergeRefs)([ref, popupRef]); 16250 const useDefaultSurface = variant !== "unstyled"; 16251 const validatedChildren = /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(PopoverValidationProvider, { children }); 16252 const popupChildren = useDefaultSurface ? /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("div", { className: style_default26.surface, children: validatedChildren }) : validatedChildren; 16253 const backdropElement = backdrop ? /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(index_parts_exports2.Backdrop, { className: style_default26.backdrop }) : null; 16254 const popupContent = /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)( 16255 index_parts_exports2.Popup, 16256 { 16257 ref: mergedPopupRef, 16258 initialFocus: resolvedInitialFocus, 16259 finalFocus, 16260 className: clsx_default( 16261 useDefaultSurface && style_default26.popup, 16262 className 16263 ), 16264 ...props, 16265 children: popupChildren 16266 } 16267 ) }); 16268 const positionedPopup = renderSlotWithChildren( 16269 positioner, 16270 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(Positioner2, {}), 16271 popupContent 16272 ); 16273 const portalChildren = /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)(import_jsx_runtime82.Fragment, { children: [ 16274 backdropElement, 16275 positionedPopup 16276 ] }); 16277 return renderSlotWithChildren(portal, /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(Portal2, {}), portalChildren); 16278 }); 16279 16280 // packages/ui/build-module/popover/root.mjs 16281 var import_jsx_runtime83 = __toESM(require_jsx_runtime(), 1); 16282 function Root6(props) { 16283 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(index_parts_exports2.Root, { ...props }); 16284 } 16285 16286 // packages/ui/build-module/popover/title.mjs 16287 var import_compose2 = __toESM(require_compose(), 1); 16288 var import_element55 = __toESM(require_element(), 1); 16289 var import_jsx_runtime84 = __toESM(require_jsx_runtime(), 1); 16290 var STYLE_HASH_ATTRIBUTE28 = "data-wp-hash"; 16291 function getRuntime28() { 16292 const globalScope = globalThis; 16293 if (globalScope.__wpStyleRuntime) { 16294 return globalScope.__wpStyleRuntime; 16295 } 16296 globalScope.__wpStyleRuntime = { 16297 documents: /* @__PURE__ */ new Map(), 16298 styles: /* @__PURE__ */ new Map(), 16299 injectedStyles: /* @__PURE__ */ new WeakMap() 16300 }; 16301 if (typeof document !== "undefined") { 16302 registerDocument28(document); 16303 } 16304 return globalScope.__wpStyleRuntime; 16305 } 16306 function documentContainsStyleHash28(targetDocument, hash) { 16307 if (!targetDocument.head) { 16308 return false; 16309 } 16310 for (const style of targetDocument.head.querySelectorAll( 16311 `style[$STYLE_HASH_ATTRIBUTE28}]` 16312 )) { 16313 if (style.getAttribute(STYLE_HASH_ATTRIBUTE28) === hash) { 16314 return true; 16315 } 16316 } 16317 return false; 16318 } 16319 function injectStyle28(targetDocument, hash, css) { 16320 if (!targetDocument.head) { 16321 return; 16322 } 16323 const runtime = getRuntime28(); 16324 let injectedStyles = runtime.injectedStyles.get(targetDocument); 16325 if (!injectedStyles) { 16326 injectedStyles = /* @__PURE__ */ new Set(); 16327 runtime.injectedStyles.set(targetDocument, injectedStyles); 16328 } 16329 if (injectedStyles.has(hash)) { 16330 return; 16331 } 16332 if (documentContainsStyleHash28(targetDocument, hash)) { 16333 injectedStyles.add(hash); 16334 return; 16335 } 16336 const style = targetDocument.createElement("style"); 16337 style.setAttribute(STYLE_HASH_ATTRIBUTE28, hash); 16338 style.appendChild(targetDocument.createTextNode(css)); 16339 targetDocument.head.appendChild(style); 16340 injectedStyles.add(hash); 16341 } 16342 function registerDocument28(targetDocument) { 16343 const runtime = getRuntime28(); 16344 runtime.documents.set( 16345 targetDocument, 16346 (runtime.documents.get(targetDocument) ?? 0) + 1 16347 ); 16348 for (const [hash, css] of runtime.styles) { 16349 injectStyle28(targetDocument, hash, css); 16350 } 16351 return () => { 16352 const count = runtime.documents.get(targetDocument); 16353 if (count === void 0) { 16354 return; 16355 } 16356 if (count <= 1) { 16357 runtime.documents.delete(targetDocument); 16358 return; 16359 } 16360 runtime.documents.set(targetDocument, count - 1); 16361 }; 16362 } 16363 function registerStyle28(hash, css) { 16364 const runtime = getRuntime28(); 16365 runtime.styles.set(hash, css); 16366 for (const targetDocument of runtime.documents.keys()) { 16367 injectStyle28(targetDocument, hash, css); 16368 } 16369 } 16370 if (typeof process === "undefined" || true) { 16371 registerStyle28("e53c8c48f6", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._380b81b8f79fb10f__dropdown-motion{--wp-ui-dropdown-slide-distance:4px;--wp-ui-dropdown-slide-duration:var(--wpds-motion-duration-md,200ms);--wp-ui-dropdown-slide-easing:var(--wpds-motion-easing-expressive,cubic-bezier(0.25,0,0,1));--wp-ui-dropdown-fade-duration:var(--wpds-motion-duration-sm,100ms);--wp-ui-dropdown-fade-easing:linear;@media not (prefers-reduced-motion){transition-duration:var(--wp-ui-dropdown-slide-duration),var(--wp-ui-dropdown-fade-duration);transition-property:transform,opacity;transition-timing-function:var(--wp-ui-dropdown-slide-easing),var(--wp-ui-dropdown-fade-easing);will-change:transform,opacity}opacity:1;transform:translate(0);&[data-instant]{transition:none}&[data-ending-style],&[data-starting-style]{opacity:0}&[data-side=bottom][data-ending-style],&[data-side=bottom][data-starting-style]{transform:translateY(calc(var(--wp-ui-dropdown-slide-distance)*-1))}&[data-side=top][data-ending-style],&[data-side=top][data-starting-style]{transform:translateY(var(--wp-ui-dropdown-slide-distance))}&[data-side=left][data-ending-style],&[data-side=left][data-starting-style]{transform:translateX(var(--wp-ui-dropdown-slide-distance))}&[data-side=right][data-ending-style],&[data-side=right][data-starting-style]{transform:translateX(calc(var(--wp-ui-dropdown-slide-distance)*-1))}}}}@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._10450722b9676f78__positioner{z-index:var(--wp-ui-popover-z-index,initial)}._84e8f597bcf683b8__popup{outline:0}._972134b6cd5808d8__surface{--_wp-ui-elevation-md:0 2px 3px rgba(0,0,0,.05),0 4px 5px rgba(0,0,0,.04),0 12px 12px rgba(0,0,0,.03),0 16px 16px rgba(0,0,0,.02);background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral,#dbdbdb);border-radius:var(--wpds-border-radius-md,4px);box-shadow:var(--_wp-ui-elevation-md);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-md,13px);line-height:var(--wpds-typography-line-height-md,24px);padding:var(--wpds-dimension-padding-lg,16px)}.e4d544aa033f05c6__backdrop~* ._972134b6cd5808d8__surface{border-color:transparent}@media (forced-colors:active){._972134b6cd5808d8__surface,.e4d544aa033f05c6__backdrop~* ._972134b6cd5808d8__surface{border-color:CanvasText}}.ca05d3eb89321fcd__arrow{display:flex;&[data-side=top]{bottom:-8px;rotate:180deg}&[data-side=bottom]{rotate:0deg;top:-8px}&[data-side=left]{inset-inline-end:-13px;rotate:90deg}&[data-side=right]{inset-inline-start:-13px;rotate:-90deg}}._12d8edd9eb946b5f__arrow-fill{fill:var(--wpds-color-background-surface-neutral-strong,#fff)}._6ddab482bd929dad__arrow-stroke{fill:var(--wpds-color-stroke-surface-neutral,#dbdbdb)}._6d7e4729cd96960e__title{--_gcd-heading-color:var(--wpds-color-foreground-content-neutral,#1e1e1e);color:var(--wpds-color-foreground-content-neutral,#1e1e1e)}.e4d544aa033f05c6__backdrop{background-color:rgba(0,0,0,.15);inset:0;opacity:1;position:fixed;z-index:var(--wp-ui-popover-z-index,initial);&[data-ending-style],&[data-starting-style]{opacity:0}@media not (prefers-reduced-motion){transition:opacity var(--wpds-motion-duration-sm,.1s) var(--wpds-motion-easing-subtle,cubic-bezier(.15,0,.15,1))}}}}'); 16372 } 16373 var style_default27 = { "positioner": "_10450722b9676f78__positioner", "popup": "_84e8f597bcf683b8__popup _380b81b8f79fb10f__dropdown-motion", "surface": "_972134b6cd5808d8__surface", "backdrop": "e4d544aa033f05c6__backdrop", "arrow": "ca05d3eb89321fcd__arrow", "arrow-fill": "_12d8edd9eb946b5f__arrow-fill", "arrow-stroke": "_6ddab482bd929dad__arrow-stroke", "title": "_6d7e4729cd96960e__title" }; 16374 var Title3 = (0, import_element55.forwardRef)( 16375 function PopoverTitle3({ children, ...props }, forwardedRef) { 16376 const validationContext = usePopoverValidationContext(); 16377 const internalRef = (0, import_element55.useRef)(null); 16378 const mergedRef = (0, import_compose2.useMergeRefs)([internalRef, forwardedRef]); 16379 (0, import_element55.useEffect)(() => { 16380 if (validationContext) { 16381 return validationContext.registerTitle(internalRef.current); 16382 } 16383 return void 0; 16384 }, [validationContext]); 16385 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)( 16386 Text, 16387 { 16388 ref: mergedRef, 16389 variant: "heading-xl", 16390 render: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(index_parts_exports2.Title, { ...props }), 16391 className: style_default27.title, 16392 children 16393 } 16394 ); 16395 } 16396 ); 16397 16398 // packages/ui/build-module/popover/trigger.mjs 16399 var import_element56 = __toESM(require_element(), 1); 16400 var import_jsx_runtime85 = __toESM(require_jsx_runtime(), 1); 16401 var Trigger3 = (0, import_element56.forwardRef)( 16402 function PopoverTrigger3(props, ref) { 16403 return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(index_parts_exports2.Trigger, { ref, ...props }); 16404 } 16405 ); 16406 16407 // packages/admin-ui/build-module/breadcrumbs/index.mjs 16408 var import_jsx_runtime86 = __toESM(require_jsx_runtime(), 1); 16409 var STYLE_HASH_ATTRIBUTE29 = "data-wp-hash"; 16410 function getRuntime29() { 16411 const globalScope = globalThis; 16412 if (globalScope.__wpStyleRuntime) { 16413 return globalScope.__wpStyleRuntime; 16414 } 16415 globalScope.__wpStyleRuntime = { 16416 documents: /* @__PURE__ */ new Map(), 16417 styles: /* @__PURE__ */ new Map(), 16418 injectedStyles: /* @__PURE__ */ new WeakMap() 16419 }; 16420 if (typeof document !== "undefined") { 16421 registerDocument29(document); 16422 } 16423 return globalScope.__wpStyleRuntime; 16424 } 16425 function documentContainsStyleHash29(targetDocument, hash) { 16426 if (!targetDocument.head) { 16427 return false; 16428 } 16429 for (const style of targetDocument.head.querySelectorAll( 16430 `style[$STYLE_HASH_ATTRIBUTE29}]` 16431 )) { 16432 if (style.getAttribute(STYLE_HASH_ATTRIBUTE29) === hash) { 16433 return true; 16434 } 16435 } 16436 return false; 16437 } 16438 function injectStyle29(targetDocument, hash, css) { 16439 if (!targetDocument.head) { 16440 return; 16441 } 16442 const runtime = getRuntime29(); 16443 let injectedStyles = runtime.injectedStyles.get(targetDocument); 16444 if (!injectedStyles) { 16445 injectedStyles = /* @__PURE__ */ new Set(); 16446 runtime.injectedStyles.set(targetDocument, injectedStyles); 16447 } 16448 if (injectedStyles.has(hash)) { 16449 return; 16450 } 16451 if (documentContainsStyleHash29(targetDocument, hash)) { 16452 injectedStyles.add(hash); 16453 return; 16454 } 16455 const style = targetDocument.createElement("style"); 16456 style.setAttribute(STYLE_HASH_ATTRIBUTE29, hash); 16457 style.appendChild(targetDocument.createTextNode(css)); 16458 targetDocument.head.appendChild(style); 16459 injectedStyles.add(hash); 16460 } 16461 function registerDocument29(targetDocument) { 16462 const runtime = getRuntime29(); 16463 runtime.documents.set( 16464 targetDocument, 16465 (runtime.documents.get(targetDocument) ?? 0) + 1 16466 ); 16467 for (const [hash, css] of runtime.styles) { 16468 injectStyle29(targetDocument, hash, css); 16469 } 16470 return () => { 16471 const count = runtime.documents.get(targetDocument); 16472 if (count === void 0) { 16473 return; 16474 } 16475 if (count <= 1) { 16476 runtime.documents.delete(targetDocument); 16477 return; 16478 } 16479 runtime.documents.set(targetDocument, count - 1); 16480 }; 16481 } 16482 function registerStyle29(hash, css) { 16483 const runtime = getRuntime29(); 16484 runtime.styles.set(hash, css); 16485 for (const targetDocument of runtime.documents.keys()) { 16486 injectStyle29(targetDocument, hash, css); 16487 } 16488 } 16489 if (typeof process === "undefined" || true) { 16490 registerStyle29("846edc217c", "._5f4053eba32ce092__list{list-style:none;margin:0;padding:0}._5f4053eba32ce092__list>li{flex-shrink:0}._5f4053eba32ce092__list>li:last-child{flex-shrink:1;min-width:0}.d1978551971a3360__current{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._6d9152063d443376__separator{color:var(--wpds-color-stroke-surface-neutral,#dbdbdb);margin:0 var(--wpds-dimension-gap-sm,8px);user-select:none}"); 16491 } 16492 var style_default28 = { "list": "_5f4053eba32ce092__list", "current": "d1978551971a3360__current", "separator": "_6d9152063d443376__separator" }; 16493 var Breadcrumbs = ({ items }) => { 16494 if (!items.length) { 16495 return null; 16496 } 16497 const precedingItems = items.slice(0, -1); 16498 const lastItem = items[items.length - 1]; 16499 if (true) { 16500 const invalidItem = precedingItems.find((item) => !item.to); 16501 if (invalidItem) { 16502 throw new Error( 16503 `Breadcrumbs: item "$invalidItem.label}" is missing a \`to\` prop. All items except the last one must have a \`to\` prop.` 16504 ); 16505 } 16506 } 16507 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)("nav", { "aria-label": (0, import_i18n4.__)("Breadcrumbs"), children: /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)( 16508 Stack, 16509 { 16510 render: /* @__PURE__ */ (0, import_jsx_runtime86.jsx)("ul", {}), 16511 direction: "row", 16512 align: "center", 16513 className: style_default28.list, 16514 children: [ 16515 precedingItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)("li", { children: [ 16516 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)( 16517 Text, 16518 { 16519 variant: "body-lg", 16520 render: /* @__PURE__ */ (0, import_jsx_runtime86.jsx)( 16521 Link, 16522 { 16523 tone: "neutral", 16524 render: /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(RouterLink, { to: item.to }) 16525 } 16526 ), 16527 children: item.label 16528 } 16529 ), 16530 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)( 16531 Text, 16532 { 16533 variant: "body-lg", 16534 "aria-hidden": "true", 16535 className: style_default28.separator, 16536 children: "/" 16537 } 16538 ) 16539 ] }, index2)), 16540 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)("li", { children: lastItem.to ? /* @__PURE__ */ (0, import_jsx_runtime86.jsx)( 16541 Text, 16542 { 16543 variant: "body-lg", 16544 render: /* @__PURE__ */ (0, import_jsx_runtime86.jsx)( 16545 Link, 16546 { 16547 tone: "neutral", 16548 render: /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(RouterLink, { to: lastItem.to }) 16549 } 16550 ), 16551 children: lastItem.label 16552 } 16553 ) : /* @__PURE__ */ (0, import_jsx_runtime86.jsx)( 16554 Text, 16555 { 16556 variant: "heading-lg", 16557 render: /* @__PURE__ */ (0, import_jsx_runtime86.jsx)("h1", {}), 16558 className: style_default28.current, 16559 children: lastItem.label 16560 } 16561 ) }) 16562 ] 16563 } 16564 ) }); 16565 }; 16566 var breadcrumbs_default = Breadcrumbs; 16567 16568 // packages/admin-ui/build-module/navigable-region/index.mjs 16569 var import_element57 = __toESM(require_element(), 1); 16570 var import_jsx_runtime87 = __toESM(require_jsx_runtime(), 1); 16571 var NavigableRegion = (0, import_element57.forwardRef)( 16572 ({ children, className, ariaLabel, as: Tag = "div", ...props }, ref) => { 16573 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)( 16574 Tag, 16575 { 16576 ref, 16577 className: clsx_default("admin-ui-navigable-region", className), 16578 "aria-label": ariaLabel, 16579 role: "region", 16580 tabIndex: "-1", 16581 ...props, 16582 children 16583 } 16584 ); 16585 } 16586 ); 16587 NavigableRegion.displayName = "NavigableRegion"; 16588 var navigable_region_default = NavigableRegion; 16589 16590 // packages/admin-ui/build-module/page/sidebar-toggle-slot.mjs 16591 var import_components = __toESM(require_components(), 1); 16592 var { Fill: SidebarToggleFill, Slot: SidebarToggleSlot } = (0, import_components.createSlotFill)("SidebarToggle"); 16593 16594 // packages/admin-ui/build-module/page/header.mjs 16595 var import_jsx_runtime88 = __toESM(require_jsx_runtime(), 1); 16596 var STYLE_HASH_ATTRIBUTE30 = "data-wp-hash"; 16597 function getRuntime30() { 16598 const globalScope = globalThis; 16599 if (globalScope.__wpStyleRuntime) { 16600 return globalScope.__wpStyleRuntime; 16601 } 16602 globalScope.__wpStyleRuntime = { 16603 documents: /* @__PURE__ */ new Map(), 16604 styles: /* @__PURE__ */ new Map(), 16605 injectedStyles: /* @__PURE__ */ new WeakMap() 16606 }; 16607 if (typeof document !== "undefined") { 16608 registerDocument30(document); 16609 } 16610 return globalScope.__wpStyleRuntime; 16611 } 16612 function documentContainsStyleHash30(targetDocument, hash) { 16613 if (!targetDocument.head) { 16614 return false; 16615 } 16616 for (const style of targetDocument.head.querySelectorAll( 16617 `style[$STYLE_HASH_ATTRIBUTE30}]` 16618 )) { 16619 if (style.getAttribute(STYLE_HASH_ATTRIBUTE30) === hash) { 16620 return true; 16621 } 16622 } 16623 return false; 16624 } 16625 function injectStyle30(targetDocument, hash, css) { 16626 if (!targetDocument.head) { 16627 return; 16628 } 16629 const runtime = getRuntime30(); 16630 let injectedStyles = runtime.injectedStyles.get(targetDocument); 16631 if (!injectedStyles) { 16632 injectedStyles = /* @__PURE__ */ new Set(); 16633 runtime.injectedStyles.set(targetDocument, injectedStyles); 16634 } 16635 if (injectedStyles.has(hash)) { 16636 return; 16637 } 16638 if (documentContainsStyleHash30(targetDocument, hash)) { 16639 injectedStyles.add(hash); 16640 return; 16641 } 16642 const style = targetDocument.createElement("style"); 16643 style.setAttribute(STYLE_HASH_ATTRIBUTE30, hash); 16644 style.appendChild(targetDocument.createTextNode(css)); 16645 targetDocument.head.appendChild(style); 16646 injectedStyles.add(hash); 16647 } 16648 function registerDocument30(targetDocument) { 16649 const runtime = getRuntime30(); 16650 runtime.documents.set( 16651 targetDocument, 16652 (runtime.documents.get(targetDocument) ?? 0) + 1 16653 ); 16654 for (const [hash, css] of runtime.styles) { 16655 injectStyle30(targetDocument, hash, css); 16656 } 16657 return () => { 16658 const count = runtime.documents.get(targetDocument); 16659 if (count === void 0) { 16660 return; 16661 } 16662 if (count <= 1) { 16663 runtime.documents.delete(targetDocument); 16664 return; 16665 } 16666 runtime.documents.set(targetDocument, count - 1); 16667 }; 16668 } 16669 function registerStyle30(hash, css) { 16670 const runtime = getRuntime30(); 16671 runtime.styles.set(hash, css); 16672 for (const targetDocument of runtime.documents.keys()) { 16673 injectStyle30(targetDocument, hash, css); 16674 } 16675 } 16676 if (typeof process === "undefined" || true) { 16677 registerStyle30("ddd9aab364", "._956b6df0898efed0__page{text-wrap:pretty;background-color:var(--wpds-color-background-surface-neutral,#fcfcfc);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:flex;flex-flow:column;height:100%;position:relative;z-index:1}._0625b55e82a0d93d__header{background:var(--wpds-color-background-surface-neutral-strong,#fff);border-block-end:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);inset-block-start:0;padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px);position:sticky;z-index:1}.a43c44d5ae28b2e8__header-content{min-height:var(--wpds-dimension-size-md,32px)}.b7cb5b9daf3a3b25__header-actions{flex-shrink:0}._8113be94e7caf73c__header-title{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._9a776c7f70996f61__header-visual{display:grid;flex-shrink:0;grid-template-columns:1fr;grid-template-rows:1fr;height:var(--wpds-dimension-size-sm,24px);width:var(--wpds-dimension-size-sm,24px);>*{grid-column:1/-1;grid-row:1/-1;max-height:100%;max-width:100%}}.d5e0920cd15d35bc__sidebar-toggle-slot:empty{display:none}._60fea2f6bf5319cd__header-subtitle{color:var(--wpds-color-foreground-content-neutral-weak,#707070);padding-block-end:var(--wpds-dimension-padding-xs,4px)}.be5e57d029ec4036__content{display:flex;flex-direction:column;flex-grow:1;overflow:auto;&._128806d0b26e3a50__has-padding{padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px)}}"); 16678 } 16679 var style_default29 = { "page": "_956b6df0898efed0__page", "header": "_0625b55e82a0d93d__header", "header-content": "a43c44d5ae28b2e8__header-content", "header-actions": "b7cb5b9daf3a3b25__header-actions", "header-title": "_8113be94e7caf73c__header-title", "header-visual": "_9a776c7f70996f61__header-visual", "sidebar-toggle-slot": "d5e0920cd15d35bc__sidebar-toggle-slot", "header-subtitle": "_60fea2f6bf5319cd__header-subtitle", "content": "be5e57d029ec4036__content", "has-padding": "_128806d0b26e3a50__has-padding" }; 16680 function Header3({ 16681 headingLevel = 1, 16682 breadcrumbs, 16683 badges, 16684 visual, 16685 title, 16686 subTitle, 16687 actions, 16688 showSidebarToggle = true 16689 }) { 16690 const HeadingTag = `h$headingLevel}`; 16691 return /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(Stack, { direction: "column", className: style_default29.header, children: [ 16692 /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)( 16693 Stack, 16694 { 16695 className: style_default29["header-content"], 16696 direction: "row", 16697 gap: "sm", 16698 justify: "space-between", 16699 children: [ 16700 /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(Stack, { direction: "row", gap: "sm", align: "center", justify: "start", children: [ 16701 showSidebarToggle && /* @__PURE__ */ (0, import_jsx_runtime88.jsx)( 16702 SidebarToggleSlot, 16703 { 16704 bubblesVirtually: true, 16705 className: style_default29["sidebar-toggle-slot"] 16706 } 16707 ), 16708 visual && /* @__PURE__ */ (0, import_jsx_runtime88.jsx)( 16709 "div", 16710 { 16711 className: style_default29["header-visual"], 16712 "aria-hidden": "true", 16713 children: visual 16714 } 16715 ), 16716 title && /* @__PURE__ */ (0, import_jsx_runtime88.jsx)( 16717 Text, 16718 { 16719 className: style_default29["header-title"], 16720 render: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(HeadingTag, {}), 16721 variant: "heading-lg", 16722 children: title 16723 } 16724 ), 16725 breadcrumbs, 16726 badges 16727 ] }), 16728 actions && /* @__PURE__ */ (0, import_jsx_runtime88.jsx)( 16729 Stack, 16730 { 16731 align: "center", 16732 className: style_default29["header-actions"], 16733 direction: "row", 16734 gap: "sm", 16735 children: actions 16736 } 16737 ) 16738 ] 16739 } 16740 ), 16741 subTitle && /* @__PURE__ */ (0, import_jsx_runtime88.jsx)( 16742 Text, 16743 { 16744 render: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("p", {}), 16745 variant: "body-md", 16746 className: style_default29["header-subtitle"], 16747 children: subTitle 16748 } 16749 ) 16750 ] }); 16751 } 16752 16753 // packages/admin-ui/build-module/page/index.mjs 16754 var import_jsx_runtime89 = __toESM(require_jsx_runtime(), 1); 16755 var STYLE_HASH_ATTRIBUTE31 = "data-wp-hash"; 16756 function getRuntime31() { 16757 const globalScope = globalThis; 16758 if (globalScope.__wpStyleRuntime) { 16759 return globalScope.__wpStyleRuntime; 16760 } 16761 globalScope.__wpStyleRuntime = { 16762 documents: /* @__PURE__ */ new Map(), 16763 styles: /* @__PURE__ */ new Map(), 16764 injectedStyles: /* @__PURE__ */ new WeakMap() 16765 }; 16766 if (typeof document !== "undefined") { 16767 registerDocument31(document); 16768 } 16769 return globalScope.__wpStyleRuntime; 16770 } 16771 function documentContainsStyleHash31(targetDocument, hash) { 16772 if (!targetDocument.head) { 16773 return false; 16774 } 16775 for (const style of targetDocument.head.querySelectorAll( 16776 `style[$STYLE_HASH_ATTRIBUTE31}]` 16777 )) { 16778 if (style.getAttribute(STYLE_HASH_ATTRIBUTE31) === hash) { 16779 return true; 16780 } 16781 } 16782 return false; 16783 } 16784 function injectStyle31(targetDocument, hash, css) { 16785 if (!targetDocument.head) { 16786 return; 16787 } 16788 const runtime = getRuntime31(); 16789 let injectedStyles = runtime.injectedStyles.get(targetDocument); 16790 if (!injectedStyles) { 16791 injectedStyles = /* @__PURE__ */ new Set(); 16792 runtime.injectedStyles.set(targetDocument, injectedStyles); 16793 } 16794 if (injectedStyles.has(hash)) { 16795 return; 16796 } 16797 if (documentContainsStyleHash31(targetDocument, hash)) { 16798 injectedStyles.add(hash); 16799 return; 16800 } 16801 const style = targetDocument.createElement("style"); 16802 style.setAttribute(STYLE_HASH_ATTRIBUTE31, hash); 16803 style.appendChild(targetDocument.createTextNode(css)); 16804 targetDocument.head.appendChild(style); 16805 injectedStyles.add(hash); 16806 } 16807 function registerDocument31(targetDocument) { 16808 const runtime = getRuntime31(); 16809 runtime.documents.set( 16810 targetDocument, 16811 (runtime.documents.get(targetDocument) ?? 0) + 1 16812 ); 16813 for (const [hash, css] of runtime.styles) { 16814 injectStyle31(targetDocument, hash, css); 16815 } 16816 return () => { 16817 const count = runtime.documents.get(targetDocument); 16818 if (count === void 0) { 16819 return; 16820 } 16821 if (count <= 1) { 16822 runtime.documents.delete(targetDocument); 16823 return; 16824 } 16825 runtime.documents.set(targetDocument, count - 1); 16826 }; 16827 } 16828 function registerStyle31(hash, css) { 16829 const runtime = getRuntime31(); 16830 runtime.styles.set(hash, css); 16831 for (const targetDocument of runtime.documents.keys()) { 16832 injectStyle31(targetDocument, hash, css); 16833 } 16834 } 16835 if (typeof process === "undefined" || true) { 16836 registerStyle31("ddd9aab364", "._956b6df0898efed0__page{text-wrap:pretty;background-color:var(--wpds-color-background-surface-neutral,#fcfcfc);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:flex;flex-flow:column;height:100%;position:relative;z-index:1}._0625b55e82a0d93d__header{background:var(--wpds-color-background-surface-neutral-strong,#fff);border-block-end:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);inset-block-start:0;padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px);position:sticky;z-index:1}.a43c44d5ae28b2e8__header-content{min-height:var(--wpds-dimension-size-md,32px)}.b7cb5b9daf3a3b25__header-actions{flex-shrink:0}._8113be94e7caf73c__header-title{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._9a776c7f70996f61__header-visual{display:grid;flex-shrink:0;grid-template-columns:1fr;grid-template-rows:1fr;height:var(--wpds-dimension-size-sm,24px);width:var(--wpds-dimension-size-sm,24px);>*{grid-column:1/-1;grid-row:1/-1;max-height:100%;max-width:100%}}.d5e0920cd15d35bc__sidebar-toggle-slot:empty{display:none}._60fea2f6bf5319cd__header-subtitle{color:var(--wpds-color-foreground-content-neutral-weak,#707070);padding-block-end:var(--wpds-dimension-padding-xs,4px)}.be5e57d029ec4036__content{display:flex;flex-direction:column;flex-grow:1;overflow:auto;&._128806d0b26e3a50__has-padding{padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px)}}"); 16837 } 16838 var style_default30 = { "page": "_956b6df0898efed0__page", "header": "_0625b55e82a0d93d__header", "header-content": "a43c44d5ae28b2e8__header-content", "header-actions": "b7cb5b9daf3a3b25__header-actions", "header-title": "_8113be94e7caf73c__header-title", "header-visual": "_9a776c7f70996f61__header-visual", "sidebar-toggle-slot": "d5e0920cd15d35bc__sidebar-toggle-slot", "header-subtitle": "_60fea2f6bf5319cd__header-subtitle", "content": "be5e57d029ec4036__content", "has-padding": "_128806d0b26e3a50__has-padding" }; 16839 function Page({ 16840 headingLevel, 16841 breadcrumbs, 16842 badges, 16843 visual, 16844 title, 16845 subTitle, 16846 children, 16847 className, 16848 actions, 16849 ariaLabel, 16850 hasPadding = false, 16851 showSidebarToggle = true 16852 }) { 16853 const classes = clsx_default(style_default30.page, className); 16854 const effectiveAriaLabel = ariaLabel ?? (typeof title === "string" ? title : ""); 16855 return /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(navigable_region_default, { className: classes, ariaLabel: effectiveAriaLabel, children: [ 16856 (title || breadcrumbs || badges || actions || visual) && /* @__PURE__ */ (0, import_jsx_runtime89.jsx)( 16857 Header3, 16858 { 16859 headingLevel, 16860 breadcrumbs, 16861 badges, 16862 visual, 16863 title, 16864 subTitle, 16865 actions, 16866 showSidebarToggle 16867 } 16868 ), 16869 hasPadding ? /* @__PURE__ */ (0, import_jsx_runtime89.jsx)( 16870 "div", 16871 { 16872 className: clsx_default( 16873 style_default30.content, 16874 style_default30["has-padding"] 16875 ), 16876 children 16877 } 16878 ) : children 16879 ] }); 16880 } 16881 Page.SidebarToggleFill = SidebarToggleFill; 16882 var page_default = Page; 16883 16884 // packages/content-types/build-module/components/layout/index.mjs 16885 var import_components2 = __toESM(require_components(), 1); 16886 var import_i18n5 = __toESM(require_i18n(), 1); 16887 import { useNavigate } from "@wordpress/route"; 16888 16889 // packages/content-types/build-module/lock-unlock.mjs 16890 var import_private_apis2 = __toESM(require_private_apis(), 1); 16891 var { lock: lock2, unlock: unlock2 } = (0, import_private_apis2.__dangerousOptInToUnstableAPIsOnlyForCoreModules)( 16892 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.", 16893 "@wordpress/content-types" 16894 ); 16895 16896 // packages/content-types/build-module/components/layout/index.mjs 16897 var import_jsx_runtime90 = __toESM(require_jsx_runtime(), 1); 16898 var { Tabs } = unlock2(import_components2.privateApis); 16899 function Layout({ activeTab, children }) { 16900 const navigate = useNavigate(); 16901 return /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)( 16902 page_default, 16903 { 16904 ariaLabel: (0, import_i18n5.__)("Content Types"), 16905 className: "content-types-page", 16906 children: [ 16907 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)( 16908 Tabs, 16909 { 16910 selectedTabId: activeTab, 16911 onSelect: (tabId) => navigate({ to: `/$tabId}` }), 16912 children: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("div", { className: "content-types-tabs-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(Tabs.TabList, { children: [ 16913 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(Tabs.Tab, { tabId: "post-types", children: (0, import_i18n5.__)("Post Types") }), 16914 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(Tabs.Tab, { tabId: "taxonomies", children: (0, import_i18n5.__)("Taxonomies") }) 16915 ] }) }) 16916 } 16917 ), 16918 children 16919 ] 16920 } 16921 ); 16922 } 16923 16924 // packages/content-types/build-module/post-types/list.mjs 16925 var import_components60 = __toESM(require_components(), 1); 16926 16927 // packages/dataviews/build-module/dataviews/index.mjs 16928 var import_element117 = __toESM(require_element(), 1); 16929 var import_compose16 = __toESM(require_compose(), 1); 16930 16931 // packages/dataviews/build-module/components/dataviews-context/index.mjs 16932 var import_element58 = __toESM(require_element(), 1); 16933 16934 // packages/dataviews/build-module/constants.mjs 16935 var import_i18n6 = __toESM(require_i18n(), 1); 16936 var OPERATOR_IS_ANY = "isAny"; 16937 var OPERATOR_IS_NONE = "isNone"; 16938 var OPERATOR_IS_ALL = "isAll"; 16939 var OPERATOR_IS_NOT_ALL = "isNotAll"; 16940 var OPERATOR_BETWEEN = "between"; 16941 var OPERATOR_IN_THE_PAST = "inThePast"; 16942 var OPERATOR_OVER = "over"; 16943 var OPERATOR_IS = "is"; 16944 var OPERATOR_IS_NOT = "isNot"; 16945 var OPERATOR_LESS_THAN = "lessThan"; 16946 var OPERATOR_GREATER_THAN = "greaterThan"; 16947 var OPERATOR_LESS_THAN_OR_EQUAL = "lessThanOrEqual"; 16948 var OPERATOR_GREATER_THAN_OR_EQUAL = "greaterThanOrEqual"; 16949 var OPERATOR_BEFORE = "before"; 16950 var OPERATOR_AFTER = "after"; 16951 var OPERATOR_BEFORE_INC = "beforeInc"; 16952 var OPERATOR_AFTER_INC = "afterInc"; 16953 var OPERATOR_CONTAINS = "contains"; 16954 var OPERATOR_NOT_CONTAINS = "notContains"; 16955 var OPERATOR_STARTS_WITH = "startsWith"; 16956 var OPERATOR_ON = "on"; 16957 var OPERATOR_NOT_ON = "notOn"; 16958 var SORTING_DIRECTIONS = ["asc", "desc"]; 16959 var sortArrows = { asc: "↑", desc: "↓" }; 16960 var sortValues = { asc: "ascending", desc: "descending" }; 16961 var sortLabels = { 16962 asc: (0, import_i18n6.__)("Sort ascending"), 16963 desc: (0, import_i18n6.__)("Sort descending") 16964 }; 16965 var sortIcons = { 16966 asc: arrow_up_default, 16967 desc: arrow_down_default 16968 }; 16969 var LAYOUT_TABLE = "table"; 16970 var LAYOUT_GRID = "grid"; 16971 var LAYOUT_LIST = "list"; 16972 var LAYOUT_ACTIVITY = "activity"; 16973 var LAYOUT_PICKER_GRID = "pickerGrid"; 16974 var LAYOUT_PICKER_TABLE = "pickerTable"; 16975 var LAYOUT_PICKER_ACTIVITY = "pickerActivity"; 16976 16977 // packages/dataviews/build-module/components/dataviews-context/index.mjs 16978 var DataViewsContext = (0, import_element58.createContext)({ 16979 view: { type: LAYOUT_TABLE }, 16980 onChangeView: () => { 16981 }, 16982 fields: [], 16983 data: [], 16984 paginationInfo: { 16985 totalItems: 0, 16986 totalPages: 0 16987 }, 16988 selection: [], 16989 onChangeSelection: () => { 16990 }, 16991 setOpenedFilter: () => { 16992 }, 16993 openedFilter: null, 16994 getItemId: (item) => item.id, 16995 isItemClickable: () => true, 16996 renderItemLink: void 0, 16997 containerWidth: 0, 16998 containerRef: (0, import_element58.createRef)(), 16999 resizeObserverRef: () => { 17000 }, 17001 defaultLayouts: { list: {}, grid: {}, table: {} }, 17002 filters: [], 17003 isShowingFilter: false, 17004 setIsShowingFilter: () => { 17005 }, 17006 hasInitiallyLoaded: false, 17007 config: { 17008 perPageSizes: [] 17009 }, 17010 intersectionObserver: null 17011 }); 17012 DataViewsContext.displayName = "DataViewsContext"; 17013 var dataviews_context_default = DataViewsContext; 17014 17015 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs 17016 var import_i18n27 = __toESM(require_i18n(), 1); 17017 17018 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs 17019 var import_i18n14 = __toESM(require_i18n(), 1); 17020 var import_components8 = __toESM(require_components(), 1); 17021 var import_element67 = __toESM(require_element(), 1); 17022 var import_keycodes2 = __toESM(require_keycodes(), 1); 17023 17024 // packages/dataviews/build-module/components/dataviews-selection-checkbox/index.mjs 17025 var import_components3 = __toESM(require_components(), 1); 17026 var import_i18n7 = __toESM(require_i18n(), 1); 17027 var import_jsx_runtime91 = __toESM(require_jsx_runtime(), 1); 17028 var SELECTION_CHECKBOX_CLASS = "dataviews-selection-checkbox"; 17029 function DataViewsSelectionCheckbox({ 17030 selection, 17031 onChangeSelection, 17032 item, 17033 getItemId, 17034 titleField: titleField2, 17035 disabled: disabled2, 17036 ...extraProps 17037 }) { 17038 const id = getItemId(item); 17039 const isInSelectionArray = selection.includes(id); 17040 const checked = !disabled2 && isInSelectionArray; 17041 const selectionLabel = titleField2?.getValue?.({ item }) || (0, import_i18n7.__)("(no title)"); 17042 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)( 17043 import_components3.CheckboxControl, 17044 { 17045 className: SELECTION_CHECKBOX_CLASS, 17046 "aria-label": selectionLabel, 17047 "aria-disabled": disabled2, 17048 checked, 17049 onChange: () => { 17050 if (disabled2) { 17051 return; 17052 } 17053 onChangeSelection( 17054 isInSelectionArray ? selection.filter((itemId) => id !== itemId) : [...selection, id] 17055 ); 17056 }, 17057 ...extraProps 17058 } 17059 ); 17060 } 17061 17062 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs 17063 var import_components4 = __toESM(require_components(), 1); 17064 var import_i18n8 = __toESM(require_i18n(), 1); 17065 var import_element59 = __toESM(require_element(), 1); 17066 var import_data = __toESM(require_data(), 1); 17067 var import_compose3 = __toESM(require_compose(), 1); 17068 17069 // packages/dataviews/build-module/lock-unlock.mjs 17070 var import_private_apis3 = __toESM(require_private_apis(), 1); 17071 var { lock: lock3, unlock: unlock3 } = (0, import_private_apis3.__dangerousOptInToUnstableAPIsOnlyForCoreModules)( 17072 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.", 17073 "@wordpress/dataviews" 17074 ); 17075 17076 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs 17077 var import_jsx_runtime92 = __toESM(require_jsx_runtime(), 1); 17078 var { Menu, kebabCase } = unlock3(import_components4.privateApis); 17079 function ButtonTrigger({ 17080 action, 17081 onClick, 17082 items, 17083 variant 17084 }) { 17085 const label = typeof action.label === "string" ? action.label : action.label(items); 17086 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)( 17087 import_components4.Button, 17088 { 17089 disabled: !!action.disabled, 17090 accessibleWhenDisabled: true, 17091 size: "compact", 17092 variant, 17093 onClick, 17094 children: label 17095 } 17096 ); 17097 } 17098 function MenuItemTrigger({ 17099 action, 17100 onClick, 17101 items 17102 }) { 17103 const label = typeof action.label === "string" ? action.label : action.label(items); 17104 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(Menu.Item, { disabled: action.disabled, onClick, children: /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(Menu.ItemLabel, { children: label }) }); 17105 } 17106 function ActionModal({ 17107 action, 17108 items, 17109 closeModal 17110 }) { 17111 const label = typeof action.label === "string" ? action.label : action.label(items); 17112 const modalHeader = typeof action.modalHeader === "function" ? action.modalHeader(items) : action.modalHeader; 17113 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)( 17114 import_components4.Modal, 17115 { 17116 title: modalHeader || label, 17117 __experimentalHideHeader: !!action.hideModalHeader, 17118 onRequestClose: closeModal, 17119 focusOnMount: action.modalFocusOnMount ?? true, 17120 size: action.modalSize || "medium", 17121 overlayClassName: `dataviews-action-modal dataviews-action-modal__$kebabCase( 17122 action.id 17123 )}`, 17124 children: /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(action.RenderModal, { items, closeModal }) 17125 } 17126 ); 17127 } 17128 function ActionsMenuGroup({ 17129 actions, 17130 item, 17131 registry, 17132 setActiveModalAction 17133 }) { 17134 const { primaryActions, regularActions } = (0, import_element59.useMemo)(() => { 17135 return actions.reduce( 17136 (acc, action) => { 17137 (action.isPrimary ? acc.primaryActions : acc.regularActions).push(action); 17138 return acc; 17139 }, 17140 { 17141 primaryActions: [], 17142 regularActions: [] 17143 } 17144 ); 17145 }, [actions]); 17146 const renderActionGroup = (actionList) => actionList.map((action) => /* @__PURE__ */ (0, import_jsx_runtime92.jsx)( 17147 MenuItemTrigger, 17148 { 17149 action, 17150 onClick: () => { 17151 if ("RenderModal" in action) { 17152 setActiveModalAction(action); 17153 return; 17154 } 17155 action.callback([item], { registry }); 17156 }, 17157 items: [item] 17158 }, 17159 action.id 17160 )); 17161 return /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)(Menu.Group, { children: [ 17162 renderActionGroup(primaryActions), 17163 renderActionGroup(regularActions) 17164 ] }); 17165 } 17166 function ItemActions({ 17167 item, 17168 actions, 17169 isCompact 17170 }) { 17171 const registry = (0, import_data.useRegistry)(); 17172 const { primaryActions, eligibleActions } = (0, import_element59.useMemo)(() => { 17173 const _eligibleActions = actions.filter( 17174 (action) => !action.isEligible || action.isEligible(item) 17175 ); 17176 const _primaryActions = _eligibleActions.filter( 17177 (action) => action.isPrimary 17178 ); 17179 return { 17180 primaryActions: _primaryActions, 17181 eligibleActions: _eligibleActions 17182 }; 17183 }, [actions, item]); 17184 const isMobileViewport = (0, import_compose3.useViewportMatch)("medium", "<"); 17185 if (isCompact) { 17186 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)( 17187 CompactItemActions, 17188 { 17189 item, 17190 actions: eligibleActions, 17191 isSmall: true, 17192 registry 17193 } 17194 ); 17195 } 17196 return /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)( 17197 Stack, 17198 { 17199 direction: "row", 17200 justify: "flex-end", 17201 className: "dataviews-item-actions", 17202 style: { 17203 flexShrink: 0, 17204 width: "auto" 17205 }, 17206 children: [ 17207 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)( 17208 PrimaryActions, 17209 { 17210 item, 17211 actions: primaryActions, 17212 registry 17213 } 17214 ), 17215 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu 17216 // there if there are any actions at all. 17217 isMobileViewport) && /* @__PURE__ */ (0, import_jsx_runtime92.jsx)( 17218 CompactItemActions, 17219 { 17220 item, 17221 actions: eligibleActions, 17222 registry 17223 } 17224 ) 17225 ] 17226 } 17227 ); 17228 } 17229 function CompactItemActions({ 17230 item, 17231 actions, 17232 isSmall, 17233 registry 17234 }) { 17235 const [activeModalAction, setActiveModalAction] = (0, import_element59.useState)( 17236 null 17237 ); 17238 return /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)(import_jsx_runtime92.Fragment, { children: [ 17239 /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)(Menu, { placement: "bottom-end", children: [ 17240 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)( 17241 Menu.TriggerButton, 17242 { 17243 render: /* @__PURE__ */ (0, import_jsx_runtime92.jsx)( 17244 import_components4.Button, 17245 { 17246 size: isSmall ? "small" : "compact", 17247 icon: more_vertical_default, 17248 label: (0, import_i18n8.__)("Actions"), 17249 accessibleWhenDisabled: true, 17250 disabled: !actions.length, 17251 className: "dataviews-all-actions-button" 17252 } 17253 ) 17254 } 17255 ), 17256 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(Menu.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime92.jsx)( 17257 ActionsMenuGroup, 17258 { 17259 actions, 17260 item, 17261 registry, 17262 setActiveModalAction 17263 } 17264 ) }) 17265 ] }), 17266 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime92.jsx)( 17267 ActionModal, 17268 { 17269 action: activeModalAction, 17270 items: [item], 17271 closeModal: () => setActiveModalAction(null) 17272 } 17273 ) 17274 ] }); 17275 } 17276 function PrimaryActions({ 17277 item, 17278 actions, 17279 registry, 17280 buttonVariant 17281 }) { 17282 const [activeModalAction, setActiveModalAction] = (0, import_element59.useState)(null); 17283 const isMobileViewport = (0, import_compose3.useViewportMatch)("medium", "<"); 17284 if (isMobileViewport) { 17285 return null; 17286 } 17287 if (!Array.isArray(actions) || actions.length === 0) { 17288 return null; 17289 } 17290 return /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)(import_jsx_runtime92.Fragment, { children: [ 17291 actions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime92.jsx)( 17292 ButtonTrigger, 17293 { 17294 action, 17295 onClick: () => { 17296 if ("RenderModal" in action) { 17297 setActiveModalAction(action); 17298 return; 17299 } 17300 action.callback([item], { registry }); 17301 }, 17302 items: [item], 17303 variant: buttonVariant 17304 }, 17305 action.id 17306 )), 17307 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime92.jsx)( 17308 ActionModal, 17309 { 17310 action: activeModalAction, 17311 items: [item], 17312 closeModal: () => setActiveModalAction(null) 17313 } 17314 ) 17315 ] }); 17316 } 17317 17318 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs 17319 var import_components5 = __toESM(require_components(), 1); 17320 var import_i18n10 = __toESM(require_i18n(), 1); 17321 var import_element60 = __toESM(require_element(), 1); 17322 var import_data2 = __toESM(require_data(), 1); 17323 var import_compose4 = __toESM(require_compose(), 1); 17324 17325 // packages/dataviews/build-module/utils/get-footer-message.mjs 17326 var import_i18n9 = __toESM(require_i18n(), 1); 17327 function getFooterMessage(selectionCount, itemsCount, totalItems, onlyTotalCount = false) { 17328 if (selectionCount > 0) { 17329 return (0, import_i18n9.sprintf)( 17330 /* translators: %d: number of items. */ 17331 (0, import_i18n9._n)("%d Item selected", "%d Items selected", selectionCount), 17332 selectionCount 17333 ); 17334 } 17335 if (onlyTotalCount || totalItems <= itemsCount) { 17336 return (0, import_i18n9.sprintf)( 17337 /* translators: %d: number of items. */ 17338 (0, import_i18n9._n)("%d Item", "%d Items", totalItems), 17339 totalItems 17340 ); 17341 } 17342 return (0, import_i18n9.sprintf)( 17343 /* translators: %1$d: number of items. %2$d: total number of items. */ 17344 (0, import_i18n9._n)("%1$d of %2$d Item", "%1$d of %2$d Items", totalItems), 17345 itemsCount, 17346 totalItems 17347 ); 17348 } 17349 17350 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs 17351 var import_jsx_runtime93 = __toESM(require_jsx_runtime(), 1); 17352 function ActionWithModal({ 17353 action, 17354 items, 17355 ActionTriggerComponent 17356 }) { 17357 const [isModalOpen, setIsModalOpen] = (0, import_element60.useState)(false); 17358 const actionTriggerProps = { 17359 action, 17360 onClick: () => { 17361 setIsModalOpen(true); 17362 }, 17363 items 17364 }; 17365 return /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(import_jsx_runtime93.Fragment, { children: [ 17366 /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(ActionTriggerComponent, { ...actionTriggerProps }), 17367 isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime93.jsx)( 17368 ActionModal, 17369 { 17370 action, 17371 items, 17372 closeModal: () => setIsModalOpen(false) 17373 } 17374 ) 17375 ] }); 17376 } 17377 function hasAPossibleBulkAction(actions, item) { 17378 return actions.some( 17379 (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item)) 17380 ); 17381 } 17382 function useHasAPossibleBulkAction(actions, item) { 17383 return (0, import_element60.useMemo)( 17384 () => hasAPossibleBulkAction(actions, item), 17385 [actions, item] 17386 ); 17387 } 17388 function useSomeItemHasAPossibleBulkAction(actions, data) { 17389 return (0, import_element60.useMemo)( 17390 () => data.some((item) => hasAPossibleBulkAction(actions, item)), 17391 [actions, data] 17392 ); 17393 } 17394 function BulkSelectionCheckbox({ 17395 selection, 17396 onChangeSelection, 17397 data, 17398 actions, 17399 getItemId, 17400 disableSelectAll = false 17401 }) { 17402 const selectableItems = (0, import_element60.useMemo)(() => { 17403 return data.filter((item) => { 17404 return actions.some( 17405 (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item)) 17406 ); 17407 }); 17408 }, [data, actions]); 17409 const selectedItems = data.filter( 17410 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item) 17411 ); 17412 const hasSelection = selection.length > 0; 17413 const areAllSelected = selectedItems.length === selectableItems.length; 17414 if (disableSelectAll) { 17415 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)( 17416 import_components5.CheckboxControl, 17417 { 17418 className: "dataviews-view-table-selection-checkbox", 17419 checked: hasSelection, 17420 disabled: !hasSelection, 17421 onChange: () => { 17422 onChangeSelection([]); 17423 }, 17424 "aria-label": (0, import_i18n10.__)("Deselect all") 17425 } 17426 ); 17427 } 17428 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)( 17429 import_components5.CheckboxControl, 17430 { 17431 className: "dataviews-view-table-selection-checkbox", 17432 checked: areAllSelected, 17433 indeterminate: !areAllSelected && !!selectedItems.length, 17434 onChange: () => { 17435 if (areAllSelected) { 17436 onChangeSelection([]); 17437 } else { 17438 onChangeSelection( 17439 selectableItems.map((item) => getItemId(item)) 17440 ); 17441 } 17442 }, 17443 "aria-label": areAllSelected ? (0, import_i18n10.__)("Deselect all") : (0, import_i18n10.__)("Select all") 17444 } 17445 ); 17446 } 17447 function ActionTrigger({ 17448 action, 17449 onClick, 17450 isBusy, 17451 items 17452 }) { 17453 const label = typeof action.label === "string" ? action.label : action.label(items); 17454 const isMobile = (0, import_compose4.useViewportMatch)("medium", "<"); 17455 if (isMobile) { 17456 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)( 17457 import_components5.Button, 17458 { 17459 disabled: isBusy, 17460 accessibleWhenDisabled: true, 17461 label, 17462 icon: action.icon, 17463 size: "compact", 17464 onClick, 17465 isBusy 17466 } 17467 ); 17468 } 17469 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)( 17470 import_components5.Button, 17471 { 17472 disabled: isBusy, 17473 accessibleWhenDisabled: true, 17474 size: "compact", 17475 onClick, 17476 isBusy, 17477 children: label 17478 } 17479 ); 17480 } 17481 var EMPTY_ARRAY2 = []; 17482 function ActionButton2({ 17483 action, 17484 selectedItems, 17485 actionInProgress, 17486 setActionInProgress 17487 }) { 17488 const registry = (0, import_data2.useRegistry)(); 17489 const selectedEligibleItems = (0, import_element60.useMemo)(() => { 17490 return selectedItems.filter((item) => { 17491 return !action.isEligible || action.isEligible(item); 17492 }); 17493 }, [action, selectedItems]); 17494 if ("RenderModal" in action) { 17495 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)( 17496 ActionWithModal, 17497 { 17498 action, 17499 items: selectedEligibleItems, 17500 ActionTriggerComponent: ActionTrigger 17501 }, 17502 action.id 17503 ); 17504 } 17505 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)( 17506 ActionTrigger, 17507 { 17508 action, 17509 onClick: async () => { 17510 setActionInProgress(action.id); 17511 await action.callback(selectedEligibleItems, { 17512 registry 17513 }); 17514 setActionInProgress(null); 17515 }, 17516 items: selectedEligibleItems, 17517 isBusy: actionInProgress === action.id 17518 }, 17519 action.id 17520 ); 17521 } 17522 function renderFooterContent(data, actions, getItemId, isInfiniteScroll, selection, actionsToShow, selectedItems, actionInProgress, setActionInProgress, onChangeSelection, paginationInfo) { 17523 const message2 = getFooterMessage( 17524 selection.length, 17525 data.length, 17526 paginationInfo.totalItems, 17527 isInfiniteScroll 17528 ); 17529 return /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)( 17530 Stack, 17531 { 17532 direction: "row", 17533 className: "dataviews-bulk-actions-footer__container", 17534 gap: "md", 17535 align: "center", 17536 children: [ 17537 /* @__PURE__ */ (0, import_jsx_runtime93.jsx)( 17538 BulkSelectionCheckbox, 17539 { 17540 selection, 17541 onChangeSelection, 17542 data, 17543 actions, 17544 getItemId, 17545 disableSelectAll: isInfiniteScroll 17546 } 17547 ), 17548 /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("span", { className: "dataviews-bulk-actions-footer__item-count", children: message2 }), 17549 /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)( 17550 Stack, 17551 { 17552 direction: "row", 17553 className: "dataviews-bulk-actions-footer__action-buttons", 17554 gap: "xs", 17555 children: [ 17556 actionsToShow.map((action) => { 17557 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)( 17558 ActionButton2, 17559 { 17560 action, 17561 selectedItems, 17562 actionInProgress, 17563 setActionInProgress 17564 }, 17565 action.id 17566 ); 17567 }), 17568 selectedItems.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime93.jsx)( 17569 import_components5.Button, 17570 { 17571 icon: close_small_default, 17572 showTooltip: true, 17573 tooltipPosition: "top", 17574 size: "compact", 17575 label: (0, import_i18n10.__)("Cancel"), 17576 disabled: !!actionInProgress, 17577 accessibleWhenDisabled: false, 17578 onClick: () => { 17579 onChangeSelection(EMPTY_ARRAY2); 17580 } 17581 } 17582 ) 17583 ] 17584 } 17585 ) 17586 ] 17587 } 17588 ); 17589 } 17590 function FooterContent({ 17591 selection, 17592 actions, 17593 onChangeSelection, 17594 data, 17595 getItemId, 17596 isInfiniteScroll, 17597 paginationInfo 17598 }) { 17599 const [actionInProgress, setActionInProgress] = (0, import_element60.useState)( 17600 null 17601 ); 17602 const footerContentRef = (0, import_element60.useRef)(void 0); 17603 const isMobile = (0, import_compose4.useViewportMatch)("medium", "<"); 17604 const bulkActions = (0, import_element60.useMemo)( 17605 () => actions.filter((action) => action.supportsBulk), 17606 [actions] 17607 ); 17608 const selectableItems = (0, import_element60.useMemo)(() => { 17609 return data.filter((item) => { 17610 return bulkActions.some( 17611 (action) => !action.isEligible || action.isEligible(item) 17612 ); 17613 }); 17614 }, [data, bulkActions]); 17615 const selectedItems = (0, import_element60.useMemo)(() => { 17616 return data.filter( 17617 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item) 17618 ); 17619 }, [selection, data, getItemId, selectableItems]); 17620 const actionsToShow = (0, import_element60.useMemo)( 17621 () => actions.filter((action) => { 17622 return action.supportsBulk && (!isMobile || action.icon) && selectedItems.some( 17623 (item) => !action.isEligible || action.isEligible(item) 17624 ); 17625 }), 17626 [actions, selectedItems, isMobile] 17627 ); 17628 if (!actionInProgress) { 17629 if (footerContentRef.current) { 17630 footerContentRef.current = void 0; 17631 } 17632 return renderFooterContent( 17633 data, 17634 actions, 17635 getItemId, 17636 isInfiniteScroll, 17637 selection, 17638 actionsToShow, 17639 selectedItems, 17640 actionInProgress, 17641 setActionInProgress, 17642 onChangeSelection, 17643 paginationInfo 17644 ); 17645 } else if (!footerContentRef.current) { 17646 footerContentRef.current = renderFooterContent( 17647 data, 17648 actions, 17649 getItemId, 17650 isInfiniteScroll, 17651 selection, 17652 actionsToShow, 17653 selectedItems, 17654 actionInProgress, 17655 setActionInProgress, 17656 onChangeSelection, 17657 paginationInfo 17658 ); 17659 } 17660 return footerContentRef.current; 17661 } 17662 function BulkActionsFooter() { 17663 const { 17664 data, 17665 selection, 17666 actions = EMPTY_ARRAY2, 17667 onChangeSelection, 17668 getItemId, 17669 paginationInfo, 17670 view 17671 } = (0, import_element60.useContext)(dataviews_context_default); 17672 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)( 17673 FooterContent, 17674 { 17675 selection, 17676 onChangeSelection, 17677 data, 17678 actions, 17679 getItemId, 17680 isInfiniteScroll: !!view.infiniteScrollEnabled, 17681 paginationInfo 17682 } 17683 ); 17684 } 17685 17686 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs 17687 var import_i18n11 = __toESM(require_i18n(), 1); 17688 var import_components6 = __toESM(require_components(), 1); 17689 var import_element61 = __toESM(require_element(), 1); 17690 17691 // packages/dataviews/build-module/utils/get-hideable-fields.mjs 17692 function getHideableFields(view, fields) { 17693 const togglableFields = [ 17694 view?.titleField, 17695 view?.mediaField, 17696 view?.descriptionField 17697 ].filter(Boolean); 17698 return fields.filter( 17699 (f2) => !togglableFields.includes(f2.id) && f2.type !== "media" && f2.enableHiding !== false 17700 ); 17701 } 17702 17703 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs 17704 var import_jsx_runtime94 = __toESM(require_jsx_runtime(), 1); 17705 var { Menu: Menu2 } = unlock3(import_components6.privateApis); 17706 function WithMenuSeparators({ children }) { 17707 return import_element61.Children.toArray(children).filter(Boolean).map((child, i2) => /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(import_element61.Fragment, { children: [ 17708 i2 > 0 && /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu2.Separator, {}), 17709 child 17710 ] }, i2)); 17711 } 17712 var _HeaderMenu = (0, import_element61.forwardRef)(function HeaderMenu({ 17713 fieldId, 17714 view, 17715 fields, 17716 onChangeView, 17717 onHide, 17718 setOpenedFilter, 17719 canMove = true, 17720 canInsertLeft = true, 17721 canInsertRight = true 17722 }, ref) { 17723 const visibleFieldIds = view.fields ?? []; 17724 const index2 = visibleFieldIds?.indexOf(fieldId); 17725 const isSorted = view.sort?.field === fieldId; 17726 let isHidable = false; 17727 let isSortable = false; 17728 let canAddFilter = false; 17729 let operators = []; 17730 const field = fields.find((f2) => f2.id === fieldId); 17731 const { setIsShowingFilter } = (0, import_element61.useContext)(dataviews_context_default); 17732 if (!field) { 17733 return null; 17734 } 17735 isHidable = field.enableHiding !== false; 17736 isSortable = field.enableSorting !== false; 17737 const header = field.header; 17738 operators = !!field.filterBy && field.filterBy?.operators || []; 17739 canAddFilter = !view.filters?.some((_filter) => fieldId === _filter.field) && !!(field.hasElements || field.Edit) && field.filterBy !== false && !field.filterBy?.isPrimary; 17740 if (!isSortable && !canMove && !isHidable && !canAddFilter) { 17741 return header; 17742 } 17743 const hiddenFields = getHideableFields(view, fields).filter( 17744 (f2) => !visibleFieldIds.includes(f2.id) 17745 ); 17746 const canInsert = (canInsertLeft || canInsertRight) && !!hiddenFields.length; 17747 const isRtl = (0, import_i18n11.isRTL)(); 17748 return /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(Menu2, { children: [ 17749 /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)( 17750 Menu2.TriggerButton, 17751 { 17752 render: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)( 17753 import_components6.Button, 17754 { 17755 size: "compact", 17756 className: "dataviews-view-table-header-button", 17757 ref, 17758 variant: "tertiary" 17759 } 17760 ), 17761 children: [ 17762 header, 17763 view.sort && isSorted && /* @__PURE__ */ (0, import_jsx_runtime94.jsx)("span", { "aria-hidden": "true", children: sortArrows[view.sort.direction] }) 17764 ] 17765 } 17766 ), 17767 /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu2.Popover, { style: { minWidth: "240px" }, children: /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(WithMenuSeparators, { children: [ 17768 isSortable && /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu2.Group, { children: SORTING_DIRECTIONS.map( 17769 (direction) => { 17770 const isChecked = view.sort && isSorted && view.sort.direction === direction; 17771 const value = `$fieldId}-$direction}`; 17772 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)( 17773 Menu2.RadioItem, 17774 { 17775 name: "view-table-sorting", 17776 value, 17777 checked: isChecked, 17778 onChange: () => { 17779 onChangeView({ 17780 ...view, 17781 sort: { 17782 field: fieldId, 17783 direction 17784 }, 17785 showLevels: false 17786 }); 17787 }, 17788 children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu2.ItemLabel, { children: sortLabels[direction] }) 17789 }, 17790 value 17791 ); 17792 } 17793 ) }), 17794 canAddFilter && /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu2.Group, { children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)( 17795 Menu2.Item, 17796 { 17797 prefix: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_components6.Icon, { icon: funnel_default }), 17798 onClick: () => { 17799 setOpenedFilter(fieldId); 17800 setIsShowingFilter(true); 17801 onChangeView({ 17802 ...view, 17803 page: 1, 17804 filters: [ 17805 ...view.filters || [], 17806 { 17807 field: fieldId, 17808 value: void 0, 17809 operator: operators[0] 17810 } 17811 ] 17812 }); 17813 }, 17814 children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu2.ItemLabel, { children: (0, import_i18n11.__)("Add filter") }) 17815 } 17816 ) }), 17817 (canMove || isHidable || canInsert) && field && /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(Menu2.Group, { children: [ 17818 canMove && /* @__PURE__ */ (0, import_jsx_runtime94.jsx)( 17819 Menu2.Item, 17820 { 17821 prefix: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_components6.Icon, { icon: arrow_left_default }), 17822 disabled: isRtl ? index2 >= visibleFieldIds.length - 1 : index2 < 1, 17823 onClick: () => { 17824 const targetIndex = isRtl ? index2 + 1 : index2 - 1; 17825 const newFields = [ 17826 ...visibleFieldIds 17827 ]; 17828 newFields.splice(index2, 1); 17829 newFields.splice( 17830 targetIndex, 17831 0, 17832 fieldId 17833 ); 17834 onChangeView({ 17835 ...view, 17836 fields: newFields 17837 }); 17838 }, 17839 children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu2.ItemLabel, { children: (0, import_i18n11.__)("Move left") }) 17840 } 17841 ), 17842 canMove && /* @__PURE__ */ (0, import_jsx_runtime94.jsx)( 17843 Menu2.Item, 17844 { 17845 prefix: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_components6.Icon, { icon: arrow_right_default }), 17846 disabled: isRtl ? index2 < 1 : index2 >= visibleFieldIds.length - 1, 17847 onClick: () => { 17848 const targetIndex = isRtl ? index2 - 1 : index2 + 1; 17849 const newFields = [ 17850 ...visibleFieldIds 17851 ]; 17852 newFields.splice(index2, 1); 17853 newFields.splice( 17854 targetIndex, 17855 0, 17856 fieldId 17857 ); 17858 onChangeView({ 17859 ...view, 17860 fields: newFields 17861 }); 17862 }, 17863 children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu2.ItemLabel, { children: (0, import_i18n11.__)("Move right") }) 17864 } 17865 ), 17866 canInsertLeft && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(Menu2, { children: [ 17867 /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu2.ItemLabel, { children: (0, import_i18n11.__)("Insert left") }) }), 17868 /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => { 17869 const insertIndex = isRtl ? index2 + 1 : index2; 17870 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)( 17871 Menu2.Item, 17872 { 17873 onClick: () => { 17874 onChangeView({ 17875 ...view, 17876 fields: [ 17877 ...visibleFieldIds.slice( 17878 0, 17879 insertIndex 17880 ), 17881 hiddenField.id, 17882 ...visibleFieldIds.slice( 17883 insertIndex 17884 ) 17885 ] 17886 }); 17887 }, 17888 children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu2.ItemLabel, { children: hiddenField.label }) 17889 }, 17890 hiddenField.id 17891 ); 17892 }) }) 17893 ] }), 17894 canInsertRight && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(Menu2, { children: [ 17895 /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu2.ItemLabel, { children: (0, import_i18n11.__)("Insert right") }) }), 17896 /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => { 17897 const insertIndex = isRtl ? index2 : index2 + 1; 17898 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)( 17899 Menu2.Item, 17900 { 17901 onClick: () => { 17902 onChangeView({ 17903 ...view, 17904 fields: [ 17905 ...visibleFieldIds.slice( 17906 0, 17907 insertIndex 17908 ), 17909 hiddenField.id, 17910 ...visibleFieldIds.slice( 17911 insertIndex 17912 ) 17913 ] 17914 }); 17915 }, 17916 children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu2.ItemLabel, { children: hiddenField.label }) 17917 }, 17918 hiddenField.id 17919 ); 17920 }) }) 17921 ] }), 17922 isHidable && field && /* @__PURE__ */ (0, import_jsx_runtime94.jsx)( 17923 Menu2.Item, 17924 { 17925 prefix: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_components6.Icon, { icon: unseen_default }), 17926 onClick: () => { 17927 onHide(field); 17928 onChangeView({ 17929 ...view, 17930 fields: visibleFieldIds.filter( 17931 (id) => id !== fieldId 17932 ) 17933 }); 17934 }, 17935 children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu2.ItemLabel, { children: (0, import_i18n11.__)("Hide column") }) 17936 } 17937 ) 17938 ] }) 17939 ] }) }) 17940 ] }); 17941 }); 17942 var ColumnHeaderMenu = _HeaderMenu; 17943 var column_header_menu_default = ColumnHeaderMenu; 17944 17945 // packages/dataviews/build-module/components/dataviews-layouts/utils/item-click-wrapper.mjs 17946 var import_element62 = __toESM(require_element(), 1); 17947 var import_jsx_runtime95 = __toESM(require_jsx_runtime(), 1); 17948 function getClickableItemProps({ 17949 item, 17950 isItemClickable, 17951 onClickItem, 17952 className 17953 }) { 17954 if (!isItemClickable(item) || !onClickItem) { 17955 return { className }; 17956 } 17957 return { 17958 className: className ? `$className} $className}--clickable` : void 0, 17959 role: "button", 17960 tabIndex: 0, 17961 onClick: (event) => { 17962 event.stopPropagation(); 17963 onClickItem(item); 17964 }, 17965 onKeyDown: (event) => { 17966 if (event.key === "Enter" || event.key === "" || event.key === " ") { 17967 event.stopPropagation(); 17968 onClickItem(item); 17969 } 17970 } 17971 }; 17972 } 17973 function ItemClickWrapper({ 17974 item, 17975 isItemClickable, 17976 onClickItem, 17977 renderItemLink, 17978 className, 17979 children, 17980 ...extraProps 17981 }) { 17982 if (!isItemClickable(item)) { 17983 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)("div", { className, ...extraProps, children }); 17984 } 17985 if (renderItemLink) { 17986 const renderedElement = renderItemLink({ 17987 item, 17988 className: `$className} $className}--clickable`, 17989 ...extraProps, 17990 children 17991 }); 17992 return (0, import_element62.cloneElement)(renderedElement, { 17993 onClick: (event) => { 17994 event.stopPropagation(); 17995 if (renderedElement.props.onClick) { 17996 renderedElement.props.onClick(event); 17997 } 17998 }, 17999 onKeyDown: (event) => { 18000 if (event.key === "Enter" || event.key === "" || event.key === " ") { 18001 event.stopPropagation(); 18002 if (renderedElement.props.onKeyDown) { 18003 renderedElement.props.onKeyDown(event); 18004 } 18005 } 18006 } 18007 }); 18008 } 18009 const clickProps = getClickableItemProps({ 18010 item, 18011 isItemClickable, 18012 onClickItem, 18013 className 18014 }); 18015 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)("div", { ...clickProps, ...extraProps, children }); 18016 } 18017 18018 // packages/dataviews/build-module/components/dataviews-layouts/table/column-primary.mjs 18019 var import_jsx_runtime96 = __toESM(require_jsx_runtime(), 1); 18020 function ColumnPrimary({ 18021 item, 18022 level, 18023 titleField: titleField2, 18024 mediaField, 18025 descriptionField: descriptionField3, 18026 onClickItem, 18027 renderItemLink, 18028 isItemClickable 18029 }) { 18030 return /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(Stack, { direction: "row", gap: "md", align: "flex-start", justify: "flex-start", children: [ 18031 mediaField && /* @__PURE__ */ (0, import_jsx_runtime96.jsx)( 18032 ItemClickWrapper, 18033 { 18034 item, 18035 isItemClickable, 18036 onClickItem, 18037 renderItemLink, 18038 className: "dataviews-view-table__cell-content-wrapper dataviews-column-primary__media", 18039 "aria-label": isItemClickable(item) && (!!onClickItem || !!renderItemLink) && !!titleField2 ? titleField2.getValue?.({ item }) : void 0, 18040 children: /* @__PURE__ */ (0, import_jsx_runtime96.jsx)( 18041 mediaField.render, 18042 { 18043 item, 18044 field: mediaField, 18045 config: { sizes: "32px" } 18046 } 18047 ) 18048 } 18049 ), 18050 /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)( 18051 Stack, 18052 { 18053 direction: "column", 18054 align: "flex-start", 18055 className: "dataviews-view-table__primary-column-content", 18056 children: [ 18057 titleField2 && /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)( 18058 ItemClickWrapper, 18059 { 18060 item, 18061 isItemClickable, 18062 onClickItem, 18063 renderItemLink, 18064 className: "dataviews-view-table__cell-content-wrapper dataviews-title-field", 18065 children: [ 18066 level !== void 0 && level > 0 && /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)("span", { className: "dataviews-view-table__level", children: [ 18067 Array(level).fill("—").join(" "), 18068 " " 18069 ] }), 18070 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(titleField2.render, { item, field: titleField2 }) 18071 ] 18072 } 18073 ), 18074 descriptionField3 && /* @__PURE__ */ (0, import_jsx_runtime96.jsx)( 18075 descriptionField3.render, 18076 { 18077 item, 18078 field: descriptionField3 18079 } 18080 ) 18081 ] 18082 } 18083 ) 18084 ] }); 18085 } 18086 var column_primary_default = ColumnPrimary; 18087 18088 // packages/dataviews/build-module/components/dataviews-layouts/table/use-scroll-state.mjs 18089 var import_element63 = __toESM(require_element(), 1); 18090 var import_i18n12 = __toESM(require_i18n(), 1); 18091 var isScrolledToEnd = (element) => { 18092 if ((0, import_i18n12.isRTL)()) { 18093 const scrollLeft = Math.abs(element.scrollLeft); 18094 return scrollLeft <= 1; 18095 } 18096 return element.scrollLeft + element.clientWidth >= element.scrollWidth - 1; 18097 }; 18098 function useScrollState({ 18099 scrollContainerRef, 18100 enabledHorizontal = false 18101 }) { 18102 const [isHorizontalScrollEnd, setIsHorizontalScrollEnd] = (0, import_element63.useState)(false); 18103 const [isVerticallyScrolled, setIsVerticallyScrolled] = (0, import_element63.useState)(false); 18104 const handleScroll = (0, import_element63.useCallback)(() => { 18105 const scrollContainer = scrollContainerRef.current; 18106 if (!scrollContainer) { 18107 return; 18108 } 18109 if (enabledHorizontal) { 18110 setIsHorizontalScrollEnd(isScrolledToEnd(scrollContainer)); 18111 } 18112 setIsVerticallyScrolled(scrollContainer.scrollTop > 0); 18113 }, [scrollContainerRef, enabledHorizontal]); 18114 (0, import_element63.useEffect)(() => { 18115 if (typeof window === "undefined" || !scrollContainerRef.current) { 18116 return () => { 18117 }; 18118 } 18119 const scrollContainer = scrollContainerRef.current; 18120 handleScroll(); 18121 scrollContainer.addEventListener("scroll", handleScroll); 18122 window.addEventListener("resize", handleScroll); 18123 return () => { 18124 scrollContainer.removeEventListener("scroll", handleScroll); 18125 window.removeEventListener("resize", handleScroll); 18126 }; 18127 }, [scrollContainerRef, enabledHorizontal, handleScroll]); 18128 return { isHorizontalScrollEnd, isVerticallyScrolled }; 18129 } 18130 18131 // packages/dataviews/build-module/components/dataviews-layouts/utils/get-data-by-group.mjs 18132 function getDataByGroup(data, groupByField) { 18133 return data.reduce((groups, item) => { 18134 const groupName = groupByField.getValue({ item }); 18135 if (!groups.has(groupName)) { 18136 groups.set(groupName, []); 18137 } 18138 groups.get(groupName)?.push(item); 18139 return groups; 18140 }, /* @__PURE__ */ new Map()); 18141 } 18142 18143 // packages/dataviews/build-module/components/dataviews-layouts/utils/use-selection-props.mjs 18144 var import_element64 = __toESM(require_element(), 1); 18145 var import_keycodes = __toESM(require_keycodes(), 1); 18146 function getRange(orderedIds, fromIndex, toIndex) { 18147 return orderedIds.slice( 18148 Math.min(fromIndex, toIndex), 18149 Math.max(fromIndex, toIndex) + 1 18150 ); 18151 } 18152 function getRangeSelection({ 18153 anchorId, 18154 targetId, 18155 lastTargetId, 18156 orderedIds, 18157 selection 18158 }) { 18159 const targetIndex = orderedIds.indexOf(targetId); 18160 if (targetIndex === -1) { 18161 return selection; 18162 } 18163 const anchorIndex = anchorId === null ? -1 : orderedIds.indexOf(anchorId); 18164 const hasAnchor = anchorIndex !== -1; 18165 const rangeStart = hasAnchor ? anchorIndex : targetIndex; 18166 const lastTargetIndex = hasAnchor && lastTargetId !== null ? orderedIds.indexOf(lastTargetId) : -1; 18167 const lastRange = lastTargetIndex === -1 ? [] : getRange(orderedIds, rangeStart, lastTargetIndex); 18168 const base = selection.filter((id) => !lastRange.includes(id)); 18169 return [ 18170 .../* @__PURE__ */ new Set([ 18171 ...base, 18172 ...getRange(orderedIds, rangeStart, targetIndex) 18173 ]) 18174 ]; 18175 } 18176 function getClosestSelectedId({ 18177 targetId, 18178 orderedIds, 18179 selection 18180 }) { 18181 const targetIndex = orderedIds.indexOf(targetId); 18182 if (targetIndex === -1) { 18183 return null; 18184 } 18185 const selectedIds = new Set(selection); 18186 let closestId = null; 18187 let closestDistance = Infinity; 18188 orderedIds.forEach((id, index2) => { 18189 if (!selectedIds.has(id)) { 18190 return; 18191 } 18192 const distance = Math.abs(index2 - targetIndex); 18193 if (distance < closestDistance) { 18194 closestDistance = distance; 18195 closestId = id; 18196 } 18197 }); 18198 return closestId; 18199 } 18200 function useSelectionProps({ 18201 data, 18202 actions, 18203 getItemId, 18204 selection, 18205 onChangeSelection 18206 }) { 18207 const gestureRef = (0, import_element64.useRef)(null); 18208 const isTouchDeviceRef = (0, import_element64.useRef)(false); 18209 (0, import_element64.useEffect)(() => { 18210 const markTouchDevice = () => { 18211 isTouchDeviceRef.current = true; 18212 }; 18213 document.addEventListener("touchstart", markTouchDevice, { 18214 once: true 18215 }); 18216 return () => document.removeEventListener("touchstart", markTouchDevice); 18217 }, []); 18218 const selectableIds = data.filter((item) => hasAPossibleBulkAction(actions, item)).map(getItemId); 18219 const selectableIdSet = new Set(selectableIds); 18220 const hasSelectableItems = selectableIds.length > 0; 18221 const getSelectionProps = (id) => { 18222 const isSelectable = selectableIdSet.has(id); 18223 return { 18224 onMouseDown: (event) => { 18225 if (event.button === 0 && event.shiftKey && hasSelectableItems) { 18226 event.preventDefault(); 18227 } 18228 }, 18229 onClickCapture: (event) => { 18230 if (!hasSelectableItems) { 18231 return; 18232 } 18233 const isModifierKeyPressed = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey; 18234 const isSelectionCheckboxClick = event.target instanceof Element && !!event.target.closest(`.$SELECTION_CHECKBOX_CLASS}`); 18235 if (!isModifierKeyPressed && !event.shiftKey) { 18236 if (isSelectable && isSelectionCheckboxClick) { 18237 gestureRef.current = { 18238 anchorId: id, 18239 lastTargetId: null 18240 }; 18241 } 18242 return; 18243 } 18244 if (isTouchDeviceRef.current || document.getSelection()?.type === "Range") { 18245 return; 18246 } 18247 event.stopPropagation(); 18248 if (!isSelectionCheckboxClick) { 18249 event.preventDefault(); 18250 } 18251 if (!isSelectable) { 18252 return; 18253 } 18254 if (event.shiftKey) { 18255 let gesture = gestureRef.current; 18256 if (!gesture || !selectableIdSet.has(gesture.anchorId)) { 18257 gesture = { 18258 anchorId: getClosestSelectedId({ 18259 targetId: id, 18260 orderedIds: selectableIds, 18261 selection 18262 }) ?? id, 18263 lastTargetId: null 18264 }; 18265 } 18266 onChangeSelection( 18267 getRangeSelection({ 18268 anchorId: gesture.anchorId, 18269 targetId: id, 18270 lastTargetId: gesture.lastTargetId, 18271 orderedIds: selectableIds, 18272 selection 18273 }) 18274 ); 18275 gestureRef.current = { 18276 anchorId: gesture.anchorId, 18277 lastTargetId: id 18278 }; 18279 } else { 18280 onChangeSelection( 18281 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id] 18282 ); 18283 gestureRef.current = { anchorId: id, lastTargetId: null }; 18284 } 18285 } 18286 }; 18287 }; 18288 return { getSelectionProps }; 18289 } 18290 18291 // packages/dataviews/build-module/components/dataviews-view-config/properties-section.mjs 18292 var import_components7 = __toESM(require_components(), 1); 18293 var import_i18n13 = __toESM(require_i18n(), 1); 18294 var import_element65 = __toESM(require_element(), 1); 18295 var import_jsx_runtime97 = __toESM(require_jsx_runtime(), 1); 18296 function FieldItem({ 18297 field, 18298 isVisible: isVisible2, 18299 onToggleVisibility 18300 }) { 18301 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(import_components7.__experimentalItem, { onClick: field.enableHiding ? onToggleVisibility : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(Stack, { direction: "row", gap: "sm", justify: "flex-start", align: "center", children: [ 18302 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("div", { style: { height: 24, width: 24 }, children: isVisible2 && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(import_components7.Icon, { icon: check_default }) }), 18303 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("span", { className: "dataviews-view-config__label", children: field.label }) 18304 ] }) }); 18305 } 18306 function isDefined(item) { 18307 return !!item; 18308 } 18309 function PropertiesSection({ 18310 showLabel = true 18311 }) { 18312 const { view, fields, onChangeView } = (0, import_element65.useContext)(dataviews_context_default); 18313 const regularFields = getHideableFields(view, fields); 18314 if (!regularFields?.length) { 18315 return null; 18316 } 18317 const titleField2 = fields.find((f2) => f2.id === view.titleField); 18318 const previewField = fields.find((f2) => f2.id === view.mediaField); 18319 const descriptionField3 = fields.find( 18320 (f2) => f2.id === view.descriptionField 18321 ); 18322 const lockedFields = [ 18323 { 18324 field: titleField2, 18325 isVisibleFlag: "showTitle" 18326 }, 18327 { 18328 field: previewField, 18329 isVisibleFlag: "showMedia" 18330 }, 18331 { 18332 field: descriptionField3, 18333 isVisibleFlag: "showDescription" 18334 } 18335 ].filter(({ field }) => isDefined(field)); 18336 const visibleFieldIds = view.fields ?? []; 18337 const visibleRegularFieldsCount = regularFields.filter( 18338 (f2) => visibleFieldIds.includes(f2.id) 18339 ).length; 18340 const visibleLockedFields = lockedFields.filter( 18341 ({ isVisibleFlag }) => ( 18342 // @ts-expect-error 18343 view[isVisibleFlag] ?? true 18344 ) 18345 ); 18346 const totalVisibleFields = visibleLockedFields.length + visibleRegularFieldsCount; 18347 const isSingleVisibleLockedField = totalVisibleFields === 1 && visibleLockedFields.length === 1; 18348 return /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(Stack, { direction: "column", className: "dataviews-field-control", children: [ 18349 showLabel && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(import_components7.BaseControl.VisualLabel, { children: (0, import_i18n13.__)("Properties") }), 18350 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)( 18351 Stack, 18352 { 18353 direction: "column", 18354 className: "dataviews-view-config__properties", 18355 children: /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(import_components7.__experimentalItemGroup, { isBordered: true, isSeparated: true, size: "medium", children: [ 18356 lockedFields.map(({ field, isVisibleFlag }) => { 18357 const isVisible2 = view[isVisibleFlag] ?? true; 18358 const fieldToRender = isSingleVisibleLockedField && isVisible2 ? { ...field, enableHiding: false } : field; 18359 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)( 18360 FieldItem, 18361 { 18362 field: fieldToRender, 18363 isVisible: isVisible2, 18364 onToggleVisibility: () => { 18365 onChangeView({ 18366 ...view, 18367 [isVisibleFlag]: !isVisible2 18368 }); 18369 } 18370 }, 18371 field.id 18372 ); 18373 }), 18374 regularFields.map((field) => { 18375 const isVisible2 = visibleFieldIds.includes(field.id); 18376 const fieldToRender = totalVisibleFields === 1 && isVisible2 ? { ...field, enableHiding: false } : field; 18377 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)( 18378 FieldItem, 18379 { 18380 field: fieldToRender, 18381 isVisible: isVisible2, 18382 onToggleVisibility: () => { 18383 onChangeView({ 18384 ...view, 18385 fields: isVisible2 ? visibleFieldIds.filter( 18386 (fieldId) => fieldId !== field.id 18387 ) : [...visibleFieldIds, field.id] 18388 }); 18389 } 18390 }, 18391 field.id 18392 ); 18393 }) 18394 ] }) 18395 } 18396 ) 18397 ] }); 18398 } 18399 18400 // packages/dataviews/build-module/hooks/use-delayed-loading.mjs 18401 var import_element66 = __toESM(require_element(), 1); 18402 function useDelayedLoading(isLoading, options = { delay: 400 }) { 18403 const [showLoader, setShowLoader] = (0, import_element66.useState)(false); 18404 (0, import_element66.useEffect)(() => { 18405 if (!isLoading) { 18406 return; 18407 } 18408 const timeout = setTimeout(() => { 18409 setShowLoader(true); 18410 }, options.delay); 18411 return () => { 18412 clearTimeout(timeout); 18413 setShowLoader(false); 18414 }; 18415 }, [isLoading, options.delay]); 18416 return showLoader; 18417 } 18418 18419 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs 18420 var import_jsx_runtime98 = __toESM(require_jsx_runtime(), 1); 18421 function getEffectiveAlign(explicitAlign, fieldType) { 18422 if (explicitAlign) { 18423 return explicitAlign; 18424 } 18425 if (fieldType === "integer" || fieldType === "number") { 18426 return "end"; 18427 } 18428 return void 0; 18429 } 18430 function TableColumnField({ 18431 item, 18432 fields, 18433 column, 18434 align 18435 }) { 18436 const field = fields.find((f2) => f2.id === column); 18437 if (!field) { 18438 return null; 18439 } 18440 const className = clsx_default("dataviews-view-table__cell-content-wrapper", { 18441 "dataviews-view-table__cell-align-end": align === "end", 18442 "dataviews-view-table__cell-align-center": align === "center" 18443 }); 18444 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(field.render, { item, field }) }); 18445 } 18446 function TableRow({ 18447 hasBulkActions, 18448 item, 18449 level, 18450 actions, 18451 fields, 18452 id, 18453 view, 18454 titleField: titleField2, 18455 mediaField, 18456 descriptionField: descriptionField3, 18457 selection, 18458 getItemId, 18459 isItemClickable, 18460 onClickItem, 18461 renderItemLink, 18462 onChangeSelection, 18463 onMouseDown, 18464 onClickCapture, 18465 isActionsColumnSticky, 18466 posinset 18467 }) { 18468 const { paginationInfo } = (0, import_element67.useContext)(dataviews_context_default); 18469 const hasPossibleBulkAction = useHasAPossibleBulkAction(actions, item); 18470 const isSelected2 = hasPossibleBulkAction && selection.includes(id); 18471 const { 18472 showTitle = true, 18473 showMedia = true, 18474 showDescription = true, 18475 infiniteScrollEnabled 18476 } = view; 18477 const columns = view.fields ?? []; 18478 const hasPrimaryColumn = titleField2 && showTitle || mediaField && showMedia || descriptionField3 && showDescription; 18479 return /* @__PURE__ */ (0, import_jsx_runtime98.jsxs)( 18480 "tr", 18481 { 18482 className: clsx_default("dataviews-view-table__row", { 18483 "is-selected": hasPossibleBulkAction && isSelected2, 18484 "has-bulk-actions": hasPossibleBulkAction 18485 }), 18486 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0, 18487 "aria-posinset": posinset, 18488 role: infiniteScrollEnabled ? "article" : void 0, 18489 onClickCapture, 18490 onMouseDown: (event) => { 18491 const isMetaClick = (0, import_keycodes2.isAppleOS)() ? event.metaKey : event.ctrlKey; 18492 if (event.button === 0 && isMetaClick && window.navigator.userAgent.toLowerCase().includes("firefox")) { 18493 event.preventDefault(); 18494 } 18495 onMouseDown(event); 18496 }, 18497 children: [ 18498 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("td", { className: "dataviews-view-table__checkbox-column", children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)( 18499 DataViewsSelectionCheckbox, 18500 { 18501 item, 18502 selection, 18503 onChangeSelection, 18504 getItemId, 18505 titleField: titleField2, 18506 disabled: !hasPossibleBulkAction 18507 } 18508 ) }) }), 18509 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)( 18510 column_primary_default, 18511 { 18512 item, 18513 level, 18514 titleField: showTitle ? titleField2 : void 0, 18515 mediaField: showMedia ? mediaField : void 0, 18516 descriptionField: showDescription ? descriptionField3 : void 0, 18517 isItemClickable, 18518 onClickItem, 18519 renderItemLink 18520 } 18521 ) }), 18522 columns.map((column) => { 18523 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {}; 18524 const field = fields.find((f2) => f2.id === column); 18525 const effectiveAlign = getEffectiveAlign(align, field?.type); 18526 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)( 18527 "td", 18528 { 18529 style: { 18530 width, 18531 maxWidth, 18532 minWidth 18533 }, 18534 children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)( 18535 TableColumnField, 18536 { 18537 fields, 18538 item, 18539 column, 18540 align: effectiveAlign 18541 } 18542 ) 18543 }, 18544 column 18545 ); 18546 }), 18547 !!actions?.length && // Disable reason: we are not making the element interactive, 18548 // but preventing any click events from bubbling up to the 18549 // table row. This allows us to add a click handler to the row 18550 // itself (to toggle row selection) without erroneously 18551 // intercepting click events from ItemActions. 18552 /* @__PURE__ */ (0, import_jsx_runtime98.jsx)( 18553 "td", 18554 { 18555 className: clsx_default("dataviews-view-table__actions-column", { 18556 "dataviews-view-table__actions-column--sticky": true, 18557 "dataviews-view-table__actions-column--stuck": isActionsColumnSticky 18558 }), 18559 onClick: (e2) => e2.stopPropagation(), 18560 children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(ItemActions, { item, actions }) 18561 } 18562 ) 18563 ] 18564 } 18565 ); 18566 } 18567 function ViewTable({ 18568 actions, 18569 data, 18570 fields, 18571 getItemId, 18572 getItemLevel, 18573 isLoading = false, 18574 onChangeView, 18575 onChangeSelection, 18576 selection, 18577 setOpenedFilter, 18578 onClickItem, 18579 isItemClickable, 18580 renderItemLink, 18581 view, 18582 className, 18583 empty 18584 }) { 18585 const { containerRef } = (0, import_element67.useContext)(dataviews_context_default); 18586 const isDelayedLoading = useDelayedLoading(isLoading); 18587 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null; 18588 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null; 18589 const orderedData = dataByGroup ? Array.from(dataByGroup.values()).flat() : data; 18590 const { getSelectionProps } = useSelectionProps({ 18591 data: orderedData, 18592 actions, 18593 getItemId, 18594 selection, 18595 onChangeSelection 18596 }); 18597 const headerMenuRefs = (0, import_element67.useRef)(/* @__PURE__ */ new Map()); 18598 const headerMenuToFocusRef = (0, import_element67.useRef)(void 0); 18599 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element67.useState)(); 18600 const [contextMenuAnchor, setContextMenuAnchor] = (0, import_element67.useState)(null); 18601 (0, import_element67.useEffect)(() => { 18602 if (headerMenuToFocusRef.current) { 18603 headerMenuToFocusRef.current.focus(); 18604 headerMenuToFocusRef.current = void 0; 18605 } 18606 }); 18607 const tableNoticeId = (0, import_element67.useId)(); 18608 const { isHorizontalScrollEnd, isVerticallyScrolled } = useScrollState({ 18609 scrollContainerRef: containerRef, 18610 enabledHorizontal: !!actions?.length 18611 }); 18612 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data); 18613 if (nextHeaderMenuToFocus) { 18614 headerMenuToFocusRef.current = nextHeaderMenuToFocus; 18615 setNextHeaderMenuToFocus(void 0); 18616 return; 18617 } 18618 const onHide = (field) => { 18619 const hidden = headerMenuRefs.current.get(field.id); 18620 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0; 18621 setNextHeaderMenuToFocus(fallback?.node); 18622 }; 18623 const handleHeaderContextMenu = (event) => { 18624 event.preventDefault(); 18625 event.stopPropagation(); 18626 const virtualAnchor = { 18627 getBoundingClientRect: () => ({ 18628 x: event.clientX, 18629 y: event.clientY, 18630 top: event.clientY, 18631 left: event.clientX, 18632 right: event.clientX, 18633 bottom: event.clientY, 18634 width: 0, 18635 height: 0, 18636 toJSON: () => ({}) 18637 }) 18638 }; 18639 window.requestAnimationFrame(() => { 18640 setContextMenuAnchor(virtualAnchor); 18641 }); 18642 }; 18643 const hasData = !!data?.length; 18644 const titleField2 = fields.find((field) => field.id === view.titleField); 18645 const mediaField = fields.find((field) => field.id === view.mediaField); 18646 const descriptionField3 = fields.find( 18647 (field) => field.id === view.descriptionField 18648 ); 18649 const { showTitle = true, showMedia = true, showDescription = true } = view; 18650 const hasPrimaryColumn = titleField2 && showTitle || mediaField && showMedia || descriptionField3 && showDescription; 18651 const columns = view.fields ?? []; 18652 const headerMenuRef = (column, index2) => (node) => { 18653 if (node) { 18654 headerMenuRefs.current.set(column, { 18655 node, 18656 fallback: columns[index2 > 0 ? index2 - 1 : 1] 18657 }); 18658 } else { 18659 headerMenuRefs.current.delete(column); 18660 } 18661 }; 18662 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup; 18663 const isRtl = (0, import_i18n14.isRTL)(); 18664 if (!hasData) { 18665 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)( 18666 "div", 18667 { 18668 className: clsx_default("dataviews-no-results", { 18669 "is-refreshing": isDelayedLoading 18670 }), 18671 id: tableNoticeId, 18672 children: empty 18673 } 18674 ); 18675 } 18676 return /* @__PURE__ */ (0, import_jsx_runtime98.jsxs)(import_jsx_runtime98.Fragment, { children: [ 18677 /* @__PURE__ */ (0, import_jsx_runtime98.jsxs)( 18678 "table", 18679 { 18680 className: clsx_default("dataviews-view-table", className, { 18681 [`has-$view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes( 18682 view.layout.density 18683 ), 18684 "has-bulk-actions": hasBulkActions, 18685 "is-refreshing": !isInfiniteScroll && isDelayedLoading 18686 }), 18687 "aria-busy": isLoading, 18688 "aria-describedby": tableNoticeId, 18689 role: isInfiniteScroll ? "feed" : void 0, 18690 inert: !isInfiniteScroll && isLoading ? "true" : void 0, 18691 children: [ 18692 /* @__PURE__ */ (0, import_jsx_runtime98.jsxs)("colgroup", { children: [ 18693 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("col", { className: "dataviews-view-table__col-checkbox" }), 18694 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("col", { className: "dataviews-view-table__col-first-data" }), 18695 columns.map((column, index2) => /* @__PURE__ */ (0, import_jsx_runtime98.jsx)( 18696 "col", 18697 { 18698 className: clsx_default( 18699 `dataviews-view-table__col-$column}`, 18700 { 18701 "dataviews-view-table__col-expand": !hasPrimaryColumn && index2 === columns.length - 1 18702 } 18703 ) 18704 }, 18705 `col-$column}` 18706 )), 18707 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("col", { className: "dataviews-view-table__col-actions" }) 18708 ] }), 18709 contextMenuAnchor && /* @__PURE__ */ (0, import_jsx_runtime98.jsx)( 18710 import_components8.Popover, 18711 { 18712 anchor: contextMenuAnchor, 18713 onClose: () => setContextMenuAnchor(null), 18714 placement: "bottom-start", 18715 children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(PropertiesSection, { showLabel: false }) 18716 } 18717 ), 18718 /* @__PURE__ */ (0, import_jsx_runtime98.jsx)( 18719 "thead", 18720 { 18721 className: clsx_default({ 18722 "dataviews-view-table__thead--stuck": isVerticallyScrolled 18723 }), 18724 onContextMenu: handleHeaderContextMenu, 18725 children: /* @__PURE__ */ (0, import_jsx_runtime98.jsxs)("tr", { className: "dataviews-view-table__row", children: [ 18726 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime98.jsx)( 18727 "th", 18728 { 18729 className: "dataviews-view-table__checkbox-column", 18730 scope: "col", 18731 onContextMenu: handleHeaderContextMenu, 18732 children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)( 18733 BulkSelectionCheckbox, 18734 { 18735 selection, 18736 onChangeSelection, 18737 data, 18738 actions, 18739 getItemId 18740 } 18741 ) 18742 } 18743 ), 18744 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("th", { scope: "col", children: titleField2 && /* @__PURE__ */ (0, import_jsx_runtime98.jsx)( 18745 column_header_menu_default, 18746 { 18747 ref: headerMenuRef( 18748 titleField2.id, 18749 0 18750 ), 18751 fieldId: titleField2.id, 18752 view, 18753 fields, 18754 onChangeView, 18755 onHide, 18756 setOpenedFilter, 18757 canMove: false, 18758 canInsertLeft: isRtl ? view.layout?.enableMoving ?? true : false, 18759 canInsertRight: isRtl ? false : view.layout?.enableMoving ?? true 18760 } 18761 ) }), 18762 columns.map((column, index2) => { 18763 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {}; 18764 const field = fields.find( 18765 (f2) => f2.id === column 18766 ); 18767 const effectiveAlign = getEffectiveAlign( 18768 align, 18769 field?.type 18770 ); 18771 const canInsertOrMove = view.layout?.enableMoving ?? true; 18772 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)( 18773 "th", 18774 { 18775 style: { 18776 width, 18777 maxWidth, 18778 minWidth, 18779 textAlign: effectiveAlign 18780 }, 18781 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0, 18782 scope: "col", 18783 children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)( 18784 column_header_menu_default, 18785 { 18786 ref: headerMenuRef(column, index2), 18787 fieldId: column, 18788 view, 18789 fields, 18790 onChangeView, 18791 onHide, 18792 setOpenedFilter, 18793 canMove: canInsertOrMove, 18794 canInsertLeft: canInsertOrMove, 18795 canInsertRight: canInsertOrMove 18796 } 18797 ) 18798 }, 18799 column 18800 ); 18801 }), 18802 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime98.jsx)( 18803 "th", 18804 { 18805 className: clsx_default( 18806 "dataviews-view-table__actions-column", 18807 { 18808 "dataviews-view-table__actions-column--sticky": true, 18809 "dataviews-view-table__actions-column--stuck": !isHorizontalScrollEnd 18810 } 18811 ), 18812 children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("span", { className: "dataviews-view-table-header", children: (0, import_i18n14.__)("Actions") }) 18813 } 18814 ) 18815 ] }) 18816 } 18817 ), 18818 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map( 18819 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime98.jsxs)("tbody", { children: [ 18820 /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("tr", { className: "dataviews-view-table__group-header-row", children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)( 18821 "td", 18822 { 18823 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + (hasBulkActions ? 1 : 0) + (actions?.length ? 1 : 0), 18824 className: "dataviews-view-table__group-header-cell", 18825 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n14.sprintf)( 18826 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". 18827 (0, import_i18n14.__)("%1$s: %2$s"), 18828 groupField.label, 18829 groupName 18830 ) 18831 } 18832 ) }), 18833 groupItems.map((item, index2) => { 18834 const id = getItemId(item) || index2.toString(); 18835 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)( 18836 TableRow, 18837 { 18838 item, 18839 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0, 18840 hasBulkActions, 18841 actions, 18842 fields, 18843 id, 18844 view, 18845 titleField: titleField2, 18846 mediaField, 18847 descriptionField: descriptionField3, 18848 selection, 18849 getItemId, 18850 onChangeSelection, 18851 ...getSelectionProps(id), 18852 onClickItem, 18853 renderItemLink, 18854 isItemClickable, 18855 isActionsColumnSticky: !isHorizontalScrollEnd 18856 }, 18857 getItemId(item) 18858 ); 18859 }) 18860 ] }, `group-$groupName}`) 18861 ) : /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("tbody", { children: hasData && data.map((item, index2) => { 18862 const id = getItemId(item) || index2.toString(); 18863 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)( 18864 TableRow, 18865 { 18866 item, 18867 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0, 18868 hasBulkActions, 18869 actions, 18870 fields, 18871 id, 18872 view, 18873 titleField: titleField2, 18874 mediaField, 18875 descriptionField: descriptionField3, 18876 selection, 18877 getItemId, 18878 onChangeSelection, 18879 ...getSelectionProps(id), 18880 onClickItem, 18881 renderItemLink, 18882 isItemClickable, 18883 isActionsColumnSticky: !isHorizontalScrollEnd, 18884 posinset: isInfiniteScroll ? index2 + 1 : void 0 18885 }, 18886 getItemId(item) 18887 ); 18888 }) }) 18889 ] 18890 } 18891 ), 18892 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("div", { className: "dataviews-loading", id: tableNoticeId, children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(import_components8.Spinner, {}) }) }) 18893 ] }); 18894 } 18895 var table_default = ViewTable; 18896 18897 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs 18898 var import_components11 = __toESM(require_components(), 1); 18899 var import_i18n17 = __toESM(require_i18n(), 1); 18900 18901 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs 18902 var import_components10 = __toESM(require_components(), 1); 18903 var import_i18n16 = __toESM(require_i18n(), 1); 18904 var import_compose5 = __toESM(require_compose(), 1); 18905 var import_element71 = __toESM(require_element(), 1); 18906 18907 // packages/dataviews/build-module/components/dataviews-layouts/grid/preview-size-picker.mjs 18908 var import_components9 = __toESM(require_components(), 1); 18909 var import_i18n15 = __toESM(require_i18n(), 1); 18910 var import_element68 = __toESM(require_element(), 1); 18911 var import_jsx_runtime99 = __toESM(require_jsx_runtime(), 1); 18912 var imageSizes = [ 18913 { 18914 value: 120, 18915 breakpoint: 1 18916 }, 18917 { 18918 value: 170, 18919 breakpoint: 1 18920 }, 18921 { 18922 value: 230, 18923 breakpoint: 1 18924 }, 18925 { 18926 value: 290, 18927 breakpoint: 1112 18928 // at minimum image width, 4 images display at this container size 18929 }, 18930 { 18931 value: 350, 18932 breakpoint: 1636 18933 // at minimum image width, 6 images display at this container size 18934 }, 18935 { 18936 value: 430, 18937 breakpoint: 588 18938 // at minimum image width, 2 images display at this container size 18939 } 18940 ]; 18941 var DEFAULT_PREVIEW_SIZE = imageSizes[2].value; 18942 function useGridColumns() { 18943 const context = (0, import_element68.useContext)(dataviews_context_default); 18944 const view = context.view; 18945 return (0, import_element68.useMemo)(() => { 18946 const containerWidth = context.containerWidth; 18947 const gap = 32; 18948 const previewSize = view.layout?.previewSize ?? DEFAULT_PREVIEW_SIZE; 18949 const columns = Math.floor( 18950 (containerWidth + gap) / (previewSize + gap) 18951 ); 18952 return Math.max(1, columns); 18953 }, [context.containerWidth, view.layout?.previewSize]); 18954 } 18955 18956 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-items.mjs 18957 var import_element69 = __toESM(require_element(), 1); 18958 var import_jsx_runtime100 = __toESM(require_jsx_runtime(), 1); 18959 var GridItems = (0, import_element69.forwardRef)(({ className, previewSize, ...props }, ref) => { 18960 return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)( 18961 "div", 18962 { 18963 ref, 18964 className: clsx_default("dataviews-view-grid-items", className), 18965 style: { 18966 gridTemplateColumns: previewSize && `repeat(auto-fill, minmax($previewSize}px, 1fr))` 18967 }, 18968 ...props 18969 } 18970 ); 18971 }); 18972 18973 // packages/dataviews/build-module/components/dataviews-layouts/utils/use-infinite-scroll.mjs 18974 var import_element70 = __toESM(require_element(), 1); 18975 function useIntersectionObserver(elementRef, posinset) { 18976 const { intersectionObserver } = (0, import_element70.useContext)(dataviews_context_default); 18977 (0, import_element70.useEffect)(() => { 18978 const element = elementRef.current; 18979 if (!element || posinset === void 0 || !intersectionObserver) { 18980 return; 18981 } 18982 intersectionObserver.observe(element); 18983 return () => { 18984 intersectionObserver.unobserve(element); 18985 }; 18986 }, [elementRef, intersectionObserver, posinset]); 18987 } 18988 function usePlaceholdersNeeded(data, isInfiniteScroll, gridColumns) { 18989 const hasData = !!data?.length; 18990 const firstItemPosition = hasData && isInfiniteScroll ? data[0].position : void 0; 18991 return firstItemPosition && gridColumns ? (firstItemPosition - 1) % gridColumns : 0; 18992 } 18993 18994 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs 18995 var import_jsx_runtime101 = __toESM(require_jsx_runtime(), 1); 18996 var { Badge: WCBadge } = unlock3(import_components10.privateApis); 18997 function chunk(array, size4) { 18998 const chunks = []; 18999 for (let i2 = 0, j2 = array.length; i2 < j2; i2 += size4) { 19000 chunks.push(array.slice(i2, i2 + size4)); 19001 } 19002 return chunks; 19003 } 19004 var GridItem = (0, import_element71.forwardRef)( 19005 function GridItem2({ 19006 view, 19007 selection, 19008 onChangeSelection, 19009 onClickItem, 19010 isItemClickable, 19011 renderItemLink, 19012 getItemId, 19013 item, 19014 actions, 19015 mediaField, 19016 titleField: titleField2, 19017 descriptionField: descriptionField3, 19018 regularFields, 19019 badgeFields, 19020 hasBulkActions, 19021 config, 19022 posinset, 19023 setsize, 19024 ...props 19025 }, forwardedRef) { 19026 const { 19027 showTitle = true, 19028 showMedia = true, 19029 showDescription = true 19030 } = view; 19031 const hasBulkAction = useHasAPossibleBulkAction(actions, item); 19032 const id = getItemId(item); 19033 const elementRef = (0, import_element71.useRef)(null); 19034 const setRefs = (0, import_element71.useCallback)( 19035 (node) => { 19036 elementRef.current = node; 19037 if (typeof forwardedRef === "function") { 19038 forwardedRef(node); 19039 } else if (forwardedRef) { 19040 forwardedRef.current = node; 19041 } 19042 }, 19043 [forwardedRef] 19044 ); 19045 useIntersectionObserver(elementRef, posinset); 19046 const instanceId = (0, import_compose5.useInstanceId)(GridItem2); 19047 const isSelected2 = selection.includes(id); 19048 const mediaPlaceholder = /* @__PURE__ */ (0, import_jsx_runtime101.jsx)("span", { className: "dataviews-view-grid__media-placeholder" }); 19049 const rendersMediaField = showMedia && mediaField?.render; 19050 const renderedMediaField = rendersMediaField ? /* @__PURE__ */ (0, import_jsx_runtime101.jsx)( 19051 mediaField.render, 19052 { 19053 item, 19054 field: mediaField, 19055 config 19056 } 19057 ) : mediaPlaceholder; 19058 const renderedTitleField = showTitle && titleField2?.render ? /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(titleField2.render, { item, field: titleField2 }) : null; 19059 let mediaA11yProps; 19060 let titleA11yProps; 19061 if (isItemClickable(item) && onClickItem) { 19062 if (renderedTitleField) { 19063 mediaA11yProps = { 19064 "aria-labelledby": `dataviews-view-grid__title-field-$instanceId}` 19065 }; 19066 titleA11yProps = { 19067 id: `dataviews-view-grid__title-field-$instanceId}` 19068 }; 19069 } else { 19070 mediaA11yProps = { 19071 "aria-label": (0, import_i18n16.__)("Navigate to item") 19072 }; 19073 } 19074 } 19075 return /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)( 19076 Stack, 19077 { 19078 direction: "column", 19079 ...props, 19080 ref: setRefs, 19081 "aria-setsize": setsize, 19082 "aria-posinset": posinset, 19083 className: clsx_default( 19084 props.className, 19085 "dataviews-view-grid__row__gridcell", 19086 "dataviews-view-grid__card", 19087 { 19088 "is-selected": hasBulkAction && isSelected2 19089 } 19090 ), 19091 children: [ 19092 /* @__PURE__ */ (0, import_jsx_runtime101.jsx)( 19093 ItemClickWrapper, 19094 { 19095 item, 19096 isItemClickable, 19097 onClickItem, 19098 renderItemLink, 19099 className: clsx_default("dataviews-view-grid__media", { 19100 "dataviews-view-grid__media--placeholder": !rendersMediaField 19101 }), 19102 ...mediaA11yProps, 19103 children: renderedMediaField 19104 } 19105 ), 19106 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime101.jsx)( 19107 DataViewsSelectionCheckbox, 19108 { 19109 item, 19110 selection, 19111 onChangeSelection, 19112 getItemId, 19113 titleField: titleField2, 19114 disabled: !hasBulkAction 19115 } 19116 ), 19117 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime101.jsx)("div", { className: "dataviews-view-grid__media-actions", children: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)( 19118 ItemActions, 19119 { 19120 item, 19121 actions, 19122 isCompact: true 19123 } 19124 ) }), 19125 showTitle && /* @__PURE__ */ (0, import_jsx_runtime101.jsx)("div", { className: "dataviews-view-grid__title-actions", children: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)( 19126 ItemClickWrapper, 19127 { 19128 item, 19129 isItemClickable, 19130 onClickItem, 19131 renderItemLink, 19132 className: "dataviews-view-grid__title-field dataviews-title-field", 19133 ...titleA11yProps, 19134 title: titleField2?.getValueFormatted({ 19135 item, 19136 field: titleField2 19137 }) || void 0, 19138 children: renderedTitleField 19139 } 19140 ) }), 19141 /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)(Stack, { direction: "column", gap: "xs", children: [ 19142 showDescription && descriptionField3?.render && /* @__PURE__ */ (0, import_jsx_runtime101.jsx)( 19143 descriptionField3.render, 19144 { 19145 item, 19146 field: descriptionField3 19147 } 19148 ), 19149 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime101.jsx)( 19150 Stack, 19151 { 19152 direction: "row", 19153 className: "dataviews-view-grid__badge-fields", 19154 gap: "sm", 19155 wrap: "wrap", 19156 align: "top", 19157 justify: "flex-start", 19158 children: badgeFields.map((field) => { 19159 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)( 19160 WCBadge, 19161 { 19162 className: "dataviews-view-grid__field-value", 19163 children: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)( 19164 field.render, 19165 { 19166 item, 19167 field 19168 } 19169 ) 19170 }, 19171 field.id 19172 ); 19173 }) 19174 } 19175 ), 19176 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime101.jsx)( 19177 Stack, 19178 { 19179 direction: "column", 19180 className: "dataviews-view-grid__fields", 19181 gap: "xs", 19182 children: regularFields.map((field) => { 19183 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)( 19184 import_components10.Flex, 19185 { 19186 className: "dataviews-view-grid__field", 19187 gap: 1, 19188 justify: "flex-start", 19189 expanded: true, 19190 style: { height: "auto" }, 19191 direction: "row", 19192 children: /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)(import_jsx_runtime101.Fragment, { children: [ 19193 /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)(tooltip_exports.Root, { children: [ 19194 /* @__PURE__ */ (0, import_jsx_runtime101.jsx)( 19195 tooltip_exports.Trigger, 19196 { 19197 render: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_components10.FlexItem, { className: "dataviews-view-grid__field-name", children: field.header }) 19198 } 19199 ), 19200 /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(tooltip_exports.Popup, { children: field.label }) 19201 ] }), 19202 /* @__PURE__ */ (0, import_jsx_runtime101.jsx)( 19203 import_components10.FlexItem, 19204 { 19205 className: "dataviews-view-grid__field-value", 19206 style: { maxHeight: "none" }, 19207 children: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)( 19208 field.render, 19209 { 19210 item, 19211 field 19212 } 19213 ) 19214 } 19215 ) 19216 ] }) 19217 }, 19218 field.id 19219 ); 19220 }) 19221 } 19222 ) 19223 ] }) 19224 ] 19225 } 19226 ); 19227 } 19228 ); 19229 function CompositeGrid({ 19230 data, 19231 isInfiniteScroll, 19232 className, 19233 inert, 19234 isLoading, 19235 view, 19236 fields, 19237 selection, 19238 onChangeSelection, 19239 onClickItem, 19240 isItemClickable, 19241 renderItemLink, 19242 getItemId, 19243 actions, 19244 getSelectionProps 19245 }) { 19246 const { paginationInfo, resizeObserverRef } = (0, import_element71.useContext)(dataviews_context_default); 19247 const gridColumns = useGridColumns(); 19248 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data); 19249 const titleField2 = fields.find( 19250 (field) => field.id === view?.titleField 19251 ); 19252 const mediaField = fields.find( 19253 (field) => field.id === view?.mediaField 19254 ); 19255 const descriptionField3 = fields.find( 19256 (field) => field.id === view?.descriptionField 19257 ); 19258 const otherFields = view.fields ?? []; 19259 const { regularFields, badgeFields } = otherFields.reduce( 19260 (accumulator, fieldId) => { 19261 const field = fields.find((f2) => f2.id === fieldId); 19262 if (!field) { 19263 return accumulator; 19264 } 19265 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields"; 19266 accumulator[key].push(field); 19267 return accumulator; 19268 }, 19269 { regularFields: [], badgeFields: [] } 19270 ); 19271 const size4 = "900px"; 19272 const totalRows = Math.ceil(data.length / gridColumns); 19273 const placeholdersNeeded = usePlaceholdersNeeded( 19274 data, 19275 isInfiniteScroll, 19276 gridColumns 19277 ); 19278 return /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)(import_jsx_runtime101.Fragment, { 19279 // Render infinite scroll layout (no rows, feed semantics) 19280 children: [ 19281 isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)( 19282 import_components10.Composite, 19283 { 19284 render: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)( 19285 GridItems, 19286 { 19287 className: clsx_default( 19288 "dataviews-view-grid-infinite-scroll", 19289 className, 19290 { 19291 [`has-$view.layout?.density}-density`]: view.layout?.density && [ 19292 "compact", 19293 "comfortable" 19294 ].includes(view.layout.density) 19295 } 19296 ), 19297 previewSize: view.layout?.previewSize, 19298 "aria-busy": isLoading, 19299 ref: resizeObserverRef 19300 } 19301 ), 19302 role: "feed", 19303 focusWrap: true, 19304 inert, 19305 children: [ 19306 Array.from({ length: placeholdersNeeded }).map( 19307 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime101.jsx)( 19308 import_components10.Composite.Item, 19309 { 19310 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime101.jsx)( 19311 Stack, 19312 { 19313 ...props, 19314 direction: "column", 19315 role: "article", 19316 className: "dataviews-view-grid__row__gridcell dataviews-view-grid__card dataviews-view-grid__placeholder" 19317 } 19318 ), 19319 "aria-hidden": true, 19320 tabIndex: -1 19321 }, 19322 `placeholder-$index2}` 19323 ) 19324 ), 19325 data.map((item) => { 19326 const itemId = getItemId(item); 19327 const selectionProps = getSelectionProps(itemId); 19328 const stablePosition = item.position; 19329 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)( 19330 import_components10.Composite.Item, 19331 { 19332 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime101.jsx)( 19333 GridItem, 19334 { 19335 ...props, 19336 id: itemId, 19337 role: "article", 19338 view, 19339 selection, 19340 onChangeSelection, 19341 onClickItem, 19342 isItemClickable, 19343 renderItemLink, 19344 getItemId, 19345 item, 19346 actions, 19347 onMouseDown: (event) => { 19348 props.onMouseDown?.(event); 19349 selectionProps.onMouseDown( 19350 event 19351 ); 19352 }, 19353 onClickCapture: (event) => { 19354 props.onClickCapture?.(event); 19355 selectionProps.onClickCapture( 19356 event 19357 ); 19358 }, 19359 mediaField, 19360 titleField: titleField2, 19361 descriptionField: descriptionField3, 19362 regularFields, 19363 badgeFields, 19364 hasBulkActions, 19365 posinset: stablePosition, 19366 setsize: paginationInfo.totalItems, 19367 config: { 19368 sizes: size4 19369 } 19370 } 19371 ) 19372 }, 19373 itemId 19374 ); 19375 }) 19376 ] 19377 } 19378 ), 19379 // Render standard grid layout (with rows, grid semantics) 19380 !isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime101.jsx)( 19381 import_components10.Composite, 19382 { 19383 role: "grid", 19384 className: clsx_default("dataviews-view-grid", className, { 19385 [`has-$view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes( 19386 view.layout.density 19387 ) 19388 }), 19389 focusWrap: true, 19390 "aria-busy": isLoading, 19391 "aria-rowcount": totalRows, 19392 ref: resizeObserverRef, 19393 inert, 19394 children: chunk(data, gridColumns).map((row, i2) => /* @__PURE__ */ (0, import_jsx_runtime101.jsx)( 19395 import_components10.Composite.Row, 19396 { 19397 render: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)( 19398 "div", 19399 { 19400 role: "row", 19401 "aria-rowindex": i2 + 1, 19402 "aria-label": (0, import_i18n16.sprintf)( 19403 /* translators: %d: The row number in the grid */ 19404 (0, import_i18n16.__)("Row %d"), 19405 i2 + 1 19406 ), 19407 className: "dataviews-view-grid__row", 19408 style: { 19409 gridTemplateColumns: `repeat( $gridColumns}, minmax(0, 1fr) )` 19410 } 19411 } 19412 ), 19413 children: row.map((item) => { 19414 const itemId = getItemId(item); 19415 const selectionProps = getSelectionProps(itemId); 19416 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)( 19417 import_components10.Composite.Item, 19418 { 19419 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime101.jsx)( 19420 GridItem, 19421 { 19422 ...props, 19423 id: itemId, 19424 role: "gridcell", 19425 view, 19426 selection, 19427 onChangeSelection, 19428 onClickItem, 19429 isItemClickable, 19430 renderItemLink, 19431 getItemId, 19432 item, 19433 actions, 19434 onMouseDown: (event) => { 19435 props.onMouseDown?.( 19436 event 19437 ); 19438 selectionProps.onMouseDown( 19439 event 19440 ); 19441 }, 19442 onClickCapture: (event) => { 19443 props.onClickCapture?.( 19444 event 19445 ); 19446 selectionProps.onClickCapture( 19447 event 19448 ); 19449 }, 19450 mediaField, 19451 titleField: titleField2, 19452 descriptionField: descriptionField3, 19453 regularFields, 19454 badgeFields, 19455 hasBulkActions, 19456 config: { 19457 sizes: size4 19458 } 19459 } 19460 ) 19461 }, 19462 itemId 19463 ); 19464 }) 19465 }, 19466 i2 19467 )) 19468 } 19469 ) 19470 ] 19471 }); 19472 } 19473 19474 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs 19475 var import_jsx_runtime102 = __toESM(require_jsx_runtime(), 1); 19476 function ViewGrid({ 19477 actions, 19478 data, 19479 fields, 19480 getItemId, 19481 isLoading, 19482 onChangeSelection, 19483 onClickItem, 19484 isItemClickable, 19485 renderItemLink, 19486 selection, 19487 view, 19488 className, 19489 empty 19490 }) { 19491 const isDelayedLoading = useDelayedLoading(!!isLoading); 19492 const hasData = !!data?.length; 19493 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null; 19494 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null; 19495 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup; 19496 const orderedData = dataByGroup ? Array.from(dataByGroup.values()).flat() : data; 19497 const { getSelectionProps } = useSelectionProps({ 19498 data: orderedData, 19499 actions, 19500 getItemId, 19501 selection, 19502 onChangeSelection 19503 }); 19504 if (!hasData) { 19505 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)( 19506 "div", 19507 { 19508 className: clsx_default("dataviews-no-results", { 19509 "is-refreshing": isDelayedLoading 19510 }), 19511 children: empty 19512 } 19513 ); 19514 } 19515 const gridProps = { 19516 className: clsx_default(className, { 19517 "is-refreshing": !isInfiniteScroll && isDelayedLoading 19518 }), 19519 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0, 19520 isLoading, 19521 view, 19522 fields, 19523 selection, 19524 onChangeSelection, 19525 onClickItem, 19526 isItemClickable, 19527 renderItemLink, 19528 getItemId, 19529 actions, 19530 getSelectionProps 19531 }; 19532 return /* @__PURE__ */ (0, import_jsx_runtime102.jsxs)(import_jsx_runtime102.Fragment, { 19533 // Render multiple groups. 19534 children: [ 19535 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(Stack, { direction: "column", gap: "lg", children: Array.from(dataByGroup.entries()).map( 19536 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime102.jsxs)( 19537 Stack, 19538 { 19539 direction: "column", 19540 gap: "sm", 19541 children: [ 19542 /* @__PURE__ */ (0, import_jsx_runtime102.jsx)("h3", { className: "dataviews-view-grid__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n17.sprintf)( 19543 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". 19544 (0, import_i18n17.__)("%1$s: %2$s"), 19545 groupField.label, 19546 groupName 19547 ) }), 19548 /* @__PURE__ */ (0, import_jsx_runtime102.jsx)( 19549 CompositeGrid, 19550 { 19551 ...gridProps, 19552 data: groupItems, 19553 isInfiniteScroll: false 19554 } 19555 ) 19556 ] 19557 }, 19558 groupName 19559 ) 19560 ) }), 19561 // Render a single grid with all data. 19562 !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime102.jsx)( 19563 CompositeGrid, 19564 { 19565 ...gridProps, 19566 data, 19567 isInfiniteScroll: !!isInfiniteScroll 19568 } 19569 ), 19570 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime102.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(import_components11.Spinner, {}) }) 19571 ] 19572 }); 19573 } 19574 var grid_default = ViewGrid; 19575 19576 // packages/dataviews/build-module/components/dataviews-layouts/list/index.mjs 19577 var import_compose6 = __toESM(require_compose(), 1); 19578 var import_components12 = __toESM(require_components(), 1); 19579 var import_element72 = __toESM(require_element(), 1); 19580 var import_i18n18 = __toESM(require_i18n(), 1); 19581 var import_data3 = __toESM(require_data(), 1); 19582 var import_jsx_runtime103 = __toESM(require_jsx_runtime(), 1); 19583 var { Menu: Menu3 } = unlock3(import_components12.privateApis); 19584 function generateItemWrapperCompositeId(idPrefix) { 19585 return `$idPrefix}-item-wrapper`; 19586 } 19587 function generatePrimaryActionCompositeId(idPrefix, primaryActionId) { 19588 return `$idPrefix}-primary-action-$primaryActionId}`; 19589 } 19590 function generateDropdownTriggerCompositeId(idPrefix) { 19591 return `$idPrefix}-dropdown`; 19592 } 19593 function PrimaryActionGridCell({ 19594 idPrefix, 19595 primaryAction, 19596 item 19597 }) { 19598 const registry = (0, import_data3.useRegistry)(); 19599 const [isModalOpen, setIsModalOpen] = (0, import_element72.useState)(false); 19600 const compositeItemId = generatePrimaryActionCompositeId( 19601 idPrefix, 19602 primaryAction.id 19603 ); 19604 const label = typeof primaryAction.label === "string" ? primaryAction.label : primaryAction.label([item]); 19605 return "RenderModal" in primaryAction ? /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)( 19606 import_components12.Composite.Item, 19607 { 19608 id: compositeItemId, 19609 render: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)( 19610 import_components12.Button, 19611 { 19612 disabled: !!primaryAction.disabled, 19613 accessibleWhenDisabled: true, 19614 text: label, 19615 size: "small", 19616 onClick: () => setIsModalOpen(true) 19617 } 19618 ), 19619 children: isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime103.jsx)( 19620 ActionModal, 19621 { 19622 action: primaryAction, 19623 items: [item], 19624 closeModal: () => setIsModalOpen(false) 19625 } 19626 ) 19627 } 19628 ) }, primaryAction.id) : /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)( 19629 import_components12.Composite.Item, 19630 { 19631 id: compositeItemId, 19632 render: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)( 19633 import_components12.Button, 19634 { 19635 disabled: !!primaryAction.disabled, 19636 accessibleWhenDisabled: true, 19637 size: "small", 19638 onClick: () => { 19639 primaryAction.callback([item], { registry }); 19640 }, 19641 children: label 19642 } 19643 ) 19644 } 19645 ) }, primaryAction.id); 19646 } 19647 function ListItem({ 19648 view, 19649 actions, 19650 idPrefix, 19651 isSelected: isSelected2, 19652 item, 19653 titleField: titleField2, 19654 mediaField, 19655 descriptionField: descriptionField3, 19656 onSelect, 19657 otherFields, 19658 onDropdownTriggerKeyDown, 19659 posinset 19660 }) { 19661 const { 19662 showTitle = true, 19663 showMedia = true, 19664 showDescription = true, 19665 infiniteScrollEnabled 19666 } = view; 19667 const itemRef = (0, import_element72.useRef)(null); 19668 const labelId = `$idPrefix}-label`; 19669 const descriptionId = `$idPrefix}-description`; 19670 const registry = (0, import_data3.useRegistry)(); 19671 const [isHovered, setIsHovered] = (0, import_element72.useState)(false); 19672 const [activeModalAction, setActiveModalAction] = (0, import_element72.useState)( 19673 null 19674 ); 19675 const handleHover = ({ type }) => { 19676 const isHover = type === "mouseenter"; 19677 setIsHovered(isHover); 19678 }; 19679 const { paginationInfo } = (0, import_element72.useContext)(dataviews_context_default); 19680 (0, import_element72.useEffect)(() => { 19681 if (isSelected2) { 19682 itemRef.current?.scrollIntoView({ 19683 behavior: "auto", 19684 block: "nearest", 19685 inline: "nearest" 19686 }); 19687 } 19688 }, [isSelected2]); 19689 const { primaryAction, eligibleActions } = (0, import_element72.useMemo)(() => { 19690 const _eligibleActions = actions.filter( 19691 (action) => !action.isEligible || action.isEligible(item) 19692 ); 19693 const _primaryActions = _eligibleActions.filter( 19694 (action) => action.isPrimary 19695 ); 19696 return { 19697 primaryAction: _primaryActions[0], 19698 eligibleActions: _eligibleActions 19699 }; 19700 }, [actions, item]); 19701 const hasOnlyOnePrimaryAction = primaryAction && actions.length === 1; 19702 const renderedMediaField = showMedia && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("div", { className: "dataviews-view-list__media-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)( 19703 mediaField.render, 19704 { 19705 item, 19706 field: mediaField, 19707 config: { sizes: "52px" } 19708 } 19709 ) }) : null; 19710 const renderedTitleField = showTitle && titleField2?.render ? /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(titleField2.render, { item, field: titleField2 }) : null; 19711 const renderDescription = showDescription && descriptionField3?.render; 19712 const hasOnlyMediaAndTitle = !!renderedMediaField && !renderDescription && !otherFields.length; 19713 const usedActions = eligibleActions?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)( 19714 Stack, 19715 { 19716 direction: "row", 19717 gap: "md", 19718 className: "dataviews-view-list__item-actions", 19719 children: [ 19720 primaryAction && /* @__PURE__ */ (0, import_jsx_runtime103.jsx)( 19721 PrimaryActionGridCell, 19722 { 19723 idPrefix, 19724 primaryAction, 19725 item 19726 } 19727 ), 19728 !hasOnlyOnePrimaryAction && /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)("div", { role: "gridcell", children: [ 19729 /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)(Menu3, { placement: "bottom-end", children: [ 19730 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)( 19731 Menu3.TriggerButton, 19732 { 19733 render: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)( 19734 import_components12.Composite.Item, 19735 { 19736 id: generateDropdownTriggerCompositeId( 19737 idPrefix 19738 ), 19739 render: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)( 19740 import_components12.Button, 19741 { 19742 size: "small", 19743 icon: more_vertical_default, 19744 label: (0, import_i18n18.__)("Actions"), 19745 accessibleWhenDisabled: true, 19746 disabled: !actions.length, 19747 onKeyDown: onDropdownTriggerKeyDown 19748 } 19749 ) 19750 } 19751 ) 19752 } 19753 ), 19754 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(Menu3.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)( 19755 ActionsMenuGroup, 19756 { 19757 actions: eligibleActions, 19758 item, 19759 registry, 19760 setActiveModalAction 19761 } 19762 ) }) 19763 ] }), 19764 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime103.jsx)( 19765 ActionModal, 19766 { 19767 action: activeModalAction, 19768 items: [item], 19769 closeModal: () => setActiveModalAction(null) 19770 } 19771 ) 19772 ] }) 19773 ] 19774 } 19775 ); 19776 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)( 19777 import_components12.Composite.Row, 19778 { 19779 ref: itemRef, 19780 render: ( 19781 /* aria-posinset breaks Composite.Row if passed to it directly. */ 19782 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)( 19783 "div", 19784 { 19785 "aria-posinset": posinset, 19786 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0 19787 } 19788 ) 19789 ), 19790 role: infiniteScrollEnabled ? "article" : "row", 19791 className: clsx_default({ 19792 "is-selected": isSelected2, 19793 "is-hovered": isHovered 19794 }), 19795 onMouseEnter: handleHover, 19796 onMouseLeave: handleHover, 19797 children: /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)( 19798 Stack, 19799 { 19800 direction: "row", 19801 className: "dataviews-view-list__item-wrapper", 19802 children: [ 19803 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)( 19804 import_components12.Composite.Item, 19805 { 19806 id: generateItemWrapperCompositeId(idPrefix), 19807 "aria-pressed": isSelected2, 19808 "aria-labelledby": labelId, 19809 "aria-describedby": descriptionId, 19810 className: "dataviews-view-list__item", 19811 onClick: () => onSelect(item) 19812 } 19813 ) }), 19814 /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)( 19815 Stack, 19816 { 19817 direction: "row", 19818 gap: "md", 19819 justify: "start", 19820 align: hasOnlyMediaAndTitle ? "center" : "flex-start", 19821 style: { flex: 1, minWidth: 0 }, 19822 children: [ 19823 renderedMediaField, 19824 /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)( 19825 Stack, 19826 { 19827 direction: "column", 19828 gap: "xs", 19829 className: "dataviews-view-list__field-wrapper", 19830 children: [ 19831 /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)(Stack, { direction: "row", align: "center", children: [ 19832 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)( 19833 "div", 19834 { 19835 className: "dataviews-title-field dataviews-view-list__title-field", 19836 id: labelId, 19837 children: renderedTitleField 19838 } 19839 ), 19840 usedActions 19841 ] }), 19842 renderDescription && /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("div", { className: "dataviews-view-list__field", children: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)( 19843 descriptionField3.render, 19844 { 19845 item, 19846 field: descriptionField3 19847 } 19848 ) }), 19849 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)( 19850 "div", 19851 { 19852 className: "dataviews-view-list__fields", 19853 id: descriptionId, 19854 children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)( 19855 "div", 19856 { 19857 className: "dataviews-view-list__field", 19858 children: [ 19859 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)( 19860 VisuallyHidden, 19861 { 19862 className: "dataviews-view-list__field-label", 19863 render: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("span", {}), 19864 children: field.label 19865 } 19866 ), 19867 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("span", { className: "dataviews-view-list__field-value", children: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)( 19868 field.render, 19869 { 19870 item, 19871 field 19872 } 19873 ) }) 19874 ] 19875 }, 19876 field.id 19877 )) 19878 } 19879 ) 19880 ] 19881 } 19882 ) 19883 ] 19884 } 19885 ) 19886 ] 19887 } 19888 ) 19889 } 19890 ); 19891 } 19892 function isDefined2(item) { 19893 return !!item; 19894 } 19895 function ViewList(props) { 19896 const { 19897 actions, 19898 data, 19899 fields, 19900 getItemId, 19901 isLoading, 19902 onChangeSelection, 19903 selection, 19904 view, 19905 className, 19906 empty 19907 } = props; 19908 const baseId = (0, import_compose6.useInstanceId)(ViewList, "view-list"); 19909 const isDelayedLoading = useDelayedLoading(!!isLoading); 19910 const { paginationInfo } = (0, import_element72.useContext)(dataviews_context_default); 19911 const selectedItem = data?.findLast( 19912 (item) => selection.includes(getItemId(item)) 19913 ); 19914 const titleField2 = fields.find((field) => field.id === view.titleField); 19915 const mediaField = fields.find((field) => field.id === view.mediaField); 19916 const descriptionField3 = fields.find( 19917 (field) => field.id === view.descriptionField 19918 ); 19919 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined2); 19920 const onSelect = (item) => onChangeSelection([getItemId(item)]); 19921 const generateCompositeItemIdPrefix = (0, import_element72.useCallback)( 19922 (item) => `$baseId}-$getItemId(item)}`, 19923 [baseId, getItemId] 19924 ); 19925 const isActiveCompositeItem = (0, import_element72.useCallback)( 19926 (item, idToCheck) => { 19927 return idToCheck.startsWith( 19928 generateCompositeItemIdPrefix(item) 19929 ); 19930 }, 19931 [generateCompositeItemIdPrefix] 19932 ); 19933 const [activeCompositeId, setActiveCompositeId] = (0, import_element72.useState)(void 0); 19934 const compositeRef = (0, import_element72.useRef)(null); 19935 (0, import_element72.useEffect)(() => { 19936 if (selectedItem) { 19937 setActiveCompositeId( 19938 generateItemWrapperCompositeId( 19939 generateCompositeItemIdPrefix(selectedItem) 19940 ) 19941 ); 19942 } 19943 }, [selectedItem, generateCompositeItemIdPrefix]); 19944 const activeItemIndex = data.findIndex( 19945 (item) => isActiveCompositeItem(item, activeCompositeId ?? "") 19946 ); 19947 const previousActiveItemIndex = (0, import_compose6.usePrevious)(activeItemIndex); 19948 const isActiveIdInList = activeItemIndex !== -1; 19949 const selectCompositeItem = (0, import_element72.useCallback)( 19950 (targetIndex, generateCompositeId) => { 19951 const clampedIndex = Math.min( 19952 data.length - 1, 19953 Math.max(0, targetIndex) 19954 ); 19955 if (!data[clampedIndex]) { 19956 return; 19957 } 19958 const itemIdPrefix = generateCompositeItemIdPrefix( 19959 data[clampedIndex] 19960 ); 19961 const targetCompositeItemId = generateCompositeId(itemIdPrefix); 19962 setActiveCompositeId(targetCompositeItemId); 19963 if (compositeRef.current?.contains( 19964 compositeRef.current.ownerDocument.activeElement 19965 )) { 19966 document.getElementById(targetCompositeItemId)?.focus(); 19967 } 19968 }, 19969 [data, generateCompositeItemIdPrefix] 19970 ); 19971 (0, import_element72.useEffect)(() => { 19972 const wasActiveIdInList = previousActiveItemIndex !== void 0 && previousActiveItemIndex !== -1; 19973 if (!isActiveIdInList && wasActiveIdInList) { 19974 selectCompositeItem( 19975 previousActiveItemIndex, 19976 generateItemWrapperCompositeId 19977 ); 19978 } 19979 }, [isActiveIdInList, selectCompositeItem, previousActiveItemIndex]); 19980 const onDropdownTriggerKeyDown = (0, import_element72.useCallback)( 19981 (event) => { 19982 if (event.key === "ArrowDown") { 19983 event.preventDefault(); 19984 selectCompositeItem( 19985 activeItemIndex + 1, 19986 generateDropdownTriggerCompositeId 19987 ); 19988 } 19989 if (event.key === "ArrowUp") { 19990 event.preventDefault(); 19991 selectCompositeItem( 19992 activeItemIndex - 1, 19993 generateDropdownTriggerCompositeId 19994 ); 19995 } 19996 }, 19997 [selectCompositeItem, activeItemIndex] 19998 ); 19999 const hasData = !!data?.length; 20000 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null; 20001 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null; 20002 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup; 20003 const hasMoreItems = isInfiniteScroll && (view.startPosition ?? 1) + (view.perPage ?? 0) < paginationInfo.totalItems; 20004 const listClassName = clsx_default("dataviews-view-list", className, { 20005 [`has-$view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(view.layout.density), 20006 "is-refreshing": !isInfiniteScroll && isDelayedLoading 20007 }); 20008 const compositeProps = { 20009 ref: compositeRef, 20010 id: baseId, 20011 render: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("div", {}), 20012 activeId: activeCompositeId, 20013 setActiveId: setActiveCompositeId, 20014 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0 20015 }; 20016 if (!hasData) { 20017 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)( 20018 "div", 20019 { 20020 className: clsx_default("dataviews-no-results", { 20021 "is-refreshing": isDelayedLoading 20022 }), 20023 children: empty 20024 } 20025 ); 20026 } 20027 if (hasData && groupField && dataByGroup) { 20028 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)( 20029 import_components12.Composite, 20030 { 20031 ...compositeProps, 20032 className: "dataviews-view-list__group", 20033 role: "grid", 20034 children: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(Stack, { direction: "column", gap: "lg", className: listClassName, children: Array.from(dataByGroup.entries()).map( 20035 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)(Stack, { direction: "column", children: [ 20036 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("h3", { className: "dataviews-view-list__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n18.sprintf)( 20037 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". 20038 (0, import_i18n18.__)("%1$s: %2$s"), 20039 groupField.label, 20040 groupName 20041 ) }), 20042 groupItems.map((item) => { 20043 const id = generateCompositeItemIdPrefix(item); 20044 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)( 20045 ListItem, 20046 { 20047 view, 20048 idPrefix: id, 20049 actions, 20050 item, 20051 isSelected: item === selectedItem, 20052 onSelect, 20053 mediaField, 20054 titleField: titleField2, 20055 descriptionField: descriptionField3, 20056 otherFields, 20057 onDropdownTriggerKeyDown 20058 }, 20059 id 20060 ); 20061 }) 20062 ] }, groupName) 20063 ) }) 20064 } 20065 ); 20066 } 20067 return /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)(import_jsx_runtime103.Fragment, { children: [ 20068 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)( 20069 import_components12.Composite, 20070 { 20071 ...compositeProps, 20072 className: listClassName, 20073 role: view.infiniteScrollEnabled ? "feed" : "grid", 20074 children: data.map((item, index2) => { 20075 const id = generateCompositeItemIdPrefix(item); 20076 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)( 20077 ListItem, 20078 { 20079 view, 20080 idPrefix: id, 20081 actions, 20082 item, 20083 isSelected: item === selectedItem, 20084 onSelect, 20085 mediaField, 20086 titleField: titleField2, 20087 descriptionField: descriptionField3, 20088 otherFields, 20089 onDropdownTriggerKeyDown, 20090 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0 20091 }, 20092 id 20093 ); 20094 }) 20095 } 20096 ), 20097 (hasMoreItems || isInfiniteScroll && isLoading) && // Keep the spinner's height reserved while loading more so the 20098 // scroll position doesn't bounce. Hidden, and silent to a11y, 20099 // while idle. 20100 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)( 20101 "p", 20102 { 20103 className: "dataviews-loading-more", 20104 "aria-hidden": !isLoading, 20105 children: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(import_components12.Spinner, {}) 20106 } 20107 ) 20108 ] }); 20109 } 20110 20111 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs 20112 var import_components13 = __toESM(require_components(), 1); 20113 20114 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-group.mjs 20115 var import_i18n19 = __toESM(require_i18n(), 1); 20116 var import_element73 = __toESM(require_element(), 1); 20117 var import_jsx_runtime104 = __toESM(require_jsx_runtime(), 1); 20118 function ActivityGroup({ 20119 groupName, 20120 groupData, 20121 groupField, 20122 showLabel = true, 20123 children 20124 }) { 20125 const groupHeader = showLabel ? (0, import_element73.createInterpolateElement)( 20126 // translators: %s: The label of the field e.g. "Status". 20127 (0, import_i18n19.sprintf)((0, import_i18n19.__)("%s: <groupName />"), groupField.label).trim(), 20128 { 20129 groupName: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)( 20130 groupField.render, 20131 { 20132 item: groupData[0], 20133 field: groupField 20134 } 20135 ) 20136 } 20137 ) : /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(groupField.render, { item: groupData[0], field: groupField }); 20138 return /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)( 20139 Stack, 20140 { 20141 direction: "column", 20142 className: "dataviews-view-activity__group", 20143 children: [ 20144 /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("h3", { className: "dataviews-view-activity__group-header", children: groupHeader }), 20145 children 20146 ] 20147 }, 20148 groupName 20149 ); 20150 } 20151 20152 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-item.mjs 20153 var import_element74 = __toESM(require_element(), 1); 20154 var import_data4 = __toESM(require_data(), 1); 20155 var import_compose7 = __toESM(require_compose(), 1); 20156 var import_jsx_runtime105 = __toESM(require_jsx_runtime(), 1); 20157 function ActivityItem(props) { 20158 const { 20159 view, 20160 actions, 20161 item, 20162 titleField: titleField2, 20163 mediaField, 20164 descriptionField: descriptionField3, 20165 otherFields, 20166 posinset, 20167 onClickItem, 20168 renderItemLink, 20169 isItemClickable 20170 } = props; 20171 const { 20172 showTitle = true, 20173 showMedia = true, 20174 showDescription = true, 20175 infiniteScrollEnabled 20176 } = view; 20177 const itemRef = (0, import_element74.useRef)(null); 20178 const registry = (0, import_data4.useRegistry)(); 20179 const { paginationInfo } = (0, import_element74.useContext)(dataviews_context_default); 20180 const { primaryActions, eligibleActions } = (0, import_element74.useMemo)(() => { 20181 const _eligibleActions = actions.filter( 20182 (action) => !action.isEligible || action.isEligible(item) 20183 ); 20184 const _primaryActions = _eligibleActions.filter( 20185 (action) => action.isPrimary 20186 ); 20187 return { 20188 primaryActions: _primaryActions, 20189 eligibleActions: _eligibleActions 20190 }; 20191 }, [actions, item]); 20192 const isMobileViewport = (0, import_compose7.useViewportMatch)("medium", "<"); 20193 const density = view.layout?.density ?? "balanced"; 20194 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime105.jsx)( 20195 mediaField.render, 20196 { 20197 item, 20198 field: mediaField, 20199 config: { 20200 sizes: density === "comfortable" ? "32px" : "24px" 20201 } 20202 } 20203 ) : null; 20204 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime105.jsx)("div", { className: "dataviews-view-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime105.jsx)( 20205 "span", 20206 { 20207 className: "dataviews-view-activity__item-bullet", 20208 "aria-hidden": "true" 20209 } 20210 ) }); 20211 const renderedTitleField = showTitle && titleField2?.render ? /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(titleField2.render, { item, field: titleField2 }) : null; 20212 const verticalGap = (0, import_element74.useMemo)(() => { 20213 switch (density) { 20214 case "comfortable": 20215 return "md"; 20216 default: 20217 return "sm"; 20218 } 20219 }, [density]); 20220 return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)( 20221 "div", 20222 { 20223 ref: itemRef, 20224 role: infiniteScrollEnabled ? "article" : void 0, 20225 "aria-posinset": posinset, 20226 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0, 20227 className: clsx_default( 20228 "dataviews-view-activity__item", 20229 density === "compact" && "is-compact", 20230 density === "balanced" && "is-balanced", 20231 density === "comfortable" && "is-comfortable" 20232 ), 20233 children: /* @__PURE__ */ (0, import_jsx_runtime105.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [ 20234 /* @__PURE__ */ (0, import_jsx_runtime105.jsx)( 20235 Stack, 20236 { 20237 direction: "column", 20238 gap: "xs", 20239 align: "center", 20240 className: "dataviews-view-activity__item-type", 20241 children: renderedMediaField 20242 } 20243 ), 20244 /* @__PURE__ */ (0, import_jsx_runtime105.jsxs)( 20245 Stack, 20246 { 20247 direction: "column", 20248 gap: verticalGap, 20249 align: "flex-start", 20250 className: "dataviews-view-activity__item-content", 20251 children: [ 20252 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime105.jsx)( 20253 ItemClickWrapper, 20254 { 20255 item, 20256 isItemClickable, 20257 onClickItem, 20258 renderItemLink, 20259 className: "dataviews-view-activity__item-title", 20260 children: renderedTitleField 20261 } 20262 ), 20263 showDescription && descriptionField3 && /* @__PURE__ */ (0, import_jsx_runtime105.jsx)("div", { className: "dataviews-view-activity__item-description", children: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)( 20264 descriptionField3.render, 20265 { 20266 item, 20267 field: descriptionField3 20268 } 20269 ) }), 20270 /* @__PURE__ */ (0, import_jsx_runtime105.jsx)("div", { className: "dataviews-view-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime105.jsxs)( 20271 "div", 20272 { 20273 className: "dataviews-view-activity__item-field", 20274 children: [ 20275 /* @__PURE__ */ (0, import_jsx_runtime105.jsx)( 20276 VisuallyHidden, 20277 { 20278 className: "dataviews-view-activity__item-field-label", 20279 render: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)("span", {}), 20280 children: field.label 20281 } 20282 ), 20283 /* @__PURE__ */ (0, import_jsx_runtime105.jsx)("span", { className: "dataviews-view-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)( 20284 field.render, 20285 { 20286 item, 20287 field 20288 } 20289 ) }) 20290 ] 20291 }, 20292 field.id 20293 )) }), 20294 !!primaryActions?.length && /* @__PURE__ */ (0, import_jsx_runtime105.jsx)( 20295 PrimaryActions, 20296 { 20297 item, 20298 actions: primaryActions, 20299 registry, 20300 buttonVariant: "secondary" 20301 } 20302 ) 20303 ] 20304 } 20305 ), 20306 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu 20307 // there if there are any actions at all. 20308 isMobileViewport && // At the same time, only show the menu if there are actions to show. 20309 eligibleActions.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime105.jsx)("div", { className: "dataviews-view-activity__item-actions", children: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)( 20310 ItemActions, 20311 { 20312 item, 20313 actions: eligibleActions, 20314 isCompact: true 20315 } 20316 ) }) 20317 ] }) 20318 } 20319 ); 20320 } 20321 var activity_item_default = ActivityItem; 20322 20323 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-items.mjs 20324 var import_react14 = __toESM(require_react(), 1); 20325 function isDefined3(item) { 20326 return !!item; 20327 } 20328 function ActivityItems(props) { 20329 const { data, fields, getItemId, view } = props; 20330 const titleField2 = fields.find((field) => field.id === view.titleField); 20331 const mediaField = fields.find((field) => field.id === view.mediaField); 20332 const descriptionField3 = fields.find( 20333 (field) => field.id === view.descriptionField 20334 ); 20335 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined3); 20336 return data.map((item, index2) => { 20337 return /* @__PURE__ */ (0, import_react14.createElement)( 20338 activity_item_default, 20339 { 20340 ...props, 20341 key: getItemId(item), 20342 item, 20343 mediaField, 20344 titleField: titleField2, 20345 descriptionField: descriptionField3, 20346 otherFields, 20347 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0 20348 } 20349 ); 20350 }); 20351 } 20352 20353 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs 20354 var import_jsx_runtime106 = __toESM(require_jsx_runtime(), 1); 20355 function ViewActivity(props) { 20356 const { empty, data, fields, isLoading, view, className } = props; 20357 const isDelayedLoading = useDelayedLoading(!!isLoading); 20358 const hasData = !!data?.length; 20359 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null; 20360 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null; 20361 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup; 20362 if (!hasData) { 20363 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)( 20364 "div", 20365 { 20366 className: clsx_default("dataviews-no-results", { 20367 "is-refreshing": isDelayedLoading 20368 }), 20369 children: empty 20370 } 20371 ); 20372 } 20373 const isInert2 = !isInfiniteScroll && !!isLoading; 20374 const wrapperClassName = clsx_default("dataviews-view-activity", className, { 20375 "is-refreshing": !isInfiniteScroll && isDelayedLoading 20376 }); 20377 const groupedEntries = dataByGroup ? Array.from(dataByGroup.entries()) : []; 20378 if (hasData && groupField && dataByGroup) { 20379 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)( 20380 Stack, 20381 { 20382 direction: "column", 20383 gap: "sm", 20384 className: wrapperClassName, 20385 inert: isInert2 ? "true" : void 0, 20386 children: groupedEntries.map( 20387 ([groupName, groupData]) => /* @__PURE__ */ (0, import_jsx_runtime106.jsx)( 20388 ActivityGroup, 20389 { 20390 groupName, 20391 groupData, 20392 groupField, 20393 showLabel: view.groupBy?.showLabel !== false, 20394 children: /* @__PURE__ */ (0, import_jsx_runtime106.jsx)( 20395 ActivityItems, 20396 { 20397 ...props, 20398 data: groupData 20399 } 20400 ) 20401 }, 20402 groupName 20403 ) 20404 ) 20405 } 20406 ); 20407 } 20408 return /* @__PURE__ */ (0, import_jsx_runtime106.jsxs)(import_jsx_runtime106.Fragment, { children: [ 20409 /* @__PURE__ */ (0, import_jsx_runtime106.jsx)( 20410 "div", 20411 { 20412 className: wrapperClassName, 20413 role: view.infiniteScrollEnabled ? "feed" : void 0, 20414 inert: isInert2 ? "true" : void 0, 20415 children: /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(ActivityItems, { ...props }) 20416 } 20417 ), 20418 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime106.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(import_components13.Spinner, {}) }) 20419 ] }); 20420 } 20421 20422 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs 20423 var import_components16 = __toESM(require_components(), 1); 20424 var import_i18n22 = __toESM(require_i18n(), 1); 20425 var import_compose8 = __toESM(require_compose(), 1); 20426 var import_element77 = __toESM(require_element(), 1); 20427 20428 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs 20429 var import_components15 = __toESM(require_components(), 1); 20430 var import_data5 = __toESM(require_data(), 1); 20431 var import_element76 = __toESM(require_element(), 1); 20432 var import_i18n21 = __toESM(require_i18n(), 1); 20433 20434 // packages/dataviews/build-module/components/dataviews-pagination/index.mjs 20435 var import_components14 = __toESM(require_components(), 1); 20436 var import_element75 = __toESM(require_element(), 1); 20437 var import_i18n20 = __toESM(require_i18n(), 1); 20438 var import_jsx_runtime107 = __toESM(require_jsx_runtime(), 1); 20439 function hasPaginationControls(view, paginationInfo) { 20440 return !view.infiniteScrollEnabled && paginationInfo.totalItems > 0 && paginationInfo.totalPages > 1; 20441 } 20442 function DataViewsPagination() { 20443 const { view, onChangeView, paginationInfo } = (0, import_element75.useContext)(dataviews_context_default); 20444 if (!hasPaginationControls(view, paginationInfo)) { 20445 return null; 20446 } 20447 const { totalPages } = paginationInfo; 20448 const currentPage = view.page ?? 1; 20449 const pageSelectOptions = Array.from(Array(totalPages)).map( 20450 (_, i2) => { 20451 const page = i2 + 1; 20452 return { 20453 value: page.toString(), 20454 label: page.toString(), 20455 "aria-label": currentPage === page ? (0, import_i18n20.sprintf)( 20456 // translators: 1: current page number. 2: total number of pages. 20457 (0, import_i18n20.__)("Page %1$d of %2$d"), 20458 currentPage, 20459 totalPages 20460 ) : page.toString() 20461 }; 20462 } 20463 ); 20464 return /* @__PURE__ */ (0, import_jsx_runtime107.jsxs)( 20465 Stack, 20466 { 20467 direction: "row", 20468 className: "dataviews-pagination", 20469 justify: "end", 20470 align: "center", 20471 gap: "xl", 20472 children: [ 20473 /* @__PURE__ */ (0, import_jsx_runtime107.jsx)( 20474 Stack, 20475 { 20476 direction: "row", 20477 justify: "flex-start", 20478 align: "center", 20479 gap: "xs", 20480 className: "dataviews-pagination__page-select", 20481 children: (0, import_element75.createInterpolateElement)( 20482 (0, import_i18n20.sprintf)( 20483 // translators: 1: Current page number, 2: Total number of pages. 20484 (0, import_i18n20._x)("<div>Page</div>%1$s<div>of %2$d</div>", "paging"), 20485 "<CurrentPage />", 20486 totalPages 20487 ), 20488 { 20489 div: /* @__PURE__ */ (0, import_jsx_runtime107.jsx)("div", { "aria-hidden": true }), 20490 // @ts-expect-error — Tag injected via sprintf argument, not visible in format string. 20491 CurrentPage: /* @__PURE__ */ (0, import_jsx_runtime107.jsx)( 20492 import_components14.SelectControl, 20493 { 20494 "aria-label": (0, import_i18n20.__)("Current page"), 20495 value: currentPage.toString(), 20496 options: pageSelectOptions, 20497 onChange: (newValue) => { 20498 onChangeView({ 20499 ...view, 20500 page: +newValue 20501 }); 20502 }, 20503 size: "small", 20504 variant: "minimal" 20505 } 20506 ) 20507 } 20508 ) 20509 } 20510 ), 20511 /* @__PURE__ */ (0, import_jsx_runtime107.jsxs)(Stack, { direction: "row", gap: "xs", align: "center", children: [ 20512 /* @__PURE__ */ (0, import_jsx_runtime107.jsx)( 20513 import_components14.Button, 20514 { 20515 onClick: () => onChangeView({ 20516 ...view, 20517 page: currentPage - 1 20518 }), 20519 disabled: currentPage === 1, 20520 accessibleWhenDisabled: true, 20521 label: (0, import_i18n20.__)("Previous page"), 20522 icon: (0, import_i18n20.isRTL)() ? next_default : previous_default, 20523 showTooltip: true, 20524 size: "compact", 20525 tooltipPosition: "top" 20526 } 20527 ), 20528 /* @__PURE__ */ (0, import_jsx_runtime107.jsx)( 20529 import_components14.Button, 20530 { 20531 onClick: () => onChangeView({ ...view, page: currentPage + 1 }), 20532 disabled: currentPage >= totalPages, 20533 accessibleWhenDisabled: true, 20534 label: (0, import_i18n20.__)("Next page"), 20535 icon: (0, import_i18n20.isRTL)() ? previous_default : next_default, 20536 showTooltip: true, 20537 size: "compact", 20538 tooltipPosition: "top" 20539 } 20540 ) 20541 ] }) 20542 ] 20543 } 20544 ); 20545 } 20546 var dataviews_pagination_default = (0, import_element75.memo)(DataViewsPagination); 20547 20548 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs 20549 var import_jsx_runtime108 = __toESM(require_jsx_runtime(), 1); 20550 function useIsMultiselectPicker(actions) { 20551 return (0, import_element76.useMemo)(() => { 20552 return !!actions?.length && actions?.every((action) => action.supportsBulk); 20553 }, [actions]); 20554 } 20555 20556 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs 20557 var import_jsx_runtime109 = __toESM(require_jsx_runtime(), 1); 20558 var { Badge: WCBadge2 } = unlock3(import_components16.privateApis); 20559 function GridItem3({ 20560 view, 20561 multiselect, 20562 selection, 20563 onChangeSelection, 20564 getItemId, 20565 item, 20566 mediaField, 20567 titleField: titleField2, 20568 descriptionField: descriptionField3, 20569 regularFields, 20570 badgeFields, 20571 config, 20572 posinset, 20573 setsize 20574 }) { 20575 const { showTitle = true, showMedia = true, showDescription = true } = view; 20576 const id = getItemId(item); 20577 const elementRef = (0, import_element77.useRef)(null); 20578 const isSelected2 = selection.includes(id); 20579 useIntersectionObserver(elementRef, posinset); 20580 const renderedMediaField = mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime109.jsx)( 20581 mediaField.render, 20582 { 20583 item, 20584 field: mediaField, 20585 config 20586 } 20587 ) : null; 20588 const renderedTitleField = showTitle && titleField2?.render ? /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(titleField2.render, { item, field: titleField2 }) : null; 20589 return /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)( 20590 import_components16.Composite.Item, 20591 { 20592 ref: elementRef, 20593 "aria-label": titleField2 ? titleField2.getValue({ item }) || (0, import_i18n22.__)("(no title)") : void 0, 20594 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(Stack, { direction: "column", children, ...props }), 20595 role: "option", 20596 "aria-posinset": posinset, 20597 "aria-setsize": setsize, 20598 className: clsx_default("dataviews-view-picker-grid__card", { 20599 "is-selected": isSelected2 20600 }), 20601 "aria-selected": isSelected2, 20602 onClick: () => { 20603 if (isSelected2) { 20604 onChangeSelection( 20605 selection.filter((itemId) => id !== itemId) 20606 ); 20607 } else { 20608 const newSelection = multiselect ? [...selection, id] : [id]; 20609 onChangeSelection(newSelection); 20610 } 20611 }, 20612 children: [ 20613 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("div", { className: "dataviews-view-picker-grid__media", children: renderedMediaField }), 20614 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)( 20615 DataViewsSelectionCheckbox, 20616 { 20617 item, 20618 selection, 20619 onChangeSelection, 20620 getItemId, 20621 titleField: titleField2, 20622 disabled: false, 20623 "aria-hidden": true, 20624 tabIndex: -1 20625 } 20626 ), 20627 showTitle && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)( 20628 Stack, 20629 { 20630 direction: "row", 20631 justify: "space-between", 20632 className: "dataviews-view-picker-grid__title-actions", 20633 children: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("div", { className: "dataviews-view-picker-grid__title-field dataviews-title-field", children: renderedTitleField }) 20634 } 20635 ), 20636 /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(Stack, { direction: "column", gap: "xs", children: [ 20637 showDescription && descriptionField3?.render && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)( 20638 descriptionField3.render, 20639 { 20640 item, 20641 field: descriptionField3 20642 } 20643 ), 20644 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)( 20645 Stack, 20646 { 20647 direction: "row", 20648 className: "dataviews-view-picker-grid__badge-fields", 20649 gap: "sm", 20650 wrap: "wrap", 20651 align: "top", 20652 justify: "flex-start", 20653 children: badgeFields.map((field) => { 20654 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)( 20655 WCBadge2, 20656 { 20657 className: "dataviews-view-picker-grid__field-value", 20658 children: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)( 20659 field.render, 20660 { 20661 item, 20662 field 20663 } 20664 ) 20665 }, 20666 field.id 20667 ); 20668 }) 20669 } 20670 ), 20671 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)( 20672 Stack, 20673 { 20674 direction: "column", 20675 className: "dataviews-view-picker-grid__fields", 20676 gap: "xs", 20677 children: regularFields.map((field) => { 20678 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)( 20679 import_components16.Flex, 20680 { 20681 className: "dataviews-view-picker-grid__field", 20682 gap: 1, 20683 justify: "flex-start", 20684 expanded: true, 20685 style: { height: "auto" }, 20686 direction: "row", 20687 children: /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(import_jsx_runtime109.Fragment, { children: [ 20688 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(import_components16.FlexItem, { className: "dataviews-view-picker-grid__field-name", children: field.header }), 20689 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)( 20690 import_components16.FlexItem, 20691 { 20692 className: "dataviews-view-picker-grid__field-value", 20693 style: { maxHeight: "none" }, 20694 children: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)( 20695 field.render, 20696 { 20697 item, 20698 field 20699 } 20700 ) 20701 } 20702 ) 20703 ] }) 20704 }, 20705 field.id 20706 ); 20707 }) 20708 } 20709 ) 20710 ] }) 20711 ] 20712 }, 20713 id 20714 ); 20715 } 20716 function GridGroup({ 20717 groupName, 20718 groupField, 20719 showLabel = true, 20720 children 20721 }) { 20722 const headerId = (0, import_compose8.useInstanceId)( 20723 GridGroup, 20724 "dataviews-view-picker-grid-group__header" 20725 ); 20726 return /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)( 20727 Stack, 20728 { 20729 direction: "column", 20730 gap: "sm", 20731 role: "group", 20732 "aria-labelledby": headerId, 20733 children: [ 20734 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)( 20735 "h3", 20736 { 20737 className: "dataviews-view-picker-grid-group__header", 20738 id: headerId, 20739 children: showLabel ? (0, import_i18n22.sprintf)( 20740 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". 20741 (0, import_i18n22.__)("%1$s: %2$s"), 20742 groupField.label, 20743 groupName 20744 ) : groupName 20745 } 20746 ), 20747 children 20748 ] 20749 }, 20750 groupName 20751 ); 20752 } 20753 function ViewPickerGrid({ 20754 actions, 20755 data, 20756 fields, 20757 getItemId, 20758 isLoading, 20759 onChangeSelection, 20760 selection, 20761 view, 20762 className, 20763 empty 20764 }) { 20765 const { resizeObserverRef, paginationInfo, itemListLabel } = (0, import_element77.useContext)(dataviews_context_default); 20766 const titleField2 = fields.find( 20767 (field) => field.id === view?.titleField 20768 ); 20769 const mediaField = fields.find( 20770 (field) => field.id === view?.mediaField 20771 ); 20772 const descriptionField3 = fields.find( 20773 (field) => field.id === view?.descriptionField 20774 ); 20775 const otherFields = view.fields ?? []; 20776 const { regularFields, badgeFields } = otherFields.reduce( 20777 (accumulator, fieldId) => { 20778 const field = fields.find((f2) => f2.id === fieldId); 20779 if (!field) { 20780 return accumulator; 20781 } 20782 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields"; 20783 accumulator[key].push(field); 20784 return accumulator; 20785 }, 20786 { regularFields: [], badgeFields: [] } 20787 ); 20788 const hasData = !!data?.length; 20789 const usedPreviewSize = view.layout?.previewSize; 20790 const isMultiselect = useIsMultiselectPicker(actions); 20791 const size4 = "900px"; 20792 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null; 20793 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null; 20794 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false; 20795 const currentPage = view?.page ?? 1; 20796 const perPage = view?.perPage ?? 0; 20797 const setSize = isInfiniteScroll ? paginationInfo?.totalItems : void 0; 20798 const gridColumns = useGridColumns(); 20799 const placeholdersNeeded = usePlaceholdersNeeded( 20800 data, 20801 isInfiniteScroll, 20802 gridColumns 20803 ); 20804 return /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(import_jsx_runtime109.Fragment, { 20805 // Render multiple groups. 20806 children: [ 20807 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)( 20808 import_components16.Composite, 20809 { 20810 virtualFocus: true, 20811 orientation: "horizontal", 20812 role: "listbox", 20813 "aria-multiselectable": isMultiselect, 20814 className: clsx_default( 20815 "dataviews-view-picker-grid", 20816 className, 20817 { 20818 [`has-$view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes( 20819 view.layout.density 20820 ) 20821 } 20822 ), 20823 "aria-label": itemListLabel, 20824 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime109.jsx)( 20825 Stack, 20826 { 20827 direction: "column", 20828 gap: "lg", 20829 children, 20830 ...props 20831 } 20832 ), 20833 children: Array.from(dataByGroup.entries()).map( 20834 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime109.jsx)( 20835 GridGroup, 20836 { 20837 groupName, 20838 groupField, 20839 showLabel: view.groupBy?.showLabel !== false, 20840 children: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)( 20841 GridItems, 20842 { 20843 previewSize: usedPreviewSize, 20844 style: { 20845 gridTemplateColumns: usedPreviewSize && `repeat(auto-fill, minmax($usedPreviewSize}px, 1fr))` 20846 }, 20847 "aria-busy": isLoading, 20848 ref: resizeObserverRef, 20849 children: groupItems.map((item) => { 20850 const posInSet = item.position ?? (currentPage - 1) * perPage + data.indexOf(item) + 1; 20851 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)( 20852 GridItem3, 20853 { 20854 view, 20855 multiselect: isMultiselect, 20856 selection, 20857 onChangeSelection, 20858 getItemId, 20859 item, 20860 mediaField, 20861 titleField: titleField2, 20862 descriptionField: descriptionField3, 20863 regularFields, 20864 badgeFields, 20865 config: { 20866 sizes: size4 20867 }, 20868 posinset: posInSet, 20869 setsize: setSize 20870 }, 20871 getItemId(item) 20872 ); 20873 }) 20874 } 20875 ) 20876 }, 20877 groupName 20878 ) 20879 ) 20880 } 20881 ), 20882 // Render a single grid with all data. 20883 hasData && !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)( 20884 import_components16.Composite, 20885 { 20886 render: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)( 20887 GridItems, 20888 { 20889 className: clsx_default( 20890 "dataviews-view-picker-grid", 20891 className, 20892 { 20893 [`has-$view.layout?.density}-density`]: view.layout?.density && [ 20894 "compact", 20895 "comfortable" 20896 ].includes(view.layout.density) 20897 } 20898 ), 20899 previewSize: usedPreviewSize, 20900 "aria-busy": isLoading, 20901 ref: resizeObserverRef 20902 } 20903 ), 20904 virtualFocus: true, 20905 orientation: "horizontal", 20906 role: "listbox", 20907 "aria-multiselectable": isMultiselect, 20908 "aria-label": itemListLabel, 20909 children: [ 20910 Array.from({ length: placeholdersNeeded }).map( 20911 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime109.jsx)( 20912 import_components16.Composite.Item, 20913 { 20914 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime109.jsx)( 20915 Stack, 20916 { 20917 direction: "column", 20918 children, 20919 ...props 20920 } 20921 ), 20922 role: "option", 20923 "aria-hidden": true, 20924 tabIndex: -1, 20925 className: "dataviews-view-picker-grid__card dataviews-view-picker-grid__placeholder" 20926 }, 20927 `placeholder-$index2}` 20928 ) 20929 ), 20930 data.map((item) => { 20931 const posinset = item.position; 20932 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)( 20933 GridItem3, 20934 { 20935 view, 20936 multiselect: isMultiselect, 20937 selection, 20938 onChangeSelection, 20939 getItemId, 20940 item, 20941 mediaField, 20942 titleField: titleField2, 20943 descriptionField: descriptionField3, 20944 regularFields, 20945 badgeFields, 20946 config: { 20947 sizes: size4 20948 }, 20949 posinset, 20950 setsize: setSize 20951 }, 20952 getItemId(item) 20953 ); 20954 }) 20955 ] 20956 } 20957 ), 20958 // Render empty state. 20959 !hasData && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)( 20960 "div", 20961 { 20962 className: clsx_default({ 20963 "dataviews-loading": isLoading, 20964 "dataviews-no-results": !isLoading 20965 }), 20966 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(import_components16.Spinner, {}) }) : empty 20967 } 20968 ), 20969 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(import_components16.Spinner, {}) }) 20970 ] 20971 }); 20972 } 20973 var picker_grid_default = ViewPickerGrid; 20974 20975 // packages/dataviews/build-module/components/dataviews-layouts/picker-table/index.mjs 20976 var import_i18n23 = __toESM(require_i18n(), 1); 20977 var import_components17 = __toESM(require_components(), 1); 20978 var import_element78 = __toESM(require_element(), 1); 20979 var import_jsx_runtime110 = __toESM(require_jsx_runtime(), 1); 20980 function TableColumnField2({ 20981 item, 20982 fields, 20983 column, 20984 align 20985 }) { 20986 const field = fields.find((f2) => f2.id === column); 20987 if (!field) { 20988 return null; 20989 } 20990 const className = clsx_default("dataviews-view-table__cell-content-wrapper", { 20991 "dataviews-view-table__cell-align-end": align === "end", 20992 "dataviews-view-table__cell-align-center": align === "center" 20993 }); 20994 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(field.render, { item, field }) }); 20995 } 20996 function TableRow2({ 20997 item, 20998 fields, 20999 id, 21000 view, 21001 titleField: titleField2, 21002 mediaField, 21003 descriptionField: descriptionField3, 21004 selection, 21005 getItemId, 21006 onChangeSelection, 21007 multiselect, 21008 posinset 21009 }) { 21010 const { paginationInfo } = (0, import_element78.useContext)(dataviews_context_default); 21011 const isSelected2 = selection.includes(id); 21012 const [isHovered, setIsHovered] = (0, import_element78.useState)(false); 21013 const elementRef = (0, import_element78.useRef)(null); 21014 useIntersectionObserver(elementRef, posinset); 21015 const { 21016 showTitle = true, 21017 showMedia = true, 21018 showDescription = true, 21019 infiniteScrollEnabled 21020 } = view; 21021 const handleMouseEnter = () => { 21022 setIsHovered(true); 21023 }; 21024 const handleMouseLeave = () => { 21025 setIsHovered(false); 21026 }; 21027 const columns = view.fields ?? []; 21028 const hasPrimaryColumn = titleField2 && showTitle || mediaField && showMedia || descriptionField3 && showDescription; 21029 return /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)( 21030 import_components17.Composite.Item, 21031 { 21032 ref: elementRef, 21033 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime110.jsx)( 21034 "tr", 21035 { 21036 className: clsx_default("dataviews-view-table__row", { 21037 "is-selected": isSelected2, 21038 "is-hovered": isHovered 21039 }), 21040 onMouseEnter: handleMouseEnter, 21041 onMouseLeave: handleMouseLeave, 21042 children, 21043 ...props 21044 } 21045 ), 21046 "aria-selected": isSelected2, 21047 "aria-setsize": paginationInfo.totalItems || void 0, 21048 "aria-posinset": posinset, 21049 role: infiniteScrollEnabled ? "article" : "option", 21050 onMouseDown: (event) => { 21051 if (event.button !== 0) { 21052 return; 21053 } 21054 event.currentTarget.parentElement?.focus({ 21055 preventScroll: true 21056 }); 21057 }, 21058 onClick: () => { 21059 if (isSelected2) { 21060 onChangeSelection( 21061 selection.filter((itemId) => id !== itemId) 21062 ); 21063 } else { 21064 const newSelection = multiselect ? [...selection, id] : [id]; 21065 onChangeSelection(newSelection); 21066 } 21067 }, 21068 children: [ 21069 /* @__PURE__ */ (0, import_jsx_runtime110.jsx)( 21070 "td", 21071 { 21072 className: "dataviews-view-table__checkbox-column", 21073 role: "presentation", 21074 children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)( 21075 DataViewsSelectionCheckbox, 21076 { 21077 item, 21078 selection, 21079 onChangeSelection, 21080 getItemId, 21081 titleField: titleField2, 21082 disabled: false, 21083 "aria-hidden": true, 21084 tabIndex: -1 21085 } 21086 ) }) 21087 } 21088 ), 21089 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime110.jsx)( 21090 "td", 21091 { 21092 role: "presentation", 21093 children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)( 21094 column_primary_default, 21095 { 21096 item, 21097 titleField: showTitle ? titleField2 : void 0, 21098 mediaField: showMedia ? mediaField : void 0, 21099 descriptionField: showDescription ? descriptionField3 : void 0, 21100 isItemClickable: () => false 21101 } 21102 ) 21103 } 21104 ), 21105 columns.map((column) => { 21106 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {}; 21107 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)( 21108 "td", 21109 { 21110 style: { 21111 width, 21112 maxWidth, 21113 minWidth 21114 }, 21115 role: "presentation", 21116 children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)( 21117 TableColumnField2, 21118 { 21119 fields, 21120 item, 21121 column, 21122 align 21123 } 21124 ) 21125 }, 21126 column 21127 ); 21128 }) 21129 ] 21130 }, 21131 id 21132 ); 21133 } 21134 function ViewPickerTable({ 21135 actions, 21136 data, 21137 fields, 21138 getItemId, 21139 isLoading = false, 21140 onChangeView, 21141 onChangeSelection, 21142 selection, 21143 setOpenedFilter, 21144 view, 21145 className, 21146 empty 21147 }) { 21148 const headerMenuRefs = (0, import_element78.useRef)(/* @__PURE__ */ new Map()); 21149 const headerMenuToFocusRef = (0, import_element78.useRef)(void 0); 21150 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element78.useState)(); 21151 const isMultiselect = useIsMultiselectPicker(actions) ?? false; 21152 (0, import_element78.useEffect)(() => { 21153 if (headerMenuToFocusRef.current) { 21154 headerMenuToFocusRef.current.focus(); 21155 headerMenuToFocusRef.current = void 0; 21156 } 21157 }); 21158 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null; 21159 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null; 21160 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup; 21161 const tableNoticeId = (0, import_element78.useId)(); 21162 if (nextHeaderMenuToFocus) { 21163 headerMenuToFocusRef.current = nextHeaderMenuToFocus; 21164 setNextHeaderMenuToFocus(void 0); 21165 return; 21166 } 21167 const onHide = (field) => { 21168 const hidden = headerMenuRefs.current.get(field.id); 21169 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0; 21170 setNextHeaderMenuToFocus(fallback?.node); 21171 }; 21172 const hasData = !!data?.length; 21173 const titleField2 = fields.find((field) => field.id === view.titleField); 21174 const mediaField = fields.find((field) => field.id === view.mediaField); 21175 const descriptionField3 = fields.find( 21176 (field) => field.id === view.descriptionField 21177 ); 21178 const { showTitle = true, showMedia = true, showDescription = true } = view; 21179 const hasPrimaryColumn = titleField2 && showTitle || mediaField && showMedia || descriptionField3 && showDescription; 21180 const columns = view.fields ?? []; 21181 const headerMenuRef = (column, index2) => (node) => { 21182 if (node) { 21183 headerMenuRefs.current.set(column, { 21184 node, 21185 fallback: columns[index2 > 0 ? index2 - 1 : 1] 21186 }); 21187 } else { 21188 headerMenuRefs.current.delete(column); 21189 } 21190 }; 21191 return /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)(import_jsx_runtime110.Fragment, { children: [ 21192 /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)( 21193 "table", 21194 { 21195 className: clsx_default( 21196 "dataviews-view-table", 21197 "dataviews-view-picker-table", 21198 className, 21199 { 21200 [`has-$view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes( 21201 view.layout.density 21202 ) 21203 } 21204 ), 21205 "aria-busy": isLoading, 21206 "aria-describedby": tableNoticeId, 21207 role: isInfiniteScroll ? "feed" : "listbox", 21208 children: [ 21209 /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("thead", { role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)( 21210 "tr", 21211 { 21212 className: "dataviews-view-table__row", 21213 role: "presentation", 21214 children: [ 21215 /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("th", { className: "dataviews-view-table__checkbox-column", children: isMultiselect && /* @__PURE__ */ (0, import_jsx_runtime110.jsx)( 21216 BulkSelectionCheckbox, 21217 { 21218 selection, 21219 onChangeSelection, 21220 data, 21221 actions, 21222 getItemId, 21223 disableSelectAll: isInfiniteScroll 21224 } 21225 ) }), 21226 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("th", { children: titleField2 && /* @__PURE__ */ (0, import_jsx_runtime110.jsx)( 21227 column_header_menu_default, 21228 { 21229 ref: headerMenuRef( 21230 titleField2.id, 21231 0 21232 ), 21233 fieldId: titleField2.id, 21234 view, 21235 fields, 21236 onChangeView, 21237 onHide, 21238 setOpenedFilter, 21239 canMove: false 21240 } 21241 ) }), 21242 columns.map((column, index2) => { 21243 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {}; 21244 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)( 21245 "th", 21246 { 21247 style: { 21248 width, 21249 maxWidth, 21250 minWidth, 21251 textAlign: align 21252 }, 21253 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0, 21254 scope: "col", 21255 children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)( 21256 column_header_menu_default, 21257 { 21258 ref: headerMenuRef(column, index2), 21259 fieldId: column, 21260 view, 21261 fields, 21262 onChangeView, 21263 onHide, 21264 setOpenedFilter, 21265 canMove: view.layout?.enableMoving ?? true 21266 } 21267 ) 21268 }, 21269 column 21270 ); 21271 }) 21272 ] 21273 } 21274 ) }), 21275 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map( 21276 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)( 21277 import_components17.Composite, 21278 { 21279 virtualFocus: true, 21280 orientation: "vertical", 21281 render: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("tbody", { role: "group" }), 21282 children: [ 21283 /* @__PURE__ */ (0, import_jsx_runtime110.jsx)( 21284 "tr", 21285 { 21286 className: "dataviews-view-table__group-header-row", 21287 role: "presentation", 21288 children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)( 21289 "td", 21290 { 21291 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + 1, 21292 className: "dataviews-view-table__group-header-cell", 21293 role: "presentation", 21294 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n23.sprintf)( 21295 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". 21296 (0, import_i18n23.__)("%1$s: %2$s"), 21297 groupField.label, 21298 groupName 21299 ) 21300 } 21301 ) 21302 } 21303 ), 21304 groupItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime110.jsx)( 21305 TableRow2, 21306 { 21307 item, 21308 fields, 21309 id: getItemId(item) || index2.toString(), 21310 view, 21311 titleField: titleField2, 21312 mediaField, 21313 descriptionField: descriptionField3, 21314 selection, 21315 getItemId, 21316 onChangeSelection, 21317 multiselect: isMultiselect 21318 }, 21319 getItemId(item) 21320 )) 21321 ] 21322 }, 21323 `group-$groupName}` 21324 ) 21325 ) : /* @__PURE__ */ (0, import_jsx_runtime110.jsx)( 21326 import_components17.Composite, 21327 { 21328 render: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("tbody", { role: "presentation" }), 21329 virtualFocus: true, 21330 orientation: "vertical", 21331 children: hasData && data.map((item, index2) => { 21332 const itemId = getItemId(item); 21333 const posinset = item.position; 21334 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)( 21335 TableRow2, 21336 { 21337 item, 21338 fields, 21339 id: itemId || index2.toString(), 21340 view, 21341 titleField: titleField2, 21342 mediaField, 21343 descriptionField: descriptionField3, 21344 selection, 21345 getItemId, 21346 onChangeSelection, 21347 multiselect: isMultiselect, 21348 posinset 21349 }, 21350 itemId 21351 ); 21352 }) 21353 } 21354 ) 21355 ] 21356 } 21357 ), 21358 /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)( 21359 "div", 21360 { 21361 className: clsx_default({ 21362 "dataviews-loading": isLoading, 21363 "dataviews-no-results": !hasData && !isLoading 21364 }), 21365 id: tableNoticeId, 21366 children: [ 21367 !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(import_components17.Spinner, {}) }) : empty), 21368 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(import_components17.Spinner, {}) }) 21369 ] 21370 } 21371 ) 21372 ] }); 21373 } 21374 var picker_table_default = ViewPickerTable; 21375 21376 // packages/dataviews/build-module/components/dataviews-layouts/picker-activity/index.mjs 21377 var import_components18 = __toESM(require_components(), 1); 21378 var import_element79 = __toESM(require_element(), 1); 21379 var import_compose9 = __toESM(require_compose(), 1); 21380 var import_i18n24 = __toESM(require_i18n(), 1); 21381 var import_jsx_runtime111 = __toESM(require_jsx_runtime(), 1); 21382 function isDefined4(item) { 21383 return !!item; 21384 } 21385 function PickerActivityItem({ 21386 view, 21387 multiselect, 21388 selection, 21389 onChangeSelection, 21390 getItemId, 21391 item, 21392 titleField: titleField2, 21393 mediaField, 21394 descriptionField: descriptionField3, 21395 otherFields, 21396 posinset, 21397 setsize 21398 }) { 21399 const elementRef = (0, import_element79.useRef)(null); 21400 useIntersectionObserver(elementRef, posinset); 21401 const { showTitle = true, showMedia = true, showDescription = true } = view; 21402 const id = getItemId(item); 21403 const isSelected2 = selection.includes(id); 21404 const density = view.layout?.density ?? "balanced"; 21405 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime111.jsx)( 21406 mediaField.render, 21407 { 21408 item, 21409 field: mediaField, 21410 config: { 21411 sizes: density === "comfortable" ? "32px" : "24px" 21412 } 21413 } 21414 ) : null; 21415 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("div", { className: "dataviews-view-picker-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime111.jsx)( 21416 "span", 21417 { 21418 className: "dataviews-view-picker-activity__item-bullet", 21419 "aria-hidden": "true" 21420 } 21421 ) }); 21422 const renderedTitleField = showTitle && titleField2?.render ? /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(titleField2.render, { item, field: titleField2 }) : null; 21423 const renderedDescriptionField = showDescription && descriptionField3?.render ? /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(descriptionField3.render, { item, field: descriptionField3 }) : null; 21424 const verticalGap = (0, import_element79.useMemo)(() => { 21425 switch (density) { 21426 case "comfortable": 21427 return "md"; 21428 default: 21429 return "sm"; 21430 } 21431 }, [density]); 21432 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)( 21433 import_components18.Composite.Item, 21434 { 21435 ref: elementRef, 21436 role: "option", 21437 "aria-label": titleField2 ? titleField2.getValue({ item }) || void 0 : void 0, 21438 "aria-posinset": posinset, 21439 "aria-setsize": setsize, 21440 "aria-selected": isSelected2, 21441 className: clsx_default( 21442 "dataviews-view-picker-activity__item", 21443 density === "compact" && "is-compact", 21444 density === "balanced" && "is-balanced", 21445 density === "comfortable" && "is-comfortable", 21446 isSelected2 && "is-selected" 21447 ), 21448 onClick: () => { 21449 if (isSelected2) { 21450 onChangeSelection( 21451 selection.filter((itemId) => id !== itemId) 21452 ); 21453 } else { 21454 const newSelection = multiselect ? [...selection, id] : [id]; 21455 onChangeSelection(newSelection); 21456 } 21457 }, 21458 render: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("div", {}), 21459 children: /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [ 21460 /* @__PURE__ */ (0, import_jsx_runtime111.jsx)( 21461 Stack, 21462 { 21463 direction: "column", 21464 gap: "xs", 21465 align: "center", 21466 className: "dataviews-view-picker-activity__item-type", 21467 children: renderedMediaField 21468 } 21469 ), 21470 /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)( 21471 Stack, 21472 { 21473 direction: "column", 21474 gap: verticalGap, 21475 align: "flex-start", 21476 className: "dataviews-view-picker-activity__item-content", 21477 children: [ 21478 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("div", { className: "dataviews-view-picker-activity__item-title", children: renderedTitleField }), 21479 renderedDescriptionField && /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("div", { className: "dataviews-view-picker-activity__item-description", children: renderedDescriptionField }), 21480 /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("div", { className: "dataviews-view-picker-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)( 21481 "div", 21482 { 21483 className: "dataviews-view-picker-activity__item-field", 21484 children: [ 21485 /* @__PURE__ */ (0, import_jsx_runtime111.jsx)( 21486 VisuallyHidden, 21487 { 21488 render: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("span", {}), 21489 className: "dataviews-view-picker-activity__item-field-label", 21490 children: field.label 21491 } 21492 ), 21493 /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("span", { className: "dataviews-view-picker-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)( 21494 field.render, 21495 { 21496 item, 21497 field 21498 } 21499 ) }) 21500 ] 21501 }, 21502 field.id 21503 )) }) 21504 ] 21505 } 21506 ) 21507 ] }) 21508 } 21509 ); 21510 } 21511 function PickerActivityGroup({ 21512 groupName, 21513 groupField, 21514 showLabel = true, 21515 children 21516 }) { 21517 const headerId = (0, import_compose9.useInstanceId)( 21518 PickerActivityGroup, 21519 "dataviews-view-picker-activity-group__header" 21520 ); 21521 return /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)( 21522 Stack, 21523 { 21524 direction: "column", 21525 role: "group", 21526 "aria-labelledby": headerId, 21527 className: "dataviews-view-picker-activity-group", 21528 children: [ 21529 /* @__PURE__ */ (0, import_jsx_runtime111.jsx)( 21530 "h3", 21531 { 21532 className: "dataviews-view-picker-activity-group__header", 21533 id: headerId, 21534 children: showLabel ? (0, import_i18n24.sprintf)( 21535 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". 21536 (0, import_i18n24.__)("%1$s: %2$s"), 21537 groupField.label, 21538 groupName 21539 ) : groupName 21540 } 21541 ), 21542 children 21543 ] 21544 } 21545 ); 21546 } 21547 function ViewPickerActivity({ 21548 data, 21549 fields, 21550 getItemId, 21551 isLoading, 21552 onChangeSelection, 21553 selection, 21554 view, 21555 actions, 21556 className, 21557 empty 21558 }) { 21559 const { itemListLabel, paginationInfo } = (0, import_element79.useContext)(dataviews_context_default); 21560 const isMultiselect = useIsMultiselectPicker(actions); 21561 const titleField2 = fields.find( 21562 (field) => field.id === view?.titleField 21563 ); 21564 const mediaField = fields.find( 21565 (field) => field.id === view?.mediaField 21566 ); 21567 const descriptionField3 = fields.find( 21568 (field) => field.id === view?.descriptionField 21569 ); 21570 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined4); 21571 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null; 21572 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null; 21573 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false; 21574 const setsize = isInfiniteScroll ? paginationInfo?.totalItems : void 0; 21575 const hasData = !!data?.length; 21576 const isGrouped = !!(groupField && dataByGroup); 21577 const renderItem = (item) => /* @__PURE__ */ (0, import_jsx_runtime111.jsx)( 21578 PickerActivityItem, 21579 { 21580 view, 21581 multiselect: isMultiselect, 21582 selection, 21583 onChangeSelection, 21584 getItemId, 21585 item, 21586 titleField: titleField2, 21587 mediaField, 21588 descriptionField: descriptionField3, 21589 otherFields, 21590 posinset: item.position, 21591 setsize 21592 }, 21593 getItemId(item) 21594 ); 21595 if (!hasData) { 21596 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)( 21597 "div", 21598 { 21599 className: clsx_default({ 21600 "dataviews-loading": isLoading, 21601 "dataviews-no-results": !isLoading 21602 }), 21603 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(import_components18.Spinner, {}) }) : empty 21604 } 21605 ); 21606 } 21607 return /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)(import_jsx_runtime111.Fragment, { children: [ 21608 /* @__PURE__ */ (0, import_jsx_runtime111.jsx)( 21609 import_components18.Composite, 21610 { 21611 virtualFocus: true, 21612 orientation: "vertical", 21613 role: "listbox", 21614 "aria-multiselectable": isMultiselect, 21615 "aria-label": itemListLabel, 21616 "aria-busy": isLoading, 21617 render: isGrouped ? /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(Stack, { direction: "column", gap: "sm" }) : void 0, 21618 className: clsx_default( 21619 "dataviews-view-picker-activity", 21620 className 21621 ), 21622 children: isGrouped && dataByGroup ? Array.from(dataByGroup.entries()).map( 21623 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime111.jsx)( 21624 PickerActivityGroup, 21625 { 21626 groupName, 21627 groupField, 21628 showLabel: view.groupBy?.showLabel !== false, 21629 children: groupItems.map(renderItem) 21630 }, 21631 groupName 21632 ) 21633 ) : data.map(renderItem) 21634 } 21635 ), 21636 isLoading && /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(import_components18.Spinner, {}) }) 21637 ] }); 21638 } 21639 21640 // packages/dataviews/build-module/components/dataviews-layouts/utils/density-picker.mjs 21641 var import_components19 = __toESM(require_components(), 1); 21642 var import_i18n25 = __toESM(require_i18n(), 1); 21643 var import_element80 = __toESM(require_element(), 1); 21644 var import_jsx_runtime112 = __toESM(require_jsx_runtime(), 1); 21645 function DensityPicker() { 21646 const context = (0, import_element80.useContext)(dataviews_context_default); 21647 const view = context.view; 21648 return /* @__PURE__ */ (0, import_jsx_runtime112.jsxs)( 21649 import_components19.__experimentalToggleGroupControl, 21650 { 21651 label: (0, import_i18n25.__)("Density"), 21652 value: view.layout?.density || "balanced", 21653 onChange: (value) => { 21654 context.onChangeView({ 21655 ...view, 21656 layout: { 21657 ...view.layout, 21658 density: value 21659 } 21660 }); 21661 }, 21662 isBlock: true, 21663 children: [ 21664 /* @__PURE__ */ (0, import_jsx_runtime112.jsx)( 21665 import_components19.__experimentalToggleGroupControlOption, 21666 { 21667 value: "comfortable", 21668 label: (0, import_i18n25._x)( 21669 "Comfortable", 21670 "Density option for DataView layout" 21671 ) 21672 }, 21673 "comfortable" 21674 ), 21675 /* @__PURE__ */ (0, import_jsx_runtime112.jsx)( 21676 import_components19.__experimentalToggleGroupControlOption, 21677 { 21678 value: "balanced", 21679 label: (0, import_i18n25._x)("Balanced", "Density option for DataView layout") 21680 }, 21681 "balanced" 21682 ), 21683 /* @__PURE__ */ (0, import_jsx_runtime112.jsx)( 21684 import_components19.__experimentalToggleGroupControlOption, 21685 { 21686 value: "compact", 21687 label: (0, import_i18n25._x)("Compact", "Density option for DataView layout") 21688 }, 21689 "compact" 21690 ) 21691 ] 21692 } 21693 ); 21694 } 21695 21696 // packages/dataviews/build-module/components/dataviews-layouts/utils/preview-size-picker.mjs 21697 var import_components20 = __toESM(require_components(), 1); 21698 var import_i18n26 = __toESM(require_i18n(), 1); 21699 var import_element81 = __toESM(require_element(), 1); 21700 var import_jsx_runtime113 = __toESM(require_jsx_runtime(), 1); 21701 var imageSizes2 = [ 21702 { 21703 value: 120, 21704 breakpoint: 1 21705 }, 21706 { 21707 value: 170, 21708 breakpoint: 1 21709 }, 21710 { 21711 value: 230, 21712 breakpoint: 1 21713 }, 21714 { 21715 value: 290, 21716 breakpoint: 1112 21717 // at minimum image width, 4 images display at this container size 21718 }, 21719 { 21720 value: 350, 21721 breakpoint: 1636 21722 // at minimum image width, 6 images display at this container size 21723 }, 21724 { 21725 value: 430, 21726 breakpoint: 588 21727 // at minimum image width, 2 images display at this container size 21728 } 21729 ]; 21730 function PreviewSizePicker() { 21731 const context = (0, import_element81.useContext)(dataviews_context_default); 21732 const view = context.view; 21733 const breakValues = imageSizes2.filter((size4) => { 21734 return context.containerWidth >= size4.breakpoint; 21735 }); 21736 const layoutPreviewSize = view.layout?.previewSize ?? 230; 21737 const previewSizeToUse = breakValues.map((size4, index2) => ({ ...size4, index: index2 })).filter((size4) => size4.value <= layoutPreviewSize).sort((a2, b2) => b2.value - a2.value)[0]?.index ?? 0; 21738 const marks = breakValues.map((size4, index2) => { 21739 return { 21740 value: index2 21741 }; 21742 }); 21743 return /* @__PURE__ */ (0, import_jsx_runtime113.jsx)( 21744 import_components20.RangeControl, 21745 { 21746 showTooltip: false, 21747 label: (0, import_i18n26.__)("Preview size"), 21748 value: previewSizeToUse, 21749 min: 0, 21750 max: breakValues.length - 1, 21751 withInputField: false, 21752 onChange: (value = 0) => { 21753 context.onChangeView({ 21754 ...view, 21755 layout: { 21756 ...view.layout, 21757 previewSize: breakValues[value].value 21758 } 21759 }); 21760 }, 21761 step: 1, 21762 marks 21763 } 21764 ); 21765 } 21766 21767 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-config-options.mjs 21768 var import_jsx_runtime114 = __toESM(require_jsx_runtime(), 1); 21769 function GridConfigOptions() { 21770 return /* @__PURE__ */ (0, import_jsx_runtime114.jsxs)(import_jsx_runtime114.Fragment, { children: [ 21771 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(DensityPicker, {}), 21772 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(PreviewSizePicker, {}) 21773 ] }); 21774 } 21775 21776 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs 21777 var VIEW_LAYOUTS = [ 21778 { 21779 type: LAYOUT_TABLE, 21780 label: (0, import_i18n27.__)("Table"), 21781 component: table_default, 21782 icon: block_table_default, 21783 viewConfigOptions: DensityPicker 21784 }, 21785 { 21786 type: LAYOUT_GRID, 21787 label: (0, import_i18n27.__)("Grid"), 21788 component: grid_default, 21789 icon: category_default, 21790 viewConfigOptions: GridConfigOptions 21791 }, 21792 { 21793 type: LAYOUT_LIST, 21794 label: (0, import_i18n27.__)("List"), 21795 component: ViewList, 21796 icon: (0, import_i18n27.isRTL)() ? format_list_bullets_rtl_default : format_list_bullets_default, 21797 viewConfigOptions: DensityPicker 21798 }, 21799 { 21800 type: LAYOUT_ACTIVITY, 21801 label: (0, import_i18n27.__)("Activity"), 21802 component: ViewActivity, 21803 icon: scheduled_default, 21804 viewConfigOptions: DensityPicker 21805 }, 21806 { 21807 type: LAYOUT_PICKER_GRID, 21808 label: (0, import_i18n27.__)("Grid"), 21809 component: picker_grid_default, 21810 icon: category_default, 21811 viewConfigOptions: GridConfigOptions, 21812 isPicker: true 21813 }, 21814 { 21815 type: LAYOUT_PICKER_TABLE, 21816 label: (0, import_i18n27.__)("Table"), 21817 component: picker_table_default, 21818 icon: block_table_default, 21819 viewConfigOptions: DensityPicker, 21820 isPicker: true 21821 }, 21822 { 21823 type: LAYOUT_PICKER_ACTIVITY, 21824 label: (0, import_i18n27.__)("Activity"), 21825 component: ViewPickerActivity, 21826 icon: scheduled_default, 21827 viewConfigOptions: DensityPicker, 21828 isPicker: true 21829 } 21830 ]; 21831 21832 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs 21833 var import_element89 = __toESM(require_element(), 1); 21834 21835 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs 21836 var import_components23 = __toESM(require_components(), 1); 21837 var import_i18n30 = __toESM(require_i18n(), 1); 21838 var import_element86 = __toESM(require_element(), 1); 21839 21840 // node_modules/@ariakit/react-components/dist/focusable/focusable-context.js 21841 var import_react15 = __toESM(require_react(), 1); 21842 var FocusableContext = (0, import_react15.createContext)(true); 21843 21844 // node_modules/@ariakit/utils/dist/index.js 21845 function toArray(arg) { 21846 if (Array.isArray(arg)) return arg; 21847 return typeof arg !== "undefined" ? [arg] : []; 21848 } 21849 function flatten2DArray(array) { 21850 const flattened = []; 21851 for (const row of array) flattened.push(...row); 21852 return flattened; 21853 } 21854 function reverseArray(array) { 21855 return array.slice().reverse(); 21856 } 21857 function noop4(..._) { 21858 } 21859 function hasOwnProperty(object, prop) { 21860 if (typeof Object.hasOwn === "function") return Object.hasOwn(object, prop); 21861 return Object.prototype.hasOwnProperty.call(object, prop); 21862 } 21863 function chain(...fns) { 21864 return (...args) => { 21865 for (const fn of fns) if (typeof fn === "function") fn(...args); 21866 }; 21867 } 21868 function normalizeString(str) { 21869 return str.normalize("NFD").replace(/[\u0300-\u036f]/g, ""); 21870 } 21871 function omit(object, keys) { 21872 const result = { ...object }; 21873 for (const key of keys) if (hasOwnProperty(result, key)) delete result[key]; 21874 return result; 21875 } 21876 function pick(object, paths) { 21877 const result = {}; 21878 for (const key of paths) if (hasOwnProperty(object, key)) result[key] = object[key]; 21879 return result; 21880 } 21881 function identity(value) { 21882 return value; 21883 } 21884 function afterPaint(cb = noop4) { 21885 let raf = requestAnimationFrame(() => { 21886 raf = requestAnimationFrame(cb); 21887 }); 21888 return () => cancelAnimationFrame(raf); 21889 } 21890 function invariant(condition, message2) { 21891 if (condition) return; 21892 if (typeof message2 !== "string") throw new Error("Invariant failed"); 21893 throw new Error(message2); 21894 } 21895 function getKeys(obj) { 21896 return Object.keys(obj); 21897 } 21898 function isFalsyBooleanCallback(booleanOrCallback, ...args) { 21899 const result = typeof booleanOrCallback === "function" ? booleanOrCallback(...args) : booleanOrCallback; 21900 if (result == null) return false; 21901 return !result; 21902 } 21903 function disabledFromProps(props) { 21904 return props.disabled || props["aria-disabled"] === true || props["aria-disabled"] === "true"; 21905 } 21906 function removeUndefinedValues(obj) { 21907 const result = {}; 21908 for (const key in obj) if (obj[key] !== void 0) result[key] = obj[key]; 21909 return result; 21910 } 21911 function defaultValue(...values) { 21912 for (const value of values) if (value !== void 0) return value; 21913 } 21914 var canUseDOM = checkIsBrowser(); 21915 function checkIsBrowser() { 21916 return typeof window !== "undefined" && !!window.document?.createElement; 21917 } 21918 function getDocument(node) { 21919 if (!node) return document; 21920 if ("self" in node) return node.document; 21921 return node.ownerDocument || document; 21922 } 21923 function getActiveElement(node, activeDescendant = false) { 21924 const { activeElement: activeElement2 } = getDocument(node); 21925 if (!activeElement2?.nodeName) return null; 21926 if (isFrame(activeElement2) && activeElement2.contentDocument?.body) return getActiveElement(activeElement2.contentDocument.body, activeDescendant); 21927 if (activeDescendant) { 21928 const id = activeElement2.getAttribute("aria-activedescendant"); 21929 if (id) { 21930 const element = getDocument(activeElement2).getElementById(id); 21931 if (element) return element; 21932 } 21933 } 21934 return activeElement2; 21935 } 21936 function contains2(parent, child) { 21937 return parent === child || parent.contains(child); 21938 } 21939 function isElement2(target) { 21940 return target?.nodeType === 1; 21941 } 21942 function isNode2(target) { 21943 return typeof target?.nodeType === "number"; 21944 } 21945 function isFrame(element) { 21946 return element.tagName === "IFRAME"; 21947 } 21948 function isButton(element) { 21949 const tagName = element.tagName.toLowerCase(); 21950 if (tagName === "button") return true; 21951 if (tagName === "input" && element.type) return buttonInputTypes.indexOf(element.type) !== -1; 21952 return false; 21953 } 21954 var buttonInputTypes = [ 21955 "button", 21956 "color", 21957 "file", 21958 "image", 21959 "reset", 21960 "submit" 21961 ]; 21962 function isVisible(element) { 21963 if (typeof element.checkVisibility === "function") return element.checkVisibility(); 21964 const htmlElement = element; 21965 return htmlElement.offsetWidth > 0 || htmlElement.offsetHeight > 0 || element.getClientRects().length > 0; 21966 } 21967 function isTextField(element) { 21968 try { 21969 if (element.tagName === "TEXTAREA") return true; 21970 if (element.tagName !== "INPUT") return false; 21971 return element.selectionStart !== null; 21972 } catch (_error) { 21973 return false; 21974 } 21975 } 21976 function isTextbox(element) { 21977 return element.isContentEditable || isTextField(element); 21978 } 21979 function getTextboxValue(element) { 21980 if (isTextField(element)) return element.value; 21981 if (element.isContentEditable) { 21982 const range = getDocument(element).createRange(); 21983 range.selectNodeContents(element); 21984 return range.toString(); 21985 } 21986 return ""; 21987 } 21988 function getTextboxSelection(element) { 21989 let start = 0; 21990 let end = 0; 21991 if (isTextField(element)) { 21992 start = element.selectionStart || 0; 21993 end = element.selectionEnd || 0; 21994 } else if (element.isContentEditable) { 21995 const selection = getDocument(element).getSelection(); 21996 if (selection?.rangeCount && selection.anchorNode && contains2(element, selection.anchorNode) && selection.focusNode && contains2(element, selection.focusNode)) { 21997 const range = selection.getRangeAt(0); 21998 const nextRange = range.cloneRange(); 21999 nextRange.selectNodeContents(element); 22000 nextRange.setEnd(range.startContainer, range.startOffset); 22001 start = nextRange.toString().length; 22002 nextRange.setEnd(range.endContainer, range.endOffset); 22003 end = nextRange.toString().length; 22004 } 22005 } 22006 return { 22007 start, 22008 end 22009 }; 22010 } 22011 var allowedPopupRoles = [ 22012 "dialog", 22013 "menu", 22014 "listbox", 22015 "tree", 22016 "grid" 22017 ]; 22018 var itemRoleByPopupRole = { 22019 menu: "menuitem", 22020 listbox: "option", 22021 tree: "treeitem" 22022 }; 22023 function getPopupRole(element, fallback) { 22024 const role = element?.getAttribute("role"); 22025 if (role && allowedPopupRoles.indexOf(role) !== -1) return role; 22026 return fallback; 22027 } 22028 function getItemRoleByPopupRole(popupRole) { 22029 if (popupRole == null) return; 22030 if (!hasOwnProperty(itemRoleByPopupRole, popupRole)) return; 22031 return itemRoleByPopupRole[popupRole]; 22032 } 22033 function getScrollingElement(element) { 22034 if (!element) return null; 22035 const isScrollableOverflow = (overflow) => { 22036 if (overflow === "auto") return true; 22037 if (overflow === "scroll") return true; 22038 return false; 22039 }; 22040 if (element.clientHeight && element.scrollHeight > element.clientHeight) { 22041 const { overflowY } = getComputedStyle(element); 22042 if (isScrollableOverflow(overflowY)) return element; 22043 } else if (element.clientWidth && element.scrollWidth > element.clientWidth) { 22044 const { overflowX } = getComputedStyle(element); 22045 if (isScrollableOverflow(overflowX)) return element; 22046 } 22047 const doc = getDocument(element); 22048 return getScrollingElement(element.parentElement) || doc.scrollingElement || doc.body; 22049 } 22050 function setSelectionRange(element, ...args) { 22051 if (/text|search|password|tel|url/i.test(element.type)) element.setSelectionRange(...args); 22052 } 22053 function sortBasedOnDOMPosition(items, getElement) { 22054 const pairs = items.map((item, index2) => [index2, item]); 22055 let isOrderDifferent = false; 22056 pairs.sort(([indexA, a2], [indexB, b2]) => { 22057 const elementA = getElement(a2); 22058 const elementB = getElement(b2); 22059 if (elementA === elementB) return 0; 22060 if (!elementA || !elementB) return 0; 22061 if (isElementPreceding(elementA, elementB)) { 22062 if (indexA > indexB) isOrderDifferent = true; 22063 return -1; 22064 } 22065 if (indexA < indexB) isOrderDifferent = true; 22066 return 1; 22067 }); 22068 if (isOrderDifferent) return pairs.map(([_, item]) => item); 22069 return items; 22070 } 22071 function isElementPreceding(a2, b2) { 22072 return Boolean(b2.compareDocumentPosition(a2) & Node.DOCUMENT_POSITION_PRECEDING); 22073 } 22074 function isTouchDevice() { 22075 return canUseDOM && !!navigator.maxTouchPoints; 22076 } 22077 function isApple() { 22078 if (!canUseDOM) return false; 22079 return /mac|iphone|ipad|ipod/i.test(navigator.platform); 22080 } 22081 function isSafari() { 22082 return canUseDOM && isApple() && /apple/i.test(navigator.vendor); 22083 } 22084 function isFirefox() { 22085 return canUseDOM && /firefox\//i.test(navigator.userAgent); 22086 } 22087 function isPortalEvent(event) { 22088 const { currentTarget, target } = event; 22089 if (!currentTarget) return false; 22090 if (!isNode2(target)) return true; 22091 return !contains2(currentTarget, target); 22092 } 22093 function isSelfTarget(event) { 22094 return event.target === event.currentTarget; 22095 } 22096 function isActivatableNavigationTarget(element) { 22097 if (!isElement2(element)) return false; 22098 const target = element; 22099 const tagName = target.tagName.toLowerCase(); 22100 if (tagName === "a") return true; 22101 if (tagName === "button" && target.type === "submit") return true; 22102 if (tagName === "input" && target.type === "submit") return true; 22103 return false; 22104 } 22105 function isOpeningInNewTab(event) { 22106 const isAppleDevice = isApple(); 22107 if (isAppleDevice && !event.metaKey) return false; 22108 if (!isAppleDevice && !event.ctrlKey) return false; 22109 return isActivatableNavigationTarget(event.currentTarget); 22110 } 22111 function isDownloading(event) { 22112 if (!event.altKey) return false; 22113 return isActivatableNavigationTarget(event.currentTarget); 22114 } 22115 function fireBlurEvent(element, eventInit) { 22116 const event = new FocusEvent("blur", eventInit); 22117 const defaultAllowed = element.dispatchEvent(event); 22118 const bubbleInit = { 22119 ...eventInit, 22120 bubbles: true 22121 }; 22122 element.dispatchEvent(new FocusEvent("focusout", bubbleInit)); 22123 return defaultAllowed; 22124 } 22125 function fireKeyboardEvent(element, type, eventInit) { 22126 const event = new KeyboardEvent(type, eventInit); 22127 return element.dispatchEvent(event); 22128 } 22129 function fireClickEvent(element, eventInit) { 22130 const event = new MouseEvent("click", eventInit); 22131 return element.dispatchEvent(event); 22132 } 22133 function isFocusEventOutside(event, container) { 22134 const containerElement = container || event.currentTarget; 22135 const relatedTarget = event.relatedTarget; 22136 return !isNode2(relatedTarget) || !contains2(containerElement, relatedTarget); 22137 } 22138 function isInputEvent(event) { 22139 return event.type === "input"; 22140 } 22141 function queueBeforeEvent(element, type, callback, timeout) { 22142 const createTimer = (callback2) => { 22143 if (timeout) { 22144 const timerId2 = setTimeout(callback2, timeout); 22145 return () => clearTimeout(timerId2); 22146 } 22147 const timerId = requestAnimationFrame(callback2); 22148 return () => cancelAnimationFrame(timerId); 22149 }; 22150 const cancelTimer = createTimer(() => { 22151 element.removeEventListener(type, callSync, true); 22152 callback(); 22153 }); 22154 const callSync = () => { 22155 cancelTimer(); 22156 callback(); 22157 }; 22158 element.addEventListener(type, callSync, { 22159 once: true, 22160 capture: true 22161 }); 22162 return () => { 22163 cancelTimer(); 22164 element.removeEventListener(type, callSync, true); 22165 }; 22166 } 22167 function addGlobalEventListener(type, listener, options, scope = window) { 22168 const children = []; 22169 try { 22170 scope.document.addEventListener(type, listener, options); 22171 for (const frame of Array.from(scope.frames)) children.push(addGlobalEventListener(type, listener, options, frame)); 22172 } catch { 22173 } 22174 const removeEventListener = () => { 22175 try { 22176 scope.document.removeEventListener(type, listener, options); 22177 } catch { 22178 } 22179 for (const remove of children) remove(); 22180 }; 22181 return removeEventListener; 22182 } 22183 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'])"; 22184 function isFocusable(element) { 22185 if (!element.matches(selector)) return false; 22186 if (!isVisible(element)) return false; 22187 if (element.closest("[inert]")) return false; 22188 return true; 22189 } 22190 function hasFocus(element) { 22191 const activeElement2 = getActiveElement(element); 22192 if (!activeElement2) return false; 22193 if (activeElement2 === element) return true; 22194 const activeDescendant = activeElement2.getAttribute("aria-activedescendant"); 22195 if (!activeDescendant) return false; 22196 return activeDescendant === element.id; 22197 } 22198 function hasFocusWithin(element) { 22199 const activeElement2 = getActiveElement(element); 22200 if (!activeElement2) return false; 22201 if (contains2(element, activeElement2)) return true; 22202 const activeDescendant = activeElement2.getAttribute("aria-activedescendant"); 22203 if (!activeDescendant) return false; 22204 if (!("id" in element)) return false; 22205 if (activeDescendant === element.id) return true; 22206 return !!element.querySelector(`#$CSS.escape(activeDescendant)}`); 22207 } 22208 function focusIntoView(element, options) { 22209 if (!("scrollIntoView" in element)) element.focus(); 22210 else { 22211 element.focus({ preventScroll: true }); 22212 element.scrollIntoView({ 22213 block: "nearest", 22214 inline: "nearest", 22215 ...options 22216 }); 22217 } 22218 } 22219 function createUndoCallback(callback) { 22220 return async () => { 22221 const redo = await callback?.(); 22222 return createUndoCallback(async () => { 22223 await redo?.(); 22224 return callback; 22225 }); 22226 }; 22227 } 22228 var UndoManager = createUndoManager(); 22229 function createUndoManager({ limit = 100 } = {}) { 22230 const undoStack = []; 22231 let redoStack = []; 22232 let currentGroup = null; 22233 const canUndo = () => undoStack.length > 0; 22234 const canRedo = () => redoStack.length > 0; 22235 const undo = async () => { 22236 if (!canUndo()) return; 22237 currentGroup = null; 22238 redoStack.push(await undoStack.pop()?.()); 22239 }; 22240 const redo = async () => { 22241 if (!canRedo()) return; 22242 currentGroup = null; 22243 undoStack.push(await redoStack.pop()?.()); 22244 }; 22245 const execute = async (callback, group) => { 22246 if (!callback) return; 22247 const sameGroup = group === currentGroup; 22248 currentGroup = group ?? null; 22249 const nextIndex = sameGroup ? Math.max(0, undoStack.length - 1) : undoStack.length; 22250 const undoCallback = await callback(); 22251 if (!undoCallback) return; 22252 redoStack = []; 22253 const currentUndo = undoStack[nextIndex]; 22254 undoStack[nextIndex] = createUndoCallback(async () => { 22255 await undoCallback?.(); 22256 const currentRedo = await currentUndo?.(); 22257 return async () => { 22258 await currentRedo?.(); 22259 await callback?.(); 22260 }; 22261 }); 22262 while (undoStack.length > limit) undoStack.shift(); 22263 }; 22264 return { 22265 canUndo, 22266 canRedo, 22267 undo, 22268 redo, 22269 execute 22270 }; 22271 } 22272 22273 // node_modules/@ariakit/react-utils/dist/index.js 22274 var React82 = __toESM(require_react(), 1); 22275 var import_react16 = __toESM(require_react(), 1); 22276 var import_jsx_runtime115 = __toESM(require_jsx_runtime(), 1); 22277 function setRef(ref, value) { 22278 if (typeof ref === "function") { 22279 const cleanup = ref(value); 22280 if (typeof cleanup === "function") return cleanup; 22281 } else if (ref) ref.current = value; 22282 } 22283 function isValidElementWithRef(element) { 22284 if (!element) return false; 22285 if (!(0, import_react16.isValidElement)(element)) return false; 22286 if ("ref" in element.props) return true; 22287 if ("ref" in element) return true; 22288 return false; 22289 } 22290 function getRefProperty(element) { 22291 if (!isValidElementWithRef(element)) return null; 22292 return { ...element.props }.ref || element.ref; 22293 } 22294 function mergeProps2(base, overrides) { 22295 const props = { ...base }; 22296 for (const key in overrides) { 22297 if (!hasOwnProperty(overrides, key)) continue; 22298 if (key === "className") { 22299 const prop = "className"; 22300 const baseClass = base[prop]; 22301 const overrideClass = overrides[prop]; 22302 if (baseClass && overrideClass) props[prop] = `$baseClass} $overrideClass}`; 22303 else props[prop] = overrideClass || baseClass; 22304 continue; 22305 } 22306 if (key === "style") { 22307 const prop = "style"; 22308 props[prop] = base[prop] ? { 22309 ...base[prop], 22310 ...overrides[prop] 22311 } : overrides[prop]; 22312 continue; 22313 } 22314 const overrideValue = overrides[key]; 22315 if (key.startsWith("on")) { 22316 if (typeof overrideValue !== "function") continue; 22317 const baseValue = base[key]; 22318 if (typeof baseValue === "function") { 22319 props[key] = (...args) => { 22320 overrideValue(...args); 22321 baseValue(...args); 22322 }; 22323 continue; 22324 } 22325 } 22326 props[key] = overrideValue; 22327 } 22328 return props; 22329 } 22330 var _React = { ...React82 }; 22331 var useReactId = _React.useId; 22332 var useReactDeferredValue = _React.useDeferredValue; 22333 var useReactInsertionEffect = _React.useInsertionEffect; 22334 var useSafeLayoutEffect = canUseDOM ? import_react16.useLayoutEffect : import_react16.useEffect; 22335 function useInitialValue(value) { 22336 const [initialValue] = (0, import_react16.useState)(value); 22337 return initialValue; 22338 } 22339 function useLiveRef(value) { 22340 const ref = (0, import_react16.useRef)(value); 22341 useSafeLayoutEffect(() => { 22342 ref.current = value; 22343 }); 22344 return ref; 22345 } 22346 function useEvent(callback) { 22347 const ref = (0, import_react16.useRef)(() => { 22348 throw new Error("Cannot call an event handler while rendering."); 22349 }); 22350 if (useReactInsertionEffect) useReactInsertionEffect(() => { 22351 ref.current = callback; 22352 }); 22353 else ref.current = callback; 22354 return (0, import_react16.useCallback)((...args) => ref.current?.(...args), []); 22355 } 22356 function useTransactionState(callback) { 22357 const [state, setState] = (0, import_react16.useState)(null); 22358 useSafeLayoutEffect(() => { 22359 if (state == null) return; 22360 if (!callback) return; 22361 let prevState = null; 22362 callback((prev) => { 22363 prevState = prev; 22364 return state; 22365 }); 22366 return () => { 22367 callback(prevState); 22368 }; 22369 }, [state, callback]); 22370 return [state, setState]; 22371 } 22372 function useMergeRefs3(...refs) { 22373 return (0, import_react16.useMemo)(() => { 22374 if (!refs.some(Boolean)) return; 22375 return (value) => { 22376 const refEffects = []; 22377 for (const ref of refs) { 22378 if (!ref) continue; 22379 const cleanup = setRef(ref, value); 22380 refEffects.push({ 22381 ref, 22382 cleanup: typeof cleanup === "function" ? cleanup : void 0 22383 }); 22384 } 22385 if (!refEffects.some((effect) => effect.cleanup)) return; 22386 return () => { 22387 for (const { ref, cleanup } of refEffects) if (cleanup) cleanup(); 22388 else setRef(ref, null); 22389 }; 22390 }; 22391 }, refs); 22392 } 22393 function useId5(defaultId) { 22394 if (useReactId) { 22395 const reactId = useReactId(); 22396 if (defaultId) return defaultId; 22397 return reactId; 22398 } 22399 const [id, setId] = (0, import_react16.useState)(defaultId); 22400 useSafeLayoutEffect(() => { 22401 if (defaultId || id) return; 22402 setId(`id-$Math.random().toString(36).slice(2, 8)}`); 22403 }, [defaultId, id]); 22404 return defaultId || id; 22405 } 22406 function useTagName(refOrElement, type) { 22407 const stringOrUndefined = (type2) => { 22408 if (typeof type2 !== "string") return; 22409 return type2; 22410 }; 22411 const [tagName, setTagName] = (0, import_react16.useState)(() => stringOrUndefined(type)); 22412 useSafeLayoutEffect(() => { 22413 setTagName((refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement)?.tagName.toLowerCase() || stringOrUndefined(type)); 22414 }, [refOrElement, type]); 22415 return tagName; 22416 } 22417 function useAttribute(refOrElement, attributeName, defaultValue2) { 22418 const initialValue = useInitialValue(defaultValue2); 22419 const [attribute, setAttribute] = (0, import_react16.useState)(initialValue); 22420 (0, import_react16.useEffect)(() => { 22421 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement; 22422 if (!element) return; 22423 const callback = () => { 22424 const value = element.getAttribute(attributeName); 22425 setAttribute(value == null ? initialValue : value); 22426 }; 22427 const observer = new MutationObserver(callback); 22428 observer.observe(element, { attributeFilter: [attributeName] }); 22429 callback(); 22430 return () => observer.disconnect(); 22431 }, [ 22432 refOrElement, 22433 attributeName, 22434 initialValue 22435 ]); 22436 return attribute; 22437 } 22438 function useUpdateEffect(effect, deps) { 22439 const mounted = (0, import_react16.useRef)(false); 22440 (0, import_react16.useEffect)(() => { 22441 if (mounted.current) return effect(); 22442 mounted.current = true; 22443 }, deps); 22444 (0, import_react16.useEffect)(() => () => { 22445 mounted.current = false; 22446 }, []); 22447 } 22448 function useUpdateLayoutEffect(effect, deps) { 22449 const mounted = (0, import_react16.useRef)(false); 22450 useSafeLayoutEffect(() => { 22451 if (mounted.current) return effect(); 22452 mounted.current = true; 22453 }, deps); 22454 useSafeLayoutEffect(() => () => { 22455 mounted.current = false; 22456 }, []); 22457 } 22458 function useForceUpdate() { 22459 return (0, import_react16.useReducer)(() => [], []); 22460 } 22461 function useBooleanEvent(booleanOrCallback) { 22462 return useEvent(typeof booleanOrCallback === "function" ? booleanOrCallback : () => booleanOrCallback); 22463 } 22464 function useWrapElement(props, callback, deps = []) { 22465 const wrapElement = (0, import_react16.useCallback)((element) => { 22466 if (props.wrapElement) element = props.wrapElement(element); 22467 return callback(element); 22468 }, [...deps, props.wrapElement]); 22469 return { 22470 ...props, 22471 wrapElement 22472 }; 22473 } 22474 function useMetadataProps(props, key, value) { 22475 const parent = props.onLoadedMetadataCapture; 22476 const onLoadedMetadataCapture = (0, import_react16.useMemo)(() => { 22477 return Object.assign(() => { 22478 }, parent, ...value !== void 0 ? [{ [key]: value }] : []); 22479 }, [ 22480 parent, 22481 key, 22482 value 22483 ]); 22484 return [parent?.[key], { onLoadedMetadataCapture }]; 22485 } 22486 var hasInstalledGlobalEventListeners = false; 22487 function useIsMouseMoving() { 22488 (0, import_react16.useEffect)(() => { 22489 if (hasInstalledGlobalEventListeners) return; 22490 addGlobalEventListener("mousemove", setMouseMoving, true); 22491 addGlobalEventListener("mousedown", resetMouseMoving, true); 22492 addGlobalEventListener("mouseup", resetMouseMoving, true); 22493 addGlobalEventListener("keydown", resetMouseMoving, true); 22494 addGlobalEventListener("scroll", resetMouseMoving, true); 22495 hasInstalledGlobalEventListeners = true; 22496 }, []); 22497 return useEvent(() => mouseMoving); 22498 } 22499 var mouseMoving = false; 22500 var previousScreenX = 0; 22501 var previousScreenY = 0; 22502 function hasMouseMovement(event) { 22503 const movementX = event.movementX || event.screenX - previousScreenX; 22504 const movementY = event.movementY || event.screenY - previousScreenY; 22505 previousScreenX = event.screenX; 22506 previousScreenY = event.screenY; 22507 return movementX || movementY || false; 22508 } 22509 function setMouseMoving(event) { 22510 if (!hasMouseMovement(event)) return; 22511 mouseMoving = true; 22512 } 22513 function resetMouseMoving() { 22514 mouseMoving = false; 22515 } 22516 function forwardRef70(render4) { 22517 const Role = React82.forwardRef((props, ref) => render4({ 22518 ...props, 22519 ref 22520 })); 22521 Role.displayName = render4.displayName || render4.name; 22522 return Role; 22523 } 22524 function memo3(Component, propsAreEqual) { 22525 return React82.memo(Component, propsAreEqual); 22526 } 22527 function createElement3(Type, props) { 22528 const { wrapElement, render: render4, ...rest } = props; 22529 const mergedRef = useMergeRefs3(props.ref, getRefProperty(render4)); 22530 let element; 22531 if (React82.isValidElement(render4)) { 22532 const renderProps = { 22533 ...render4.props, 22534 ref: mergedRef 22535 }; 22536 element = React82.cloneElement(render4, mergeProps2(rest, renderProps)); 22537 } else if (render4) element = render4(rest); 22538 else element = /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(Type, { ...rest }); 22539 if (wrapElement) return wrapElement(element); 22540 return element; 22541 } 22542 function createHook(useProps) { 22543 const useRole = (props = {}) => { 22544 return useProps(props); 22545 }; 22546 useRole.displayName = useProps.name; 22547 return useRole; 22548 } 22549 function createStoreContext(providers = [], scopedProviders = []) { 22550 const context = React82.createContext(void 0); 22551 const scopedContext = React82.createContext(void 0); 22552 const useContext53 = () => React82.useContext(context); 22553 const useScopedContext = (onlyScoped = false) => { 22554 const scoped = React82.useContext(scopedContext); 22555 const store = useContext53(); 22556 if (onlyScoped) return scoped; 22557 return scoped || store; 22558 }; 22559 const useProviderContext = () => { 22560 const scoped = React82.useContext(scopedContext); 22561 const store = useContext53(); 22562 if (scoped && scoped === store) return; 22563 return store; 22564 }; 22565 const ContextProvider = (props) => { 22566 return providers.reduceRight((children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(Provider2, { 22567 ...props, 22568 children 22569 }), /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(context.Provider, { ...props })); 22570 }; 22571 const ScopedContextProvider = (props) => { 22572 return /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(ContextProvider, { 22573 ...props, 22574 children: scopedProviders.reduceRight((children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(Provider2, { 22575 ...props, 22576 children 22577 }), /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(scopedContext.Provider, { ...props })) 22578 }); 22579 }; 22580 return { 22581 context, 22582 scopedContext, 22583 useContext: useContext53, 22584 useScopedContext, 22585 useProviderContext, 22586 ContextProvider, 22587 ScopedContextProvider 22588 }; 22589 } 22590 22591 // node_modules/@ariakit/react-components/dist/focusable/focusable.js 22592 var import_react17 = __toESM(require_react(), 1); 22593 var TagName = "div"; 22594 var accessibleWhenDisabledSymbol = /* @__PURE__ */ Symbol("accessibleWhenDisabled"); 22595 var isSafariBrowser = isSafari(); 22596 var alwaysFocusVisibleInputTypes = [ 22597 "text", 22598 "search", 22599 "url", 22600 "tel", 22601 "email", 22602 "password", 22603 "number", 22604 "date", 22605 "month", 22606 "week", 22607 "time", 22608 "datetime", 22609 "datetime-local" 22610 ]; 22611 function isAlwaysFocusVisible(element) { 22612 const { tagName, readOnly, type } = element; 22613 if (tagName === "TEXTAREA" && !readOnly) return true; 22614 if (tagName === "SELECT" && !readOnly) return true; 22615 if (tagName === "INPUT" && !readOnly) return alwaysFocusVisibleInputTypes.includes(type); 22616 if (element.isContentEditable) return true; 22617 if (element.getAttribute("role") === "combobox" && element.dataset.name) return true; 22618 return false; 22619 } 22620 function isNativeTabbable(tagName) { 22621 if (!tagName) return true; 22622 return tagName === "button" || tagName === "summary" || tagName === "input" || tagName === "select" || tagName === "textarea" || tagName === "a"; 22623 } 22624 function supportsDisabledAttribute(tagName) { 22625 if (!tagName) return true; 22626 return tagName === "button" || tagName === "input" || tagName === "select" || tagName === "textarea"; 22627 } 22628 function isNativeSubmitControl(element) { 22629 if (element.tagName === "BUTTON") { 22630 const { type } = element; 22631 return type === "submit"; 22632 } 22633 if (element.tagName === "INPUT") { 22634 const { type } = element; 22635 return type === "submit" || type === "image"; 22636 } 22637 return false; 22638 } 22639 function getTabIndex4({ focusable: focusable2, trulyDisabled, nativeTabbable, supportsDisabled, safariTabIndex, tabIndexProp }) { 22640 if (!focusable2) return tabIndexProp; 22641 if (trulyDisabled) { 22642 if (nativeTabbable && !supportsDisabled) return -1; 22643 return; 22644 } 22645 if (nativeTabbable) { 22646 if (safariTabIndex && tabIndexProp == null) return 0; 22647 return tabIndexProp; 22648 } 22649 return tabIndexProp ?? 0; 22650 } 22651 function useDisableEvent(onEvent, disabled2) { 22652 return useEvent((event) => { 22653 onEvent?.(event); 22654 if (event.defaultPrevented) return; 22655 if (disabled2) { 22656 event.stopPropagation(); 22657 event.preventDefault(); 22658 } 22659 }); 22660 } 22661 var hasInstalledGlobalEventListeners2 = false; 22662 var isKeyboardModality = true; 22663 function onGlobalMouseDown(event) { 22664 const target = event.target; 22665 if (isElement2(target) && !target.hasAttribute("data-focus-visible")) isKeyboardModality = false; 22666 } 22667 function onGlobalKeyDown(event) { 22668 if (event.metaKey) return; 22669 if (event.ctrlKey) return; 22670 if (event.altKey) return; 22671 isKeyboardModality = true; 22672 } 22673 var useFocusable = createHook(function useFocusable2({ focusable: focusable2 = true, accessibleWhenDisabled, autoFocus, onFocusVisible, ...props }) { 22674 const ref = (0, import_react17.useRef)(null); 22675 const [parentAccessibleWhenDisabled, metadataProps] = useMetadataProps(props, accessibleWhenDisabledSymbol, accessibleWhenDisabled); 22676 accessibleWhenDisabled ??= parentAccessibleWhenDisabled; 22677 (0, import_react17.useEffect)(() => { 22678 if (!focusable2) return; 22679 if (hasInstalledGlobalEventListeners2) return; 22680 addGlobalEventListener("mousedown", onGlobalMouseDown, true); 22681 addGlobalEventListener("keydown", onGlobalKeyDown, true); 22682 hasInstalledGlobalEventListeners2 = true; 22683 }, [focusable2]); 22684 const disabled2 = focusable2 && disabledFromProps(props); 22685 const trulyDisabled = disabled2 && !accessibleWhenDisabled; 22686 const [focusVisible, setFocusVisible] = (0, import_react17.useState)(false); 22687 const focusVisibleRef = (0, import_react17.useRef)(false); 22688 const nativeSubmitObserverCleanupRef = (0, import_react17.useRef)(null); 22689 const cleanupFocusVisible = useEvent((element) => { 22690 nativeSubmitObserverCleanupRef.current?.(); 22691 nativeSubmitObserverCleanupRef.current = null; 22692 focusVisibleRef.current = false; 22693 element?.removeAttribute("data-focus-visible"); 22694 }); 22695 (0, import_react17.useEffect)(() => { 22696 if (!focusable2) return; 22697 if (!trulyDisabled) return; 22698 cleanupFocusVisible(ref.current); 22699 if (focusVisible) setFocusVisible(false); 22700 }, [ 22701 focusable2, 22702 trulyDisabled, 22703 focusVisible, 22704 cleanupFocusVisible 22705 ]); 22706 (0, import_react17.useEffect)(() => { 22707 if (!focusable2) return; 22708 if (!focusVisible) return; 22709 const element = ref.current; 22710 if (!element) return; 22711 if (typeof IntersectionObserver === "undefined") return; 22712 const observer = new IntersectionObserver(() => { 22713 if (!isFocusable(element)) { 22714 focusVisibleRef.current = false; 22715 setFocusVisible(false); 22716 } 22717 }); 22718 observer.observe(element); 22719 return () => observer.disconnect(); 22720 }, [focusable2, focusVisible]); 22721 (0, import_react17.useEffect)(() => { 22722 return () => nativeSubmitObserverCleanupRef.current?.(); 22723 }, []); 22724 const onKeyPressCapture = useDisableEvent(props.onKeyPressCapture, disabled2); 22725 const onMouseDownCapture = useDisableEvent(props.onMouseDownCapture, disabled2); 22726 const onClickCapture = useDisableEvent(props.onClickCapture, disabled2); 22727 const handleFocusVisible = (event, currentTarget) => { 22728 if (currentTarget) event.currentTarget = currentTarget; 22729 if (!focusable2) return; 22730 const element = event.currentTarget; 22731 if (!element) return; 22732 if (!hasFocus(element)) return; 22733 onFocusVisible?.(event); 22734 if (event.defaultPrevented) return; 22735 element.dataset.focusVisible = "true"; 22736 focusVisibleRef.current = true; 22737 if (isNativeSubmitControl(element)) { 22738 nativeSubmitObserverCleanupRef.current?.(); 22739 nativeSubmitObserverCleanupRef.current = null; 22740 if (typeof IntersectionObserver !== "undefined") { 22741 const observer = new IntersectionObserver(() => { 22742 if (isFocusable(element)) return; 22743 cleanupFocusVisible(element); 22744 }); 22745 observer.observe(element); 22746 nativeSubmitObserverCleanupRef.current = () => observer.disconnect(); 22747 } 22748 return; 22749 } 22750 setFocusVisible(true); 22751 }; 22752 const onKeyDownCaptureProp = props.onKeyDownCapture; 22753 const onKeyDownCapture = useEvent((event) => { 22754 onKeyDownCaptureProp?.(event); 22755 if (event.defaultPrevented) return; 22756 if (!focusable2) return; 22757 if (focusVisible) return; 22758 if (focusVisibleRef.current) return; 22759 if (event.metaKey) return; 22760 if (event.altKey) return; 22761 if (event.ctrlKey) return; 22762 if (!isSelfTarget(event)) return; 22763 const element = event.currentTarget; 22764 const applyFocusVisible = () => handleFocusVisible(event, element); 22765 queueBeforeEvent(element, "focusout", applyFocusVisible); 22766 }); 22767 const onFocusCaptureProp = props.onFocusCapture; 22768 const onFocusCapture = useEvent((event) => { 22769 onFocusCaptureProp?.(event); 22770 if (event.defaultPrevented) return; 22771 if (!focusable2) return; 22772 if (!isSelfTarget(event)) { 22773 setFocusVisible(false); 22774 return; 22775 } 22776 const element = event.currentTarget; 22777 const applyFocusVisible = () => handleFocusVisible(event, element); 22778 if (isKeyboardModality || isAlwaysFocusVisible(event.target)) queueBeforeEvent(event.target, "focusout", applyFocusVisible); 22779 else setFocusVisible(false); 22780 }); 22781 const onBlurProp = props.onBlur; 22782 const onBlur = useEvent((event) => { 22783 onBlurProp?.(event); 22784 if (!focusable2) return; 22785 if (!isFocusEventOutside(event)) return; 22786 cleanupFocusVisible(event.currentTarget); 22787 setFocusVisible(false); 22788 }); 22789 const autoFocusOnShow = (0, import_react17.useContext)(FocusableContext); 22790 const autoFocusRef = useEvent((element) => { 22791 if (!focusable2) return; 22792 if (!autoFocus) return; 22793 if (!element) return; 22794 if (!autoFocusOnShow) return; 22795 queueMicrotask(() => { 22796 if (hasFocus(element)) return; 22797 if (!isFocusable(element)) return; 22798 element.focus(); 22799 }); 22800 }); 22801 const tagName = useTagName(ref); 22802 const nativeTabbable = focusable2 && isNativeTabbable(tagName); 22803 const supportsDisabled = focusable2 && supportsDisabledAttribute(tagName); 22804 const [safariTabIndex, setSafariTabIndex] = (0, import_react17.useState)(false); 22805 if (isSafariBrowser) (0, import_react17.useEffect)(() => { 22806 if (!focusable2) return; 22807 const element = ref.current; 22808 if (!element) return; 22809 const { type } = element; 22810 const isNativeCheckboxOrRadio = element.tagName === "INPUT" && (type === "checkbox" || type === "radio"); 22811 setSafariTabIndex(isButton(element) || isNativeCheckboxOrRadio); 22812 }, [focusable2]); 22813 const styleProp = props.style; 22814 const style = (0, import_react17.useMemo)(() => { 22815 if (trulyDisabled) return { 22816 pointerEvents: "none", 22817 ...styleProp 22818 }; 22819 return styleProp; 22820 }, [trulyDisabled, styleProp]); 22821 props = { 22822 "data-focus-visible": focusable2 && focusVisible || void 0, 22823 "data-autofocus": autoFocus || void 0, 22824 "aria-disabled": disabled2 || void 0, 22825 ...props, 22826 ...metadataProps, 22827 ref: useMergeRefs3(ref, autoFocusRef, props.ref), 22828 style, 22829 tabIndex: getTabIndex4({ 22830 focusable: focusable2, 22831 trulyDisabled, 22832 nativeTabbable, 22833 supportsDisabled, 22834 safariTabIndex, 22835 tabIndexProp: props.tabIndex 22836 }), 22837 disabled: supportsDisabled && trulyDisabled ? true : void 0, 22838 contentEditable: disabled2 ? void 0 : props.contentEditable, 22839 onKeyPressCapture, 22840 onClickCapture, 22841 onMouseDownCapture, 22842 onKeyDownCapture, 22843 onFocusCapture, 22844 onBlur 22845 }; 22846 return removeUndefinedValues(props); 22847 }); 22848 var Focusable = forwardRef70(function Focusable2(props) { 22849 return createElement3(TagName, useFocusable(props)); 22850 }); 22851 22852 // node_modules/@ariakit/react-components/dist/command/command.js 22853 var import_react18 = __toESM(require_react(), 1); 22854 var TagName2 = "button"; 22855 function isNativeClick(event) { 22856 if (!event.isTrusted) return false; 22857 const element = event.currentTarget; 22858 if (event.key === "Enter") return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "A"; 22859 if (event.key === " ") return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "INPUT" || element.tagName === "SELECT"; 22860 return false; 22861 } 22862 var symbol = /* @__PURE__ */ Symbol("command"); 22863 var useCommand = createHook(function useCommand2({ clickOnEnter = true, clickOnSpace = true, ...props }) { 22864 const ref = (0, import_react18.useRef)(null); 22865 const [isNativeButton, setIsNativeButton] = (0, import_react18.useState)(false); 22866 (0, import_react18.useEffect)(() => { 22867 if (!ref.current) return; 22868 setIsNativeButton(isButton(ref.current)); 22869 }, []); 22870 const [active, setActive] = (0, import_react18.useState)(false); 22871 const activeRef = (0, import_react18.useRef)(false); 22872 const disabled2 = disabledFromProps(props); 22873 const [isDuplicate, metadataProps] = useMetadataProps(props, symbol, true); 22874 useSafeLayoutEffect(() => { 22875 if (!disabled2) return; 22876 activeRef.current = false; 22877 setActive(false); 22878 }, [disabled2]); 22879 const onKeyDownProp = props.onKeyDown; 22880 const onKeyDown = useEvent((event) => { 22881 onKeyDownProp?.(event); 22882 const element = event.currentTarget; 22883 if (event.defaultPrevented) return; 22884 if (isDuplicate) return; 22885 if (disabled2) return; 22886 if (!isSelfTarget(event)) return; 22887 if (isTextField(element)) return; 22888 if (element.isContentEditable) return; 22889 const isEnter = clickOnEnter && event.key === "Enter"; 22890 const isSpace = clickOnSpace && event.key === " "; 22891 const shouldPreventEnter = event.key === "Enter" && !clickOnEnter; 22892 const shouldPreventSpace = event.key === " " && !clickOnSpace; 22893 if (shouldPreventEnter || shouldPreventSpace) { 22894 event.preventDefault(); 22895 return; 22896 } 22897 if (isEnter || isSpace) { 22898 const nativeClick = isNativeClick(event); 22899 if (isEnter) { 22900 if (!nativeClick) { 22901 event.preventDefault(); 22902 const { view, ...eventInit } = event; 22903 const click = () => fireClickEvent(element, eventInit); 22904 if (isFirefox()) queueBeforeEvent(element, "keyup", click); 22905 else queueMicrotask(click); 22906 } 22907 } else if (isSpace) { 22908 activeRef.current = true; 22909 if (!nativeClick) { 22910 event.preventDefault(); 22911 setActive(true); 22912 } 22913 } 22914 } 22915 }); 22916 const onKeyUpProp = props.onKeyUp; 22917 const onKeyUp = useEvent((event) => { 22918 onKeyUpProp?.(event); 22919 if (isDuplicate) return; 22920 const isSpace = clickOnSpace && event.key === " "; 22921 if (!activeRef.current || !isSpace) return; 22922 const nativeClick = isNativeClick(event); 22923 activeRef.current = false; 22924 if (!nativeClick) setActive(false); 22925 if (event.defaultPrevented) return; 22926 if (!isSelfTarget(event)) return; 22927 if (disabled2) return; 22928 if (event.metaKey) return; 22929 if (nativeClick) return; 22930 event.preventDefault(); 22931 const element = event.currentTarget; 22932 const { view, ...eventInit } = event; 22933 queueMicrotask(() => fireClickEvent(element, eventInit)); 22934 }); 22935 const onBlurProp = props.onBlur; 22936 const onBlur = useEvent((event) => { 22937 onBlurProp?.(event); 22938 if (!activeRef.current) return; 22939 activeRef.current = false; 22940 setActive(false); 22941 }); 22942 props = { 22943 "data-active": active || void 0, 22944 type: isNativeButton ? "button" : void 0, 22945 ...metadataProps, 22946 ...props, 22947 ref: useMergeRefs3(ref, props.ref), 22948 onKeyDown, 22949 onKeyUp, 22950 onBlur 22951 }; 22952 props = useFocusable(props); 22953 return props; 22954 }); 22955 var Command = forwardRef70(function Command2(props) { 22956 return createElement3(TagName2, useCommand(props)); 22957 }); 22958 22959 // node_modules/@ariakit/react-components/dist/collection/collection-context.js 22960 var ctx = createStoreContext(); 22961 var useCollectionContext = ctx.useContext; 22962 var useCollectionScopedContext = ctx.useScopedContext; 22963 var useCollectionProviderContext = ctx.useProviderContext; 22964 var CollectionContextProvider = ctx.ContextProvider; 22965 var CollectionScopedContextProvider = ctx.ScopedContextProvider; 22966 22967 // node_modules/@ariakit/react-components/dist/collection/collection-item.js 22968 var import_react19 = __toESM(require_react(), 1); 22969 var TagName3 = "div"; 22970 var useCollectionItem = createHook(function useCollectionItem2({ store, shouldRegisterItem = true, getItem = identity, element, ...props }) { 22971 const context = useCollectionContext(); 22972 store = store || context; 22973 const id = useId5(props.id); 22974 const ref = (0, import_react19.useRef)(element); 22975 (0, import_react19.useEffect)(() => { 22976 const element2 = ref.current; 22977 if (!id) return; 22978 if (!element2) return; 22979 if (!shouldRegisterItem) return; 22980 const item = getItem({ 22981 id, 22982 element: element2 22983 }); 22984 return store?.renderItem(item); 22985 }, [ 22986 id, 22987 shouldRegisterItem, 22988 getItem, 22989 store 22990 ]); 22991 props = { 22992 ...props, 22993 ref: useMergeRefs3(ref, props.ref) 22994 }; 22995 return removeUndefinedValues(props); 22996 }); 22997 var CollectionItem = forwardRef70(function CollectionItem2(props) { 22998 return createElement3(TagName3, useCollectionItem(props)); 22999 }); 23000 23001 // node_modules/@ariakit/react-components/dist/composite/composite-context.js 23002 var import_react20 = __toESM(require_react(), 1); 23003 var ctx2 = createStoreContext([CollectionContextProvider], [CollectionScopedContextProvider]); 23004 var useCompositeContext = ctx2.useContext; 23005 var useCompositeScopedContext = ctx2.useScopedContext; 23006 var useCompositeProviderContext = ctx2.useProviderContext; 23007 var CompositeContextProvider = ctx2.ContextProvider; 23008 var CompositeScopedContextProvider = ctx2.ScopedContextProvider; 23009 var CompositeItemContext = (0, import_react20.createContext)(void 0); 23010 var CompositeRowContext = (0, import_react20.createContext)(void 0); 23011 23012 // node_modules/@ariakit/store/dist/index.js 23013 function getInternal(store, key) { 23014 const internals = store.__unstableInternals; 23015 invariant(internals, "Invalid store"); 23016 return internals[key]; 23017 } 23018 function hasUpdatedKey(keys, updatedKey) { 23019 if (!keys) return true; 23020 for (const currentKey of keys) if (updatedKey instanceof Set) { 23021 if (updatedKey.has(currentKey)) return true; 23022 } else if (currentKey === updatedKey) return true; 23023 return false; 23024 } 23025 function isSameValue(value, other) { 23026 return value === other || value !== value && other !== other; 23027 } 23028 function getCleanupPrevState(prevState, state, stateBeforeCleanup, updatedKey) { 23029 let cleanupPrevState; 23030 for (const key of getKeys(state)) { 23031 if (isSameValue(state[key], stateBeforeCleanup[key])) continue; 23032 if (updatedKey !== void 0 && hasUpdatedKey([key], updatedKey)) continue; 23033 cleanupPrevState ??= { ...prevState }; 23034 cleanupPrevState[key] = state[key]; 23035 } 23036 return cleanupPrevState; 23037 } 23038 var MAX_REPAIR_PASSES = 100; 23039 function addKeyedListener(map, keys, listener) { 23040 if (!keys) return; 23041 for (const key of keys) { 23042 let listeners = map.get(key); 23043 if (!listeners) { 23044 listeners = /* @__PURE__ */ new Set(); 23045 map.set(key, listeners); 23046 } 23047 listeners.add(listener); 23048 } 23049 } 23050 function deleteKeyedListener(map, keys, listener) { 23051 if (!map) return; 23052 if (!keys) return; 23053 for (const key of keys) { 23054 const listeners = map.get(key); 23055 if (!listeners) continue; 23056 listeners.delete(listener); 23057 if (!listeners.size) map.delete(key); 23058 } 23059 } 23060 function getFastPathNotifiedListeners(frame) { 23061 const notifiedListeners = /* @__PURE__ */ new Set(); 23062 const currentListener = frame.currentListener; 23063 if (!currentListener) return notifiedListeners; 23064 for (const listener of frame.keyedListeners) { 23065 notifiedListeners.add(listener); 23066 if (listener === currentListener) return notifiedListeners; 23067 } 23068 notifiedListeners.clear(); 23069 notifiedListeners.add(currentListener); 23070 return notifiedListeners; 23071 } 23072 function preserveFastPathNotifiedListeners(frame) { 23073 frame.notifiedListeners ??= getFastPathNotifiedListeners(frame); 23074 } 23075 function hasFastPathPassedListener(frame, listener) { 23076 if (!frame.currentListener) return false; 23077 let foundCurrentKeyedListener = false; 23078 for (const currentListener of frame.keyedListeners) { 23079 if (currentListener === frame.currentListener) { 23080 foundCurrentKeyedListener = true; 23081 continue; 23082 } 23083 if (!foundCurrentKeyedListener) continue; 23084 if (currentListener === listener) return false; 23085 } 23086 let foundListener = false; 23087 for (const currentListener of frame.group.listeners) { 23088 if (currentListener === frame.currentListener) return foundListener; 23089 if (currentListener === listener) foundListener = true; 23090 } 23091 return false; 23092 } 23093 function preserveFastPathFrames(fastPathFrames, group, listener) { 23094 for (const frame of fastPathFrames) { 23095 if (frame.group !== group) continue; 23096 if (frame.recovering) continue; 23097 if (listener && !frame.keyedListeners.has(listener)) continue; 23098 preserveFastPathNotifiedListeners(frame); 23099 for (const currentListener of frame.group.listeners) { 23100 if (currentListener === frame.currentListener) break; 23101 if (!hasFastPathPassedListener(frame, currentListener)) continue; 23102 frame.notifiedListeners?.add(currentListener); 23103 } 23104 } 23105 } 23106 function preserveFastPathPassedListeners(fastPathFrames, group, listener) { 23107 for (const frame of fastPathFrames) { 23108 if (frame.group !== group) continue; 23109 if (frame.recovering) continue; 23110 if (!hasFastPathPassedListener(frame, listener)) continue; 23111 preserveFastPathNotifiedListeners(frame); 23112 frame.notifiedListeners?.add(listener); 23113 } 23114 } 23115 function preserveFastPathPassedKeyedListeners({ fastPathFrames, group, keys, listener }) { 23116 const wasRegistered = group.listeners.has(listener); 23117 for (const frame of fastPathFrames) { 23118 if (frame.group !== group) continue; 23119 if (frame.recovering) continue; 23120 if (!keys.includes(frame.updatedKey)) continue; 23121 if (hasFastPathPassedListener(frame, listener)) { 23122 preserveFastPathNotifiedListeners(frame); 23123 frame.notifiedListeners?.add(listener); 23124 } else if (wasRegistered) { 23125 preserveFastPathNotifiedListeners(frame); 23126 frame.recoverToLive = true; 23127 } 23128 } 23129 } 23130 function clearFastPathNotifiedListener(fastPathFrames, group, listener) { 23131 for (const frame of fastPathFrames) { 23132 if (frame.group !== group) continue; 23133 frame.notifiedListeners?.delete(listener); 23134 } 23135 } 23136 function addFastPathKeyedListener({ fastPathFrames, group, keys, listener }) { 23137 for (const frame of fastPathFrames) { 23138 if (frame.group !== group) continue; 23139 if (frame.recovering) continue; 23140 if (!keys.includes(frame.updatedKey)) continue; 23141 frame.keyedListeners.add(listener); 23142 } 23143 } 23144 function runPendingCleanup(group, listener) { 23145 if (!group.disposables.size) return; 23146 const cleanup = group.disposables.get(listener); 23147 if (!cleanup) return; 23148 group.disposables.delete(listener); 23149 cleanup(); 23150 } 23151 function setListenerCleanup(group, listener, cleanup) { 23152 const currentCleanup = group.disposables.get(listener); 23153 if (!currentCleanup) { 23154 group.disposables.set(listener, cleanup); 23155 return; 23156 } 23157 group.disposables.set(listener, () => { 23158 currentCleanup(); 23159 cleanup(); 23160 }); 23161 } 23162 function notifyStoreListener(group, listener, state, prevState, getState, updatedKey) { 23163 if (group.suspendCounts?.has(listener)) return; 23164 const { disposables } = group; 23165 const cleanup = disposables.size ? disposables.get(listener) : void 0; 23166 if (cleanup) { 23167 disposables.delete(listener); 23168 const stateBeforeCleanup = state; 23169 cleanup(); 23170 state = getState?.() ?? state; 23171 if (state !== stateBeforeCleanup) prevState = getCleanupPrevState(prevState, state, stateBeforeCleanup, updatedKey) ?? prevState; 23172 } 23173 const result = listener(state, prevState); 23174 if (result) setListenerCleanup(group, listener, result); 23175 } 23176 function runLiveListeners({ group, getState, prevState, updatedKey, notifiedListeners }) { 23177 const allKeysListeners = group.allKeysListeners; 23178 for (const listener of group.listeners) { 23179 if (notifiedListeners?.has(listener)) continue; 23180 if (!allKeysListeners?.has(listener)) { 23181 if (!hasUpdatedKey(group.listenerKeys.get(listener), updatedKey)) continue; 23182 } 23183 notifiedListeners?.add(listener); 23184 notifyStoreListener(group, listener, getState(), prevState, getState, updatedKey); 23185 } 23186 } 23187 function createStore(initialState, ...stores) { 23188 let state = initialState; 23189 let prevStateBatch = state; 23190 let destroy = noop4; 23191 let batchPending = false; 23192 let inDispatch = false; 23193 let updatedKeys = /* @__PURE__ */ new Set(); 23194 const instances = /* @__PURE__ */ new Set(); 23195 const setups = /* @__PURE__ */ new Set(); 23196 const syncListenerGroup = { 23197 listeners: /* @__PURE__ */ new Set(), 23198 disposables: /* @__PURE__ */ new Map(), 23199 listenerKeys: /* @__PURE__ */ new WeakMap() 23200 }; 23201 const batchListenerGroup = { 23202 listeners: /* @__PURE__ */ new Set(), 23203 disposables: /* @__PURE__ */ new Map(), 23204 listenerKeys: /* @__PURE__ */ new WeakMap() 23205 }; 23206 const storeSetup = (callback) => { 23207 setups.add(callback); 23208 return () => setups.delete(callback); 23209 }; 23210 const storeInit = () => { 23211 const initializedInstances = instances.size; 23212 const instance = /* @__PURE__ */ Symbol(); 23213 instances.add(instance); 23214 const maybeDestroy = () => { 23215 if (!instances.delete(instance)) return; 23216 if (instances.size) return; 23217 destroy(); 23218 }; 23219 if (initializedInstances) return maybeDestroy; 23220 const stateKeys = getKeys(state); 23221 const desyncs = []; 23222 for (const store of stores) { 23223 const storeState = store?.getState?.(); 23224 if (!storeState) continue; 23225 const keys = stateKeys.filter((key) => hasOwnProperty(storeState, key)); 23226 if (!keys.length) continue; 23227 if (stores.length === 1 || keys.length === stateKeys.length) { 23228 for (const key of keys) desyncs.push(sync(store, [key], (state2) => { 23229 setState(key, state2[key], true); 23230 })); 23231 continue; 23232 } 23233 desyncs.push(subscribe(store, keys, (state2, prevState) => { 23234 for (const key of keys) { 23235 if (state2[key] === prevState[key]) continue; 23236 setState(key, state2[key], true); 23237 } 23238 })); 23239 for (const key of keys) { 23240 const liveState = store?.getState?.(); 23241 if (!liveState) continue; 23242 setState(key, liveState[key], true); 23243 } 23244 } 23245 const teardowns = []; 23246 for (const setup2 of setups) teardowns.push(setup2()); 23247 const cleanups = stores.map(init); 23248 destroy = chain(...desyncs, ...teardowns, ...cleanups); 23249 return maybeDestroy; 23250 }; 23251 const deleteListenerIndexes = (group, listener, keys) => { 23252 if (keys === void 0) return; 23253 if (keys) deleteKeyedListener(group.listenersByKey, keys, listener); 23254 else group.allKeysListeners?.delete(listener); 23255 }; 23256 const fastPathFrames = []; 23257 const registerListener = (keys, listener, group = syncListenerGroup) => { 23258 const listenerKeysValue = keys ? [...keys] : null; 23259 const wasRegistered = group.listeners.has(listener); 23260 if (!wasRegistered) clearFastPathNotifiedListener(fastPathFrames, group, listener); 23261 if (!listenerKeysValue) { 23262 if (wasRegistered) preserveFastPathFrames(fastPathFrames, group); 23263 preserveFastPathPassedListeners(fastPathFrames, group, listener); 23264 } else preserveFastPathPassedKeyedListeners({ 23265 fastPathFrames, 23266 group, 23267 keys: listenerKeysValue, 23268 listener 23269 }); 23270 if (wasRegistered) { 23271 preserveFastPathFrames(fastPathFrames, group, listener); 23272 deleteListenerIndexes(group, listener, group.listenerKeys.get(listener)); 23273 } 23274 group.listeners.add(listener); 23275 if (listenerKeysValue) { 23276 group.listenersByKey ??= /* @__PURE__ */ new Map(); 23277 addKeyedListener(group.listenersByKey, listenerKeysValue, listener); 23278 addFastPathKeyedListener({ 23279 fastPathFrames, 23280 group, 23281 keys: listenerKeysValue, 23282 listener 23283 }); 23284 } else { 23285 group.allKeysListeners ??= /* @__PURE__ */ new Set(); 23286 group.allKeysListeners.add(listener); 23287 } 23288 group.listenerKeys.set(listener, listenerKeysValue); 23289 return () => { 23290 const cleanup = group.disposables.get(listener); 23291 group.disposables.delete(listener); 23292 preserveFastPathFrames(fastPathFrames, group, listener); 23293 const currentKeys = group.listenerKeys.get(listener); 23294 deleteListenerIndexes(group, listener, listenerKeysValue); 23295 if (currentKeys !== listenerKeysValue) deleteListenerIndexes(group, listener, currentKeys); 23296 group.listenerKeys.delete(listener); 23297 group.listeners.delete(listener); 23298 cleanup?.(); 23299 }; 23300 }; 23301 const storeSubscribe = (keys, listener) => registerListener(keys, listener); 23302 const runInitialListener = (group, listener, prevState) => { 23303 const shouldSuspend = group.listeners.has(listener); 23304 if (shouldSuspend) { 23305 group.suspendCounts ??= /* @__PURE__ */ new Map(); 23306 const count = group.suspendCounts.get(listener) ?? 0; 23307 group.suspendCounts.set(listener, count + 1); 23308 } 23309 let cleanupPrevState; 23310 try { 23311 const stateBeforeCleanups = state; 23312 runPendingCleanup(group, listener); 23313 if (state !== stateBeforeCleanups) cleanupPrevState = getCleanupPrevState(prevState, state, stateBeforeCleanups); 23314 const cleanup = listener(state, cleanupPrevState ?? prevState); 23315 if (cleanup) setListenerCleanup(group, listener, cleanup); 23316 } finally { 23317 if (shouldSuspend) { 23318 const suspendCounts = group.suspendCounts; 23319 const count = suspendCounts?.get(listener); 23320 if (count && count > 1) suspendCounts?.set(listener, count - 1); 23321 else suspendCounts?.delete(listener); 23322 if (!suspendCounts?.size) delete group.suspendCounts; 23323 } 23324 } 23325 }; 23326 const storeSync = (keys, listener) => { 23327 runInitialListener(syncListenerGroup, listener, state); 23328 return registerListener(keys, listener); 23329 }; 23330 const storeBatch = (keys, listener) => { 23331 if (!batchListenerGroup.listeners.size && !inDispatch) prevStateBatch = state; 23332 runInitialListener(batchListenerGroup, listener, prevStateBatch); 23333 return registerListener(keys, listener, batchListenerGroup); 23334 }; 23335 const storePick = (keys) => createStore(pick(state, keys), finalStore); 23336 const storeOmit = (keys) => createStore(omit(state, keys), finalStore); 23337 const getState = () => state; 23338 const runListeners = (group, prevState, updatedKey) => { 23339 if (!(updatedKey instanceof Set) && !group.allKeysListeners?.size) { 23340 const keyedListeners = group.listenersByKey?.get(updatedKey); 23341 if (!keyedListeners) return; 23342 const frame = { 23343 group, 23344 keyedListeners, 23345 updatedKey, 23346 currentListener: null 23347 }; 23348 fastPathFrames.push(frame); 23349 try { 23350 for (const listener of keyedListeners) { 23351 if (frame.notifiedListeners?.has(listener)) continue; 23352 frame.currentListener = listener; 23353 frame.notifiedListeners?.add(listener); 23354 notifyStoreListener(group, listener, state, prevState, getState, updatedKey); 23355 if (!group.allKeysListeners?.size && !frame.recoverToLive) continue; 23356 const notifiedListeners = frame.notifiedListeners ?? getFastPathNotifiedListeners(frame); 23357 frame.notifiedListeners = notifiedListeners; 23358 frame.recovering = true; 23359 runLiveListeners({ 23360 group, 23361 getState, 23362 prevState, 23363 updatedKey, 23364 notifiedListeners 23365 }); 23366 return; 23367 } 23368 } finally { 23369 fastPathFrames.pop(); 23370 } 23371 return; 23372 } 23373 runLiveListeners({ 23374 group, 23375 getState, 23376 prevState, 23377 updatedKey 23378 }); 23379 }; 23380 const setState = (key, value, fromStores = false) => { 23381 if (!hasOwnProperty(state, key)) return; 23382 const currentValue = state[key]; 23383 const nextValue = typeof value === "function" ? value(currentValue) : value; 23384 if (isSameValue(nextValue, currentValue)) return; 23385 const wasInDispatch = inDispatch; 23386 inDispatch = true; 23387 const prevState = state; 23388 const nextState = { 23389 ...state, 23390 [key]: nextValue 23391 }; 23392 state = nextState; 23393 let superseded = false; 23394 try { 23395 if (!fromStores && stores.length) { 23396 for (const store of stores) { 23397 store?.setState?.(key, nextValue); 23398 if (isSameValue(state[key], nextValue)) continue; 23399 superseded = true; 23400 break; 23401 } 23402 if (superseded) { 23403 let pass = 0; 23404 for (; pass < MAX_REPAIR_PASSES; pass += 1) { 23405 let changed = false; 23406 for (const store of stores) { 23407 const previousValue = state[key]; 23408 store?.setState?.(key, previousValue); 23409 if (!isSameValue(state[key], previousValue)) changed = true; 23410 } 23411 if (!changed) break; 23412 } 23413 if (pass === MAX_REPAIR_PASSES) console.warn("Parent stores did not converge after a superseded fan-out; a parent listener may be rewriting this key in a cycle."); 23414 } 23415 } 23416 if (!superseded) runListeners(syncListenerGroup, state === nextState ? prevState : { 23417 ...state, 23418 [key]: prevState[key] 23419 }, key); 23420 } finally { 23421 inDispatch = wasInDispatch; 23422 } 23423 if (!batchListenerGroup.listeners.size) { 23424 if (!inDispatch) prevStateBatch = state; 23425 return; 23426 } 23427 updatedKeys.add(key); 23428 if (batchPending) return; 23429 batchPending = true; 23430 queueMicrotask(() => { 23431 batchPending = false; 23432 const snapshot = state; 23433 const updatedKeysSnapshot = updatedKeys; 23434 updatedKeys = /* @__PURE__ */ new Set(); 23435 const prevStateBatchBefore = prevStateBatch; 23436 runListeners(batchListenerGroup, prevStateBatchBefore, updatedKeysSnapshot); 23437 if (prevStateBatch === prevStateBatchBefore) prevStateBatch = snapshot; 23438 }); 23439 }; 23440 const finalStore = { 23441 getState, 23442 setState, 23443 __unstableInternals: { 23444 setup: storeSetup, 23445 init: storeInit, 23446 subscribe: storeSubscribe, 23447 sync: storeSync, 23448 batch: storeBatch, 23449 pick: storePick, 23450 omit: storeOmit 23451 } 23452 }; 23453 return finalStore; 23454 } 23455 function setup(store, ...args) { 23456 if (!store) return; 23457 return getInternal(store, "setup")(...args); 23458 } 23459 function init(store, ...args) { 23460 if (!store) return; 23461 return getInternal(store, "init")(...args); 23462 } 23463 function subscribe(store, ...args) { 23464 if (!store) return; 23465 return getInternal(store, "subscribe")(...args); 23466 } 23467 function sync(store, ...args) { 23468 if (!store) return; 23469 return getInternal(store, "sync")(...args); 23470 } 23471 function batch(store, ...args) { 23472 if (!store) return; 23473 return getInternal(store, "batch")(...args); 23474 } 23475 function omit2(store, ...args) { 23476 if (!store) return; 23477 return getInternal(store, "omit")(...args); 23478 } 23479 function pick2(store, ...args) { 23480 if (!store) return; 23481 return getInternal(store, "pick")(...args); 23482 } 23483 function mergeStore(...stores) { 23484 const initialState = {}; 23485 for (const store2 of stores) { 23486 const nextState = store2?.getState?.(); 23487 if (nextState) Object.assign(initialState, nextState); 23488 } 23489 const store = createStore(initialState, ...stores); 23490 return Object.assign({}, ...stores, store); 23491 } 23492 function throwOnConflictingProps(props, store) { 23493 if (false) return; 23494 if (!store) return; 23495 const defaultKeys = Object.entries(props).filter(([key, value]) => key.startsWith("default") && value !== void 0).map(([key]) => { 23496 const stateKey = key.replace("default", ""); 23497 return `$stateKey[0]?.toLowerCase() || ""}$stateKey.slice(1)}`; 23498 }); 23499 if (!defaultKeys.length) return; 23500 const storeState = store.getState(); 23501 if (!defaultKeys.filter((key) => hasOwnProperty(storeState, key)).length) return; 23502 throw new Error(`Passing a store prop in conjunction with a default state is not supported. 23503 23504 const store = useSelectStore(); 23505 <SelectProvider store={store} defaultValue="Apple" /> 23506 ^ ^ 23507 23508 Instead, pass the default state to the topmost store: 23509 23510 const store = useSelectStore({ defaultValue: "Apple" }); 23511 <SelectProvider store={store} /> 23512 23513 See https://github.com/ariakit/ariakit/pull/2745 for more details. 23514 23515 If there's a particular need for this, please submit a feature request at https://github.com/ariakit/ariakit 23516 `); 23517 } 23518 23519 // node_modules/@ariakit/components/dist/collection/collection-store.js 23520 function getCommonParent(items) { 23521 const firstItem = items.find((item) => !!item.element); 23522 const lastElement = [...items].reverse().find((item) => !!item.element)?.element; 23523 let parentElement = firstItem?.element?.parentElement; 23524 if (!lastElement) return getDocument(parentElement).body; 23525 while (parentElement) { 23526 if (parentElement.contains(lastElement)) return parentElement; 23527 parentElement = parentElement.parentElement; 23528 } 23529 return getDocument(parentElement).body; 23530 } 23531 function getPrivateStore(store) { 23532 return store?.__unstablePrivateStore; 23533 } 23534 function createCollectionStore(props = {}) { 23535 throwOnConflictingProps(props, props.store); 23536 const syncState = props.store?.getState(); 23537 const items = defaultValue(props.items, syncState?.items, props.defaultItems, []); 23538 const itemsMap = new Map(items.map((item) => [item.id, item])); 23539 const initialState = { 23540 items, 23541 renderedItems: defaultValue(syncState?.renderedItems, []) 23542 }; 23543 const syncPrivateStore = getPrivateStore(props.store); 23544 const privateStore = createStore({ 23545 items, 23546 renderedItems: initialState.renderedItems 23547 }, syncPrivateStore); 23548 const collection = createStore(initialState, props.store); 23549 const sortItems = (renderedItems) => { 23550 const sortedItems = sortBasedOnDOMPosition(renderedItems, (i2) => i2.element); 23551 privateStore.setState("renderedItems", sortedItems); 23552 collection.setState("renderedItems", sortedItems); 23553 }; 23554 setup(collection, () => init(privateStore)); 23555 setup(privateStore, () => { 23556 return batch(privateStore, ["items"], (state) => { 23557 collection.setState("items", state.items); 23558 }); 23559 }); 23560 setup(privateStore, () => { 23561 return batch(privateStore, ["renderedItems"], (state) => { 23562 let firstRun = true; 23563 let raf = requestAnimationFrame(() => { 23564 const { renderedItems } = collection.getState(); 23565 if (state.renderedItems === renderedItems) return; 23566 sortItems(state.renderedItems); 23567 }); 23568 if (typeof IntersectionObserver !== "function") return () => cancelAnimationFrame(raf); 23569 const ioCallback = () => { 23570 if (firstRun) { 23571 firstRun = false; 23572 return; 23573 } 23574 cancelAnimationFrame(raf); 23575 raf = requestAnimationFrame(() => sortItems(state.renderedItems)); 23576 }; 23577 const root = getCommonParent(state.renderedItems); 23578 const observer = new IntersectionObserver(ioCallback, { root }); 23579 for (const item of state.renderedItems) { 23580 if (!item.element) continue; 23581 observer.observe(item.element); 23582 } 23583 return () => { 23584 cancelAnimationFrame(raf); 23585 observer.disconnect(); 23586 }; 23587 }); 23588 }); 23589 const mergeItem = (item, setItems, canDeleteFromMap = false) => { 23590 let prevItem; 23591 setItems((items2) => { 23592 const index2 = items2.findIndex(({ id }) => id === item.id); 23593 const nextItems = items2.slice(); 23594 if (index2 !== -1) { 23595 prevItem = items2[index2]; 23596 const nextItem = { 23597 ...prevItem, 23598 ...item 23599 }; 23600 nextItems[index2] = nextItem; 23601 itemsMap.set(item.id, nextItem); 23602 } else { 23603 nextItems.push(item); 23604 itemsMap.set(item.id, item); 23605 } 23606 return nextItems; 23607 }); 23608 const unmergeItem = () => { 23609 setItems((items2) => { 23610 if (!prevItem) { 23611 if (canDeleteFromMap) itemsMap.delete(item.id); 23612 return items2.filter(({ id }) => id !== item.id); 23613 } 23614 const index2 = items2.findIndex(({ id }) => id === item.id); 23615 if (index2 === -1) return items2; 23616 const nextItems = items2.slice(); 23617 nextItems[index2] = prevItem; 23618 itemsMap.set(item.id, prevItem); 23619 return nextItems; 23620 }); 23621 }; 23622 return unmergeItem; 23623 }; 23624 const registerItem = (item) => mergeItem(item, (getItems) => privateStore.setState("items", getItems), true); 23625 return { 23626 ...collection, 23627 registerItem, 23628 renderItem: (item) => chain(registerItem(item), mergeItem(item, (getItems) => privateStore.setState("renderedItems", getItems))), 23629 item: (id) => { 23630 if (!id) return null; 23631 let item = itemsMap.get(id); 23632 if (!item) { 23633 const { items: items2 } = privateStore.getState(); 23634 item = items2.find((item2) => item2.id === id); 23635 if (item) itemsMap.set(id, item); 23636 } 23637 return item || null; 23638 }, 23639 __unstablePrivateStore: privateStore 23640 }; 23641 } 23642 23643 // node_modules/@ariakit/components/dist/composite/composite-store.js 23644 var NULL_ITEM = { id: null }; 23645 function findFirstEnabledItem(items, excludeId) { 23646 return items.find((item) => { 23647 if (excludeId) return !item.disabled && item.id !== excludeId; 23648 return !item.disabled; 23649 }); 23650 } 23651 function getEnabledItems(items, excludeId) { 23652 return items.filter((item) => { 23653 if (excludeId) return !item.disabled && item.id !== excludeId; 23654 return !item.disabled; 23655 }); 23656 } 23657 function getItemsInRow(items, rowId) { 23658 return items.filter((item) => item.rowId === rowId); 23659 } 23660 function findEnabledItemId({ items, fromIndex, step, rowId, excludeId }) { 23661 for (let i2 = fromIndex; i2 >= 0 && i2 < items.length; i2 += step) { 23662 const item = items[i2]; 23663 if (!item) continue; 23664 if (item.rowId !== rowId) continue; 23665 if (item.disabled) continue; 23666 if (excludeId != null && item.id === excludeId) continue; 23667 return item.id; 23668 } 23669 } 23670 function flipItems(items, activeId, shouldInsertNullItem = false) { 23671 const index2 = items.findIndex((item) => item.id === activeId); 23672 return [ 23673 ...items.slice(index2 + 1), 23674 ...shouldInsertNullItem ? [NULL_ITEM] : [], 23675 ...items.slice(0, index2) 23676 ]; 23677 } 23678 function groupItemsByRows(items) { 23679 const rows = []; 23680 for (const item of items) { 23681 const row = rows.find((currentRow) => currentRow[0]?.rowId === item.rowId); 23682 if (row) row.push(item); 23683 else rows.push([item]); 23684 } 23685 return rows; 23686 } 23687 function getMaxRowLength(array) { 23688 let maxLength = 0; 23689 for (const { length } of array) if (length > maxLength) maxLength = length; 23690 return maxLength; 23691 } 23692 function createEmptyItem(rowId) { 23693 return { 23694 id: "__EMPTY_ITEM__", 23695 disabled: true, 23696 rowId 23697 }; 23698 } 23699 function normalizeRows(rows, activeId, focusShift) { 23700 const maxLength = getMaxRowLength(rows); 23701 for (const row of rows) for (let i2 = 0; i2 < maxLength; i2 += 1) { 23702 const item = row[i2]; 23703 if (!item || focusShift && item.disabled) { 23704 const previousItem = i2 === 0 && focusShift ? findFirstEnabledItem(row) : row[i2 - 1]; 23705 row[i2] = previousItem && activeId !== previousItem.id && focusShift ? previousItem : createEmptyItem(previousItem?.rowId); 23706 } 23707 } 23708 return rows; 23709 } 23710 function verticalizeItems(items) { 23711 const rows = groupItemsByRows(items); 23712 const maxLength = getMaxRowLength(rows); 23713 const verticalized = []; 23714 for (let i2 = 0; i2 < maxLength; i2 += 1) for (const row of rows) { 23715 const item = row[i2]; 23716 if (item) verticalized.push({ 23717 ...item, 23718 rowId: item.rowId ? `$i2}` : void 0 23719 }); 23720 } 23721 return verticalized; 23722 } 23723 function createCompositeStore(props = {}) { 23724 const syncState = props.store?.getState(); 23725 const collection = createCollectionStore(props); 23726 const activeId = defaultValue(props.activeId, syncState?.activeId, props.defaultActiveId); 23727 const composite = createStore({ 23728 ...collection.getState(), 23729 id: defaultValue(props.id, syncState?.id) ?? `id-$Math.random().toString(36).slice(2, 8)}`, 23730 activeId, 23731 baseElement: defaultValue(syncState?.baseElement, null), 23732 includesBaseElement: defaultValue(props.includesBaseElement, syncState?.includesBaseElement, activeId === null), 23733 moves: defaultValue(syncState?.moves, 0), 23734 orientation: defaultValue(props.orientation, syncState?.orientation, "both"), 23735 rtl: defaultValue(props.rtl, syncState?.rtl, false), 23736 virtualFocus: defaultValue(props.virtualFocus, syncState?.virtualFocus, false), 23737 focusLoop: defaultValue(props.focusLoop, syncState?.focusLoop, false), 23738 focusWrap: defaultValue(props.focusWrap, syncState?.focusWrap, false), 23739 focusShift: defaultValue(props.focusShift, syncState?.focusShift, false) 23740 }, collection, props.store); 23741 setup(composite, () => sync(composite, ["renderedItems", "activeId"], (state) => { 23742 composite.setState("activeId", (activeId2) => { 23743 if (activeId2 !== void 0) return activeId2; 23744 return findFirstEnabledItem(state.renderedItems)?.id; 23745 }); 23746 })); 23747 const getNextId = (direction = "next", options = {}) => { 23748 const defaultState = composite.getState(); 23749 const { skip = 0, activeId: activeId2 = defaultState.activeId, focusShift = defaultState.focusShift, focusLoop = defaultState.focusLoop, focusWrap = defaultState.focusWrap, includesBaseElement = defaultState.includesBaseElement, renderedItems = defaultState.renderedItems, rtl = defaultState.rtl } = options; 23750 const isVerticalDirection = direction === "up" || direction === "down"; 23751 const isNextDirection = direction === "next" || direction === "down"; 23752 const canReverse = isNextDirection ? rtl && !isVerticalDirection : !rtl || isVerticalDirection; 23753 const canShift = focusShift && !skip; 23754 if (!skip && !focusWrap && !includesBaseElement && activeId2 != null) { 23755 if (!isVerticalDirection ? true : !canShift && !renderedItems.some((item) => item.rowId != null)) { 23756 const activeIndex2 = renderedItems.findIndex((item) => item.id === activeId2); 23757 const activeItem2 = renderedItems[activeIndex2]; 23758 if (activeItem2) { 23759 const step = canReverse ? -1 : 1; 23760 const nextId = findEnabledItemId({ 23761 items: renderedItems, 23762 fromIndex: activeIndex2 + step, 23763 step, 23764 rowId: activeItem2.rowId, 23765 excludeId: activeId2 23766 }); 23767 if (nextId !== void 0) return nextId; 23768 if (!(focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical"))) return void 0; 23769 return findEnabledItemId({ 23770 items: renderedItems, 23771 fromIndex: step === 1 ? 0 : renderedItems.length - 1, 23772 step, 23773 rowId: activeItem2.rowId, 23774 excludeId: activeId2 23775 }); 23776 } 23777 } 23778 } 23779 let items = !isVerticalDirection ? renderedItems : flatten2DArray(normalizeRows(groupItemsByRows(renderedItems), activeId2, canShift)); 23780 items = canReverse ? reverseArray(items) : items; 23781 items = isVerticalDirection ? verticalizeItems(items) : items; 23782 if (activeId2 == null) return findFirstEnabledItem(items)?.id; 23783 const activeItem = items.find((item) => item.id === activeId2); 23784 if (!activeItem) return findFirstEnabledItem(items)?.id; 23785 const isGrid2 = items.some((item) => item.rowId); 23786 const activeIndex = items.indexOf(activeItem); 23787 const nextItems = items.slice(activeIndex + 1); 23788 const nextItemsInRow = getItemsInRow(nextItems, activeItem.rowId); 23789 if (skip) { 23790 const nextEnabledItemsInRow = getEnabledItems(nextItemsInRow, activeId2); 23791 return (nextEnabledItemsInRow.slice(skip)[0] || nextEnabledItemsInRow[nextEnabledItemsInRow.length - 1])?.id; 23792 } 23793 const canLoop = focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical"); 23794 const canWrap = isGrid2 && focusWrap && (isVerticalDirection ? focusWrap !== "horizontal" : focusWrap !== "vertical"); 23795 const hasNullItem = isNextDirection ? (!isGrid2 || isVerticalDirection) && canLoop && includesBaseElement : isVerticalDirection ? includesBaseElement : false; 23796 if (canLoop) return findFirstEnabledItem(flipItems(canWrap && !hasNullItem ? items : getItemsInRow(items, activeItem.rowId), activeId2, hasNullItem), activeId2)?.id; 23797 if (canWrap) { 23798 const nextItem2 = findFirstEnabledItem(hasNullItem ? nextItemsInRow : nextItems, activeId2); 23799 return hasNullItem ? nextItem2?.id || null : nextItem2?.id; 23800 } 23801 const nextItem = findFirstEnabledItem(nextItemsInRow, activeId2); 23802 if (!nextItem && hasNullItem) return null; 23803 return nextItem?.id; 23804 }; 23805 const getNextIdFromOptions = (direction, options) => { 23806 if (typeof options === "number") return getNextId(direction, { skip: options }); 23807 return getNextId(direction, options); 23808 }; 23809 return { 23810 ...collection, 23811 ...composite, 23812 setBaseElement: (element) => composite.setState("baseElement", element), 23813 setActiveId: (id) => composite.setState("activeId", id), 23814 move: (id) => { 23815 if (id === void 0) return; 23816 composite.setState("activeId", id); 23817 composite.setState("moves", (moves) => moves + 1); 23818 }, 23819 first: () => findFirstEnabledItem(composite.getState().renderedItems)?.id, 23820 last: () => findFirstEnabledItem(reverseArray(composite.getState().renderedItems))?.id, 23821 next: (options) => getNextIdFromOptions("next", options), 23822 previous: (options) => getNextIdFromOptions("previous", options), 23823 down: (options) => getNextIdFromOptions("down", options), 23824 up: (options) => getNextIdFromOptions("up", options) 23825 }; 23826 } 23827 23828 // node_modules/@ariakit/react-components/dist/composite/utils.js 23829 var findFirstEnabledItem2 = findFirstEnabledItem; 23830 var groupItemsByRows2 = groupItemsByRows; 23831 function getEnabledItem(store, id) { 23832 if (!id) return null; 23833 return store.item(id) || null; 23834 } 23835 function selectTextField(element, collapseToEnd = false) { 23836 if (isTextField(element)) element.setSelectionRange(collapseToEnd ? element.value.length : 0, element.value.length); 23837 else if (element.isContentEditable) { 23838 const selection = getDocument(element).getSelection(); 23839 selection?.selectAllChildren(element); 23840 if (collapseToEnd) selection?.collapseToEnd(); 23841 } 23842 } 23843 var FOCUS_SILENTLY = /* @__PURE__ */ Symbol("FOCUS_SILENTLY"); 23844 function focusSilently(element) { 23845 element[FOCUS_SILENTLY] = true; 23846 element.focus({ preventScroll: true }); 23847 } 23848 function silentlyFocused(element) { 23849 const isSilentlyFocused = element[FOCUS_SILENTLY]; 23850 delete element[FOCUS_SILENTLY]; 23851 return isSilentlyFocused; 23852 } 23853 function isItem(store, element, exclude) { 23854 if (!element) return false; 23855 if (element === exclude) return false; 23856 const item = store.item(element.id); 23857 if (!item) return false; 23858 if (exclude && item.element === exclude) return false; 23859 return true; 23860 } 23861 23862 // node_modules/@ariakit/react-components/dist/composite/composite-item.js 23863 var import_react21 = __toESM(require_react(), 1); 23864 var import_jsx_runtime116 = __toESM(require_jsx_runtime(), 1); 23865 23866 // node_modules/@ariakit/react-store/dist/index.js 23867 var React83 = __toESM(require_react(), 1); 23868 var import_shim2 = __toESM(require_shim(), 1); 23869 var noopSubscribe = () => () => { 23870 }; 23871 function useStoreState(store, keyOrSelector = identity) { 23872 const storeSubscribe = React83.useCallback((callback) => { 23873 if (!store) return noopSubscribe(); 23874 return subscribe(store, null, callback); 23875 }, [store]); 23876 const getSnapshot = () => { 23877 const key = typeof keyOrSelector === "string" ? keyOrSelector : null; 23878 const selector2 = typeof keyOrSelector === "function" ? keyOrSelector : null; 23879 const state = store?.getState(); 23880 if (selector2) return selector2(state); 23881 if (!state) return; 23882 if (!key) return; 23883 if (!hasOwnProperty(state, key)) return; 23884 return state[key]; 23885 }; 23886 return (0, import_shim2.useSyncExternalStore)(storeSubscribe, getSnapshot, getSnapshot); 23887 } 23888 function useStoreStateObject(store, object) { 23889 const objRef = React83.useRef({}); 23890 const storeSubscribe = React83.useCallback((callback) => { 23891 if (!store) return noopSubscribe(); 23892 return subscribe(store, null, callback); 23893 }, [store]); 23894 const getSnapshot = () => { 23895 const state = store?.getState(); 23896 let updated = false; 23897 const obj = objRef.current; 23898 for (const prop in object) { 23899 const keyOrSelector = object[prop]; 23900 if (typeof keyOrSelector === "function") { 23901 const value = keyOrSelector(state); 23902 if (!Object.is(value, obj[prop])) { 23903 obj[prop] = value; 23904 updated = true; 23905 } 23906 } 23907 if (typeof keyOrSelector === "string") { 23908 if (!state) continue; 23909 if (!hasOwnProperty(state, keyOrSelector)) continue; 23910 const value = state[keyOrSelector]; 23911 if (!Object.is(value, obj[prop])) { 23912 obj[prop] = value; 23913 updated = true; 23914 } 23915 } 23916 } 23917 if (updated) objRef.current = { ...obj }; 23918 return objRef.current; 23919 }; 23920 return (0, import_shim2.useSyncExternalStore)(storeSubscribe, getSnapshot, getSnapshot); 23921 } 23922 function useStoreProps(store, props, key, setKey) { 23923 const value = hasOwnProperty(props, key) ? props[key] : void 0; 23924 const propsRef = useLiveRef({ 23925 value, 23926 setValue: setKey ? props[setKey] : void 0 23927 }); 23928 useSafeLayoutEffect(() => { 23929 return sync(store, [key], (state, prev) => { 23930 const { value: value2, setValue } = propsRef.current; 23931 if (!setValue) return; 23932 if (state[key] === prev[key]) return; 23933 if (state[key] === value2) return; 23934 setValue(state[key]); 23935 }); 23936 }, [store, key]); 23937 useSafeLayoutEffect(() => { 23938 if (value === void 0) return; 23939 store.setState(key, value); 23940 return batch(store, [key], () => { 23941 if (value === void 0) return; 23942 store.setState(key, value); 23943 }); 23944 }); 23945 } 23946 function useStore2(createStore2, props) { 23947 const [store, setStore] = React83.useState(() => createStore2(props)); 23948 useSafeLayoutEffect(() => init(store), [store]); 23949 const useState56 = React83.useCallback((keyOrSelector) => useStoreState(store, keyOrSelector), [store]); 23950 return [React83.useMemo(() => ({ 23951 ...store, 23952 useState: useState56 23953 }), [store, useState56]), useEvent(() => { 23954 setStore((store2) => createStore2({ 23955 ...props, 23956 ...store2.getState() 23957 })); 23958 })]; 23959 } 23960 23961 // node_modules/@ariakit/react-components/dist/composite/composite-item.js 23962 var TagName4 = "button"; 23963 function isEditableElement(element) { 23964 if (isTextbox(element)) return true; 23965 return element.tagName === "INPUT" && !isButton(element); 23966 } 23967 function getNextPageOffset(scrollingElement, pageUp = false) { 23968 const height = scrollingElement.clientHeight; 23969 const { top } = scrollingElement.getBoundingClientRect(); 23970 const pageSize = Math.max(height * 0.875, height - 40) * 1.5; 23971 const pageOffset = pageUp ? height - pageSize + top : pageSize + top; 23972 if (scrollingElement.tagName === "HTML") return pageOffset + scrollingElement.scrollTop; 23973 return pageOffset; 23974 } 23975 function getItemOffset(itemElement, pageUp = false) { 23976 const { top } = itemElement.getBoundingClientRect(); 23977 if (pageUp) return top + itemElement.clientHeight; 23978 return top; 23979 } 23980 function findNextPageItemId(element, store, next, pageUp = false) { 23981 if (!store) return; 23982 if (!next) return; 23983 const { renderedItems } = store.getState(); 23984 const scrollingElement = getScrollingElement(element); 23985 if (!scrollingElement) return; 23986 const nextPageOffset = getNextPageOffset(scrollingElement, pageUp); 23987 let id; 23988 let prevDifference; 23989 for (let i2 = 0; i2 < renderedItems.length; i2 += 1) { 23990 const previousId = id; 23991 id = next(i2); 23992 if (!id) break; 23993 if (id === previousId) continue; 23994 const itemElement = getEnabledItem(store, id)?.element; 23995 if (!itemElement) continue; 23996 const difference = getItemOffset(itemElement, pageUp) - nextPageOffset; 23997 const absDifference = Math.abs(difference); 23998 if (pageUp && difference <= 0 || !pageUp && difference >= 0) { 23999 if (prevDifference !== void 0 && prevDifference < absDifference) id = previousId; 24000 break; 24001 } 24002 prevDifference = absDifference; 24003 } 24004 return id; 24005 } 24006 function targetIsAnotherItem(event, store) { 24007 if (isSelfTarget(event)) return false; 24008 return isItem(store, event.target); 24009 } 24010 var useCompositeItem = createHook(function useCompositeItem2({ store, rowId: rowIdProp, preventScrollOnKeyDown = false, moveOnKeyPress = true, tabbable: tabbable4 = false, getItem: getItemProp, "aria-setsize": ariaSetSizeProp, "aria-posinset": ariaPosInSetProp, ...props }) { 24011 const context = useCompositeScopedContext(); 24012 store = store || context; 24013 const id = useId5(props.id); 24014 const ref = (0, import_react21.useRef)(null); 24015 const row = (0, import_react21.useContext)(CompositeRowContext); 24016 const trulyDisabled = disabledFromProps(props) && !props.accessibleWhenDisabled; 24017 const shouldRegisterItem = props.shouldRegisterItem; 24018 const getRowId = (state) => { 24019 if (rowIdProp) return rowIdProp; 24020 if (!state) return; 24021 if (!row?.baseElement) return; 24022 if (row.baseElement !== state.baseElement) return; 24023 return row.id; 24024 }; 24025 const { rowId, baseElement, isActiveItem, ariaSetSize, ariaPosInSet, isTabbable: isTabbable2 } = useStoreStateObject(store, { 24026 rowId: getRowId, 24027 baseElement(state) { 24028 return state?.baseElement || void 0; 24029 }, 24030 isActiveItem(state) { 24031 return !!state && state.activeId === id; 24032 }, 24033 ariaSetSize(state) { 24034 if (ariaSetSizeProp != null) return ariaSetSizeProp; 24035 if (!state) return; 24036 if (!row?.ariaSetSize) return; 24037 if (row.baseElement !== state.baseElement) return; 24038 return row.ariaSetSize; 24039 }, 24040 ariaPosInSet(state) { 24041 if (ariaPosInSetProp != null) return ariaPosInSetProp; 24042 if (!state) return; 24043 if (!row?.ariaPosInSet) return; 24044 if (row.baseElement !== state.baseElement) return; 24045 const rowId2 = getRowId(state); 24046 const itemsInRow = state.renderedItems.filter((item) => item.rowId === rowId2); 24047 return row.ariaPosInSet + itemsInRow.findIndex((item) => item.id === id); 24048 }, 24049 isTabbable(state) { 24050 if (!state?.renderedItems.length) return true; 24051 if (state.virtualFocus) return false; 24052 if (tabbable4) return true; 24053 if (state.activeId === null) return false; 24054 const item = store?.item(state.activeId); 24055 if (item?.disabled) return true; 24056 if (!item?.element) return true; 24057 return state.activeId === id; 24058 } 24059 }); 24060 const getItem = (0, import_react21.useCallback)((item) => { 24061 const nextItem = { 24062 ...item, 24063 id: id || item.id, 24064 rowId, 24065 disabled: trulyDisabled, 24066 children: item.element?.textContent 24067 }; 24068 if (getItemProp) return getItemProp(nextItem); 24069 return nextItem; 24070 }, [ 24071 id, 24072 rowId, 24073 trulyDisabled, 24074 getItemProp 24075 ]); 24076 const onFocusProp = props.onFocus; 24077 const hasFocusedComposite = (0, import_react21.useRef)(false); 24078 const cancelScheduledFocusRedirectRef = (0, import_react21.useRef)(null); 24079 const onFocus = useEvent((event) => { 24080 onFocusProp?.(event); 24081 if (event.defaultPrevented) return; 24082 if (isPortalEvent(event)) return; 24083 if (!id) return; 24084 if (!store) return; 24085 if (targetIsAnotherItem(event, store)) return; 24086 const { virtualFocus, baseElement: baseElement2 } = store.getState(); 24087 store.setActiveId(id); 24088 if (isTextbox(event.currentTarget)) selectTextField(event.currentTarget); 24089 if (!virtualFocus) return; 24090 if (!isSelfTarget(event)) return; 24091 if (isEditableElement(event.currentTarget)) return; 24092 const redirectFocusToBaseElement = (currentTarget2, relatedTarget2, baseElement3) => { 24093 if (isSafari() && currentTarget2.hasAttribute("data-autofocus")) currentTarget2.scrollIntoView({ 24094 block: "nearest", 24095 inline: "nearest" 24096 }); 24097 hasFocusedComposite.current = true; 24098 if (relatedTarget2 === baseElement3 || isItem(store, relatedTarget2)) focusSilently(baseElement3); 24099 else baseElement3.focus(); 24100 }; 24101 if (baseElement2?.isConnected) { 24102 redirectFocusToBaseElement(event.currentTarget, event.relatedTarget, baseElement2); 24103 return; 24104 } 24105 if (shouldRegisterItem === false) return; 24106 const { currentTarget, relatedTarget } = event; 24107 const cancelScheduledFocusRedirect = () => { 24108 cancelScheduledFocusRedirectRef.current?.(); 24109 cancelScheduledFocusRedirectRef.current = null; 24110 }; 24111 cancelScheduledFocusRedirect(); 24112 cancelScheduledFocusRedirectRef.current = subscribe(store, null, () => { 24113 if (getActiveElement(currentTarget) !== currentTarget) { 24114 cancelScheduledFocusRedirect(); 24115 return; 24116 } 24117 const state = store.getState(); 24118 const nextBaseElement = state.baseElement; 24119 if (!nextBaseElement?.isConnected) return; 24120 cancelScheduledFocusRedirect(); 24121 if (!state.virtualFocus) return; 24122 redirectFocusToBaseElement(currentTarget, relatedTarget, nextBaseElement); 24123 }); 24124 }); 24125 const onBlurCaptureProp = props.onBlurCapture; 24126 const onBlurCapture = useEvent((event) => { 24127 onBlurCaptureProp?.(event); 24128 if (event.defaultPrevented) return; 24129 if (store?.getState()?.virtualFocus && hasFocusedComposite.current) { 24130 hasFocusedComposite.current = false; 24131 event.preventDefault(); 24132 event.stopPropagation(); 24133 } 24134 }); 24135 const onKeyDownProp = props.onKeyDown; 24136 const preventScrollOnKeyDownProp = useBooleanEvent(preventScrollOnKeyDown); 24137 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress); 24138 const onKeyDown = useEvent((event) => { 24139 onKeyDownProp?.(event); 24140 if (event.defaultPrevented) return; 24141 if (!isSelfTarget(event)) return; 24142 if (!store) return; 24143 const { currentTarget } = event; 24144 const state = store.getState(); 24145 const isGrid2 = !!store.item(id)?.rowId; 24146 const isVertical = state.orientation !== "horizontal"; 24147 const isHorizontal = state.orientation !== "vertical"; 24148 const canHomeEnd = () => { 24149 if (isGrid2) return true; 24150 if (isHorizontal) return true; 24151 if (!state.baseElement) return true; 24152 if (!isTextField(state.baseElement)) return true; 24153 return false; 24154 }; 24155 const action = { 24156 ArrowUp: (isGrid2 || isVertical) && store.up, 24157 ArrowRight: (isGrid2 || isHorizontal) && store.next, 24158 ArrowDown: (isGrid2 || isVertical) && store.down, 24159 ArrowLeft: (isGrid2 || isHorizontal) && store.previous, 24160 Home: () => { 24161 if (!canHomeEnd()) return; 24162 if (!isGrid2 || event.ctrlKey) return store?.first(); 24163 return store?.previous(-1); 24164 }, 24165 End: () => { 24166 if (!canHomeEnd()) return; 24167 if (!isGrid2 || event.ctrlKey) return store?.last(); 24168 return store?.next(-1); 24169 }, 24170 PageUp: () => { 24171 return findNextPageItemId(currentTarget, store, store?.up, true); 24172 }, 24173 PageDown: () => { 24174 return findNextPageItemId(currentTarget, store, store?.down); 24175 } 24176 }[event.key]; 24177 if (action) { 24178 if (isTextbox(currentTarget)) { 24179 const selection = getTextboxSelection(currentTarget); 24180 const isLeft = isHorizontal && event.key === "ArrowLeft"; 24181 const isRight = isHorizontal && event.key === "ArrowRight"; 24182 const isUp = isVertical && event.key === "ArrowUp"; 24183 const isDown = isVertical && event.key === "ArrowDown"; 24184 if (isRight || isDown) { 24185 const { length: valueLength } = getTextboxValue(currentTarget); 24186 if (selection.end !== valueLength) return; 24187 } else if ((isLeft || isUp) && selection.start !== 0) return; 24188 } 24189 const nextId = action(); 24190 if (preventScrollOnKeyDownProp(event) || nextId !== void 0) { 24191 if (!moveOnKeyPressProp(event)) return; 24192 event.preventDefault(); 24193 store.move(nextId); 24194 } 24195 } 24196 }); 24197 const providerValue = (0, import_react21.useMemo)(() => ({ 24198 id, 24199 baseElement 24200 }), [id, baseElement]); 24201 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(CompositeItemContext.Provider, { 24202 value: providerValue, 24203 children: element 24204 }), [providerValue]); 24205 props = { 24206 "data-active-item": isActiveItem || void 0, 24207 ...props, 24208 id, 24209 ref: useMergeRefs3(ref, props.ref), 24210 tabIndex: isTabbable2 ? props.tabIndex : -1, 24211 onFocus, 24212 onBlurCapture, 24213 onKeyDown 24214 }; 24215 props = useCommand(props); 24216 props = useCollectionItem({ 24217 store, 24218 ...props, 24219 getItem, 24220 shouldRegisterItem: id ? shouldRegisterItem : false 24221 }); 24222 return removeUndefinedValues({ 24223 ...props, 24224 "aria-setsize": ariaSetSize, 24225 "aria-posinset": ariaPosInSet 24226 }); 24227 }); 24228 var CompositeItem = memo3(forwardRef70(function CompositeItem2(props) { 24229 return createElement3(TagName4, useCompositeItem(props)); 24230 })); 24231 24232 // node_modules/@ariakit/react-components/dist/composite/composite.js 24233 var import_react22 = __toESM(require_react(), 1); 24234 var import_jsx_runtime117 = __toESM(require_jsx_runtime(), 1); 24235 var TagName5 = "div"; 24236 function isGrid(items) { 24237 return items.some((item) => !!item.rowId); 24238 } 24239 function isPrintableKey(event) { 24240 const target = event.target; 24241 if (target && !isTextField(target)) return false; 24242 return event.key.length === 1 && !event.ctrlKey && !event.metaKey; 24243 } 24244 function isModifierKey(event) { 24245 return event.key === "Shift" || event.key === "Control" || event.key === "Alt" || event.key === "Meta"; 24246 } 24247 function useKeyboardEventProxy(store, onKeyboardEvent, previousElementRef) { 24248 return useEvent((event) => { 24249 onKeyboardEvent?.(event); 24250 if (event.defaultPrevented) return; 24251 if (event.isPropagationStopped()) return; 24252 if (!isSelfTarget(event)) return; 24253 if (isModifierKey(event)) return; 24254 if (isPrintableKey(event)) return; 24255 const activeElement2 = getEnabledItem(store, store.getState().activeId)?.element; 24256 if (!activeElement2) return; 24257 const { view, ...eventInit } = event; 24258 if (activeElement2 !== previousElementRef?.current) activeElement2.focus(); 24259 if (!fireKeyboardEvent(activeElement2, event.type, eventInit)) event.preventDefault(); 24260 if (event.currentTarget.contains(activeElement2)) event.stopPropagation(); 24261 }); 24262 } 24263 function findFirstEnabledItemInTheLastRow(items) { 24264 return findFirstEnabledItem2(flatten2DArray(reverseArray(groupItemsByRows2(items)))); 24265 } 24266 function withBaseScrollPreserved(store, callback) { 24267 const { virtualFocus, baseElement } = store.getState(); 24268 if (!virtualFocus || !baseElement || !isTextField(baseElement)) { 24269 callback(); 24270 return; 24271 } 24272 const savedScrollLeft = baseElement.scrollLeft; 24273 const savedScrollTop = baseElement.scrollTop; 24274 callback(); 24275 baseElement.scrollLeft = savedScrollLeft; 24276 baseElement.scrollTop = savedScrollTop; 24277 } 24278 function useScheduleFocus(store) { 24279 const [scheduled, setScheduled] = (0, import_react22.useState)(false); 24280 const schedule = (0, import_react22.useCallback)(() => setScheduled(true), []); 24281 const activeItem = useStoreState(store, (state) => scheduled ? getEnabledItem(store, state.activeId) : null); 24282 (0, import_react22.useEffect)(() => { 24283 const activeElement2 = activeItem?.element; 24284 if (!scheduled) return; 24285 if (!activeElement2) return; 24286 setScheduled(false); 24287 withBaseScrollPreserved(store, () => { 24288 activeElement2.focus({ preventScroll: true }); 24289 }); 24290 }, [ 24291 store, 24292 activeItem, 24293 scheduled 24294 ]); 24295 return schedule; 24296 } 24297 var CompositeFocusOnMove = memo3(function CompositeFocusOnMove2({ store, focusOnMove, previousElementRef }) { 24298 const moves = useStoreState(store, "moves"); 24299 const baseElement = useStoreState(store, "baseElement"); 24300 (0, import_react22.useEffect)(() => { 24301 if (!moves) return; 24302 if (!focusOnMove) return; 24303 const { activeId } = store.getState(); 24304 const itemElement = getEnabledItem(store, activeId)?.element; 24305 if (!itemElement) return; 24306 withBaseScrollPreserved(store, () => focusIntoView(itemElement)); 24307 }, [ 24308 store, 24309 moves, 24310 focusOnMove 24311 ]); 24312 useSafeLayoutEffect(() => { 24313 if (!moves) return; 24314 if (!baseElement) return; 24315 const { activeId } = store.getState(); 24316 if (!(activeId === null)) return; 24317 const previousElement = previousElementRef.current; 24318 previousElementRef.current = null; 24319 if (previousElement) fireBlurEvent(previousElement, { relatedTarget: baseElement }); 24320 if (!hasFocus(baseElement)) baseElement.focus(); 24321 }, [ 24322 store, 24323 moves, 24324 baseElement 24325 ]); 24326 return null; 24327 }); 24328 var useComposite = createHook(function useComposite2({ store, composite = true, focusOnMove = composite, moveOnKeyPress = true, ...props }) { 24329 const context = useCompositeProviderContext(); 24330 store = store || context; 24331 invariant(store, "Composite must receive a `store` prop or be wrapped in a CompositeProvider component."); 24332 const ref = (0, import_react22.useRef)(null); 24333 const previousElementRef = (0, import_react22.useRef)(null); 24334 const scheduleFocus = useScheduleFocus(store); 24335 const [, setBaseElement] = useTransactionState(composite ? store.setBaseElement : null); 24336 const virtualFocus = useStoreState(store, "virtualFocus"); 24337 const activeId = useStoreState(store, (state) => state.virtualFocus ? state.activeId : null); 24338 useSafeLayoutEffect(() => { 24339 if (!store) return; 24340 if (!composite) return; 24341 if (!virtualFocus) return; 24342 const previousElement = previousElementRef.current; 24343 previousElementRef.current = null; 24344 if (!previousElement) return; 24345 const relatedTarget = getEnabledItem(store, activeId)?.element || getActiveElement(previousElement); 24346 if (relatedTarget === previousElement) return; 24347 fireBlurEvent(previousElement, { relatedTarget }); 24348 }, [ 24349 store, 24350 activeId, 24351 virtualFocus, 24352 composite 24353 ]); 24354 const onKeyDownCapture = useKeyboardEventProxy(store, props.onKeyDownCapture, previousElementRef); 24355 const onKeyUpCapture = useKeyboardEventProxy(store, props.onKeyUpCapture, previousElementRef); 24356 const onFocusCaptureProp = props.onFocusCapture; 24357 const onFocusCapture = useEvent((event) => { 24358 onFocusCaptureProp?.(event); 24359 if (event.defaultPrevented) return; 24360 if (!store) return; 24361 const { virtualFocus: virtualFocus2 } = store.getState(); 24362 if (!virtualFocus2) return; 24363 const previousActiveElement = event.relatedTarget; 24364 const isSilentlyFocused = silentlyFocused(event.currentTarget); 24365 if (isSelfTarget(event) && isSilentlyFocused) { 24366 event.stopPropagation(); 24367 previousElementRef.current = previousActiveElement; 24368 } 24369 }); 24370 const onFocusProp = props.onFocus; 24371 const onFocus = useEvent((event) => { 24372 onFocusProp?.(event); 24373 if (event.defaultPrevented) return; 24374 if (!composite) return; 24375 if (!store) return; 24376 const { relatedTarget } = event; 24377 const { virtualFocus: virtualFocus2 } = store.getState(); 24378 if (virtualFocus2) { 24379 if (isSelfTarget(event) && !isItem(store, relatedTarget)) queueMicrotask(scheduleFocus); 24380 } else if (isSelfTarget(event)) store.setActiveId(null); 24381 }); 24382 const onBlurCaptureProp = props.onBlurCapture; 24383 const onBlurCapture = useEvent((event) => { 24384 onBlurCaptureProp?.(event); 24385 if (event.defaultPrevented) return; 24386 if (!store) return; 24387 const { virtualFocus: virtualFocus2, activeId: activeId2 } = store.getState(); 24388 if (!virtualFocus2) return; 24389 const activeElement2 = getEnabledItem(store, activeId2)?.element; 24390 const nextActiveElement = event.relatedTarget; 24391 const nextActiveElementIsItem = isItem(store, nextActiveElement); 24392 const previousElement = previousElementRef.current; 24393 previousElementRef.current = null; 24394 if (isSelfTarget(event) && nextActiveElementIsItem) { 24395 if (nextActiveElement === activeElement2) { 24396 if (previousElement && previousElement !== nextActiveElement) fireBlurEvent(previousElement, event); 24397 } else if (activeElement2) fireBlurEvent(activeElement2, event); 24398 else if (previousElement) fireBlurEvent(previousElement, event); 24399 event.stopPropagation(); 24400 } else if (!isItem(store, event.target) && activeElement2) fireBlurEvent(activeElement2, event); 24401 }); 24402 const onKeyDownProp = props.onKeyDown; 24403 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress); 24404 const onKeyDown = useEvent((event) => { 24405 onKeyDownProp?.(event); 24406 if (event.nativeEvent.isComposing) return; 24407 if (event.defaultPrevented) return; 24408 if (!store) return; 24409 if (!isSelfTarget(event)) return; 24410 const { orientation, renderedItems, activeId: activeId2, rtl } = store.getState(); 24411 if (getEnabledItem(store, activeId2)?.element?.isConnected) return; 24412 const isVertical = orientation !== "horizontal"; 24413 const isHorizontal = orientation !== "vertical"; 24414 const grid = isGrid(renderedItems); 24415 if ((event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "Home" || event.key === "End") && isTextField(event.currentTarget)) return; 24416 const up = () => { 24417 if (grid) return findFirstEnabledItemInTheLastRow(renderedItems)?.id; 24418 return store?.last(); 24419 }; 24420 const action = { 24421 ArrowUp: (grid || isVertical) && up, 24422 ArrowRight: (grid || isHorizontal) && (rtl ? store.last : store.first), 24423 ArrowDown: (grid || isVertical) && store.first, 24424 ArrowLeft: (grid || isHorizontal) && (rtl ? store.first : store.last), 24425 Home: store.first, 24426 End: store.last, 24427 PageUp: store.first, 24428 PageDown: store.last 24429 }[event.key]; 24430 if (action) { 24431 const id = action(); 24432 if (id !== void 0) { 24433 if (!moveOnKeyPressProp(event)) return; 24434 event.preventDefault(); 24435 store.move(id); 24436 } 24437 } 24438 }); 24439 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)(CompositeScopedContextProvider, { 24440 value: store, 24441 children: [element, composite && /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(CompositeFocusOnMove, { 24442 store, 24443 focusOnMove, 24444 previousElementRef 24445 })] 24446 }), [ 24447 store, 24448 composite, 24449 focusOnMove 24450 ]); 24451 props = { 24452 "aria-activedescendant": useStoreState(store, (state) => { 24453 if (!store) return; 24454 if (!composite) return; 24455 if (!state.virtualFocus) return; 24456 return getEnabledItem(store, state.activeId)?.id; 24457 }), 24458 ...props, 24459 ref: useMergeRefs3(ref, setBaseElement, props.ref), 24460 onKeyDownCapture, 24461 onKeyUpCapture, 24462 onFocusCapture, 24463 onFocus, 24464 onBlurCapture, 24465 onKeyDown 24466 }; 24467 props = useFocusable({ 24468 focusable: useStoreState(store, (state) => composite && (state.virtualFocus || state.activeId === null)), 24469 ...props 24470 }); 24471 return props; 24472 }); 24473 var Composite6 = forwardRef70(function Composite7(props) { 24474 return createElement3(TagName5, useComposite(props)); 24475 }); 24476 24477 // node_modules/@ariakit/react-components/dist/disclosure/disclosure-context.js 24478 var ctx3 = createStoreContext(); 24479 var useDisclosureContext = ctx3.useContext; 24480 var useDisclosureScopedContext = ctx3.useScopedContext; 24481 var useDisclosureProviderContext = ctx3.useProviderContext; 24482 var DisclosureContextProvider = ctx3.ContextProvider; 24483 var DisclosureScopedContextProvider = ctx3.ScopedContextProvider; 24484 24485 // node_modules/@ariakit/react-components/dist/dialog/dialog-context.js 24486 var import_react23 = __toESM(require_react(), 1); 24487 var ctx4 = createStoreContext([DisclosureContextProvider], [DisclosureScopedContextProvider]); 24488 var useDialogContext = ctx4.useContext; 24489 var useDialogScopedContext = ctx4.useScopedContext; 24490 var useDialogProviderContext = ctx4.useProviderContext; 24491 var DialogContextProvider = ctx4.ContextProvider; 24492 var DialogScopedContextProvider = ctx4.ScopedContextProvider; 24493 var DialogHeadingContext = (0, import_react23.createContext)(void 0); 24494 var DialogDescriptionContext = (0, import_react23.createContext)(void 0); 24495 24496 // node_modules/@ariakit/react-components/dist/disclosure/disclosure-content.js 24497 var import_react24 = __toESM(require_react(), 1); 24498 var import_jsx_runtime118 = __toESM(require_jsx_runtime(), 1); 24499 var import_react_dom4 = __toESM(require_react_dom(), 1); 24500 var TagName6 = "div"; 24501 function afterTimeout(timeoutMs, cb) { 24502 const timeoutId = setTimeout(cb, timeoutMs); 24503 return () => clearTimeout(timeoutId); 24504 } 24505 function parseCSSTime(time) { 24506 const value = time?.trim() || "0s"; 24507 const multiplier = value.endsWith("ms") ? 1 : 1e3; 24508 const parsed = Number.parseFloat(value) * multiplier; 24509 return Number.isNaN(parsed) ? 0 : parsed; 24510 } 24511 function getEndTime(names, delays, durations) { 24512 const nameList = names.split(","); 24513 const delayList = delays.split(","); 24514 const durationList = durations.split(","); 24515 let endTime = 0; 24516 for (const [index2, name] of nameList.entries()) { 24517 if (name.trim() === "none") continue; 24518 const delay = parseCSSTime(delayList[index2 % delayList.length]); 24519 const duration = parseCSSTime(durationList[index2 % durationList.length]); 24520 endTime = Math.max(endTime, delay + duration); 24521 } 24522 return endTime; 24523 } 24524 function getElementEndTime(element) { 24525 const { transitionProperty, transitionDuration, transitionDelay, animationName, animationDuration, animationDelay } = getComputedStyle(element); 24526 return Math.max(getEndTime(transitionProperty, transitionDelay, transitionDuration), getEndTime(animationName, animationDelay, animationDuration)); 24527 } 24528 function isHidden3(mounted, hidden, alwaysVisible) { 24529 return !alwaysVisible && hidden !== false && (!mounted || !!hidden); 24530 } 24531 var useDisclosureContent = createHook(function useDisclosureContent2({ store, alwaysVisible, unstable_otherElementRef: otherElementRef, ...props }) { 24532 const context = useDisclosureProviderContext(); 24533 store = store || context; 24534 invariant(store, "DisclosureContent must receive a `store` prop or be wrapped in a DisclosureProvider component."); 24535 const ref = (0, import_react24.useRef)(null); 24536 const id = useId5(props.id); 24537 const [transition, setTransition] = (0, import_react24.useState)(null); 24538 const open = useStoreState(store, "open"); 24539 const mounted = useStoreState(store, "mounted"); 24540 const animated = useStoreState(store, "animated"); 24541 const contentElement = useStoreState(store, "contentElement"); 24542 const otherElement = useStoreState(store.disclosure, "contentElement"); 24543 const hasClosedRef = (0, import_react24.useRef)(false); 24544 useSafeLayoutEffect(() => { 24545 if (!ref.current) return; 24546 store?.setContentElement(ref.current); 24547 }, [store]); 24548 useSafeLayoutEffect(() => { 24549 let previousAnimated; 24550 store?.setState("animated", (animated2) => { 24551 previousAnimated = animated2; 24552 return true; 24553 }); 24554 return () => { 24555 if (previousAnimated === void 0) return; 24556 store?.setState("animated", previousAnimated); 24557 }; 24558 }, [store]); 24559 useSafeLayoutEffect(() => { 24560 if (!animated) { 24561 if (!open) { 24562 hasClosedRef.current = true; 24563 setTransition(null); 24564 } else if (hasClosedRef.current) { 24565 hasClosedRef.current = false; 24566 setTransition("enter"); 24567 } 24568 return; 24569 } 24570 if (!contentElement?.isConnected) { 24571 setTransition(null); 24572 return; 24573 } 24574 return afterPaint(() => { 24575 setTransition(open ? "enter" : mounted ? "leave" : null); 24576 }); 24577 }, [ 24578 animated, 24579 contentElement, 24580 open, 24581 mounted 24582 ]); 24583 useSafeLayoutEffect(() => { 24584 if (!store) return; 24585 if (!animated) return; 24586 if (!transition) return; 24587 if (!contentElement) return; 24588 const stopAnimation = () => store?.setState("animating", false); 24589 const stopAnimationSync = () => (0, import_react_dom4.flushSync)(stopAnimation); 24590 if (transition === "leave" && open) return; 24591 if (transition === "enter" && !open) return; 24592 if (typeof animated === "number") return afterTimeout(animated, stopAnimationSync); 24593 const elements = [contentElement]; 24594 if (otherElement) elements.push(otherElement); 24595 const relatedElement = otherElementRef?.current; 24596 if (relatedElement) elements.push(relatedElement); 24597 const timeout = Math.max(...elements.map(getElementEndTime)); 24598 if (!timeout) { 24599 if (transition === "enter") store.setState("animated", false); 24600 stopAnimation(); 24601 return; 24602 } 24603 return afterTimeout(Math.max(timeout - 1e3 / 60, 0), stopAnimationSync); 24604 }, [ 24605 store, 24606 animated, 24607 contentElement, 24608 otherElement, 24609 otherElementRef, 24610 open, 24611 transition 24612 ]); 24613 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(DialogScopedContextProvider, { 24614 value: store, 24615 children: element 24616 }), [store]); 24617 const hidden = isHidden3(mounted, props.hidden, alwaysVisible); 24618 const styleProp = props.style; 24619 const style = (0, import_react24.useMemo)(() => { 24620 if (hidden) return { 24621 ...styleProp, 24622 display: "none" 24623 }; 24624 return styleProp; 24625 }, [hidden, styleProp]); 24626 props = { 24627 "data-open": open || void 0, 24628 "data-enter": transition === "enter" || void 0, 24629 "data-leave": transition === "leave" || void 0, 24630 hidden, 24631 ...props, 24632 id, 24633 ref: useMergeRefs3(id ? store.setContentElement : null, ref, props.ref), 24634 style 24635 }; 24636 return removeUndefinedValues(props); 24637 }); 24638 var DisclosureContentImpl = forwardRef70(function DisclosureContentImpl2(props) { 24639 return createElement3(TagName6, useDisclosureContent(props)); 24640 }); 24641 var DisclosureContent = forwardRef70(function DisclosureContent2({ unmountOnHide, ...props }) { 24642 const context = useDisclosureProviderContext(); 24643 if (useStoreState(props.store || context, (state) => !unmountOnHide || state?.mounted) === false) return null; 24644 return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(DisclosureContentImpl, { ...props }); 24645 }); 24646 24647 // node_modules/@ariakit/components/dist/disclosure/disclosure-store.js 24648 function createDisclosureStore(props = {}) { 24649 const store = mergeStore(props.store, omit2(props.disclosure, ["contentElement", "disclosureElement"])); 24650 throwOnConflictingProps(props, store); 24651 const syncState = store?.getState(); 24652 const open = defaultValue(props.open, syncState?.open, props.defaultOpen, false); 24653 const animated = defaultValue(props.animated, syncState?.animated, false); 24654 const disclosure = createStore({ 24655 open, 24656 animated, 24657 animating: !!animated && open, 24658 mounted: open, 24659 contentElement: defaultValue(syncState?.contentElement, null), 24660 disclosureElement: defaultValue(syncState?.disclosureElement, null) 24661 }, store); 24662 setup(disclosure, () => sync(disclosure, ["animated", "animating"], (state) => { 24663 if (state.animated) return; 24664 disclosure.setState("animating", false); 24665 })); 24666 setup(disclosure, () => subscribe(disclosure, ["open"], () => { 24667 if (!disclosure.getState().animated) return; 24668 disclosure.setState("animating", true); 24669 })); 24670 setup(disclosure, () => sync(disclosure, ["open", "animating"], (state) => { 24671 disclosure.setState("mounted", state.open || state.animating); 24672 })); 24673 return { 24674 ...disclosure, 24675 disclosure: props.disclosure, 24676 setOpen: (value) => disclosure.setState("open", value), 24677 show: () => disclosure.setState("open", true), 24678 hide: () => disclosure.setState("open", false), 24679 toggle: () => disclosure.setState("open", (open2) => !open2), 24680 stopAnimation: () => disclosure.setState("animating", false), 24681 setContentElement: (value) => disclosure.setState("contentElement", value), 24682 setDisclosureElement: (value) => disclosure.setState("disclosureElement", value) 24683 }; 24684 } 24685 24686 // node_modules/@ariakit/react-components/dist/disclosure/disclosure-store.js 24687 function useDisclosureStoreProps(store, update2, props) { 24688 useUpdateEffect(update2, [props.store, props.disclosure]); 24689 useStoreProps(store, props, "open", "setOpen"); 24690 useStoreProps(store, props, "mounted", "setMounted"); 24691 useStoreProps(store, props, "animated"); 24692 return Object.assign(store, { disclosure: props.disclosure }); 24693 } 24694 24695 // node_modules/@ariakit/react-components/dist/popover/popover-context.js 24696 var ctx5 = createStoreContext([DialogContextProvider], [DialogScopedContextProvider]); 24697 var usePopoverContext = ctx5.useContext; 24698 var usePopoverScopedContext = ctx5.useScopedContext; 24699 var usePopoverProviderContext = ctx5.useProviderContext; 24700 var PopoverContextProvider = ctx5.ContextProvider; 24701 var PopoverScopedContextProvider = ctx5.ScopedContextProvider; 24702 24703 // node_modules/@ariakit/react-components/dist/combobox/combobox-context.js 24704 var import_react25 = __toESM(require_react(), 1); 24705 var ComboboxListRoleContext = (0, import_react25.createContext)(void 0); 24706 var ctx6 = createStoreContext([PopoverContextProvider, CompositeContextProvider], [PopoverScopedContextProvider, CompositeScopedContextProvider]); 24707 var useComboboxContext = ctx6.useContext; 24708 var useComboboxScopedContext = ctx6.useScopedContext; 24709 var useComboboxProviderContext = ctx6.useProviderContext; 24710 var ComboboxContextProvider = ctx6.ContextProvider; 24711 var ComboboxScopedContextProvider = ctx6.ScopedContextProvider; 24712 var ComboboxItemValueContext = (0, import_react25.createContext)(void 0); 24713 var ComboboxItemCheckedContext = (0, import_react25.createContext)(false); 24714 24715 // node_modules/@ariakit/react-components/dist/collection/collection-store.js 24716 function useCollectionStoreProps(store, update2, props) { 24717 useUpdateEffect(update2, [props.store]); 24718 useStoreProps(store, props, "items", "setItems"); 24719 return store; 24720 } 24721 24722 // node_modules/@ariakit/react-components/dist/composite/composite-store.js 24723 function useCompositeStoreOptions(props) { 24724 return { 24725 id: useId5(props.id), 24726 ...props 24727 }; 24728 } 24729 function useCompositeStoreProps(store, update2, props) { 24730 store = useCollectionStoreProps(store, update2, props); 24731 useStoreProps(store, props, "activeId", "setActiveId"); 24732 useStoreProps(store, props, "includesBaseElement"); 24733 useStoreProps(store, props, "virtualFocus"); 24734 useStoreProps(store, props, "orientation"); 24735 useStoreProps(store, props, "rtl"); 24736 useStoreProps(store, props, "focusLoop"); 24737 useStoreProps(store, props, "focusWrap"); 24738 useStoreProps(store, props, "focusShift"); 24739 return store; 24740 } 24741 24742 // node_modules/@ariakit/components/dist/dialog/dialog-store.js 24743 function createDialogStore(props = {}) { 24744 return createDisclosureStore(props); 24745 } 24746 24747 // node_modules/@ariakit/react-components/dist/dialog/dialog-store.js 24748 function useDialogStoreProps(store, update2, props) { 24749 return useDisclosureStoreProps(store, update2, props); 24750 } 24751 24752 // node_modules/@ariakit/components/dist/popover/popover-store.js 24753 function createPopoverStore({ popover: otherPopover, ...props } = {}) { 24754 const store = mergeStore(props.store, omit2(otherPopover, [ 24755 "arrowElement", 24756 "anchorElement", 24757 "contentElement", 24758 "popoverElement", 24759 "disclosureElement" 24760 ])); 24761 throwOnConflictingProps(props, store); 24762 const syncState = store?.getState(); 24763 const dialog = createDialogStore({ 24764 ...props, 24765 store 24766 }); 24767 const placement = defaultValue(props.placement, syncState?.placement, "bottom"); 24768 const popover = createStore({ 24769 ...dialog.getState(), 24770 placement, 24771 currentPlacement: placement, 24772 anchorElement: defaultValue(syncState?.anchorElement, null), 24773 popoverElement: defaultValue(syncState?.popoverElement, null), 24774 arrowElement: defaultValue(syncState?.arrowElement, null), 24775 rendered: /* @__PURE__ */ Symbol("rendered") 24776 }, dialog, store); 24777 return { 24778 ...dialog, 24779 ...popover, 24780 setAnchorElement: (element) => popover.setState("anchorElement", element), 24781 setPopoverElement: (element) => popover.setState("popoverElement", element), 24782 setArrowElement: (element) => popover.setState("arrowElement", element), 24783 render: () => popover.setState("rendered", /* @__PURE__ */ Symbol("rendered")) 24784 }; 24785 } 24786 24787 // node_modules/@ariakit/react-components/dist/popover/popover-store.js 24788 function usePopoverStoreProps(store, update2, props) { 24789 useUpdateEffect(update2, [props.popover]); 24790 useStoreProps(store, props, "placement"); 24791 return useDialogStoreProps(store, update2, props); 24792 } 24793 24794 // node_modules/@ariakit/react-components/dist/popover/popover-anchor.js 24795 var TagName7 = "div"; 24796 var usePopoverAnchor = createHook(function usePopoverAnchor2({ store, ...props }) { 24797 const context = usePopoverProviderContext(); 24798 store = store || context; 24799 props = { 24800 ...props, 24801 ref: useMergeRefs3(store?.setAnchorElement, props.ref) 24802 }; 24803 return props; 24804 }); 24805 var PopoverAnchor = forwardRef70(function PopoverAnchor2(props) { 24806 return createElement3(TagName7, usePopoverAnchor(props)); 24807 }); 24808 24809 // node_modules/@ariakit/react-components/dist/composite/composite-hover.js 24810 var import_react26 = __toESM(require_react(), 1); 24811 var TagName8 = "div"; 24812 function hoveringInside(event) { 24813 const nextElement = event.relatedTarget; 24814 if (!isElement2(nextElement)) return false; 24815 return contains2(event.currentTarget, nextElement); 24816 } 24817 var symbol2 = /* @__PURE__ */ Symbol("composite-hover"); 24818 function movingToAnotherItem(event) { 24819 const { relatedTarget } = event; 24820 if (!isElement2(relatedTarget)) return false; 24821 let dest = relatedTarget; 24822 do { 24823 if (hasOwnProperty(dest, symbol2) && dest[symbol2]) return true; 24824 dest = dest.parentElement; 24825 } while (dest); 24826 return false; 24827 } 24828 var useCompositeHover = createHook(function useCompositeHover2({ store, focusOnHover = true, blurOnHoverEnd = !!focusOnHover, ...props }) { 24829 const context = useCompositeScopedContext(); 24830 store = store || context; 24831 invariant(store, "CompositeHover must be wrapped in a Composite component."); 24832 const isMouseMoving = useIsMouseMoving(); 24833 const onMouseMoveProp = props.onMouseMove; 24834 const focusOnHoverProp = useBooleanEvent(focusOnHover); 24835 const onMouseMove = useEvent((event) => { 24836 onMouseMoveProp?.(event); 24837 if (event.defaultPrevented) return; 24838 if (!isMouseMoving()) return; 24839 if (!focusOnHoverProp(event)) return; 24840 if (!hasFocusWithin(event.currentTarget)) { 24841 const baseElement = store?.getState().baseElement; 24842 if (baseElement && !hasFocus(baseElement)) baseElement.focus(); 24843 } 24844 store?.setActiveId(event.currentTarget.id); 24845 }); 24846 const onMouseLeaveProp = props.onMouseLeave; 24847 const blurOnHoverEndProp = useBooleanEvent(blurOnHoverEnd); 24848 const onMouseLeave = useEvent((event) => { 24849 onMouseLeaveProp?.(event); 24850 if (event.defaultPrevented) return; 24851 if (!isMouseMoving()) return; 24852 if (hoveringInside(event)) return; 24853 if (movingToAnotherItem(event)) return; 24854 if (!focusOnHoverProp(event)) return; 24855 if (!blurOnHoverEndProp(event)) return; 24856 store?.setActiveId(null); 24857 store?.getState().baseElement?.focus(); 24858 }); 24859 const ref = (0, import_react26.useCallback)((element) => { 24860 if (!element) return; 24861 element[symbol2] = true; 24862 }, []); 24863 props = { 24864 ...props, 24865 ref: useMergeRefs3(ref, props.ref), 24866 onMouseMove, 24867 onMouseLeave 24868 }; 24869 return removeUndefinedValues(props); 24870 }); 24871 var CompositeHover = memo3(forwardRef70(function CompositeHover2(props) { 24872 return createElement3(TagName8, useCompositeHover(props)); 24873 })); 24874 24875 // node_modules/@ariakit/react-components/dist/combobox/combobox.js 24876 var import_react27 = __toESM(require_react(), 1); 24877 var TagName9 = "input"; 24878 function isFirstItemAutoSelected(items, activeValue, autoSelect) { 24879 if (!autoSelect) return false; 24880 return items.find((item) => !item.disabled && item.value)?.value === activeValue; 24881 } 24882 function hasCompletionString(value, activeValue) { 24883 if (!activeValue) return false; 24884 if (value == null) return false; 24885 const normalizedValue = normalizeString(value); 24886 const normalizedActiveValue = normalizeString(activeValue); 24887 if (normalizedValue.length !== value.length) return false; 24888 if (normalizedActiveValue.length !== activeValue.length) return false; 24889 return normalizedActiveValue.length > normalizedValue.length && normalizedActiveValue.toLowerCase().startsWith(normalizedValue.toLowerCase()); 24890 } 24891 function isAriaAutoCompleteValue(value) { 24892 return value === "inline" || value === "list" || value === "both" || value === "none"; 24893 } 24894 function getDefaultAutoSelectId(items) { 24895 return items.find((item) => { 24896 if (item.disabled) return false; 24897 return item.element?.getAttribute("role") !== "tab"; 24898 })?.id; 24899 } 24900 var useCombobox = createHook(function useCombobox2({ store, focusable: focusable2 = true, autoSelect: autoSelectProp = false, getAutoSelectId, setValueOnChange, showMinLength = 0, showOnChange, showOnMouseDown, showOnClick = showOnMouseDown, showOnKeyDown, showOnKeyPress = showOnKeyDown, blurActiveItemOnClick, setValueOnClick = true, moveOnKeyPress = true, autoComplete = "list", ...props }) { 24901 const context = useComboboxProviderContext(); 24902 store = store || context; 24903 invariant(store, "Combobox must receive a `store` prop or be wrapped in a ComboboxProvider component."); 24904 const ref = (0, import_react27.useRef)(null); 24905 const [valueUpdated, forceValueUpdate] = useForceUpdate(); 24906 const canAutoSelectRef = (0, import_react27.useRef)(false); 24907 const composingRef = (0, import_react27.useRef)(false); 24908 const autoSelect = useStoreState(store, (state) => state.virtualFocus && autoSelectProp); 24909 const inline4 = autoComplete === "inline" || autoComplete === "both"; 24910 const [canInline, setCanInline] = (0, import_react27.useState)(inline4); 24911 useUpdateLayoutEffect(() => { 24912 if (!inline4) return; 24913 setCanInline(true); 24914 }, [inline4]); 24915 const storeValue = useStoreState(store, "value"); 24916 const prevSelectedValueRef = (0, import_react27.useRef)(void 0); 24917 (0, import_react27.useEffect)(() => { 24918 return sync(store, ["selectedValue", "activeId"], (_, prev) => { 24919 prevSelectedValueRef.current = prev.selectedValue; 24920 }); 24921 }, [store]); 24922 const inlineActiveValue = useStoreState(store, (state) => { 24923 if (!inline4) return; 24924 if (!canInline) return; 24925 if (state.activeValue && Array.isArray(state.selectedValue)) { 24926 if (state.selectedValue.includes(state.activeValue)) return; 24927 if (prevSelectedValueRef.current?.includes(state.activeValue)) return; 24928 } 24929 return state.activeValue; 24930 }); 24931 const items = useStoreState(store, "renderedItems"); 24932 const open = useStoreState(store, "open"); 24933 const contentElement = useStoreState(store, "contentElement"); 24934 const value = (0, import_react27.useMemo)(() => { 24935 if (!inline4) return storeValue; 24936 if (!canInline) return storeValue; 24937 if (isFirstItemAutoSelected(items, inlineActiveValue, autoSelect)) { 24938 if (hasCompletionString(storeValue, inlineActiveValue)) return storeValue + (inlineActiveValue?.slice(storeValue.length) || ""); 24939 return storeValue; 24940 } 24941 return inlineActiveValue || storeValue; 24942 }, [ 24943 inline4, 24944 canInline, 24945 items, 24946 inlineActiveValue, 24947 autoSelect, 24948 storeValue 24949 ]); 24950 (0, import_react27.useEffect)(() => { 24951 const element = ref.current; 24952 if (!element) return; 24953 const onCompositeItemMove = () => setCanInline(true); 24954 element.addEventListener("combobox-item-move", onCompositeItemMove); 24955 return () => { 24956 element.removeEventListener("combobox-item-move", onCompositeItemMove); 24957 }; 24958 }, []); 24959 (0, import_react27.useEffect)(() => { 24960 if (!inline4) return; 24961 if (!canInline) return; 24962 if (!inlineActiveValue) return; 24963 if (!isFirstItemAutoSelected(items, inlineActiveValue, autoSelect)) return; 24964 if (!hasCompletionString(storeValue, inlineActiveValue)) return; 24965 let cleanup = noop4; 24966 queueMicrotask(() => { 24967 const element = ref.current; 24968 if (!element) return; 24969 const { start: prevStart, end: prevEnd } = getTextboxSelection(element); 24970 const nextStart = storeValue.length; 24971 const nextEnd = inlineActiveValue.length; 24972 setSelectionRange(element, nextStart, nextEnd); 24973 cleanup = () => { 24974 if (!hasFocus(element)) return; 24975 const { start, end } = getTextboxSelection(element); 24976 if (start !== nextStart) return; 24977 if (end !== nextEnd) return; 24978 setSelectionRange(element, prevStart, prevEnd); 24979 }; 24980 }); 24981 return () => cleanup(); 24982 }, [ 24983 valueUpdated, 24984 inline4, 24985 canInline, 24986 inlineActiveValue, 24987 items, 24988 autoSelect, 24989 storeValue 24990 ]); 24991 const getAutoSelectIdProp = useEvent(getAutoSelectId); 24992 const autoSelectIdRef = (0, import_react27.useRef)(null); 24993 const autoSelectMovedRef = (0, import_react27.useRef)(void 0); 24994 const userScrolledRef = (0, import_react27.useRef)(false); 24995 const isAutoScrollingRef = (0, import_react27.useRef)(false); 24996 (0, import_react27.useEffect)(() => { 24997 if (!open) return; 24998 if (!contentElement) return; 24999 const scrollingElement = getScrollingElement(contentElement); 25000 if (!scrollingElement) return; 25001 const onUserScroll = () => { 25002 canAutoSelectRef.current = false; 25003 userScrolledRef.current = true; 25004 }; 25005 const onScroll = () => { 25006 if (!isAutoScrollingRef.current) userScrolledRef.current = true; 25007 if (!store) return; 25008 if (!canAutoSelectRef.current) return; 25009 const { activeId } = store.getState(); 25010 if (activeId === null) return; 25011 if (activeId === autoSelectIdRef.current) return; 25012 canAutoSelectRef.current = false; 25013 }; 25014 const options = { 25015 passive: true, 25016 capture: true 25017 }; 25018 scrollingElement.addEventListener("wheel", onUserScroll, options); 25019 scrollingElement.addEventListener("touchmove", onUserScroll, options); 25020 scrollingElement.addEventListener("scroll", onScroll, options); 25021 return () => { 25022 scrollingElement.removeEventListener("wheel", onUserScroll, true); 25023 scrollingElement.removeEventListener("touchmove", onUserScroll, true); 25024 scrollingElement.removeEventListener("scroll", onScroll, true); 25025 }; 25026 }, [ 25027 open, 25028 contentElement, 25029 store 25030 ]); 25031 useSafeLayoutEffect(() => { 25032 userScrolledRef.current = false; 25033 if (!storeValue) return; 25034 if (composingRef.current) return; 25035 canAutoSelectRef.current = true; 25036 }, [storeValue]); 25037 useSafeLayoutEffect(() => { 25038 if (autoSelect !== "always" && open) return; 25039 canAutoSelectRef.current = open; 25040 }, [autoSelect, open]); 25041 useSafeLayoutEffect(() => { 25042 if (open) return; 25043 autoSelectMovedRef.current = void 0; 25044 }, [open]); 25045 const resetValueOnSelect = useStoreState(store, "resetValueOnSelect"); 25046 useUpdateEffect(() => { 25047 const canAutoSelect = canAutoSelectRef.current; 25048 if (!store) return; 25049 if (!open) return; 25050 if (!canAutoSelect && (!resetValueOnSelect || userScrolledRef.current)) return; 25051 const { baseElement, contentElement: contentElement2, activeId } = store.getState(); 25052 if (baseElement && !hasFocus(baseElement)) return; 25053 if (contentElement2?.hasAttribute("data-placing")) { 25054 const observer = new MutationObserver(forceValueUpdate); 25055 observer.observe(contentElement2, { attributeFilter: ["data-placing"] }); 25056 return () => observer.disconnect(); 25057 } 25058 if (autoSelect && canAutoSelect) { 25059 const userAutoSelectId = getAutoSelectIdProp(items); 25060 const autoSelectId = userAutoSelectId !== void 0 ? userAutoSelectId : getDefaultAutoSelectId(items) ?? store.first(); 25061 autoSelectIdRef.current = autoSelectId; 25062 const nextActiveId = autoSelectId ?? null; 25063 const nextActiveValue = store.item(nextActiveId)?.value; 25064 const moved = autoSelectMovedRef.current; 25065 if (nextActiveId !== activeId || moved?.id !== nextActiveId || moved?.value !== nextActiveValue) { 25066 autoSelectMovedRef.current = { 25067 id: nextActiveId, 25068 value: nextActiveValue 25069 }; 25070 store.move(nextActiveId); 25071 } else store.setState("activeValue", nextActiveValue); 25072 } else { 25073 const element = store.item(activeId || store.first())?.element; 25074 if (element && "scrollIntoView" in element) { 25075 isAutoScrollingRef.current = true; 25076 element.scrollIntoView({ 25077 block: "nearest", 25078 inline: "nearest" 25079 }); 25080 requestAnimationFrame(() => { 25081 isAutoScrollingRef.current = false; 25082 }); 25083 } 25084 } 25085 }, [ 25086 store, 25087 open, 25088 valueUpdated, 25089 storeValue, 25090 autoSelect, 25091 resetValueOnSelect, 25092 getAutoSelectIdProp, 25093 items 25094 ]); 25095 (0, import_react27.useEffect)(() => { 25096 if (!inline4) return; 25097 const combobox = ref.current; 25098 if (!combobox) return; 25099 const elements = [combobox, contentElement].filter((value2) => !!value2); 25100 const onBlur2 = (event) => { 25101 if (elements.every((el) => isFocusEventOutside(event, el))) store?.setValue(value); 25102 }; 25103 for (const element of elements) element.addEventListener("focusout", onBlur2); 25104 return () => { 25105 for (const element of elements) element.removeEventListener("focusout", onBlur2); 25106 }; 25107 }, [ 25108 inline4, 25109 contentElement, 25110 store, 25111 value 25112 ]); 25113 const canShow = (event) => { 25114 return event.currentTarget.value.length >= showMinLength; 25115 }; 25116 const onChangeProp = props.onChange; 25117 const showOnChangeProp = useBooleanEvent(showOnChange ?? canShow); 25118 const setValueOnChangeProp = useBooleanEvent(setValueOnChange ?? !store.tag); 25119 const onChange = useEvent((event) => { 25120 onChangeProp?.(event); 25121 if (event.defaultPrevented) return; 25122 if (!store) return; 25123 const currentTarget = event.currentTarget; 25124 const { value: value2, selectionStart, selectionEnd } = currentTarget; 25125 const nativeEvent = event.nativeEvent; 25126 canAutoSelectRef.current = true; 25127 if (isInputEvent(nativeEvent)) { 25128 if (nativeEvent.isComposing) { 25129 canAutoSelectRef.current = false; 25130 composingRef.current = true; 25131 } 25132 if (inline4) { 25133 const textInserted = nativeEvent.inputType === "insertText" || nativeEvent.inputType === "insertCompositionText"; 25134 const caretAtEnd = selectionStart === value2.length; 25135 setCanInline(textInserted && caretAtEnd); 25136 } 25137 } 25138 if (setValueOnChangeProp(event)) { 25139 const isSameValue2 = value2 === store.getState().value; 25140 store.setValue(value2); 25141 queueMicrotask(() => { 25142 setSelectionRange(currentTarget, selectionStart, selectionEnd); 25143 }); 25144 if (inline4 && autoSelect && isSameValue2) forceValueUpdate(); 25145 } 25146 if (showOnChangeProp(event)) store.show(); 25147 if (!autoSelect || !canAutoSelectRef.current) store.setActiveId(null); 25148 }); 25149 const onCompositionEndProp = props.onCompositionEnd; 25150 const onCompositionEnd = useEvent((event) => { 25151 canAutoSelectRef.current = true; 25152 composingRef.current = false; 25153 onCompositionEndProp?.(event); 25154 if (event.defaultPrevented) return; 25155 if (!autoSelect) return; 25156 forceValueUpdate(); 25157 }); 25158 const onMouseDownProp = props.onMouseDown; 25159 const blurActiveItemOnClickProp = useBooleanEvent(blurActiveItemOnClick ?? (() => store.getState().includesBaseElement)); 25160 const setValueOnClickProp = useBooleanEvent(setValueOnClick); 25161 const showOnClickProp = useBooleanEvent(showOnClick ?? canShow); 25162 const onMouseDown = useEvent((event) => { 25163 onMouseDownProp?.(event); 25164 if (event.defaultPrevented) return; 25165 if (event.button) return; 25166 if (event.ctrlKey) return; 25167 if (!store) return; 25168 if (blurActiveItemOnClickProp(event)) store.setActiveId(null); 25169 if (setValueOnClickProp(event)) store.setValue(value); 25170 if (showOnClickProp(event)) queueBeforeEvent(event.currentTarget, "mouseup", store.show); 25171 }); 25172 const onKeyDownProp = props.onKeyDown; 25173 const showOnKeyPressProp = useBooleanEvent(showOnKeyPress ?? canShow); 25174 const onKeyDown = useEvent((event) => { 25175 onKeyDownProp?.(event); 25176 if (!event.repeat) canAutoSelectRef.current = false; 25177 if (event.defaultPrevented) return; 25178 if (!store) return; 25179 const { open: open2 } = store.getState(); 25180 if (open2 && event.key === "Enter") { 25181 event.preventDefault(); 25182 return; 25183 } 25184 if (event.ctrlKey) return; 25185 if (event.altKey) return; 25186 if (event.shiftKey) return; 25187 if (event.metaKey) return; 25188 if (open2) return; 25189 if (event.key === "ArrowUp" || event.key === "ArrowDown") { 25190 if (showOnKeyPressProp(event)) { 25191 event.preventDefault(); 25192 store.show(); 25193 } 25194 } 25195 }); 25196 const onBlurProp = props.onBlur; 25197 const onBlur = useEvent((event) => { 25198 canAutoSelectRef.current = false; 25199 onBlurProp?.(event); 25200 }); 25201 const id = useId5(props.id); 25202 const ariaAutoComplete = isAriaAutoCompleteValue(autoComplete) ? autoComplete : void 0; 25203 const isActiveItem = useStoreState(store, (state) => state.activeId === null); 25204 props = { 25205 role: "combobox", 25206 "aria-autocomplete": ariaAutoComplete, 25207 "aria-haspopup": getPopupRole(contentElement, "listbox"), 25208 "aria-expanded": open, 25209 "aria-controls": contentElement?.id, 25210 "data-active-item": isActiveItem || void 0, 25211 value, 25212 ...props, 25213 id, 25214 ref: useMergeRefs3(ref, props.ref), 25215 onChange, 25216 onCompositionEnd, 25217 onMouseDown, 25218 onKeyDown, 25219 onBlur 25220 }; 25221 props = useComposite({ 25222 store, 25223 focusable: focusable2, 25224 ...props, 25225 moveOnKeyPress: (event) => { 25226 if (isFalsyBooleanCallback(moveOnKeyPress, event)) return false; 25227 if (inline4) setCanInline(true); 25228 return true; 25229 } 25230 }); 25231 props = usePopoverAnchor({ 25232 store, 25233 ...props 25234 }); 25235 return { 25236 autoComplete: "off", 25237 ...props 25238 }; 25239 }); 25240 var Combobox = forwardRef70(function Combobox2(props) { 25241 return createElement3(TagName9, useCombobox(props)); 25242 }); 25243 25244 // node_modules/@ariakit/react-components/dist/combobox/combobox-item.js 25245 var import_react28 = __toESM(require_react(), 1); 25246 var import_jsx_runtime119 = __toESM(require_jsx_runtime(), 1); 25247 var TagName10 = "div"; 25248 function isSelected(storeValue, itemValue) { 25249 if (itemValue == null) return; 25250 if (storeValue == null) return false; 25251 if (Array.isArray(storeValue)) return storeValue.includes(itemValue); 25252 return storeValue === itemValue; 25253 } 25254 function getItemRole(popupRole) { 25255 return getItemRoleByPopupRole(popupRole) ?? "option"; 25256 } 25257 var useComboboxItem = createHook(function useComboboxItem2({ store, value, hideOnClick, setValueOnClick, selectValueOnClick = true, resetValueOnSelect, focusOnHover = false, moveOnKeyPress = true, getItem: getItemProp, ...props }) { 25258 const context = useComboboxScopedContext(); 25259 store = store || context; 25260 invariant(store, "ComboboxItem must be wrapped in a ComboboxList or ComboboxPopover component."); 25261 const { resetValueOnSelectState, multiSelectable, selected } = useStoreStateObject(store, { 25262 resetValueOnSelectState: "resetValueOnSelect", 25263 multiSelectable(state) { 25264 return Array.isArray(state.selectedValue); 25265 }, 25266 selected(state) { 25267 return isSelected(state.selectedValue, value); 25268 } 25269 }); 25270 const getItem = (0, import_react28.useCallback)((item) => { 25271 const nextItem = { 25272 ...item, 25273 value 25274 }; 25275 if (getItemProp) return getItemProp(nextItem); 25276 return nextItem; 25277 }, [value, getItemProp]); 25278 setValueOnClick = setValueOnClick ?? !multiSelectable; 25279 hideOnClick = hideOnClick ?? (value != null && !multiSelectable); 25280 const onClickProp = props.onClick; 25281 const setValueOnClickProp = useBooleanEvent(setValueOnClick); 25282 const selectValueOnClickProp = useBooleanEvent(selectValueOnClick); 25283 const resetValueOnSelectProp = useBooleanEvent(resetValueOnSelect ?? resetValueOnSelectState ?? multiSelectable); 25284 const hideOnClickProp = useBooleanEvent(hideOnClick); 25285 const onClick = useEvent((event) => { 25286 onClickProp?.(event); 25287 if (event.defaultPrevented) return; 25288 if (isDownloading(event)) return; 25289 if (isOpeningInNewTab(event)) return; 25290 if (value != null) { 25291 if (selectValueOnClickProp(event)) { 25292 if (resetValueOnSelectProp(event)) store?.resetValue(); 25293 store?.setSelectedValue((prevValue) => { 25294 if (!Array.isArray(prevValue)) return value; 25295 if (prevValue.includes(value)) return prevValue.filter((v2) => v2 !== value); 25296 return [...prevValue, value]; 25297 }); 25298 } 25299 if (setValueOnClickProp(event)) store?.setValue(value); 25300 } 25301 if (hideOnClickProp(event)) store?.hide(); 25302 }); 25303 const onKeyDownProp = props.onKeyDown; 25304 const onKeyDown = useEvent((event) => { 25305 onKeyDownProp?.(event); 25306 if (event.defaultPrevented) return; 25307 const baseElement = store?.getState().baseElement; 25308 if (!baseElement) return; 25309 if (hasFocus(baseElement)) return; 25310 const printable = event.key.length === 1 && !event.ctrlKey && !event.metaKey; 25311 const paste = (!isApple() ? event.ctrlKey : event.metaKey) && event.key.toLowerCase() === "v"; 25312 const deleteKey = event.key === "Backspace" || event.key === "Delete"; 25313 if (printable || paste || deleteKey) { 25314 queueMicrotask(() => baseElement.focus()); 25315 if (isTextField(baseElement)) store?.setValue(baseElement.value); 25316 } 25317 }); 25318 if (multiSelectable && selected != null) props = { 25319 "aria-selected": selected, 25320 ...props 25321 }; 25322 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(ComboboxItemValueContext.Provider, { 25323 value, 25324 children: /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(ComboboxItemCheckedContext.Provider, { 25325 value: selected ?? false, 25326 children: element 25327 }) 25328 }), [value, selected]); 25329 props = { 25330 role: getItemRole((0, import_react28.useContext)(ComboboxListRoleContext)), 25331 children: value, 25332 ...props, 25333 onClick, 25334 onKeyDown 25335 }; 25336 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress); 25337 props = useCompositeItem({ 25338 store, 25339 ...props, 25340 getItem, 25341 moveOnKeyPress: (event) => { 25342 if (!moveOnKeyPressProp(event)) return false; 25343 const moveEvent = new Event("combobox-item-move"); 25344 store?.getState().baseElement?.dispatchEvent(moveEvent); 25345 return true; 25346 } 25347 }); 25348 props = useCompositeHover({ 25349 store, 25350 focusOnHover, 25351 ...props 25352 }); 25353 return props; 25354 }); 25355 var ComboboxItem = memo3(forwardRef70(function ComboboxItem2(props) { 25356 return createElement3(TagName10, useComboboxItem(props)); 25357 })); 25358 25359 // node_modules/@ariakit/react-components/dist/combobox/combobox-item-value.js 25360 var import_react29 = __toESM(require_react(), 1); 25361 var import_jsx_runtime120 = __toESM(require_jsx_runtime(), 1); 25362 var TagName11 = "span"; 25363 function normalizeValue(value) { 25364 return normalizeString(value).toLowerCase(); 25365 } 25366 function getOffsets(string, values) { 25367 const offsets = []; 25368 for (const value of values) { 25369 if (!value) continue; 25370 let pos = 0; 25371 const length = value.length; 25372 let index2 = string.indexOf(value, pos); 25373 while (index2 !== -1) { 25374 offsets.push([index2, length]); 25375 pos = index2 + 1; 25376 index2 = string.indexOf(value, pos); 25377 } 25378 } 25379 return offsets; 25380 } 25381 function mergeOverlappingOffsets(offsets) { 25382 offsets.sort(([a2], [b2]) => a2 - b2); 25383 const merged = []; 25384 for (const [offset4, length] of offsets) { 25385 const last = merged[merged.length - 1]; 25386 if (last && offset4 < last[0] + last[1]) last[1] = Math.max(last[1], offset4 + length - last[0]); 25387 else merged.push([offset4, length]); 25388 } 25389 return merged; 25390 } 25391 function getNormalizedIndexes(itemValue) { 25392 const starts = []; 25393 const ends = []; 25394 let index2 = 0; 25395 for (const char of itemValue) { 25396 const normalizedLength = normalizeValue(char).length; 25397 for (let i2 = 0; i2 < normalizedLength; i2 += 1) { 25398 starts.push(i2 === 0 ? index2 : -1); 25399 ends.push(index2); 25400 } 25401 index2 += char.length; 25402 } 25403 starts.push(itemValue.length); 25404 ends.push(itemValue.length); 25405 let nextBoundary = itemValue.length; 25406 for (let i2 = starts.length - 1; i2 >= 0; i2 -= 1) { 25407 const start = starts[i2]; 25408 if (start == null) continue; 25409 if (start === -1) starts[i2] = nextBoundary; 25410 else nextBoundary = start; 25411 } 25412 return { 25413 starts, 25414 ends 25415 }; 25416 } 25417 function toOriginalOffsets(itemValue, normalizedOffsets) { 25418 if (!normalizedOffsets.length) return normalizedOffsets; 25419 const { starts, ends } = getNormalizedIndexes(itemValue); 25420 const offsets = []; 25421 for (const [normalizedOffset, normalizedLength] of normalizedOffsets) { 25422 const start = starts[normalizedOffset]; 25423 const end = ends[normalizedOffset + normalizedLength]; 25424 if (start == null || end == null) continue; 25425 if (end <= start) continue; 25426 offsets.push([start, end - start]); 25427 } 25428 return offsets; 25429 } 25430 function splitValue(itemValue, userValue) { 25431 if (!itemValue) return itemValue; 25432 if (!userValue) return itemValue; 25433 const userValues = toArray(userValue).map(normalizeValue); 25434 const parts = []; 25435 const span = (value, autocomplete = false) => /* @__PURE__ */ (0, import_jsx_runtime120.jsx)("span", { 25436 "data-autocomplete-value": autocomplete ? "" : void 0, 25437 "data-user-value": autocomplete ? void 0 : "", 25438 children: value 25439 }, parts.length); 25440 const offsets = toOriginalOffsets(itemValue, mergeOverlappingOffsets(getOffsets(normalizeValue(itemValue), new Set(userValues)))); 25441 const firstEntry = offsets[0]; 25442 if (!firstEntry) { 25443 parts.push(span(itemValue, true)); 25444 return parts; 25445 } 25446 const [firstOffset] = firstEntry; 25447 [itemValue.slice(0, firstOffset), ...offsets.flatMap(([offset4, length], i2) => { 25448 const value = itemValue.slice(offset4, offset4 + length); 25449 const nextOffset = offsets[i2 + 1]?.[0]; 25450 return [value, itemValue.slice(offset4 + length, nextOffset)]; 25451 })].forEach((value, i2) => { 25452 if (!value) return; 25453 parts.push(span(value, i2 % 2 === 0)); 25454 }); 25455 return parts; 25456 } 25457 var useComboboxItemValue = createHook(function useComboboxItemValue2({ store, value, userValue, ...props }) { 25458 const context = useComboboxScopedContext(); 25459 store = store || context; 25460 const itemContext = (0, import_react29.useContext)(ComboboxItemValueContext); 25461 const itemValue = value ?? itemContext; 25462 const inputValue = useStoreState(store, (state) => userValue ?? state?.value); 25463 props = { 25464 children: (0, import_react29.useMemo)(() => { 25465 if (!itemValue) return; 25466 if (!inputValue) return itemValue; 25467 return splitValue(itemValue, inputValue); 25468 }, [itemValue, inputValue]), 25469 ...props 25470 }; 25471 return removeUndefinedValues(props); 25472 }); 25473 var ComboboxItemValue = forwardRef70(function ComboboxItemValue2(props) { 25474 return createElement3(TagName11, useComboboxItemValue(props)); 25475 }); 25476 25477 // node_modules/@ariakit/react-components/dist/combobox/combobox-label.js 25478 var TagName12 = "label"; 25479 var useComboboxLabel = createHook(function useComboboxLabel2({ store, ...props }) { 25480 const context = useComboboxProviderContext(); 25481 store = store || context; 25482 invariant(store, "ComboboxLabel must receive a `store` prop or be wrapped in a ComboboxProvider component."); 25483 props = { 25484 htmlFor: useStoreState(store, (state) => state.baseElement?.id), 25485 ...props 25486 }; 25487 return removeUndefinedValues(props); 25488 }); 25489 var ComboboxLabel = memo3(forwardRef70(function ComboboxLabel2(props) { 25490 return createElement3(TagName12, useComboboxLabel(props)); 25491 })); 25492 25493 // node_modules/@ariakit/react-components/dist/combobox/combobox-list.js 25494 var import_react30 = __toESM(require_react(), 1); 25495 var import_jsx_runtime121 = __toESM(require_jsx_runtime(), 1); 25496 var TagName13 = "div"; 25497 var useComboboxList = createHook(function useComboboxList2({ store, alwaysVisible, ...props }) { 25498 const scopedContext = useComboboxScopedContext(true); 25499 const context = useComboboxContext(); 25500 store = store || context; 25501 const scopedContextSameStore = !!store && store === scopedContext; 25502 invariant(store, "ComboboxList must receive a `store` prop or be wrapped in a ComboboxProvider component."); 25503 const ref = (0, import_react30.useRef)(null); 25504 const id = useId5(props.id); 25505 const mounted = useStoreState(store, "mounted"); 25506 const hidden = isHidden3(mounted, props.hidden, alwaysVisible); 25507 const style = hidden ? { 25508 ...props.style, 25509 display: "none" 25510 } : props.style; 25511 const multiSelectable = useStoreState(store, (state) => Array.isArray(state.selectedValue)); 25512 const role = useAttribute(ref, "role", props.role); 25513 const ariaMultiSelectable = role === "listbox" || role === "tree" || role === "grid" ? multiSelectable || void 0 : void 0; 25514 const [hasListboxInside, setHasListboxInside] = (0, import_react30.useState)(false); 25515 const contentElement = useStoreState(store, "contentElement"); 25516 useSafeLayoutEffect(() => { 25517 if (!mounted) return; 25518 const element = ref.current; 25519 if (!element) return; 25520 if (contentElement !== element) return; 25521 const callback = () => { 25522 setHasListboxInside(!!element.querySelector("[role='listbox']")); 25523 }; 25524 const observer = new MutationObserver(callback); 25525 observer.observe(element, { 25526 subtree: true, 25527 childList: true, 25528 attributeFilter: ["role"] 25529 }); 25530 callback(); 25531 return () => observer.disconnect(); 25532 }, [mounted, contentElement]); 25533 if (!hasListboxInside) props = { 25534 role: "listbox", 25535 "aria-multiselectable": ariaMultiSelectable, 25536 ...props 25537 }; 25538 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(ComboboxScopedContextProvider, { 25539 value: store, 25540 children: /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(ComboboxListRoleContext.Provider, { 25541 value: role, 25542 children: element 25543 }) 25544 }), [store, role]); 25545 const setContentElement = id && (!scopedContext || !scopedContextSameStore) ? store.setContentElement : null; 25546 props = { 25547 hidden, 25548 ...props, 25549 id, 25550 ref: useMergeRefs3(setContentElement, ref, props.ref), 25551 style 25552 }; 25553 return removeUndefinedValues(props); 25554 }); 25555 var ComboboxList = forwardRef70(function ComboboxList2(props) { 25556 return createElement3(TagName13, useComboboxList(props)); 25557 }); 25558 25559 // node_modules/@ariakit/react-components/dist/tag/tag-context.js 25560 var import_react31 = __toESM(require_react(), 1); 25561 var TagValueContext = (0, import_react31.createContext)(null); 25562 var TagRemoveIdContext = (0, import_react31.createContext)(null); 25563 var ctx7 = createStoreContext([CompositeContextProvider], [CompositeScopedContextProvider]); 25564 var useTagContext = ctx7.useContext; 25565 var useTagScopedContext = ctx7.useScopedContext; 25566 var useTagProviderContext = ctx7.useProviderContext; 25567 var TagContextProvider = ctx7.ContextProvider; 25568 var TagScopedContextProvider = ctx7.ScopedContextProvider; 25569 25570 // node_modules/@ariakit/components/dist/combobox/combobox-store.js 25571 var isTouchSafari = isSafari() && isTouchDevice(); 25572 function createComboboxStore({ tag, ...props } = {}) { 25573 const store = mergeStore(props.store, pick2(tag, ["value", "rtl"])); 25574 throwOnConflictingProps(props, store); 25575 const tagState = tag?.getState(); 25576 const syncState = store?.getState(); 25577 const activeId = defaultValue(props.activeId, syncState?.activeId, props.defaultActiveId, null); 25578 const composite = createCompositeStore({ 25579 ...props, 25580 activeId, 25581 includesBaseElement: defaultValue(props.includesBaseElement, syncState?.includesBaseElement, true), 25582 orientation: defaultValue(props.orientation, syncState?.orientation, "vertical"), 25583 focusLoop: defaultValue(props.focusLoop, syncState?.focusLoop, true), 25584 focusWrap: defaultValue(props.focusWrap, syncState?.focusWrap, true), 25585 virtualFocus: defaultValue(props.virtualFocus, syncState?.virtualFocus, true) 25586 }); 25587 const popover = createPopoverStore({ 25588 ...props, 25589 placement: defaultValue(props.placement, syncState?.placement, "bottom-start") 25590 }); 25591 const value = defaultValue(props.value, syncState?.value, props.defaultValue, ""); 25592 const selectedValue = defaultValue(props.selectedValue, syncState?.selectedValue, tagState?.values, props.defaultSelectedValue, ""); 25593 const multiSelectable = Array.isArray(selectedValue); 25594 const initialState = { 25595 ...composite.getState(), 25596 ...popover.getState(), 25597 value, 25598 selectedValue, 25599 resetValueOnSelect: defaultValue(props.resetValueOnSelect, syncState?.resetValueOnSelect, multiSelectable), 25600 resetValueOnHide: defaultValue(props.resetValueOnHide, syncState?.resetValueOnHide, multiSelectable && !tag), 25601 activeValue: syncState?.activeValue 25602 }; 25603 const combobox = createStore(initialState, composite, popover, store); 25604 if (isTouchSafari) setup(combobox, () => sync(combobox, ["virtualFocus"], () => { 25605 combobox.setState("virtualFocus", false); 25606 })); 25607 setup(combobox, () => { 25608 if (!tag) return; 25609 return chain(sync(combobox, ["selectedValue"], (state) => { 25610 if (!Array.isArray(state.selectedValue)) return; 25611 tag.setValues(state.selectedValue); 25612 }), sync(tag, ["values"], (state) => { 25613 combobox.setState("selectedValue", state.values); 25614 })); 25615 }); 25616 setup(combobox, () => sync(combobox, ["resetValueOnHide", "mounted"], (state) => { 25617 if (!state.resetValueOnHide) return; 25618 if (state.mounted) return; 25619 combobox.setState("value", value); 25620 })); 25621 setup(combobox, () => sync(combobox, ["open"], (state) => { 25622 if (state.open) return; 25623 combobox.setState("activeId", activeId); 25624 combobox.setState("moves", 0); 25625 })); 25626 setup(combobox, () => sync(combobox, ["moves", "activeId"], (state, prevState) => { 25627 if (state.moves === prevState.moves) combobox.setState("activeValue", void 0); 25628 })); 25629 setup(combobox, () => batch(combobox, ["moves", "renderedItems"], (state, prev) => { 25630 if (state.moves === prev.moves) return; 25631 const { activeId: activeId2 } = combobox.getState(); 25632 const activeItem = composite.item(activeId2); 25633 combobox.setState("activeValue", activeItem?.value); 25634 })); 25635 return { 25636 ...popover, 25637 ...composite, 25638 ...combobox, 25639 tag, 25640 setValue: (value2) => combobox.setState("value", value2), 25641 resetValue: () => combobox.setState("value", initialState.value), 25642 setSelectedValue: (selectedValue2) => combobox.setState("selectedValue", selectedValue2) 25643 }; 25644 } 25645 25646 // node_modules/@ariakit/react-components/dist/combobox/combobox-store.js 25647 function useComboboxStoreOptions(props) { 25648 const tag = useTagContext(); 25649 props = { 25650 ...props, 25651 tag: props.tag !== void 0 ? props.tag : tag 25652 }; 25653 return useCompositeStoreOptions(props); 25654 } 25655 function useComboboxStoreProps(store, update2, props) { 25656 useUpdateEffect(update2, [props.tag]); 25657 useStoreProps(store, props, "value", "setValue"); 25658 useStoreProps(store, props, "selectedValue", "setSelectedValue"); 25659 useStoreProps(store, props, "resetValueOnHide"); 25660 useStoreProps(store, props, "resetValueOnSelect"); 25661 return Object.assign(useCompositeStoreProps(usePopoverStoreProps(store, update2, props), update2, props), { tag: props.tag }); 25662 } 25663 function useComboboxStore(props = {}) { 25664 props = useComboboxStoreOptions(props); 25665 const [store, update2] = useStore2(createComboboxStore, props); 25666 return useComboboxStoreProps(store, update2, props); 25667 } 25668 25669 // node_modules/@ariakit/react-components/dist/combobox/combobox-provider.js 25670 var import_jsx_runtime122 = __toESM(require_jsx_runtime(), 1); 25671 function ComboboxProvider(props = {}) { 25672 return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(ComboboxContextProvider, { 25673 value: useComboboxStore(props), 25674 children: props.children 25675 }); 25676 } 25677 25678 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs 25679 var import_remove_accents = __toESM(require_remove_accents(), 1); 25680 var import_compose10 = __toESM(require_compose(), 1); 25681 var import_i18n28 = __toESM(require_i18n(), 1); 25682 var import_element83 = __toESM(require_element(), 1); 25683 var import_components21 = __toESM(require_components(), 1); 25684 25685 // packages/dataviews/build-module/components/dataviews-filters/utils.mjs 25686 var EMPTY_ARRAY3 = []; 25687 var getCurrentValue = (filterDefinition, currentFilter) => { 25688 if (filterDefinition.singleSelection) { 25689 return currentFilter?.value; 25690 } 25691 if (Array.isArray(currentFilter?.value)) { 25692 return currentFilter.value; 25693 } 25694 if (!Array.isArray(currentFilter?.value) && !!currentFilter?.value) { 25695 return [currentFilter.value]; 25696 } 25697 return EMPTY_ARRAY3; 25698 }; 25699 25700 // packages/dataviews/build-module/hooks/use-elements.mjs 25701 var import_element82 = __toESM(require_element(), 1); 25702 var EMPTY_ARRAY4 = []; 25703 function useElements({ 25704 elements, 25705 getElements 25706 }) { 25707 const staticElements = Array.isArray(elements) && elements.length > 0 ? elements : EMPTY_ARRAY4; 25708 const [records, setRecords] = (0, import_element82.useState)(staticElements); 25709 const [isLoading, setIsLoading] = (0, import_element82.useState)(false); 25710 (0, import_element82.useEffect)(() => { 25711 if (!getElements) { 25712 setRecords(staticElements); 25713 return; 25714 } 25715 let cancelled = false; 25716 setIsLoading(true); 25717 getElements().then((fetchedElements) => { 25718 if (!cancelled) { 25719 const dynamicElements = Array.isArray(fetchedElements) && fetchedElements.length > 0 ? fetchedElements : staticElements; 25720 setRecords(dynamicElements); 25721 } 25722 }).catch(() => { 25723 if (!cancelled) { 25724 setRecords(staticElements); 25725 } 25726 }).finally(() => { 25727 if (!cancelled) { 25728 setIsLoading(false); 25729 } 25730 }); 25731 return () => { 25732 cancelled = true; 25733 }; 25734 }, [getElements, staticElements]); 25735 return { 25736 elements: records, 25737 isLoading 25738 }; 25739 } 25740 25741 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs 25742 var import_jsx_runtime123 = __toESM(require_jsx_runtime(), 1); 25743 function normalizeSearchInput(input = "") { 25744 return (0, import_remove_accents.default)(input.trim().toLowerCase()); 25745 } 25746 var getNewValue = (filterDefinition, currentFilter, value) => { 25747 if (filterDefinition.singleSelection) { 25748 return value; 25749 } 25750 if (Array.isArray(currentFilter?.value)) { 25751 return currentFilter.value.includes(value) ? currentFilter.value.filter((v2) => v2 !== value) : [...currentFilter.value, value]; 25752 } 25753 return [value]; 25754 }; 25755 function generateFilterElementCompositeItemId(prefix, filterElementValue) { 25756 return `$prefix}-$filterElementValue}`; 25757 } 25758 var MultiSelectionOption = ({ selected }) => { 25759 return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)( 25760 "span", 25761 { 25762 className: clsx_default( 25763 "dataviews-filters__search-widget-listitem-multi-selection", 25764 { "is-selected": selected } 25765 ), 25766 children: selected && /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(import_components21.Icon, { icon: check_default }) 25767 } 25768 ); 25769 }; 25770 var SingleSelectionOption = ({ selected }) => { 25771 return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)( 25772 "span", 25773 { 25774 className: clsx_default( 25775 "dataviews-filters__search-widget-listitem-single-selection", 25776 { "is-selected": selected } 25777 ) 25778 } 25779 ); 25780 }; 25781 function ListBox({ view, filter, onChangeView }) { 25782 const baseId = (0, import_compose10.useInstanceId)(ListBox, "dataviews-filter-list-box"); 25783 const [activeCompositeId, setActiveCompositeId] = (0, import_element83.useState)( 25784 // When there are one or less operators, the first item is set as active 25785 // (by setting the initial `activeId` to `undefined`). 25786 // With 2 or more operators, the focus is moved on the operators control 25787 // (by setting the initial `activeId` to `null`), meaning that there won't 25788 // be an active item initially. Focus is then managed via the 25789 // `onFocusVisible` callback. 25790 filter.operators?.length === 1 ? void 0 : null 25791 ); 25792 const currentFilter = view.filters?.find( 25793 (f2) => f2.field === filter.field 25794 ); 25795 const currentValue = getCurrentValue(filter, currentFilter); 25796 return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)( 25797 import_components21.Composite, 25798 { 25799 virtualFocus: true, 25800 focusLoop: true, 25801 activeId: activeCompositeId, 25802 setActiveId: setActiveCompositeId, 25803 role: "listbox", 25804 className: "dataviews-filters__search-widget-listbox", 25805 "aria-label": (0, import_i18n28.sprintf)( 25806 /* translators: List of items for a filter. 1: Filter name. e.g.: "List of: Author". */ 25807 (0, import_i18n28.__)("List of: %1$s"), 25808 filter.name 25809 ), 25810 onFocusVisible: () => { 25811 if (!activeCompositeId && filter.elements.length) { 25812 setActiveCompositeId( 25813 generateFilterElementCompositeItemId( 25814 baseId, 25815 filter.elements[0].value 25816 ) 25817 ); 25818 } 25819 }, 25820 render: /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(import_components21.Composite.Typeahead, {}), 25821 children: filter.elements.map((element) => /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)( 25822 import_components21.Composite.Hover, 25823 { 25824 render: /* @__PURE__ */ (0, import_jsx_runtime123.jsx)( 25825 import_components21.Composite.Item, 25826 { 25827 id: generateFilterElementCompositeItemId( 25828 baseId, 25829 element.value 25830 ), 25831 render: /* @__PURE__ */ (0, import_jsx_runtime123.jsx)( 25832 "div", 25833 { 25834 "aria-label": element.label, 25835 role: "option", 25836 className: "dataviews-filters__search-widget-listitem" 25837 } 25838 ), 25839 onClick: () => { 25840 const newFilters = currentFilter ? [ 25841 ...(view.filters ?? []).map( 25842 (_filter) => { 25843 if (_filter.field === filter.field) { 25844 return { 25845 ..._filter, 25846 operator: currentFilter.operator || filter.operators[0], 25847 value: getNewValue( 25848 filter, 25849 currentFilter, 25850 element.value 25851 ) 25852 }; 25853 } 25854 return _filter; 25855 } 25856 ) 25857 ] : [ 25858 ...view.filters ?? [], 25859 { 25860 field: filter.field, 25861 operator: filter.operators[0], 25862 value: getNewValue( 25863 filter, 25864 currentFilter, 25865 element.value 25866 ) 25867 } 25868 ]; 25869 onChangeView({ 25870 ...view, 25871 page: 1, 25872 filters: newFilters 25873 }); 25874 } 25875 } 25876 ), 25877 children: [ 25878 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime123.jsx)( 25879 SingleSelectionOption, 25880 { 25881 selected: currentValue === element.value 25882 } 25883 ), 25884 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime123.jsx)( 25885 MultiSelectionOption, 25886 { 25887 selected: currentValue.includes(element.value) 25888 } 25889 ), 25890 /* @__PURE__ */ (0, import_jsx_runtime123.jsx)( 25891 "span", 25892 { 25893 className: "dataviews-filters__search-widget-listitem-value", 25894 title: element.label, 25895 children: element.label 25896 } 25897 ) 25898 ] 25899 }, 25900 element.value 25901 )) 25902 } 25903 ); 25904 } 25905 function ComboboxList22({ view, filter, onChangeView }) { 25906 const [searchValue, setSearchValue] = (0, import_element83.useState)(""); 25907 const deferredSearchValue = (0, import_element83.useDeferredValue)(searchValue); 25908 const currentFilter = view.filters?.find( 25909 (_filter) => _filter.field === filter.field 25910 ); 25911 const currentValue = getCurrentValue(filter, currentFilter); 25912 const matches2 = (0, import_element83.useMemo)(() => { 25913 const normalizedSearch = normalizeSearchInput(deferredSearchValue); 25914 return filter.elements.filter( 25915 (item) => normalizeSearchInput(item.label).includes(normalizedSearch) 25916 ); 25917 }, [filter.elements, deferredSearchValue]); 25918 return /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)( 25919 ComboboxProvider, 25920 { 25921 selectedValue: currentValue, 25922 setSelectedValue: (value) => { 25923 const newFilters = currentFilter ? [ 25924 ...(view.filters ?? []).map((_filter) => { 25925 if (_filter.field === filter.field) { 25926 return { 25927 ..._filter, 25928 operator: currentFilter.operator || filter.operators[0], 25929 value 25930 }; 25931 } 25932 return _filter; 25933 }) 25934 ] : [ 25935 ...view.filters ?? [], 25936 { 25937 field: filter.field, 25938 operator: filter.operators[0], 25939 value 25940 } 25941 ]; 25942 onChangeView({ 25943 ...view, 25944 page: 1, 25945 filters: newFilters 25946 }); 25947 }, 25948 setValue: setSearchValue, 25949 children: [ 25950 /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)("div", { className: "dataviews-filters__search-widget-filter-combobox__wrapper", children: [ 25951 /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(ComboboxLabel, {}), children: (0, import_i18n28.__)("Search items") }), 25952 /* @__PURE__ */ (0, import_jsx_runtime123.jsx)( 25953 Combobox, 25954 { 25955 autoSelect: "always", 25956 placeholder: (0, import_i18n28.__)("Search"), 25957 className: "dataviews-filters__search-widget-filter-combobox__input" 25958 } 25959 ), 25960 /* @__PURE__ */ (0, import_jsx_runtime123.jsx)("div", { className: "dataviews-filters__search-widget-filter-combobox__icon", children: /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(import_components21.Icon, { icon: search_default }) }) 25961 ] }), 25962 /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)( 25963 ComboboxList, 25964 { 25965 className: "dataviews-filters__search-widget-filter-combobox-list", 25966 alwaysVisible: true, 25967 children: [ 25968 matches2.map((element) => { 25969 return /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)( 25970 ComboboxItem, 25971 { 25972 resetValueOnSelect: false, 25973 value: element.value, 25974 className: "dataviews-filters__search-widget-listitem", 25975 hideOnClick: false, 25976 setValueOnClick: false, 25977 focusOnHover: true, 25978 children: [ 25979 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime123.jsx)( 25980 SingleSelectionOption, 25981 { 25982 selected: currentValue === element.value 25983 } 25984 ), 25985 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime123.jsx)( 25986 MultiSelectionOption, 25987 { 25988 selected: currentValue.includes( 25989 element.value 25990 ) 25991 } 25992 ), 25993 /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)( 25994 "span", 25995 { 25996 className: "dataviews-filters__search-widget-listitem-value", 25997 title: element.label, 25998 children: [ 25999 /* @__PURE__ */ (0, import_jsx_runtime123.jsx)( 26000 ComboboxItemValue, 26001 { 26002 className: "dataviews-filters__search-widget-filter-combobox-item-value", 26003 value: element.label 26004 } 26005 ), 26006 !!element.description && /* @__PURE__ */ (0, import_jsx_runtime123.jsx)("span", { className: "dataviews-filters__search-widget-listitem-description", children: element.description }) 26007 ] 26008 } 26009 ) 26010 ] 26011 }, 26012 element.value 26013 ); 26014 }), 26015 !matches2.length && /* @__PURE__ */ (0, import_jsx_runtime123.jsx)("p", { children: (0, import_i18n28.__)("No results found") }) 26016 ] 26017 } 26018 ) 26019 ] 26020 } 26021 ); 26022 } 26023 function SearchWidget(props) { 26024 const { elements, isLoading } = useElements({ 26025 elements: props.filter.elements, 26026 getElements: props.filter.getElements 26027 }); 26028 if (isLoading) { 26029 return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(import_components21.Spinner, {}) }); 26030 } 26031 if (elements.length === 0) { 26032 return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: (0, import_i18n28.__)("No elements found") }); 26033 } 26034 const Widget = elements.length > 10 ? ComboboxList22 : ListBox; 26035 return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(Widget, { ...props, filter: { ...props.filter, elements } }); 26036 } 26037 26038 // packages/dataviews/build-module/components/dataviews-filters/input-widget.mjs 26039 var import_es6 = __toESM(require_es6(), 1); 26040 var import_compose11 = __toESM(require_compose(), 1); 26041 var import_element84 = __toESM(require_element(), 1); 26042 var import_components22 = __toESM(require_components(), 1); 26043 var import_jsx_runtime124 = __toESM(require_jsx_runtime(), 1); 26044 function InputWidget({ 26045 filter, 26046 view, 26047 onChangeView, 26048 fields 26049 }) { 26050 const currentFilter = view.filters?.find( 26051 (f2) => f2.field === filter.field 26052 ); 26053 const currentValue = getCurrentValue(filter, currentFilter); 26054 const field = (0, import_element84.useMemo)(() => { 26055 const currentField = fields.find((f2) => f2.id === filter.field); 26056 if (currentField) { 26057 return { 26058 ...currentField, 26059 // Deactivate validation for filters. 26060 isValid: {}, 26061 // Filter controls are always enabled. 26062 isDisabled: () => false, 26063 // Filter controls are always visible. 26064 isVisible: () => true, 26065 // Configure getValue/setValue as if Item was a plain object. 26066 getValue: ({ item }) => item[currentField.id], 26067 setValue: ({ value }) => ({ 26068 [currentField.id]: value 26069 }) 26070 }; 26071 } 26072 return currentField; 26073 }, [fields, filter.field]); 26074 const data = (0, import_element84.useMemo)(() => { 26075 return (view.filters ?? []).reduce( 26076 (acc, activeFilter) => { 26077 acc[activeFilter.field] = activeFilter.value; 26078 return acc; 26079 }, 26080 {} 26081 ); 26082 }, [view.filters]); 26083 const handleChange = (0, import_compose11.useEvent)((updatedData) => { 26084 if (!field || !currentFilter) { 26085 return; 26086 } 26087 const nextValue = field.getValue({ item: updatedData }); 26088 if ((0, import_es6.default)(nextValue, currentValue)) { 26089 return; 26090 } 26091 onChangeView({ 26092 ...view, 26093 filters: (view.filters ?? []).map( 26094 (_filter) => _filter.field === filter.field ? { 26095 ..._filter, 26096 operator: currentFilter.operator || filter.operators[0], 26097 // Consider empty strings as undefined: 26098 // 26099 // - undefined as value means the filter is unset: the filter widget displays no value and the search returns all records 26100 // - empty string as value means "search empty string": returns only the records that have an empty string as value 26101 // 26102 // In practice, this means the filter will not be able to find an empty string as the value. 26103 value: nextValue === "" ? void 0 : nextValue 26104 } : _filter 26105 ) 26106 }); 26107 }); 26108 if (!field || !field.Edit || !currentFilter) { 26109 return null; 26110 } 26111 return /* @__PURE__ */ (0, import_jsx_runtime124.jsx)( 26112 import_components22.Flex, 26113 { 26114 className: "dataviews-filters__user-input-widget", 26115 gap: 2.5, 26116 direction: "column", 26117 children: /* @__PURE__ */ (0, import_jsx_runtime124.jsx)( 26118 field.Edit, 26119 { 26120 hideLabelFromVision: true, 26121 data, 26122 field, 26123 operator: currentFilter.operator, 26124 onChange: handleChange 26125 } 26126 ) 26127 } 26128 ); 26129 } 26130 26131 // node_modules/date-fns/constants.js 26132 var daysInYear = 365.2425; 26133 var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3; 26134 var minTime = -maxTime; 26135 var millisecondsInWeek = 6048e5; 26136 var millisecondsInDay = 864e5; 26137 var secondsInHour = 3600; 26138 var secondsInDay = secondsInHour * 24; 26139 var secondsInWeek = secondsInDay * 7; 26140 var secondsInYear = secondsInDay * daysInYear; 26141 var secondsInMonth = secondsInYear / 12; 26142 var secondsInQuarter = secondsInMonth * 3; 26143 var constructFromSymbol = /* @__PURE__ */ Symbol.for("constructDateFrom"); 26144 26145 // node_modules/date-fns/constructFrom.js 26146 function constructFrom(date, value) { 26147 if (typeof date === "function") return date(value); 26148 if (date && typeof date === "object" && constructFromSymbol in date) 26149 return date[constructFromSymbol](value); 26150 if (date instanceof Date) return new date.constructor(value); 26151 return new Date(value); 26152 } 26153 26154 // node_modules/date-fns/toDate.js 26155 function toDate(argument, context) { 26156 return constructFrom(context || argument, argument); 26157 } 26158 26159 // node_modules/date-fns/addDays.js 26160 function addDays(date, amount, options) { 26161 const _date = toDate(date, options?.in); 26162 if (isNaN(amount)) return constructFrom(options?.in || date, NaN); 26163 if (!amount) return _date; 26164 _date.setDate(_date.getDate() + amount); 26165 return _date; 26166 } 26167 26168 // node_modules/date-fns/addMonths.js 26169 function addMonths(date, amount, options) { 26170 const _date = toDate(date, options?.in); 26171 if (isNaN(amount)) return constructFrom(options?.in || date, NaN); 26172 if (!amount) { 26173 return _date; 26174 } 26175 const dayOfMonth = _date.getDate(); 26176 const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime()); 26177 endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0); 26178 const daysInMonth = endOfDesiredMonth.getDate(); 26179 if (dayOfMonth >= daysInMonth) { 26180 return endOfDesiredMonth; 26181 } else { 26182 _date.setFullYear( 26183 endOfDesiredMonth.getFullYear(), 26184 endOfDesiredMonth.getMonth(), 26185 dayOfMonth 26186 ); 26187 return _date; 26188 } 26189 } 26190 26191 // node_modules/date-fns/_lib/defaultOptions.js 26192 var defaultOptions = {}; 26193 function getDefaultOptions() { 26194 return defaultOptions; 26195 } 26196 26197 // node_modules/date-fns/startOfWeek.js 26198 function startOfWeek(date, options) { 26199 const defaultOptions2 = getDefaultOptions(); 26200 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0; 26201 const _date = toDate(date, options?.in); 26202 const day = _date.getDay(); 26203 const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn; 26204 _date.setDate(_date.getDate() - diff); 26205 _date.setHours(0, 0, 0, 0); 26206 return _date; 26207 } 26208 26209 // node_modules/date-fns/startOfISOWeek.js 26210 function startOfISOWeek(date, options) { 26211 return startOfWeek(date, { ...options, weekStartsOn: 1 }); 26212 } 26213 26214 // node_modules/date-fns/getISOWeekYear.js 26215 function getISOWeekYear(date, options) { 26216 const _date = toDate(date, options?.in); 26217 const year = _date.getFullYear(); 26218 const fourthOfJanuaryOfNextYear = constructFrom(_date, 0); 26219 fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4); 26220 fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0); 26221 const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear); 26222 const fourthOfJanuaryOfThisYear = constructFrom(_date, 0); 26223 fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4); 26224 fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0); 26225 const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear); 26226 if (_date.getTime() >= startOfNextYear.getTime()) { 26227 return year + 1; 26228 } else if (_date.getTime() >= startOfThisYear.getTime()) { 26229 return year; 26230 } else { 26231 return year - 1; 26232 } 26233 } 26234 26235 // node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js 26236 function getTimezoneOffsetInMilliseconds(date) { 26237 const _date = toDate(date); 26238 const utcDate = new Date( 26239 Date.UTC( 26240 _date.getFullYear(), 26241 _date.getMonth(), 26242 _date.getDate(), 26243 _date.getHours(), 26244 _date.getMinutes(), 26245 _date.getSeconds(), 26246 _date.getMilliseconds() 26247 ) 26248 ); 26249 utcDate.setUTCFullYear(_date.getFullYear()); 26250 return +date - +utcDate; 26251 } 26252 26253 // node_modules/date-fns/_lib/normalizeDates.js 26254 function normalizeDates(context, ...dates) { 26255 const normalize = constructFrom.bind( 26256 null, 26257 context || dates.find((date) => typeof date === "object") 26258 ); 26259 return dates.map(normalize); 26260 } 26261 26262 // node_modules/date-fns/startOfDay.js 26263 function startOfDay(date, options) { 26264 const _date = toDate(date, options?.in); 26265 _date.setHours(0, 0, 0, 0); 26266 return _date; 26267 } 26268 26269 // node_modules/date-fns/differenceInCalendarDays.js 26270 function differenceInCalendarDays(laterDate, earlierDate, options) { 26271 const [laterDate_, earlierDate_] = normalizeDates( 26272 options?.in, 26273 laterDate, 26274 earlierDate 26275 ); 26276 const laterStartOfDay = startOfDay(laterDate_); 26277 const earlierStartOfDay = startOfDay(earlierDate_); 26278 const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay); 26279 const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay); 26280 return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay); 26281 } 26282 26283 // node_modules/date-fns/startOfISOWeekYear.js 26284 function startOfISOWeekYear(date, options) { 26285 const year = getISOWeekYear(date, options); 26286 const fourthOfJanuary = constructFrom(options?.in || date, 0); 26287 fourthOfJanuary.setFullYear(year, 0, 4); 26288 fourthOfJanuary.setHours(0, 0, 0, 0); 26289 return startOfISOWeek(fourthOfJanuary); 26290 } 26291 26292 // node_modules/date-fns/addWeeks.js 26293 function addWeeks(date, amount, options) { 26294 return addDays(date, amount * 7, options); 26295 } 26296 26297 // node_modules/date-fns/addYears.js 26298 function addYears(date, amount, options) { 26299 return addMonths(date, amount * 12, options); 26300 } 26301 26302 // node_modules/date-fns/isDate.js 26303 function isDate(value) { 26304 return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]"; 26305 } 26306 26307 // node_modules/date-fns/isValid.js 26308 function isValid(date) { 26309 return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date))); 26310 } 26311 26312 // node_modules/date-fns/startOfMonth.js 26313 function startOfMonth(date, options) { 26314 const _date = toDate(date, options?.in); 26315 _date.setDate(1); 26316 _date.setHours(0, 0, 0, 0); 26317 return _date; 26318 } 26319 26320 // node_modules/date-fns/startOfYear.js 26321 function startOfYear(date, options) { 26322 const date_ = toDate(date, options?.in); 26323 date_.setFullYear(date_.getFullYear(), 0, 1); 26324 date_.setHours(0, 0, 0, 0); 26325 return date_; 26326 } 26327 26328 // node_modules/date-fns/locale/en-US/_lib/formatDistance.js 26329 var formatDistanceLocale = { 26330 lessThanXSeconds: { 26331 one: "less than a second", 26332 other: "less than {{count}} seconds" 26333 }, 26334 xSeconds: { 26335 one: "1 second", 26336 other: "{{count}} seconds" 26337 }, 26338 halfAMinute: "half a minute", 26339 lessThanXMinutes: { 26340 one: "less than a minute", 26341 other: "less than {{count}} minutes" 26342 }, 26343 xMinutes: { 26344 one: "1 minute", 26345 other: "{{count}} minutes" 26346 }, 26347 aboutXHours: { 26348 one: "about 1 hour", 26349 other: "about {{count}} hours" 26350 }, 26351 xHours: { 26352 one: "1 hour", 26353 other: "{{count}} hours" 26354 }, 26355 xDays: { 26356 one: "1 day", 26357 other: "{{count}} days" 26358 }, 26359 aboutXWeeks: { 26360 one: "about 1 week", 26361 other: "about {{count}} weeks" 26362 }, 26363 xWeeks: { 26364 one: "1 week", 26365 other: "{{count}} weeks" 26366 }, 26367 aboutXMonths: { 26368 one: "about 1 month", 26369 other: "about {{count}} months" 26370 }, 26371 xMonths: { 26372 one: "1 month", 26373 other: "{{count}} months" 26374 }, 26375 aboutXYears: { 26376 one: "about 1 year", 26377 other: "about {{count}} years" 26378 }, 26379 xYears: { 26380 one: "1 year", 26381 other: "{{count}} years" 26382 }, 26383 overXYears: { 26384 one: "over 1 year", 26385 other: "over {{count}} years" 26386 }, 26387 almostXYears: { 26388 one: "almost 1 year", 26389 other: "almost {{count}} years" 26390 } 26391 }; 26392 var formatDistance = (token, count, options) => { 26393 let result; 26394 const tokenValue = formatDistanceLocale[token]; 26395 if (typeof tokenValue === "string") { 26396 result = tokenValue; 26397 } else if (count === 1) { 26398 result = tokenValue.one; 26399 } else { 26400 result = tokenValue.other.replace("{{count}}", count.toString()); 26401 } 26402 if (options?.addSuffix) { 26403 if (options.comparison && options.comparison > 0) { 26404 return "in " + result; 26405 } else { 26406 return result + " ago"; 26407 } 26408 } 26409 return result; 26410 }; 26411 26412 // node_modules/date-fns/locale/_lib/buildFormatLongFn.js 26413 function buildFormatLongFn(args) { 26414 return (options = {}) => { 26415 const width = options.width ? String(options.width) : args.defaultWidth; 26416 const format6 = args.formats[width] || args.formats[args.defaultWidth]; 26417 return format6; 26418 }; 26419 } 26420 26421 // node_modules/date-fns/locale/en-US/_lib/formatLong.js 26422 var dateFormats = { 26423 full: "EEEE, MMMM do, y", 26424 long: "MMMM do, y", 26425 medium: "MMM d, y", 26426 short: "MM/dd/yyyy" 26427 }; 26428 var timeFormats = { 26429 full: "h:mm:ss a zzzz", 26430 long: "h:mm:ss a z", 26431 medium: "h:mm:ss a", 26432 short: "h:mm a" 26433 }; 26434 var dateTimeFormats = { 26435 full: "{{date}} 'at' {{time}}", 26436 long: "{{date}} 'at' {{time}}", 26437 medium: "{{date}}, {{time}}", 26438 short: "{{date}}, {{time}}" 26439 }; 26440 var formatLong = { 26441 date: buildFormatLongFn({ 26442 formats: dateFormats, 26443 defaultWidth: "full" 26444 }), 26445 time: buildFormatLongFn({ 26446 formats: timeFormats, 26447 defaultWidth: "full" 26448 }), 26449 dateTime: buildFormatLongFn({ 26450 formats: dateTimeFormats, 26451 defaultWidth: "full" 26452 }) 26453 }; 26454 26455 // node_modules/date-fns/locale/en-US/_lib/formatRelative.js 26456 var formatRelativeLocale = { 26457 lastWeek: "'last' eeee 'at' p", 26458 yesterday: "'yesterday at' p", 26459 today: "'today at' p", 26460 tomorrow: "'tomorrow at' p", 26461 nextWeek: "eeee 'at' p", 26462 other: "P" 26463 }; 26464 var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token]; 26465 26466 // node_modules/date-fns/locale/_lib/buildLocalizeFn.js 26467 function buildLocalizeFn(args) { 26468 return (value, options) => { 26469 const context = options?.context ? String(options.context) : "standalone"; 26470 let valuesArray; 26471 if (context === "formatting" && args.formattingValues) { 26472 const defaultWidth = args.defaultFormattingWidth || args.defaultWidth; 26473 const width = options?.width ? String(options.width) : defaultWidth; 26474 valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth]; 26475 } else { 26476 const defaultWidth = args.defaultWidth; 26477 const width = options?.width ? String(options.width) : args.defaultWidth; 26478 valuesArray = args.values[width] || args.values[defaultWidth]; 26479 } 26480 const index2 = args.argumentCallback ? args.argumentCallback(value) : value; 26481 return valuesArray[index2]; 26482 }; 26483 } 26484 26485 // node_modules/date-fns/locale/en-US/_lib/localize.js 26486 var eraValues = { 26487 narrow: ["B", "A"], 26488 abbreviated: ["BC", "AD"], 26489 wide: ["Before Christ", "Anno Domini"] 26490 }; 26491 var quarterValues = { 26492 narrow: ["1", "2", "3", "4"], 26493 abbreviated: ["Q1", "Q2", "Q3", "Q4"], 26494 wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"] 26495 }; 26496 var monthValues = { 26497 narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"], 26498 abbreviated: [ 26499 "Jan", 26500 "Feb", 26501 "Mar", 26502 "Apr", 26503 "May", 26504 "Jun", 26505 "Jul", 26506 "Aug", 26507 "Sep", 26508 "Oct", 26509 "Nov", 26510 "Dec" 26511 ], 26512 wide: [ 26513 "January", 26514 "February", 26515 "March", 26516 "April", 26517 "May", 26518 "June", 26519 "July", 26520 "August", 26521 "September", 26522 "October", 26523 "November", 26524 "December" 26525 ] 26526 }; 26527 var dayValues = { 26528 narrow: ["S", "M", "T", "W", "T", "F", "S"], 26529 short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], 26530 abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], 26531 wide: [ 26532 "Sunday", 26533 "Monday", 26534 "Tuesday", 26535 "Wednesday", 26536 "Thursday", 26537 "Friday", 26538 "Saturday" 26539 ] 26540 }; 26541 var dayPeriodValues = { 26542 narrow: { 26543 am: "a", 26544 pm: "p", 26545 midnight: "mi", 26546 noon: "n", 26547 morning: "morning", 26548 afternoon: "afternoon", 26549 evening: "evening", 26550 night: "night" 26551 }, 26552 abbreviated: { 26553 am: "AM", 26554 pm: "PM", 26555 midnight: "midnight", 26556 noon: "noon", 26557 morning: "morning", 26558 afternoon: "afternoon", 26559 evening: "evening", 26560 night: "night" 26561 }, 26562 wide: { 26563 am: "a.m.", 26564 pm: "p.m.", 26565 midnight: "midnight", 26566 noon: "noon", 26567 morning: "morning", 26568 afternoon: "afternoon", 26569 evening: "evening", 26570 night: "night" 26571 } 26572 }; 26573 var formattingDayPeriodValues = { 26574 narrow: { 26575 am: "a", 26576 pm: "p", 26577 midnight: "mi", 26578 noon: "n", 26579 morning: "in the morning", 26580 afternoon: "in the afternoon", 26581 evening: "in the evening", 26582 night: "at night" 26583 }, 26584 abbreviated: { 26585 am: "AM", 26586 pm: "PM", 26587 midnight: "midnight", 26588 noon: "noon", 26589 morning: "in the morning", 26590 afternoon: "in the afternoon", 26591 evening: "in the evening", 26592 night: "at night" 26593 }, 26594 wide: { 26595 am: "a.m.", 26596 pm: "p.m.", 26597 midnight: "midnight", 26598 noon: "noon", 26599 morning: "in the morning", 26600 afternoon: "in the afternoon", 26601 evening: "in the evening", 26602 night: "at night" 26603 } 26604 }; 26605 var ordinalNumber = (dirtyNumber, _options) => { 26606 const number = Number(dirtyNumber); 26607 const rem100 = number % 100; 26608 if (rem100 > 20 || rem100 < 10) { 26609 switch (rem100 % 10) { 26610 case 1: 26611 return number + "st"; 26612 case 2: 26613 return number + "nd"; 26614 case 3: 26615 return number + "rd"; 26616 } 26617 } 26618 return number + "th"; 26619 }; 26620 var localize = { 26621 ordinalNumber, 26622 era: buildLocalizeFn({ 26623 values: eraValues, 26624 defaultWidth: "wide" 26625 }), 26626 quarter: buildLocalizeFn({ 26627 values: quarterValues, 26628 defaultWidth: "wide", 26629 argumentCallback: (quarter) => quarter - 1 26630 }), 26631 month: buildLocalizeFn({ 26632 values: monthValues, 26633 defaultWidth: "wide" 26634 }), 26635 day: buildLocalizeFn({ 26636 values: dayValues, 26637 defaultWidth: "wide" 26638 }), 26639 dayPeriod: buildLocalizeFn({ 26640 values: dayPeriodValues, 26641 defaultWidth: "wide", 26642 formattingValues: formattingDayPeriodValues, 26643 defaultFormattingWidth: "wide" 26644 }) 26645 }; 26646 26647 // node_modules/date-fns/locale/_lib/buildMatchFn.js 26648 function buildMatchFn(args) { 26649 return (string, options = {}) => { 26650 const width = options.width; 26651 const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth]; 26652 const matchResult = string.match(matchPattern); 26653 if (!matchResult) { 26654 return null; 26655 } 26656 const matchedString = matchResult[0]; 26657 const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth]; 26658 const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : ( 26659 // [TODO] -- I challenge you to fix the type 26660 findKey(parsePatterns, (pattern) => pattern.test(matchedString)) 26661 ); 26662 let value; 26663 value = args.valueCallback ? args.valueCallback(key) : key; 26664 value = options.valueCallback ? ( 26665 // [TODO] -- I challenge you to fix the type 26666 options.valueCallback(value) 26667 ) : value; 26668 const rest = string.slice(matchedString.length); 26669 return { value, rest }; 26670 }; 26671 } 26672 function findKey(object, predicate) { 26673 for (const key in object) { 26674 if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) { 26675 return key; 26676 } 26677 } 26678 return void 0; 26679 } 26680 function findIndex(array, predicate) { 26681 for (let key = 0; key < array.length; key++) { 26682 if (predicate(array[key])) { 26683 return key; 26684 } 26685 } 26686 return void 0; 26687 } 26688 26689 // node_modules/date-fns/locale/_lib/buildMatchPatternFn.js 26690 function buildMatchPatternFn(args) { 26691 return (string, options = {}) => { 26692 const matchResult = string.match(args.matchPattern); 26693 if (!matchResult) return null; 26694 const matchedString = matchResult[0]; 26695 const parseResult = string.match(args.parsePattern); 26696 if (!parseResult) return null; 26697 let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0]; 26698 value = options.valueCallback ? options.valueCallback(value) : value; 26699 const rest = string.slice(matchedString.length); 26700 return { value, rest }; 26701 }; 26702 } 26703 26704 // node_modules/date-fns/locale/en-US/_lib/match.js 26705 var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i; 26706 var parseOrdinalNumberPattern = /\d+/i; 26707 var matchEraPatterns = { 26708 narrow: /^(b|a)/i, 26709 abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i, 26710 wide: /^(before christ|before common era|anno domini|common era)/i 26711 }; 26712 var parseEraPatterns = { 26713 any: [/^b/i, /^(a|c)/i] 26714 }; 26715 var matchQuarterPatterns = { 26716 narrow: /^[1234]/i, 26717 abbreviated: /^q[1234]/i, 26718 wide: /^[1234](th|st|nd|rd)? quarter/i 26719 }; 26720 var parseQuarterPatterns = { 26721 any: [/1/i, /2/i, /3/i, /4/i] 26722 }; 26723 var matchMonthPatterns = { 26724 narrow: /^[jfmasond]/i, 26725 abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i, 26726 wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i 26727 }; 26728 var parseMonthPatterns = { 26729 narrow: [ 26730 /^j/i, 26731 /^f/i, 26732 /^m/i, 26733 /^a/i, 26734 /^m/i, 26735 /^j/i, 26736 /^j/i, 26737 /^a/i, 26738 /^s/i, 26739 /^o/i, 26740 /^n/i, 26741 /^d/i 26742 ], 26743 any: [ 26744 /^ja/i, 26745 /^f/i, 26746 /^mar/i, 26747 /^ap/i, 26748 /^may/i, 26749 /^jun/i, 26750 /^jul/i, 26751 /^au/i, 26752 /^s/i, 26753 /^o/i, 26754 /^n/i, 26755 /^d/i 26756 ] 26757 }; 26758 var matchDayPatterns = { 26759 narrow: /^[smtwf]/i, 26760 short: /^(su|mo|tu|we|th|fr|sa)/i, 26761 abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i, 26762 wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i 26763 }; 26764 var parseDayPatterns = { 26765 narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i], 26766 any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i] 26767 }; 26768 var matchDayPeriodPatterns = { 26769 narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i, 26770 any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i 26771 }; 26772 var parseDayPeriodPatterns = { 26773 any: { 26774 am: /^a/i, 26775 pm: /^p/i, 26776 midnight: /^mi/i, 26777 noon: /^no/i, 26778 morning: /morning/i, 26779 afternoon: /afternoon/i, 26780 evening: /evening/i, 26781 night: /night/i 26782 } 26783 }; 26784 var match = { 26785 ordinalNumber: buildMatchPatternFn({ 26786 matchPattern: matchOrdinalNumberPattern, 26787 parsePattern: parseOrdinalNumberPattern, 26788 valueCallback: (value) => parseInt(value, 10) 26789 }), 26790 era: buildMatchFn({ 26791 matchPatterns: matchEraPatterns, 26792 defaultMatchWidth: "wide", 26793 parsePatterns: parseEraPatterns, 26794 defaultParseWidth: "any" 26795 }), 26796 quarter: buildMatchFn({ 26797 matchPatterns: matchQuarterPatterns, 26798 defaultMatchWidth: "wide", 26799 parsePatterns: parseQuarterPatterns, 26800 defaultParseWidth: "any", 26801 valueCallback: (index2) => index2 + 1 26802 }), 26803 month: buildMatchFn({ 26804 matchPatterns: matchMonthPatterns, 26805 defaultMatchWidth: "wide", 26806 parsePatterns: parseMonthPatterns, 26807 defaultParseWidth: "any" 26808 }), 26809 day: buildMatchFn({ 26810 matchPatterns: matchDayPatterns, 26811 defaultMatchWidth: "wide", 26812 parsePatterns: parseDayPatterns, 26813 defaultParseWidth: "any" 26814 }), 26815 dayPeriod: buildMatchFn({ 26816 matchPatterns: matchDayPeriodPatterns, 26817 defaultMatchWidth: "any", 26818 parsePatterns: parseDayPeriodPatterns, 26819 defaultParseWidth: "any" 26820 }) 26821 }; 26822 26823 // node_modules/date-fns/locale/en-US.js 26824 var enUS = { 26825 code: "en-US", 26826 formatDistance, 26827 formatLong, 26828 formatRelative, 26829 localize, 26830 match, 26831 options: { 26832 weekStartsOn: 0, 26833 firstWeekContainsDate: 1 26834 } 26835 }; 26836 26837 // node_modules/date-fns/getDayOfYear.js 26838 function getDayOfYear(date, options) { 26839 const _date = toDate(date, options?.in); 26840 const diff = differenceInCalendarDays(_date, startOfYear(_date)); 26841 const dayOfYear = diff + 1; 26842 return dayOfYear; 26843 } 26844 26845 // node_modules/date-fns/getISOWeek.js 26846 function getISOWeek(date, options) { 26847 const _date = toDate(date, options?.in); 26848 const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date); 26849 return Math.round(diff / millisecondsInWeek) + 1; 26850 } 26851 26852 // node_modules/date-fns/getWeekYear.js 26853 function getWeekYear(date, options) { 26854 const _date = toDate(date, options?.in); 26855 const year = _date.getFullYear(); 26856 const defaultOptions2 = getDefaultOptions(); 26857 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1; 26858 const firstWeekOfNextYear = constructFrom(options?.in || date, 0); 26859 firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate); 26860 firstWeekOfNextYear.setHours(0, 0, 0, 0); 26861 const startOfNextYear = startOfWeek(firstWeekOfNextYear, options); 26862 const firstWeekOfThisYear = constructFrom(options?.in || date, 0); 26863 firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate); 26864 firstWeekOfThisYear.setHours(0, 0, 0, 0); 26865 const startOfThisYear = startOfWeek(firstWeekOfThisYear, options); 26866 if (+_date >= +startOfNextYear) { 26867 return year + 1; 26868 } else if (+_date >= +startOfThisYear) { 26869 return year; 26870 } else { 26871 return year - 1; 26872 } 26873 } 26874 26875 // node_modules/date-fns/startOfWeekYear.js 26876 function startOfWeekYear(date, options) { 26877 const defaultOptions2 = getDefaultOptions(); 26878 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1; 26879 const year = getWeekYear(date, options); 26880 const firstWeek = constructFrom(options?.in || date, 0); 26881 firstWeek.setFullYear(year, 0, firstWeekContainsDate); 26882 firstWeek.setHours(0, 0, 0, 0); 26883 const _date = startOfWeek(firstWeek, options); 26884 return _date; 26885 } 26886 26887 // node_modules/date-fns/getWeek.js 26888 function getWeek(date, options) { 26889 const _date = toDate(date, options?.in); 26890 const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options); 26891 return Math.round(diff / millisecondsInWeek) + 1; 26892 } 26893 26894 // node_modules/date-fns/_lib/addLeadingZeros.js 26895 function addLeadingZeros(number, targetLength) { 26896 const sign = number < 0 ? "-" : ""; 26897 const output = Math.abs(number).toString().padStart(targetLength, "0"); 26898 return sign + output; 26899 } 26900 26901 // node_modules/date-fns/_lib/format/lightFormatters.js 26902 var lightFormatters = { 26903 // Year 26904 y(date, token) { 26905 const signedYear = date.getFullYear(); 26906 const year = signedYear > 0 ? signedYear : 1 - signedYear; 26907 return addLeadingZeros(token === "yy" ? year % 100 : year, token.length); 26908 }, 26909 // Month 26910 M(date, token) { 26911 const month = date.getMonth(); 26912 return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2); 26913 }, 26914 // Day of the month 26915 d(date, token) { 26916 return addLeadingZeros(date.getDate(), token.length); 26917 }, 26918 // AM or PM 26919 a(date, token) { 26920 const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am"; 26921 switch (token) { 26922 case "a": 26923 case "aa": 26924 return dayPeriodEnumValue.toUpperCase(); 26925 case "aaa": 26926 return dayPeriodEnumValue; 26927 case "aaaaa": 26928 return dayPeriodEnumValue[0]; 26929 case "aaaa": 26930 default: 26931 return dayPeriodEnumValue === "am" ? "a.m." : "p.m."; 26932 } 26933 }, 26934 // Hour [1-12] 26935 h(date, token) { 26936 return addLeadingZeros(date.getHours() % 12 || 12, token.length); 26937 }, 26938 // Hour [0-23] 26939 H(date, token) { 26940 return addLeadingZeros(date.getHours(), token.length); 26941 }, 26942 // Minute 26943 m(date, token) { 26944 return addLeadingZeros(date.getMinutes(), token.length); 26945 }, 26946 // Second 26947 s(date, token) { 26948 return addLeadingZeros(date.getSeconds(), token.length); 26949 }, 26950 // Fraction of second 26951 S(date, token) { 26952 const numberOfDigits = token.length; 26953 const milliseconds = date.getMilliseconds(); 26954 const fractionalSeconds = Math.trunc( 26955 milliseconds * Math.pow(10, numberOfDigits - 3) 26956 ); 26957 return addLeadingZeros(fractionalSeconds, token.length); 26958 } 26959 }; 26960 26961 // node_modules/date-fns/_lib/format/formatters.js 26962 var dayPeriodEnum = { 26963 am: "am", 26964 pm: "pm", 26965 midnight: "midnight", 26966 noon: "noon", 26967 morning: "morning", 26968 afternoon: "afternoon", 26969 evening: "evening", 26970 night: "night" 26971 }; 26972 var formatters = { 26973 // Era 26974 G: function(date, token, localize2) { 26975 const era = date.getFullYear() > 0 ? 1 : 0; 26976 switch (token) { 26977 // AD, BC 26978 case "G": 26979 case "GG": 26980 case "GGG": 26981 return localize2.era(era, { width: "abbreviated" }); 26982 // A, B 26983 case "GGGGG": 26984 return localize2.era(era, { width: "narrow" }); 26985 // Anno Domini, Before Christ 26986 case "GGGG": 26987 default: 26988 return localize2.era(era, { width: "wide" }); 26989 } 26990 }, 26991 // Year 26992 y: function(date, token, localize2) { 26993 if (token === "yo") { 26994 const signedYear = date.getFullYear(); 26995 const year = signedYear > 0 ? signedYear : 1 - signedYear; 26996 return localize2.ordinalNumber(year, { unit: "year" }); 26997 } 26998 return lightFormatters.y(date, token); 26999 }, 27000 // Local week-numbering year 27001 Y: function(date, token, localize2, options) { 27002 const signedWeekYear = getWeekYear(date, options); 27003 const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear; 27004 if (token === "YY") { 27005 const twoDigitYear = weekYear % 100; 27006 return addLeadingZeros(twoDigitYear, 2); 27007 } 27008 if (token === "Yo") { 27009 return localize2.ordinalNumber(weekYear, { unit: "year" }); 27010 } 27011 return addLeadingZeros(weekYear, token.length); 27012 }, 27013 // ISO week-numbering year 27014 R: function(date, token) { 27015 const isoWeekYear = getISOWeekYear(date); 27016 return addLeadingZeros(isoWeekYear, token.length); 27017 }, 27018 // Extended year. This is a single number designating the year of this calendar system. 27019 // The main difference between `y` and `u` localizers are B.C. years: 27020 // | Year | `y` | `u` | 27021 // |------|-----|-----| 27022 // | AC 1 | 1 | 1 | 27023 // | BC 1 | 1 | 0 | 27024 // | BC 2 | 2 | -1 | 27025 // Also `yy` always returns the last two digits of a year, 27026 // while `uu` pads single digit years to 2 characters and returns other years unchanged. 27027 u: function(date, token) { 27028 const year = date.getFullYear(); 27029 return addLeadingZeros(year, token.length); 27030 }, 27031 // Quarter 27032 Q: function(date, token, localize2) { 27033 const quarter = Math.ceil((date.getMonth() + 1) / 3); 27034 switch (token) { 27035 // 1, 2, 3, 4 27036 case "Q": 27037 return String(quarter); 27038 // 01, 02, 03, 04 27039 case "QQ": 27040 return addLeadingZeros(quarter, 2); 27041 // 1st, 2nd, 3rd, 4th 27042 case "Qo": 27043 return localize2.ordinalNumber(quarter, { unit: "quarter" }); 27044 // Q1, Q2, Q3, Q4 27045 case "QQQ": 27046 return localize2.quarter(quarter, { 27047 width: "abbreviated", 27048 context: "formatting" 27049 }); 27050 // 1, 2, 3, 4 (narrow quarter; could be not numerical) 27051 case "QQQQQ": 27052 return localize2.quarter(quarter, { 27053 width: "narrow", 27054 context: "formatting" 27055 }); 27056 // 1st quarter, 2nd quarter, ... 27057 case "QQQQ": 27058 default: 27059 return localize2.quarter(quarter, { 27060 width: "wide", 27061 context: "formatting" 27062 }); 27063 } 27064 }, 27065 // Stand-alone quarter 27066 q: function(date, token, localize2) { 27067 const quarter = Math.ceil((date.getMonth() + 1) / 3); 27068 switch (token) { 27069 // 1, 2, 3, 4 27070 case "q": 27071 return String(quarter); 27072 // 01, 02, 03, 04 27073 case "qq": 27074 return addLeadingZeros(quarter, 2); 27075 // 1st, 2nd, 3rd, 4th 27076 case "qo": 27077 return localize2.ordinalNumber(quarter, { unit: "quarter" }); 27078 // Q1, Q2, Q3, Q4 27079 case "qqq": 27080 return localize2.quarter(quarter, { 27081 width: "abbreviated", 27082 context: "standalone" 27083 }); 27084 // 1, 2, 3, 4 (narrow quarter; could be not numerical) 27085 case "qqqqq": 27086 return localize2.quarter(quarter, { 27087 width: "narrow", 27088 context: "standalone" 27089 }); 27090 // 1st quarter, 2nd quarter, ... 27091 case "qqqq": 27092 default: 27093 return localize2.quarter(quarter, { 27094 width: "wide", 27095 context: "standalone" 27096 }); 27097 } 27098 }, 27099 // Month 27100 M: function(date, token, localize2) { 27101 const month = date.getMonth(); 27102 switch (token) { 27103 case "M": 27104 case "MM": 27105 return lightFormatters.M(date, token); 27106 // 1st, 2nd, ..., 12th 27107 case "Mo": 27108 return localize2.ordinalNumber(month + 1, { unit: "month" }); 27109 // Jan, Feb, ..., Dec 27110 case "MMM": 27111 return localize2.month(month, { 27112 width: "abbreviated", 27113 context: "formatting" 27114 }); 27115 // J, F, ..., D 27116 case "MMMMM": 27117 return localize2.month(month, { 27118 width: "narrow", 27119 context: "formatting" 27120 }); 27121 // January, February, ..., December 27122 case "MMMM": 27123 default: 27124 return localize2.month(month, { width: "wide", context: "formatting" }); 27125 } 27126 }, 27127 // Stand-alone month 27128 L: function(date, token, localize2) { 27129 const month = date.getMonth(); 27130 switch (token) { 27131 // 1, 2, ..., 12 27132 case "L": 27133 return String(month + 1); 27134 // 01, 02, ..., 12 27135 case "LL": 27136 return addLeadingZeros(month + 1, 2); 27137 // 1st, 2nd, ..., 12th 27138 case "Lo": 27139 return localize2.ordinalNumber(month + 1, { unit: "month" }); 27140 // Jan, Feb, ..., Dec 27141 case "LLL": 27142 return localize2.month(month, { 27143 width: "abbreviated", 27144 context: "standalone" 27145 }); 27146 // J, F, ..., D 27147 case "LLLLL": 27148 return localize2.month(month, { 27149 width: "narrow", 27150 context: "standalone" 27151 }); 27152 // January, February, ..., December 27153 case "LLLL": 27154 default: 27155 return localize2.month(month, { width: "wide", context: "standalone" }); 27156 } 27157 }, 27158 // Local week of year 27159 w: function(date, token, localize2, options) { 27160 const week = getWeek(date, options); 27161 if (token === "wo") { 27162 return localize2.ordinalNumber(week, { unit: "week" }); 27163 } 27164 return addLeadingZeros(week, token.length); 27165 }, 27166 // ISO week of year 27167 I: function(date, token, localize2) { 27168 const isoWeek = getISOWeek(date); 27169 if (token === "Io") { 27170 return localize2.ordinalNumber(isoWeek, { unit: "week" }); 27171 } 27172 return addLeadingZeros(isoWeek, token.length); 27173 }, 27174 // Day of the month 27175 d: function(date, token, localize2) { 27176 if (token === "do") { 27177 return localize2.ordinalNumber(date.getDate(), { unit: "date" }); 27178 } 27179 return lightFormatters.d(date, token); 27180 }, 27181 // Day of year 27182 D: function(date, token, localize2) { 27183 const dayOfYear = getDayOfYear(date); 27184 if (token === "Do") { 27185 return localize2.ordinalNumber(dayOfYear, { unit: "dayOfYear" }); 27186 } 27187 return addLeadingZeros(dayOfYear, token.length); 27188 }, 27189 // Day of week 27190 E: function(date, token, localize2) { 27191 const dayOfWeek = date.getDay(); 27192 switch (token) { 27193 // Tue 27194 case "E": 27195 case "EE": 27196 case "EEE": 27197 return localize2.day(dayOfWeek, { 27198 width: "abbreviated", 27199 context: "formatting" 27200 }); 27201 // T 27202 case "EEEEE": 27203 return localize2.day(dayOfWeek, { 27204 width: "narrow", 27205 context: "formatting" 27206 }); 27207 // Tu 27208 case "EEEEEE": 27209 return localize2.day(dayOfWeek, { 27210 width: "short", 27211 context: "formatting" 27212 }); 27213 // Tuesday 27214 case "EEEE": 27215 default: 27216 return localize2.day(dayOfWeek, { 27217 width: "wide", 27218 context: "formatting" 27219 }); 27220 } 27221 }, 27222 // Local day of week 27223 e: function(date, token, localize2, options) { 27224 const dayOfWeek = date.getDay(); 27225 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7; 27226 switch (token) { 27227 // Numerical value (Nth day of week with current locale or weekStartsOn) 27228 case "e": 27229 return String(localDayOfWeek); 27230 // Padded numerical value 27231 case "ee": 27232 return addLeadingZeros(localDayOfWeek, 2); 27233 // 1st, 2nd, ..., 7th 27234 case "eo": 27235 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" }); 27236 case "eee": 27237 return localize2.day(dayOfWeek, { 27238 width: "abbreviated", 27239 context: "formatting" 27240 }); 27241 // T 27242 case "eeeee": 27243 return localize2.day(dayOfWeek, { 27244 width: "narrow", 27245 context: "formatting" 27246 }); 27247 // Tu 27248 case "eeeeee": 27249 return localize2.day(dayOfWeek, { 27250 width: "short", 27251 context: "formatting" 27252 }); 27253 // Tuesday 27254 case "eeee": 27255 default: 27256 return localize2.day(dayOfWeek, { 27257 width: "wide", 27258 context: "formatting" 27259 }); 27260 } 27261 }, 27262 // Stand-alone local day of week 27263 c: function(date, token, localize2, options) { 27264 const dayOfWeek = date.getDay(); 27265 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7; 27266 switch (token) { 27267 // Numerical value (same as in `e`) 27268 case "c": 27269 return String(localDayOfWeek); 27270 // Padded numerical value 27271 case "cc": 27272 return addLeadingZeros(localDayOfWeek, token.length); 27273 // 1st, 2nd, ..., 7th 27274 case "co": 27275 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" }); 27276 case "ccc": 27277 return localize2.day(dayOfWeek, { 27278 width: "abbreviated", 27279 context: "standalone" 27280 }); 27281 // T 27282 case "ccccc": 27283 return localize2.day(dayOfWeek, { 27284 width: "narrow", 27285 context: "standalone" 27286 }); 27287 // Tu 27288 case "cccccc": 27289 return localize2.day(dayOfWeek, { 27290 width: "short", 27291 context: "standalone" 27292 }); 27293 // Tuesday 27294 case "cccc": 27295 default: 27296 return localize2.day(dayOfWeek, { 27297 width: "wide", 27298 context: "standalone" 27299 }); 27300 } 27301 }, 27302 // ISO day of week 27303 i: function(date, token, localize2) { 27304 const dayOfWeek = date.getDay(); 27305 const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek; 27306 switch (token) { 27307 // 2 27308 case "i": 27309 return String(isoDayOfWeek); 27310 // 02 27311 case "ii": 27312 return addLeadingZeros(isoDayOfWeek, token.length); 27313 // 2nd 27314 case "io": 27315 return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" }); 27316 // Tue 27317 case "iii": 27318 return localize2.day(dayOfWeek, { 27319 width: "abbreviated", 27320 context: "formatting" 27321 }); 27322 // T 27323 case "iiiii": 27324 return localize2.day(dayOfWeek, { 27325 width: "narrow", 27326 context: "formatting" 27327 }); 27328 // Tu 27329 case "iiiiii": 27330 return localize2.day(dayOfWeek, { 27331 width: "short", 27332 context: "formatting" 27333 }); 27334 // Tuesday 27335 case "iiii": 27336 default: 27337 return localize2.day(dayOfWeek, { 27338 width: "wide", 27339 context: "formatting" 27340 }); 27341 } 27342 }, 27343 // AM or PM 27344 a: function(date, token, localize2) { 27345 const hours = date.getHours(); 27346 const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am"; 27347 switch (token) { 27348 case "a": 27349 case "aa": 27350 return localize2.dayPeriod(dayPeriodEnumValue, { 27351 width: "abbreviated", 27352 context: "formatting" 27353 }); 27354 case "aaa": 27355 return localize2.dayPeriod(dayPeriodEnumValue, { 27356 width: "abbreviated", 27357 context: "formatting" 27358 }).toLowerCase(); 27359 case "aaaaa": 27360 return localize2.dayPeriod(dayPeriodEnumValue, { 27361 width: "narrow", 27362 context: "formatting" 27363 }); 27364 case "aaaa": 27365 default: 27366 return localize2.dayPeriod(dayPeriodEnumValue, { 27367 width: "wide", 27368 context: "formatting" 27369 }); 27370 } 27371 }, 27372 // AM, PM, midnight, noon 27373 b: function(date, token, localize2) { 27374 const hours = date.getHours(); 27375 let dayPeriodEnumValue; 27376 if (hours === 12) { 27377 dayPeriodEnumValue = dayPeriodEnum.noon; 27378 } else if (hours === 0) { 27379 dayPeriodEnumValue = dayPeriodEnum.midnight; 27380 } else { 27381 dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am"; 27382 } 27383 switch (token) { 27384 case "b": 27385 case "bb": 27386 return localize2.dayPeriod(dayPeriodEnumValue, { 27387 width: "abbreviated", 27388 context: "formatting" 27389 }); 27390 case "bbb": 27391 return localize2.dayPeriod(dayPeriodEnumValue, { 27392 width: "abbreviated", 27393 context: "formatting" 27394 }).toLowerCase(); 27395 case "bbbbb": 27396 return localize2.dayPeriod(dayPeriodEnumValue, { 27397 width: "narrow", 27398 context: "formatting" 27399 }); 27400 case "bbbb": 27401 default: 27402 return localize2.dayPeriod(dayPeriodEnumValue, { 27403 width: "wide", 27404 context: "formatting" 27405 }); 27406 } 27407 }, 27408 // in the morning, in the afternoon, in the evening, at night 27409 B: function(date, token, localize2) { 27410 const hours = date.getHours(); 27411 let dayPeriodEnumValue; 27412 if (hours >= 17) { 27413 dayPeriodEnumValue = dayPeriodEnum.evening; 27414 } else if (hours >= 12) { 27415 dayPeriodEnumValue = dayPeriodEnum.afternoon; 27416 } else if (hours >= 4) { 27417 dayPeriodEnumValue = dayPeriodEnum.morning; 27418 } else { 27419 dayPeriodEnumValue = dayPeriodEnum.night; 27420 } 27421 switch (token) { 27422 case "B": 27423 case "BB": 27424 case "BBB": 27425 return localize2.dayPeriod(dayPeriodEnumValue, { 27426 width: "abbreviated", 27427 context: "formatting" 27428 }); 27429 case "BBBBB": 27430 return localize2.dayPeriod(dayPeriodEnumValue, { 27431 width: "narrow", 27432 context: "formatting" 27433 }); 27434 case "BBBB": 27435 default: 27436 return localize2.dayPeriod(dayPeriodEnumValue, { 27437 width: "wide", 27438 context: "formatting" 27439 }); 27440 } 27441 }, 27442 // Hour [1-12] 27443 h: function(date, token, localize2) { 27444 if (token === "ho") { 27445 let hours = date.getHours() % 12; 27446 if (hours === 0) hours = 12; 27447 return localize2.ordinalNumber(hours, { unit: "hour" }); 27448 } 27449 return lightFormatters.h(date, token); 27450 }, 27451 // Hour [0-23] 27452 H: function(date, token, localize2) { 27453 if (token === "Ho") { 27454 return localize2.ordinalNumber(date.getHours(), { unit: "hour" }); 27455 } 27456 return lightFormatters.H(date, token); 27457 }, 27458 // Hour [0-11] 27459 K: function(date, token, localize2) { 27460 const hours = date.getHours() % 12; 27461 if (token === "Ko") { 27462 return localize2.ordinalNumber(hours, { unit: "hour" }); 27463 } 27464 return addLeadingZeros(hours, token.length); 27465 }, 27466 // Hour [1-24] 27467 k: function(date, token, localize2) { 27468 let hours = date.getHours(); 27469 if (hours === 0) hours = 24; 27470 if (token === "ko") { 27471 return localize2.ordinalNumber(hours, { unit: "hour" }); 27472 } 27473 return addLeadingZeros(hours, token.length); 27474 }, 27475 // Minute 27476 m: function(date, token, localize2) { 27477 if (token === "mo") { 27478 return localize2.ordinalNumber(date.getMinutes(), { unit: "minute" }); 27479 } 27480 return lightFormatters.m(date, token); 27481 }, 27482 // Second 27483 s: function(date, token, localize2) { 27484 if (token === "so") { 27485 return localize2.ordinalNumber(date.getSeconds(), { unit: "second" }); 27486 } 27487 return lightFormatters.s(date, token); 27488 }, 27489 // Fraction of second 27490 S: function(date, token) { 27491 return lightFormatters.S(date, token); 27492 }, 27493 // Timezone (ISO-8601. If offset is 0, output is always `'Z'`) 27494 X: function(date, token, _localize) { 27495 const timezoneOffset = date.getTimezoneOffset(); 27496 if (timezoneOffset === 0) { 27497 return "Z"; 27498 } 27499 switch (token) { 27500 // Hours and optional minutes 27501 case "X": 27502 return formatTimezoneWithOptionalMinutes(timezoneOffset); 27503 // Hours, minutes and optional seconds without `:` delimiter 27504 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets 27505 // so this token always has the same output as `XX` 27506 case "XXXX": 27507 case "XX": 27508 return formatTimezone(timezoneOffset); 27509 // Hours, minutes and optional seconds with `:` delimiter 27510 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets 27511 // so this token always has the same output as `XXX` 27512 case "XXXXX": 27513 case "XXX": 27514 // Hours and minutes with `:` delimiter 27515 default: 27516 return formatTimezone(timezoneOffset, ":"); 27517 } 27518 }, 27519 // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent) 27520 x: function(date, token, _localize) { 27521 const timezoneOffset = date.getTimezoneOffset(); 27522 switch (token) { 27523 // Hours and optional minutes 27524 case "x": 27525 return formatTimezoneWithOptionalMinutes(timezoneOffset); 27526 // Hours, minutes and optional seconds without `:` delimiter 27527 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets 27528 // so this token always has the same output as `xx` 27529 case "xxxx": 27530 case "xx": 27531 return formatTimezone(timezoneOffset); 27532 // Hours, minutes and optional seconds with `:` delimiter 27533 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets 27534 // so this token always has the same output as `xxx` 27535 case "xxxxx": 27536 case "xxx": 27537 // Hours and minutes with `:` delimiter 27538 default: 27539 return formatTimezone(timezoneOffset, ":"); 27540 } 27541 }, 27542 // Timezone (GMT) 27543 O: function(date, token, _localize) { 27544 const timezoneOffset = date.getTimezoneOffset(); 27545 switch (token) { 27546 // Short 27547 case "O": 27548 case "OO": 27549 case "OOO": 27550 return "GMT" + formatTimezoneShort(timezoneOffset, ":"); 27551 // Long 27552 case "OOOO": 27553 default: 27554 return "GMT" + formatTimezone(timezoneOffset, ":"); 27555 } 27556 }, 27557 // Timezone (specific non-location) 27558 z: function(date, token, _localize) { 27559 const timezoneOffset = date.getTimezoneOffset(); 27560 switch (token) { 27561 // Short 27562 case "z": 27563 case "zz": 27564 case "zzz": 27565 return "GMT" + formatTimezoneShort(timezoneOffset, ":"); 27566 // Long 27567 case "zzzz": 27568 default: 27569 return "GMT" + formatTimezone(timezoneOffset, ":"); 27570 } 27571 }, 27572 // Seconds timestamp 27573 t: function(date, token, _localize) { 27574 const timestamp = Math.trunc(+date / 1e3); 27575 return addLeadingZeros(timestamp, token.length); 27576 }, 27577 // Milliseconds timestamp 27578 T: function(date, token, _localize) { 27579 return addLeadingZeros(+date, token.length); 27580 } 27581 }; 27582 function formatTimezoneShort(offset4, delimiter = "") { 27583 const sign = offset4 > 0 ? "-" : "+"; 27584 const absOffset = Math.abs(offset4); 27585 const hours = Math.trunc(absOffset / 60); 27586 const minutes = absOffset % 60; 27587 if (minutes === 0) { 27588 return sign + String(hours); 27589 } 27590 return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2); 27591 } 27592 function formatTimezoneWithOptionalMinutes(offset4, delimiter) { 27593 if (offset4 % 60 === 0) { 27594 const sign = offset4 > 0 ? "-" : "+"; 27595 return sign + addLeadingZeros(Math.abs(offset4) / 60, 2); 27596 } 27597 return formatTimezone(offset4, delimiter); 27598 } 27599 function formatTimezone(offset4, delimiter = "") { 27600 const sign = offset4 > 0 ? "-" : "+"; 27601 const absOffset = Math.abs(offset4); 27602 const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2); 27603 const minutes = addLeadingZeros(absOffset % 60, 2); 27604 return sign + hours + delimiter + minutes; 27605 } 27606 27607 // node_modules/date-fns/_lib/format/longFormatters.js 27608 var dateLongFormatter = (pattern, formatLong2) => { 27609 switch (pattern) { 27610 case "P": 27611 return formatLong2.date({ width: "short" }); 27612 case "PP": 27613 return formatLong2.date({ width: "medium" }); 27614 case "PPP": 27615 return formatLong2.date({ width: "long" }); 27616 case "PPPP": 27617 default: 27618 return formatLong2.date({ width: "full" }); 27619 } 27620 }; 27621 var timeLongFormatter = (pattern, formatLong2) => { 27622 switch (pattern) { 27623 case "p": 27624 return formatLong2.time({ width: "short" }); 27625 case "pp": 27626 return formatLong2.time({ width: "medium" }); 27627 case "ppp": 27628 return formatLong2.time({ width: "long" }); 27629 case "pppp": 27630 default: 27631 return formatLong2.time({ width: "full" }); 27632 } 27633 }; 27634 var dateTimeLongFormatter = (pattern, formatLong2) => { 27635 const matchResult = pattern.match(/(P+)(p+)?/) || []; 27636 const datePattern = matchResult[1]; 27637 const timePattern = matchResult[2]; 27638 if (!timePattern) { 27639 return dateLongFormatter(pattern, formatLong2); 27640 } 27641 let dateTimeFormat; 27642 switch (datePattern) { 27643 case "P": 27644 dateTimeFormat = formatLong2.dateTime({ width: "short" }); 27645 break; 27646 case "PP": 27647 dateTimeFormat = formatLong2.dateTime({ width: "medium" }); 27648 break; 27649 case "PPP": 27650 dateTimeFormat = formatLong2.dateTime({ width: "long" }); 27651 break; 27652 case "PPPP": 27653 default: 27654 dateTimeFormat = formatLong2.dateTime({ width: "full" }); 27655 break; 27656 } 27657 return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2)); 27658 }; 27659 var longFormatters = { 27660 p: timeLongFormatter, 27661 P: dateTimeLongFormatter 27662 }; 27663 27664 // node_modules/date-fns/_lib/protectedTokens.js 27665 var dayOfYearTokenRE = /^D+$/; 27666 var weekYearTokenRE = /^Y+$/; 27667 var throwTokens = ["D", "DD", "YY", "YYYY"]; 27668 function isProtectedDayOfYearToken(token) { 27669 return dayOfYearTokenRE.test(token); 27670 } 27671 function isProtectedWeekYearToken(token) { 27672 return weekYearTokenRE.test(token); 27673 } 27674 function warnOrThrowProtectedError(token, format6, input) { 27675 const _message = message(token, format6, input); 27676 console.warn(_message); 27677 if (throwTokens.includes(token)) throw new RangeError(_message); 27678 } 27679 function message(token, format6, input) { 27680 const subject = token[0] === "Y" ? "years" : "days of the month"; 27681 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`; 27682 } 27683 27684 // node_modules/date-fns/format.js 27685 var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g; 27686 var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g; 27687 var escapedStringRegExp = /^'([^]*?)'?$/; 27688 var doubleQuoteRegExp = /''/g; 27689 var unescapedLatinCharacterRegExp = /[a-zA-Z]/; 27690 function format(date, formatStr, options) { 27691 const defaultOptions2 = getDefaultOptions(); 27692 const locale = options?.locale ?? defaultOptions2.locale ?? enUS; 27693 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1; 27694 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0; 27695 const originalDate = toDate(date, options?.in); 27696 if (!isValid(originalDate)) { 27697 throw new RangeError("Invalid time value"); 27698 } 27699 let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => { 27700 const firstCharacter = substring[0]; 27701 if (firstCharacter === "p" || firstCharacter === "P") { 27702 const longFormatter = longFormatters[firstCharacter]; 27703 return longFormatter(substring, locale.formatLong); 27704 } 27705 return substring; 27706 }).join("").match(formattingTokensRegExp).map((substring) => { 27707 if (substring === "''") { 27708 return { isToken: false, value: "'" }; 27709 } 27710 const firstCharacter = substring[0]; 27711 if (firstCharacter === "'") { 27712 return { isToken: false, value: cleanEscapedString(substring) }; 27713 } 27714 if (formatters[firstCharacter]) { 27715 return { isToken: true, value: substring }; 27716 } 27717 if (firstCharacter.match(unescapedLatinCharacterRegExp)) { 27718 throw new RangeError( 27719 "Format string contains an unescaped latin alphabet character `" + firstCharacter + "`" 27720 ); 27721 } 27722 return { isToken: false, value: substring }; 27723 }); 27724 if (locale.localize.preprocessor) { 27725 parts = locale.localize.preprocessor(originalDate, parts); 27726 } 27727 const formatterOptions = { 27728 firstWeekContainsDate, 27729 weekStartsOn, 27730 locale 27731 }; 27732 return parts.map((part) => { 27733 if (!part.isToken) return part.value; 27734 const token = part.value; 27735 if (!options?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token) || !options?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) { 27736 warnOrThrowProtectedError(token, formatStr, String(date)); 27737 } 27738 const formatter = formatters[token[0]]; 27739 return formatter(originalDate, token, locale.localize, formatterOptions); 27740 }).join(""); 27741 } 27742 function cleanEscapedString(input) { 27743 const matched = input.match(escapedStringRegExp); 27744 if (!matched) { 27745 return input; 27746 } 27747 return matched[1].replace(doubleQuoteRegExp, "'"); 27748 } 27749 27750 // node_modules/date-fns/subDays.js 27751 function subDays(date, amount, options) { 27752 return addDays(date, -amount, options); 27753 } 27754 27755 // node_modules/date-fns/subMonths.js 27756 function subMonths(date, amount, options) { 27757 return addMonths(date, -amount, options); 27758 } 27759 27760 // node_modules/date-fns/subWeeks.js 27761 function subWeeks(date, amount, options) { 27762 return addWeeks(date, -amount, options); 27763 } 27764 27765 // node_modules/date-fns/subYears.js 27766 function subYears(date, amount, options) { 27767 return addYears(date, -amount, options); 27768 } 27769 27770 // packages/dataviews/build-module/utils/operators.mjs 27771 var import_i18n29 = __toESM(require_i18n(), 1); 27772 var import_element85 = __toESM(require_element(), 1); 27773 var import_date = __toESM(require_date(), 1); 27774 var import_jsx_runtime125 = __toESM(require_jsx_runtime(), 1); 27775 var filterTextWrappers = { 27776 Name: /* @__PURE__ */ (0, import_jsx_runtime125.jsx)("span", { className: "dataviews-filters__summary-filter-text-name" }), 27777 Value: /* @__PURE__ */ (0, import_jsx_runtime125.jsx)("span", { className: "dataviews-filters__summary-filter-text-value" }) 27778 }; 27779 function getRelativeDate(value, unit) { 27780 switch (unit) { 27781 case "days": 27782 return subDays(/* @__PURE__ */ new Date(), value); 27783 case "weeks": 27784 return subWeeks(/* @__PURE__ */ new Date(), value); 27785 case "months": 27786 return subMonths(/* @__PURE__ */ new Date(), value); 27787 case "years": 27788 return subYears(/* @__PURE__ */ new Date(), value); 27789 default: 27790 return /* @__PURE__ */ new Date(); 27791 } 27792 } 27793 var isNoneOperatorDefinition = { 27794 /* translators: DataViews operator name */ 27795 label: (0, import_i18n29.__)("Is none of"), 27796 filterText: (filter, activeElements) => (0, import_element85.createInterpolateElement)( 27797 (0, import_i18n29.sprintf)( 27798 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */ 27799 (0, import_i18n29.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"), 27800 filter.name, 27801 activeElements.map((element) => element.label).join(", ") 27802 ), 27803 filterTextWrappers 27804 ), 27805 filter: ((item, field, filterValue) => { 27806 if (!filterValue?.length) { 27807 return true; 27808 } 27809 const fieldValue = field.getValue({ item }); 27810 if (Array.isArray(fieldValue)) { 27811 return !filterValue.some( 27812 (fv) => fieldValue.includes(fv) 27813 ); 27814 } else if (typeof fieldValue === "string") { 27815 return !filterValue.includes(fieldValue); 27816 } 27817 return false; 27818 }), 27819 selection: "multi" 27820 }; 27821 var OPERATORS = [ 27822 { 27823 name: OPERATOR_IS_ANY, 27824 /* translators: DataViews operator name */ 27825 label: (0, import_i18n29.__)("Includes"), 27826 filterText: (filter, activeElements) => (0, import_element85.createInterpolateElement)( 27827 (0, import_i18n29.sprintf)( 27828 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is any: Admin, Editor". */ 27829 (0, import_i18n29.__)("<Name>%1$s includes: </Name><Value>%2$s</Value>"), 27830 filter.name, 27831 activeElements.map((element) => element.label).join(", ") 27832 ), 27833 filterTextWrappers 27834 ), 27835 filter(item, field, filterValue) { 27836 if (!filterValue?.length) { 27837 return true; 27838 } 27839 const fieldValue = field.getValue({ item }); 27840 if (Array.isArray(fieldValue)) { 27841 return filterValue.some( 27842 (fv) => fieldValue.includes(fv) 27843 ); 27844 } else if (typeof fieldValue === "string") { 27845 return filterValue.includes(fieldValue); 27846 } 27847 return false; 27848 }, 27849 selection: "multi" 27850 }, 27851 { 27852 name: OPERATOR_IS_NONE, 27853 ...isNoneOperatorDefinition 27854 }, 27855 { 27856 name: OPERATOR_IS_ALL, 27857 /* translators: DataViews operator name */ 27858 label: (0, import_i18n29.__)("Includes all"), 27859 filterText: (filter, activeElements) => (0, import_element85.createInterpolateElement)( 27860 (0, import_i18n29.sprintf)( 27861 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author includes all: Admin, Editor". */ 27862 (0, import_i18n29.__)("<Name>%1$s includes all: </Name><Value>%2$s</Value>"), 27863 filter.name, 27864 activeElements.map((element) => element.label).join(", ") 27865 ), 27866 filterTextWrappers 27867 ), 27868 filter(item, field, filterValue) { 27869 if (!filterValue?.length) { 27870 return true; 27871 } 27872 return filterValue.every((value) => { 27873 return field.getValue({ item })?.includes(value); 27874 }); 27875 }, 27876 selection: "multi" 27877 }, 27878 { 27879 name: OPERATOR_IS_NOT_ALL, 27880 ...isNoneOperatorDefinition 27881 }, 27882 { 27883 name: OPERATOR_BETWEEN, 27884 /* translators: DataViews operator name */ 27885 label: (0, import_i18n29.__)("Between (inc)"), 27886 filterText: (filter, activeElements) => (0, import_element85.createInterpolateElement)( 27887 (0, import_i18n29.sprintf)( 27888 /* 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". */ 27889 (0, import_i18n29.__)( 27890 "<Name>%1$s between (inc): </Name><Value>%2$s and %3$s</Value>" 27891 ), 27892 filter.name, 27893 activeElements[0].label[0], 27894 activeElements[0].label[1] 27895 ), 27896 filterTextWrappers 27897 ), 27898 filter(item, field, filterValue) { 27899 if (!Array.isArray(filterValue) || filterValue.length !== 2 || filterValue[0] === void 0 || filterValue[1] === void 0) { 27900 return true; 27901 } 27902 const fieldValue = field.getValue({ item }); 27903 if (typeof fieldValue === "number" || fieldValue instanceof Date || typeof fieldValue === "string") { 27904 return fieldValue >= filterValue[0] && fieldValue <= filterValue[1]; 27905 } 27906 return false; 27907 }, 27908 selection: "custom" 27909 }, 27910 { 27911 name: OPERATOR_IN_THE_PAST, 27912 /* translators: DataViews operator name */ 27913 label: (0, import_i18n29.__)("In the past"), 27914 filterText: (filter, activeElements) => (0, import_element85.createInterpolateElement)( 27915 (0, import_i18n29.sprintf)( 27916 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is in the past: 7 days". */ 27917 (0, import_i18n29.__)( 27918 "<Name>%1$s is in the past: </Name><Value>%2$s</Value>" 27919 ), 27920 filter.name, 27921 `$activeElements[0].value.value} $activeElements[0].value.unit}` 27922 ), 27923 filterTextWrappers 27924 ), 27925 filter(item, field, filterValue) { 27926 if (filterValue?.value === void 0 || filterValue?.unit === void 0) { 27927 return true; 27928 } 27929 const targetDate = getRelativeDate( 27930 filterValue.value, 27931 filterValue.unit 27932 ); 27933 const fieldValue = (0, import_date.getDate)(field.getValue({ item })); 27934 return fieldValue >= targetDate && fieldValue <= /* @__PURE__ */ new Date(); 27935 }, 27936 selection: "custom" 27937 }, 27938 { 27939 name: OPERATOR_OVER, 27940 /* translators: DataViews operator name */ 27941 label: (0, import_i18n29.__)("Over"), 27942 filterText: (filter, activeElements) => (0, import_element85.createInterpolateElement)( 27943 (0, import_i18n29.sprintf)( 27944 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is over: 7 days". */ 27945 (0, import_i18n29.__)("<Name>%1$s is over: </Name><Value>%2$s</Value>"), 27946 filter.name, 27947 `$activeElements[0].value.value} $activeElements[0].value.unit}` 27948 ), 27949 filterTextWrappers 27950 ), 27951 filter(item, field, filterValue) { 27952 if (filterValue?.value === void 0 || filterValue?.unit === void 0) { 27953 return true; 27954 } 27955 const targetDate = getRelativeDate( 27956 filterValue.value, 27957 filterValue.unit 27958 ); 27959 const fieldValue = (0, import_date.getDate)(field.getValue({ item })); 27960 return fieldValue < targetDate; 27961 }, 27962 selection: "custom" 27963 }, 27964 { 27965 name: OPERATOR_IS, 27966 /* translators: DataViews operator name */ 27967 label: (0, import_i18n29.__)("Is"), 27968 filterText: (filter, activeElements) => (0, import_element85.createInterpolateElement)( 27969 (0, import_i18n29.sprintf)( 27970 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is: Admin". */ 27971 (0, import_i18n29.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"), 27972 filter.name, 27973 activeElements[0].label 27974 ), 27975 filterTextWrappers 27976 ), 27977 filter(item, field, filterValue) { 27978 return filterValue === field.getValue({ item }) || filterValue === void 0; 27979 }, 27980 selection: "single" 27981 }, 27982 { 27983 name: OPERATOR_IS_NOT, 27984 /* translators: DataViews operator name */ 27985 label: (0, import_i18n29.__)("Is not"), 27986 filterText: (filter, activeElements) => (0, import_element85.createInterpolateElement)( 27987 (0, import_i18n29.sprintf)( 27988 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is not: Admin". */ 27989 (0, import_i18n29.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"), 27990 filter.name, 27991 activeElements[0].label 27992 ), 27993 filterTextWrappers 27994 ), 27995 filter(item, field, filterValue) { 27996 return filterValue !== field.getValue({ item }); 27997 }, 27998 selection: "single" 27999 }, 28000 { 28001 name: OPERATOR_LESS_THAN, 28002 /* translators: DataViews operator name */ 28003 label: (0, import_i18n29.__)("Less than"), 28004 filterText: (filter, activeElements) => (0, import_element85.createInterpolateElement)( 28005 (0, import_i18n29.sprintf)( 28006 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than: 10". */ 28007 (0, import_i18n29.__)("<Name>%1$s is less than: </Name><Value>%2$s</Value>"), 28008 filter.name, 28009 activeElements[0].label 28010 ), 28011 filterTextWrappers 28012 ), 28013 filter(item, field, filterValue) { 28014 if (filterValue === void 0) { 28015 return true; 28016 } 28017 const fieldValue = field.getValue({ item }); 28018 return fieldValue < filterValue; 28019 }, 28020 selection: "single" 28021 }, 28022 { 28023 name: OPERATOR_GREATER_THAN, 28024 /* translators: DataViews operator name */ 28025 label: (0, import_i18n29.__)("Greater than"), 28026 filterText: (filter, activeElements) => (0, import_element85.createInterpolateElement)( 28027 (0, import_i18n29.sprintf)( 28028 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than: 10". */ 28029 (0, import_i18n29.__)( 28030 "<Name>%1$s is greater than: </Name><Value>%2$s</Value>" 28031 ), 28032 filter.name, 28033 activeElements[0].label 28034 ), 28035 filterTextWrappers 28036 ), 28037 filter(item, field, filterValue) { 28038 if (filterValue === void 0) { 28039 return true; 28040 } 28041 const fieldValue = field.getValue({ item }); 28042 return fieldValue > filterValue; 28043 }, 28044 selection: "single" 28045 }, 28046 { 28047 name: OPERATOR_LESS_THAN_OR_EQUAL, 28048 /* translators: DataViews operator name */ 28049 label: (0, import_i18n29.__)("Less than or equal"), 28050 filterText: (filter, activeElements) => (0, import_element85.createInterpolateElement)( 28051 (0, import_i18n29.sprintf)( 28052 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than or equal to: 10". */ 28053 (0, import_i18n29.__)( 28054 "<Name>%1$s is less than or equal to: </Name><Value>%2$s</Value>" 28055 ), 28056 filter.name, 28057 activeElements[0].label 28058 ), 28059 filterTextWrappers 28060 ), 28061 filter(item, field, filterValue) { 28062 if (filterValue === void 0) { 28063 return true; 28064 } 28065 const fieldValue = field.getValue({ item }); 28066 return fieldValue <= filterValue; 28067 }, 28068 selection: "single" 28069 }, 28070 { 28071 name: OPERATOR_GREATER_THAN_OR_EQUAL, 28072 /* translators: DataViews operator name */ 28073 label: (0, import_i18n29.__)("Greater than or equal"), 28074 filterText: (filter, activeElements) => (0, import_element85.createInterpolateElement)( 28075 (0, import_i18n29.sprintf)( 28076 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than or equal to: 10". */ 28077 (0, import_i18n29.__)( 28078 "<Name>%1$s is greater than or equal to: </Name><Value>%2$s</Value>" 28079 ), 28080 filter.name, 28081 activeElements[0].label 28082 ), 28083 filterTextWrappers 28084 ), 28085 filter(item, field, filterValue) { 28086 if (filterValue === void 0) { 28087 return true; 28088 } 28089 const fieldValue = field.getValue({ item }); 28090 return fieldValue >= filterValue; 28091 }, 28092 selection: "single" 28093 }, 28094 { 28095 name: OPERATOR_BEFORE, 28096 /* translators: DataViews operator name */ 28097 label: (0, import_i18n29.__)("Before"), 28098 filterText: (filter, activeElements) => (0, import_element85.createInterpolateElement)( 28099 (0, import_i18n29.sprintf)( 28100 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is before: 2024-01-01". */ 28101 (0, import_i18n29.__)("<Name>%1$s is before: </Name><Value>%2$s</Value>"), 28102 filter.name, 28103 activeElements[0].label 28104 ), 28105 filterTextWrappers 28106 ), 28107 filter(item, field, filterValue) { 28108 if (filterValue === void 0) { 28109 return true; 28110 } 28111 const filterDate = (0, import_date.getDate)(filterValue); 28112 const fieldDate = (0, import_date.getDate)(field.getValue({ item })); 28113 return fieldDate < filterDate; 28114 }, 28115 selection: "single" 28116 }, 28117 { 28118 name: OPERATOR_AFTER, 28119 /* translators: DataViews operator name */ 28120 label: (0, import_i18n29.__)("After"), 28121 filterText: (filter, activeElements) => (0, import_element85.createInterpolateElement)( 28122 (0, import_i18n29.sprintf)( 28123 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is after: 2024-01-01". */ 28124 (0, import_i18n29.__)("<Name>%1$s is after: </Name><Value>%2$s</Value>"), 28125 filter.name, 28126 activeElements[0].label 28127 ), 28128 filterTextWrappers 28129 ), 28130 filter(item, field, filterValue) { 28131 if (filterValue === void 0) { 28132 return true; 28133 } 28134 const filterDate = (0, import_date.getDate)(filterValue); 28135 const fieldDate = (0, import_date.getDate)(field.getValue({ item })); 28136 return fieldDate > filterDate; 28137 }, 28138 selection: "single" 28139 }, 28140 { 28141 name: OPERATOR_BEFORE_INC, 28142 /* translators: DataViews operator name */ 28143 label: (0, import_i18n29.__)("Before (inc)"), 28144 filterText: (filter, activeElements) => (0, import_element85.createInterpolateElement)( 28145 (0, import_i18n29.sprintf)( 28146 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or before: 2024-01-01". */ 28147 (0, import_i18n29.__)( 28148 "<Name>%1$s is on or before: </Name><Value>%2$s</Value>" 28149 ), 28150 filter.name, 28151 activeElements[0].label 28152 ), 28153 filterTextWrappers 28154 ), 28155 filter(item, field, filterValue) { 28156 if (filterValue === void 0) { 28157 return true; 28158 } 28159 const filterDate = (0, import_date.getDate)(filterValue); 28160 const fieldDate = (0, import_date.getDate)(field.getValue({ item })); 28161 return fieldDate <= filterDate; 28162 }, 28163 selection: "single" 28164 }, 28165 { 28166 name: OPERATOR_AFTER_INC, 28167 /* translators: DataViews operator name */ 28168 label: (0, import_i18n29.__)("After (inc)"), 28169 filterText: (filter, activeElements) => (0, import_element85.createInterpolateElement)( 28170 (0, import_i18n29.sprintf)( 28171 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or after: 2024-01-01". */ 28172 (0, import_i18n29.__)( 28173 "<Name>%1$s is on or after: </Name><Value>%2$s</Value>" 28174 ), 28175 filter.name, 28176 activeElements[0].label 28177 ), 28178 filterTextWrappers 28179 ), 28180 filter(item, field, filterValue) { 28181 if (filterValue === void 0) { 28182 return true; 28183 } 28184 const filterDate = (0, import_date.getDate)(filterValue); 28185 const fieldDate = (0, import_date.getDate)(field.getValue({ item })); 28186 return fieldDate >= filterDate; 28187 }, 28188 selection: "single" 28189 }, 28190 { 28191 name: OPERATOR_CONTAINS, 28192 /* translators: DataViews operator name */ 28193 label: (0, import_i18n29.__)("Contains"), 28194 filterText: (filter, activeElements) => (0, import_element85.createInterpolateElement)( 28195 (0, import_i18n29.sprintf)( 28196 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title contains: Hello". */ 28197 (0, import_i18n29.__)("<Name>%1$s contains: </Name><Value>%2$s</Value>"), 28198 filter.name, 28199 activeElements[0].label 28200 ), 28201 filterTextWrappers 28202 ), 28203 filter(item, field, filterValue) { 28204 if (filterValue === void 0) { 28205 return true; 28206 } 28207 const fieldValue = field.getValue({ item }); 28208 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().includes(String(filterValue).toLowerCase()); 28209 }, 28210 selection: "single" 28211 }, 28212 { 28213 name: OPERATOR_NOT_CONTAINS, 28214 /* translators: DataViews operator name */ 28215 label: (0, import_i18n29.__)("Doesn't contain"), 28216 filterText: (filter, activeElements) => (0, import_element85.createInterpolateElement)( 28217 (0, import_i18n29.sprintf)( 28218 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title doesn't contain: Hello". */ 28219 (0, import_i18n29.__)( 28220 "<Name>%1$s doesn't contain: </Name><Value>%2$s</Value>" 28221 ), 28222 filter.name, 28223 activeElements[0].label 28224 ), 28225 filterTextWrappers 28226 ), 28227 filter(item, field, filterValue) { 28228 if (filterValue === void 0) { 28229 return true; 28230 } 28231 const fieldValue = field.getValue({ item }); 28232 return typeof fieldValue === "string" && filterValue && !fieldValue.toLowerCase().includes(String(filterValue).toLowerCase()); 28233 }, 28234 selection: "single" 28235 }, 28236 { 28237 name: OPERATOR_STARTS_WITH, 28238 /* translators: DataViews operator name */ 28239 label: (0, import_i18n29.__)("Starts with"), 28240 filterText: (filter, activeElements) => (0, import_element85.createInterpolateElement)( 28241 (0, import_i18n29.sprintf)( 28242 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title starts with: Hello". */ 28243 (0, import_i18n29.__)("<Name>%1$s starts with: </Name><Value>%2$s</Value>"), 28244 filter.name, 28245 activeElements[0].label 28246 ), 28247 filterTextWrappers 28248 ), 28249 filter(item, field, filterValue) { 28250 if (filterValue === void 0) { 28251 return true; 28252 } 28253 const fieldValue = field.getValue({ item }); 28254 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().startsWith(String(filterValue).toLowerCase()); 28255 }, 28256 selection: "single" 28257 }, 28258 { 28259 name: OPERATOR_ON, 28260 /* translators: DataViews operator name */ 28261 label: (0, import_i18n29.__)("On"), 28262 filterText: (filter, activeElements) => (0, import_element85.createInterpolateElement)( 28263 (0, import_i18n29.sprintf)( 28264 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is: 2024-01-01". */ 28265 (0, import_i18n29.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"), 28266 filter.name, 28267 activeElements[0].label 28268 ), 28269 filterTextWrappers 28270 ), 28271 filter(item, field, filterValue) { 28272 if (filterValue === void 0) { 28273 return true; 28274 } 28275 const filterDate = (0, import_date.getDate)(filterValue); 28276 const fieldDate = (0, import_date.getDate)(field.getValue({ item })); 28277 return filterDate.getTime() === fieldDate.getTime(); 28278 }, 28279 selection: "single" 28280 }, 28281 { 28282 name: OPERATOR_NOT_ON, 28283 /* translators: DataViews operator name */ 28284 label: (0, import_i18n29.__)("Not on"), 28285 filterText: (filter, activeElements) => (0, import_element85.createInterpolateElement)( 28286 (0, import_i18n29.sprintf)( 28287 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is not: 2024-01-01". */ 28288 (0, import_i18n29.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"), 28289 filter.name, 28290 activeElements[0].label 28291 ), 28292 filterTextWrappers 28293 ), 28294 filter(item, field, filterValue) { 28295 if (filterValue === void 0) { 28296 return true; 28297 } 28298 const filterDate = (0, import_date.getDate)(filterValue); 28299 const fieldDate = (0, import_date.getDate)(field.getValue({ item })); 28300 return filterDate.getTime() !== fieldDate.getTime(); 28301 }, 28302 selection: "single" 28303 } 28304 ]; 28305 var getOperatorByName = (name) => OPERATORS.find((op) => op.name === name); 28306 var getAllOperatorNames = () => OPERATORS.map((op) => op.name); 28307 var isSingleSelectionOperator = (name) => OPERATORS.filter((op) => op.selection === "single").some( 28308 (op) => op.name === name 28309 ); 28310 var isRegisteredOperator = (name) => OPERATORS.some((op) => op.name === name); 28311 28312 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs 28313 var import_jsx_runtime126 = __toESM(require_jsx_runtime(), 1); 28314 var ENTER = "Enter"; 28315 var SPACE = " "; 28316 var FilterText = ({ 28317 activeElements, 28318 filterInView, 28319 filter 28320 }) => { 28321 if (activeElements === void 0 || activeElements.length === 0) { 28322 return filter.name; 28323 } 28324 const operator = getOperatorByName(filterInView?.operator); 28325 if (operator !== void 0) { 28326 return operator.filterText(filter, activeElements); 28327 } 28328 return (0, import_i18n30.sprintf)( 28329 /* translators: 1: Filter name e.g.: "Unknown status for Author". */ 28330 (0, import_i18n30.__)("Unknown status for %1$s"), 28331 filter.name 28332 ); 28333 }; 28334 function OperatorSelector({ 28335 filter, 28336 view, 28337 onChangeView 28338 }) { 28339 const operatorOptions = filter.operators?.map((operator) => ({ 28340 value: operator, 28341 label: getOperatorByName(operator)?.label || operator 28342 })); 28343 const currentFilter = view.filters?.find( 28344 (_filter) => _filter.field === filter.field 28345 ); 28346 const value = currentFilter?.operator || filter.operators[0]; 28347 return operatorOptions.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime126.jsxs)( 28348 Stack, 28349 { 28350 direction: "row", 28351 gap: "sm", 28352 justify: "flex-start", 28353 className: "dataviews-filters__summary-operators-container", 28354 align: "center", 28355 children: [ 28356 /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(import_components23.FlexItem, { className: "dataviews-filters__summary-operators-filter-name", children: filter.name }), 28357 /* @__PURE__ */ (0, import_jsx_runtime126.jsx)( 28358 import_components23.SelectControl, 28359 { 28360 className: "dataviews-filters__summary-operators-filter-select", 28361 label: (0, import_i18n30.__)("Conditions"), 28362 value, 28363 options: operatorOptions, 28364 onChange: (newValue) => { 28365 const newOperator = newValue; 28366 const currentOperator = currentFilter?.operator; 28367 const newFilters = currentFilter ? [ 28368 ...(view.filters ?? []).map( 28369 (_filter) => { 28370 if (_filter.field === filter.field) { 28371 const currentOpSelectionModel = getOperatorByName( 28372 currentOperator 28373 )?.selection; 28374 const newOpSelectionModel = getOperatorByName( 28375 newOperator 28376 )?.selection; 28377 const shouldResetValue = currentOpSelectionModel !== newOpSelectionModel || [ 28378 currentOpSelectionModel, 28379 newOpSelectionModel 28380 ].includes("custom"); 28381 return { 28382 ..._filter, 28383 value: shouldResetValue ? void 0 : _filter.value, 28384 operator: newOperator 28385 }; 28386 } 28387 return _filter; 28388 } 28389 ) 28390 ] : [ 28391 ...view.filters ?? [], 28392 { 28393 field: filter.field, 28394 operator: newOperator, 28395 value: void 0 28396 } 28397 ]; 28398 onChangeView({ 28399 ...view, 28400 page: 1, 28401 filters: newFilters 28402 }); 28403 }, 28404 size: "small", 28405 variant: "minimal", 28406 hideLabelFromVision: true 28407 } 28408 ) 28409 ] 28410 } 28411 ); 28412 } 28413 function Filter({ 28414 addFilterRef, 28415 openedFilter, 28416 fields, 28417 ...commonProps 28418 }) { 28419 const toggleRef = (0, import_element86.useRef)(null); 28420 const { filter, view, onChangeView } = commonProps; 28421 const filterInView = view.filters?.find( 28422 (f2) => f2.field === filter.field 28423 ); 28424 let activeElements = []; 28425 const field = (0, import_element86.useMemo)(() => { 28426 const currentField = fields.find((f2) => f2.id === filter.field); 28427 if (currentField) { 28428 return { 28429 ...currentField, 28430 // Configure getValue as if Item was a plain object. 28431 // See related input-widget.tsx 28432 getValue: ({ item }) => item[currentField.id] 28433 }; 28434 } 28435 return currentField; 28436 }, [fields, filter.field]); 28437 const { elements } = useElements({ 28438 elements: filter.elements, 28439 getElements: filter.getElements 28440 }); 28441 if (elements.length > 0) { 28442 activeElements = elements.filter((element) => { 28443 if (filter.singleSelection) { 28444 return element.value === filterInView?.value; 28445 } 28446 return filterInView?.value?.includes(element.value); 28447 }); 28448 } else if (Array.isArray(filterInView?.value)) { 28449 const label = filterInView.value.map((v2) => { 28450 const formattedValue = field?.getValueFormatted({ 28451 item: { [field.id]: v2 }, 28452 field 28453 }); 28454 return formattedValue || String(v2); 28455 }); 28456 activeElements = [ 28457 { 28458 value: filterInView.value, 28459 // @ts-ignore 28460 label 28461 } 28462 ]; 28463 } else if (typeof filterInView?.value === "object") { 28464 activeElements = [ 28465 { value: filterInView.value, label: filterInView.value } 28466 ]; 28467 } else if (filterInView?.value !== void 0) { 28468 const label = field !== void 0 ? field.getValueFormatted({ 28469 item: { [field.id]: filterInView.value }, 28470 field 28471 }) : String(filterInView.value); 28472 activeElements = [ 28473 { 28474 value: filterInView.value, 28475 label 28476 } 28477 ]; 28478 } 28479 const isPrimary = filter.isPrimary; 28480 const isLocked = filterInView?.isLocked; 28481 const hasValues = !isLocked && filterInView?.value !== void 0; 28482 const canResetOrRemove = !isLocked && (!isPrimary || hasValues); 28483 const resetOrRemoveLabel = isPrimary ? (0, import_i18n30.__)("Reset") : (0, import_i18n30.__)("Remove"); 28484 return /* @__PURE__ */ (0, import_jsx_runtime126.jsx)( 28485 import_components23.Dropdown, 28486 { 28487 defaultOpen: openedFilter === filter.field, 28488 contentClassName: "dataviews-filters__summary-popover", 28489 popoverProps: { placement: "bottom-start", role: "dialog" }, 28490 onClose: () => { 28491 toggleRef.current?.focus(); 28492 }, 28493 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime126.jsxs)("div", { className: "dataviews-filters__summary-chip-container", children: [ 28494 /* @__PURE__ */ (0, import_jsx_runtime126.jsxs)(tooltip_exports.Root, { children: [ 28495 /* @__PURE__ */ (0, import_jsx_runtime126.jsx)( 28496 tooltip_exports.Trigger, 28497 { 28498 render: /* @__PURE__ */ (0, import_jsx_runtime126.jsx)( 28499 "div", 28500 { 28501 className: clsx_default( 28502 "dataviews-filters__summary-chip", 28503 { 28504 "has-reset": canResetOrRemove, 28505 "has-values": hasValues, 28506 "is-not-clickable": isLocked 28507 } 28508 ), 28509 role: "button", 28510 tabIndex: isLocked ? -1 : 0, 28511 onClick: () => { 28512 if (!isLocked) { 28513 onToggle(); 28514 } 28515 }, 28516 onKeyDown: (event) => { 28517 if (!isLocked && [ENTER, SPACE].includes( 28518 event.key 28519 )) { 28520 onToggle(); 28521 event.preventDefault(); 28522 } 28523 }, 28524 "aria-disabled": isLocked, 28525 "aria-pressed": isOpen, 28526 "aria-expanded": isOpen, 28527 ref: toggleRef, 28528 children: /* @__PURE__ */ (0, import_jsx_runtime126.jsx)( 28529 FilterText, 28530 { 28531 activeElements, 28532 filterInView, 28533 filter 28534 } 28535 ) 28536 } 28537 ) 28538 } 28539 ), 28540 /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(tooltip_exports.Popup, { children: (0, import_i18n30.sprintf)( 28541 /* translators: 1: Filter name. */ 28542 (0, import_i18n30.__)("Filter by: %1$s"), 28543 filter.name.toLowerCase() 28544 ) }) 28545 ] }), 28546 canResetOrRemove && /* @__PURE__ */ (0, import_jsx_runtime126.jsxs)(tooltip_exports.Root, { children: [ 28547 /* @__PURE__ */ (0, import_jsx_runtime126.jsx)( 28548 tooltip_exports.Trigger, 28549 { 28550 render: /* @__PURE__ */ (0, import_jsx_runtime126.jsx)( 28551 "button", 28552 { 28553 className: clsx_default( 28554 "dataviews-filters__summary-chip-remove", 28555 { "has-values": hasValues } 28556 ), 28557 "aria-label": resetOrRemoveLabel, 28558 onClick: () => { 28559 onChangeView({ 28560 ...view, 28561 page: 1, 28562 filters: view.filters?.filter( 28563 (_filter) => _filter.field !== filter.field 28564 ) 28565 }); 28566 if (!isPrimary) { 28567 addFilterRef.current?.focus(); 28568 } else { 28569 toggleRef.current?.focus(); 28570 } 28571 }, 28572 children: /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(import_components23.Icon, { icon: close_small_default }) 28573 } 28574 ) 28575 } 28576 ), 28577 /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(tooltip_exports.Popup, { children: resetOrRemoveLabel }) 28578 ] }) 28579 ] }), 28580 renderContent: () => { 28581 return /* @__PURE__ */ (0, import_jsx_runtime126.jsxs)(Stack, { direction: "column", justify: "flex-start", children: [ 28582 /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(OperatorSelector, { ...commonProps }), 28583 commonProps.filter.hasElements ? /* @__PURE__ */ (0, import_jsx_runtime126.jsx)( 28584 SearchWidget, 28585 { 28586 ...commonProps, 28587 filter: { 28588 ...commonProps.filter, 28589 elements 28590 } 28591 } 28592 ) : /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(InputWidget, { ...commonProps, fields }) 28593 ] }); 28594 } 28595 } 28596 ); 28597 } 28598 28599 // packages/dataviews/build-module/components/dataviews-filters/add-filter.mjs 28600 var import_components24 = __toESM(require_components(), 1); 28601 var import_i18n31 = __toESM(require_i18n(), 1); 28602 var import_element87 = __toESM(require_element(), 1); 28603 var import_jsx_runtime127 = __toESM(require_jsx_runtime(), 1); 28604 var { Menu: Menu4 } = unlock3(import_components24.privateApis); 28605 function AddFilterMenu({ 28606 filters, 28607 view, 28608 onChangeView, 28609 setOpenedFilter, 28610 triggerProps 28611 }) { 28612 const inactiveFilters = filters.filter((filter) => !filter.isVisible); 28613 return /* @__PURE__ */ (0, import_jsx_runtime127.jsxs)(Menu4, { children: [ 28614 /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(Menu4.TriggerButton, { ...triggerProps }), 28615 /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(Menu4.Popover, { children: inactiveFilters.map((filter) => { 28616 return /* @__PURE__ */ (0, import_jsx_runtime127.jsx)( 28617 Menu4.Item, 28618 { 28619 onClick: () => { 28620 setOpenedFilter(filter.field); 28621 onChangeView({ 28622 ...view, 28623 page: 1, 28624 filters: [ 28625 ...view.filters || [], 28626 { 28627 field: filter.field, 28628 value: void 0, 28629 operator: filter.operators[0] 28630 } 28631 ] 28632 }); 28633 }, 28634 children: /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(Menu4.ItemLabel, { children: filter.name }) 28635 }, 28636 filter.field 28637 ); 28638 }) }) 28639 ] }); 28640 } 28641 function AddFilter({ filters, view, onChangeView, setOpenedFilter }, ref) { 28642 if (!filters.length || filters.every(({ isPrimary }) => isPrimary)) { 28643 return null; 28644 } 28645 const inactiveFilters = filters.filter((filter) => !filter.isVisible); 28646 return /* @__PURE__ */ (0, import_jsx_runtime127.jsx)( 28647 AddFilterMenu, 28648 { 28649 triggerProps: { 28650 render: /* @__PURE__ */ (0, import_jsx_runtime127.jsx)( 28651 import_components24.Button, 28652 { 28653 accessibleWhenDisabled: true, 28654 size: "compact", 28655 className: "dataviews-filters-button", 28656 variant: "tertiary", 28657 disabled: !inactiveFilters.length, 28658 ref 28659 } 28660 ), 28661 children: (0, import_i18n31.__)("Add filter") 28662 }, 28663 ...{ filters, view, onChangeView, setOpenedFilter } 28664 } 28665 ); 28666 } 28667 var add_filter_default = (0, import_element87.forwardRef)(AddFilter); 28668 28669 // packages/dataviews/build-module/components/dataviews-filters/reset-filters.mjs 28670 var import_components25 = __toESM(require_components(), 1); 28671 var import_i18n32 = __toESM(require_i18n(), 1); 28672 var import_jsx_runtime128 = __toESM(require_jsx_runtime(), 1); 28673 function ResetFilter({ 28674 filters, 28675 view, 28676 onChangeView 28677 }) { 28678 const isPrimary = (field) => filters.some( 28679 (_filter) => _filter.field === field && _filter.isPrimary 28680 ); 28681 const isDisabled = !view.search && !view.filters?.some( 28682 (_filter) => !_filter.isLocked && (_filter.value !== void 0 || !isPrimary(_filter.field)) 28683 ); 28684 return /* @__PURE__ */ (0, import_jsx_runtime128.jsx)( 28685 import_components25.Button, 28686 { 28687 disabled: isDisabled, 28688 accessibleWhenDisabled: true, 28689 size: "compact", 28690 variant: "tertiary", 28691 className: "dataviews-filters__reset-button", 28692 onClick: () => { 28693 onChangeView({ 28694 ...view, 28695 page: 1, 28696 search: "", 28697 filters: view.filters?.filter((f2) => !!f2.isLocked) || [] 28698 }); 28699 }, 28700 children: (0, import_i18n32.__)("Reset") 28701 } 28702 ); 28703 } 28704 28705 // packages/dataviews/build-module/components/dataviews-filters/use-filters.mjs 28706 var import_element88 = __toESM(require_element(), 1); 28707 function useFilters(fields, view) { 28708 return (0, import_element88.useMemo)(() => { 28709 const filters = []; 28710 fields.forEach((field) => { 28711 if (field.filterBy === false || !field.hasElements && !field.Edit) { 28712 return; 28713 } 28714 const operators = field.filterBy.operators; 28715 const isPrimary = !!field.filterBy?.isPrimary; 28716 const isLocked = view.filters?.some( 28717 (f2) => f2.field === field.id && !!f2.isLocked 28718 ) ?? false; 28719 filters.push({ 28720 field: field.id, 28721 name: field.label, 28722 elements: field.elements, 28723 getElements: field.getElements, 28724 hasElements: field.hasElements, 28725 singleSelection: operators.some( 28726 (op) => isSingleSelectionOperator(op) 28727 ), 28728 operators, 28729 isVisible: isLocked || isPrimary || !!view.filters?.some( 28730 (f2) => f2.field === field.id && isRegisteredOperator(f2.operator) 28731 ), 28732 isPrimary, 28733 isLocked 28734 }); 28735 }); 28736 filters.sort((a2, b2) => { 28737 if (a2.isLocked && !b2.isLocked) { 28738 return -1; 28739 } 28740 if (!a2.isLocked && b2.isLocked) { 28741 return 1; 28742 } 28743 if (a2.isPrimary && !b2.isPrimary) { 28744 return -1; 28745 } 28746 if (!a2.isPrimary && b2.isPrimary) { 28747 return 1; 28748 } 28749 return a2.name.localeCompare(b2.name); 28750 }); 28751 return filters; 28752 }, [fields, view]); 28753 } 28754 var use_filters_default = useFilters; 28755 28756 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs 28757 var import_jsx_runtime129 = __toESM(require_jsx_runtime(), 1); 28758 function Filters({ className }) { 28759 const { fields, view, onChangeView, openedFilter, setOpenedFilter } = (0, import_element89.useContext)(dataviews_context_default); 28760 const addFilterRef = (0, import_element89.useRef)(null); 28761 const filters = use_filters_default(fields, view); 28762 const addFilter = /* @__PURE__ */ (0, import_jsx_runtime129.jsx)( 28763 add_filter_default, 28764 { 28765 filters, 28766 view, 28767 onChangeView, 28768 ref: addFilterRef, 28769 setOpenedFilter 28770 }, 28771 "add-filter" 28772 ); 28773 const visibleFilters = filters.filter((filter) => filter.isVisible); 28774 if (visibleFilters.length === 0) { 28775 return null; 28776 } 28777 const filterComponents = [ 28778 ...visibleFilters.map((filter) => { 28779 return /* @__PURE__ */ (0, import_jsx_runtime129.jsx)( 28780 Filter, 28781 { 28782 filter, 28783 view, 28784 fields, 28785 onChangeView, 28786 addFilterRef, 28787 openedFilter 28788 }, 28789 filter.field 28790 ); 28791 }), 28792 addFilter 28793 ]; 28794 filterComponents.push( 28795 /* @__PURE__ */ (0, import_jsx_runtime129.jsx)( 28796 ResetFilter, 28797 { 28798 filters, 28799 view, 28800 onChangeView 28801 }, 28802 "reset-filters" 28803 ) 28804 ); 28805 return /* @__PURE__ */ (0, import_jsx_runtime129.jsx)( 28806 Stack, 28807 { 28808 direction: "row", 28809 justify: "flex-start", 28810 gap: "sm", 28811 style: { width: "fit-content" }, 28812 wrap: "wrap", 28813 className, 28814 children: filterComponents 28815 } 28816 ); 28817 } 28818 var filters_default = (0, import_element89.memo)(Filters); 28819 28820 // packages/dataviews/build-module/components/dataviews-filters/toggle.mjs 28821 var import_element90 = __toESM(require_element(), 1); 28822 var import_components26 = __toESM(require_components(), 1); 28823 var import_i18n33 = __toESM(require_i18n(), 1); 28824 var import_jsx_runtime130 = __toESM(require_jsx_runtime(), 1); 28825 function FiltersToggle() { 28826 const { 28827 filters, 28828 view, 28829 onChangeView, 28830 setOpenedFilter, 28831 isShowingFilter, 28832 setIsShowingFilter 28833 } = (0, import_element90.useContext)(dataviews_context_default); 28834 const buttonRef = (0, import_element90.useRef)(null); 28835 const onChangeViewWithFilterVisibility = (0, import_element90.useCallback)( 28836 (_view) => { 28837 onChangeView(_view); 28838 setIsShowingFilter(true); 28839 }, 28840 [onChangeView, setIsShowingFilter] 28841 ); 28842 if (filters.length === 0) { 28843 return null; 28844 } 28845 const hasVisibleFilters = filters.some((filter) => filter.isVisible); 28846 const addFilterButtonProps = { 28847 label: (0, import_i18n33.__)("Add filter"), 28848 "aria-expanded": false, 28849 isPressed: false 28850 }; 28851 const toggleFiltersButtonProps = { 28852 label: (0, import_i18n33._x)("Filter", "verb"), 28853 "aria-expanded": isShowingFilter, 28854 isPressed: isShowingFilter, 28855 onClick: () => { 28856 if (!isShowingFilter) { 28857 setOpenedFilter(null); 28858 } 28859 setIsShowingFilter(!isShowingFilter); 28860 } 28861 }; 28862 const hasPrimaryOrLockedFilters = filters.some( 28863 (filter) => filter.isPrimary || filter.isLocked 28864 ); 28865 const buttonComponent = /* @__PURE__ */ (0, import_jsx_runtime130.jsx)( 28866 import_components26.Button, 28867 { 28868 ref: buttonRef, 28869 className: "dataviews-filters__visibility-toggle", 28870 size: "compact", 28871 icon: funnel_default, 28872 disabled: hasPrimaryOrLockedFilters, 28873 accessibleWhenDisabled: true, 28874 ...hasVisibleFilters ? toggleFiltersButtonProps : addFilterButtonProps 28875 } 28876 ); 28877 return /* @__PURE__ */ (0, import_jsx_runtime130.jsx)("div", { className: "dataviews-filters__container-visibility-toggle", children: !hasVisibleFilters ? /* @__PURE__ */ (0, import_jsx_runtime130.jsx)( 28878 AddFilterMenu, 28879 { 28880 filters, 28881 view, 28882 onChangeView: onChangeViewWithFilterVisibility, 28883 setOpenedFilter, 28884 triggerProps: { render: buttonComponent } 28885 } 28886 ) : /* @__PURE__ */ (0, import_jsx_runtime130.jsx)( 28887 FilterVisibilityToggle, 28888 { 28889 buttonRef, 28890 filtersCount: view.filters?.length, 28891 children: buttonComponent 28892 } 28893 ) }); 28894 } 28895 function FilterVisibilityToggle({ 28896 buttonRef, 28897 filtersCount, 28898 children 28899 }) { 28900 (0, import_element90.useEffect)( 28901 () => () => { 28902 buttonRef.current?.focus(); 28903 }, 28904 [buttonRef] 28905 ); 28906 return /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(import_jsx_runtime130.Fragment, { children: [ 28907 children, 28908 !!filtersCount && /* @__PURE__ */ (0, import_jsx_runtime130.jsx)("span", { className: "dataviews-filters-toggle__count", children: filtersCount }) 28909 ] }); 28910 } 28911 var toggle_default = FiltersToggle; 28912 28913 // packages/dataviews/build-module/components/dataviews-filters/filters-toggled.mjs 28914 var import_element91 = __toESM(require_element(), 1); 28915 var import_jsx_runtime131 = __toESM(require_jsx_runtime(), 1); 28916 function FiltersToggled(props) { 28917 const { isShowingFilter } = (0, import_element91.useContext)(dataviews_context_default); 28918 if (!isShowingFilter) { 28919 return null; 28920 } 28921 return /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(filters_default, { ...props }); 28922 } 28923 var filters_toggled_default = FiltersToggled; 28924 28925 // packages/dataviews/build-module/components/dataviews-layout/index.mjs 28926 var import_element92 = __toESM(require_element(), 1); 28927 var import_components27 = __toESM(require_components(), 1); 28928 var import_i18n34 = __toESM(require_i18n(), 1); 28929 var import_jsx_runtime132 = __toESM(require_jsx_runtime(), 1); 28930 function DataViewsLayout({ className }) { 28931 const { 28932 actions = [], 28933 data, 28934 fields, 28935 getItemId, 28936 getItemLevel, 28937 hasInitiallyLoaded, 28938 isLoading, 28939 view, 28940 onChangeView, 28941 selection, 28942 onChangeSelection, 28943 setOpenedFilter, 28944 onClickItem, 28945 isItemClickable, 28946 renderItemLink, 28947 defaultLayouts: defaultLayouts3, 28948 containerRef, 28949 empty = /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("p", { children: (0, import_i18n34.__)("No results") }) 28950 } = (0, import_element92.useContext)(dataviews_context_default); 28951 const isDelayedInitialLoading = useDelayedLoading(!hasInitiallyLoaded, { 28952 delay: 200 28953 }); 28954 if (!hasInitiallyLoaded) { 28955 if (!isDelayedInitialLoading) { 28956 return null; 28957 } 28958 return /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("div", { className: "dataviews-loading", children: /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(import_components27.Spinner, {}) }) }); 28959 } 28960 const ViewComponent = VIEW_LAYOUTS.find( 28961 (v2) => v2.type === view.type && defaultLayouts3[v2.type] 28962 )?.component; 28963 return /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("div", { className: "dataviews-layout__container", ref: containerRef, children: /* @__PURE__ */ (0, import_jsx_runtime132.jsx)( 28964 ViewComponent, 28965 { 28966 className, 28967 actions, 28968 data, 28969 fields, 28970 getItemId, 28971 getItemLevel, 28972 isLoading, 28973 onChangeView, 28974 onChangeSelection, 28975 selection, 28976 setOpenedFilter, 28977 onClickItem, 28978 renderItemLink, 28979 isItemClickable, 28980 view, 28981 empty 28982 } 28983 ) }); 28984 } 28985 28986 // packages/dataviews/build-module/components/dataviews-footer/index.mjs 28987 var import_element93 = __toESM(require_element(), 1); 28988 var import_jsx_runtime133 = __toESM(require_jsx_runtime(), 1); 28989 var EMPTY_ARRAY5 = []; 28990 function DataViewsFooter() { 28991 const { 28992 view, 28993 paginationInfo: { totalItems = 0, totalPages }, 28994 data, 28995 actions = EMPTY_ARRAY5, 28996 isLoading, 28997 hasInitiallyLoaded 28998 } = (0, import_element93.useContext)(dataviews_context_default); 28999 const isRefreshing = !!isLoading && hasInitiallyLoaded && !!data?.length; 29000 const isDelayedRefreshing = useDelayedLoading(!!isRefreshing); 29001 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data) && [LAYOUT_TABLE, LAYOUT_GRID].includes(view.type); 29002 const hasPagination = hasPaginationControls(view, { 29003 totalItems, 29004 totalPages 29005 }); 29006 if (!totalItems || !hasBulkActions && !hasPagination) { 29007 return null; 29008 } 29009 return /* @__PURE__ */ (0, import_jsx_runtime133.jsx)( 29010 "div", 29011 { 29012 className: "dataviews-footer", 29013 inert: isRefreshing ? "true" : void 0, 29014 children: /* @__PURE__ */ (0, import_jsx_runtime133.jsxs)( 29015 Stack, 29016 { 29017 direction: "row", 29018 justify: "end", 29019 align: "center", 29020 className: clsx_default("dataviews-footer__content", { 29021 "is-refreshing": isDelayedRefreshing 29022 }), 29023 gap: "sm", 29024 children: [ 29025 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(BulkActionsFooter, {}), 29026 /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(dataviews_pagination_default, {}) 29027 ] 29028 } 29029 ) 29030 } 29031 ); 29032 } 29033 29034 // packages/dataviews/build-module/components/dataviews-search/index.mjs 29035 var import_i18n35 = __toESM(require_i18n(), 1); 29036 var import_element94 = __toESM(require_element(), 1); 29037 var import_components28 = __toESM(require_components(), 1); 29038 var import_compose12 = __toESM(require_compose(), 1); 29039 var import_jsx_runtime134 = __toESM(require_jsx_runtime(), 1); 29040 var DataViewsSearch = (0, import_element94.memo)(function Search({ label }) { 29041 const { view, onChangeView } = (0, import_element94.useContext)(dataviews_context_default); 29042 const [search, setSearch, debouncedSearch] = (0, import_compose12.useDebouncedInput)( 29043 view.search 29044 ); 29045 (0, import_element94.useEffect)(() => { 29046 if (view.search !== debouncedSearch) { 29047 setSearch(view.search ?? ""); 29048 } 29049 }, [view.search, setSearch]); 29050 const onChangeViewRef = (0, import_element94.useRef)(onChangeView); 29051 const viewRef = (0, import_element94.useRef)(view); 29052 (0, import_element94.useEffect)(() => { 29053 onChangeViewRef.current = onChangeView; 29054 viewRef.current = view; 29055 }, [onChangeView, view]); 29056 (0, import_element94.useEffect)(() => { 29057 if (debouncedSearch !== viewRef.current?.search) { 29058 onChangeViewRef.current({ 29059 ...viewRef.current, 29060 page: view.page ? 1 : void 0, 29061 startPosition: view.startPosition ? 1 : void 0, 29062 search: debouncedSearch 29063 }); 29064 } 29065 }, [debouncedSearch]); 29066 const searchLabel = label || (0, import_i18n35.__)("Search"); 29067 return /* @__PURE__ */ (0, import_jsx_runtime134.jsx)( 29068 import_components28.SearchControl, 29069 { 29070 className: "dataviews-search", 29071 onChange: setSearch, 29072 value: search, 29073 label: searchLabel, 29074 placeholder: searchLabel, 29075 size: "compact" 29076 } 29077 ); 29078 }); 29079 var dataviews_search_default = DataViewsSearch; 29080 29081 // packages/dataviews/build-module/components/dataviews-view-config/index.mjs 29082 var import_components29 = __toESM(require_components(), 1); 29083 var import_i18n36 = __toESM(require_i18n(), 1); 29084 var import_element95 = __toESM(require_element(), 1); 29085 var import_warning = __toESM(require_warning(), 1); 29086 var import_compose13 = __toESM(require_compose(), 1); 29087 var import_jsx_runtime135 = __toESM(require_jsx_runtime(), 1); 29088 var { Menu: Menu5 } = unlock3(import_components29.privateApis); 29089 var DATAVIEWS_CONFIG_POPOVER_PROPS = { 29090 className: "dataviews-config__popover", 29091 placement: "bottom-end", 29092 offset: 9 29093 }; 29094 function ViewTypeMenu() { 29095 const { view, onChangeView, defaultLayouts: defaultLayouts3 } = (0, import_element95.useContext)(dataviews_context_default); 29096 const availableLayouts = Object.keys(defaultLayouts3); 29097 if (availableLayouts.length <= 1) { 29098 return null; 29099 } 29100 const activeView = VIEW_LAYOUTS.find((v2) => view.type === v2.type); 29101 return /* @__PURE__ */ (0, import_jsx_runtime135.jsxs)(Menu5, { children: [ 29102 /* @__PURE__ */ (0, import_jsx_runtime135.jsx)( 29103 Menu5.TriggerButton, 29104 { 29105 render: /* @__PURE__ */ (0, import_jsx_runtime135.jsx)( 29106 import_components29.Button, 29107 { 29108 size: "compact", 29109 icon: activeView?.icon, 29110 label: (0, import_i18n36.__)("Layout") 29111 } 29112 ) 29113 } 29114 ), 29115 /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(Menu5.Popover, { children: availableLayouts.map((layout) => { 29116 const config = VIEW_LAYOUTS.find( 29117 (v2) => v2.type === layout 29118 ); 29119 if (!config) { 29120 return null; 29121 } 29122 return /* @__PURE__ */ (0, import_jsx_runtime135.jsx)( 29123 Menu5.RadioItem, 29124 { 29125 value: layout, 29126 name: "view-actions-available-view", 29127 checked: layout === view.type, 29128 hideOnClick: true, 29129 onChange: (e2) => { 29130 switch (e2.target.value) { 29131 case "list": 29132 case "grid": 29133 case "table": 29134 case "pickerGrid": 29135 case "pickerTable": 29136 case "pickerActivity": 29137 case "activity": 29138 const viewWithoutLayout = { ...view }; 29139 if ("layout" in viewWithoutLayout) { 29140 delete viewWithoutLayout.layout; 29141 } 29142 return onChangeView({ 29143 ...viewWithoutLayout, 29144 type: e2.target.value, 29145 ...defaultLayouts3[e2.target.value] 29146 }); 29147 } 29148 (0, import_warning.default)("Invalid dataview"); 29149 }, 29150 children: /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(Menu5.ItemLabel, { children: config.label }) 29151 }, 29152 layout 29153 ); 29154 }) }) 29155 ] }); 29156 } 29157 function SortFieldControl() { 29158 const { view, fields, onChangeView } = (0, import_element95.useContext)(dataviews_context_default); 29159 const orderOptions = (0, import_element95.useMemo)(() => { 29160 const sortableFields = fields.filter( 29161 (field) => field.enableSorting !== false 29162 ); 29163 return sortableFields.map((field) => { 29164 return { 29165 label: field.label, 29166 value: field.id 29167 }; 29168 }); 29169 }, [fields]); 29170 return /* @__PURE__ */ (0, import_jsx_runtime135.jsx)( 29171 import_components29.SelectControl, 29172 { 29173 label: (0, import_i18n36.__)("Sort by"), 29174 value: view.sort?.field, 29175 options: orderOptions, 29176 onChange: (value) => { 29177 onChangeView({ 29178 ...view, 29179 sort: { 29180 direction: view?.sort?.direction || "desc", 29181 field: value 29182 }, 29183 showLevels: false 29184 }); 29185 } 29186 } 29187 ); 29188 } 29189 function SortDirectionControl() { 29190 const { view, fields, onChangeView } = (0, import_element95.useContext)(dataviews_context_default); 29191 const sortableFields = fields.filter( 29192 (field) => field.enableSorting !== false 29193 ); 29194 if (sortableFields.length === 0) { 29195 return null; 29196 } 29197 let value = view.sort?.direction; 29198 if (!value && view.sort?.field) { 29199 value = "desc"; 29200 } 29201 return /* @__PURE__ */ (0, import_jsx_runtime135.jsx)( 29202 import_components29.__experimentalToggleGroupControl, 29203 { 29204 className: "dataviews-view-config__sort-direction", 29205 isBlock: true, 29206 label: (0, import_i18n36.__)("Order"), 29207 value, 29208 onChange: (newDirection) => { 29209 if (newDirection === "asc" || newDirection === "desc") { 29210 onChangeView({ 29211 ...view, 29212 sort: { 29213 direction: newDirection, 29214 field: view.sort?.field || // If there is no field assigned as the sorting field assign the first sortable field. 29215 fields.find( 29216 (field) => field.enableSorting !== false 29217 )?.id || "" 29218 }, 29219 showLevels: false 29220 }); 29221 return; 29222 } 29223 (0, import_warning.default)("Invalid direction"); 29224 }, 29225 children: SORTING_DIRECTIONS.map((direction) => { 29226 return /* @__PURE__ */ (0, import_jsx_runtime135.jsx)( 29227 import_components29.__experimentalToggleGroupControlOptionIcon, 29228 { 29229 value: direction, 29230 icon: sortIcons[direction], 29231 label: sortLabels[direction] 29232 }, 29233 direction 29234 ); 29235 }) 29236 } 29237 ); 29238 } 29239 function ItemsPerPageControl() { 29240 const { view, config, onChangeView } = (0, import_element95.useContext)(dataviews_context_default); 29241 const { infiniteScrollEnabled } = view; 29242 if (!config || !config.perPageSizes || config.perPageSizes.length < 2 || config.perPageSizes.length > 6 || infiniteScrollEnabled) { 29243 return null; 29244 } 29245 return /* @__PURE__ */ (0, import_jsx_runtime135.jsx)( 29246 import_components29.__experimentalToggleGroupControl, 29247 { 29248 isBlock: true, 29249 label: (0, import_i18n36.__)("Items per page"), 29250 value: view.perPage || 10, 29251 disabled: !view?.sort?.field, 29252 onChange: (newItemsPerPage) => { 29253 const newItemsPerPageNumber = typeof newItemsPerPage === "number" || newItemsPerPage === void 0 ? newItemsPerPage : parseInt(newItemsPerPage, 10); 29254 onChangeView({ 29255 ...view, 29256 perPage: newItemsPerPageNumber, 29257 page: 1 29258 }); 29259 }, 29260 children: config.perPageSizes.map((value) => { 29261 return /* @__PURE__ */ (0, import_jsx_runtime135.jsx)( 29262 import_components29.__experimentalToggleGroupControlOption, 29263 { 29264 value, 29265 label: value.toString() 29266 }, 29267 value 29268 ); 29269 }) 29270 } 29271 ); 29272 } 29273 function ResetViewButton() { 29274 const { onReset } = (0, import_element95.useContext)(dataviews_context_default); 29275 if (onReset === void 0) { 29276 return null; 29277 } 29278 const isDisabled = onReset === false; 29279 return /* @__PURE__ */ (0, import_jsx_runtime135.jsx)( 29280 import_components29.Button, 29281 { 29282 variant: "tertiary", 29283 size: "compact", 29284 disabled: isDisabled, 29285 accessibleWhenDisabled: true, 29286 className: "dataviews-view-config__reset-button", 29287 onClick: () => { 29288 if (typeof onReset === "function") { 29289 onReset(); 29290 } 29291 }, 29292 children: (0, import_i18n36.__)("Reset view") 29293 } 29294 ); 29295 } 29296 function DataviewsViewConfigDropdown() { 29297 const { view, onReset } = (0, import_element95.useContext)(dataviews_context_default); 29298 const popoverId = (0, import_compose13.useInstanceId)( 29299 _DataViewsViewConfig, 29300 "dataviews-view-config-dropdown" 29301 ); 29302 const activeLayout = VIEW_LAYOUTS.find( 29303 (layout) => layout.type === view.type 29304 ); 29305 const isModified = typeof onReset === "function"; 29306 return /* @__PURE__ */ (0, import_jsx_runtime135.jsx)( 29307 import_components29.Dropdown, 29308 { 29309 expandOnMobile: true, 29310 popoverProps: { 29311 ...DATAVIEWS_CONFIG_POPOVER_PROPS, 29312 id: popoverId 29313 }, 29314 renderToggle: ({ onToggle, isOpen }) => { 29315 return /* @__PURE__ */ (0, import_jsx_runtime135.jsxs)("div", { className: "dataviews-view-config__toggle-wrapper", children: [ 29316 /* @__PURE__ */ (0, import_jsx_runtime135.jsx)( 29317 import_components29.Button, 29318 { 29319 size: "compact", 29320 icon: cog_default, 29321 label: (0, import_i18n36._x)( 29322 "View options", 29323 "View is used as a noun" 29324 ), 29325 onClick: onToggle, 29326 "aria-expanded": isOpen ? "true" : "false", 29327 "aria-controls": popoverId 29328 } 29329 ), 29330 isModified && /* @__PURE__ */ (0, import_jsx_runtime135.jsx)("span", { className: "dataviews-view-config__modified-indicator" }) 29331 ] }); 29332 }, 29333 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime135.jsx)( 29334 import_components29.__experimentalDropdownContentWrapper, 29335 { 29336 paddingSize: "medium", 29337 className: "dataviews-config__popover-content-wrapper", 29338 children: /* @__PURE__ */ (0, import_jsx_runtime135.jsxs)( 29339 Stack, 29340 { 29341 direction: "column", 29342 className: "dataviews-view-config", 29343 gap: "xl", 29344 children: [ 29345 /* @__PURE__ */ (0, import_jsx_runtime135.jsxs)( 29346 Stack, 29347 { 29348 direction: "row", 29349 justify: "space-between", 29350 align: "center", 29351 className: "dataviews-view-config__header", 29352 children: [ 29353 /* @__PURE__ */ (0, import_jsx_runtime135.jsx)( 29354 import_components29.__experimentalHeading, 29355 { 29356 level: 2, 29357 className: "dataviews-settings-section__title", 29358 children: (0, import_i18n36.__)("Appearance") 29359 } 29360 ), 29361 /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(ResetViewButton, {}) 29362 ] 29363 } 29364 ), 29365 /* @__PURE__ */ (0, import_jsx_runtime135.jsxs)(Stack, { direction: "column", gap: "lg", children: [ 29366 /* @__PURE__ */ (0, import_jsx_runtime135.jsxs)( 29367 Stack, 29368 { 29369 direction: "row", 29370 gap: "sm", 29371 className: "dataviews-view-config__sort-controls", 29372 children: [ 29373 /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(SortFieldControl, {}), 29374 /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(SortDirectionControl, {}) 29375 ] 29376 } 29377 ), 29378 !!activeLayout?.viewConfigOptions && /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(activeLayout.viewConfigOptions, {}), 29379 /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(ItemsPerPageControl, {}), 29380 /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(PropertiesSection, {}) 29381 ] }) 29382 ] 29383 } 29384 ) 29385 } 29386 ) 29387 } 29388 ); 29389 } 29390 function _DataViewsViewConfig() { 29391 return /* @__PURE__ */ (0, import_jsx_runtime135.jsxs)(import_jsx_runtime135.Fragment, { children: [ 29392 /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(ViewTypeMenu, {}), 29393 /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(DataviewsViewConfigDropdown, {}) 29394 ] }); 29395 } 29396 var DataViewsViewConfig = (0, import_element95.memo)(_DataViewsViewConfig); 29397 var dataviews_view_config_default = DataViewsViewConfig; 29398 29399 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs 29400 var import_components30 = __toESM(require_components(), 1); 29401 var import_element96 = __toESM(require_element(), 1); 29402 29403 // packages/dataviews/build-module/components/dataform-controls/utils/get-custom-validity.mjs 29404 function getCustomValidity(isValid2, validity) { 29405 let customValidity; 29406 if (isValid2?.required && validity?.required) { 29407 customValidity = validity?.required?.message ? validity.required : void 0; 29408 } else if (isValid2?.pattern && validity?.pattern) { 29409 customValidity = validity.pattern; 29410 } else if (isValid2?.min && validity?.min) { 29411 customValidity = validity.min; 29412 } else if (isValid2?.max && validity?.max) { 29413 customValidity = validity.max; 29414 } else if (isValid2?.minLength && validity?.minLength) { 29415 customValidity = validity.minLength; 29416 } else if (isValid2?.maxLength && validity?.maxLength) { 29417 customValidity = validity.maxLength; 29418 } else if (isValid2?.elements && validity?.elements) { 29419 customValidity = validity.elements; 29420 } else if (validity?.custom) { 29421 customValidity = validity.custom; 29422 } 29423 return customValidity; 29424 } 29425 29426 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs 29427 var import_jsx_runtime136 = __toESM(require_jsx_runtime(), 1); 29428 var { ValidatedCheckboxControl } = unlock3(import_components30.privateApis); 29429 function Checkbox({ 29430 field, 29431 onChange, 29432 data, 29433 hideLabelFromVision, 29434 markWhenOptional, 29435 validity 29436 }) { 29437 const { getValue, setValue, label, description, isValid: isValid2 } = field; 29438 const disabled2 = field.isDisabled({ item: data, field }); 29439 const onChangeControl = (0, import_element96.useCallback)(() => { 29440 onChange( 29441 setValue({ item: data, value: !getValue({ item: data }) }) 29442 ); 29443 }, [data, getValue, onChange, setValue]); 29444 return /* @__PURE__ */ (0, import_jsx_runtime136.jsx)( 29445 ValidatedCheckboxControl, 29446 { 29447 required: !!field.isValid?.required, 29448 markWhenOptional, 29449 customValidity: getCustomValidity(isValid2, validity), 29450 hidden: hideLabelFromVision, 29451 label, 29452 help: description, 29453 checked: getValue({ item: data }), 29454 onChange: onChangeControl, 29455 disabled: disabled2 29456 } 29457 ); 29458 } 29459 29460 // packages/dataviews/build-module/components/dataform-controls/combobox.mjs 29461 var import_components31 = __toESM(require_components(), 1); 29462 var import_element97 = __toESM(require_element(), 1); 29463 var import_jsx_runtime137 = __toESM(require_jsx_runtime(), 1); 29464 var { ValidatedComboboxControl } = unlock3(import_components31.privateApis); 29465 function Combobox3({ 29466 data, 29467 field, 29468 onChange, 29469 hideLabelFromVision, 29470 validity 29471 }) { 29472 const { label, description, placeholder, getValue, setValue, isValid: isValid2 } = field; 29473 const value = getValue({ item: data }) ?? ""; 29474 const onChangeControl = (0, import_element97.useCallback)( 29475 (newValue) => onChange(setValue({ item: data, value: newValue ?? "" })), 29476 [data, onChange, setValue] 29477 ); 29478 const { elements, isLoading } = useElements({ 29479 elements: field.elements, 29480 getElements: field.getElements 29481 }); 29482 if (isLoading) { 29483 return /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(import_components31.Spinner, {}); 29484 } 29485 return /* @__PURE__ */ (0, import_jsx_runtime137.jsx)( 29486 ValidatedComboboxControl, 29487 { 29488 required: !!field.isValid?.required, 29489 customValidity: getCustomValidity(isValid2, validity), 29490 label, 29491 value, 29492 help: description, 29493 placeholder, 29494 options: elements, 29495 onChange: onChangeControl, 29496 hideLabelFromVision, 29497 allowReset: true, 29498 expandOnFocus: true 29499 } 29500 ); 29501 } 29502 29503 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs 29504 var import_components33 = __toESM(require_components(), 1); 29505 var import_element100 = __toESM(require_element(), 1); 29506 var import_i18n38 = __toESM(require_i18n(), 1); 29507 var import_date3 = __toESM(require_date(), 1); 29508 29509 // packages/dataviews/build-module/components/dataform-controls/utils/relative-date-control.mjs 29510 var import_components32 = __toESM(require_components(), 1); 29511 var import_element98 = __toESM(require_element(), 1); 29512 var import_i18n37 = __toESM(require_i18n(), 1); 29513 var import_jsx_runtime138 = __toESM(require_jsx_runtime(), 1); 29514 var TIME_UNITS_OPTIONS = { 29515 [OPERATOR_IN_THE_PAST]: [ 29516 { value: "days", label: (0, import_i18n37.__)("Days") }, 29517 { value: "weeks", label: (0, import_i18n37.__)("Weeks") }, 29518 { value: "months", label: (0, import_i18n37.__)("Months") }, 29519 { value: "years", label: (0, import_i18n37.__)("Years") } 29520 ], 29521 [OPERATOR_OVER]: [ 29522 { value: "days", label: (0, import_i18n37.__)("Days ago") }, 29523 { value: "weeks", label: (0, import_i18n37.__)("Weeks ago") }, 29524 { value: "months", label: (0, import_i18n37.__)("Months ago") }, 29525 { value: "years", label: (0, import_i18n37.__)("Years ago") } 29526 ] 29527 }; 29528 function RelativeDateControl({ 29529 className, 29530 data, 29531 field, 29532 onChange, 29533 hideLabelFromVision, 29534 operator 29535 }) { 29536 const options = TIME_UNITS_OPTIONS[operator === OPERATOR_IN_THE_PAST ? "inThePast" : "over"]; 29537 const { id, label, description, getValue, setValue } = field; 29538 const disabled2 = field.isDisabled({ item: data, field }); 29539 const fieldValue = getValue({ item: data }); 29540 const { value: relValue = "", unit = options[0].value } = fieldValue && typeof fieldValue === "object" ? fieldValue : {}; 29541 const onChangeValue = (0, import_element98.useCallback)( 29542 (newValue) => onChange( 29543 setValue({ 29544 item: data, 29545 value: { value: Number(newValue), unit } 29546 }) 29547 ), 29548 [onChange, setValue, data, unit] 29549 ); 29550 const onChangeUnit = (0, import_element98.useCallback)( 29551 (newUnit) => onChange( 29552 setValue({ 29553 item: data, 29554 value: { value: relValue, unit: newUnit } 29555 }) 29556 ), 29557 [onChange, setValue, data, relValue] 29558 ); 29559 return /* @__PURE__ */ (0, import_jsx_runtime138.jsx)( 29560 import_components32.BaseControl, 29561 { 29562 id, 29563 className: clsx_default(className, "dataviews-controls__relative-date"), 29564 label, 29565 hideLabelFromVision, 29566 help: description, 29567 children: /* @__PURE__ */ (0, import_jsx_runtime138.jsxs)(Stack, { direction: "row", gap: "sm", children: [ 29568 /* @__PURE__ */ (0, import_jsx_runtime138.jsx)( 29569 import_components32.__experimentalNumberControl, 29570 { 29571 className: "dataviews-controls__relative-date-number", 29572 spinControls: "none", 29573 min: 1, 29574 step: 1, 29575 value: relValue, 29576 onChange: onChangeValue, 29577 disabled: disabled2 29578 } 29579 ), 29580 /* @__PURE__ */ (0, import_jsx_runtime138.jsx)( 29581 import_components32.SelectControl, 29582 { 29583 className: "dataviews-controls__relative-date-unit", 29584 label: (0, import_i18n37.__)("Unit"), 29585 value: unit, 29586 options, 29587 onChange: onChangeUnit, 29588 hideLabelFromVision: true, 29589 disabled: disabled2 29590 } 29591 ) 29592 ] }) 29593 } 29594 ); 29595 } 29596 29597 // packages/dataviews/build-module/components/dataform-controls/utils/use-disabled-date-matchers.mjs 29598 var import_element99 = __toESM(require_element(), 1); 29599 function useDisabledDateMatchers(isValid2, parseDateFn) { 29600 const minConstraint = typeof isValid2.min?.constraint === "string" ? isValid2.min.constraint : void 0; 29601 const maxConstraint = typeof isValid2.max?.constraint === "string" ? isValid2.max.constraint : void 0; 29602 const disabledMatchers = (0, import_element99.useMemo)(() => { 29603 const matchers = []; 29604 if (minConstraint) { 29605 const minDate = parseDateFn(minConstraint); 29606 if (minDate) { 29607 matchers.push({ before: minDate }); 29608 } 29609 } 29610 if (maxConstraint) { 29611 const maxDate = parseDateFn(maxConstraint); 29612 if (maxDate) { 29613 matchers.push({ after: maxDate }); 29614 } 29615 } 29616 return matchers.length > 0 ? matchers : void 0; 29617 }, [minConstraint, maxConstraint, parseDateFn]); 29618 return { minConstraint, maxConstraint, disabledMatchers }; 29619 } 29620 29621 // packages/dataviews/build-module/field-types/utils/parse-date-time.mjs 29622 var import_date2 = __toESM(require_date(), 1); 29623 function parseDateTime(dateTimeString) { 29624 if (!dateTimeString) { 29625 return null; 29626 } 29627 const parsed = (0, import_date2.getDate)(dateTimeString); 29628 return parsed && isValid(parsed) ? parsed : null; 29629 } 29630 29631 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs 29632 var import_jsx_runtime139 = __toESM(require_jsx_runtime(), 1); 29633 var { DateCalendar, ValidatedInputControl } = unlock3(import_components33.privateApis); 29634 var formatDateTime = (value) => { 29635 if (!value) { 29636 return ""; 29637 } 29638 return (0, import_date3.dateI18n)("Y-m-d\\TH:i", (0, import_date3.getDate)(value)); 29639 }; 29640 function CalendarDateTimeControl({ 29641 data, 29642 field, 29643 onChange, 29644 hideLabelFromVision, 29645 markWhenOptional, 29646 validity, 29647 config 29648 }) { 29649 const { compact } = config || {}; 29650 const { id, label, description, setValue, getValue, isValid: isValid2 } = field; 29651 const disabled2 = field.isDisabled({ item: data, field }); 29652 const fieldValue = getValue({ item: data }); 29653 const value = typeof fieldValue === "string" ? fieldValue : void 0; 29654 const [calendarMonth, setCalendarMonth] = (0, import_element100.useState)(() => { 29655 const parsedDate = parseDateTime(value); 29656 return parsedDate || /* @__PURE__ */ new Date(); 29657 }); 29658 const inputControlRef = (0, import_element100.useRef)(null); 29659 const validationTimeoutRef = (0, import_element100.useRef)(void 0); 29660 const previousFocusRef = (0, import_element100.useRef)(null); 29661 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDateTime); 29662 const onChangeCallback = (0, import_element100.useCallback)( 29663 (newValue) => onChange(setValue({ item: data, value: newValue })), 29664 [data, onChange, setValue] 29665 ); 29666 (0, import_element100.useEffect)(() => { 29667 return () => { 29668 if (validationTimeoutRef.current) { 29669 clearTimeout(validationTimeoutRef.current); 29670 } 29671 }; 29672 }, []); 29673 const onSelectDate = (0, import_element100.useCallback)( 29674 (newDate) => { 29675 let dateTimeValue; 29676 if (newDate) { 29677 const wpDate = (0, import_date3.dateI18n)("Y-m-d", newDate); 29678 let wpTime; 29679 if (value) { 29680 wpTime = (0, import_date3.dateI18n)("H:i", (0, import_date3.getDate)(value)); 29681 } else { 29682 wpTime = (0, import_date3.dateI18n)("H:i", newDate); 29683 } 29684 const finalDateTime = (0, import_date3.getDate)(`$wpDate}T$wpTime}`); 29685 dateTimeValue = finalDateTime.toISOString(); 29686 onChangeCallback(dateTimeValue); 29687 if (validationTimeoutRef.current) { 29688 clearTimeout(validationTimeoutRef.current); 29689 } 29690 } else { 29691 onChangeCallback(void 0); 29692 } 29693 previousFocusRef.current = inputControlRef.current && inputControlRef.current.ownerDocument.activeElement; 29694 validationTimeoutRef.current = setTimeout(() => { 29695 if (inputControlRef.current) { 29696 inputControlRef.current.focus(); 29697 inputControlRef.current.blur(); 29698 onChangeCallback(dateTimeValue); 29699 if (previousFocusRef.current && previousFocusRef.current instanceof HTMLElement) { 29700 previousFocusRef.current.focus(); 29701 } 29702 } 29703 }, 0); 29704 }, 29705 [onChangeCallback, value] 29706 ); 29707 const handleManualDateTimeChange = (0, import_element100.useCallback)( 29708 (newValue) => { 29709 if (newValue) { 29710 const dateTime = (0, import_date3.getDate)(newValue); 29711 onChangeCallback(dateTime.toISOString()); 29712 const parsedDate = parseDateTime(dateTime.toISOString()); 29713 if (parsedDate) { 29714 setCalendarMonth(parsedDate); 29715 } 29716 } else { 29717 onChangeCallback(void 0); 29718 } 29719 }, 29720 [onChangeCallback] 29721 ); 29722 const { format: fieldFormat } = field; 29723 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date3.getSettings)().l10n.startOfWeek; 29724 const { 29725 timezone: { string: timezoneString } 29726 } = (0, import_date3.getSettings)(); 29727 let displayLabel = label; 29728 if (isValid2?.required && !markWhenOptional && !hideLabelFromVision) { 29729 displayLabel = `$label} (${(0, import_i18n38.__)("Required")})`; 29730 } else if (!isValid2?.required && markWhenOptional && !hideLabelFromVision) { 29731 displayLabel = `$label} (${(0, import_i18n38.__)("Optional")})`; 29732 } 29733 return /* @__PURE__ */ (0, import_jsx_runtime139.jsx)( 29734 import_components33.BaseControl, 29735 { 29736 id, 29737 label: displayLabel, 29738 help: description, 29739 hideLabelFromVision, 29740 children: /* @__PURE__ */ (0, import_jsx_runtime139.jsxs)(Stack, { direction: "column", gap: "lg", children: [ 29741 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)( 29742 ValidatedInputControl, 29743 { 29744 ref: inputControlRef, 29745 required: !!isValid2?.required, 29746 customValidity: getCustomValidity(isValid2, validity), 29747 type: "datetime-local", 29748 label: (0, import_i18n38.__)("Date time"), 29749 hideLabelFromVision: true, 29750 value: formatDateTime(value), 29751 onChange: handleManualDateTimeChange, 29752 disabled: disabled2, 29753 min: minConstraint ? formatDateTime(minConstraint) : void 0, 29754 max: maxConstraint ? formatDateTime(maxConstraint) : void 0 29755 } 29756 ), 29757 !compact && /* @__PURE__ */ (0, import_jsx_runtime139.jsx)( 29758 DateCalendar, 29759 { 29760 style: { width: "100%" }, 29761 selected: value ? parseDateTime(value) || void 0 : void 0, 29762 onSelect: onSelectDate, 29763 month: calendarMonth, 29764 onMonthChange: setCalendarMonth, 29765 timeZone: timezoneString || void 0, 29766 weekStartsOn, 29767 disabled: disabled2 || disabledMatchers 29768 } 29769 ) 29770 ] }) 29771 } 29772 ); 29773 } 29774 function DateTime({ 29775 data, 29776 field, 29777 onChange, 29778 hideLabelFromVision, 29779 markWhenOptional, 29780 operator, 29781 validity, 29782 config 29783 }) { 29784 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) { 29785 return /* @__PURE__ */ (0, import_jsx_runtime139.jsx)( 29786 RelativeDateControl, 29787 { 29788 className: "dataviews-controls__datetime", 29789 data, 29790 field, 29791 onChange, 29792 hideLabelFromVision, 29793 operator 29794 } 29795 ); 29796 } 29797 return /* @__PURE__ */ (0, import_jsx_runtime139.jsx)( 29798 CalendarDateTimeControl, 29799 { 29800 data, 29801 field, 29802 onChange, 29803 hideLabelFromVision, 29804 markWhenOptional, 29805 validity, 29806 config 29807 } 29808 ); 29809 } 29810 29811 // packages/dataviews/build-module/components/dataform-controls/date.mjs 29812 var import_components34 = __toESM(require_components(), 1); 29813 var import_element101 = __toESM(require_element(), 1); 29814 var import_i18n39 = __toESM(require_i18n(), 1); 29815 var import_date4 = __toESM(require_date(), 1); 29816 import { speak as speak3 } from "@wordpress/a11y"; 29817 var import_jsx_runtime140 = __toESM(require_jsx_runtime(), 1); 29818 var { DateCalendar: DateCalendar2, DateRangeCalendar } = unlock3(import_components34.privateApis); 29819 var DATE_PRESETS = [ 29820 { 29821 id: "today", 29822 label: (0, import_i18n39.__)("Today"), 29823 getValue: () => (0, import_date4.getDate)(null) 29824 }, 29825 { 29826 id: "yesterday", 29827 label: (0, import_i18n39.__)("Yesterday"), 29828 getValue: () => { 29829 const today = (0, import_date4.getDate)(null); 29830 return subDays(today, 1); 29831 } 29832 }, 29833 { 29834 id: "past-week", 29835 label: (0, import_i18n39.__)("Past week"), 29836 getValue: () => { 29837 const today = (0, import_date4.getDate)(null); 29838 return subDays(today, 7); 29839 } 29840 }, 29841 { 29842 id: "past-month", 29843 label: (0, import_i18n39.__)("Past month"), 29844 getValue: () => { 29845 const today = (0, import_date4.getDate)(null); 29846 return subMonths(today, 1); 29847 } 29848 } 29849 ]; 29850 var DATE_RANGE_PRESETS = [ 29851 { 29852 id: "last-7-days", 29853 label: (0, import_i18n39.__)("Last 7 days"), 29854 getValue: () => { 29855 const today = (0, import_date4.getDate)(null); 29856 return [subDays(today, 7), today]; 29857 } 29858 }, 29859 { 29860 id: "last-30-days", 29861 label: (0, import_i18n39.__)("Last 30 days"), 29862 getValue: () => { 29863 const today = (0, import_date4.getDate)(null); 29864 return [subDays(today, 30), today]; 29865 } 29866 }, 29867 { 29868 id: "month-to-date", 29869 label: (0, import_i18n39.__)("Month to date"), 29870 getValue: () => { 29871 const today = (0, import_date4.getDate)(null); 29872 return [startOfMonth(today), today]; 29873 } 29874 }, 29875 { 29876 id: "last-year", 29877 label: (0, import_i18n39.__)("Last year"), 29878 getValue: () => { 29879 const today = (0, import_date4.getDate)(null); 29880 return [subYears(today, 1), today]; 29881 } 29882 }, 29883 { 29884 id: "year-to-date", 29885 label: (0, import_i18n39.__)("Year to date"), 29886 getValue: () => { 29887 const today = (0, import_date4.getDate)(null); 29888 return [startOfYear(today), today]; 29889 } 29890 } 29891 ]; 29892 var parseDate = (dateString) => { 29893 if (!dateString) { 29894 return null; 29895 } 29896 const parsed = (0, import_date4.getDate)(dateString); 29897 return parsed && isValid(parsed) ? parsed : null; 29898 }; 29899 var formatDate = (date) => { 29900 if (!date) { 29901 return ""; 29902 } 29903 return typeof date === "string" ? date : format(date, "yyyy-MM-dd"); 29904 }; 29905 function ValidatedDateControl({ 29906 field, 29907 validity, 29908 inputRefs, 29909 isTouched, 29910 setIsTouched, 29911 children 29912 }) { 29913 const { isValid: isValid2 } = field; 29914 const [customValidity, setCustomValidity] = (0, import_element101.useState)(void 0); 29915 const validateRefs = (0, import_element101.useCallback)(() => { 29916 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs]; 29917 for (const ref of refs) { 29918 const input = ref.current; 29919 if (input && !input.validity.valid) { 29920 setCustomValidity({ 29921 type: "invalid", 29922 message: input.validationMessage 29923 }); 29924 return; 29925 } 29926 } 29927 setCustomValidity(void 0); 29928 }, [inputRefs]); 29929 (0, import_element101.useEffect)(() => { 29930 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs]; 29931 const result = validity ? getCustomValidity(isValid2, validity) : void 0; 29932 for (const ref of refs) { 29933 const input = ref.current; 29934 if (input) { 29935 input.setCustomValidity( 29936 result?.type === "invalid" && result.message ? result.message : "" 29937 ); 29938 } 29939 } 29940 }, [inputRefs, isValid2, validity]); 29941 (0, import_element101.useEffect)(() => { 29942 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs]; 29943 const handleInvalid = (event) => { 29944 event.preventDefault(); 29945 setIsTouched(true); 29946 }; 29947 for (const ref of refs) { 29948 ref.current?.addEventListener("invalid", handleInvalid); 29949 } 29950 return () => { 29951 for (const ref of refs) { 29952 ref.current?.removeEventListener("invalid", handleInvalid); 29953 } 29954 }; 29955 }, [inputRefs, setIsTouched]); 29956 (0, import_element101.useEffect)(() => { 29957 if (!isTouched) { 29958 return; 29959 } 29960 const result = validity ? getCustomValidity(isValid2, validity) : void 0; 29961 if (result) { 29962 setCustomValidity(result); 29963 } else { 29964 validateRefs(); 29965 } 29966 }, [isTouched, isValid2, validity, validateRefs]); 29967 (0, import_element101.useEffect)(() => { 29968 if (isTouched && customValidity?.message) { 29969 speak3(customValidity.message); 29970 } 29971 }, [isTouched, customValidity?.message]); 29972 const onBlur = (event) => { 29973 if (isTouched) { 29974 return; 29975 } 29976 if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) { 29977 setIsTouched(true); 29978 } 29979 }; 29980 return /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)("div", { onBlur, children: [ 29981 children, 29982 customValidity && /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)( 29983 "p", 29984 { 29985 className: clsx_default( 29986 "components-validated-control__indicator", 29987 customValidity.type === "invalid" ? "is-invalid" : void 0 29988 ), 29989 children: [ 29990 /* @__PURE__ */ (0, import_jsx_runtime140.jsx)( 29991 import_components34.Icon, 29992 { 29993 className: "components-validated-control__indicator-icon", 29994 icon: error_default, 29995 size: 16, 29996 fill: "currentColor" 29997 } 29998 ), 29999 customValidity.message 30000 ] 30001 } 30002 ) 30003 ] }); 30004 } 30005 function CalendarDateControl({ 30006 data, 30007 field, 30008 onChange, 30009 hideLabelFromVision, 30010 markWhenOptional, 30011 validity 30012 }) { 30013 const { 30014 id, 30015 label, 30016 description, 30017 setValue, 30018 getValue, 30019 isValid: isValid2, 30020 format: fieldFormat 30021 } = field; 30022 const disabled2 = field.isDisabled({ item: data, field }); 30023 const [selectedPresetId, setSelectedPresetId] = (0, import_element101.useState)( 30024 null 30025 ); 30026 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek; 30027 const fieldValue = getValue({ item: data }); 30028 const value = typeof fieldValue === "string" ? fieldValue : void 0; 30029 const [calendarMonth, setCalendarMonth] = (0, import_element101.useState)(() => { 30030 const parsedDate = parseDate(value); 30031 return parsedDate || /* @__PURE__ */ new Date(); 30032 }); 30033 const [isTouched, setIsTouched] = (0, import_element101.useState)(false); 30034 const validityTargetRef = (0, import_element101.useRef)(null); 30035 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate); 30036 const onChangeCallback = (0, import_element101.useCallback)( 30037 (newValue) => onChange(setValue({ item: data, value: newValue })), 30038 [data, onChange, setValue] 30039 ); 30040 const onSelectDate = (0, import_element101.useCallback)( 30041 (newDate) => { 30042 const dateValue = newDate ? format(newDate, "yyyy-MM-dd") : void 0; 30043 onChangeCallback(dateValue); 30044 setSelectedPresetId(null); 30045 setIsTouched(true); 30046 }, 30047 [onChangeCallback] 30048 ); 30049 const handlePresetClick = (0, import_element101.useCallback)( 30050 (preset) => { 30051 const presetDate = preset.getValue(); 30052 const dateValue = formatDate(presetDate); 30053 setCalendarMonth(presetDate); 30054 onChangeCallback(dateValue); 30055 setSelectedPresetId(preset.id); 30056 setIsTouched(true); 30057 }, 30058 [onChangeCallback] 30059 ); 30060 const handleManualDateChange = (0, import_element101.useCallback)( 30061 (newValue) => { 30062 onChangeCallback(newValue); 30063 if (newValue) { 30064 const parsedDate = parseDate(newValue); 30065 if (parsedDate) { 30066 setCalendarMonth(parsedDate); 30067 } 30068 } 30069 setSelectedPresetId(null); 30070 setIsTouched(true); 30071 }, 30072 [onChangeCallback] 30073 ); 30074 const { 30075 timezone: { string: timezoneString } 30076 } = (0, import_date4.getSettings)(); 30077 let displayLabel = label; 30078 if (isValid2?.required && !markWhenOptional) { 30079 displayLabel = `$label} (${(0, import_i18n39.__)("Required")})`; 30080 } else if (!isValid2?.required && markWhenOptional) { 30081 displayLabel = `$label} (${(0, import_i18n39.__)("Optional")})`; 30082 } 30083 return /* @__PURE__ */ (0, import_jsx_runtime140.jsx)( 30084 ValidatedDateControl, 30085 { 30086 field, 30087 validity, 30088 inputRefs: validityTargetRef, 30089 isTouched, 30090 setIsTouched, 30091 children: /* @__PURE__ */ (0, import_jsx_runtime140.jsx)( 30092 import_components34.BaseControl, 30093 { 30094 id, 30095 className: "dataviews-controls__date", 30096 label: displayLabel, 30097 help: description, 30098 hideLabelFromVision, 30099 children: /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)(Stack, { direction: "column", gap: "lg", children: [ 30100 /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)( 30101 Stack, 30102 { 30103 direction: "row", 30104 gap: "sm", 30105 wrap: "wrap", 30106 justify: "flex-start", 30107 children: [ 30108 DATE_PRESETS.map((preset) => { 30109 const isSelected2 = selectedPresetId === preset.id; 30110 return /* @__PURE__ */ (0, import_jsx_runtime140.jsx)( 30111 import_components34.Button, 30112 { 30113 className: "dataviews-controls__date-preset", 30114 variant: "tertiary", 30115 isPressed: isSelected2, 30116 size: "small", 30117 disabled: disabled2, 30118 accessibleWhenDisabled: true, 30119 onClick: () => handlePresetClick(preset), 30120 children: preset.label 30121 }, 30122 preset.id 30123 ); 30124 }), 30125 /* @__PURE__ */ (0, import_jsx_runtime140.jsx)( 30126 import_components34.Button, 30127 { 30128 className: "dataviews-controls__date-preset", 30129 variant: "tertiary", 30130 isPressed: !selectedPresetId, 30131 size: "small", 30132 disabled: !!selectedPresetId || disabled2, 30133 accessibleWhenDisabled: true, 30134 children: (0, import_i18n39.__)("Custom") 30135 } 30136 ) 30137 ] 30138 } 30139 ), 30140 /* @__PURE__ */ (0, import_jsx_runtime140.jsx)( 30141 import_components34.__experimentalInputControl, 30142 { 30143 ref: validityTargetRef, 30144 type: "date", 30145 label: (0, import_i18n39.__)("Date"), 30146 hideLabelFromVision: true, 30147 value, 30148 onChange: handleManualDateChange, 30149 required: !!field.isValid?.required, 30150 disabled: disabled2, 30151 min: minConstraint, 30152 max: maxConstraint 30153 } 30154 ), 30155 /* @__PURE__ */ (0, import_jsx_runtime140.jsx)( 30156 DateCalendar2, 30157 { 30158 style: { width: "100%" }, 30159 selected: value ? parseDate(value) || void 0 : void 0, 30160 onSelect: onSelectDate, 30161 month: calendarMonth, 30162 onMonthChange: setCalendarMonth, 30163 timeZone: timezoneString || void 0, 30164 weekStartsOn, 30165 disabled: disabled2 || disabledMatchers, 30166 disableNavigation: disabled2 30167 } 30168 ) 30169 ] }) 30170 } 30171 ) 30172 } 30173 ); 30174 } 30175 function CalendarDateRangeControl({ 30176 data, 30177 field, 30178 onChange, 30179 hideLabelFromVision, 30180 markWhenOptional, 30181 validity 30182 }) { 30183 const { 30184 id, 30185 label, 30186 description, 30187 getValue, 30188 setValue, 30189 isValid: isValid2, 30190 format: fieldFormat 30191 } = field; 30192 const disabled2 = field.isDisabled({ item: data, field }); 30193 let value; 30194 const fieldValue = getValue({ item: data }); 30195 if (Array.isArray(fieldValue) && fieldValue.length === 2 && fieldValue.every((date) => typeof date === "string")) { 30196 value = fieldValue; 30197 } 30198 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek; 30199 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate); 30200 const onChangeCallback = (0, import_element101.useCallback)( 30201 (newValue) => { 30202 onChange( 30203 setValue({ 30204 item: data, 30205 value: newValue 30206 }) 30207 ); 30208 }, 30209 [data, onChange, setValue] 30210 ); 30211 const [selectedPresetId, setSelectedPresetId] = (0, import_element101.useState)( 30212 null 30213 ); 30214 const selectedRange = (0, import_element101.useMemo)(() => { 30215 if (!value) { 30216 return { from: void 0, to: void 0 }; 30217 } 30218 const [from, to] = value; 30219 return { 30220 from: parseDate(from) || void 0, 30221 to: parseDate(to) || void 0 30222 }; 30223 }, [value]); 30224 const [calendarMonth, setCalendarMonth] = (0, import_element101.useState)(() => { 30225 return selectedRange.from || /* @__PURE__ */ new Date(); 30226 }); 30227 const [isTouched, setIsTouched] = (0, import_element101.useState)(false); 30228 const fromInputRef = (0, import_element101.useRef)(null); 30229 const toInputRef = (0, import_element101.useRef)(null); 30230 const updateDateRange = (0, import_element101.useCallback)( 30231 (fromDate, toDate2) => { 30232 if (fromDate && toDate2) { 30233 onChangeCallback([ 30234 formatDate(fromDate), 30235 formatDate(toDate2) 30236 ]); 30237 } else if (!fromDate && !toDate2) { 30238 onChangeCallback(void 0); 30239 } 30240 }, 30241 [onChangeCallback] 30242 ); 30243 const onSelectCalendarRange = (0, import_element101.useCallback)( 30244 (newRange) => { 30245 updateDateRange(newRange?.from, newRange?.to); 30246 setSelectedPresetId(null); 30247 setIsTouched(true); 30248 }, 30249 [updateDateRange] 30250 ); 30251 const handlePresetClick = (0, import_element101.useCallback)( 30252 (preset) => { 30253 const [startDate, endDate] = preset.getValue(); 30254 setCalendarMonth(startDate); 30255 updateDateRange(startDate, endDate); 30256 setSelectedPresetId(preset.id); 30257 setIsTouched(true); 30258 }, 30259 [updateDateRange] 30260 ); 30261 const handleManualDateChange = (0, import_element101.useCallback)( 30262 (fromOrTo, newValue) => { 30263 const [currentFrom, currentTo] = value || [ 30264 void 0, 30265 void 0 30266 ]; 30267 const updatedFrom = fromOrTo === "from" ? newValue : currentFrom; 30268 const updatedTo = fromOrTo === "to" ? newValue : currentTo; 30269 updateDateRange(updatedFrom, updatedTo); 30270 if (newValue) { 30271 const parsedDate = parseDate(newValue); 30272 if (parsedDate) { 30273 setCalendarMonth(parsedDate); 30274 } 30275 } 30276 setSelectedPresetId(null); 30277 setIsTouched(true); 30278 }, 30279 [value, updateDateRange] 30280 ); 30281 const { timezone } = (0, import_date4.getSettings)(); 30282 let displayLabel = label; 30283 if (field.isValid?.required && !markWhenOptional) { 30284 displayLabel = `$label} (${(0, import_i18n39.__)("Required")})`; 30285 } else if (!field.isValid?.required && markWhenOptional) { 30286 displayLabel = `$label} (${(0, import_i18n39.__)("Optional")})`; 30287 } 30288 return /* @__PURE__ */ (0, import_jsx_runtime140.jsx)( 30289 ValidatedDateControl, 30290 { 30291 field, 30292 validity, 30293 inputRefs: [fromInputRef, toInputRef], 30294 isTouched, 30295 setIsTouched, 30296 children: /* @__PURE__ */ (0, import_jsx_runtime140.jsx)( 30297 import_components34.BaseControl, 30298 { 30299 id, 30300 className: "dataviews-controls__date", 30301 label: displayLabel, 30302 help: description, 30303 hideLabelFromVision, 30304 children: /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)(Stack, { direction: "column", gap: "lg", children: [ 30305 /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)( 30306 Stack, 30307 { 30308 direction: "row", 30309 gap: "sm", 30310 wrap: "wrap", 30311 justify: "flex-start", 30312 children: [ 30313 DATE_RANGE_PRESETS.map((preset) => { 30314 const isSelected2 = selectedPresetId === preset.id; 30315 return /* @__PURE__ */ (0, import_jsx_runtime140.jsx)( 30316 import_components34.Button, 30317 { 30318 className: "dataviews-controls__date-preset", 30319 variant: "tertiary", 30320 isPressed: isSelected2, 30321 size: "small", 30322 disabled: disabled2, 30323 accessibleWhenDisabled: true, 30324 onClick: () => handlePresetClick(preset), 30325 children: preset.label 30326 }, 30327 preset.id 30328 ); 30329 }), 30330 /* @__PURE__ */ (0, import_jsx_runtime140.jsx)( 30331 import_components34.Button, 30332 { 30333 className: "dataviews-controls__date-preset", 30334 variant: "tertiary", 30335 isPressed: !selectedPresetId, 30336 size: "small", 30337 accessibleWhenDisabled: true, 30338 disabled: !!selectedPresetId || disabled2, 30339 children: (0, import_i18n39.__)("Custom") 30340 } 30341 ) 30342 ] 30343 } 30344 ), 30345 /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)( 30346 Stack, 30347 { 30348 direction: "row", 30349 gap: "sm", 30350 justify: "space-between", 30351 className: "dataviews-controls__date-range-inputs", 30352 children: [ 30353 /* @__PURE__ */ (0, import_jsx_runtime140.jsx)( 30354 import_components34.__experimentalInputControl, 30355 { 30356 ref: fromInputRef, 30357 type: "date", 30358 label: (0, import_i18n39.__)("From"), 30359 hideLabelFromVision: true, 30360 value: value?.[0], 30361 onChange: (newValue) => handleManualDateChange("from", newValue), 30362 required: !!field.isValid?.required, 30363 disabled: disabled2, 30364 min: minConstraint, 30365 max: maxConstraint 30366 } 30367 ), 30368 /* @__PURE__ */ (0, import_jsx_runtime140.jsx)( 30369 import_components34.__experimentalInputControl, 30370 { 30371 ref: toInputRef, 30372 type: "date", 30373 label: (0, import_i18n39.__)("To"), 30374 hideLabelFromVision: true, 30375 value: value?.[1], 30376 onChange: (newValue) => handleManualDateChange("to", newValue), 30377 required: !!field.isValid?.required, 30378 disabled: disabled2, 30379 min: minConstraint, 30380 max: maxConstraint 30381 } 30382 ) 30383 ] 30384 } 30385 ), 30386 /* @__PURE__ */ (0, import_jsx_runtime140.jsx)( 30387 DateRangeCalendar, 30388 { 30389 style: { width: "100%" }, 30390 selected: selectedRange, 30391 onSelect: onSelectCalendarRange, 30392 month: calendarMonth, 30393 onMonthChange: setCalendarMonth, 30394 timeZone: timezone.string || void 0, 30395 weekStartsOn, 30396 disabled: disabled2 || disabledMatchers 30397 } 30398 ) 30399 ] }) 30400 } 30401 ) 30402 } 30403 ); 30404 } 30405 function DateControl({ 30406 data, 30407 field, 30408 onChange, 30409 hideLabelFromVision, 30410 markWhenOptional, 30411 operator, 30412 validity 30413 }) { 30414 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) { 30415 return /* @__PURE__ */ (0, import_jsx_runtime140.jsx)( 30416 RelativeDateControl, 30417 { 30418 className: "dataviews-controls__date", 30419 data, 30420 field, 30421 onChange, 30422 hideLabelFromVision, 30423 operator 30424 } 30425 ); 30426 } 30427 if (operator === OPERATOR_BETWEEN) { 30428 return /* @__PURE__ */ (0, import_jsx_runtime140.jsx)( 30429 CalendarDateRangeControl, 30430 { 30431 data, 30432 field, 30433 onChange, 30434 hideLabelFromVision, 30435 markWhenOptional, 30436 validity 30437 } 30438 ); 30439 } 30440 return /* @__PURE__ */ (0, import_jsx_runtime140.jsx)( 30441 CalendarDateControl, 30442 { 30443 data, 30444 field, 30445 onChange, 30446 hideLabelFromVision, 30447 markWhenOptional, 30448 validity 30449 } 30450 ); 30451 } 30452 30453 // packages/dataviews/build-module/components/dataform-controls/select.mjs 30454 var import_components35 = __toESM(require_components(), 1); 30455 var import_element102 = __toESM(require_element(), 1); 30456 var import_jsx_runtime141 = __toESM(require_jsx_runtime(), 1); 30457 var { ValidatedSelectControl } = unlock3(import_components35.privateApis); 30458 function Select({ 30459 data, 30460 field, 30461 onChange, 30462 hideLabelFromVision, 30463 markWhenOptional, 30464 validity 30465 }) { 30466 const { type, label, description, getValue, setValue, isValid: isValid2 } = field; 30467 const disabled2 = field.isDisabled({ item: data, field }); 30468 const isMultiple = type === "array"; 30469 const value = getValue({ item: data }) ?? (isMultiple ? [] : ""); 30470 const onChangeControl = (0, import_element102.useCallback)( 30471 (newValue) => onChange(setValue({ item: data, value: newValue })), 30472 [data, onChange, setValue] 30473 ); 30474 const { elements, isLoading } = useElements({ 30475 elements: field.elements, 30476 getElements: field.getElements 30477 }); 30478 if (isLoading) { 30479 return /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(import_components35.Spinner, {}); 30480 } 30481 return /* @__PURE__ */ (0, import_jsx_runtime141.jsx)( 30482 ValidatedSelectControl, 30483 { 30484 required: !!field.isValid?.required, 30485 markWhenOptional, 30486 customValidity: getCustomValidity(isValid2, validity), 30487 label, 30488 value, 30489 help: description, 30490 options: elements, 30491 onChange: onChangeControl, 30492 hideLabelFromVision, 30493 multiple: isMultiple, 30494 disabled: disabled2 30495 } 30496 ); 30497 } 30498 30499 // packages/dataviews/build-module/components/dataform-controls/adaptive-select.mjs 30500 var import_jsx_runtime142 = __toESM(require_jsx_runtime(), 1); 30501 var ELEMENTS_THRESHOLD = 10; 30502 function AdaptiveSelect(props) { 30503 const { field } = props; 30504 const { elements } = useElements({ 30505 elements: field.elements, 30506 getElements: field.getElements 30507 }); 30508 if (elements.length >= ELEMENTS_THRESHOLD) { 30509 return /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(Combobox3, { ...props }); 30510 } 30511 return /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(Select, { ...props }); 30512 } 30513 30514 // packages/dataviews/build-module/components/dataform-controls/email.mjs 30515 var import_components37 = __toESM(require_components(), 1); 30516 30517 // packages/dataviews/build-module/components/dataform-controls/utils/validated-input.mjs 30518 var import_components36 = __toESM(require_components(), 1); 30519 var import_element103 = __toESM(require_element(), 1); 30520 var import_jsx_runtime143 = __toESM(require_jsx_runtime(), 1); 30521 var { ValidatedInputControl: ValidatedInputControl2 } = unlock3(import_components36.privateApis); 30522 function ValidatedText({ 30523 data, 30524 field, 30525 onChange, 30526 hideLabelFromVision, 30527 markWhenOptional, 30528 type, 30529 prefix, 30530 suffix, 30531 validity 30532 }) { 30533 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field; 30534 const value = getValue({ item: data }); 30535 const disabled2 = field.isDisabled({ item: data, field }); 30536 const onChangeControl = (0, import_element103.useCallback)( 30537 (newValue) => onChange( 30538 setValue({ 30539 item: data, 30540 value: newValue 30541 }) 30542 ), 30543 [data, setValue, onChange] 30544 ); 30545 return /* @__PURE__ */ (0, import_jsx_runtime143.jsx)( 30546 ValidatedInputControl2, 30547 { 30548 required: !!isValid2.required, 30549 markWhenOptional, 30550 customValidity: getCustomValidity(isValid2, validity), 30551 label, 30552 placeholder, 30553 value: value ?? "", 30554 help: description, 30555 onChange: onChangeControl, 30556 hideLabelFromVision, 30557 type, 30558 prefix, 30559 suffix, 30560 disabled: disabled2, 30561 pattern: isValid2.pattern ? isValid2.pattern.constraint : void 0, 30562 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0, 30563 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0 30564 } 30565 ); 30566 } 30567 30568 // packages/dataviews/build-module/components/dataform-controls/email.mjs 30569 var import_jsx_runtime144 = __toESM(require_jsx_runtime(), 1); 30570 function Email({ 30571 data, 30572 field, 30573 onChange, 30574 hideLabelFromVision, 30575 markWhenOptional, 30576 validity 30577 }) { 30578 return /* @__PURE__ */ (0, import_jsx_runtime144.jsx)( 30579 ValidatedText, 30580 { 30581 ...{ 30582 data, 30583 field, 30584 onChange, 30585 hideLabelFromVision, 30586 markWhenOptional, 30587 validity, 30588 type: "email", 30589 prefix: /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(import_components37.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(import_components37.Icon, { icon: envelope_default }) }) 30590 } 30591 } 30592 ); 30593 } 30594 30595 // packages/dataviews/build-module/components/dataform-controls/telephone.mjs 30596 var import_components38 = __toESM(require_components(), 1); 30597 var import_jsx_runtime145 = __toESM(require_jsx_runtime(), 1); 30598 function Telephone({ 30599 data, 30600 field, 30601 onChange, 30602 hideLabelFromVision, 30603 markWhenOptional, 30604 validity 30605 }) { 30606 return /* @__PURE__ */ (0, import_jsx_runtime145.jsx)( 30607 ValidatedText, 30608 { 30609 ...{ 30610 data, 30611 field, 30612 onChange, 30613 hideLabelFromVision, 30614 markWhenOptional, 30615 validity, 30616 type: "tel", 30617 prefix: /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(import_components38.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(import_components38.Icon, { icon: mobile_default }) }) 30618 } 30619 } 30620 ); 30621 } 30622 30623 // packages/dataviews/build-module/components/dataform-controls/url.mjs 30624 var import_components39 = __toESM(require_components(), 1); 30625 var import_jsx_runtime146 = __toESM(require_jsx_runtime(), 1); 30626 function Url({ 30627 data, 30628 field, 30629 onChange, 30630 hideLabelFromVision, 30631 markWhenOptional, 30632 validity 30633 }) { 30634 return /* @__PURE__ */ (0, import_jsx_runtime146.jsx)( 30635 ValidatedText, 30636 { 30637 ...{ 30638 data, 30639 field, 30640 onChange, 30641 hideLabelFromVision, 30642 markWhenOptional, 30643 validity, 30644 type: "url", 30645 prefix: /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(import_components39.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(import_components39.Icon, { icon: link_default }) }) 30646 } 30647 } 30648 ); 30649 } 30650 30651 // packages/dataviews/build-module/components/dataform-controls/utils/validated-number.mjs 30652 var import_components40 = __toESM(require_components(), 1); 30653 var import_element104 = __toESM(require_element(), 1); 30654 var import_i18n40 = __toESM(require_i18n(), 1); 30655 var import_jsx_runtime147 = __toESM(require_jsx_runtime(), 1); 30656 var { ValidatedNumberControl } = unlock3(import_components40.privateApis); 30657 function toNumberOrEmpty(value) { 30658 if (value === "" || value === void 0) { 30659 return ""; 30660 } 30661 const number = Number(value); 30662 return Number.isFinite(number) ? number : ""; 30663 } 30664 function BetweenControls({ 30665 value, 30666 onChange, 30667 hideLabelFromVision, 30668 step 30669 }) { 30670 const [min2 = "", max2 = ""] = value; 30671 const onChangeMin = (0, import_element104.useCallback)( 30672 (newValue) => onChange([toNumberOrEmpty(newValue), max2]), 30673 [onChange, max2] 30674 ); 30675 const onChangeMax = (0, import_element104.useCallback)( 30676 (newValue) => onChange([min2, toNumberOrEmpty(newValue)]), 30677 [onChange, min2] 30678 ); 30679 return /* @__PURE__ */ (0, import_jsx_runtime147.jsx)( 30680 import_components40.BaseControl, 30681 { 30682 help: (0, import_i18n40.__)("The max. value must be greater than the min. value."), 30683 children: /* @__PURE__ */ (0, import_jsx_runtime147.jsxs)(import_components40.Flex, { direction: "row", gap: 4, children: [ 30684 /* @__PURE__ */ (0, import_jsx_runtime147.jsx)( 30685 import_components40.__experimentalNumberControl, 30686 { 30687 label: (0, import_i18n40.__)("Min."), 30688 value: min2, 30689 max: max2 ? Number(max2) - step : void 0, 30690 onChange: onChangeMin, 30691 hideLabelFromVision, 30692 step 30693 } 30694 ), 30695 /* @__PURE__ */ (0, import_jsx_runtime147.jsx)( 30696 import_components40.__experimentalNumberControl, 30697 { 30698 label: (0, import_i18n40.__)("Max."), 30699 value: max2, 30700 min: min2 ? Number(min2) + step : void 0, 30701 onChange: onChangeMax, 30702 hideLabelFromVision, 30703 step 30704 } 30705 ) 30706 ] }) 30707 } 30708 ); 30709 } 30710 function ValidatedNumber({ 30711 data, 30712 field, 30713 onChange, 30714 hideLabelFromVision, 30715 markWhenOptional, 30716 operator, 30717 validity 30718 }) { 30719 const decimals = field.format?.decimals ?? 0; 30720 const step = Math.pow(10, Math.abs(decimals) * -1); 30721 const { label, description, getValue, setValue, isValid: isValid2 } = field; 30722 const value = getValue({ item: data }) ?? ""; 30723 const disabled2 = field.isDisabled({ item: data, field }); 30724 const onChangeControl = (0, import_element104.useCallback)( 30725 (newValue) => { 30726 onChange( 30727 setValue({ 30728 item: data, 30729 // Do not convert an empty string or undefined to a number, 30730 // otherwise there's a mismatch between the UI control (empty) 30731 // and the data relied by onChange (0). 30732 value: ["", void 0].includes(newValue) ? void 0 : Number(newValue) 30733 }) 30734 ); 30735 }, 30736 [data, onChange, setValue] 30737 ); 30738 const onChangeBetweenControls = (0, import_element104.useCallback)( 30739 (newValue) => { 30740 onChange( 30741 setValue({ 30742 item: data, 30743 value: newValue 30744 }) 30745 ); 30746 }, 30747 [data, onChange, setValue] 30748 ); 30749 if (operator === OPERATOR_BETWEEN) { 30750 let valueBetween = ["", ""]; 30751 if (Array.isArray(value) && value.length === 2 && value.every( 30752 (element) => typeof element === "number" || element === "" 30753 )) { 30754 valueBetween = value; 30755 } 30756 return /* @__PURE__ */ (0, import_jsx_runtime147.jsx)( 30757 BetweenControls, 30758 { 30759 value: valueBetween, 30760 onChange: onChangeBetweenControls, 30761 hideLabelFromVision, 30762 step 30763 } 30764 ); 30765 } 30766 return /* @__PURE__ */ (0, import_jsx_runtime147.jsx)( 30767 ValidatedNumberControl, 30768 { 30769 required: !!isValid2.required, 30770 markWhenOptional, 30771 customValidity: getCustomValidity(isValid2, validity), 30772 label, 30773 help: description, 30774 value, 30775 onChange: onChangeControl, 30776 hideLabelFromVision, 30777 step, 30778 min: isValid2.min ? isValid2.min.constraint : void 0, 30779 max: isValid2.max ? isValid2.max.constraint : void 0, 30780 disabled: disabled2 30781 } 30782 ); 30783 } 30784 30785 // packages/dataviews/build-module/components/dataform-controls/integer.mjs 30786 var import_jsx_runtime148 = __toESM(require_jsx_runtime(), 1); 30787 function Integer(props) { 30788 return /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(ValidatedNumber, { ...props }); 30789 } 30790 30791 // packages/dataviews/build-module/components/dataform-controls/number.mjs 30792 var import_jsx_runtime149 = __toESM(require_jsx_runtime(), 1); 30793 function Number2(props) { 30794 return /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(ValidatedNumber, { ...props }); 30795 } 30796 30797 // packages/dataviews/build-module/components/dataform-controls/radio.mjs 30798 var import_components41 = __toESM(require_components(), 1); 30799 var import_element105 = __toESM(require_element(), 1); 30800 var import_jsx_runtime150 = __toESM(require_jsx_runtime(), 1); 30801 var { ValidatedRadioControl } = unlock3(import_components41.privateApis); 30802 function Radio({ 30803 data, 30804 field, 30805 onChange, 30806 hideLabelFromVision, 30807 markWhenOptional, 30808 validity 30809 }) { 30810 const { label, description, getValue, setValue, isValid: isValid2 } = field; 30811 const disabled2 = field.isDisabled({ item: data, field }); 30812 const { elements, isLoading } = useElements({ 30813 elements: field.elements, 30814 getElements: field.getElements 30815 }); 30816 const value = getValue({ item: data }); 30817 const onChangeControl = (0, import_element105.useCallback)( 30818 (newValue) => onChange(setValue({ item: data, value: newValue })), 30819 [data, onChange, setValue] 30820 ); 30821 if (isLoading) { 30822 return /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_components41.Spinner, {}); 30823 } 30824 return /* @__PURE__ */ (0, import_jsx_runtime150.jsx)( 30825 ValidatedRadioControl, 30826 { 30827 required: !!field.isValid?.required, 30828 markWhenOptional, 30829 customValidity: getCustomValidity(isValid2, validity), 30830 label, 30831 help: description, 30832 onChange: onChangeControl, 30833 options: elements, 30834 selected: value, 30835 hideLabelFromVision, 30836 disabled: disabled2 30837 } 30838 ); 30839 } 30840 30841 // packages/dataviews/build-module/components/dataform-controls/text.mjs 30842 var import_element106 = __toESM(require_element(), 1); 30843 var import_jsx_runtime151 = __toESM(require_jsx_runtime(), 1); 30844 function Text3({ 30845 data, 30846 field, 30847 onChange, 30848 hideLabelFromVision, 30849 markWhenOptional, 30850 config, 30851 validity 30852 }) { 30853 const { prefix, suffix } = config || {}; 30854 return /* @__PURE__ */ (0, import_jsx_runtime151.jsx)( 30855 ValidatedText, 30856 { 30857 ...{ 30858 data, 30859 field, 30860 onChange, 30861 hideLabelFromVision, 30862 markWhenOptional, 30863 validity, 30864 prefix: prefix ? (0, import_element106.createElement)(prefix) : void 0, 30865 suffix: suffix ? (0, import_element106.createElement)(suffix) : void 0 30866 } 30867 } 30868 ); 30869 } 30870 30871 // packages/dataviews/build-module/components/dataform-controls/toggle.mjs 30872 var import_components42 = __toESM(require_components(), 1); 30873 var import_element107 = __toESM(require_element(), 1); 30874 var import_jsx_runtime152 = __toESM(require_jsx_runtime(), 1); 30875 var { ValidatedToggleControl } = unlock3(import_components42.privateApis); 30876 function Toggle({ 30877 field, 30878 onChange, 30879 data, 30880 hideLabelFromVision, 30881 markWhenOptional, 30882 validity 30883 }) { 30884 const { label, description, getValue, setValue, isValid: isValid2 } = field; 30885 const disabled2 = field.isDisabled({ item: data, field }); 30886 const onChangeControl = (0, import_element107.useCallback)(() => { 30887 onChange( 30888 setValue({ item: data, value: !getValue({ item: data }) }) 30889 ); 30890 }, [onChange, setValue, data, getValue]); 30891 return /* @__PURE__ */ (0, import_jsx_runtime152.jsx)( 30892 ValidatedToggleControl, 30893 { 30894 required: !!isValid2.required, 30895 markWhenOptional, 30896 customValidity: getCustomValidity(isValid2, validity), 30897 hidden: hideLabelFromVision, 30898 label, 30899 help: description, 30900 checked: getValue({ item: data }), 30901 onChange: onChangeControl, 30902 disabled: disabled2 30903 } 30904 ); 30905 } 30906 30907 // packages/dataviews/build-module/components/dataform-controls/textarea.mjs 30908 var import_components43 = __toESM(require_components(), 1); 30909 var import_element108 = __toESM(require_element(), 1); 30910 var import_jsx_runtime153 = __toESM(require_jsx_runtime(), 1); 30911 var { ValidatedTextareaControl } = unlock3(import_components43.privateApis); 30912 function Textarea({ 30913 data, 30914 field, 30915 onChange, 30916 hideLabelFromVision, 30917 markWhenOptional, 30918 config, 30919 validity 30920 }) { 30921 const { rows = 4 } = config || {}; 30922 const disabled2 = field.isDisabled({ item: data, field }); 30923 const { label, placeholder, description, setValue, isValid: isValid2 } = field; 30924 const value = field.getValue({ item: data }); 30925 const onChangeControl = (0, import_element108.useCallback)( 30926 (newValue) => onChange(setValue({ item: data, value: newValue })), 30927 [data, onChange, setValue] 30928 ); 30929 return /* @__PURE__ */ (0, import_jsx_runtime153.jsx)( 30930 ValidatedTextareaControl, 30931 { 30932 required: !!isValid2.required, 30933 markWhenOptional, 30934 customValidity: getCustomValidity(isValid2, validity), 30935 label, 30936 placeholder, 30937 value: value ?? "", 30938 help: description, 30939 onChange: onChangeControl, 30940 rows, 30941 disabled: disabled2, 30942 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0, 30943 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0, 30944 __next40pxDefaultSize: true, 30945 hideLabelFromVision 30946 } 30947 ); 30948 } 30949 30950 // packages/dataviews/build-module/components/dataform-controls/richtext/index.mjs 30951 var import_element110 = __toESM(require_element(), 1); 30952 30953 // packages/dataviews/build-module/components/dataform-controls/richtext/control.mjs 30954 var import_components44 = __toESM(require_components(), 1); 30955 var import_compose14 = __toESM(require_compose(), 1); 30956 var import_element109 = __toESM(require_element(), 1); 30957 var import_rich_text2 = __toESM(require_rich_text(), 1); 30958 30959 // packages/dataviews/build-module/components/dataform-controls/richtext/utils.mjs 30960 var EMPTY_ARRAY6 = []; 30961 function getAllowedFormats({ 30962 allowedFormats, 30963 disableFormats 30964 }) { 30965 if (disableFormats) { 30966 return EMPTY_ARRAY6; 30967 } 30968 return allowedFormats; 30969 } 30970 30971 // packages/dataviews/build-module/components/dataform-controls/richtext/format-edit.mjs 30972 var import_rich_text = __toESM(require_rich_text(), 1); 30973 var import_jsx_runtime154 = __toESM(require_jsx_runtime(), 1); 30974 var import_react32 = __toESM(require_react(), 1); 30975 var EMPTY_CONTEXT = {}; 30976 function Edit({ 30977 onChange, 30978 onFocus, 30979 value, 30980 forwardedRef, 30981 settings, 30982 isVisible: isVisible2 30983 }) { 30984 const { name, edit: EditFunction } = settings; 30985 if (!EditFunction) { 30986 return null; 30987 } 30988 const activeFormat = (0, import_rich_text.getActiveFormat)(value, name); 30989 const isActive = activeFormat !== void 0; 30990 const activeObject = (0, import_rich_text.getActiveObject)(value); 30991 const isObjectActive = activeObject !== void 0 && activeObject.type === name; 30992 return /* @__PURE__ */ (0, import_jsx_runtime154.jsx)( 30993 EditFunction, 30994 { 30995 isActive, 30996 isVisible: isVisible2, 30997 activeAttributes: isActive ? activeFormat.attributes || {} : {}, 30998 isObjectActive, 30999 activeObjectAttributes: isObjectActive ? activeObject.attributes || {} : {}, 31000 value, 31001 onChange, 31002 onFocus, 31003 contentRef: forwardedRef, 31004 context: EMPTY_CONTEXT 31005 }, 31006 name 31007 ); 31008 } 31009 function FormatEdit({ 31010 formatTypes, 31011 ...props 31012 }) { 31013 return formatTypes.map((settings) => /* @__PURE__ */ (0, import_react32.createElement)(Edit, { settings, ...props, key: settings.name })); 31014 } 31015 31016 // packages/dataviews/build-module/components/dataform-controls/richtext/control.mjs 31017 var import_jsx_runtime155 = __toESM(require_jsx_runtime(), 1); 31018 var { 31019 ValidatedContentEditableControl: RichTextControlShell, 31020 withIgnoreIMEEvents 31021 } = unlock3(import_components44.privateApis); 31022 var { 31023 useRichText, 31024 KeyboardShortcutContext, 31025 InputEventContext, 31026 shortcutsListener, 31027 inputEventsListener 31028 } = unlock3(import_rich_text2.privateApis); 31029 var EMPTY_COMPLETERS = []; 31030 function RichTextControl({ 31031 label, 31032 value: attrValue, 31033 onChange, 31034 placeholder, 31035 id, 31036 clientId, 31037 className, 31038 hideLabelFromVision, 31039 help, 31040 disabled: disabled2, 31041 required, 31042 markWhenOptional, 31043 customValidity, 31044 allowedFormats, 31045 disableFormats, 31046 withoutInteractiveFormatting, 31047 preserveWhiteSpace, 31048 disableLineBreaks, 31049 focusOnMount, 31050 completers = EMPTY_COMPLETERS 31051 }) { 31052 const [selection, setSelection] = (0, import_element109.useState)({ 31053 start: void 0, 31054 end: void 0 31055 }); 31056 const [isSelected2, setIsSelected] = (0, import_element109.useState)(false); 31057 const anchorRef = (0, import_element109.useRef)(void 0); 31058 const inputEvents = (0, import_element109.useRef)(/* @__PURE__ */ new Set()); 31059 const keyboardShortcuts = (0, import_element109.useRef)( 31060 /* @__PURE__ */ new Set() 31061 ); 31062 const focusOutside = (0, import_compose14.__experimentalUseFocusOutside)(() => setIsSelected(false)); 31063 const adjustedAllowedFormats = getAllowedFormats({ 31064 allowedFormats, 31065 disableFormats 31066 }); 31067 const { 31068 value, 31069 onChange: onRichTextChange, 31070 ref: richTextRef, 31071 formatTypes, 31072 getValue 31073 } = useRichText({ 31074 value: attrValue, 31075 onChange, 31076 selectionStart: selection.start, 31077 selectionEnd: selection.end, 31078 onSelectionChange: (start, end) => setSelection({ start, end }), 31079 __unstableIsSelected: isSelected2, 31080 preserveWhiteSpace: !!preserveWhiteSpace, 31081 placeholder, 31082 __unstableDisableFormats: disableFormats, 31083 allowedFormats: adjustedAllowedFormats, 31084 withoutInteractiveFormatting, 31085 __unstableFormatTypeHandlerContext: (0, import_element109.useMemo)( 31086 () => ({ 31087 richTextIdentifier: id, 31088 blockClientId: clientId 31089 }), 31090 [id, clientId] 31091 ) 31092 }); 31093 function onFocus() { 31094 anchorRef.current?.focus(); 31095 } 31096 const eventListenersPropsRef = (0, import_element109.useRef)({ 31097 keyboardShortcuts, 31098 inputEvents 31099 }); 31100 const inputRulePropsRef = (0, import_element109.useRef)({ 31101 formatTypes, 31102 getValue, 31103 onChange: onRichTextChange 31104 }); 31105 (0, import_element109.useInsertionEffect)(() => { 31106 inputRulePropsRef.current = { 31107 formatTypes, 31108 getValue, 31109 onChange: onRichTextChange 31110 }; 31111 }); 31112 const enterRef = (0, import_compose14.useRefEffect)( 31113 (element) => { 31114 if (disabled2) { 31115 return; 31116 } 31117 const onKeyDown = withIgnoreIMEEvents((event) => { 31118 if (event.key !== "Enter" || event.defaultPrevented || event.metaKey || event.ctrlKey) { 31119 return; 31120 } 31121 event.preventDefault(); 31122 if (disableLineBreaks) { 31123 return; 31124 } 31125 const { getValue: getCurrentValue2, onChange: handleChange } = inputRulePropsRef.current; 31126 const current = getCurrentValue2(); 31127 handleChange( 31128 (0, import_rich_text2.insert)( 31129 current, 31130 "\n", 31131 current.start ?? current.text.length, 31132 current.end ?? current.text.length 31133 ) 31134 ); 31135 }); 31136 element.addEventListener("keydown", onKeyDown); 31137 return () => element.removeEventListener("keydown", onKeyDown); 31138 }, 31139 [disableLineBreaks, disabled2] 31140 ); 31141 const eventListenersRef = (0, import_compose14.useRefEffect)( 31142 (element) => { 31143 if (!isSelected2) { 31144 return; 31145 } 31146 const cleanupShortcuts = shortcutsListener( 31147 eventListenersPropsRef 31148 )(element); 31149 const cleanupInputEvents = inputEventsListener( 31150 eventListenersPropsRef 31151 )(element); 31152 function onFormatInput(event) { 31153 if (event.inputType !== "insertText" && event.type !== "compositionend") { 31154 return; 31155 } 31156 const { 31157 formatTypes: types, 31158 getValue: getCurrentValue2, 31159 onChange: handleChange 31160 } = inputRulePropsRef.current; 31161 const current = getCurrentValue2(); 31162 const transformed = types.reduce( 31163 (accumulator, { 31164 __unstableInputRule 31165 }) => __unstableInputRule ? __unstableInputRule(accumulator) : accumulator, 31166 current 31167 ); 31168 if (transformed !== current) { 31169 handleChange({ 31170 ...transformed, 31171 activeFormats: current.activeFormats 31172 }); 31173 } 31174 } 31175 element.addEventListener("input", onFormatInput); 31176 element.addEventListener("compositionend", onFormatInput); 31177 return () => { 31178 cleanupShortcuts(); 31179 cleanupInputEvents(); 31180 element.removeEventListener("input", onFormatInput); 31181 element.removeEventListener("compositionend", onFormatInput); 31182 }; 31183 }, 31184 [isSelected2] 31185 ); 31186 const { ref: autocompleteRef, ...autocompleteProps } = (0, import_components44.__unstableUseAutocompleteProps)( 31187 { 31188 completers, 31189 record: value, 31190 onChange: onRichTextChange, 31191 // This control's completers insert their completion into the value; 31192 // none replace the whole value, so the required `onReplace` is a 31193 // no-op here. 31194 onReplace: () => { 31195 } 31196 } 31197 ); 31198 const focusOnMountRef = (0, import_compose14.useRefEffect)( 31199 (element) => { 31200 if (focusOnMount && !disabled2) { 31201 element.focus(); 31202 } 31203 }, 31204 [focusOnMount, disabled2] 31205 ); 31206 const editableRef = (0, import_compose14.useMergeRefs)([ 31207 richTextRef, 31208 anchorRef, 31209 eventListenersRef, 31210 enterRef, 31211 focusOnMountRef, 31212 autocompleteRef 31213 ]); 31214 return ( 31215 // Focus boundary for the field's selection: `onFocus` selects on entry; 31216 // the spread `useFocusOutside` handlers deselect once focus leaves. 31217 /* @__PURE__ */ (0, import_jsx_runtime155.jsx)( 31218 "div", 31219 { 31220 ...focusOutside, 31221 onFocus: (event) => { 31222 setIsSelected(true); 31223 focusOutside.onFocus(event); 31224 }, 31225 children: /* @__PURE__ */ (0, import_jsx_runtime155.jsxs)(import_components44.SlotFillProvider, { children: [ 31226 /* @__PURE__ */ (0, import_jsx_runtime155.jsx)( 31227 RichTextControlShell, 31228 { 31229 label, 31230 id, 31231 className: clsx_default( 31232 "dataviews-controls__richtext", 31233 className 31234 ), 31235 placeholder, 31236 hideLabelFromVision, 31237 help, 31238 disabled: disabled2, 31239 required, 31240 markWhenOptional, 31241 customValidity, 31242 value: value.text, 31243 "aria-multiline": !disableLineBreaks, 31244 ...autocompleteProps, 31245 ref: editableRef 31246 } 31247 ), 31248 isSelected2 && !disabled2 && /* @__PURE__ */ (0, import_jsx_runtime155.jsx)( 31249 KeyboardShortcutContext.Provider, 31250 { 31251 value: keyboardShortcuts, 31252 children: /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(InputEventContext.Provider, { value: inputEvents, children: /* @__PURE__ */ (0, import_jsx_runtime155.jsx)( 31253 FormatEdit, 31254 { 31255 value, 31256 onChange: onRichTextChange, 31257 onFocus, 31258 formatTypes, 31259 forwardedRef: anchorRef, 31260 isVisible: true 31261 } 31262 ) }) 31263 } 31264 ) 31265 ] }) 31266 } 31267 ) 31268 ); 31269 } 31270 31271 // packages/dataviews/build-module/components/dataform-controls/richtext/index.mjs 31272 var import_jsx_runtime156 = __toESM(require_jsx_runtime(), 1); 31273 function RichText({ 31274 data, 31275 field, 31276 onChange, 31277 hideLabelFromVision, 31278 markWhenOptional, 31279 config, 31280 validity 31281 }) { 31282 const { 31283 className, 31284 clientId, 31285 allowedFormats, 31286 disableFormats, 31287 withoutInteractiveFormatting, 31288 preserveWhiteSpace, 31289 disableLineBreaks 31290 } = config || {}; 31291 const disabled2 = field.isDisabled({ item: data, field }); 31292 const { label, placeholder, description, id, setValue, isValid: isValid2 } = field; 31293 const value = field.getValue({ item: data }) ?? ""; 31294 const onChangeControl = (0, import_element110.useCallback)( 31295 (newValue) => onChange(setValue({ item: data, value: newValue })), 31296 [data, onChange, setValue] 31297 ); 31298 return /* @__PURE__ */ (0, import_jsx_runtime156.jsx)( 31299 RichTextControl, 31300 { 31301 label, 31302 value, 31303 onChange: onChangeControl, 31304 placeholder, 31305 id, 31306 hideLabelFromVision, 31307 help: description, 31308 disabled: disabled2, 31309 required: !!isValid2.required, 31310 markWhenOptional, 31311 customValidity: getCustomValidity(isValid2, validity), 31312 className, 31313 clientId, 31314 allowedFormats, 31315 disableFormats, 31316 withoutInteractiveFormatting, 31317 preserveWhiteSpace, 31318 disableLineBreaks 31319 } 31320 ); 31321 } 31322 31323 // packages/dataviews/build-module/components/dataform-controls/toggle-group.mjs 31324 var import_components45 = __toESM(require_components(), 1); 31325 var import_element111 = __toESM(require_element(), 1); 31326 var import_jsx_runtime157 = __toESM(require_jsx_runtime(), 1); 31327 var { ValidatedToggleGroupControl } = unlock3(import_components45.privateApis); 31328 function ToggleGroup({ 31329 data, 31330 field, 31331 onChange, 31332 hideLabelFromVision, 31333 markWhenOptional, 31334 validity 31335 }) { 31336 const { getValue, setValue, isValid: isValid2 } = field; 31337 const disabled2 = field.isDisabled({ item: data, field }); 31338 const value = getValue({ item: data }); 31339 const onChangeControl = (0, import_element111.useCallback)( 31340 (newValue) => onChange(setValue({ item: data, value: newValue })), 31341 [data, onChange, setValue] 31342 ); 31343 const { elements, isLoading } = useElements({ 31344 elements: field.elements, 31345 getElements: field.getElements 31346 }); 31347 if (isLoading) { 31348 return /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(import_components45.Spinner, {}); 31349 } 31350 if (elements.length === 0) { 31351 return null; 31352 } 31353 const selectedOption = elements.find((el) => el.value === value); 31354 return /* @__PURE__ */ (0, import_jsx_runtime157.jsx)( 31355 ValidatedToggleGroupControl, 31356 { 31357 required: !!field.isValid?.required, 31358 markWhenOptional, 31359 customValidity: getCustomValidity(isValid2, validity), 31360 isBlock: true, 31361 label: field.label, 31362 help: selectedOption?.description || field.description, 31363 onChange: onChangeControl, 31364 value, 31365 hideLabelFromVision, 31366 children: elements.map((el) => /* @__PURE__ */ (0, import_jsx_runtime157.jsx)( 31367 import_components45.__experimentalToggleGroupControlOption, 31368 { 31369 label: el.label, 31370 value: el.value, 31371 disabled: disabled2 31372 }, 31373 el.value 31374 )) 31375 } 31376 ); 31377 } 31378 31379 // packages/dataviews/build-module/components/dataform-controls/array.mjs 31380 var import_components46 = __toESM(require_components(), 1); 31381 var import_element112 = __toESM(require_element(), 1); 31382 var import_jsx_runtime158 = __toESM(require_jsx_runtime(), 1); 31383 var { ValidatedFormTokenField } = unlock3(import_components46.privateApis); 31384 function ArrayControl({ 31385 data, 31386 field, 31387 onChange, 31388 hideLabelFromVision, 31389 markWhenOptional, 31390 validity 31391 }) { 31392 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field; 31393 const value = getValue({ item: data }); 31394 const disabled2 = field.isDisabled({ item: data, field }); 31395 const { elements, isLoading } = useElements({ 31396 elements: field.elements, 31397 getElements: field.getElements 31398 }); 31399 const arrayValueAsElements = (0, import_element112.useMemo)( 31400 () => Array.isArray(value) ? value.map((token) => { 31401 const element = elements?.find( 31402 (suggestion) => suggestion.value === token 31403 ); 31404 return element || { value: token, label: token }; 31405 }) : [], 31406 [value, elements] 31407 ); 31408 const onChangeControl = (0, import_element112.useCallback)( 31409 (tokens) => { 31410 const valueTokens = tokens.map((token) => { 31411 if (typeof token === "object" && "value" in token) { 31412 return token.value; 31413 } 31414 return token; 31415 }); 31416 onChange(setValue({ item: data, value: valueTokens })); 31417 }, 31418 [onChange, setValue, data] 31419 ); 31420 if (isLoading) { 31421 return /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(import_components46.Spinner, {}); 31422 } 31423 return /* @__PURE__ */ (0, import_jsx_runtime158.jsx)( 31424 ValidatedFormTokenField, 31425 { 31426 required: !!isValid2?.required, 31427 markWhenOptional, 31428 customValidity: getCustomValidity(isValid2, validity), 31429 label: hideLabelFromVision ? void 0 : label, 31430 value: arrayValueAsElements, 31431 onChange: onChangeControl, 31432 placeholder, 31433 suggestions: elements?.map((element) => element.value), 31434 disabled: disabled2, 31435 __experimentalValidateInput: (token) => { 31436 if (field.isValid?.elements && elements) { 31437 return elements.some( 31438 (element) => element.value === token || element.label === token 31439 ); 31440 } 31441 return true; 31442 }, 31443 __experimentalExpandOnFocus: elements && elements.length > 0, 31444 help: description ?? (field.isValid?.elements ? "" : void 0), 31445 displayTransform: (token) => { 31446 if (typeof token === "object" && "label" in token) { 31447 return token.label; 31448 } 31449 if (typeof token === "string" && elements) { 31450 const element = elements.find( 31451 (el) => el.value === token 31452 ); 31453 return element?.label || token; 31454 } 31455 return token; 31456 }, 31457 __experimentalRenderItem: ({ item }) => { 31458 if (typeof item === "string" && elements) { 31459 const element = elements.find( 31460 (el) => el.value === item 31461 ); 31462 return /* @__PURE__ */ (0, import_jsx_runtime158.jsx)("span", { children: element?.label || item }); 31463 } 31464 return /* @__PURE__ */ (0, import_jsx_runtime158.jsx)("span", { children: item }); 31465 } 31466 } 31467 ); 31468 } 31469 31470 // node_modules/colord/index.mjs 31471 var r2 = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }; 31472 var t = function(r3) { 31473 return "string" == typeof r3 ? r3.length > 0 : "number" == typeof r3; 31474 }; 31475 var n = function(r3, t2, n2) { 31476 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = Math.pow(10, t2)), Math.round(n2 * r3) / n2 + 0; 31477 }; 31478 var e = function(r3, t2, n2) { 31479 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = 1), r3 > n2 ? n2 : r3 > t2 ? r3 : t2; 31480 }; 31481 var u = function(r3) { 31482 return (r3 = isFinite(r3) ? r3 % 360 : 0) > 0 ? r3 : r3 + 360; 31483 }; 31484 var a = function(r3) { 31485 return { r: e(r3.r, 0, 255), g: e(r3.g, 0, 255), b: e(r3.b, 0, 255), a: e(r3.a) }; 31486 }; 31487 var o = function(r3) { 31488 return { r: n(r3.r), g: n(r3.g), b: n(r3.b), a: n(r3.a, 3) }; 31489 }; 31490 var i = /^#([0-9a-f]{3,8})$/i; 31491 var s = function(r3) { 31492 var t2 = r3.toString(16); 31493 return t2.length < 2 ? "0" + t2 : t2; 31494 }; 31495 var h = function(r3) { 31496 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; 31497 return { h: 60 * (i2 < 0 ? i2 + 6 : i2), s: a2 ? o2 / a2 * 100 : 0, v: a2 / 255 * 100, a: u2 }; 31498 }; 31499 var b = function(r3) { 31500 var t2 = r3.h, n2 = r3.s, e2 = r3.v, u2 = r3.a; 31501 t2 = t2 / 360 * 6, n2 /= 100, e2 /= 100; 31502 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; 31503 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 }; 31504 }; 31505 var g = function(r3) { 31506 return { h: u(r3.h), s: e(r3.s, 0, 100), l: e(r3.l, 0, 100), a: e(r3.a) }; 31507 }; 31508 var d = function(r3) { 31509 return { h: n(r3.h), s: n(r3.s), l: n(r3.l), a: n(r3.a, 3) }; 31510 }; 31511 var f = function(r3) { 31512 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 })); 31513 var t2, n2, e2; 31514 }; 31515 var c = function(r3) { 31516 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 }; 31517 var t2, n2, e2, u2; 31518 }; 31519 var l = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; 31520 var p = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; 31521 var v = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; 31522 var m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; 31523 var y = { string: [[function(r3) { 31524 var t2 = i.exec(r3); 31525 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; 31526 }, "hex"], [function(r3) { 31527 var t2 = v.exec(r3) || m.exec(r3); 31528 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; 31529 }, "rgb"], [function(t2) { 31530 var n2 = l.exec(t2) || p.exec(t2); 31531 if (!n2) return null; 31532 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) }); 31533 return f(a2); 31534 }, "hsl"]], object: [[function(r3) { 31535 var n2 = r3.r, e2 = r3.g, u2 = r3.b, o2 = r3.a, i2 = void 0 === o2 ? 1 : o2; 31536 return t(n2) && t(e2) && t(u2) ? a({ r: Number(n2), g: Number(e2), b: Number(u2), a: Number(i2) }) : null; 31537 }, "rgb"], [function(r3) { 31538 var n2 = r3.h, e2 = r3.s, u2 = r3.l, a2 = r3.a, o2 = void 0 === a2 ? 1 : a2; 31539 if (!t(n2) || !t(e2) || !t(u2)) return null; 31540 var i2 = g({ h: Number(n2), s: Number(e2), l: Number(u2), a: Number(o2) }); 31541 return f(i2); 31542 }, "hsl"], [function(r3) { 31543 var n2 = r3.h, a2 = r3.s, o2 = r3.v, i2 = r3.a, s2 = void 0 === i2 ? 1 : i2; 31544 if (!t(n2) || !t(a2) || !t(o2)) return null; 31545 var h2 = (function(r4) { 31546 return { h: u(r4.h), s: e(r4.s, 0, 100), v: e(r4.v, 0, 100), a: e(r4.a) }; 31547 })({ h: Number(n2), s: Number(a2), v: Number(o2), a: Number(s2) }); 31548 return b(h2); 31549 }, "hsv"]] }; 31550 var N = function(r3, t2) { 31551 for (var n2 = 0; n2 < t2.length; n2++) { 31552 var e2 = t2[n2][0](r3); 31553 if (e2) return [e2, t2[n2][1]]; 31554 } 31555 return [null, void 0]; 31556 }; 31557 var x = function(r3) { 31558 return "string" == typeof r3 ? N(r3.trim(), y.string) : "object" == typeof r3 && null !== r3 ? N(r3, y.object) : [null, void 0]; 31559 }; 31560 var M = function(r3, t2) { 31561 var n2 = c(r3); 31562 return { h: n2.h, s: e(n2.s + 100 * t2, 0, 100), l: n2.l, a: n2.a }; 31563 }; 31564 var H = function(r3) { 31565 return (299 * r3.r + 587 * r3.g + 114 * r3.b) / 1e3 / 255; 31566 }; 31567 var $ = function(r3, t2) { 31568 var n2 = c(r3); 31569 return { h: n2.h, s: n2.s, l: e(n2.l + 100 * t2, 0, 100), a: n2.a }; 31570 }; 31571 var j = (function() { 31572 function r3(r4) { 31573 this.parsed = x(r4)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 }; 31574 } 31575 return r3.prototype.isValid = function() { 31576 return null !== this.parsed; 31577 }, r3.prototype.brightness = function() { 31578 return n(H(this.rgba), 2); 31579 }, r3.prototype.isDark = function() { 31580 return H(this.rgba) < 0.5; 31581 }, r3.prototype.isLight = function() { 31582 return H(this.rgba) >= 0.5; 31583 }, r3.prototype.toHex = function() { 31584 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; 31585 var r4, t2, e2, u2, a2, i2; 31586 }, r3.prototype.toRgb = function() { 31587 return o(this.rgba); 31588 }, r3.prototype.toRgbString = function() { 31589 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 + ")"; 31590 var r4, t2, n2, e2, u2; 31591 }, r3.prototype.toHsl = function() { 31592 return d(c(this.rgba)); 31593 }, r3.prototype.toHslString = function() { 31594 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 + "%)"; 31595 var r4, t2, n2, e2, u2; 31596 }, r3.prototype.toHsv = function() { 31597 return r4 = h(this.rgba), { h: n(r4.h), s: n(r4.s), v: n(r4.v), a: n(r4.a, 3) }; 31598 var r4; 31599 }, r3.prototype.invert = function() { 31600 return w({ r: 255 - (r4 = this.rgba).r, g: 255 - r4.g, b: 255 - r4.b, a: r4.a }); 31601 var r4; 31602 }, r3.prototype.saturate = function(r4) { 31603 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, r4)); 31604 }, r3.prototype.desaturate = function(r4) { 31605 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, -r4)); 31606 }, r3.prototype.grayscale = function() { 31607 return w(M(this.rgba, -1)); 31608 }, r3.prototype.lighten = function(r4) { 31609 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, r4)); 31610 }, r3.prototype.darken = function(r4) { 31611 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, -r4)); 31612 }, r3.prototype.rotate = function(r4) { 31613 return void 0 === r4 && (r4 = 15), this.hue(this.hue() + r4); 31614 }, r3.prototype.alpha = function(r4) { 31615 return "number" == typeof r4 ? w({ r: (t2 = this.rgba).r, g: t2.g, b: t2.b, a: r4 }) : n(this.rgba.a, 3); 31616 var t2; 31617 }, r3.prototype.hue = function(r4) { 31618 var t2 = c(this.rgba); 31619 return "number" == typeof r4 ? w({ h: r4, s: t2.s, l: t2.l, a: t2.a }) : n(t2.h); 31620 }, r3.prototype.isEqual = function(r4) { 31621 return this.toHex() === w(r4).toHex(); 31622 }, r3; 31623 })(); 31624 var w = function(r3) { 31625 return r3 instanceof j ? r3 : new j(r3); 31626 }; 31627 31628 // packages/dataviews/build-module/components/dataform-controls/color.mjs 31629 var import_components47 = __toESM(require_components(), 1); 31630 var import_element113 = __toESM(require_element(), 1); 31631 var import_i18n41 = __toESM(require_i18n(), 1); 31632 var import_jsx_runtime159 = __toESM(require_jsx_runtime(), 1); 31633 var { ValidatedInputControl: ValidatedInputControl3 } = unlock3(import_components47.privateApis); 31634 var ColorPickerDropdown = ({ 31635 color, 31636 onColorChange, 31637 disabled: disabled2 31638 }) => { 31639 const validColor = color && w(color).isValid() ? color : "#ffffff"; 31640 return /* @__PURE__ */ (0, import_jsx_runtime159.jsx)( 31641 import_components47.Dropdown, 31642 { 31643 className: "dataviews-controls__color-picker-dropdown", 31644 popoverProps: { resize: false }, 31645 renderToggle: ({ onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime159.jsx)( 31646 import_components47.Button, 31647 { 31648 onClick: onToggle, 31649 "aria-label": (0, import_i18n41.__)("Open color picker"), 31650 size: "small", 31651 disabled: disabled2, 31652 accessibleWhenDisabled: true, 31653 icon: () => /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(import_components47.ColorIndicator, { colorValue: validColor }) 31654 } 31655 ), 31656 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(import_components47.__experimentalDropdownContentWrapper, { paddingSize: "none", children: /* @__PURE__ */ (0, import_jsx_runtime159.jsx)( 31657 import_components47.ColorPicker, 31658 { 31659 color: validColor, 31660 onChange: onColorChange, 31661 enableAlpha: true 31662 } 31663 ) }) 31664 } 31665 ); 31666 }; 31667 function Color({ 31668 data, 31669 field, 31670 onChange, 31671 hideLabelFromVision, 31672 markWhenOptional, 31673 validity 31674 }) { 31675 const { label, placeholder, description, setValue, isValid: isValid2 } = field; 31676 const disabled2 = field.isDisabled({ item: data, field }); 31677 const value = field.getValue({ item: data }) || ""; 31678 const handleColorChange = (0, import_element113.useCallback)( 31679 (newColor) => { 31680 onChange(setValue({ item: data, value: newColor })); 31681 }, 31682 [data, onChange, setValue] 31683 ); 31684 const handleInputChange = (0, import_element113.useCallback)( 31685 (newValue) => { 31686 onChange(setValue({ item: data, value: newValue || "" })); 31687 }, 31688 [data, onChange, setValue] 31689 ); 31690 return /* @__PURE__ */ (0, import_jsx_runtime159.jsx)( 31691 ValidatedInputControl3, 31692 { 31693 required: !!field.isValid?.required, 31694 markWhenOptional, 31695 customValidity: getCustomValidity(isValid2, validity), 31696 label, 31697 placeholder, 31698 value, 31699 help: description, 31700 onChange: handleInputChange, 31701 hideLabelFromVision, 31702 type: "text", 31703 disabled: disabled2, 31704 prefix: /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(import_components47.__experimentalInputControlPrefixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime159.jsx)( 31705 ColorPickerDropdown, 31706 { 31707 color: value, 31708 onColorChange: handleColorChange, 31709 disabled: disabled2 31710 } 31711 ) }) 31712 } 31713 ); 31714 } 31715 31716 // packages/dataviews/build-module/components/dataform-controls/password.mjs 31717 var import_components48 = __toESM(require_components(), 1); 31718 var import_element114 = __toESM(require_element(), 1); 31719 var import_i18n42 = __toESM(require_i18n(), 1); 31720 var import_jsx_runtime160 = __toESM(require_jsx_runtime(), 1); 31721 function Password({ 31722 data, 31723 field, 31724 onChange, 31725 hideLabelFromVision, 31726 markWhenOptional, 31727 validity 31728 }) { 31729 const [isVisible2, setIsVisible] = (0, import_element114.useState)(false); 31730 const disabled2 = field.isDisabled({ item: data, field }); 31731 const toggleVisibility = (0, import_element114.useCallback)(() => { 31732 setIsVisible((prev) => !prev); 31733 }, []); 31734 return /* @__PURE__ */ (0, import_jsx_runtime160.jsx)( 31735 ValidatedText, 31736 { 31737 ...{ 31738 data, 31739 field, 31740 onChange, 31741 hideLabelFromVision, 31742 markWhenOptional, 31743 validity, 31744 type: isVisible2 ? "text" : "password", 31745 suffix: /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(import_components48.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime160.jsx)( 31746 import_components48.Button, 31747 { 31748 icon: isVisible2 ? unseen_default : seen_default, 31749 onClick: toggleVisibility, 31750 size: "small", 31751 label: isVisible2 ? (0, import_i18n42.__)("Hide password") : (0, import_i18n42.__)("Show password"), 31752 disabled: disabled2, 31753 accessibleWhenDisabled: true 31754 } 31755 ) }) 31756 } 31757 } 31758 ); 31759 } 31760 31761 // packages/dataviews/build-module/field-types/utils/has-elements.mjs 31762 function hasElements(field) { 31763 return Array.isArray(field.elements) && field.elements.length > 0 || typeof field.getElements === "function"; 31764 } 31765 31766 // packages/dataviews/build-module/components/dataform-controls/index.mjs 31767 var import_jsx_runtime161 = __toESM(require_jsx_runtime(), 1); 31768 var FORM_CONTROLS = { 31769 adaptiveSelect: AdaptiveSelect, 31770 array: ArrayControl, 31771 checkbox: Checkbox, 31772 color: Color, 31773 combobox: Combobox3, 31774 datetime: DateTime, 31775 date: DateControl, 31776 email: Email, 31777 telephone: Telephone, 31778 url: Url, 31779 integer: Integer, 31780 number: Number2, 31781 password: Password, 31782 radio: Radio, 31783 select: Select, 31784 text: Text3, 31785 toggle: Toggle, 31786 textarea: Textarea, 31787 richtext: RichText, 31788 toggleGroup: ToggleGroup 31789 }; 31790 function isEditConfig(value) { 31791 return value && typeof value === "object" && typeof value.control === "string"; 31792 } 31793 function createConfiguredControl(config) { 31794 const { control, ...controlConfig } = config; 31795 const BaseControlType = getControlByType(control); 31796 if (BaseControlType === null) { 31797 return null; 31798 } 31799 return function ConfiguredControl(props) { 31800 return /* @__PURE__ */ (0, import_jsx_runtime161.jsx)(BaseControlType, { ...props, config: controlConfig }); 31801 }; 31802 } 31803 function getControl(field, fallback) { 31804 if (typeof field.Edit === "function") { 31805 return field.Edit; 31806 } 31807 if (typeof field.Edit === "string") { 31808 return getControlByType(field.Edit); 31809 } 31810 if (isEditConfig(field.Edit)) { 31811 return createConfiguredControl(field.Edit); 31812 } 31813 if (hasElements(field) && field.type !== "array") { 31814 return getControlByType("adaptiveSelect"); 31815 } 31816 if (fallback === null) { 31817 return null; 31818 } 31819 return getControlByType(fallback); 31820 } 31821 function getControlByType(type) { 31822 if (Object.keys(FORM_CONTROLS).includes(type)) { 31823 return FORM_CONTROLS[type]; 31824 } 31825 return null; 31826 } 31827 31828 // packages/dataviews/build-module/field-types/utils/get-filter-by.mjs 31829 function getFilterBy(field, defaultOperators, validOperators) { 31830 if (field.filterBy === false) { 31831 return false; 31832 } 31833 const operators = field.filterBy?.operators?.filter( 31834 (op) => validOperators.includes(op) 31835 ) ?? defaultOperators; 31836 if (operators.length === 0) { 31837 return false; 31838 } 31839 return { 31840 isPrimary: !!field.filterBy?.isPrimary, 31841 operators 31842 }; 31843 } 31844 var get_filter_by_default = getFilterBy; 31845 31846 // packages/dataviews/build-module/field-types/utils/get-value-from-id.mjs 31847 var getValueFromId = (id) => ({ item }) => { 31848 const path = id.split("."); 31849 let value = item; 31850 for (const segment of path) { 31851 if (value.hasOwnProperty(segment)) { 31852 value = value[segment]; 31853 } else { 31854 value = void 0; 31855 } 31856 } 31857 return value; 31858 }; 31859 var get_value_from_id_default = getValueFromId; 31860 31861 // packages/dataviews/build-module/field-types/utils/set-value-from-id.mjs 31862 var setValueFromId = (id) => ({ value }) => { 31863 const path = id.split("."); 31864 const result = {}; 31865 let current = result; 31866 for (const segment of path.slice(0, -1)) { 31867 current[segment] = {}; 31868 current = current[segment]; 31869 } 31870 current[path.at(-1)] = value; 31871 return result; 31872 }; 31873 var set_value_from_id_default = setValueFromId; 31874 31875 // packages/dataviews/build-module/field-types/email.mjs 31876 var import_i18n43 = __toESM(require_i18n(), 1); 31877 31878 // packages/dataviews/build-module/field-types/utils/render-from-elements.mjs 31879 function RenderFromElements({ 31880 item, 31881 field 31882 }) { 31883 const { elements, isLoading } = useElements({ 31884 elements: field.elements, 31885 getElements: field.getElements 31886 }); 31887 const value = field.getValue({ item }); 31888 if (isLoading) { 31889 return value; 31890 } 31891 if (elements.length === 0) { 31892 return value; 31893 } 31894 return elements?.find((element) => element.value === value)?.label || field.getValue({ item }); 31895 } 31896 31897 // packages/dataviews/build-module/field-types/utils/render-default.mjs 31898 var import_jsx_runtime162 = __toESM(require_jsx_runtime(), 1); 31899 function render({ 31900 item, 31901 field 31902 }) { 31903 if (field.hasElements) { 31904 return /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(RenderFromElements, { item, field }); 31905 } 31906 return field.getValueFormatted({ item, field }); 31907 } 31908 31909 // packages/dataviews/build-module/field-types/utils/sort-text.mjs 31910 var sort_text_default = (a2, b2, direction) => { 31911 return direction === "asc" ? a2.localeCompare(b2) : b2.localeCompare(a2); 31912 }; 31913 31914 // packages/dataviews/build-module/field-types/utils/is-valid-required.mjs 31915 function isValidRequired(item, field) { 31916 const value = field.getValue({ item }); 31917 return ![void 0, "", null].includes(value); 31918 } 31919 31920 // packages/dataviews/build-module/field-types/utils/is-valid-min-length.mjs 31921 function isValidMinLength(item, field) { 31922 if (typeof field.isValid.minLength?.constraint !== "number") { 31923 return false; 31924 } 31925 const value = field.getValue({ item }); 31926 if ([void 0, "", null].includes(value)) { 31927 return true; 31928 } 31929 return String(value).length >= field.isValid.minLength.constraint; 31930 } 31931 31932 // packages/dataviews/build-module/field-types/utils/is-valid-max-length.mjs 31933 function isValidMaxLength(item, field) { 31934 if (typeof field.isValid.maxLength?.constraint !== "number") { 31935 return false; 31936 } 31937 const value = field.getValue({ item }); 31938 if ([void 0, "", null].includes(value)) { 31939 return true; 31940 } 31941 return String(value).length <= field.isValid.maxLength.constraint; 31942 } 31943 31944 // packages/dataviews/build-module/field-types/utils/is-valid-pattern.mjs 31945 function isValidPattern(item, field) { 31946 if (field.isValid.pattern?.constraint === void 0) { 31947 return true; 31948 } 31949 try { 31950 const regexp = new RegExp(field.isValid.pattern.constraint); 31951 const value = field.getValue({ item }); 31952 if ([void 0, "", null].includes(value)) { 31953 return true; 31954 } 31955 return regexp.test(String(value)); 31956 } catch { 31957 return false; 31958 } 31959 } 31960 31961 // packages/dataviews/build-module/field-types/utils/is-valid-elements.mjs 31962 function isValidElements(item, field) { 31963 const elements = field.elements ?? []; 31964 const validValues = elements.map((el) => el.value); 31965 if (validValues.length === 0) { 31966 return true; 31967 } 31968 const value = field.getValue({ item }); 31969 return [].concat(value).every((v2) => validValues.includes(v2)); 31970 } 31971 31972 // packages/dataviews/build-module/field-types/utils/get-value-formatted-default.mjs 31973 function getValueFormatted({ 31974 item, 31975 field 31976 }) { 31977 return field.getValue({ item }); 31978 } 31979 var get_value_formatted_default_default = getValueFormatted; 31980 31981 // packages/dataviews/build-module/field-types/email.mjs 31982 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])?)*$/; 31983 function isValidCustom(item, field) { 31984 const value = field.getValue({ item }); 31985 if (![void 0, "", null].includes(value) && !emailRegex.test(value)) { 31986 return (0, import_i18n43.__)("Value must be a valid email address."); 31987 } 31988 return null; 31989 } 31990 var email_default = { 31991 type: "email", 31992 render, 31993 Edit: "email", 31994 sort: sort_text_default, 31995 enableSorting: true, 31996 enableGlobalSearch: false, 31997 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE], 31998 validOperators: [ 31999 OPERATOR_IS, 32000 OPERATOR_IS_NOT, 32001 OPERATOR_CONTAINS, 32002 OPERATOR_NOT_CONTAINS, 32003 OPERATOR_STARTS_WITH, 32004 // Multiple selection 32005 OPERATOR_IS_ANY, 32006 OPERATOR_IS_NONE, 32007 OPERATOR_IS_ALL, 32008 OPERATOR_IS_NOT_ALL 32009 ], 32010 format: {}, 32011 getValueFormatted: get_value_formatted_default_default, 32012 validate: { 32013 required: isValidRequired, 32014 pattern: isValidPattern, 32015 minLength: isValidMinLength, 32016 maxLength: isValidMaxLength, 32017 elements: isValidElements, 32018 custom: isValidCustom 32019 } 32020 }; 32021 32022 // packages/dataviews/build-module/field-types/integer.mjs 32023 var import_i18n44 = __toESM(require_i18n(), 1); 32024 32025 // packages/dataviews/build-module/field-types/utils/sort-number.mjs 32026 var sort_number_default = (a2, b2, direction) => { 32027 return direction === "asc" ? a2 - b2 : b2 - a2; 32028 }; 32029 32030 // packages/dataviews/build-module/field-types/utils/is-valid-min.mjs 32031 function isValidMin(item, field) { 32032 if (typeof field.isValid.min?.constraint !== "number") { 32033 return false; 32034 } 32035 const value = field.getValue({ item }); 32036 if ([void 0, "", null].includes(value)) { 32037 return true; 32038 } 32039 return Number(value) >= field.isValid.min.constraint; 32040 } 32041 32042 // packages/dataviews/build-module/field-types/utils/is-valid-max.mjs 32043 function isValidMax(item, field) { 32044 if (typeof field.isValid.max?.constraint !== "number") { 32045 return false; 32046 } 32047 const value = field.getValue({ item }); 32048 if ([void 0, "", null].includes(value)) { 32049 return true; 32050 } 32051 return Number(value) <= field.isValid.max.constraint; 32052 } 32053 32054 // packages/dataviews/build-module/field-types/integer.mjs 32055 var format2 = { 32056 separatorThousand: "," 32057 }; 32058 function getValueFormatted2({ 32059 item, 32060 field 32061 }) { 32062 let value = field.getValue({ item }); 32063 if (value === null || value === void 0) { 32064 return ""; 32065 } 32066 value = Number(value); 32067 if (!Number.isFinite(value)) { 32068 return String(value); 32069 } 32070 let formatInteger; 32071 if (field.type !== "integer") { 32072 formatInteger = format2; 32073 } else { 32074 formatInteger = field.format; 32075 } 32076 const { separatorThousand } = formatInteger; 32077 const integerValue = Math.trunc(value); 32078 if (!separatorThousand) { 32079 return String(integerValue); 32080 } 32081 return String(integerValue).replace( 32082 /\B(?=(\d{3})+(?!\d))/g, 32083 separatorThousand 32084 ); 32085 } 32086 function isValidCustom2(item, field) { 32087 const value = field.getValue({ item }); 32088 if (![void 0, "", null].includes(value) && !Number.isInteger(value)) { 32089 return (0, import_i18n44.__)("Value must be an integer."); 32090 } 32091 return null; 32092 } 32093 var integer_default = { 32094 type: "integer", 32095 render, 32096 Edit: "integer", 32097 sort: sort_number_default, 32098 enableSorting: true, 32099 enableGlobalSearch: false, 32100 defaultOperators: [ 32101 OPERATOR_IS, 32102 OPERATOR_IS_NOT, 32103 OPERATOR_LESS_THAN, 32104 OPERATOR_GREATER_THAN, 32105 OPERATOR_LESS_THAN_OR_EQUAL, 32106 OPERATOR_GREATER_THAN_OR_EQUAL, 32107 OPERATOR_BETWEEN 32108 ], 32109 validOperators: [ 32110 // Single-selection 32111 OPERATOR_IS, 32112 OPERATOR_IS_NOT, 32113 OPERATOR_LESS_THAN, 32114 OPERATOR_GREATER_THAN, 32115 OPERATOR_LESS_THAN_OR_EQUAL, 32116 OPERATOR_GREATER_THAN_OR_EQUAL, 32117 OPERATOR_BETWEEN, 32118 // Multiple-selection 32119 OPERATOR_IS_ANY, 32120 OPERATOR_IS_NONE, 32121 OPERATOR_IS_ALL, 32122 OPERATOR_IS_NOT_ALL 32123 ], 32124 format: format2, 32125 getValueFormatted: getValueFormatted2, 32126 validate: { 32127 required: isValidRequired, 32128 min: isValidMin, 32129 max: isValidMax, 32130 elements: isValidElements, 32131 custom: isValidCustom2 32132 } 32133 }; 32134 32135 // packages/dataviews/build-module/field-types/number.mjs 32136 var import_i18n45 = __toESM(require_i18n(), 1); 32137 var format3 = { 32138 separatorThousand: ",", 32139 separatorDecimal: ".", 32140 decimals: 2 32141 }; 32142 function getValueFormatted3({ 32143 item, 32144 field 32145 }) { 32146 let value = field.getValue({ item }); 32147 if (value === null || value === void 0) { 32148 return ""; 32149 } 32150 value = Number(value); 32151 if (!Number.isFinite(value)) { 32152 return String(value); 32153 } 32154 let formatNumber; 32155 if (field.type !== "number") { 32156 formatNumber = format3; 32157 } else { 32158 formatNumber = field.format; 32159 } 32160 const { separatorThousand, separatorDecimal, decimals } = formatNumber; 32161 const fixedValue = value.toFixed(decimals); 32162 const [integerPart, decimalPart] = fixedValue.split("."); 32163 const formattedInteger = separatorThousand ? integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, separatorThousand) : integerPart; 32164 return decimals === 0 ? formattedInteger : formattedInteger + separatorDecimal + decimalPart; 32165 } 32166 function isEmpty(value) { 32167 return value === "" || value === void 0 || value === null; 32168 } 32169 function isValidCustom3(item, field) { 32170 const value = field.getValue({ item }); 32171 if (!isEmpty(value) && !Number.isFinite(value)) { 32172 return (0, import_i18n45.__)("Value must be a number."); 32173 } 32174 return null; 32175 } 32176 var number_default = { 32177 type: "number", 32178 render, 32179 Edit: "number", 32180 sort: sort_number_default, 32181 enableSorting: true, 32182 enableGlobalSearch: false, 32183 defaultOperators: [ 32184 OPERATOR_IS, 32185 OPERATOR_IS_NOT, 32186 OPERATOR_LESS_THAN, 32187 OPERATOR_GREATER_THAN, 32188 OPERATOR_LESS_THAN_OR_EQUAL, 32189 OPERATOR_GREATER_THAN_OR_EQUAL, 32190 OPERATOR_BETWEEN 32191 ], 32192 validOperators: [ 32193 // Single-selection 32194 OPERATOR_IS, 32195 OPERATOR_IS_NOT, 32196 OPERATOR_LESS_THAN, 32197 OPERATOR_GREATER_THAN, 32198 OPERATOR_LESS_THAN_OR_EQUAL, 32199 OPERATOR_GREATER_THAN_OR_EQUAL, 32200 OPERATOR_BETWEEN, 32201 // Multiple-selection 32202 OPERATOR_IS_ANY, 32203 OPERATOR_IS_NONE, 32204 OPERATOR_IS_ALL, 32205 OPERATOR_IS_NOT_ALL 32206 ], 32207 format: format3, 32208 getValueFormatted: getValueFormatted3, 32209 validate: { 32210 required: isValidRequired, 32211 min: isValidMin, 32212 max: isValidMax, 32213 elements: isValidElements, 32214 custom: isValidCustom3 32215 } 32216 }; 32217 32218 // packages/dataviews/build-module/field-types/text.mjs 32219 var text_default = { 32220 type: "text", 32221 render, 32222 Edit: "text", 32223 sort: sort_text_default, 32224 enableSorting: true, 32225 enableGlobalSearch: false, 32226 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE], 32227 validOperators: [ 32228 // Single selection 32229 OPERATOR_IS, 32230 OPERATOR_IS_NOT, 32231 OPERATOR_CONTAINS, 32232 OPERATOR_NOT_CONTAINS, 32233 OPERATOR_STARTS_WITH, 32234 // Multiple selection 32235 OPERATOR_IS_ANY, 32236 OPERATOR_IS_NONE, 32237 OPERATOR_IS_ALL, 32238 OPERATOR_IS_NOT_ALL 32239 ], 32240 format: {}, 32241 getValueFormatted: get_value_formatted_default_default, 32242 validate: { 32243 required: isValidRequired, 32244 pattern: isValidPattern, 32245 minLength: isValidMinLength, 32246 maxLength: isValidMaxLength, 32247 elements: isValidElements 32248 } 32249 }; 32250 32251 // packages/dataviews/build-module/field-types/datetime.mjs 32252 var import_date7 = __toESM(require_date(), 1); 32253 32254 // packages/dataviews/build-module/field-types/utils/is-valid-date-boundary.mjs 32255 var import_date6 = __toESM(require_date(), 1); 32256 function parseDateLike(value) { 32257 if (!value) { 32258 return null; 32259 } 32260 if (!isValid(new Date(value))) { 32261 return null; 32262 } 32263 const parsed = (0, import_date6.getDate)(value); 32264 return parsed && isValid(parsed) ? parsed : null; 32265 } 32266 function validateDateLikeBoundary(item, field, boundary) { 32267 const constraint = field.isValid[boundary]?.constraint; 32268 if (typeof constraint !== "string") { 32269 return false; 32270 } 32271 const value = field.getValue({ item }); 32272 const boundaryValue = Array.isArray(value) ? value[boundary === "min" ? 0 : value.length - 1] : value; 32273 if (boundaryValue === void 0 || boundaryValue === null || boundaryValue === "") { 32274 return true; 32275 } 32276 const parsedConstraint = parseDateLike(constraint); 32277 const parsedValue = parseDateLike(String(boundaryValue)); 32278 return !!parsedConstraint && !!parsedValue && (boundary === "min" ? parsedValue.getTime() >= parsedConstraint.getTime() : parsedValue.getTime() <= parsedConstraint.getTime()); 32279 } 32280 function isValidMinDate(item, field) { 32281 return validateDateLikeBoundary(item, field, "min"); 32282 } 32283 function isValidMaxDate(item, field) { 32284 return validateDateLikeBoundary(item, field, "max"); 32285 } 32286 32287 // packages/dataviews/build-module/field-types/datetime.mjs 32288 var format4 = { 32289 datetime: (0, import_date7.getSettings)().formats.datetime, 32290 weekStartsOn: (0, import_date7.getSettings)().l10n.startOfWeek 32291 }; 32292 function getValueFormatted4({ 32293 item, 32294 field 32295 }) { 32296 const value = field.getValue({ item }); 32297 if (["", void 0, null].includes(value)) { 32298 return ""; 32299 } 32300 let formatDatetime; 32301 if (field.type !== "datetime") { 32302 formatDatetime = format4; 32303 } else { 32304 formatDatetime = field.format; 32305 } 32306 return (0, import_date7.dateI18n)(formatDatetime.datetime, (0, import_date7.getDate)(value)); 32307 } 32308 var sort = (a2, b2, direction) => { 32309 const timeA = new Date(a2).getTime(); 32310 const timeB = new Date(b2).getTime(); 32311 return direction === "asc" ? timeA - timeB : timeB - timeA; 32312 }; 32313 var datetime_default = { 32314 type: "datetime", 32315 render, 32316 Edit: "datetime", 32317 sort, 32318 enableSorting: true, 32319 enableGlobalSearch: false, 32320 defaultOperators: [ 32321 OPERATOR_ON, 32322 OPERATOR_NOT_ON, 32323 OPERATOR_BEFORE, 32324 OPERATOR_AFTER, 32325 OPERATOR_BEFORE_INC, 32326 OPERATOR_AFTER_INC, 32327 OPERATOR_IN_THE_PAST, 32328 OPERATOR_OVER 32329 ], 32330 validOperators: [ 32331 OPERATOR_ON, 32332 OPERATOR_NOT_ON, 32333 OPERATOR_BEFORE, 32334 OPERATOR_AFTER, 32335 OPERATOR_BEFORE_INC, 32336 OPERATOR_AFTER_INC, 32337 OPERATOR_IN_THE_PAST, 32338 OPERATOR_OVER 32339 ], 32340 format: format4, 32341 getValueFormatted: getValueFormatted4, 32342 validate: { 32343 required: isValidRequired, 32344 elements: isValidElements, 32345 min: isValidMinDate, 32346 max: isValidMaxDate 32347 } 32348 }; 32349 32350 // packages/dataviews/build-module/field-types/date.mjs 32351 var import_date8 = __toESM(require_date(), 1); 32352 var format5 = { 32353 date: (0, import_date8.getSettings)().formats.date, 32354 weekStartsOn: (0, import_date8.getSettings)().l10n.startOfWeek 32355 }; 32356 function getValueFormatted5({ 32357 item, 32358 field 32359 }) { 32360 const value = field.getValue({ item }); 32361 if (["", void 0, null].includes(value)) { 32362 return ""; 32363 } 32364 let formatDate2; 32365 if (field.type !== "date") { 32366 formatDate2 = format5; 32367 } else { 32368 formatDate2 = field.format; 32369 } 32370 return (0, import_date8.dateI18n)(formatDate2.date, (0, import_date8.getDate)(value)); 32371 } 32372 var sort2 = (a2, b2, direction) => { 32373 const timeA = new Date(a2).getTime(); 32374 const timeB = new Date(b2).getTime(); 32375 return direction === "asc" ? timeA - timeB : timeB - timeA; 32376 }; 32377 var date_default = { 32378 type: "date", 32379 render, 32380 Edit: "date", 32381 sort: sort2, 32382 enableSorting: true, 32383 enableGlobalSearch: false, 32384 defaultOperators: [ 32385 OPERATOR_ON, 32386 OPERATOR_NOT_ON, 32387 OPERATOR_BEFORE, 32388 OPERATOR_AFTER, 32389 OPERATOR_BEFORE_INC, 32390 OPERATOR_AFTER_INC, 32391 OPERATOR_IN_THE_PAST, 32392 OPERATOR_OVER, 32393 OPERATOR_BETWEEN 32394 ], 32395 validOperators: [ 32396 OPERATOR_ON, 32397 OPERATOR_NOT_ON, 32398 OPERATOR_BEFORE, 32399 OPERATOR_AFTER, 32400 OPERATOR_BEFORE_INC, 32401 OPERATOR_AFTER_INC, 32402 OPERATOR_IN_THE_PAST, 32403 OPERATOR_OVER, 32404 OPERATOR_BETWEEN 32405 ], 32406 format: format5, 32407 getValueFormatted: getValueFormatted5, 32408 validate: { 32409 required: isValidRequired, 32410 elements: isValidElements, 32411 min: isValidMinDate, 32412 max: isValidMaxDate 32413 } 32414 }; 32415 32416 // packages/dataviews/build-module/field-types/boolean.mjs 32417 var import_i18n46 = __toESM(require_i18n(), 1); 32418 32419 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-bool.mjs 32420 function isValidRequiredForBool(item, field) { 32421 const value = field.getValue({ item }); 32422 return value === true; 32423 } 32424 32425 // packages/dataviews/build-module/field-types/boolean.mjs 32426 function getValueFormatted6({ 32427 item, 32428 field 32429 }) { 32430 const value = field.getValue({ item }); 32431 if (value === true) { 32432 return (0, import_i18n46.__)("True"); 32433 } 32434 if (value === false) { 32435 return (0, import_i18n46.__)("False"); 32436 } 32437 return ""; 32438 } 32439 function isValidCustom4(item, field) { 32440 const value = field.getValue({ item }); 32441 if (![void 0, "", null].includes(value) && ![true, false].includes(value)) { 32442 return (0, import_i18n46.__)("Value must be true, false, or undefined"); 32443 } 32444 return null; 32445 } 32446 var sort3 = (a2, b2, direction) => { 32447 const boolA = Boolean(a2); 32448 const boolB = Boolean(b2); 32449 if (boolA === boolB) { 32450 return 0; 32451 } 32452 if (direction === "asc") { 32453 return boolA ? 1 : -1; 32454 } 32455 return boolA ? -1 : 1; 32456 }; 32457 var boolean_default = { 32458 type: "boolean", 32459 render, 32460 Edit: "checkbox", 32461 sort: sort3, 32462 validate: { 32463 required: isValidRequiredForBool, 32464 elements: isValidElements, 32465 custom: isValidCustom4 32466 }, 32467 enableSorting: true, 32468 enableGlobalSearch: false, 32469 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT], 32470 validOperators: [OPERATOR_IS, OPERATOR_IS_NOT], 32471 format: {}, 32472 getValueFormatted: getValueFormatted6 32473 }; 32474 32475 // packages/dataviews/build-module/field-types/media.mjs 32476 var media_default = { 32477 type: "media", 32478 render: () => null, 32479 Edit: null, 32480 sort: () => 0, 32481 enableSorting: false, 32482 enableGlobalSearch: false, 32483 defaultOperators: [], 32484 validOperators: [], 32485 format: {}, 32486 getValueFormatted: get_value_formatted_default_default, 32487 // cannot validate any constraint, so 32488 // the only available validation for the field author 32489 // would be providing a custom validator. 32490 validate: {} 32491 }; 32492 32493 // packages/dataviews/build-module/field-types/array.mjs 32494 var import_i18n47 = __toESM(require_i18n(), 1); 32495 32496 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-array.mjs 32497 function isValidRequiredForArray(item, field) { 32498 const value = field.getValue({ item }); 32499 return Array.isArray(value) && value.length > 0 && value.every( 32500 (element) => ![void 0, "", null].includes(element) 32501 ); 32502 } 32503 32504 // packages/dataviews/build-module/field-types/array.mjs 32505 function getValueFormatted7({ 32506 item, 32507 field 32508 }) { 32509 const value = field.getValue({ item }); 32510 const arr = Array.isArray(value) ? value : []; 32511 return arr.join(", "); 32512 } 32513 function render2({ item, field }) { 32514 return getValueFormatted7({ item, field }); 32515 } 32516 function isValidCustom5(item, field) { 32517 const value = field.getValue({ item }); 32518 if (![void 0, "", null].includes(value) && !Array.isArray(value)) { 32519 return (0, import_i18n47.__)("Value must be an array."); 32520 } 32521 if (!value.every((v2) => typeof v2 === "string")) { 32522 return (0, import_i18n47.__)("Every value must be a string."); 32523 } 32524 return null; 32525 } 32526 var sort4 = (a2, b2, direction) => { 32527 const arrA = Array.isArray(a2) ? a2 : []; 32528 const arrB = Array.isArray(b2) ? b2 : []; 32529 if (arrA.length !== arrB.length) { 32530 return direction === "asc" ? arrA.length - arrB.length : arrB.length - arrA.length; 32531 } 32532 const joinedA = arrA.join(","); 32533 const joinedB = arrB.join(","); 32534 return direction === "asc" ? joinedA.localeCompare(joinedB) : joinedB.localeCompare(joinedA); 32535 }; 32536 var array_default = { 32537 type: "array", 32538 render: render2, 32539 Edit: "array", 32540 sort: sort4, 32541 enableSorting: true, 32542 enableGlobalSearch: false, 32543 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE], 32544 validOperators: [ 32545 OPERATOR_IS_ANY, 32546 OPERATOR_IS_NONE, 32547 OPERATOR_IS_ALL, 32548 OPERATOR_IS_NOT_ALL 32549 ], 32550 format: {}, 32551 getValueFormatted: getValueFormatted7, 32552 validate: { 32553 required: isValidRequiredForArray, 32554 elements: isValidElements, 32555 custom: isValidCustom5 32556 } 32557 }; 32558 32559 // packages/dataviews/build-module/field-types/password.mjs 32560 function getValueFormatted8({ 32561 item, 32562 field 32563 }) { 32564 return field.getValue({ item }) ? "••••••••" : ""; 32565 } 32566 var password_default = { 32567 type: "password", 32568 render, 32569 Edit: "password", 32570 sort: () => 0, 32571 // Passwords should not be sortable for security reasons 32572 enableSorting: false, 32573 enableGlobalSearch: false, 32574 defaultOperators: [], 32575 validOperators: [], 32576 format: {}, 32577 getValueFormatted: getValueFormatted8, 32578 validate: { 32579 required: isValidRequired, 32580 pattern: isValidPattern, 32581 minLength: isValidMinLength, 32582 maxLength: isValidMaxLength, 32583 elements: isValidElements 32584 } 32585 }; 32586 32587 // packages/dataviews/build-module/field-types/telephone.mjs 32588 var telephone_default = { 32589 type: "telephone", 32590 render, 32591 Edit: "telephone", 32592 sort: sort_text_default, 32593 enableSorting: true, 32594 enableGlobalSearch: false, 32595 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE], 32596 validOperators: [ 32597 OPERATOR_IS, 32598 OPERATOR_IS_NOT, 32599 OPERATOR_CONTAINS, 32600 OPERATOR_NOT_CONTAINS, 32601 OPERATOR_STARTS_WITH, 32602 // Multiple selection 32603 OPERATOR_IS_ANY, 32604 OPERATOR_IS_NONE, 32605 OPERATOR_IS_ALL, 32606 OPERATOR_IS_NOT_ALL 32607 ], 32608 format: {}, 32609 getValueFormatted: get_value_formatted_default_default, 32610 validate: { 32611 required: isValidRequired, 32612 pattern: isValidPattern, 32613 minLength: isValidMinLength, 32614 maxLength: isValidMaxLength, 32615 elements: isValidElements 32616 } 32617 }; 32618 32619 // packages/dataviews/build-module/field-types/color.mjs 32620 var import_i18n48 = __toESM(require_i18n(), 1); 32621 var import_jsx_runtime163 = __toESM(require_jsx_runtime(), 1); 32622 function render3({ item, field }) { 32623 if (field.hasElements) { 32624 return /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(RenderFromElements, { item, field }); 32625 } 32626 const value = get_value_formatted_default_default({ item, field }); 32627 if (!value || !w(value).isValid()) { 32628 return value; 32629 } 32630 return /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [ 32631 /* @__PURE__ */ (0, import_jsx_runtime163.jsx)( 32632 "div", 32633 { 32634 style: { 32635 width: "16px", 32636 height: "16px", 32637 borderRadius: "50%", 32638 backgroundColor: value, 32639 border: "1px solid #ddd", 32640 flexShrink: 0 32641 } 32642 } 32643 ), 32644 /* @__PURE__ */ (0, import_jsx_runtime163.jsx)("span", { children: value }) 32645 ] }); 32646 } 32647 function isValidCustom6(item, field) { 32648 const value = field.getValue({ item }); 32649 if (![void 0, "", null].includes(value) && !w(value).isValid()) { 32650 return (0, import_i18n48.__)("Value must be a valid color."); 32651 } 32652 return null; 32653 } 32654 var sort5 = (a2, b2, direction) => { 32655 const colorA = w(a2); 32656 const colorB = w(b2); 32657 if (!colorA.isValid() && !colorB.isValid()) { 32658 return 0; 32659 } 32660 if (!colorA.isValid()) { 32661 return direction === "asc" ? 1 : -1; 32662 } 32663 if (!colorB.isValid()) { 32664 return direction === "asc" ? -1 : 1; 32665 } 32666 const hslA = colorA.toHsl(); 32667 const hslB = colorB.toHsl(); 32668 if (hslA.h !== hslB.h) { 32669 return direction === "asc" ? hslA.h - hslB.h : hslB.h - hslA.h; 32670 } 32671 if (hslA.s !== hslB.s) { 32672 return direction === "asc" ? hslA.s - hslB.s : hslB.s - hslA.s; 32673 } 32674 return direction === "asc" ? hslA.l - hslB.l : hslB.l - hslA.l; 32675 }; 32676 var color_default = { 32677 type: "color", 32678 render: render3, 32679 Edit: "color", 32680 sort: sort5, 32681 enableSorting: true, 32682 enableGlobalSearch: false, 32683 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE], 32684 validOperators: [ 32685 OPERATOR_IS, 32686 OPERATOR_IS_NOT, 32687 OPERATOR_IS_ANY, 32688 OPERATOR_IS_NONE 32689 ], 32690 format: {}, 32691 getValueFormatted: get_value_formatted_default_default, 32692 validate: { 32693 required: isValidRequired, 32694 elements: isValidElements, 32695 custom: isValidCustom6 32696 } 32697 }; 32698 32699 // packages/dataviews/build-module/field-types/url.mjs 32700 var url_default = { 32701 type: "url", 32702 render, 32703 Edit: "url", 32704 sort: sort_text_default, 32705 enableSorting: true, 32706 enableGlobalSearch: false, 32707 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE], 32708 validOperators: [ 32709 OPERATOR_IS, 32710 OPERATOR_IS_NOT, 32711 OPERATOR_CONTAINS, 32712 OPERATOR_NOT_CONTAINS, 32713 OPERATOR_STARTS_WITH, 32714 // Multiple selection 32715 OPERATOR_IS_ANY, 32716 OPERATOR_IS_NONE, 32717 OPERATOR_IS_ALL, 32718 OPERATOR_IS_NOT_ALL 32719 ], 32720 format: {}, 32721 getValueFormatted: get_value_formatted_default_default, 32722 validate: { 32723 required: isValidRequired, 32724 pattern: isValidPattern, 32725 minLength: isValidMinLength, 32726 maxLength: isValidMaxLength, 32727 elements: isValidElements 32728 } 32729 }; 32730 32731 // packages/dataviews/build-module/field-types/no-type.mjs 32732 var sort6 = (a2, b2, direction) => { 32733 if (typeof a2 === "number" && typeof b2 === "number") { 32734 return sort_number_default(a2, b2, direction); 32735 } 32736 return sort_text_default(a2, b2, direction); 32737 }; 32738 var no_type_default = { 32739 // type: no type for this one 32740 render, 32741 Edit: null, 32742 sort: sort6, 32743 enableSorting: true, 32744 enableGlobalSearch: false, 32745 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT], 32746 validOperators: getAllOperatorNames(), 32747 format: {}, 32748 getValueFormatted: get_value_formatted_default_default, 32749 validate: { 32750 required: isValidRequired, 32751 elements: isValidElements 32752 } 32753 }; 32754 32755 // packages/dataviews/build-module/field-types/utils/get-is-valid.mjs 32756 function supportsNumericRangeConstraint(type) { 32757 return type === "integer" || type === "number"; 32758 } 32759 function supportsDateRangeConstraint(type) { 32760 return type === "date" || type === "datetime"; 32761 } 32762 function normalizeRangeRule(value, fieldType, key) { 32763 const validator = fieldType.validate[key]; 32764 if (validator && (typeof value === "number" && supportsNumericRangeConstraint(fieldType.type) || typeof value === "string" && supportsDateRangeConstraint(fieldType.type))) { 32765 return { constraint: value, validate: validator }; 32766 } 32767 return void 0; 32768 } 32769 function getIsValid(field, fieldType) { 32770 const rules = field.isValid; 32771 let required; 32772 if (rules?.required === true && fieldType.validate.required !== void 0) { 32773 required = { 32774 constraint: true, 32775 validate: fieldType.validate.required 32776 }; 32777 } 32778 let elements; 32779 if ((rules?.elements === true || // elements is enabled unless the field opts-out 32780 rules?.elements === void 0 && (!!field.elements || !!field.getElements)) && fieldType.validate.elements !== void 0) { 32781 elements = { 32782 constraint: true, 32783 validate: fieldType.validate.elements 32784 }; 32785 } 32786 const min2 = normalizeRangeRule(rules?.min, fieldType, "min"); 32787 const max2 = normalizeRangeRule(rules?.max, fieldType, "max"); 32788 const minLengthValue = rules?.minLength; 32789 let minLength; 32790 if (typeof minLengthValue === "number" && fieldType.validate.minLength !== void 0) { 32791 minLength = { 32792 constraint: minLengthValue, 32793 validate: fieldType.validate.minLength 32794 }; 32795 } 32796 const maxLengthValue = rules?.maxLength; 32797 let maxLength; 32798 if (typeof maxLengthValue === "number" && fieldType.validate.maxLength !== void 0) { 32799 maxLength = { 32800 constraint: maxLengthValue, 32801 validate: fieldType.validate.maxLength 32802 }; 32803 } 32804 const patternValue = rules?.pattern; 32805 let pattern; 32806 if (patternValue !== void 0 && fieldType.validate.pattern !== void 0) { 32807 pattern = { 32808 constraint: patternValue, 32809 validate: fieldType.validate.pattern 32810 }; 32811 } 32812 const custom = rules?.custom ?? fieldType.validate.custom; 32813 return { 32814 required, 32815 elements, 32816 min: min2, 32817 max: max2, 32818 minLength, 32819 maxLength, 32820 pattern, 32821 custom 32822 }; 32823 } 32824 32825 // packages/dataviews/build-module/field-types/utils/get-filter.mjs 32826 function getFilter(fieldType) { 32827 return fieldType.validOperators.reduce((accumulator, operator) => { 32828 const operatorObj = getOperatorByName(operator); 32829 if (operatorObj?.filter) { 32830 accumulator[operator] = operatorObj.filter; 32831 } 32832 return accumulator; 32833 }, {}); 32834 } 32835 32836 // packages/dataviews/build-module/field-types/utils/get-format.mjs 32837 function getFormat(field, fieldType) { 32838 return { 32839 ...fieldType.format, 32840 ...field.format 32841 }; 32842 } 32843 var get_format_default = getFormat; 32844 32845 // packages/dataviews/build-module/field-types/index.mjs 32846 function getFieldTypeByName(type) { 32847 const found = [ 32848 email_default, 32849 integer_default, 32850 number_default, 32851 text_default, 32852 datetime_default, 32853 date_default, 32854 boolean_default, 32855 media_default, 32856 array_default, 32857 password_default, 32858 telephone_default, 32859 color_default, 32860 url_default 32861 ].find((fieldType) => fieldType?.type === type); 32862 if (!!found) { 32863 return found; 32864 } 32865 return no_type_default; 32866 } 32867 function normalizeFields(fields) { 32868 return fields.map((field) => { 32869 const fieldType = getFieldTypeByName(field.type); 32870 const getValue = field.getValue || get_value_from_id_default(field.id); 32871 const sort7 = function(a2, b2, direction) { 32872 const aValue = getValue({ item: a2 }); 32873 const bValue = getValue({ item: b2 }); 32874 return field.sort ? field.sort(aValue, bValue, direction) : fieldType.sort(aValue, bValue, direction); 32875 }; 32876 return { 32877 id: field.id, 32878 label: field.label || field.id, 32879 header: field.header || field.label || field.id, 32880 description: field.description, 32881 placeholder: field.placeholder, 32882 getValue, 32883 setValue: field.setValue || set_value_from_id_default(field.id), 32884 elements: field.elements, 32885 getElements: field.getElements, 32886 hasElements: hasElements(field), 32887 isVisible: field.isVisible, 32888 isDisabled: typeof field.isDisabled === "function" ? field.isDisabled : () => !!field.isDisabled, 32889 enableHiding: field.enableHiding ?? true, 32890 readOnly: field.readOnly ?? false, 32891 // The type provides defaults for the following props 32892 type: fieldType.type, 32893 render: field.render ?? fieldType.render, 32894 Edit: getControl(field, fieldType.Edit), 32895 sort: sort7, 32896 enableSorting: field.enableSorting ?? fieldType.enableSorting, 32897 enableGlobalSearch: field.enableGlobalSearch ?? fieldType.enableGlobalSearch, 32898 isValid: getIsValid(field, fieldType), 32899 filterBy: get_filter_by_default( 32900 field, 32901 fieldType.defaultOperators, 32902 fieldType.validOperators 32903 ), 32904 filter: getFilter(fieldType), 32905 format: get_format_default(field, fieldType), 32906 getValueFormatted: field.getValueFormatted ?? fieldType.getValueFormatted 32907 }; 32908 }); 32909 } 32910 32911 // packages/dataviews/build-module/hooks/use-data.mjs 32912 var import_element115 = __toESM(require_element(), 1); 32913 function useData({ 32914 view, 32915 data: shownData, 32916 getItemId, 32917 isLoading, 32918 paginationInfo, 32919 selection 32920 }) { 32921 const isInfiniteScrollEnabled = view.infiniteScrollEnabled; 32922 const [hasInitiallyLoaded, setHasInitiallyLoaded] = (0, import_element115.useState)( 32923 !isLoading 32924 ); 32925 (0, import_element115.useEffect)(() => { 32926 if (!isLoading) { 32927 setHasInitiallyLoaded(true); 32928 } 32929 }, [isLoading]); 32930 const previousDataRef = (0, import_element115.useRef)(shownData); 32931 const previousPaginationInfoRef = (0, import_element115.useRef)(paginationInfo); 32932 (0, import_element115.useEffect)(() => { 32933 if (!isLoading) { 32934 previousDataRef.current = shownData; 32935 previousPaginationInfoRef.current = paginationInfo; 32936 } 32937 }, [shownData, isLoading, paginationInfo]); 32938 const [visibleEntries, setVisibleEntries] = (0, import_element115.useState)([]); 32939 const positionMapRef = (0, import_element115.useRef)(/* @__PURE__ */ new Map()); 32940 const allLoadedRecordsRef = (0, import_element115.useRef)([]); 32941 const prevViewParamsRef = (0, import_element115.useRef)({ 32942 search: void 0, 32943 filters: void 0, 32944 perPage: void 0 32945 }); 32946 const scrollDirectionRef = (0, import_element115.useRef)(void 0); 32947 const prevStartPositionRef = (0, import_element115.useRef)(void 0); 32948 const hasInitializedRef = (0, import_element115.useRef)(false); 32949 const allLoadedRecords = (0, import_element115.useMemo)(() => { 32950 if (view.startPosition !== void 0 && prevStartPositionRef.current !== void 0) { 32951 if (view.startPosition < prevStartPositionRef.current) { 32952 scrollDirectionRef.current = "up"; 32953 } else if (view.startPosition > prevStartPositionRef.current) { 32954 scrollDirectionRef.current = "down"; 32955 } 32956 } 32957 prevStartPositionRef.current = view.startPosition; 32958 const currentFiltersKey = JSON.stringify(view.filters ?? []); 32959 const prevFiltersKey = prevViewParamsRef.current.filters; 32960 const shouldReset = !hasInitializedRef.current || !view.infiniteScrollEnabled || view.search !== prevViewParamsRef.current.search || currentFiltersKey !== prevFiltersKey || view.perPage !== prevViewParamsRef.current.perPage; 32961 hasInitializedRef.current = true; 32962 prevViewParamsRef.current = { 32963 search: view.search, 32964 filters: currentFiltersKey, 32965 perPage: view.perPage 32966 }; 32967 if (shouldReset) { 32968 positionMapRef.current.clear(); 32969 scrollDirectionRef.current = void 0; 32970 const startPosition = view.search ? 1 : view.startPosition ?? 1; 32971 const records = shownData.map((record, index2) => { 32972 const position = startPosition + index2; 32973 positionMapRef.current.set(getItemId(record), position); 32974 return { 32975 ...record, 32976 position 32977 }; 32978 }); 32979 allLoadedRecordsRef.current = records; 32980 return records; 32981 } 32982 const prev = allLoadedRecordsRef.current; 32983 const shownDataIds = new Set(shownData.map(getItemId)); 32984 const scrollDirection = scrollDirectionRef.current; 32985 const basePosition = view.search ? 1 : view.startPosition ?? 1; 32986 const newRecords = shownData.map((record, index2) => { 32987 const itemId = getItemId(record); 32988 const position = view.infiniteScrollEnabled ? basePosition + index2 : void 0; 32989 if (position !== void 0) { 32990 positionMapRef.current.set(itemId, position); 32991 } 32992 return { 32993 ...record, 32994 position 32995 }; 32996 }); 32997 if (newRecords.length === 0) { 32998 return prev; 32999 } 33000 const prevWithoutDuplicates = prev.filter( 33001 (record) => !shownDataIds.has(getItemId(record)) 33002 ); 33003 const allRecords = scrollDirection === "up" ? [...newRecords, ...prevWithoutDuplicates] : [...prevWithoutDuplicates, ...newRecords]; 33004 allRecords.sort((a2, b2) => { 33005 const posA = a2.position; 33006 const posB = b2.position; 33007 return posA - posB; 33008 }); 33009 let result = allRecords; 33010 if (visibleEntries.length > 0) { 33011 const visibleMin = Math.min(...visibleEntries); 33012 const visibleMax = Math.max(...visibleEntries); 33013 const buffer = 20; 33014 const recordPositions = allRecords.map( 33015 (r3) => r3.position 33016 ); 33017 const minRecordPos = Math.min(...recordPositions); 33018 const maxRecordPos = Math.max(...recordPositions); 33019 const hasOverlap = !(maxRecordPos < visibleMin - buffer || minRecordPos > visibleMax + buffer); 33020 if (hasOverlap) { 33021 result = allRecords.filter((record) => { 33022 const itemId = getItemId(record); 33023 const isSelected2 = selection?.includes(itemId); 33024 if (isSelected2) { 33025 return true; 33026 } 33027 const itemPosition = record.position; 33028 if (scrollDirection === "up") { 33029 return itemPosition <= visibleMax + buffer; 33030 } else if (scrollDirection === "down") { 33031 return itemPosition >= visibleMin - buffer; 33032 } 33033 return itemPosition >= visibleMin - buffer && itemPosition <= visibleMax + buffer; 33034 }); 33035 } 33036 } 33037 allLoadedRecordsRef.current = result; 33038 return result; 33039 }, [ 33040 shownData, 33041 view.search, 33042 view.filters, 33043 view.perPage, 33044 view.startPosition, 33045 view.infiniteScrollEnabled, 33046 visibleEntries, 33047 selection, 33048 getItemId 33049 ]); 33050 if (!isInfiniteScrollEnabled) { 33051 const dataToReturn = isLoading && previousDataRef.current?.length ? previousDataRef.current : shownData; 33052 return { 33053 data: dataToReturn.map((item) => ({ 33054 ...item, 33055 position: void 0 33056 })), 33057 paginationInfo: isLoading && previousDataRef.current?.length ? previousPaginationInfoRef.current : paginationInfo, 33058 hasInitiallyLoaded, 33059 setVisibleEntries: void 0 33060 }; 33061 } 33062 return { 33063 data: allLoadedRecords, 33064 paginationInfo, 33065 hasInitiallyLoaded, 33066 setVisibleEntries 33067 }; 33068 } 33069 33070 // packages/dataviews/build-module/hooks/use-infinite-scroll.mjs 33071 var import_element116 = __toESM(require_element(), 1); 33072 var import_compose15 = __toESM(require_compose(), 1); 33073 function captureAnchorElement(container, anchorElementRef, direction) { 33074 const containerRect = container.getBoundingClientRect(); 33075 const centerY = containerRect.top + containerRect.height / 2; 33076 const items = Array.from(container.querySelectorAll("[aria-posinset]")); 33077 if (items.length === 0) { 33078 return false; 33079 } 33080 const bestAnchor = items.reduce((best, item) => { 33081 const itemRect = item.getBoundingClientRect(); 33082 const itemCenterY = itemRect.top + itemRect.height / 2; 33083 const distance = Math.abs(itemCenterY - centerY); 33084 const bestRect = best.getBoundingClientRect(); 33085 const bestCenterY = bestRect.top + bestRect.height / 2; 33086 const bestDistance = Math.abs(bestCenterY - centerY); 33087 return distance < bestDistance ? item : best; 33088 }); 33089 const posinset = Number(bestAnchor.getAttribute("aria-posinset")); 33090 const anchorRect = bestAnchor.getBoundingClientRect(); 33091 anchorElementRef.current = { 33092 posinset, 33093 viewportOffset: anchorRect.top - containerRect.top, 33094 scrollTop: container.scrollTop, 33095 direction 33096 }; 33097 return true; 33098 } 33099 function useInfiniteScroll({ 33100 view, 33101 onChangeView, 33102 isLoading, 33103 paginationInfo, 33104 containerRef, 33105 setVisibleEntries 33106 }) { 33107 const anchorElementRef = (0, import_element116.useRef)(null); 33108 const viewRef = (0, import_element116.useRef)(view); 33109 const isLoadingRef = (0, import_element116.useRef)(isLoading); 33110 const onChangeViewRef = (0, import_element116.useRef)(onChangeView); 33111 const totalItemsRef = (0, import_element116.useRef)(paginationInfo.totalItems); 33112 (0, import_element116.useLayoutEffect)(() => { 33113 viewRef.current = view; 33114 isLoadingRef.current = isLoading; 33115 onChangeViewRef.current = onChangeView; 33116 totalItemsRef.current = paginationInfo.totalItems; 33117 }, [view, isLoading, onChangeView, paginationInfo.totalItems]); 33118 const intersectionObserverCallback = (0, import_element116.useCallback)( 33119 (entries) => { 33120 if (!setVisibleEntries) { 33121 return; 33122 } 33123 setVisibleEntries((prev) => { 33124 const newVisibleEntries = new Set(prev); 33125 let hasChanged = false; 33126 entries.forEach((entry) => { 33127 const posInSet = Number( 33128 entry.target?.attributes?.getNamedItem( 33129 "aria-posinset" 33130 )?.value 33131 ); 33132 if (isNaN(posInSet)) { 33133 return; 33134 } 33135 if (entry.isIntersecting) { 33136 if (!newVisibleEntries.has(posInSet)) { 33137 newVisibleEntries.add(posInSet); 33138 hasChanged = true; 33139 } 33140 } else if (newVisibleEntries.has(posInSet)) { 33141 newVisibleEntries.delete(posInSet); 33142 hasChanged = true; 33143 } 33144 }); 33145 return hasChanged ? Array.from(newVisibleEntries).sort() : prev; 33146 }); 33147 }, 33148 [setVisibleEntries] 33149 ); 33150 (0, import_element116.useLayoutEffect)(() => { 33151 const container = containerRef.current; 33152 const anchor = anchorElementRef.current; 33153 if (!container || !view.infiniteScrollEnabled || !anchor || isLoading) { 33154 return; 33155 } 33156 const anchorElement = container.querySelector( 33157 `[aria-posinset="$anchor.posinset}"]` 33158 ); 33159 if (anchorElement) { 33160 const containerRect = container.getBoundingClientRect(); 33161 const anchorRect = anchorElement.getBoundingClientRect(); 33162 const currentOffset = anchorRect.top - containerRect.top; 33163 const scrollAdjustment = currentOffset - anchor.viewportOffset + (container.scrollTop - anchor.scrollTop); 33164 if (Math.abs(scrollAdjustment) > 1) { 33165 container.scrollTop += scrollAdjustment; 33166 } 33167 } 33168 anchorElementRef.current = null; 33169 }, [containerRef, isLoading, view.infiniteScrollEnabled]); 33170 const intersectionObserverRef = (0, import_element116.useRef)( 33171 null 33172 ); 33173 (0, import_element116.useEffect)(() => { 33174 if (!view.infiniteScrollEnabled || !intersectionObserverCallback) { 33175 if (intersectionObserverRef.current) { 33176 intersectionObserverRef.current.disconnect(); 33177 intersectionObserverRef.current = null; 33178 } 33179 return; 33180 } 33181 intersectionObserverRef.current = new IntersectionObserver( 33182 intersectionObserverCallback, 33183 { root: null, rootMargin: "0px", threshold: 0.1 } 33184 ); 33185 return () => { 33186 if (intersectionObserverRef.current) { 33187 intersectionObserverRef.current.disconnect(); 33188 intersectionObserverRef.current = null; 33189 } 33190 }; 33191 }, [view.infiniteScrollEnabled, intersectionObserverCallback]); 33192 (0, import_element116.useEffect)(() => { 33193 if (!view.infiniteScrollEnabled || !containerRef.current) { 33194 return; 33195 } 33196 let lastScrollTop = 0; 33197 const BOTTOM_THRESHOLD = 600; 33198 const TOP_THRESHOLD = 800; 33199 const handleScroll = (0, import_compose15.throttle)((event) => { 33200 const currentView = viewRef.current; 33201 const totalItems = totalItemsRef.current; 33202 const target = event.target; 33203 const scrollTop = target.scrollTop; 33204 const scrollHeight = target.scrollHeight; 33205 const clientHeight = target.clientHeight; 33206 const scrollDirection = scrollTop > lastScrollTop ? "down" : "up"; 33207 lastScrollTop = scrollTop; 33208 if (isLoadingRef.current) { 33209 return; 33210 } 33211 const currentStartPosition = currentView.startPosition || 1; 33212 const batchSize = currentView.perPage || 10; 33213 const currentEndPosition = Math.min( 33214 currentStartPosition + batchSize, 33215 totalItems 33216 ); 33217 if (scrollDirection === "down" && scrollTop + clientHeight >= scrollHeight - BOTTOM_THRESHOLD) { 33218 if (currentEndPosition < totalItems) { 33219 const newStartPosition = currentEndPosition; 33220 captureAnchorElement(target, anchorElementRef, "down"); 33221 onChangeViewRef.current({ 33222 ...currentView, 33223 startPosition: newStartPosition 33224 }); 33225 } 33226 } 33227 if (scrollDirection === "up" && scrollTop <= TOP_THRESHOLD) { 33228 if (currentStartPosition > 1) { 33229 const calculatedStartPosition = currentStartPosition - batchSize; 33230 const newStartPosition = calculatedStartPosition < 6 ? 1 : calculatedStartPosition; 33231 captureAnchorElement(target, anchorElementRef, "up"); 33232 onChangeViewRef.current({ 33233 ...currentView, 33234 startPosition: newStartPosition 33235 }); 33236 } 33237 } 33238 }, 50); 33239 const container = containerRef.current; 33240 container.addEventListener("scroll", handleScroll); 33241 return () => { 33242 container.removeEventListener("scroll", handleScroll); 33243 handleScroll.cancel(); 33244 }; 33245 }, [containerRef, view.infiniteScrollEnabled]); 33246 return { 33247 intersectionObserver: intersectionObserverRef.current 33248 }; 33249 } 33250 33251 // packages/dataviews/build-module/dataviews/index.mjs 33252 var import_jsx_runtime164 = __toESM(require_jsx_runtime(), 1); 33253 var defaultGetItemId = (item) => item.id; 33254 var defaultIsItemClickable = () => true; 33255 var EMPTY_ARRAY7 = []; 33256 var DEFAULT_LAYOUTS = { table: {}, grid: {}, list: {} }; 33257 var dataViewsLayouts = VIEW_LAYOUTS.filter( 33258 (viewLayout) => !viewLayout.isPicker 33259 ); 33260 function DefaultUI({ 33261 header, 33262 search = true, 33263 searchLabel = void 0 33264 }) { 33265 const { view } = (0, import_element117.useContext)(dataviews_context_default); 33266 const isInfiniteScroll = view.infiniteScrollEnabled; 33267 return /* @__PURE__ */ (0, import_jsx_runtime164.jsxs)(import_jsx_runtime164.Fragment, { children: [ 33268 /* @__PURE__ */ (0, import_jsx_runtime164.jsxs)( 33269 Stack, 33270 { 33271 direction: "row", 33272 align: "top", 33273 justify: "space-between", 33274 className: clsx_default("dataviews__view-actions", { 33275 "dataviews__view-actions--infinite-scroll": isInfiniteScroll 33276 }), 33277 gap: "xs", 33278 children: [ 33279 /* @__PURE__ */ (0, import_jsx_runtime164.jsxs)( 33280 Stack, 33281 { 33282 direction: "row", 33283 justify: "start", 33284 gap: "sm", 33285 className: "dataviews__search", 33286 children: [ 33287 search && /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(dataviews_search_default, { label: searchLabel }), 33288 /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(toggle_default, {}) 33289 ] 33290 } 33291 ), 33292 /* @__PURE__ */ (0, import_jsx_runtime164.jsxs)(Stack, { direction: "row", gap: "xs", style: { flexShrink: 0 }, children: [ 33293 /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(dataviews_view_config_default, {}), 33294 header 33295 ] }) 33296 ] 33297 } 33298 ), 33299 /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(filters_toggled_default, { className: "dataviews-filters__container" }), 33300 /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(DataViewsLayout, {}), 33301 /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(DataViewsFooter, {}) 33302 ] }); 33303 } 33304 function DataViews({ 33305 view, 33306 onChangeView, 33307 fields, 33308 search = true, 33309 searchLabel = void 0, 33310 actions = EMPTY_ARRAY7, 33311 data, 33312 getItemId = defaultGetItemId, 33313 getItemLevel, 33314 isLoading = false, 33315 paginationInfo, 33316 defaultLayouts: defaultLayoutsProperty = DEFAULT_LAYOUTS, 33317 selection: selectionProperty, 33318 onChangeSelection, 33319 onClickItem, 33320 renderItemLink, 33321 isItemClickable = defaultIsItemClickable, 33322 header, 33323 children, 33324 config = { perPageSizes: [10, 20, 50, 100] }, 33325 empty, 33326 onReset 33327 }) { 33328 const [selectionState, setSelectionState] = (0, import_element117.useState)([]); 33329 const isUncontrolled = selectionProperty === void 0 || onChangeSelection === void 0; 33330 const selection = isUncontrolled ? selectionState : selectionProperty; 33331 const { 33332 data: displayData, 33333 paginationInfo: displayPaginationInfo, 33334 hasInitiallyLoaded, 33335 setVisibleEntries 33336 } = useData({ 33337 view, 33338 data, 33339 getItemId, 33340 isLoading, 33341 selection, 33342 paginationInfo 33343 }); 33344 const containerRef = (0, import_element117.useRef)(null); 33345 const [containerWidth, setContainerWidth] = (0, import_element117.useState)(0); 33346 const resizeObserverRef = (0, import_compose16.useResizeObserver)( 33347 (resizeObserverEntries) => { 33348 setContainerWidth( 33349 resizeObserverEntries[0].borderBoxSize[0].inlineSize 33350 ); 33351 }, 33352 { box: "border-box" } 33353 ); 33354 const [openedFilter, setOpenedFilter] = (0, import_element117.useState)(null); 33355 function setSelectionWithChange(value) { 33356 const newValue = typeof value === "function" ? value(selection) : value; 33357 if (isUncontrolled) { 33358 setSelectionState(newValue); 33359 } 33360 if (onChangeSelection) { 33361 onChangeSelection(newValue); 33362 } 33363 } 33364 const _fields = (0, import_element117.useMemo)(() => normalizeFields(fields), [fields]); 33365 const _selection = (0, import_element117.useMemo)(() => { 33366 if (view.infiniteScrollEnabled) { 33367 return selection; 33368 } 33369 return selection.filter( 33370 (id) => data.some((item) => getItemId(item) === id) 33371 ); 33372 }, [selection, data, getItemId, view.infiniteScrollEnabled]); 33373 const filters = use_filters_default(_fields, view); 33374 const hasPrimaryOrLockedFilters = (0, import_element117.useMemo)( 33375 () => (filters || []).some( 33376 (filter) => filter.isPrimary || filter.isLocked 33377 ), 33378 [filters] 33379 ); 33380 const [isShowingFilter, setIsShowingFilter] = (0, import_element117.useState)( 33381 hasPrimaryOrLockedFilters 33382 ); 33383 const { intersectionObserver } = useInfiniteScroll({ 33384 view, 33385 onChangeView, 33386 isLoading, 33387 paginationInfo, 33388 containerRef, 33389 setVisibleEntries 33390 }); 33391 (0, import_element117.useEffect)(() => { 33392 if (hasPrimaryOrLockedFilters && !isShowingFilter) { 33393 setIsShowingFilter(true); 33394 } 33395 }, [hasPrimaryOrLockedFilters, isShowingFilter]); 33396 const defaultLayouts3 = (0, import_element117.useMemo)( 33397 () => Object.fromEntries( 33398 Object.entries(defaultLayoutsProperty).filter(([layoutType]) => { 33399 return dataViewsLayouts.some( 33400 (viewLayout) => viewLayout.type === layoutType 33401 ); 33402 }).map(([key, value]) => [ 33403 key, 33404 value === true ? {} : value 33405 ]) 33406 ), 33407 [defaultLayoutsProperty] 33408 ); 33409 if (!defaultLayouts3[view.type]) { 33410 return null; 33411 } 33412 return /* @__PURE__ */ (0, import_jsx_runtime164.jsx)( 33413 dataviews_context_default.Provider, 33414 { 33415 value: { 33416 view, 33417 onChangeView, 33418 fields: _fields, 33419 actions, 33420 data: displayData, 33421 isLoading, 33422 paginationInfo: displayPaginationInfo, 33423 selection: _selection, 33424 onChangeSelection: setSelectionWithChange, 33425 openedFilter, 33426 setOpenedFilter, 33427 getItemId, 33428 getItemLevel, 33429 isItemClickable, 33430 onClickItem, 33431 renderItemLink, 33432 containerWidth, 33433 containerRef, 33434 resizeObserverRef, 33435 defaultLayouts: defaultLayouts3, 33436 filters, 33437 isShowingFilter, 33438 setIsShowingFilter, 33439 config, 33440 empty, 33441 hasInitiallyLoaded, 33442 onReset, 33443 intersectionObserver 33444 }, 33445 children: /* @__PURE__ */ (0, import_jsx_runtime164.jsx)("div", { className: "dataviews-wrapper", children: children ?? /* @__PURE__ */ (0, import_jsx_runtime164.jsx)( 33446 DefaultUI, 33447 { 33448 header, 33449 search, 33450 searchLabel 33451 } 33452 ) }) 33453 } 33454 ); 33455 } 33456 var DataViewsSubComponents = DataViews; 33457 DataViewsSubComponents.BulkActionToolbar = BulkActionsFooter; 33458 DataViewsSubComponents.Filters = filters_default; 33459 DataViewsSubComponents.FiltersToggled = filters_toggled_default; 33460 DataViewsSubComponents.FiltersToggle = toggle_default; 33461 DataViewsSubComponents.Layout = DataViewsLayout; 33462 DataViewsSubComponents.LayoutSwitcher = ViewTypeMenu; 33463 DataViewsSubComponents.Pagination = DataViewsPagination; 33464 DataViewsSubComponents.Search = dataviews_search_default; 33465 DataViewsSubComponents.ViewConfig = DataviewsViewConfigDropdown; 33466 DataViewsSubComponents.Footer = DataViewsFooter; 33467 var dataviews_default = DataViewsSubComponents; 33468 33469 // packages/dataviews/build-module/dataform/index.mjs 33470 var import_element129 = __toESM(require_element(), 1); 33471 33472 // packages/dataviews/build-module/components/dataform-context/index.mjs 33473 var import_element118 = __toESM(require_element(), 1); 33474 var import_jsx_runtime165 = __toESM(require_jsx_runtime(), 1); 33475 var DataFormContext = (0, import_element118.createContext)({ 33476 fields: [] 33477 }); 33478 DataFormContext.displayName = "DataFormContext"; 33479 function DataFormProvider({ 33480 fields, 33481 children 33482 }) { 33483 return /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(DataFormContext.Provider, { value: { fields }, children }); 33484 } 33485 var dataform_context_default = DataFormContext; 33486 33487 // packages/dataviews/build-module/components/dataform-layouts/data-form-layout.mjs 33488 var import_element128 = __toESM(require_element(), 1); 33489 33490 // packages/dataviews/build-module/components/dataform-layouts/regular/index.mjs 33491 var import_element119 = __toESM(require_element(), 1); 33492 var import_components49 = __toESM(require_components(), 1); 33493 33494 // packages/dataviews/build-module/components/dataform-layouts/normalize-form.mjs 33495 var import_i18n49 = __toESM(require_i18n(), 1); 33496 var DEFAULT_LAYOUT = { 33497 type: "regular", 33498 labelPosition: "top" 33499 }; 33500 var normalizeCardSummaryField = (sum) => { 33501 if (typeof sum === "string") { 33502 return [{ id: sum, visibility: "when-collapsed" }]; 33503 } 33504 return sum.map((item) => { 33505 if (typeof item === "string") { 33506 return { id: item, visibility: "when-collapsed" }; 33507 } 33508 return { id: item.id, visibility: item.visibility }; 33509 }); 33510 }; 33511 function normalizeLayout(layout) { 33512 let normalizedLayout = DEFAULT_LAYOUT; 33513 if (layout?.type === "regular") { 33514 normalizedLayout = { 33515 type: "regular", 33516 labelPosition: layout?.labelPosition ?? "top" 33517 }; 33518 } else if (layout?.type === "panel") { 33519 const summary = layout.summary ?? []; 33520 const normalizedSummary = Array.isArray(summary) ? summary : [summary]; 33521 const openAs = layout?.openAs; 33522 let normalizedOpenAs; 33523 if (typeof openAs === "object" && openAs.type === "modal") { 33524 normalizedOpenAs = { 33525 type: "modal", 33526 applyLabel: openAs.applyLabel?.trim() || (0, import_i18n49.__)("Apply"), 33527 cancelLabel: openAs.cancelLabel?.trim() || (0, import_i18n49.__)("Cancel") 33528 }; 33529 } else if (openAs === "modal") { 33530 normalizedOpenAs = { 33531 type: "modal", 33532 applyLabel: (0, import_i18n49.__)("Apply"), 33533 cancelLabel: (0, import_i18n49.__)("Cancel") 33534 }; 33535 } else { 33536 normalizedOpenAs = { type: "dropdown" }; 33537 } 33538 normalizedLayout = { 33539 type: "panel", 33540 labelPosition: layout?.labelPosition ?? "side", 33541 openAs: normalizedOpenAs, 33542 summary: normalizedSummary, 33543 editVisibility: layout?.editVisibility ?? "on-hover" 33544 }; 33545 } else if (layout?.type === "card") { 33546 if (layout.withHeader === false) { 33547 normalizedLayout = { 33548 type: "card", 33549 withHeader: false, 33550 isOpened: true, 33551 summary: [], 33552 isCollapsible: false 33553 }; 33554 } else { 33555 const summary = layout.summary ?? []; 33556 normalizedLayout = { 33557 type: "card", 33558 withHeader: true, 33559 isOpened: typeof layout.isOpened === "boolean" ? layout.isOpened : true, 33560 summary: normalizeCardSummaryField(summary), 33561 isCollapsible: layout.isCollapsible === void 0 ? true : layout.isCollapsible 33562 }; 33563 } 33564 } else if (layout?.type === "row") { 33565 normalizedLayout = { 33566 type: "row", 33567 alignment: layout?.alignment ?? "center", 33568 styles: layout?.styles ?? {} 33569 }; 33570 } else if (layout?.type === "details") { 33571 normalizedLayout = { 33572 type: "details", 33573 summary: layout?.summary ?? "" 33574 }; 33575 } 33576 return normalizedLayout; 33577 } 33578 function normalizeForm(form) { 33579 const normalizedFormLayout = normalizeLayout(form?.layout); 33580 const normalizedFields = (form.fields ?? []).map( 33581 (field) => { 33582 if (typeof field === "string") { 33583 return { 33584 id: field, 33585 layout: normalizedFormLayout 33586 }; 33587 } 33588 const fieldLayout = field.layout ? normalizeLayout(field.layout) : normalizedFormLayout; 33589 return { 33590 id: field.id, 33591 layout: fieldLayout, 33592 ...!!field.label && { label: field.label }, 33593 ...!!field.description && { 33594 description: field.description 33595 }, 33596 ..."children" in field && Array.isArray(field.children) && { 33597 children: normalizeForm({ 33598 fields: field.children, 33599 layout: DEFAULT_LAYOUT 33600 }).fields 33601 } 33602 }; 33603 } 33604 ); 33605 return { 33606 layout: normalizedFormLayout, 33607 fields: normalizedFields 33608 }; 33609 } 33610 var normalize_form_default = normalizeForm; 33611 33612 // packages/dataviews/build-module/components/dataform-layouts/regular/index.mjs 33613 var import_jsx_runtime166 = __toESM(require_jsx_runtime(), 1); 33614 function Header4({ title }) { 33615 return /* @__PURE__ */ (0, import_jsx_runtime166.jsx)( 33616 Stack, 33617 { 33618 direction: "column", 33619 className: "dataforms-layouts-regular__header", 33620 gap: "lg", 33621 children: /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(Stack, { direction: "row", align: "center", children: /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(import_components49.__experimentalHeading, { level: 2, size: 13, children: title }) }) 33622 } 33623 ); 33624 } 33625 function FormRegularField({ 33626 data, 33627 field, 33628 onChange, 33629 hideLabelFromVision, 33630 markWhenOptional, 33631 validity 33632 }) { 33633 const { fields } = (0, import_element119.useContext)(dataform_context_default); 33634 const layout = field.layout; 33635 const form = (0, import_element119.useMemo)( 33636 () => ({ 33637 layout: DEFAULT_LAYOUT, 33638 fields: !!field.children ? field.children : [] 33639 }), 33640 [field] 33641 ); 33642 if (!!field.children) { 33643 return /* @__PURE__ */ (0, import_jsx_runtime166.jsxs)(import_jsx_runtime166.Fragment, { children: [ 33644 !hideLabelFromVision && field.label && /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(Header4, { title: field.label }), 33645 /* @__PURE__ */ (0, import_jsx_runtime166.jsx)( 33646 DataFormLayout, 33647 { 33648 data, 33649 form, 33650 onChange, 33651 validity: validity?.children 33652 } 33653 ) 33654 ] }); 33655 } 33656 const labelPosition = layout.labelPosition; 33657 const fieldDefinition = fields.find( 33658 (fieldDef) => fieldDef.id === field.id 33659 ); 33660 if (!fieldDefinition || !fieldDefinition.Edit) { 33661 return null; 33662 } 33663 if (labelPosition === "side") { 33664 return /* @__PURE__ */ (0, import_jsx_runtime166.jsxs)( 33665 Stack, 33666 { 33667 direction: "row", 33668 className: "dataforms-layouts-regular__field", 33669 gap: "sm", 33670 children: [ 33671 /* @__PURE__ */ (0, import_jsx_runtime166.jsx)( 33672 "div", 33673 { 33674 className: clsx_default( 33675 "dataforms-layouts-regular__field-label", 33676 `dataforms-layouts-regular__field-label--label-position-$labelPosition}` 33677 ), 33678 children: /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(import_components49.BaseControl.VisualLabel, { children: fieldDefinition.label }) 33679 } 33680 ), 33681 /* @__PURE__ */ (0, import_jsx_runtime166.jsx)("div", { className: "dataforms-layouts-regular__field-control", children: fieldDefinition.readOnly === true ? /* @__PURE__ */ (0, import_jsx_runtime166.jsx)( 33682 fieldDefinition.render, 33683 { 33684 item: data, 33685 field: fieldDefinition 33686 } 33687 ) : /* @__PURE__ */ (0, import_jsx_runtime166.jsx)( 33688 fieldDefinition.Edit, 33689 { 33690 data, 33691 field: fieldDefinition, 33692 onChange, 33693 hideLabelFromVision: true, 33694 markWhenOptional, 33695 validity 33696 }, 33697 fieldDefinition.id 33698 ) }) 33699 ] 33700 } 33701 ); 33702 } 33703 return /* @__PURE__ */ (0, import_jsx_runtime166.jsx)("div", { className: "dataforms-layouts-regular__field", children: fieldDefinition.readOnly === true ? /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(import_jsx_runtime166.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime166.jsxs)(import_jsx_runtime166.Fragment, { children: [ 33704 !hideLabelFromVision && labelPosition !== "none" && /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(import_components49.BaseControl.VisualLabel, { children: fieldDefinition.label }), 33705 /* @__PURE__ */ (0, import_jsx_runtime166.jsx)( 33706 fieldDefinition.render, 33707 { 33708 item: data, 33709 field: fieldDefinition 33710 } 33711 ) 33712 ] }) }) : /* @__PURE__ */ (0, import_jsx_runtime166.jsx)( 33713 fieldDefinition.Edit, 33714 { 33715 data, 33716 field: fieldDefinition, 33717 onChange, 33718 hideLabelFromVision: labelPosition === "none" ? true : hideLabelFromVision, 33719 markWhenOptional, 33720 validity 33721 } 33722 ) }); 33723 } 33724 33725 // packages/dataviews/build-module/components/dataform-layouts/panel/modal.mjs 33726 var import_deepmerge2 = __toESM(require_cjs(), 1); 33727 var import_components52 = __toESM(require_components(), 1); 33728 var import_element124 = __toESM(require_element(), 1); 33729 var import_compose18 = __toESM(require_compose(), 1); 33730 33731 // packages/dataviews/build-module/components/dataform-layouts/panel/summary-button.mjs 33732 var import_components51 = __toESM(require_components(), 1); 33733 var import_i18n50 = __toESM(require_i18n(), 1); 33734 var import_compose17 = __toESM(require_compose(), 1); 33735 var import_element120 = __toESM(require_element(), 1); 33736 33737 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/get-label-classname.mjs 33738 function getLabelClassName(labelPosition, showError) { 33739 return clsx_default( 33740 "dataforms-layouts-panel__field-label", 33741 `dataforms-layouts-panel__field-label--label-position-$labelPosition}`, 33742 { "has-error": showError } 33743 ); 33744 } 33745 var get_label_classname_default = getLabelClassName; 33746 33747 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/get-label-content.mjs 33748 var import_components50 = __toESM(require_components(), 1); 33749 var import_jsx_runtime167 = __toESM(require_jsx_runtime(), 1); 33750 function getLabelContent(showError, errorMessage, fieldLabel) { 33751 return showError ? /* @__PURE__ */ (0, import_jsx_runtime167.jsxs)(tooltip_exports.Root, { children: [ 33752 /* @__PURE__ */ (0, import_jsx_runtime167.jsx)( 33753 tooltip_exports.Trigger, 33754 { 33755 render: /* @__PURE__ */ (0, import_jsx_runtime167.jsxs)("span", { className: "dataforms-layouts-panel__field-label-error-content", children: [ 33756 /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(import_components50.Icon, { icon: error_default, size: 16 }), 33757 /* @__PURE__ */ (0, import_jsx_runtime167.jsxs)(VisuallyHidden, { children: [ 33758 errorMessage, 33759 ": " 33760 ] }), 33761 fieldLabel 33762 ] }) 33763 } 33764 ), 33765 /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(tooltip_exports.Popup, { children: errorMessage }) 33766 ] }) : fieldLabel; 33767 } 33768 var get_label_content_default = getLabelContent; 33769 33770 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/get-first-validation-error.mjs 33771 function getFirstValidationError(validity) { 33772 if (!validity) { 33773 return void 0; 33774 } 33775 const validityRules = Object.keys(validity).filter( 33776 (key) => key !== "children" 33777 ); 33778 for (const key of validityRules) { 33779 const rule = validity[key]; 33780 if (rule === void 0) { 33781 continue; 33782 } 33783 if (rule.type === "invalid") { 33784 if (rule.message) { 33785 return rule.message; 33786 } 33787 if (key === "required") { 33788 return "A required field is empty"; 33789 } 33790 return "Unidentified validation error"; 33791 } 33792 } 33793 if (validity.children) { 33794 for (const childValidity of Object.values(validity.children)) { 33795 const childError = getFirstValidationError(childValidity); 33796 if (childError) { 33797 return childError; 33798 } 33799 } 33800 } 33801 return void 0; 33802 } 33803 var get_first_validation_error_default = getFirstValidationError; 33804 33805 // packages/dataviews/build-module/components/dataform-layouts/panel/summary-button.mjs 33806 var import_jsx_runtime168 = __toESM(require_jsx_runtime(), 1); 33807 function SummaryButton({ 33808 data, 33809 field, 33810 fieldLabel, 33811 summaryFields, 33812 validity, 33813 touched, 33814 disabled: disabled2, 33815 isOpen, 33816 onClick 33817 }) { 33818 const { labelPosition, editVisibility } = field.layout; 33819 const errorMessage = get_first_validation_error_default(validity); 33820 const showError = touched && !!errorMessage; 33821 const labelClassName = get_label_classname_default(labelPosition, showError); 33822 const labelContent = get_label_content_default(showError, errorMessage, fieldLabel); 33823 const className = clsx_default( 33824 "dataforms-layouts-panel__field-trigger", 33825 `dataforms-layouts-panel__field-trigger--label-$labelPosition}`, 33826 { 33827 "is-disabled": disabled2, 33828 "dataforms-layouts-panel__field-trigger--edit-always": editVisibility === "always" 33829 } 33830 ); 33831 const controlId = (0, import_compose17.useInstanceId)( 33832 SummaryButton, 33833 "dataforms-layouts-panel__field-control" 33834 ); 33835 const ariaLabel = showError ? (0, import_i18n50.sprintf)( 33836 // translators: %s: Field name. 33837 (0, import_i18n50._x)("Edit %s (has errors)", "field"), 33838 fieldLabel || "" 33839 ) : (0, import_i18n50.sprintf)( 33840 // translators: %s: Field name. 33841 (0, import_i18n50._x)("Edit %s", "field"), 33842 fieldLabel || "" 33843 ); 33844 const rowRef = (0, import_element120.useRef)(null); 33845 const editButtonRef = (0, import_element120.useRef)(null); 33846 const handleRowClick = (event) => { 33847 if (!isOpen && event.detail < 2 && !editButtonRef.current?.contains(event.target) && rowRef.current?.ownerDocument.defaultView?.getSelection()?.toString()) { 33848 return; 33849 } 33850 onClick(); 33851 }; 33852 const handleKeyDown = (event) => { 33853 if (event.target === event.currentTarget && (event.key === "Enter" || event.key === " ")) { 33854 event.preventDefault(); 33855 onClick(); 33856 } 33857 }; 33858 return /* @__PURE__ */ (0, import_jsx_runtime168.jsxs)( 33859 "div", 33860 { 33861 ref: rowRef, 33862 className, 33863 onClick: !disabled2 ? handleRowClick : void 0, 33864 onKeyDown: !disabled2 ? handleKeyDown : void 0, 33865 children: [ 33866 labelPosition !== "none" && /* @__PURE__ */ (0, import_jsx_runtime168.jsx)("span", { className: labelClassName, children: labelContent }), 33867 labelPosition === "none" && showError && /* @__PURE__ */ (0, import_jsx_runtime168.jsxs)(tooltip_exports.Root, { children: [ 33868 /* @__PURE__ */ (0, import_jsx_runtime168.jsx)( 33869 tooltip_exports.Trigger, 33870 { 33871 render: /* @__PURE__ */ (0, import_jsx_runtime168.jsx)( 33872 "span", 33873 { 33874 className: "dataforms-layouts-panel__field-label-error-content", 33875 role: "img", 33876 "aria-label": errorMessage, 33877 children: /* @__PURE__ */ (0, import_jsx_runtime168.jsx)(import_components51.Icon, { icon: error_default, size: 16 }) 33878 } 33879 ) 33880 } 33881 ), 33882 /* @__PURE__ */ (0, import_jsx_runtime168.jsx)(tooltip_exports.Popup, { children: errorMessage }) 33883 ] }), 33884 /* @__PURE__ */ (0, import_jsx_runtime168.jsx)( 33885 "span", 33886 { 33887 id: `$controlId}`, 33888 className: "dataforms-layouts-panel__field-control", 33889 children: summaryFields.length > 1 ? /* @__PURE__ */ (0, import_jsx_runtime168.jsx)( 33890 "span", 33891 { 33892 style: { 33893 display: "flex", 33894 flexDirection: "column", 33895 alignItems: "flex-start", 33896 width: "100%", 33897 gap: "2px" 33898 }, 33899 children: summaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime168.jsx)( 33900 "span", 33901 { 33902 style: { width: "100%" }, 33903 children: /* @__PURE__ */ (0, import_jsx_runtime168.jsx)( 33904 summaryField.render, 33905 { 33906 item: data, 33907 field: summaryField 33908 } 33909 ) 33910 }, 33911 summaryField.id 33912 )) 33913 } 33914 ) : summaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime168.jsx)( 33915 summaryField.render, 33916 { 33917 item: data, 33918 field: summaryField 33919 }, 33920 summaryField.id 33921 )) 33922 } 33923 ), 33924 !disabled2 && /* @__PURE__ */ (0, import_jsx_runtime168.jsx)( 33925 import_components51.Button, 33926 { 33927 ref: editButtonRef, 33928 className: "dataforms-layouts-panel__field-trigger-icon", 33929 label: ariaLabel, 33930 icon: pencil_default, 33931 size: "small", 33932 "aria-expanded": isOpen, 33933 "aria-haspopup": "dialog", 33934 "aria-describedby": `$controlId}` 33935 } 33936 ) 33937 ] 33938 } 33939 ); 33940 } 33941 33942 // packages/dataviews/build-module/hooks/use-form-validity.mjs 33943 var import_deepmerge = __toESM(require_cjs(), 1); 33944 var import_es62 = __toESM(require_es6(), 1); 33945 var import_element121 = __toESM(require_element(), 1); 33946 var import_i18n51 = __toESM(require_i18n(), 1); 33947 function isFormValid(formValidity) { 33948 if (!formValidity) { 33949 return true; 33950 } 33951 return Object.values(formValidity).every((fieldValidation) => { 33952 return Object.entries(fieldValidation).every( 33953 ([key, validation]) => { 33954 if (key === "children" && validation && typeof validation === "object") { 33955 return isFormValid(validation); 33956 } 33957 return validation.type !== "invalid" && validation.type !== "validating"; 33958 } 33959 ); 33960 }); 33961 } 33962 function getFormFieldsToValidate(form, fields) { 33963 const normalizedForm = normalize_form_default(form); 33964 if (normalizedForm.fields.length === 0) { 33965 return []; 33966 } 33967 const fieldsMap = /* @__PURE__ */ new Map(); 33968 fields.forEach((field) => { 33969 fieldsMap.set(field.id, field); 33970 }); 33971 function processFormField(formField) { 33972 if ("children" in formField && Array.isArray(formField.children)) { 33973 const processedChildren = formField.children.map(processFormField).filter((child) => child !== null); 33974 if (processedChildren.length === 0) { 33975 return null; 33976 } 33977 const fieldDef2 = fieldsMap.get(formField.id); 33978 if (fieldDef2) { 33979 const [normalizedField2] = normalizeFields([ 33980 fieldDef2 33981 ]); 33982 return { 33983 id: formField.id, 33984 children: processedChildren, 33985 field: normalizedField2 33986 }; 33987 } 33988 return { 33989 id: formField.id, 33990 children: processedChildren 33991 }; 33992 } 33993 const fieldDef = fieldsMap.get(formField.id); 33994 if (!fieldDef) { 33995 return null; 33996 } 33997 const [normalizedField] = normalizeFields([fieldDef]); 33998 return { 33999 id: formField.id, 34000 children: [], 34001 field: normalizedField 34002 }; 34003 } 34004 const toValidate = normalizedForm.fields.map(processFormField).filter((field) => field !== null); 34005 return toValidate; 34006 } 34007 function setValidityAtPath(formValidity, fieldValidity, path) { 34008 if (!formValidity) { 34009 formValidity = {}; 34010 } 34011 if (path.length === 0) { 34012 return formValidity; 34013 } 34014 const result = { ...formValidity }; 34015 let current = result; 34016 for (let i2 = 0; i2 < path.length - 1; i2++) { 34017 const segment = path[i2]; 34018 if (!current[segment]) { 34019 current[segment] = {}; 34020 } 34021 current[segment] = { ...current[segment] }; 34022 current = current[segment]; 34023 } 34024 const finalKey = path[path.length - 1]; 34025 current[finalKey] = { 34026 ...current[finalKey] || {}, 34027 ...fieldValidity 34028 }; 34029 return result; 34030 } 34031 function removeValidationProperty(formValidity, path, property) { 34032 if (!formValidity || path.length === 0) { 34033 return formValidity; 34034 } 34035 const result = { ...formValidity }; 34036 let current = result; 34037 for (let i2 = 0; i2 < path.length - 1; i2++) { 34038 const segment = path[i2]; 34039 if (!current[segment]) { 34040 return formValidity; 34041 } 34042 current[segment] = { ...current[segment] }; 34043 current = current[segment]; 34044 } 34045 const finalKey = path[path.length - 1]; 34046 if (!current[finalKey]) { 34047 return formValidity; 34048 } 34049 const fieldValidity = { ...current[finalKey] }; 34050 delete fieldValidity[property]; 34051 if (Object.keys(fieldValidity).length === 0) { 34052 delete current[finalKey]; 34053 } else { 34054 current[finalKey] = fieldValidity; 34055 } 34056 if (Object.keys(result).length === 0) { 34057 return void 0; 34058 } 34059 return result; 34060 } 34061 function handleElementsValidationAsync(promise, formField, promiseHandler) { 34062 const { elementsCounterRef, setFormValidity, path, item } = promiseHandler; 34063 const currentToken = (elementsCounterRef.current[formField.id] || 0) + 1; 34064 elementsCounterRef.current[formField.id] = currentToken; 34065 promise.then((result) => { 34066 if (currentToken !== elementsCounterRef.current[formField.id]) { 34067 return; 34068 } 34069 if (!Array.isArray(result)) { 34070 setFormValidity((prev) => { 34071 const newFormValidity = setValidityAtPath( 34072 prev, 34073 { 34074 elements: { 34075 type: "invalid", 34076 message: (0, import_i18n51.__)("Could not validate elements.") 34077 } 34078 }, 34079 [...path, formField.id] 34080 ); 34081 return newFormValidity; 34082 }); 34083 return; 34084 } 34085 if (formField.field?.isValid.elements && !formField.field.isValid.elements.validate(item, { 34086 ...formField.field, 34087 elements: result 34088 })) { 34089 setFormValidity((prev) => { 34090 const newFormValidity = setValidityAtPath( 34091 prev, 34092 { 34093 elements: { 34094 type: "invalid", 34095 message: (0, import_i18n51.__)( 34096 "Value must be one of the elements." 34097 ) 34098 } 34099 }, 34100 [...path, formField.id] 34101 ); 34102 return newFormValidity; 34103 }); 34104 } else { 34105 setFormValidity((prev) => { 34106 return removeValidationProperty( 34107 prev, 34108 [...path, formField.id], 34109 "elements" 34110 ); 34111 }); 34112 } 34113 }).catch((error2) => { 34114 if (currentToken !== elementsCounterRef.current[formField.id]) { 34115 return; 34116 } 34117 let errorMessage; 34118 if (error2 instanceof Error) { 34119 errorMessage = error2.message; 34120 } else { 34121 errorMessage = String(error2) || (0, import_i18n51.__)( 34122 "Unknown error when running elements validation asynchronously." 34123 ); 34124 } 34125 setFormValidity((prev) => { 34126 const newFormValidity = setValidityAtPath( 34127 prev, 34128 { 34129 elements: { 34130 type: "invalid", 34131 message: errorMessage 34132 } 34133 }, 34134 [...path, formField.id] 34135 ); 34136 return newFormValidity; 34137 }); 34138 }); 34139 } 34140 function handleCustomValidationAsync(promise, formField, promiseHandler) { 34141 const { customCounterRef, setFormValidity, path } = promiseHandler; 34142 const currentToken = (customCounterRef.current[formField.id] || 0) + 1; 34143 customCounterRef.current[formField.id] = currentToken; 34144 promise.then((result) => { 34145 if (currentToken !== customCounterRef.current[formField.id]) { 34146 return; 34147 } 34148 if (result === null) { 34149 setFormValidity((prev) => { 34150 return removeValidationProperty( 34151 prev, 34152 [...path, formField.id], 34153 "custom" 34154 ); 34155 }); 34156 return; 34157 } 34158 if (typeof result === "string") { 34159 setFormValidity((prev) => { 34160 const newFormValidity = setValidityAtPath( 34161 prev, 34162 { 34163 custom: { 34164 type: "invalid", 34165 message: result 34166 } 34167 }, 34168 [...path, formField.id] 34169 ); 34170 return newFormValidity; 34171 }); 34172 return; 34173 } 34174 setFormValidity((prev) => { 34175 const newFormValidity = setValidityAtPath( 34176 prev, 34177 { 34178 custom: { 34179 type: "invalid", 34180 message: (0, import_i18n51.__)("Validation could not be processed.") 34181 } 34182 }, 34183 [...path, formField.id] 34184 ); 34185 return newFormValidity; 34186 }); 34187 }).catch((error2) => { 34188 if (currentToken !== customCounterRef.current[formField.id]) { 34189 return; 34190 } 34191 let errorMessage; 34192 if (error2 instanceof Error) { 34193 errorMessage = error2.message; 34194 } else { 34195 errorMessage = String(error2) || (0, import_i18n51.__)( 34196 "Unknown error when running custom validation asynchronously." 34197 ); 34198 } 34199 setFormValidity((prev) => { 34200 const newFormValidity = setValidityAtPath( 34201 prev, 34202 { 34203 custom: { 34204 type: "invalid", 34205 message: errorMessage 34206 } 34207 }, 34208 [...path, formField.id] 34209 ); 34210 return newFormValidity; 34211 }); 34212 }); 34213 } 34214 function validateFormField(item, formField, promiseHandler) { 34215 if (formField.field?.isValid.required && !formField.field.isValid.required.validate(item, formField.field)) { 34216 return { 34217 required: { type: "invalid" } 34218 }; 34219 } 34220 if (formField.field?.isValid.pattern && !formField.field.isValid.pattern.validate(item, formField.field)) { 34221 return { 34222 pattern: { 34223 type: "invalid", 34224 message: (0, import_i18n51.__)("Value does not match the required pattern.") 34225 } 34226 }; 34227 } 34228 if (formField.field?.isValid.min && !formField.field.isValid.min.validate(item, formField.field)) { 34229 return { 34230 min: { 34231 type: "invalid", 34232 message: (0, import_i18n51.__)("Value is below the minimum.") 34233 } 34234 }; 34235 } 34236 if (formField.field?.isValid.max && !formField.field.isValid.max.validate(item, formField.field)) { 34237 return { 34238 max: { 34239 type: "invalid", 34240 message: (0, import_i18n51.__)("Value is above the maximum.") 34241 } 34242 }; 34243 } 34244 if (formField.field?.isValid.minLength && !formField.field.isValid.minLength.validate(item, formField.field)) { 34245 return { 34246 minLength: { 34247 type: "invalid", 34248 message: (0, import_i18n51.__)("Value is too short.") 34249 } 34250 }; 34251 } 34252 if (formField.field?.isValid.maxLength && !formField.field.isValid.maxLength.validate(item, formField.field)) { 34253 return { 34254 maxLength: { 34255 type: "invalid", 34256 message: (0, import_i18n51.__)("Value is too long.") 34257 } 34258 }; 34259 } 34260 if (formField.field?.isValid.elements && formField.field.hasElements && !formField.field.getElements && Array.isArray(formField.field.elements) && !formField.field.isValid.elements.validate(item, formField.field)) { 34261 return { 34262 elements: { 34263 type: "invalid", 34264 message: (0, import_i18n51.__)("Value must be one of the elements.") 34265 } 34266 }; 34267 } 34268 let customError; 34269 if (!!formField.field && formField.field.isValid.custom) { 34270 try { 34271 const value = formField.field.getValue({ item }); 34272 customError = formField.field.isValid.custom( 34273 (0, import_deepmerge.default)( 34274 item, 34275 formField.field.setValue({ 34276 item, 34277 value 34278 }) 34279 ), 34280 formField.field 34281 ); 34282 } catch (error2) { 34283 let errorMessage; 34284 if (error2 instanceof Error) { 34285 errorMessage = error2.message; 34286 } else { 34287 errorMessage = String(error2) || (0, import_i18n51.__)("Unknown error when running custom validation."); 34288 } 34289 return { 34290 custom: { 34291 type: "invalid", 34292 message: errorMessage 34293 } 34294 }; 34295 } 34296 } 34297 if (typeof customError === "string") { 34298 return { 34299 custom: { 34300 type: "invalid", 34301 message: customError 34302 } 34303 }; 34304 } 34305 const fieldValidity = {}; 34306 if (!!formField.field && formField.field.isValid.elements && formField.field.hasElements && typeof formField.field.getElements === "function") { 34307 handleElementsValidationAsync( 34308 formField.field.getElements(), 34309 formField, 34310 promiseHandler 34311 ); 34312 fieldValidity.elements = { 34313 type: "validating", 34314 message: (0, import_i18n51.__)("Validating…") 34315 }; 34316 } 34317 if (customError instanceof Promise) { 34318 handleCustomValidationAsync(customError, formField, promiseHandler); 34319 fieldValidity.custom = { 34320 type: "validating", 34321 message: (0, import_i18n51.__)("Validating…") 34322 }; 34323 } 34324 if (Object.keys(fieldValidity).length > 0) { 34325 return fieldValidity; 34326 } 34327 if (formField.children.length > 0) { 34328 const result = {}; 34329 formField.children.forEach((child) => { 34330 result[child.id] = validateFormField(item, child, { 34331 ...promiseHandler, 34332 path: [...promiseHandler.path, formField.id, "children"] 34333 }); 34334 }); 34335 const filteredResult = {}; 34336 Object.entries(result).forEach(([key, value]) => { 34337 if (value !== void 0) { 34338 filteredResult[key] = value; 34339 } 34340 }); 34341 if (Object.keys(filteredResult).length === 0) { 34342 return void 0; 34343 } 34344 return { 34345 children: filteredResult 34346 }; 34347 } 34348 return void 0; 34349 } 34350 function getFormFieldValue(formField, item) { 34351 const fieldValue = formField?.field?.getValue({ item }); 34352 if (formField.children.length === 0) { 34353 return fieldValue; 34354 } 34355 const childrenValues = formField.children.map( 34356 (child) => getFormFieldValue(child, item) 34357 ); 34358 if (!childrenValues) { 34359 return fieldValue; 34360 } 34361 return { 34362 value: fieldValue, 34363 children: childrenValues 34364 }; 34365 } 34366 function useFormValidity(item, fields, form) { 34367 const [formValidity, setFormValidity] = (0, import_element121.useState)(); 34368 const customCounterRef = (0, import_element121.useRef)({}); 34369 const elementsCounterRef = (0, import_element121.useRef)({}); 34370 const previousValuesRef = (0, import_element121.useRef)({}); 34371 const validate = (0, import_element121.useCallback)(() => { 34372 const promiseHandler = { 34373 customCounterRef, 34374 elementsCounterRef, 34375 setFormValidity, 34376 path: [], 34377 item 34378 }; 34379 const formFieldsToValidate = getFormFieldsToValidate(form, fields); 34380 if (formFieldsToValidate.length === 0) { 34381 setFormValidity(void 0); 34382 return; 34383 } 34384 const newFormValidity = {}; 34385 const untouchedFields = []; 34386 formFieldsToValidate.forEach((formField) => { 34387 const value = getFormFieldValue(formField, item); 34388 if (previousValuesRef.current.hasOwnProperty(formField.id) && (0, import_es62.default)( 34389 previousValuesRef.current[formField.id], 34390 value 34391 )) { 34392 untouchedFields.push(formField.id); 34393 return; 34394 } 34395 previousValuesRef.current[formField.id] = value; 34396 const fieldValidity = validateFormField( 34397 item, 34398 formField, 34399 promiseHandler 34400 ); 34401 if (fieldValidity !== void 0) { 34402 newFormValidity[formField.id] = fieldValidity; 34403 } 34404 }); 34405 setFormValidity((existingFormValidity) => { 34406 let validity = { 34407 ...existingFormValidity, 34408 ...newFormValidity 34409 }; 34410 const fieldsToKeep = [ 34411 ...untouchedFields, 34412 ...Object.keys(newFormValidity) 34413 ]; 34414 Object.keys(validity).forEach((key) => { 34415 if (validity && !fieldsToKeep.includes(key)) { 34416 delete validity[key]; 34417 } 34418 }); 34419 if (Object.keys(validity).length === 0) { 34420 validity = void 0; 34421 } 34422 const areEqual = (0, import_es62.default)(existingFormValidity, validity); 34423 if (areEqual) { 34424 return existingFormValidity; 34425 } 34426 return validity; 34427 }); 34428 }, [item, fields, form]); 34429 (0, import_element121.useEffect)(() => { 34430 validate(); 34431 }, [validate]); 34432 return { 34433 validity: formValidity, 34434 isValid: isFormValid(formValidity) 34435 }; 34436 } 34437 var use_form_validity_default = useFormValidity; 34438 34439 // packages/dataviews/build-module/hooks/use-report-validity.mjs 34440 var import_element122 = __toESM(require_element(), 1); 34441 function useReportValidity(ref, shouldReport) { 34442 (0, import_element122.useEffect)(() => { 34443 if (shouldReport && ref.current) { 34444 const inputs = ref.current.querySelectorAll( 34445 "input, textarea, select" 34446 ); 34447 inputs.forEach((input) => { 34448 input.reportValidity(); 34449 }); 34450 } 34451 }, [shouldReport, ref]); 34452 } 34453 34454 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/use-field-from-form-field.mjs 34455 var import_element123 = __toESM(require_element(), 1); 34456 34457 // packages/dataviews/build-module/components/dataform-layouts/get-summary-fields.mjs 34458 function extractSummaryIds(summary) { 34459 if (Array.isArray(summary)) { 34460 return summary.map( 34461 (item) => typeof item === "string" ? item : item.id 34462 ); 34463 } 34464 return []; 34465 } 34466 var getSummaryFields = (summaryField, fields) => { 34467 if (Array.isArray(summaryField) && summaryField.length > 0) { 34468 const summaryIds = extractSummaryIds(summaryField); 34469 return summaryIds.map( 34470 (summaryId) => fields.find((_field) => _field.id === summaryId) 34471 ).filter((_field) => _field !== void 0); 34472 } 34473 return []; 34474 }; 34475 34476 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/use-field-from-form-field.mjs 34477 var getFieldDefinition = (field, fields) => { 34478 const fieldDefinition = fields.find((_field) => _field.id === field.id); 34479 if (!fieldDefinition) { 34480 return fields.find((_field) => { 34481 if (!!field.children) { 34482 const simpleChildren = field.children.filter( 34483 (child) => !child.children 34484 ); 34485 if (simpleChildren.length === 0) { 34486 return false; 34487 } 34488 return _field.id === simpleChildren[0].id; 34489 } 34490 return _field.id === field.id; 34491 }); 34492 } 34493 return fieldDefinition; 34494 }; 34495 function useFieldFromFormField(field) { 34496 const { fields } = (0, import_element123.useContext)(dataform_context_default); 34497 const layout = field.layout; 34498 const summaryFields = getSummaryFields(layout.summary, fields); 34499 const fieldDefinition = getFieldDefinition(field, fields); 34500 const fieldLabel = !!field.children ? field.label : fieldDefinition?.label; 34501 if (summaryFields.length === 0) { 34502 return { 34503 summaryFields: fieldDefinition ? [fieldDefinition] : [], 34504 fieldDefinition, 34505 fieldLabel 34506 }; 34507 } 34508 return { 34509 summaryFields, 34510 fieldDefinition, 34511 fieldLabel 34512 }; 34513 } 34514 var use_field_from_form_field_default = useFieldFromFormField; 34515 34516 // packages/dataviews/build-module/components/dataform-layouts/panel/modal.mjs 34517 var import_jsx_runtime169 = __toESM(require_jsx_runtime(), 1); 34518 function ModalContent({ 34519 data, 34520 field, 34521 onChange, 34522 fieldLabel, 34523 onClose, 34524 touched 34525 }) { 34526 const { openAs } = field.layout; 34527 const { applyLabel, cancelLabel } = openAs; 34528 const { fields } = (0, import_element124.useContext)(dataform_context_default); 34529 const [changes, setChanges] = (0, import_element124.useState)({}); 34530 const modalData = (0, import_element124.useMemo)(() => { 34531 return (0, import_deepmerge2.default)(data, changes, { 34532 arrayMerge: (target, source) => source 34533 }); 34534 }, [data, changes]); 34535 const form = (0, import_element124.useMemo)( 34536 () => ({ 34537 layout: DEFAULT_LAYOUT, 34538 fields: !!field.children ? field.children : ( 34539 // If not explicit children return the field id itself. 34540 [{ id: field.id, layout: DEFAULT_LAYOUT }] 34541 ) 34542 }), 34543 [field] 34544 ); 34545 const fieldsAsFieldType = fields.map((f2) => ({ 34546 ...f2, 34547 Edit: f2.Edit === null ? void 0 : f2.Edit, 34548 isValid: { 34549 required: f2.isValid.required?.constraint, 34550 elements: f2.isValid.elements?.constraint, 34551 min: f2.isValid.min?.constraint, 34552 max: f2.isValid.max?.constraint, 34553 pattern: f2.isValid.pattern?.constraint, 34554 minLength: f2.isValid.minLength?.constraint, 34555 maxLength: f2.isValid.maxLength?.constraint 34556 } 34557 })); 34558 const { validity } = use_form_validity_default(modalData, fieldsAsFieldType, form); 34559 const onApply = () => { 34560 onChange(changes); 34561 onClose(); 34562 }; 34563 const handleOnChange = (newValue) => { 34564 setChanges( 34565 (prev) => (0, import_deepmerge2.default)(prev, newValue, { 34566 arrayMerge: (target, source) => source 34567 }) 34568 ); 34569 }; 34570 const focusOnMountRef = (0, import_compose18.useFocusOnMount)("firstInputElement"); 34571 const contentRef = (0, import_element124.useRef)(null); 34572 const mergedRef = (0, import_compose18.useMergeRefs)([focusOnMountRef, contentRef]); 34573 useReportValidity(contentRef, touched); 34574 return /* @__PURE__ */ (0, import_jsx_runtime169.jsxs)( 34575 import_components52.Modal, 34576 { 34577 className: "dataforms-layouts-panel__modal", 34578 onRequestClose: onClose, 34579 isFullScreen: false, 34580 title: fieldLabel, 34581 size: "medium", 34582 children: [ 34583 /* @__PURE__ */ (0, import_jsx_runtime169.jsx)("div", { ref: mergedRef, children: /* @__PURE__ */ (0, import_jsx_runtime169.jsx)( 34584 DataFormLayout, 34585 { 34586 data: modalData, 34587 form, 34588 onChange: handleOnChange, 34589 validity, 34590 children: (FieldLayout, childField, childFieldValidity, markWhenOptional) => /* @__PURE__ */ (0, import_jsx_runtime169.jsx)( 34591 FieldLayout, 34592 { 34593 data: modalData, 34594 field: childField, 34595 onChange: handleOnChange, 34596 hideLabelFromVision: form.fields.length < 2, 34597 markWhenOptional, 34598 validity: childFieldValidity 34599 }, 34600 childField.id 34601 ) 34602 } 34603 ) }), 34604 /* @__PURE__ */ (0, import_jsx_runtime169.jsxs)( 34605 Stack, 34606 { 34607 direction: "row", 34608 className: "dataforms-layouts-panel__modal-footer", 34609 gap: "md", 34610 children: [ 34611 /* @__PURE__ */ (0, import_jsx_runtime169.jsx)(import_components52.__experimentalSpacer, { style: { flex: 1 } }), 34612 /* @__PURE__ */ (0, import_jsx_runtime169.jsx)( 34613 import_components52.Button, 34614 { 34615 variant: "tertiary", 34616 onClick: onClose, 34617 __next40pxDefaultSize: true, 34618 children: cancelLabel 34619 } 34620 ), 34621 /* @__PURE__ */ (0, import_jsx_runtime169.jsx)( 34622 import_components52.Button, 34623 { 34624 variant: "primary", 34625 onClick: onApply, 34626 __next40pxDefaultSize: true, 34627 children: applyLabel 34628 } 34629 ) 34630 ] 34631 } 34632 ) 34633 ] 34634 } 34635 ); 34636 } 34637 function PanelModal({ 34638 data, 34639 field, 34640 onChange, 34641 validity 34642 }) { 34643 const [touched, setTouched] = (0, import_element124.useState)(false); 34644 const [isOpen, setIsOpen] = (0, import_element124.useState)(false); 34645 const { fieldDefinition, fieldLabel, summaryFields } = use_field_from_form_field_default(field); 34646 if (!fieldDefinition) { 34647 return null; 34648 } 34649 const handleClose = () => { 34650 setIsOpen(false); 34651 setTouched(true); 34652 }; 34653 return /* @__PURE__ */ (0, import_jsx_runtime169.jsxs)(import_jsx_runtime169.Fragment, { children: [ 34654 /* @__PURE__ */ (0, import_jsx_runtime169.jsx)( 34655 SummaryButton, 34656 { 34657 data, 34658 field, 34659 fieldLabel, 34660 summaryFields, 34661 validity, 34662 touched, 34663 disabled: fieldDefinition.readOnly === true, 34664 onClick: () => setIsOpen(true), 34665 isOpen 34666 } 34667 ), 34668 isOpen && /* @__PURE__ */ (0, import_jsx_runtime169.jsx)( 34669 ModalContent, 34670 { 34671 data, 34672 field, 34673 onChange, 34674 fieldLabel: fieldLabel ?? "", 34675 onClose: handleClose, 34676 touched 34677 } 34678 ) 34679 ] }); 34680 } 34681 var modal_default = PanelModal; 34682 34683 // packages/dataviews/build-module/components/dataform-layouts/panel/dropdown.mjs 34684 var import_components53 = __toESM(require_components(), 1); 34685 var import_i18n52 = __toESM(require_i18n(), 1); 34686 var import_element125 = __toESM(require_element(), 1); 34687 var import_compose19 = __toESM(require_compose(), 1); 34688 var import_jsx_runtime170 = __toESM(require_jsx_runtime(), 1); 34689 function DropdownHeader({ 34690 title, 34691 onClose 34692 }) { 34693 return /* @__PURE__ */ (0, import_jsx_runtime170.jsx)( 34694 Stack, 34695 { 34696 direction: "column", 34697 className: "dataforms-layouts-panel__dropdown-header", 34698 gap: "lg", 34699 children: /* @__PURE__ */ (0, import_jsx_runtime170.jsxs)(Stack, { direction: "row", gap: "sm", align: "center", children: [ 34700 title && /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(import_components53.__experimentalHeading, { level: 2, size: 13, children: title }), 34701 /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(import_components53.__experimentalSpacer, { style: { flex: 1 } }), 34702 onClose && /* @__PURE__ */ (0, import_jsx_runtime170.jsx)( 34703 import_components53.Button, 34704 { 34705 label: (0, import_i18n52.__)("Close"), 34706 icon: close_small_default, 34707 onClick: onClose, 34708 size: "small" 34709 } 34710 ) 34711 ] }) 34712 } 34713 ); 34714 } 34715 function DropdownContentWithValidation({ 34716 touched, 34717 children 34718 }) { 34719 const ref = (0, import_element125.useRef)(null); 34720 useReportValidity(ref, touched); 34721 return /* @__PURE__ */ (0, import_jsx_runtime170.jsx)("div", { ref, children }); 34722 } 34723 function PanelDropdown({ 34724 data, 34725 field, 34726 onChange, 34727 validity 34728 }) { 34729 const [touched, setTouched] = (0, import_element125.useState)(false); 34730 const [popoverAnchor, setPopoverAnchor] = (0, import_element125.useState)( 34731 null 34732 ); 34733 const popoverProps = (0, import_element125.useMemo)( 34734 () => ({ 34735 // Anchor the popover to the middle of the entire row so that it doesn't 34736 // move around when the label changes. 34737 anchor: popoverAnchor, 34738 placement: "left-start", 34739 offset: 36, 34740 shift: true 34741 }), 34742 [popoverAnchor] 34743 ); 34744 const [dialogRef, dialogProps] = (0, import_compose19.__experimentalUseDialog)({ 34745 focusOnMount: "firstInputElement" 34746 }); 34747 const form = (0, import_element125.useMemo)( 34748 () => ({ 34749 layout: DEFAULT_LAYOUT, 34750 fields: !!field.children ? field.children : ( 34751 // If not explicit children return the field id itself. 34752 [{ id: field.id, layout: DEFAULT_LAYOUT }] 34753 ) 34754 }), 34755 [field] 34756 ); 34757 const formValidity = (0, import_element125.useMemo)(() => { 34758 if (validity === void 0) { 34759 return void 0; 34760 } 34761 if (!!field.children) { 34762 return validity?.children; 34763 } 34764 return { [field.id]: validity }; 34765 }, [validity, field]); 34766 const { fieldDefinition, fieldLabel, summaryFields } = use_field_from_form_field_default(field); 34767 if (!fieldDefinition) { 34768 return null; 34769 } 34770 return /* @__PURE__ */ (0, import_jsx_runtime170.jsx)( 34771 "div", 34772 { 34773 ref: setPopoverAnchor, 34774 className: "dataforms-layouts-panel__field-dropdown-anchor", 34775 children: /* @__PURE__ */ (0, import_jsx_runtime170.jsx)( 34776 import_components53.Dropdown, 34777 { 34778 contentClassName: "dataforms-layouts-panel__field-dropdown", 34779 popoverProps, 34780 focusOnMount: false, 34781 onToggle: (willOpen) => { 34782 if (!willOpen) { 34783 setTouched(true); 34784 } 34785 }, 34786 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime170.jsx)( 34787 SummaryButton, 34788 { 34789 data, 34790 field, 34791 fieldLabel, 34792 summaryFields, 34793 validity, 34794 touched, 34795 disabled: fieldDefinition.readOnly === true, 34796 isOpen, 34797 onClick: onToggle 34798 } 34799 ), 34800 renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(DropdownContentWithValidation, { touched, children: /* @__PURE__ */ (0, import_jsx_runtime170.jsxs)("div", { ref: dialogRef, ...dialogProps, children: [ 34801 /* @__PURE__ */ (0, import_jsx_runtime170.jsx)( 34802 DropdownHeader, 34803 { 34804 title: fieldLabel, 34805 onClose 34806 } 34807 ), 34808 /* @__PURE__ */ (0, import_jsx_runtime170.jsx)( 34809 DataFormLayout, 34810 { 34811 data, 34812 form, 34813 onChange, 34814 validity: formValidity, 34815 children: (FieldLayout, childField, childFieldValidity, markWhenOptional) => /* @__PURE__ */ (0, import_jsx_runtime170.jsx)( 34816 FieldLayout, 34817 { 34818 data, 34819 field: childField, 34820 onChange, 34821 hideLabelFromVision: (form?.fields ?? []).length < 2, 34822 markWhenOptional, 34823 validity: childFieldValidity 34824 }, 34825 childField.id 34826 ) 34827 } 34828 ) 34829 ] }) }) 34830 } 34831 ) 34832 } 34833 ); 34834 } 34835 var dropdown_default = PanelDropdown; 34836 34837 // packages/dataviews/build-module/components/dataform-layouts/panel/index.mjs 34838 var import_jsx_runtime171 = __toESM(require_jsx_runtime(), 1); 34839 function FormPanelField({ 34840 data, 34841 field, 34842 onChange, 34843 validity 34844 }) { 34845 const layout = field.layout; 34846 if (layout.openAs.type === "modal") { 34847 return /* @__PURE__ */ (0, import_jsx_runtime171.jsx)( 34848 modal_default, 34849 { 34850 data, 34851 field, 34852 onChange, 34853 validity 34854 } 34855 ); 34856 } 34857 return /* @__PURE__ */ (0, import_jsx_runtime171.jsx)( 34858 dropdown_default, 34859 { 34860 data, 34861 field, 34862 onChange, 34863 validity 34864 } 34865 ); 34866 } 34867 34868 // packages/dataviews/build-module/components/dataform-layouts/card/index.mjs 34869 var import_element126 = __toESM(require_element(), 1); 34870 34871 // packages/dataviews/build-module/components/dataform-layouts/validation-badge.mjs 34872 var import_i18n53 = __toESM(require_i18n(), 1); 34873 var import_jsx_runtime172 = __toESM(require_jsx_runtime(), 1); 34874 function countInvalidFields(validity) { 34875 if (!validity) { 34876 return 0; 34877 } 34878 let count = 0; 34879 const validityRules = Object.keys(validity).filter( 34880 (key) => key !== "children" 34881 ); 34882 for (const key of validityRules) { 34883 const rule = validity[key]; 34884 if (rule?.type === "invalid") { 34885 count++; 34886 } 34887 } 34888 if (validity.children) { 34889 for (const childValidity of Object.values(validity.children)) { 34890 count += countInvalidFields(childValidity); 34891 } 34892 } 34893 return count; 34894 } 34895 function ValidationBadge({ 34896 validity 34897 }) { 34898 const invalidCount = countInvalidFields(validity); 34899 if (invalidCount === 0) { 34900 return null; 34901 } 34902 return /* @__PURE__ */ (0, import_jsx_runtime172.jsx)(Badge, { intent: "high", children: (0, import_i18n53.sprintf)( 34903 /* translators: %d: Number of fields that need attention */ 34904 (0, import_i18n53._n)( 34905 "%d field needs attention", 34906 "%d fields need attention", 34907 invalidCount 34908 ), 34909 invalidCount 34910 ) }); 34911 } 34912 34913 // packages/dataviews/build-module/components/dataform-layouts/card/index.mjs 34914 var import_jsx_runtime173 = __toESM(require_jsx_runtime(), 1); 34915 function isSummaryFieldVisible(summaryField, summaryConfig, isOpen) { 34916 if (!summaryConfig || Array.isArray(summaryConfig) && summaryConfig.length === 0) { 34917 return false; 34918 } 34919 const summaryConfigArray = Array.isArray(summaryConfig) ? summaryConfig : [summaryConfig]; 34920 const fieldConfig = summaryConfigArray.find((config) => { 34921 if (typeof config === "string") { 34922 return config === summaryField.id; 34923 } 34924 if (typeof config === "object" && "id" in config) { 34925 return config.id === summaryField.id; 34926 } 34927 return false; 34928 }); 34929 if (!fieldConfig) { 34930 return false; 34931 } 34932 if (typeof fieldConfig === "string") { 34933 return true; 34934 } 34935 if (typeof fieldConfig === "object" && "visibility" in fieldConfig) { 34936 return fieldConfig.visibility === "always" || fieldConfig.visibility === "when-collapsed" && !isOpen; 34937 } 34938 return true; 34939 } 34940 function HeaderContent({ 34941 data, 34942 fields, 34943 label, 34944 layout, 34945 isOpen, 34946 touched, 34947 validity 34948 }) { 34949 const summaryFields = getSummaryFields(layout.summary, fields); 34950 const visibleSummaryFields = summaryFields.filter( 34951 (summaryField) => isSummaryFieldVisible(summaryField, layout.summary, isOpen) 34952 ); 34953 const hasBadge = touched && layout.isCollapsible; 34954 const hasSummary = visibleSummaryFields.length > 0 && layout.withHeader; 34955 return /* @__PURE__ */ (0, import_jsx_runtime173.jsxs)( 34956 Stack, 34957 { 34958 align: "center", 34959 justify: "space-between", 34960 className: "dataforms-layouts-card__field-header-content", 34961 children: [ 34962 /* @__PURE__ */ (0, import_jsx_runtime173.jsx)(card_exports.Title, { children: label }), 34963 (hasBadge || hasSummary) && /* @__PURE__ */ (0, import_jsx_runtime173.jsxs)(collapsible_card_exports.HeaderDescription, { className: "dataforms-layouts-card__field-header-content-description", children: [ 34964 hasBadge && /* @__PURE__ */ (0, import_jsx_runtime173.jsx)(ValidationBadge, { validity }), 34965 hasSummary && /* @__PURE__ */ (0, import_jsx_runtime173.jsx)("div", { className: "dataforms-layouts-card__field-summary", children: visibleSummaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime173.jsx)( 34966 summaryField.render, 34967 { 34968 item: data, 34969 field: summaryField 34970 }, 34971 summaryField.id 34972 )) }) 34973 ] }) 34974 ] 34975 } 34976 ); 34977 } 34978 function BodyContent({ 34979 data, 34980 field, 34981 form, 34982 onChange, 34983 hideLabelFromVision, 34984 markWhenOptional, 34985 validity, 34986 withHeader 34987 }) { 34988 if (field.children) { 34989 return /* @__PURE__ */ (0, import_jsx_runtime173.jsxs)(import_jsx_runtime173.Fragment, { children: [ 34990 field.description && /* @__PURE__ */ (0, import_jsx_runtime173.jsx)("div", { className: "dataforms-layouts-card__field-description", children: field.description }), 34991 /* @__PURE__ */ (0, import_jsx_runtime173.jsx)( 34992 DataFormLayout, 34993 { 34994 data, 34995 form, 34996 onChange, 34997 validity: validity?.children 34998 } 34999 ) 35000 ] }); 35001 } 35002 const SingleFieldLayout = getFormFieldLayout("regular")?.component; 35003 if (!SingleFieldLayout) { 35004 return null; 35005 } 35006 return /* @__PURE__ */ (0, import_jsx_runtime173.jsx)( 35007 SingleFieldLayout, 35008 { 35009 data, 35010 field, 35011 onChange, 35012 hideLabelFromVision: hideLabelFromVision || withHeader, 35013 markWhenOptional, 35014 validity 35015 } 35016 ); 35017 } 35018 function FormCardField({ 35019 data, 35020 field, 35021 onChange, 35022 hideLabelFromVision, 35023 markWhenOptional, 35024 validity 35025 }) { 35026 const { fields } = (0, import_element126.useContext)(dataform_context_default); 35027 const layout = field.layout; 35028 const contentRef = (0, import_element126.useRef)(null); 35029 const form = (0, import_element126.useMemo)( 35030 () => ({ 35031 layout: DEFAULT_LAYOUT, 35032 fields: field.children ?? [] 35033 }), 35034 [field] 35035 ); 35036 const { isOpened, isCollapsible } = layout; 35037 const [isOpen, setIsOpen] = (0, import_element126.useState)(isOpened); 35038 const [touched, setTouched] = (0, import_element126.useState)(false); 35039 (0, import_element126.useEffect)(() => { 35040 setIsOpen(isOpened); 35041 }, [isOpened]); 35042 const handleOpenChange = (0, import_element126.useCallback)((open) => { 35043 if (!open) { 35044 setTouched(true); 35045 } 35046 setIsOpen(open); 35047 }, []); 35048 const handleBlur = (0, import_element126.useCallback)(() => { 35049 setTouched(true); 35050 }, []); 35051 useReportValidity( 35052 contentRef, 35053 (isCollapsible ? isOpen : true) && touched 35054 ); 35055 let label = field.label; 35056 let withHeader; 35057 if (field.children) { 35058 withHeader = !!label && layout.withHeader; 35059 } else { 35060 const fieldDefinition = fields.find( 35061 (fieldDef) => fieldDef.id === field.id 35062 ); 35063 if (!fieldDefinition || !fieldDefinition.Edit) { 35064 return null; 35065 } 35066 label = fieldDefinition.label; 35067 withHeader = !!label && layout.withHeader; 35068 } 35069 const bodyContent = /* @__PURE__ */ (0, import_jsx_runtime173.jsx)( 35070 BodyContent, 35071 { 35072 data, 35073 field, 35074 form, 35075 onChange, 35076 hideLabelFromVision, 35077 markWhenOptional, 35078 validity, 35079 withHeader 35080 } 35081 ); 35082 const headerContent = /* @__PURE__ */ (0, import_jsx_runtime173.jsx)( 35083 HeaderContent, 35084 { 35085 data, 35086 fields, 35087 label, 35088 layout, 35089 isOpen: isCollapsible ? !!isOpen : true, 35090 touched, 35091 validity 35092 } 35093 ); 35094 if (withHeader && isCollapsible) { 35095 return /* @__PURE__ */ (0, import_jsx_runtime173.jsxs)( 35096 collapsible_card_exports.Root, 35097 { 35098 className: "dataforms-layouts-card__field", 35099 open: isOpen, 35100 onOpenChange: handleOpenChange, 35101 children: [ 35102 /* @__PURE__ */ (0, import_jsx_runtime173.jsx)(collapsible_card_exports.Header, { children: headerContent }), 35103 /* @__PURE__ */ (0, import_jsx_runtime173.jsx)( 35104 collapsible_card_exports.Content, 35105 { 35106 ref: contentRef, 35107 onBlur: handleBlur, 35108 children: bodyContent 35109 } 35110 ) 35111 ] 35112 } 35113 ); 35114 } 35115 return /* @__PURE__ */ (0, import_jsx_runtime173.jsxs)(card_exports.Root, { className: "dataforms-layouts-card__field", children: [ 35116 withHeader && /* @__PURE__ */ (0, import_jsx_runtime173.jsx)(card_exports.Header, { children: headerContent }), 35117 /* @__PURE__ */ (0, import_jsx_runtime173.jsx)(card_exports.Content, { ref: contentRef, onBlur: handleBlur, children: bodyContent }) 35118 ] }); 35119 } 35120 35121 // packages/dataviews/build-module/components/dataform-layouts/row/index.mjs 35122 var import_components54 = __toESM(require_components(), 1); 35123 var import_jsx_runtime174 = __toESM(require_jsx_runtime(), 1); 35124 function Header5({ title }) { 35125 return /* @__PURE__ */ (0, import_jsx_runtime174.jsx)( 35126 Stack, 35127 { 35128 direction: "column", 35129 className: "dataforms-layouts-row__header", 35130 gap: "lg", 35131 children: /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(Stack, { direction: "row", align: "center", children: /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(import_components54.__experimentalHeading, { level: 2, size: 13, children: title }) }) 35132 } 35133 ); 35134 } 35135 var EMPTY_WRAPPER = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(import_jsx_runtime174.Fragment, { children }); 35136 function FormRowField({ 35137 data, 35138 field, 35139 onChange, 35140 hideLabelFromVision, 35141 markWhenOptional, 35142 validity 35143 }) { 35144 const layout = field.layout; 35145 if (!!field.children) { 35146 const form = { 35147 layout: DEFAULT_LAYOUT, 35148 fields: field.children 35149 }; 35150 return /* @__PURE__ */ (0, import_jsx_runtime174.jsxs)("div", { className: "dataforms-layouts-row__field", children: [ 35151 !hideLabelFromVision && field.label && /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(Header5, { title: field.label }), 35152 /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(Stack, { direction: "row", align: layout.alignment, gap: "lg", children: /* @__PURE__ */ (0, import_jsx_runtime174.jsx)( 35153 DataFormLayout, 35154 { 35155 data, 35156 form, 35157 onChange, 35158 validity: validity?.children, 35159 as: EMPTY_WRAPPER, 35160 children: (FieldLayout, childField, childFieldValidity) => /* @__PURE__ */ (0, import_jsx_runtime174.jsx)( 35161 "div", 35162 { 35163 className: "dataforms-layouts-row__field-control", 35164 style: layout.styles[childField.id], 35165 children: /* @__PURE__ */ (0, import_jsx_runtime174.jsx)( 35166 FieldLayout, 35167 { 35168 data, 35169 field: childField, 35170 onChange, 35171 hideLabelFromVision, 35172 markWhenOptional, 35173 validity: childFieldValidity 35174 } 35175 ) 35176 }, 35177 childField.id 35178 ) 35179 } 35180 ) }) 35181 ] }); 35182 } 35183 const RegularLayout = getFormFieldLayout("regular")?.component; 35184 if (!RegularLayout) { 35185 return null; 35186 } 35187 return /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(import_jsx_runtime174.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime174.jsx)("div", { className: "dataforms-layouts-row__field-control", children: /* @__PURE__ */ (0, import_jsx_runtime174.jsx)( 35188 RegularLayout, 35189 { 35190 data, 35191 field, 35192 onChange, 35193 markWhenOptional, 35194 validity 35195 } 35196 ) }) }); 35197 } 35198 35199 // packages/dataviews/build-module/components/dataform-layouts/details/index.mjs 35200 var import_element127 = __toESM(require_element(), 1); 35201 var import_i18n54 = __toESM(require_i18n(), 1); 35202 var import_jsx_runtime175 = __toESM(require_jsx_runtime(), 1); 35203 function FormDetailsField({ 35204 data, 35205 field, 35206 onChange, 35207 validity 35208 }) { 35209 const { fields } = (0, import_element127.useContext)(dataform_context_default); 35210 const detailsRef = (0, import_element127.useRef)(null); 35211 const contentRef = (0, import_element127.useRef)(null); 35212 const [touched, setTouched] = (0, import_element127.useState)(false); 35213 const [isOpen, setIsOpen] = (0, import_element127.useState)(false); 35214 const form = (0, import_element127.useMemo)( 35215 () => ({ 35216 layout: DEFAULT_LAYOUT, 35217 fields: field.children ?? [] 35218 }), 35219 [field] 35220 ); 35221 (0, import_element127.useEffect)(() => { 35222 const details = detailsRef.current; 35223 if (!details) { 35224 return; 35225 } 35226 const handleToggle = () => { 35227 const nowOpen = details.open; 35228 if (!nowOpen) { 35229 setTouched(true); 35230 } 35231 setIsOpen(nowOpen); 35232 }; 35233 details.addEventListener("toggle", handleToggle); 35234 return () => { 35235 details.removeEventListener("toggle", handleToggle); 35236 }; 35237 }, []); 35238 useReportValidity(contentRef, isOpen && touched); 35239 const handleBlur = (0, import_element127.useCallback)(() => { 35240 setTouched(true); 35241 }, []); 35242 if (!field.children) { 35243 return null; 35244 } 35245 const summaryFieldId = field.layout.summary ?? ""; 35246 const summaryField = summaryFieldId ? fields.find((fieldDef) => fieldDef.id === summaryFieldId) : void 0; 35247 let summaryContent; 35248 if (summaryField && summaryField.render) { 35249 summaryContent = /* @__PURE__ */ (0, import_jsx_runtime175.jsx)(summaryField.render, { item: data, field: summaryField }); 35250 } else { 35251 summaryContent = field.label || (0, import_i18n54.__)("More details"); 35252 } 35253 return /* @__PURE__ */ (0, import_jsx_runtime175.jsxs)( 35254 "details", 35255 { 35256 ref: detailsRef, 35257 className: "dataforms-layouts-details__details", 35258 children: [ 35259 /* @__PURE__ */ (0, import_jsx_runtime175.jsx)("summary", { className: "dataforms-layouts-details__summary", children: /* @__PURE__ */ (0, import_jsx_runtime175.jsxs)( 35260 Stack, 35261 { 35262 direction: "row", 35263 align: "center", 35264 gap: "md", 35265 className: "dataforms-layouts-details__summary-content", 35266 children: [ 35267 summaryContent, 35268 touched && /* @__PURE__ */ (0, import_jsx_runtime175.jsx)(ValidationBadge, { validity }) 35269 ] 35270 } 35271 ) }), 35272 /* @__PURE__ */ (0, import_jsx_runtime175.jsx)( 35273 "div", 35274 { 35275 ref: contentRef, 35276 className: "dataforms-layouts-details__content", 35277 onBlur: handleBlur, 35278 children: /* @__PURE__ */ (0, import_jsx_runtime175.jsx)( 35279 DataFormLayout, 35280 { 35281 data, 35282 form, 35283 onChange, 35284 validity: validity?.children 35285 } 35286 ) 35287 } 35288 ) 35289 ] 35290 } 35291 ); 35292 } 35293 35294 // packages/dataviews/build-module/components/dataform-layouts/index.mjs 35295 var import_jsx_runtime176 = __toESM(require_jsx_runtime(), 1); 35296 var FORM_FIELD_LAYOUTS = [ 35297 { 35298 type: "regular", 35299 component: FormRegularField, 35300 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime176.jsx)( 35301 Stack, 35302 { 35303 direction: "column", 35304 className: "dataforms-layouts__wrapper", 35305 gap: "lg", 35306 children 35307 } 35308 ) 35309 }, 35310 { 35311 type: "panel", 35312 component: FormPanelField, 35313 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime176.jsx)( 35314 Stack, 35315 { 35316 direction: "column", 35317 className: "dataforms-layouts__wrapper", 35318 gap: "md", 35319 children 35320 } 35321 ) 35322 }, 35323 { 35324 type: "card", 35325 component: FormCardField, 35326 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime176.jsx)( 35327 Stack, 35328 { 35329 direction: "column", 35330 className: "dataforms-layouts__wrapper", 35331 gap: "xl", 35332 children 35333 } 35334 ) 35335 }, 35336 { 35337 type: "row", 35338 component: FormRowField, 35339 wrapper: ({ 35340 children, 35341 layout 35342 }) => /* @__PURE__ */ (0, import_jsx_runtime176.jsx)( 35343 Stack, 35344 { 35345 direction: "column", 35346 className: "dataforms-layouts__wrapper", 35347 gap: "lg", 35348 children: /* @__PURE__ */ (0, import_jsx_runtime176.jsx)("div", { className: "dataforms-layouts-row__field", children: /* @__PURE__ */ (0, import_jsx_runtime176.jsx)( 35349 Stack, 35350 { 35351 direction: "row", 35352 gap: "lg", 35353 align: layout.alignment, 35354 children 35355 } 35356 ) }) 35357 } 35358 ) 35359 }, 35360 { 35361 type: "details", 35362 component: FormDetailsField 35363 } 35364 ]; 35365 function getFormFieldLayout(type) { 35366 return FORM_FIELD_LAYOUTS.find((layout) => layout.type === type); 35367 } 35368 35369 // packages/dataviews/build-module/components/dataform-layouts/data-form-layout.mjs 35370 var import_jsx_runtime177 = __toESM(require_jsx_runtime(), 1); 35371 var DEFAULT_WRAPPER = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(Stack, { direction: "column", className: "dataforms-layouts__wrapper", gap: "lg", children }); 35372 function DataFormLayout({ 35373 data, 35374 form, 35375 onChange, 35376 validity, 35377 children, 35378 as 35379 }) { 35380 const { fields: fieldDefinitions } = (0, import_element128.useContext)(dataform_context_default); 35381 const markWhenOptional = (0, import_element128.useMemo)(() => { 35382 const requiredCount = fieldDefinitions.filter( 35383 (f2) => !!f2.isValid?.required 35384 ).length; 35385 const optionalCount = fieldDefinitions.length - requiredCount; 35386 return requiredCount > optionalCount; 35387 }, [fieldDefinitions]); 35388 function getFieldDefinition2(field) { 35389 return fieldDefinitions.find( 35390 (fieldDefinition) => fieldDefinition.id === field.id 35391 ); 35392 } 35393 const Wrapper = as ?? getFormFieldLayout(form.layout.type)?.wrapper ?? DEFAULT_WRAPPER; 35394 return /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(Wrapper, { layout: form.layout, children: form.fields.map((formField) => { 35395 const FieldLayout = getFormFieldLayout(formField.layout.type)?.component; 35396 if (!FieldLayout) { 35397 return null; 35398 } 35399 const fieldDefinition = !formField.children ? getFieldDefinition2(formField) : void 0; 35400 if (fieldDefinition && fieldDefinition.isVisible && !fieldDefinition.isVisible(data)) { 35401 return null; 35402 } 35403 if (children) { 35404 return children( 35405 FieldLayout, 35406 formField, 35407 validity?.[formField.id], 35408 markWhenOptional 35409 ); 35410 } 35411 return /* @__PURE__ */ (0, import_jsx_runtime177.jsx)( 35412 FieldLayout, 35413 { 35414 data, 35415 field: formField, 35416 onChange, 35417 markWhenOptional, 35418 validity: validity?.[formField.id] 35419 }, 35420 formField.id 35421 ); 35422 }) }); 35423 } 35424 35425 // packages/dataviews/build-module/dataform/index.mjs 35426 var import_jsx_runtime178 = __toESM(require_jsx_runtime(), 1); 35427 function DataForm({ 35428 data, 35429 form, 35430 fields, 35431 onChange, 35432 validity 35433 }) { 35434 const normalizedForm = (0, import_element129.useMemo)(() => normalize_form_default(form), [form]); 35435 const normalizedFields = (0, import_element129.useMemo)( 35436 () => normalizeFields(fields), 35437 [fields] 35438 ); 35439 if (!form.fields) { 35440 return null; 35441 } 35442 return /* @__PURE__ */ (0, import_jsx_runtime178.jsx)(DataFormProvider, { fields: normalizedFields, children: /* @__PURE__ */ (0, import_jsx_runtime178.jsx)( 35443 DataFormLayout, 35444 { 35445 data, 35446 form: normalizedForm, 35447 onChange, 35448 validity 35449 } 35450 ) }); 35451 } 35452 35453 // packages/content-types/build-module/post-types/list.mjs 35454 var import_core_data9 = __toESM(require_core_data(), 1); 35455 var import_element138 = __toESM(require_element(), 1); 35456 var import_i18n68 = __toESM(require_i18n(), 1); 35457 import { useNavigate as useNavigate3, useSearch } from "@wordpress/route"; 35458 35459 // node_modules/dequal/dist/index.mjs 35460 var has = Object.prototype.hasOwnProperty; 35461 function find(iter, tar, key) { 35462 for (key of iter.keys()) { 35463 if (dequal(key, tar)) return key; 35464 } 35465 } 35466 function dequal(foo, bar) { 35467 var ctor, len, tmp; 35468 if (foo === bar) return true; 35469 if (foo && bar && (ctor = foo.constructor) === bar.constructor) { 35470 if (ctor === Date) return foo.getTime() === bar.getTime(); 35471 if (ctor === RegExp) return foo.toString() === bar.toString(); 35472 if (ctor === Array) { 35473 if ((len = foo.length) === bar.length) { 35474 while (len-- && dequal(foo[len], bar[len])) ; 35475 } 35476 return len === -1; 35477 } 35478 if (ctor === Set) { 35479 if (foo.size !== bar.size) { 35480 return false; 35481 } 35482 for (len of foo) { 35483 tmp = len; 35484 if (tmp && typeof tmp === "object") { 35485 tmp = find(bar, tmp); 35486 if (!tmp) return false; 35487 } 35488 if (!bar.has(tmp)) return false; 35489 } 35490 return true; 35491 } 35492 if (ctor === Map) { 35493 if (foo.size !== bar.size) { 35494 return false; 35495 } 35496 for (len of foo) { 35497 tmp = len[0]; 35498 if (tmp && typeof tmp === "object") { 35499 tmp = find(bar, tmp); 35500 if (!tmp) return false; 35501 } 35502 if (!dequal(len[1], bar.get(tmp))) { 35503 return false; 35504 } 35505 } 35506 return true; 35507 } 35508 if (ctor === ArrayBuffer) { 35509 foo = new Uint8Array(foo); 35510 bar = new Uint8Array(bar); 35511 } else if (ctor === DataView) { 35512 if ((len = foo.byteLength) === bar.byteLength) { 35513 while (len-- && foo.getInt8(len) === bar.getInt8(len)) ; 35514 } 35515 return len === -1; 35516 } 35517 if (ArrayBuffer.isView(foo)) { 35518 if ((len = foo.byteLength) === bar.byteLength) { 35519 while (len-- && foo[len] === bar[len]) ; 35520 } 35521 return len === -1; 35522 } 35523 if (!ctor || typeof foo === "object") { 35524 len = 0; 35525 for (ctor in foo) { 35526 if (has.call(foo, ctor) && ++len && !has.call(bar, ctor)) return false; 35527 if (!(ctor in bar) || !dequal(foo[ctor], bar[ctor])) return false; 35528 } 35529 return Object.keys(bar).length === len; 35530 } 35531 } 35532 return foo !== foo && bar !== bar; 35533 } 35534 35535 // packages/views/build-module/use-view.mjs 35536 var import_element130 = __toESM(require_element(), 1); 35537 var import_data6 = __toESM(require_data(), 1); 35538 var import_preferences = __toESM(require_preferences(), 1); 35539 35540 // packages/views/build-module/preference-keys.mjs 35541 function generatePreferenceKey(kind, name, slug) { 35542 return `dataviews-$kind}-$name}-$slug}`; 35543 } 35544 35545 // packages/views/build-module/resolve-view.mjs 35546 var QUERY_PARAMS = ["page", "search"]; 35547 function isPlainObject(value) { 35548 return typeof value === "object" && value !== null && !Array.isArray(value); 35549 } 35550 function withoutQueryParams(layer) { 35551 const result = isPlainObject(layer) ? { ...layer } : {}; 35552 for (const key of QUERY_PARAMS) { 35553 delete result[key]; 35554 } 35555 return result; 35556 } 35557 function mergeLayer(lower, upper) { 35558 const result = { ...lower }; 35559 for (const key of Object.keys(upper)) { 35560 const value = upper[key]; 35561 const current = result[key]; 35562 result[key] = isPlainObject(current) && isPlainObject(value) ? mergeLayer(current, value) : value; 35563 } 35564 return result; 35565 } 35566 function diffLayer(value, base, persisted = {}) { 35567 const result = {}; 35568 for (const key of Object.keys(value)) { 35569 const next = value[key]; 35570 const current = base[key]; 35571 const prev = persisted[key]; 35572 if (next === void 0) { 35573 continue; 35574 } 35575 if (isPlainObject(next) && isPlainObject(current)) { 35576 const nested = diffLayer( 35577 next, 35578 current, 35579 isPlainObject(prev) ? prev : {} 35580 ); 35581 if (Object.keys(nested).length > 0) { 35582 result[key] = nested; 35583 } 35584 } else if (!dequal(next, current)) { 35585 result[key] = next; 35586 } else if (prev !== void 0 && dequal(next, prev)) { 35587 result[key] = prev; 35588 } 35589 } 35590 return result; 35591 } 35592 function getLockedFilters(overrides) { 35593 return (overrides?.filters ?? []).filter((filter) => filter.isLocked); 35594 } 35595 function applyLockedFilters(view, overrides) { 35596 const locked = getLockedFilters(overrides); 35597 if (locked.length === 0) { 35598 return view; 35599 } 35600 const rest = (view.filters ?? []).filter( 35601 (filter) => !locked.some((f2) => f2.field === filter.field) 35602 ); 35603 return { ...view, filters: [...locked, ...rest] }; 35604 } 35605 function resolveBaseView(layers, effectiveType) { 35606 const { defaultView, defaultLayouts: defaultLayouts3, activeViewOverrides } = layers; 35607 const layoutDefaults = defaultLayouts3?.[effectiveType]; 35608 return applyLockedFilters( 35609 [layoutDefaults, activeViewOverrides].reduce( 35610 (lower, upper) => mergeLayer(lower, withoutQueryParams(upper)), 35611 withoutQueryParams(defaultView) 35612 ), 35613 activeViewOverrides 35614 ); 35615 } 35616 function resolveView(args) { 35617 const { defaultView, activeViewOverrides, persistedView, page, search } = args; 35618 const effectiveType = persistedView?.type ?? activeViewOverrides?.type ?? defaultView?.type; 35619 const baseView = resolveBaseView(args, effectiveType); 35620 const view = { 35621 ...applyLockedFilters( 35622 mergeLayer(baseView, withoutQueryParams(persistedView)), 35623 activeViewOverrides 35624 ), 35625 page: Number(page ?? 1), 35626 search: search ?? "" 35627 }; 35628 return view; 35629 } 35630 function getUserModifications(newView, layers) { 35631 const { activeViewOverrides, persistedView } = layers; 35632 const baseView = resolveBaseView(layers, newView.type); 35633 const modifications = diffLayer( 35634 withoutQueryParams(newView), 35635 withoutQueryParams(baseView), 35636 withoutQueryParams(persistedView) 35637 ); 35638 const locked = getLockedFilters(activeViewOverrides); 35639 if (locked.length > 0 && Array.isArray(modifications.filters)) { 35640 modifications.filters = modifications.filters.filter( 35641 (filter) => !locked.some((f2) => f2.field === filter.field) 35642 ); 35643 } 35644 return Object.keys(modifications).length > 0 ? modifications : void 0; 35645 } 35646 35647 // packages/views/build-module/use-view.mjs 35648 function useView(config) { 35649 const { 35650 kind, 35651 name, 35652 slug, 35653 defaultView, 35654 defaultLayouts: defaultLayouts3, 35655 activeViewOverrides, 35656 queryParams, 35657 onChangeQueryParams 35658 } = config; 35659 const preferenceKey = generatePreferenceKey(kind, name, slug); 35660 const persistedView = (0, import_data6.useSelect)( 35661 (select2) => { 35662 return select2(import_preferences.store).get( 35663 "core/views", 35664 preferenceKey 35665 ); 35666 }, 35667 [preferenceKey] 35668 ); 35669 const { set: set3 } = (0, import_data6.useDispatch)(import_preferences.store); 35670 const page = Number(queryParams?.page ?? 1); 35671 const search = queryParams?.search ?? ""; 35672 const view = (0, import_element130.useMemo)( 35673 () => resolveView({ 35674 defaultView, 35675 defaultLayouts: defaultLayouts3, 35676 activeViewOverrides, 35677 persistedView, 35678 page, 35679 search 35680 }), 35681 [ 35682 defaultView, 35683 defaultLayouts3, 35684 activeViewOverrides, 35685 persistedView, 35686 page, 35687 search 35688 ] 35689 ); 35690 const isModified = !!persistedView && Object.keys(persistedView).length > 0; 35691 const updateView = (0, import_element130.useCallback)( 35692 (newView) => { 35693 const newQueryParams = { 35694 page: Number(newView?.page ?? 1), 35695 search: newView?.search ?? "" 35696 }; 35697 if (onChangeQueryParams && !dequal(newQueryParams, { page, search })) { 35698 onChangeQueryParams(newQueryParams); 35699 } 35700 const modifications = getUserModifications(newView, { 35701 defaultView, 35702 defaultLayouts: defaultLayouts3, 35703 activeViewOverrides, 35704 persistedView 35705 }); 35706 if (!dequal(modifications, persistedView)) { 35707 set3("core/views", preferenceKey, modifications); 35708 } 35709 }, 35710 [ 35711 onChangeQueryParams, 35712 page, 35713 search, 35714 defaultView, 35715 defaultLayouts3, 35716 activeViewOverrides, 35717 persistedView, 35718 set3, 35719 preferenceKey 35720 ] 35721 ); 35722 const resetToDefault = (0, import_element130.useCallback)(() => { 35723 set3("core/views", preferenceKey, void 0); 35724 }, [preferenceKey, set3]); 35725 return { 35726 view, 35727 isModified, 35728 updateView, 35729 resetToDefault 35730 }; 35731 } 35732 35733 // packages/views/build-module/load-view.mjs 35734 var import_data7 = __toESM(require_data(), 1); 35735 var import_preferences2 = __toESM(require_preferences(), 1); 35736 35737 // packages/views/build-module/use-view-config.mjs 35738 var import_data8 = __toESM(require_data(), 1); 35739 var import_core_data = __toESM(require_core_data(), 1); 35740 35741 // packages/views/build-module/lock-unlock.mjs 35742 var import_private_apis4 = __toESM(require_private_apis(), 1); 35743 var { lock: lock4, unlock: unlock4 } = (0, import_private_apis4.__dangerousOptInToUnstableAPIsOnlyForCoreModules)( 35744 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.", 35745 "@wordpress/views" 35746 ); 35747 35748 // packages/content-types/build-module/post-types/actions/activate.mjs 35749 var import_i18n55 = __toESM(require_i18n(), 1); 35750 35751 // packages/content-types/build-module/utils/actions.mjs 35752 var import_core_data2 = __toESM(require_core_data(), 1); 35753 var import_notices = __toESM(require_notices(), 1); 35754 function createStatusAction(config) { 35755 const isEligible = (item) => item.status !== config.targetStatus; 35756 return { 35757 id: config.id, 35758 label: config.label, 35759 supportsBulk: true, 35760 isEligible, 35761 async callback(items, { registry }) { 35762 const itemsToUpdate = items.filter(isEligible); 35763 if (itemsToUpdate.length === 0) { 35764 return; 35765 } 35766 const { saveEntityRecord } = registry.dispatch(import_core_data2.store); 35767 const { createSuccessNotice, createErrorNotice } = registry.dispatch(import_notices.store); 35768 const promiseResult = await Promise.allSettled( 35769 itemsToUpdate.map( 35770 (item) => saveEntityRecord( 35771 "postType", 35772 config.entity, 35773 { id: item.id, status: config.targetStatus }, 35774 { throwOnError: true } 35775 ) 35776 ) 35777 ); 35778 if (promiseResult.every(({ status }) => status === "fulfilled")) { 35779 createSuccessNotice( 35780 itemsToUpdate.length === 1 ? config.messages.successSingle : config.messages.successMany(itemsToUpdate.length), 35781 { type: "snackbar" } 35782 ); 35783 return; 35784 } 35785 let errorMessage; 35786 if (promiseResult.length === 1) { 35787 const typedError = promiseResult[0]; 35788 if (typedError.reason?.message && typedError.reason.code !== "unknown_error") { 35789 errorMessage = typedError.reason.message; 35790 } else { 35791 errorMessage = config.messages.failSingle; 35792 } 35793 } else { 35794 const errorMessages = /* @__PURE__ */ new Set(); 35795 const failedPromises = promiseResult.filter( 35796 ({ status }) => status === "rejected" 35797 ); 35798 for (const failedPromise of failedPromises) { 35799 const typedError = failedPromise; 35800 if (typedError.reason?.message && typedError.reason.code !== "unknown_error") { 35801 errorMessages.add(typedError.reason.message); 35802 } 35803 } 35804 if (errorMessages.size === 0) { 35805 errorMessage = config.messages.failMany; 35806 } else if (errorMessages.size === 1) { 35807 errorMessage = config.messages.errorSingle( 35808 [...errorMessages][0] 35809 ); 35810 } else { 35811 errorMessage = config.messages.errorMany( 35812 [...errorMessages].join(",") 35813 ); 35814 } 35815 } 35816 createErrorNotice(errorMessage, { type: "snackbar" }); 35817 } 35818 }; 35819 } 35820 35821 // packages/content-types/build-module/constants.mjs 35822 var POST_TYPES_PATH = "/post-types"; 35823 var TAXONOMIES_PATH = "/taxonomies"; 35824 var POST_TYPE_ENTITY = "wp_user_post_type"; 35825 var TAXONOMY_ENTITY = "wp_user_taxonomy"; 35826 var NEW_ID = "new"; 35827 35828 // packages/content-types/build-module/post-types/actions/activate.mjs 35829 var activateAction = createStatusAction({ 35830 id: "activate", 35831 label: (0, import_i18n55.__)("Activate"), 35832 entity: POST_TYPE_ENTITY, 35833 targetStatus: "publish", 35834 messages: { 35835 successSingle: (0, import_i18n55.__)("Post type activated."), 35836 successMany: (count) => (0, import_i18n55.sprintf)( 35837 /* translators: %d: The number of post types. */ 35838 (0, import_i18n55._n)( 35839 "%d post type activated.", 35840 "%d post types activated.", 35841 count 35842 ), 35843 count 35844 ), 35845 failSingle: (0, import_i18n55.__)("Failed to activate post type."), 35846 failMany: (0, import_i18n55.__)("Failed to activate post types."), 35847 errorSingle: (message2) => (0, import_i18n55.sprintf)( 35848 /* translators: %s: an error message */ 35849 (0, import_i18n55.__)("An error occurred while activating the post type: %s"), 35850 message2 35851 ), 35852 errorMany: (messages) => (0, import_i18n55.sprintf)( 35853 /* translators: %s: a list of comma separated error messages */ 35854 (0, import_i18n55.__)( 35855 "Some errors occurred while activating the post types: %s" 35856 ), 35857 messages 35858 ) 35859 } 35860 }); 35861 var activate_default = activateAction; 35862 35863 // packages/content-types/build-module/post-types/actions/deactivate.mjs 35864 var import_i18n56 = __toESM(require_i18n(), 1); 35865 var deactivateAction = createStatusAction({ 35866 id: "deactivate", 35867 label: (0, import_i18n56.__)("Deactivate"), 35868 entity: POST_TYPE_ENTITY, 35869 targetStatus: "draft", 35870 messages: { 35871 successSingle: (0, import_i18n56.__)("Post type deactivated."), 35872 successMany: (count) => (0, import_i18n56.sprintf)( 35873 /* translators: %d: The number of post types. */ 35874 (0, import_i18n56._n)( 35875 "%d post type deactivated.", 35876 "%d post types deactivated.", 35877 count 35878 ), 35879 count 35880 ), 35881 failSingle: (0, import_i18n56.__)("Failed to deactivate post type."), 35882 failMany: (0, import_i18n56.__)("Failed to deactivate post types."), 35883 errorSingle: (message2) => (0, import_i18n56.sprintf)( 35884 /* translators: %s: an error message */ 35885 (0, import_i18n56.__)("An error occurred while deactivating the post type: %s"), 35886 message2 35887 ), 35888 errorMany: (messages) => (0, import_i18n56.sprintf)( 35889 /* translators: %s: a list of comma separated error messages */ 35890 (0, import_i18n56.__)( 35891 "Some errors occurred while deactivating the post types: %s" 35892 ), 35893 messages 35894 ) 35895 } 35896 }); 35897 var deactivate_default = deactivateAction; 35898 35899 // packages/content-types/build-module/post-types/actions/delete.mjs 35900 var import_components55 = __toESM(require_components(), 1); 35901 var import_core_data4 = __toESM(require_core_data(), 1); 35902 var import_data10 = __toESM(require_data(), 1); 35903 var import_element132 = __toESM(require_element(), 1); 35904 var import_i18n57 = __toESM(require_i18n(), 1); 35905 var import_notices2 = __toESM(require_notices(), 1); 35906 35907 // packages/content-types/build-module/utils/use-maybe-invalidate-content-type-cache.mjs 35908 var import_element131 = __toESM(require_element(), 1); 35909 var import_core_data3 = __toESM(require_core_data(), 1); 35910 var import_data9 = __toESM(require_data(), 1); 35911 var import_is_shallow_equal = __toESM(require_is_shallow_equal(), 1); 35912 function useMaybeInvalidateContentTypeCache() { 35913 const registry = (0, import_data9.useRegistry)(); 35914 return (0, import_element131.useCallback)( 35915 (prev, next, entityName) => { 35916 if ((0, import_is_shallow_equal.isShallowEqual)([...prev].sort(), [...next].sort())) { 35917 return; 35918 } 35919 const resolvers = registry.select(import_core_data3.store).getCachedResolvers(); 35920 const cache = resolvers.getEntityRecords; 35921 cache?.forEach((_value, args) => { 35922 if (args[0] === "postType" && args[1] === entityName) { 35923 registry.dispatch(import_core_data3.store).invalidateResolution("getEntityRecords", args); 35924 } 35925 }); 35926 }, 35927 [registry] 35928 ); 35929 } 35930 35931 // packages/content-types/build-module/post-types/actions/delete.mjs 35932 var import_jsx_runtime179 = __toESM(require_jsx_runtime(), 1); 35933 function DeletePostTypeModal({ 35934 items, 35935 closeModal, 35936 onActionPerformed 35937 }) { 35938 const [isDeleting, setIsDeleting] = (0, import_element132.useState)(false); 35939 const { deleteEntityRecord } = (0, import_data10.useDispatch)(import_core_data4.store); 35940 const { createSuccessNotice, createErrorNotice } = (0, import_data10.useDispatch)(import_notices2.store); 35941 const maybeInvalidateCache = useMaybeInvalidateContentTypeCache(); 35942 async function onDelete() { 35943 if (isDeleting) { 35944 return; 35945 } 35946 setIsDeleting(true); 35947 const itemsToDelete = items.filter((item) => item.id !== void 0); 35948 const promiseResult = await Promise.allSettled( 35949 itemsToDelete.map( 35950 (item) => deleteEntityRecord( 35951 "postType", 35952 POST_TYPE_ENTITY, 35953 item.id, 35954 { force: true }, 35955 { throwOnError: true } 35956 ) 35957 ) 35958 ); 35959 if (promiseResult.every(({ status }) => status === "fulfilled")) { 35960 createSuccessNotice( 35961 itemsToDelete.length === 1 ? (0, import_i18n57.sprintf)( 35962 /* translators: %s: The post type's plural label. */ 35963 (0, import_i18n57.__)('"%s" post type deleted.'), 35964 itemsToDelete[0].title.raw 35965 ) : (0, import_i18n57.sprintf)( 35966 /* translators: %d: The number of post types. */ 35967 (0, import_i18n57._n)( 35968 "%d post type deleted.", 35969 "%d post types deleted.", 35970 itemsToDelete.length 35971 ), 35972 itemsToDelete.length 35973 ), 35974 { type: "snackbar" } 35975 ); 35976 } else { 35977 let errorMessage; 35978 if (promiseResult.length === 1) { 35979 const typedError = promiseResult[0]; 35980 if (typedError.reason?.message && typedError.reason.code !== "unknown_error") { 35981 errorMessage = typedError.reason.message; 35982 } else { 35983 errorMessage = (0, import_i18n57.__)("Failed to delete post type."); 35984 } 35985 } else { 35986 const errorMessages = /* @__PURE__ */ new Set(); 35987 const failedPromises = promiseResult.filter( 35988 ({ status }) => status === "rejected" 35989 ); 35990 for (const failedPromise of failedPromises) { 35991 const typedError = failedPromise; 35992 if (typedError.reason?.message && typedError.reason.code !== "unknown_error") { 35993 errorMessages.add(typedError.reason.message); 35994 } 35995 } 35996 if (errorMessages.size === 0) { 35997 errorMessage = (0, import_i18n57.__)("Failed to delete post types."); 35998 } else if (errorMessages.size === 1) { 35999 errorMessage = (0, import_i18n57.sprintf)( 36000 /* translators: %s: an error message */ 36001 (0, import_i18n57.__)( 36002 "An error occurred while deleting the post type: %s" 36003 ), 36004 [...errorMessages][0] 36005 ); 36006 } else { 36007 errorMessage = (0, import_i18n57.sprintf)( 36008 /* translators: %s: a list of comma separated error messages */ 36009 (0, import_i18n57.__)( 36010 "Some errors occurred while deleting the post types: %s" 36011 ), 36012 [...errorMessages].join(",") 36013 ); 36014 } 36015 } 36016 createErrorNotice(errorMessage, { type: "snackbar" }); 36017 } 36018 const deletedRefs = itemsToDelete.filter((_, i2) => promiseResult[i2].status === "fulfilled").flatMap((item) => item.config.taxonomies); 36019 maybeInvalidateCache(deletedRefs, [], TAXONOMY_ENTITY); 36020 onActionPerformed?.(itemsToDelete); 36021 setIsDeleting(false); 36022 closeModal?.(); 36023 } 36024 return /* @__PURE__ */ (0, import_jsx_runtime179.jsxs)(Stack, { direction: "column", gap: "md", children: [ 36025 /* @__PURE__ */ (0, import_jsx_runtime179.jsx)(Text, { children: items.length > 1 ? (0, import_i18n57.sprintf)( 36026 /* translators: %d: number of post types to delete. */ 36027 (0, import_i18n57._n)( 36028 "Are you sure you want to delete %d post type?", 36029 "Are you sure you want to delete %d post types?", 36030 items.length 36031 ), 36032 items.length 36033 ) : (0, import_i18n57.sprintf)( 36034 /* translators: %s: The post type's plural label. */ 36035 (0, import_i18n57.__)('Are you sure you want to delete "%s"?'), 36036 items[0].title.raw 36037 ) }), 36038 /* @__PURE__ */ (0, import_jsx_runtime179.jsxs)(Stack, { direction: "row", justify: "flex-end", gap: "sm", children: [ 36039 /* @__PURE__ */ (0, import_jsx_runtime179.jsx)( 36040 import_components55.Button, 36041 { 36042 __next40pxDefaultSize: true, 36043 variant: "tertiary", 36044 onClick: closeModal, 36045 disabled: isDeleting, 36046 accessibleWhenDisabled: true, 36047 children: (0, import_i18n57.__)("Cancel") 36048 } 36049 ), 36050 /* @__PURE__ */ (0, import_jsx_runtime179.jsx)( 36051 import_components55.Button, 36052 { 36053 __next40pxDefaultSize: true, 36054 variant: "primary", 36055 isDestructive: true, 36056 isBusy: isDeleting, 36057 disabled: isDeleting, 36058 accessibleWhenDisabled: true, 36059 onClick: onDelete, 36060 children: (0, import_i18n57._x)("Delete", "verb") 36061 } 36062 ) 36063 ] }) 36064 ] }); 36065 } 36066 var deletePostTypeAction = { 36067 id: "delete-post-type", 36068 label: (0, import_i18n57._x)("Delete", "verb"), 36069 icon: trash_default, 36070 supportsBulk: true, 36071 hideModalHeader: true, 36072 modalFocusOnMount: "firstContentElement", 36073 modalSize: "small", 36074 RenderModal: DeletePostTypeModal 36075 }; 36076 var delete_default = deletePostTypeAction; 36077 36078 // packages/content-types/build-module/post-types/actions/duplicate.mjs 36079 var import_components57 = __toESM(require_components(), 1); 36080 var import_core_data7 = __toESM(require_core_data(), 1); 36081 var import_data13 = __toESM(require_data(), 1); 36082 var import_element135 = __toESM(require_element(), 1); 36083 var import_i18n62 = __toESM(require_i18n(), 1); 36084 var import_notices3 = __toESM(require_notices(), 1); 36085 36086 // packages/content-types/build-module/post-types/fields/general.mjs 36087 var import_core_data6 = __toESM(require_core_data(), 1); 36088 var import_data12 = __toESM(require_data(), 1); 36089 var import_element134 = __toESM(require_element(), 1); 36090 var import_i18n61 = __toESM(require_i18n(), 1); 36091 var import_url4 = __toESM(require_url(), 1); 36092 36093 // packages/content-types/build-module/utils/fields.mjs 36094 var import_components56 = __toESM(require_components(), 1); 36095 var import_i18n58 = __toESM(require_i18n(), 1); 36096 var import_url3 = __toESM(require_url(), 1); 36097 var import_jsx_runtime180 = __toESM(require_jsx_runtime(), 1); 36098 var { ValidatedInputControl: ValidatedInputControl4, ValidatedToggleControl: ValidatedToggleControl2 } = unlock2( 36099 import_components56.privateApis 36100 ); 36101 function getCustomValidity2(validity) { 36102 if (validity?.required?.message) { 36103 return validity.required; 36104 } 36105 if (validity?.pattern) { 36106 return validity.pattern; 36107 } 36108 if (validity?.maxLength) { 36109 return validity.maxLength; 36110 } 36111 return validity?.custom; 36112 } 36113 function createBooleanField(id, label, options) { 36114 const field = { 36115 id, 36116 label, 36117 type: "boolean", 36118 description: options.description, 36119 Edit: "toggle", 36120 getValue: ({ item }) => item.config[id], 36121 setValue: ({ item, value }) => ({ 36122 config: { ...item.config, [id]: !!value } 36123 }), 36124 filterBy: false, 36125 enableSorting: false 36126 }; 36127 if (options.isVisible) { 36128 field.isVisible = options.isVisible; 36129 } 36130 return field; 36131 } 36132 function createLabelField(id, label, options = {}) { 36133 const field = { 36134 id, 36135 label, 36136 type: "text", 36137 placeholder: options.placeholder, 36138 description: options.description, 36139 getValue: ({ item }) => item.config.labels[id] ?? "", 36140 setValue: ({ item, value }) => ({ 36141 config: { 36142 ...item.config, 36143 labels: { 36144 ...item.config.labels, 36145 [id]: String(value ?? "") 36146 } 36147 } 36148 }), 36149 isValid: { 36150 ...options.required ? { required: true } : {}, 36151 // Mirrors the server REST schema: 200 chars for labels. 36152 maxLength: 200 36153 }, 36154 enableSorting: false 36155 }; 36156 if (options.isVisible) { 36157 field.isVisible = options.isVisible; 36158 } 36159 return field; 36160 } 36161 var titleField = { 36162 id: "title", 36163 label: (0, import_i18n58.__)("Title"), 36164 type: "text", 36165 enableGlobalSearch: true, 36166 getValue: ({ item }) => item.title.raw, 36167 setValue: ({ value }) => ({ 36168 title: { raw: String(value ?? "") } 36169 }), 36170 isValid: { 36171 required: true, 36172 // Title is stored as the plural label — mirrors the server REST schema (200 chars). 36173 maxLength: 200 36174 }, 36175 filterBy: false, 36176 enableHiding: false 36177 }; 36178 var pluralLabelField = { 36179 id: "plural_name", 36180 label: (0, import_i18n58.__)("Plural label"), 36181 type: "text", 36182 getValue: ({ item }) => item.title.raw, 36183 setValue: ({ value }) => ({ 36184 title: { raw: String(value ?? "") } 36185 }), 36186 isValid: { 36187 required: true, 36188 maxLength: 200 36189 } 36190 }; 36191 var singularLabelField = createLabelField( 36192 "singular_name", 36193 (0, import_i18n58.__)("Singular label"), 36194 { required: true } 36195 ); 36196 function createDescriptionField(description) { 36197 return { 36198 id: "description", 36199 label: (0, import_i18n58.__)("Description"), 36200 type: "text", 36201 Edit: { control: "textarea", rows: 3 }, 36202 description, 36203 getValue: ({ item }) => item.config.description, 36204 setValue: ({ item, value }) => ({ 36205 config: { ...item.config, description: String(value ?? "") } 36206 }), 36207 // Mirrors the server REST schema (1000 chars for description). 36208 isValid: { maxLength: 1e3 }, 36209 enableSorting: false 36210 }; 36211 } 36212 var statusField = { 36213 id: "status", 36214 label: (0, import_i18n58.__)("Status"), 36215 description: (0, import_i18n58.__)("Enabled and registered with WordPress when active."), 36216 // The field keeps `label: 'Status'` so the filter chip and column header 36217 // read naturally ("Status: Active"); the form toggle uses its own "Active" 36218 // label — the on/off semantic is clearer next to a switch. 36219 Edit: ({ 36220 data, 36221 field, 36222 onChange, 36223 hideLabelFromVision, 36224 markWhenOptional, 36225 validity 36226 }) => { 36227 const isActive = field.getValue({ item: data }) === "publish"; 36228 return /* @__PURE__ */ (0, import_jsx_runtime180.jsx)( 36229 ValidatedToggleControl2, 36230 { 36231 label: (0, import_i18n58.__)("Active"), 36232 hidden: hideLabelFromVision, 36233 help: field.description, 36234 markWhenOptional, 36235 customValidity: getCustomValidity2(validity), 36236 checked: isActive, 36237 onChange: (next) => onChange( 36238 field.setValue({ 36239 item: data, 36240 value: next ? "publish" : "draft" 36241 }) 36242 ) 36243 } 36244 ); 36245 }, 36246 elements: [ 36247 { value: "publish", label: (0, import_i18n58.__)("Active") }, 36248 { value: "draft", label: (0, import_i18n58.__)("Inactive") } 36249 ], 36250 render: ({ item }) => { 36251 const isActive = item.status === "publish"; 36252 return /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(Badge, { intent: isActive ? "stable" : "draft", children: isActive ? (0, import_i18n58.__)("Active") : (0, import_i18n58.__)("Inactive") }); 36253 }, 36254 enableSorting: false 36255 }; 36256 function SlugEdit({ 36257 data, 36258 field, 36259 onChange, 36260 hideLabelFromVision, 36261 markWhenOptional, 36262 validity 36263 }) { 36264 const { label, description, getValue, setValue } = field; 36265 const isValid2 = field.isValid; 36266 const value = getValue({ item: data }) ?? ""; 36267 const handleChange = (newValue) => onChange(setValue({ item: data, value: newValue })); 36268 const onFocus = () => { 36269 if (data.id !== void 0 || data.slug) { 36270 return; 36271 } 36272 const singular = data.config.labels.singular_name?.trim(); 36273 if (!singular) { 36274 return; 36275 } 36276 const cleaned = (0, import_url3.cleanForSlug)(singular); 36277 if (/[^a-z0-9_-]/.test(cleaned)) { 36278 return; 36279 } 36280 const trimmed = cleaned.slice(0, isValid2.maxLength.constraint).replace(/-+$/, ""); 36281 if (trimmed) { 36282 handleChange(trimmed); 36283 } 36284 }; 36285 return /* @__PURE__ */ (0, import_jsx_runtime180.jsx)( 36286 ValidatedInputControl4, 36287 { 36288 required: !!isValid2.required, 36289 markWhenOptional, 36290 customValidity: getCustomValidity2(validity), 36291 label, 36292 value, 36293 help: description, 36294 onChange: handleChange, 36295 onFocus, 36296 hideLabelFromVision, 36297 pattern: isValid2.pattern?.constraint, 36298 maxLength: isValid2.maxLength.constraint 36299 } 36300 ); 36301 } 36302 36303 // packages/content-types/build-module/utils/overflowing-badges.mjs 36304 var import_i18n59 = __toESM(require_i18n(), 1); 36305 var import_jsx_runtime181 = __toESM(require_jsx_runtime(), 1); 36306 var DEFAULT_MAX = 3; 36307 function OverflowingBadges({ 36308 items, 36309 max: max2 = DEFAULT_MAX 36310 }) { 36311 const visible = items.slice(0, max2); 36312 const hidden = items.slice(max2); 36313 const moreLabel = (0, import_i18n59.sprintf)( 36314 /* translators: %d: number of additional items */ 36315 (0, import_i18n59._n)("Show %d more", "Show %d more", hidden.length), 36316 hidden.length 36317 ); 36318 const popoverTitle = (0, import_i18n59.sprintf)( 36319 /* translators: %d: number of additional items */ 36320 (0, import_i18n59._n)("%d more item", "%d more items", hidden.length), 36321 hidden.length 36322 ); 36323 return /* @__PURE__ */ (0, import_jsx_runtime181.jsxs)( 36324 Stack, 36325 { 36326 direction: "row", 36327 wrap: "wrap", 36328 gap: "xs", 36329 align: "center", 36330 render: /* @__PURE__ */ (0, import_jsx_runtime181.jsx)("span", {}), 36331 children: [ 36332 visible.map((item) => /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(Badge, { children: item.label }, item.key)), 36333 hidden.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(tooltip_exports.Provider, { delay: 0, children: /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(tooltip_exports.Root, { children: /* @__PURE__ */ (0, import_jsx_runtime181.jsxs)(popover_exports.Root, { children: [ 36334 /* @__PURE__ */ (0, import_jsx_runtime181.jsx)( 36335 tooltip_exports.Trigger, 36336 { 36337 render: /* @__PURE__ */ (0, import_jsx_runtime181.jsx)( 36338 popover_exports.Trigger, 36339 { 36340 render: /* @__PURE__ */ (0, import_jsx_runtime181.jsx)( 36341 Button4, 36342 { 36343 variant: "outline", 36344 tone: "neutral", 36345 size: "small", 36346 "aria-label": moreLabel, 36347 style: { 36348 minWidth: "auto", 36349 borderRadius: "var(--wpds-border-radius-lg, 8px)", 36350 fontWeight: "normal" 36351 }, 36352 children: (0, import_i18n59.sprintf)( 36353 /* translators: %d: number of additional items */ 36354 (0, import_i18n59.__)("+%d"), 36355 hidden.length 36356 ) 36357 } 36358 ) 36359 } 36360 ) 36361 } 36362 ), 36363 /* @__PURE__ */ (0, import_jsx_runtime181.jsxs)(popover_exports.Popup, { style: { maxWidth: 320 }, children: [ 36364 /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(popover_exports.Title, {}), children: popoverTitle }), 36365 /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(Stack, { direction: "row", wrap: "wrap", gap: "xs", children: hidden.map((item) => /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(Badge, { children: item.label }, item.key)) }) 36366 ] }), 36367 /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(tooltip_exports.Popup, { children: moreLabel }) 36368 ] }) }) }) 36369 ] 36370 } 36371 ); 36372 } 36373 36374 // packages/content-types/build-module/post-types/utils.mjs 36375 var import_core_data5 = __toESM(require_core_data(), 1); 36376 var import_data11 = __toESM(require_data(), 1); 36377 var import_element133 = __toESM(require_element(), 1); 36378 var import_i18n60 = __toESM(require_i18n(), 1); 36379 36380 // packages/content-types/build-module/utils/form-data.mjs 36381 function pickStoredLabels(source, keys) { 36382 const labels = {}; 36383 for (const key of keys) { 36384 const value = source?.[key]; 36385 if (typeof value === "string") { 36386 labels[key] = value; 36387 } 36388 } 36389 return labels; 36390 } 36391 function serializeLabels(source, keys) { 36392 const labels = {}; 36393 for (const key of keys) { 36394 const value = source[key]; 36395 if (typeof value === "string" && value.trim() !== "") { 36396 labels[key] = value.trim(); 36397 } 36398 } 36399 labels.singular_name = source.singular_name; 36400 return labels; 36401 } 36402 36403 // packages/content-types/build-module/post-types/utils.mjs 36404 var DEFAULT_SUPPORTS = ["title", "editor"]; 36405 var BLANK_RECORD = { 36406 slug: "", 36407 status: "publish", 36408 title: { raw: "" }, 36409 config: { 36410 labels: { singular_name: "" }, 36411 taxonomies: [], 36412 supports: [...DEFAULT_SUPPORTS], 36413 description: "", 36414 public: true, 36415 hierarchical: false, 36416 has_archive: false, 36417 show_in_rest: true 36418 } 36419 }; 36420 var STRING_LABEL_KEYS = [ 36421 "singular_name", 36422 "menu_name", 36423 "all_items", 36424 "add_new", 36425 "add_new_item", 36426 "edit_item", 36427 "new_item", 36428 "view_item", 36429 "view_items", 36430 "search_items", 36431 "not_found", 36432 "not_found_in_trash", 36433 "parent_item_colon", 36434 "archives", 36435 "attributes", 36436 "insert_into_item", 36437 "uploaded_to_this_item", 36438 "featured_image", 36439 "set_featured_image", 36440 "remove_featured_image", 36441 "use_featured_image", 36442 "filter_items_list", 36443 "items_list_navigation", 36444 "items_list" 36445 ]; 36446 function deriveLabels(plural, singular) { 36447 const lcPlural = plural.toLowerCase(); 36448 const lcSingular = singular.toLowerCase(); 36449 return { 36450 menu_name: plural, 36451 all_items: (0, import_i18n60.sprintf)( 36452 /* translators: %s: Plural post type label. */ 36453 (0, import_i18n60.__)("All %s"), 36454 plural 36455 ), 36456 add_new: (0, import_i18n60.__)("Add New"), 36457 add_new_item: (0, import_i18n60.sprintf)( 36458 /* translators: %s: Singular post type label. */ 36459 (0, import_i18n60.__)("Add New %s"), 36460 singular 36461 ), 36462 edit_item: (0, import_i18n60.sprintf)( 36463 /* translators: %s: Singular post type label. */ 36464 (0, import_i18n60.__)("Edit %s"), 36465 singular 36466 ), 36467 new_item: (0, import_i18n60.sprintf)( 36468 /* translators: %s: Singular post type label. */ 36469 (0, import_i18n60.__)("New %s"), 36470 singular 36471 ), 36472 view_item: (0, import_i18n60.sprintf)( 36473 /* translators: %s: Singular post type label. */ 36474 (0, import_i18n60.__)("View %s"), 36475 singular 36476 ), 36477 view_items: (0, import_i18n60.sprintf)( 36478 /* translators: %s: Plural post type label. */ 36479 (0, import_i18n60.__)("View %s"), 36480 plural 36481 ), 36482 search_items: (0, import_i18n60.sprintf)( 36483 /* translators: %s: Plural post type label. */ 36484 (0, import_i18n60.__)("Search %s"), 36485 plural 36486 ), 36487 not_found: (0, import_i18n60.sprintf)( 36488 /* translators: %s: Plural post type label, lowercase. */ 36489 (0, import_i18n60.__)("No %s found."), 36490 lcPlural 36491 ), 36492 not_found_in_trash: (0, import_i18n60.sprintf)( 36493 /* translators: %s: Plural post type label, lowercase. */ 36494 (0, import_i18n60.__)("No %s found in Trash."), 36495 lcPlural 36496 ), 36497 parent_item_colon: (0, import_i18n60.sprintf)( 36498 /* translators: %s: Singular post type label. */ 36499 (0, import_i18n60.__)("Parent %s:"), 36500 singular 36501 ), 36502 archives: (0, import_i18n60.sprintf)( 36503 /* translators: %s: Singular post type label. */ 36504 (0, import_i18n60.__)("%s Archives"), 36505 singular 36506 ), 36507 attributes: (0, import_i18n60.sprintf)( 36508 /* translators: %s: Singular post type label. */ 36509 (0, import_i18n60.__)("%s Attributes"), 36510 singular 36511 ), 36512 insert_into_item: (0, import_i18n60.sprintf)( 36513 /* translators: %s: Singular post type label, lowercase. */ 36514 (0, import_i18n60.__)("Insert into %s"), 36515 lcSingular 36516 ), 36517 uploaded_to_this_item: (0, import_i18n60.sprintf)( 36518 /* translators: %s: Singular post type label, lowercase. */ 36519 (0, import_i18n60.__)("Uploaded to this %s"), 36520 lcSingular 36521 ), 36522 featured_image: (0, import_i18n60.__)("Featured image"), 36523 set_featured_image: (0, import_i18n60.__)("Set featured image"), 36524 remove_featured_image: (0, import_i18n60.__)("Remove featured image"), 36525 use_featured_image: (0, import_i18n60.__)("Use as featured image"), 36526 filter_items_list: (0, import_i18n60.sprintf)( 36527 /* translators: %s: Plural post type label, lowercase. */ 36528 (0, import_i18n60.__)("Filter %s list"), 36529 lcPlural 36530 ), 36531 items_list_navigation: (0, import_i18n60.sprintf)( 36532 /* translators: %s: Plural post type label. */ 36533 (0, import_i18n60.__)("%s list navigation"), 36534 plural 36535 ), 36536 items_list: (0, import_i18n60.sprintf)( 36537 /* translators: %s: Plural post type label. */ 36538 (0, import_i18n60.__)("%s list"), 36539 plural 36540 ) 36541 }; 36542 } 36543 var SUPPORT_FEATURES = [ 36544 "title", 36545 "editor", 36546 "thumbnail", 36547 "excerpt", 36548 "comments", 36549 "revisions", 36550 "author", 36551 "page-attributes", 36552 "custom-fields", 36553 "trackbacks", 36554 "post-formats" 36555 ]; 36556 function toFormData(row) { 36557 const config = row.config ?? {}; 36558 const labels = pickStoredLabels( 36559 config.labels, 36560 STRING_LABEL_KEYS 36561 ); 36562 const supports = Array.isArray(config.supports) ? config.supports.filter( 36563 (s2) => SUPPORT_FEATURES.includes(s2) 36564 ) : [...DEFAULT_SUPPORTS]; 36565 return { 36566 id: row.id, 36567 slug: row.slug, 36568 status: row.status, 36569 title: { raw: row.title.raw }, 36570 config: { 36571 labels: { singular_name: "", ...labels }, 36572 taxonomies: Array.isArray(config.taxonomies) ? config.taxonomies : [], 36573 supports, 36574 description: config.description ?? "", 36575 public: config.public ?? true, 36576 hierarchical: config.hierarchical ?? false, 36577 has_archive: config.has_archive ?? false, 36578 show_in_rest: config.show_in_rest ?? true 36579 }, 36580 count: row.count 36581 }; 36582 } 36583 function serializeForSave(data) { 36584 const { config } = data; 36585 const labels = serializeLabels( 36586 config.labels, 36587 STRING_LABEL_KEYS 36588 ); 36589 const description = config.description.trim(); 36590 return { 36591 ...data.id !== void 0 ? { id: data.id } : {}, 36592 slug: data.slug, 36593 status: data.status, 36594 title: data.title.raw, 36595 config: { 36596 labels, 36597 taxonomies: config.taxonomies, 36598 supports: config.supports, 36599 public: config.public, 36600 hierarchical: config.hierarchical, 36601 has_archive: config.has_archive, 36602 show_in_rest: config.show_in_rest, 36603 ...description !== "" ? { description } : {} 36604 } 36605 }; 36606 } 36607 var CORE_TAXONOMY_SLUGS = ["category", "post_tag"]; 36608 function usePublicTaxonomies() { 36609 const taxonomies = (0, import_data11.useSelect)( 36610 (select2) => select2(import_core_data5.store).getTaxonomies({ per_page: -1 }), 36611 [] 36612 ); 36613 return (0, import_element133.useMemo)(() => { 36614 return taxonomies?.filter((t2) => !!t2.visibility?.public).sort((a2, b2) => { 36615 const aIsCore = CORE_TAXONOMY_SLUGS.includes(a2.slug); 36616 const bIsCore = CORE_TAXONOMY_SLUGS.includes(b2.slug); 36617 if (aIsCore !== bIsCore) { 36618 return aIsCore ? -1 : 1; 36619 } 36620 return a2.name.localeCompare(b2.name); 36621 }); 36622 }, [taxonomies]); 36623 } 36624 36625 // packages/content-types/build-module/post-types/fields/general.mjs 36626 var import_jsx_runtime182 = __toESM(require_jsx_runtime(), 1); 36627 var SUPPORT_LABELS = { 36628 title: (0, import_i18n61.__)("Title"), 36629 editor: (0, import_i18n61.__)("Editor"), 36630 thumbnail: (0, import_i18n61.__)("Featured image"), 36631 excerpt: (0, import_i18n61.__)("Excerpt"), 36632 comments: (0, import_i18n61.__)("Comments"), 36633 revisions: (0, import_i18n61.__)("Revisions"), 36634 author: (0, import_i18n61.__)("Author"), 36635 "page-attributes": (0, import_i18n61.__)("Page attributes"), 36636 "custom-fields": (0, import_i18n61.__)("Custom fields"), 36637 trackbacks: (0, import_i18n61.__)("Trackbacks"), 36638 "post-formats": (0, import_i18n61.__)("Post formats") 36639 }; 36640 var descriptionField = createDescriptionField( 36641 (0, import_i18n61.__)( 36642 "Optional summary of the post type. Shown in admin UIs that surface post type details." 36643 ) 36644 ); 36645 var publicField = createBooleanField("public", (0, import_i18n61.__)("Public"), { 36646 description: (0, import_i18n61.__)( 36647 "Whether the post type is intended for use publicly either via the admin interface or by front-end users." 36648 ) 36649 }); 36650 var hierarchicalField = createBooleanField( 36651 "hierarchical", 36652 (0, import_i18n61.__)("Hierarchical"), 36653 { 36654 description: (0, import_i18n61.__)( 36655 "When on, posts of this type can have parent-child relationships like pages, and the parent picker is shown in the editor. When off, they behave like posts." 36656 ) 36657 } 36658 ); 36659 var hasArchiveField = createBooleanField( 36660 "has_archive", 36661 (0, import_i18n61.__)("Has archive"), 36662 { 36663 description: (0, import_i18n61.__)( 36664 "Whether the post type has an archive page (e.g. /book/). Requires permalink rewrite rules to be flushed after enabling." 36665 ) 36666 } 36667 ); 36668 var showInRestField = createBooleanField( 36669 "show_in_rest", 36670 (0, import_i18n61.__)("Show in REST API"), 36671 { 36672 description: (0, import_i18n61.__)( 36673 "Required for the block editor. Disable only if posts of this type should not be available via the REST API." 36674 ) 36675 } 36676 ); 36677 var countField = { 36678 id: "count", 36679 label: (0, import_i18n61.__)("Posts"), 36680 type: "integer", 36681 readOnly: true, 36682 render: ({ item }) => { 36683 const count = item.count; 36684 if (item.status !== "publish" || !count) { 36685 return /* @__PURE__ */ (0, import_jsx_runtime182.jsx)("span", { "aria-hidden": "true", children: "—" }); 36686 } 36687 return /* @__PURE__ */ (0, import_jsx_runtime182.jsx)( 36688 Link, 36689 { 36690 href: (0, import_url4.addQueryArgs)("edit.php", { 36691 post_type: item.slug 36692 }), 36693 children: count 36694 } 36695 ); 36696 }, 36697 enableSorting: false, 36698 filterBy: false 36699 }; 36700 var supportsField = { 36701 id: "supports", 36702 label: (0, import_i18n61.__)("Supports"), 36703 type: "array", 36704 description: (0, import_i18n61.__)( 36705 "Editor features and metadata enabled for posts of this type." 36706 ), 36707 elements: SUPPORT_FEATURES.map((feature) => ({ 36708 value: feature, 36709 label: SUPPORT_LABELS[feature] 36710 })), 36711 enableSorting: false, 36712 getValue: ({ item }) => item.config.supports, 36713 setValue: ({ item, value }) => ({ 36714 config: { 36715 ...item.config, 36716 supports: Array.isArray(value) ? value.filter( 36717 (v2) => SUPPORT_FEATURES.includes(v2) 36718 ) : [] 36719 } 36720 }), 36721 render: ({ item }) => { 36722 const features = item.config.supports; 36723 if (!features || features.length === 0) { 36724 return /* @__PURE__ */ (0, import_jsx_runtime182.jsx)("span", { "aria-hidden": "true", children: "—" }); 36725 } 36726 return /* @__PURE__ */ (0, import_jsx_runtime182.jsx)( 36727 OverflowingBadges, 36728 { 36729 items: features.map((f2) => ({ 36730 key: f2, 36731 label: SUPPORT_LABELS[f2] ?? f2 36732 })) 36733 } 36734 ); 36735 }, 36736 filterBy: false 36737 }; 36738 var SLUG_MAX_LENGTH = 20; 36739 function useSlugField(originalSlug, currentValue) { 36740 const registeredPostTypes = (0, import_data12.useSelect)( 36741 (select2) => select2(import_core_data6.store).getPostTypes(), 36742 [] 36743 ); 36744 const showRenameWarning = originalSlug !== void 0 && currentValue !== originalSlug; 36745 return (0, import_element134.useMemo)( 36746 () => ({ 36747 id: "slug", 36748 label: (0, import_i18n61.__)("Post type key"), 36749 type: "text", 36750 enableGlobalSearch: true, 36751 description: /* @__PURE__ */ (0, import_jsx_runtime182.jsxs)(Stack, { direction: "column", gap: "sm", render: /* @__PURE__ */ (0, import_jsx_runtime182.jsx)("span", {}), children: [ 36752 showRenameWarning && /* @__PURE__ */ (0, import_jsx_runtime182.jsx)(notice_exports.Root, { intent: "warning", render: /* @__PURE__ */ (0, import_jsx_runtime182.jsx)("span", {}), children: /* @__PURE__ */ (0, import_jsx_runtime182.jsx)(notice_exports.Description, { children: (0, import_i18n61.__)( 36753 "Changing the key renames the post type — existing posts may become inaccessible until a migration updates the database." 36754 ) }) }), 36755 /* @__PURE__ */ (0, import_jsx_runtime182.jsx)("span", { children: (0, import_i18n61.__)( 36756 "Lower case letters, numbers, underscores, and dashes only. Maximum length: 20 characters." 36757 ) }) 36758 ] }), 36759 isValid: { 36760 required: true, 36761 pattern: "^[a-z0-9_\\-]+$", 36762 maxLength: SLUG_MAX_LENGTH, 36763 custom: async (value) => { 36764 const slug = value.slug; 36765 if (originalSlug !== void 0 && slug === originalSlug) { 36766 return null; 36767 } 36768 const slugTaken = (registeredPostTypes ?? []).some( 36769 (pt) => pt.slug === slug 36770 ); 36771 if (slugTaken) { 36772 return (0, import_i18n61.__)("This post type key is already in use."); 36773 } 36774 const drafts = await (0, import_data12.resolveSelect)( 36775 import_core_data6.store 36776 ).getEntityRecords("postType", POST_TYPE_ENTITY, { 36777 slug, 36778 status: "draft", 36779 _fields: "id,name", 36780 per_page: 1 36781 }); 36782 return drafts?.length ? (0, import_i18n61.__)("This post type key is already in use.") : null; 36783 } 36784 }, 36785 Edit: SlugEdit, 36786 filterBy: false, 36787 enableSorting: false 36788 }), 36789 [registeredPostTypes, originalSlug, showRenameWarning] 36790 ); 36791 } 36792 function useTaxonomiesField() { 36793 const publicTaxonomies = usePublicTaxonomies(); 36794 return (0, import_element134.useMemo)(() => { 36795 const elements = (publicTaxonomies ?? []).map((tax) => ({ 36796 value: tax.slug, 36797 label: tax.name 36798 })); 36799 const labelMap = Object.fromEntries( 36800 elements.map((e2) => [e2.value, e2.label]) 36801 ); 36802 return { 36803 id: "taxonomies", 36804 label: (0, import_i18n61.__)("Taxonomies"), 36805 type: "array", 36806 description: (0, import_i18n61.__)( 36807 "One or more taxonomies that should be associated with this post type." 36808 ), 36809 elements, 36810 enableSorting: false, 36811 getValue: ({ item }) => item.config.taxonomies, 36812 setValue: ({ item, value }) => ({ 36813 config: { 36814 ...item.config, 36815 taxonomies: Array.isArray(value) ? value : [] 36816 } 36817 }), 36818 render: ({ item }) => { 36819 const slugs = item.config.taxonomies; 36820 if (!slugs || slugs.length === 0) { 36821 return /* @__PURE__ */ (0, import_jsx_runtime182.jsx)("span", { "aria-hidden": "true", children: "—" }); 36822 } 36823 return /* @__PURE__ */ (0, import_jsx_runtime182.jsx)( 36824 OverflowingBadges, 36825 { 36826 items: slugs.map((s2) => ({ 36827 key: s2, 36828 label: labelMap[s2] ?? s2 36829 })) 36830 } 36831 ); 36832 }, 36833 filterBy: false 36834 }; 36835 }, [publicTaxonomies]); 36836 } 36837 var defaultForm = { 36838 layout: { type: "regular" }, 36839 fields: [ 36840 "plural_name", 36841 "singular_name", 36842 "slug", 36843 "taxonomies", 36844 "public", 36845 "hierarchical", 36846 "has_archive", 36847 "status" 36848 ] 36849 }; 36850 var generalForm = { 36851 layout: { type: "regular" }, 36852 fields: [ 36853 "plural_name", 36854 "singular_name", 36855 "slug", 36856 "description", 36857 "taxonomies", 36858 "supports", 36859 "public", 36860 "hierarchical", 36861 "has_archive", 36862 "show_in_rest", 36863 "status" 36864 ] 36865 }; 36866 36867 // packages/content-types/build-module/post-types/actions/duplicate.mjs 36868 var import_jsx_runtime183 = __toESM(require_jsx_runtime(), 1); 36869 var SLUG_MAX_LENGTH2 = 20; 36870 var duplicateForm = { 36871 layout: { type: "regular" }, 36872 fields: ["plural_name", "singular_name", "slug"] 36873 }; 36874 function buildCopySlug(slug) { 36875 const match2 = slug.match(/^(.*?)(\d+)$/); 36876 const base = match2 ? match2[1] : slug; 36877 const nextNumber = String(match2 ? parseInt(match2[2], 10) + 1 : 2); 36878 return `$base.slice( 36879 0, 36880 SLUG_MAX_LENGTH2 - nextNumber.length 36881 )}$nextNumber}`; 36882 } 36883 function DuplicatePostTypeModal({ 36884 items, 36885 closeModal, 36886 onActionPerformed 36887 }) { 36888 const source = items[0]; 36889 const [data, setData] = (0, import_element135.useState)(() => ({ 36890 ...source, 36891 id: void 0, 36892 status: "draft", 36893 title: { 36894 raw: (0, import_i18n62.sprintf)( 36895 /* translators: %s: existing post type title. */ 36896 (0, import_i18n62._x)("%s (Copy)", "post type"), 36897 source.title.raw 36898 ) 36899 }, 36900 slug: buildCopySlug(source.slug) 36901 })); 36902 const [isDuplicating, setIsDuplicating] = (0, import_element135.useState)(false); 36903 const slugField = useSlugField(void 0, data.slug); 36904 const fields = (0, import_element135.useMemo)( 36905 () => [ 36906 pluralLabelField, 36907 singularLabelField, 36908 slugField 36909 ], 36910 [slugField] 36911 ); 36912 const { validity, isValid: isValid2 } = use_form_validity_default( 36913 data, 36914 fields, 36915 duplicateForm 36916 ); 36917 const { saveEntityRecord } = (0, import_data13.useDispatch)(import_core_data7.store); 36918 const { createSuccessNotice, createErrorNotice } = (0, import_data13.useDispatch)(import_notices3.store); 36919 async function onDuplicate() { 36920 if (isDuplicating || !isValid2) { 36921 return; 36922 } 36923 setIsDuplicating(true); 36924 try { 36925 await saveEntityRecord( 36926 "postType", 36927 POST_TYPE_ENTITY, 36928 serializeForSave(data), 36929 { throwOnError: true } 36930 ); 36931 createSuccessNotice( 36932 (0, import_i18n62.sprintf)( 36933 /* translators: %s: post type plural label. */ 36934 (0, import_i18n62.__)('"%s" post type created.'), 36935 data.title.raw 36936 ), 36937 { type: "snackbar" } 36938 ); 36939 onActionPerformed?.(items); 36940 closeModal?.(); 36941 } catch (error2) { 36942 const typedError = error2; 36943 createErrorNotice( 36944 typedError?.message && typedError.code !== "unknown_error" ? typedError.message : (0, import_i18n62.__)("Failed to duplicate post type."), 36945 { type: "snackbar" } 36946 ); 36947 } finally { 36948 setIsDuplicating(false); 36949 } 36950 } 36951 return /* @__PURE__ */ (0, import_jsx_runtime183.jsxs)(Stack, { direction: "column", gap: "md", children: [ 36952 /* @__PURE__ */ (0, import_jsx_runtime183.jsx)( 36953 DataForm, 36954 { 36955 data, 36956 fields, 36957 form: duplicateForm, 36958 validity, 36959 onChange: (edits) => setData( 36960 (prev) => ({ ...prev, ...edits }) 36961 ) 36962 } 36963 ), 36964 /* @__PURE__ */ (0, import_jsx_runtime183.jsxs)(Stack, { direction: "row", justify: "flex-end", gap: "sm", children: [ 36965 /* @__PURE__ */ (0, import_jsx_runtime183.jsx)( 36966 import_components57.Button, 36967 { 36968 __next40pxDefaultSize: true, 36969 variant: "tertiary", 36970 onClick: closeModal, 36971 disabled: isDuplicating, 36972 accessibleWhenDisabled: true, 36973 children: (0, import_i18n62.__)("Cancel") 36974 } 36975 ), 36976 /* @__PURE__ */ (0, import_jsx_runtime183.jsx)( 36977 import_components57.Button, 36978 { 36979 __next40pxDefaultSize: true, 36980 variant: "primary", 36981 isBusy: isDuplicating, 36982 disabled: isDuplicating || !isValid2, 36983 accessibleWhenDisabled: true, 36984 onClick: onDuplicate, 36985 children: (0, import_i18n62._x)("Duplicate", "action label") 36986 } 36987 ) 36988 ] }) 36989 ] }); 36990 } 36991 var duplicatePostTypeAction = { 36992 id: "duplicate-post-type", 36993 label: (0, import_i18n62._x)("Duplicate", "action label"), 36994 icon: copy_default, 36995 modalHeader: (0, import_i18n62.__)("Duplicate post type"), 36996 modalFocusOnMount: "firstContentElement", 36997 RenderModal: DuplicatePostTypeModal 36998 }; 36999 var duplicate_default = duplicatePostTypeAction; 37000 37001 // packages/content-types/build-module/post-types/actions/view-posts.mjs 37002 var import_i18n63 = __toESM(require_i18n(), 1); 37003 var import_url5 = __toESM(require_url(), 1); 37004 var viewPostsAction = { 37005 id: "view-posts", 37006 label: (items) => items[0]?.config.labels.view_items || (items[0]?.config.hierarchical ? (0, import_i18n63.__)("View pages") : (0, import_i18n63.__)("View posts")), 37007 // Drafts are not registered with WordPress, so `edit.php?post_type=…` 37008 // would 404. Only surface the link for active post types. 37009 isEligible: (item) => item.status === "publish", 37010 callback: (items, { onActionPerformed }) => { 37011 const item = items[0]; 37012 if (!item?.slug) { 37013 return; 37014 } 37015 document.location.href = (0, import_url5.addQueryArgs)("edit.php", { 37016 post_type: item.slug 37017 }); 37018 onActionPerformed?.(items); 37019 } 37020 }; 37021 var view_posts_default = viewPostsAction; 37022 37023 // packages/content-types/build-module/post-types/fields/labels.mjs 37024 var import_i18n65 = __toESM(require_i18n(), 1); 37025 37026 // packages/content-types/build-module/utils/labels.mjs 37027 var import_components58 = __toESM(require_components(), 1); 37028 var import_i18n64 = __toESM(require_i18n(), 1); 37029 var import_jsx_runtime184 = __toESM(require_jsx_runtime(), 1); 37030 var LABELS_ACTIONS_FIELD_ID = "__labels_actions"; 37031 function createLabelsActionsField(options) { 37032 const { labelKeys, deriveLabels: deriveLabels3, helpText } = options; 37033 function LabelsActionsEdit({ 37034 data, 37035 onChange 37036 }) { 37037 const plural = data.title.raw.trim(); 37038 const singular = data.config.labels.singular_name.trim(); 37039 const canAutoFill = !!plural.length && !!singular.length; 37040 const currentLabels = data.config.labels; 37041 const hasOverrides = labelKeys.some( 37042 (key) => key !== "singular_name" && (currentLabels[key] ?? "") !== "" 37043 ); 37044 return /* @__PURE__ */ (0, import_jsx_runtime184.jsxs)(Stack, { direction: "column", gap: "md", children: [ 37045 /* @__PURE__ */ (0, import_jsx_runtime184.jsx)(Text, { variant: "body-md", children: helpText }), 37046 /* @__PURE__ */ (0, import_jsx_runtime184.jsxs)(Stack, { direction: "row", justify: "flex-end", gap: "sm", children: [ 37047 /* @__PURE__ */ (0, import_jsx_runtime184.jsx)( 37048 import_components58.Button, 37049 { 37050 __next40pxDefaultSize: true, 37051 variant: "secondary", 37052 size: "compact", 37053 accessibleWhenDisabled: true, 37054 disabled: !canAutoFill, 37055 onClick: () => onChange({ 37056 config: { 37057 ...data.config, 37058 labels: { 37059 ...data.config.labels, 37060 ...deriveLabels3(plural, singular) 37061 } 37062 } 37063 }), 37064 children: (0, import_i18n64.__)("Auto-fill labels") 37065 } 37066 ), 37067 /* @__PURE__ */ (0, import_jsx_runtime184.jsx)( 37068 import_components58.Button, 37069 { 37070 __next40pxDefaultSize: true, 37071 size: "compact", 37072 icon: trash_default, 37073 isDestructive: true, 37074 label: (0, import_i18n64.__)("Clear labels"), 37075 accessibleWhenDisabled: true, 37076 disabled: !hasOverrides, 37077 onClick: () => { 37078 const cleared = { 37079 singular_name: data.config.labels.singular_name 37080 }; 37081 for (const key of labelKeys) { 37082 if (key !== "singular_name") { 37083 cleared[key] = ""; 37084 } 37085 } 37086 onChange({ 37087 config: { ...data.config, labels: cleared } 37088 }); 37089 } 37090 } 37091 ) 37092 ] }) 37093 ] }); 37094 } 37095 return { 37096 id: LABELS_ACTIONS_FIELD_ID, 37097 label: "", 37098 getValue: () => "", 37099 setValue: () => ({}), 37100 Edit: LabelsActionsEdit, 37101 enableSorting: false, 37102 filterBy: false 37103 }; 37104 } 37105 37106 // packages/content-types/build-module/post-types/fields/labels.mjs 37107 var menuNameField = createLabelField("menu_name", (0, import_i18n65.__)("Menu name"), { 37108 placeholder: (0, import_i18n65.__)("Posts"), 37109 description: (0, import_i18n65.__)("Defaults to the plural label.") 37110 }); 37111 var allItemsField = createLabelField("all_items", (0, import_i18n65.__)("All items"), { 37112 placeholder: (0, import_i18n65.__)("All Posts") 37113 }); 37114 var addNewField = createLabelField("add_new", (0, import_i18n65.__)("Add new"), { 37115 placeholder: (0, import_i18n65.__)("Add New"), 37116 description: (0, import_i18n65.__)("Shown in the admin menu and on toolbar buttons.") 37117 }); 37118 var addNewItemLabelField = createLabelField( 37119 "add_new_item", 37120 (0, import_i18n65.__)("Add new item"), 37121 { placeholder: (0, import_i18n65.__)("Add New Post") } 37122 ); 37123 var editItemField = createLabelField("edit_item", (0, import_i18n65.__)("Edit item"), { 37124 placeholder: (0, import_i18n65.__)("Edit Post") 37125 }); 37126 var newItemField = createLabelField("new_item", (0, import_i18n65.__)("New item"), { 37127 placeholder: (0, import_i18n65.__)("New Post") 37128 }); 37129 var viewItemField = createLabelField("view_item", (0, import_i18n65.__)("View item"), { 37130 placeholder: (0, import_i18n65.__)("View Post") 37131 }); 37132 var viewItemsField = createLabelField( 37133 "view_items", 37134 (0, import_i18n65.__)("View items"), 37135 { 37136 placeholder: (0, import_i18n65.__)("View Posts"), 37137 description: (0, import_i18n65.__)("Used as the link label for the post type archive.") 37138 } 37139 ); 37140 var searchItemsField = createLabelField( 37141 "search_items", 37142 (0, import_i18n65.__)("Search items"), 37143 { placeholder: (0, import_i18n65.__)("Search Posts") } 37144 ); 37145 var notFoundField = createLabelField("not_found", (0, import_i18n65.__)("Not found"), { 37146 placeholder: (0, import_i18n65.__)("No posts found."), 37147 description: (0, import_i18n65.__)("Shown in the admin list when no posts match.") 37148 }); 37149 var notFoundInTrashField = createLabelField( 37150 "not_found_in_trash", 37151 (0, import_i18n65.__)("Not found in trash"), 37152 { placeholder: (0, import_i18n65.__)("No posts found in Trash.") } 37153 ); 37154 var archivesField = createLabelField("archives", (0, import_i18n65.__)("Archives"), { 37155 placeholder: (0, import_i18n65.__)("Post Archives"), 37156 description: (0, import_i18n65.__)( 37157 "Used in the navigation menus block when adding a link to the post type archive." 37158 ) 37159 }); 37160 var attributesField = createLabelField( 37161 "attributes", 37162 (0, import_i18n65.__)("Attributes"), 37163 { 37164 placeholder: (0, import_i18n65.__)("Post Attributes"), 37165 description: (0, import_i18n65.__)( 37166 "Title of the Attributes meta box. Not used on non-hierarchical post types." 37167 ), 37168 isVisible: (item) => item.config.hierarchical 37169 } 37170 ); 37171 var parentItemColonField = createLabelField( 37172 "parent_item_colon", 37173 (0, import_i18n65.__)("Parent item with colon"), 37174 { 37175 placeholder: (0, import_i18n65.__)("Parent Page:"), 37176 description: (0, import_i18n65.__)( 37177 "Shown above the parent dropdown. Not used on non-hierarchical post types." 37178 ), 37179 isVisible: (item) => item.config.hierarchical 37180 } 37181 ); 37182 var insertIntoItemField = createLabelField( 37183 "insert_into_item", 37184 (0, import_i18n65.__)("Insert into item"), 37185 { 37186 placeholder: (0, import_i18n65.__)("Insert into post"), 37187 description: (0, import_i18n65.__)("Shown in the media library uploader.") 37188 } 37189 ); 37190 var uploadedToThisItemField = createLabelField( 37191 "uploaded_to_this_item", 37192 (0, import_i18n65.__)("Uploaded to this item"), 37193 { 37194 placeholder: (0, import_i18n65.__)("Uploaded to this post") 37195 } 37196 ); 37197 var featuredImageField = createLabelField( 37198 "featured_image", 37199 (0, import_i18n65.__)("Featured image"), 37200 { 37201 placeholder: (0, import_i18n65.__)("Featured image") 37202 } 37203 ); 37204 var setFeaturedImageField = createLabelField( 37205 "set_featured_image", 37206 (0, import_i18n65.__)("Set featured image"), 37207 { 37208 placeholder: (0, import_i18n65.__)("Set featured image") 37209 } 37210 ); 37211 var removeFeaturedImageField = createLabelField( 37212 "remove_featured_image", 37213 (0, import_i18n65.__)("Remove featured image"), 37214 { 37215 placeholder: (0, import_i18n65.__)("Remove featured image") 37216 } 37217 ); 37218 var useFeaturedImageField = createLabelField( 37219 "use_featured_image", 37220 (0, import_i18n65.__)("Use as featured image"), 37221 { 37222 placeholder: (0, import_i18n65.__)("Use as featured image") 37223 } 37224 ); 37225 var filterItemsListField = createLabelField( 37226 "filter_items_list", 37227 (0, import_i18n65.__)("Filter items list"), 37228 { 37229 placeholder: (0, import_i18n65.__)("Filter posts list"), 37230 description: (0, import_i18n65.__)( 37231 "Screen reader text for the admin list filter controls." 37232 ) 37233 } 37234 ); 37235 var itemsListNavigationField = createLabelField( 37236 "items_list_navigation", 37237 (0, import_i18n65.__)("Items list navigation"), 37238 { 37239 placeholder: (0, import_i18n65.__)("Posts list navigation"), 37240 description: (0, import_i18n65.__)("Screen reader text for the admin list pagination.") 37241 } 37242 ); 37243 var itemsListField = createLabelField( 37244 "items_list", 37245 (0, import_i18n65.__)("Items list"), 37246 { 37247 placeholder: (0, import_i18n65.__)("Posts list"), 37248 description: (0, import_i18n65.__)("Screen reader text for the admin list table.") 37249 } 37250 ); 37251 var labelsActionsField = createLabelsActionsField( 37252 { 37253 labelKeys: STRING_LABEL_KEYS, 37254 deriveLabels, 37255 helpText: (0, import_i18n65.__)( 37256 "Override the text WordPress shows in admin lists, menus, and forms. Auto-fill replaces every label below with values derived from the current plural and singular names — including any you have already customized. Clearing removes all overrides so WordPress falls back to its defaults. If you rename the post type after auto-filling, click Auto-fill again to keep them in sync." 37257 ) 37258 } 37259 ); 37260 var labelsForm = { 37261 layout: { type: "regular" }, 37262 fields: [ 37263 { 37264 id: LABELS_ACTIONS_FIELD_ID, 37265 layout: { type: "regular", labelPosition: "none" } 37266 }, 37267 // singular_name lives in the General card, so exclude it here. 37268 ...STRING_LABEL_KEYS.filter((key) => key !== "singular_name") 37269 ] 37270 }; 37271 37272 // packages/content-types/build-module/post-types/actions/edit.mjs 37273 var import_element136 = __toESM(require_element(), 1); 37274 var import_i18n66 = __toESM(require_i18n(), 1); 37275 import { useNavigate as useNavigate2 } from "@wordpress/route"; 37276 function useEditPostTypeAction() { 37277 const navigate = useNavigate2(); 37278 return (0, import_element136.useMemo)( 37279 () => ({ 37280 id: "edit-post-type", 37281 label: (0, import_i18n66.__)("Edit"), 37282 callback: (items) => { 37283 const item = items[0]; 37284 if (item?.id === void 0) { 37285 return; 37286 } 37287 navigate({ 37288 to: `$POST_TYPES_PATH}/$item.id}` 37289 }); 37290 } 37291 }), 37292 [navigate] 37293 ); 37294 } 37295 37296 // packages/content-types/build-module/post-types/actions/quick-edit.mjs 37297 var import_components59 = __toESM(require_components(), 1); 37298 var import_core_data8 = __toESM(require_core_data(), 1); 37299 var import_data14 = __toESM(require_data(), 1); 37300 var import_element137 = __toESM(require_element(), 1); 37301 var import_i18n67 = __toESM(require_i18n(), 1); 37302 var import_notices4 = __toESM(require_notices(), 1); 37303 var import_jsx_runtime185 = __toESM(require_jsx_runtime(), 1); 37304 function QuickEditPostTypeModal({ 37305 items, 37306 closeModal 37307 }) { 37308 const item = items[0]; 37309 const [data, setData] = (0, import_element137.useState)(item); 37310 const [isSaving, setIsSaving] = (0, import_element137.useState)(false); 37311 const slugField = useSlugField(item.slug, data.slug); 37312 const taxonomiesField = useTaxonomiesField(); 37313 const fields = (0, import_element137.useMemo)( 37314 () => [ 37315 pluralLabelField, 37316 singularLabelField, 37317 slugField, 37318 taxonomiesField, 37319 publicField, 37320 hierarchicalField, 37321 hasArchiveField, 37322 statusField 37323 ], 37324 [slugField, taxonomiesField] 37325 ); 37326 const { validity, isValid: isValid2 } = use_form_validity_default(data, fields, defaultForm); 37327 const { saveEntityRecord } = (0, import_data14.useDispatch)(import_core_data8.store); 37328 const { createSuccessNotice, createErrorNotice } = (0, import_data14.useDispatch)(import_notices4.store); 37329 const maybeInvalidateCache = useMaybeInvalidateContentTypeCache(); 37330 async function onSave() { 37331 if (isSaving || !isValid2) { 37332 return; 37333 } 37334 setIsSaving(true); 37335 try { 37336 await saveEntityRecord( 37337 "postType", 37338 POST_TYPE_ENTITY, 37339 serializeForSave({ ...data, id: item.id }), 37340 { throwOnError: true } 37341 ); 37342 createSuccessNotice( 37343 (0, import_i18n67.sprintf)( 37344 /* translators: %s: post type plural label. */ 37345 (0, import_i18n67.__)('"%s" post type updated.'), 37346 data.title.raw 37347 ), 37348 { type: "snackbar" } 37349 ); 37350 maybeInvalidateCache( 37351 item.config.taxonomies, 37352 data.config.taxonomies, 37353 TAXONOMY_ENTITY 37354 ); 37355 closeModal?.(); 37356 } catch (error2) { 37357 createErrorNotice( 37358 error2?.message && error2?.code !== "unknown_error" ? error2.message : (0, import_i18n67.__)("Failed to update post type."), 37359 { type: "snackbar" } 37360 ); 37361 } finally { 37362 setIsSaving(false); 37363 } 37364 } 37365 return /* @__PURE__ */ (0, import_jsx_runtime185.jsxs)( 37366 "form", 37367 { 37368 onSubmit: (event) => { 37369 event.preventDefault(); 37370 onSave(); 37371 }, 37372 children: [ 37373 /* @__PURE__ */ (0, import_jsx_runtime185.jsxs)( 37374 Stack, 37375 { 37376 className: "dataviews-action-modal__quick-edit-post-type-header", 37377 direction: "row", 37378 justify: "space-between", 37379 align: "center", 37380 children: [ 37381 /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(Text, { variant: "heading-sm", render: /* @__PURE__ */ (0, import_jsx_runtime185.jsx)("h2", {}), children: (0, import_i18n67.__)("Quick edit post type") }), 37382 /* @__PURE__ */ (0, import_jsx_runtime185.jsx)( 37383 import_components59.Button, 37384 { 37385 size: "small", 37386 icon: close_small_default, 37387 label: (0, import_i18n67.__)("Close"), 37388 onClick: closeModal 37389 } 37390 ) 37391 ] 37392 } 37393 ), 37394 /* @__PURE__ */ (0, import_jsx_runtime185.jsx)("div", { className: "dataviews-action-modal__quick-edit-post-type-content", children: /* @__PURE__ */ (0, import_jsx_runtime185.jsx)( 37395 DataForm, 37396 { 37397 data, 37398 fields, 37399 form: defaultForm, 37400 validity, 37401 onChange: (edits) => setData( 37402 (prev) => ({ ...prev, ...edits }) 37403 ) 37404 } 37405 ) }), 37406 /* @__PURE__ */ (0, import_jsx_runtime185.jsxs)( 37407 Stack, 37408 { 37409 className: "dataviews-action-modal__quick-edit-post-type-footer", 37410 direction: "row", 37411 gap: "sm", 37412 children: [ 37413 /* @__PURE__ */ (0, import_jsx_runtime185.jsx)( 37414 import_components59.Button, 37415 { 37416 __next40pxDefaultSize: true, 37417 variant: "secondary", 37418 onClick: closeModal, 37419 children: (0, import_i18n67.__)("Cancel") 37420 } 37421 ), 37422 /* @__PURE__ */ (0, import_jsx_runtime185.jsx)( 37423 import_components59.Button, 37424 { 37425 __next40pxDefaultSize: true, 37426 variant: "primary", 37427 type: "submit", 37428 isBusy: isSaving, 37429 disabled: isSaving || !isValid2, 37430 accessibleWhenDisabled: true, 37431 children: (0, import_i18n67.__)("Done") 37432 } 37433 ) 37434 ] 37435 } 37436 ) 37437 ] 37438 } 37439 ); 37440 } 37441 var quickEditPostTypeAction = { 37442 id: "quick-edit-post-type", 37443 label: (0, import_i18n67.__)("Quick edit"), 37444 icon: pencil_default, 37445 isPrimary: true, 37446 hideModalHeader: true, 37447 RenderModal: QuickEditPostTypeModal 37448 }; 37449 var quick_edit_default = quickEditPostTypeAction; 37450 37451 // packages/content-types/build-module/post-types/list.mjs 37452 var import_jsx_runtime186 = __toESM(require_jsx_runtime(), 1); 37453 var defaultLayouts = { 37454 table: {} 37455 }; 37456 var DEFAULT_VIEW = { 37457 type: "table", 37458 perPage: 20, 37459 page: 1, 37460 fields: ["taxonomies", "count", "status"], 37461 titleField: "title", 37462 layout: { 37463 styles: { 37464 taxonomies: { minWidth: 230 }, 37465 supports: { minWidth: 230 } 37466 } 37467 } 37468 }; 37469 function PostTypesList() { 37470 const navigate = useNavigate3(); 37471 const searchParams = useSearch({ from: POST_TYPES_PATH }); 37472 const handleQueryParamsChange = (0, import_element138.useCallback)( 37473 (params) => { 37474 navigate({ 37475 search: { 37476 ...searchParams, 37477 ...params 37478 } 37479 }); 37480 }, 37481 [searchParams, navigate] 37482 ); 37483 const { view, updateView, isModified, resetToDefault } = useView({ 37484 kind: "postType", 37485 name: POST_TYPE_ENTITY, 37486 slug: "default", 37487 defaultView: DEFAULT_VIEW, 37488 queryParams: searchParams, 37489 onChangeQueryParams: handleQueryParamsChange 37490 }); 37491 const editAction = useEditPostTypeAction(); 37492 const postTypeActions = (0, import_element138.useMemo)( 37493 () => [ 37494 editAction, 37495 quick_edit_default, 37496 duplicate_default, 37497 view_posts_default, 37498 activate_default, 37499 deactivate_default, 37500 delete_default 37501 ], 37502 [editAction] 37503 ); 37504 const slugField = useSlugField(); 37505 const taxonomiesField = useTaxonomiesField(); 37506 const fields = (0, import_element138.useMemo)( 37507 () => [ 37508 titleField, 37509 taxonomiesField, 37510 countField, 37511 statusField, 37512 publicField, 37513 slugField, 37514 hierarchicalField, 37515 hasArchiveField, 37516 supportsField 37517 ], 37518 [slugField, taxonomiesField] 37519 ); 37520 const queryArgs = (0, import_element138.useMemo)(() => { 37521 const statusFilter = view.filters?.find( 37522 (filter) => filter.field === "status" 37523 ); 37524 return { 37525 per_page: view.perPage, 37526 page: view.page, 37527 context: "edit", 37528 order: view.sort?.direction, 37529 orderby: view.sort?.field, 37530 search: view.search, 37531 status: statusFilter?.value ?? ["publish", "draft"] 37532 }; 37533 }, [view]); 37534 const { records, isResolving, hasResolved, totalItems, totalPages } = (0, import_core_data9.useEntityRecords)( 37535 "postType", 37536 POST_TYPE_ENTITY, 37537 queryArgs 37538 ); 37539 const data = (0, import_element138.useMemo)( 37540 () => (records ?? []).map(toFormData), 37541 [records] 37542 ); 37543 const paginationInfo = (0, import_element138.useMemo)( 37544 () => ({ 37545 totalItems: totalItems ?? 0, 37546 totalPages: totalPages ?? 0 37547 }), 37548 [totalItems, totalPages] 37549 ); 37550 return /* @__PURE__ */ (0, import_jsx_runtime186.jsx)( 37551 dataviews_default, 37552 { 37553 data, 37554 fields, 37555 actions: postTypeActions, 37556 view, 37557 onChangeView: updateView, 37558 onReset: isModified ? resetToDefault : false, 37559 isLoading: isResolving || !hasResolved, 37560 paginationInfo, 37561 defaultLayouts, 37562 getItemId: (item) => String(item.id), 37563 isItemClickable: () => true, 37564 onClickItem: (item) => navigate({ 37565 to: `$POST_TYPES_PATH}/$item.id}` 37566 }), 37567 header: /* @__PURE__ */ (0, import_jsx_runtime186.jsx)( 37568 import_components60.Button, 37569 { 37570 variant: "primary", 37571 size: "compact", 37572 __next40pxDefaultSize: true, 37573 onClick: () => navigate({ 37574 to: `$POST_TYPES_PATH}/$NEW_ID}` 37575 }), 37576 children: (0, import_i18n68.__)("Add post type") 37577 } 37578 ) 37579 } 37580 ); 37581 } 37582 37583 // packages/content-types/build-module/post-types/edit.mjs 37584 var import_components61 = __toESM(require_components(), 1); 37585 var import_compose20 = __toESM(require_compose(), 1); 37586 var import_core_data10 = __toESM(require_core_data(), 1); 37587 var import_data15 = __toESM(require_data(), 1); 37588 var import_element139 = __toESM(require_element(), 1); 37589 var import_i18n69 = __toESM(require_i18n(), 1); 37590 var import_notices5 = __toESM(require_notices(), 1); 37591 import { useNavigate as useNavigate4, useParams } from "@wordpress/route"; 37592 var import_jsx_runtime187 = __toESM(require_jsx_runtime(), 1); 37593 function PostTypeEdit() { 37594 const { id } = useParams({ from: `$POST_TYPES_PATH}/$id` }); 37595 const navigate = useNavigate4(); 37596 const isAddMode = id === NEW_ID; 37597 const postTypeId = parseInt(id, 10); 37598 const record = (0, import_data15.useSelect)( 37599 (select2) => { 37600 return !isAddMode && // beforeLoad (route.ts) guarantees the record is in cache. 37601 select2(import_core_data10.store).getEntityRecord( 37602 "postType", 37603 POST_TYPE_ENTITY, 37604 postTypeId 37605 ); 37606 }, 37607 [isAddMode, postTypeId] 37608 ); 37609 const initialData = !isAddMode && record ? toFormData(record) : BLANK_RECORD; 37610 const title = isAddMode ? (0, import_i18n69.__)("Add post type") : initialData.title.raw; 37611 const commonProps = { initialData, title }; 37612 const postTypePageProps = isAddMode ? { 37613 ...commonProps, 37614 isAddMode: true, 37615 breadcrumbLabel: (0, import_i18n69.__)("Add new"), 37616 subTitle: (0, import_i18n69.__)( 37617 "Define a new post type. Fill in the essentials under General; expand Labels to customize." 37618 ), 37619 onSaved: (saved) => navigate({ 37620 to: `$POST_TYPES_PATH}/$saved.id}` 37621 }) 37622 } : { 37623 ...commonProps, 37624 isAddMode: false, 37625 breadcrumbLabel: title, 37626 subTitle: (0, import_i18n69.__)( 37627 "Edit this post type. Expand the Labels section to adjust labels." 37628 ) 37629 }; 37630 return /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(PostTypePage, { ...postTypePageProps }, id); 37631 } 37632 function PostTypePage({ 37633 isAddMode, 37634 initialData, 37635 title, 37636 breadcrumbLabel, 37637 subTitle, 37638 onSaved 37639 }) { 37640 const [data, setData] = (0, import_element139.useState)(initialData); 37641 const [isSaving, setIsSaving] = (0, import_element139.useState)(false); 37642 const originalSlug = !isAddMode ? initialData.slug : void 0; 37643 const slugField = useSlugField(originalSlug, data.slug); 37644 const taxonomiesField = useTaxonomiesField(); 37645 const fields = (0, import_element139.useMemo)( 37646 () => [ 37647 // General 37648 pluralLabelField, 37649 singularLabelField, 37650 slugField, 37651 descriptionField, 37652 taxonomiesField, 37653 supportsField, 37654 publicField, 37655 hierarchicalField, 37656 hasArchiveField, 37657 showInRestField, 37658 statusField, 37659 // Labels 37660 labelsActionsField, 37661 menuNameField, 37662 allItemsField, 37663 addNewField, 37664 addNewItemLabelField, 37665 editItemField, 37666 newItemField, 37667 viewItemField, 37668 viewItemsField, 37669 searchItemsField, 37670 notFoundField, 37671 notFoundInTrashField, 37672 parentItemColonField, 37673 archivesField, 37674 attributesField, 37675 insertIntoItemField, 37676 uploadedToThisItemField, 37677 featuredImageField, 37678 setFeaturedImageField, 37679 removeFeaturedImageField, 37680 useFeaturedImageField, 37681 filterItemsListField, 37682 itemsListNavigationField, 37683 itemsListField 37684 ], 37685 [slugField, taxonomiesField] 37686 ); 37687 const form = (0, import_element139.useMemo)( 37688 () => ({ 37689 layout: { type: "card", isCollapsible: true }, 37690 fields: [ 37691 { 37692 id: "general", 37693 label: (0, import_i18n69.__)("General"), 37694 description: (0, import_i18n69.__)( 37695 "Core identity, taxonomies, supports, and activation." 37696 ), 37697 layout: { 37698 type: "card", 37699 isCollapsible: true, 37700 isOpened: true 37701 }, 37702 children: generalForm.fields 37703 }, 37704 { 37705 id: "labels", 37706 label: (0, import_i18n69.__)("Labels"), 37707 layout: { 37708 type: "card", 37709 isCollapsible: true, 37710 isOpened: false 37711 }, 37712 children: labelsForm.fields 37713 } 37714 ] 37715 }), 37716 [] 37717 ); 37718 const { validity, isValid: isValid2 } = use_form_validity_default(data, fields, form); 37719 const formId = (0, import_compose20.useInstanceId)(PostTypePage, "post-type-form"); 37720 const { saveEntityRecord } = (0, import_data15.useDispatch)(import_core_data10.store); 37721 const { createSuccessNotice, createErrorNotice } = (0, import_data15.useDispatch)(import_notices5.store); 37722 const maybeInvalidateCache = useMaybeInvalidateContentTypeCache(); 37723 async function onSave() { 37724 if (isSaving || !isValid2) { 37725 return; 37726 } 37727 setIsSaving(true); 37728 try { 37729 const saved = await saveEntityRecord( 37730 "postType", 37731 POST_TYPE_ENTITY, 37732 serializeForSave(data), 37733 { throwOnError: true } 37734 ); 37735 const successMessage = isAddMode ? (0, import_i18n69.sprintf)( 37736 /* translators: %s: post type plural label. */ 37737 (0, import_i18n69.__)('"%s" post type created.'), 37738 data.title.raw 37739 ) : (0, import_i18n69.sprintf)( 37740 /* translators: %s: post type plural label. */ 37741 (0, import_i18n69.__)('"%s" post type updated.'), 37742 data.title.raw 37743 ); 37744 createSuccessNotice(successMessage, { type: "snackbar" }); 37745 maybeInvalidateCache( 37746 initialData.config.taxonomies, 37747 data.config.taxonomies, 37748 TAXONOMY_ENTITY 37749 ); 37750 if (saved?.id !== void 0) { 37751 onSaved?.({ ...data, id: saved.id }); 37752 } 37753 } catch (error2) { 37754 let errorMessage; 37755 if (error2?.message && error2?.code !== "unknown_error") { 37756 errorMessage = error2.message; 37757 } else if (isAddMode) { 37758 errorMessage = (0, import_i18n69.__)("Failed to create post type."); 37759 } else { 37760 errorMessage = (0, import_i18n69.__)("Failed to update post type."); 37761 } 37762 createErrorNotice(errorMessage, { type: "snackbar" }); 37763 } finally { 37764 setIsSaving(false); 37765 } 37766 } 37767 return /* @__PURE__ */ (0, import_jsx_runtime187.jsx)( 37768 page_default, 37769 { 37770 ariaLabel: title, 37771 breadcrumbs: /* @__PURE__ */ (0, import_jsx_runtime187.jsx)( 37772 breadcrumbs_default, 37773 { 37774 items: [ 37775 { label: (0, import_i18n69.__)("Post Types"), to: POST_TYPES_PATH }, 37776 { label: breadcrumbLabel } 37777 ] 37778 } 37779 ), 37780 subTitle, 37781 actions: /* @__PURE__ */ (0, import_jsx_runtime187.jsx)( 37782 import_components61.Button, 37783 { 37784 __next40pxDefaultSize: true, 37785 variant: "primary", 37786 size: "compact", 37787 type: "submit", 37788 form: formId, 37789 isBusy: isSaving, 37790 disabled: isSaving || !isValid2, 37791 accessibleWhenDisabled: true, 37792 children: isAddMode ? (0, import_i18n69.__)("Create") : (0, import_i18n69.__)("Save") 37793 } 37794 ), 37795 children: /* @__PURE__ */ (0, import_jsx_runtime187.jsx)( 37796 Stack, 37797 { 37798 direction: "column", 37799 gap: "md", 37800 className: "post-type-form", 37801 render: /* @__PURE__ */ (0, import_jsx_runtime187.jsx)( 37802 "form", 37803 { 37804 id: formId, 37805 onSubmit: (event) => { 37806 event.preventDefault(); 37807 onSave(); 37808 } 37809 } 37810 ), 37811 children: /* @__PURE__ */ (0, import_jsx_runtime187.jsx)( 37812 DataForm, 37813 { 37814 data, 37815 fields, 37816 form, 37817 validity, 37818 onChange: (edits) => setData( 37819 (prev) => ({ 37820 ...prev, 37821 ...edits 37822 }) 37823 ) 37824 } 37825 ) 37826 } 37827 ) 37828 } 37829 ); 37830 } 37831 37832 // packages/content-types/build-module/taxonomies/list.mjs 37833 var import_components65 = __toESM(require_components(), 1); 37834 var import_core_data16 = __toESM(require_core_data(), 1); 37835 var import_element146 = __toESM(require_element(), 1); 37836 var import_i18n82 = __toESM(require_i18n(), 1); 37837 import { useNavigate as useNavigate6, useSearch as useSearch2 } from "@wordpress/route"; 37838 37839 // packages/content-types/build-module/taxonomies/actions/activate.mjs 37840 var import_i18n70 = __toESM(require_i18n(), 1); 37841 var activateAction2 = createStatusAction({ 37842 id: "activate", 37843 label: (0, import_i18n70.__)("Activate"), 37844 entity: TAXONOMY_ENTITY, 37845 targetStatus: "publish", 37846 messages: { 37847 successSingle: (0, import_i18n70.__)("Taxonomy activated."), 37848 successMany: (count) => (0, import_i18n70.sprintf)( 37849 /* translators: %d: The number of taxonomies. */ 37850 (0, import_i18n70._n)( 37851 "%d taxonomy activated.", 37852 "%d taxonomies activated.", 37853 count 37854 ), 37855 count 37856 ), 37857 failSingle: (0, import_i18n70.__)("Failed to activate taxonomy."), 37858 failMany: (0, import_i18n70.__)("Failed to activate taxonomies."), 37859 errorSingle: (message2) => (0, import_i18n70.sprintf)( 37860 /* translators: %s: an error message */ 37861 (0, import_i18n70.__)("An error occurred while activating the taxonomy: %s"), 37862 message2 37863 ), 37864 errorMany: (messages) => (0, import_i18n70.sprintf)( 37865 /* translators: %s: a list of comma separated error messages */ 37866 (0, import_i18n70.__)( 37867 "Some errors occurred while activating the taxonomies: %s" 37868 ), 37869 messages 37870 ) 37871 } 37872 }); 37873 var activate_default2 = activateAction2; 37874 37875 // packages/content-types/build-module/taxonomies/actions/deactivate.mjs 37876 var import_i18n71 = __toESM(require_i18n(), 1); 37877 var deactivateAction2 = createStatusAction({ 37878 id: "deactivate", 37879 label: (0, import_i18n71.__)("Deactivate"), 37880 entity: TAXONOMY_ENTITY, 37881 targetStatus: "draft", 37882 messages: { 37883 successSingle: (0, import_i18n71.__)("Taxonomy deactivated."), 37884 successMany: (count) => (0, import_i18n71.sprintf)( 37885 /* translators: %d: The number of taxonomies. */ 37886 (0, import_i18n71._n)( 37887 "%d taxonomy deactivated.", 37888 "%d taxonomies deactivated.", 37889 count 37890 ), 37891 count 37892 ), 37893 failSingle: (0, import_i18n71.__)("Failed to deactivate taxonomy."), 37894 failMany: (0, import_i18n71.__)("Failed to deactivate taxonomies."), 37895 errorSingle: (message2) => (0, import_i18n71.sprintf)( 37896 /* translators: %s: an error message */ 37897 (0, import_i18n71.__)("An error occurred while deactivating the taxonomy: %s"), 37898 message2 37899 ), 37900 errorMany: (messages) => (0, import_i18n71.sprintf)( 37901 /* translators: %s: a list of comma separated error messages */ 37902 (0, import_i18n71.__)( 37903 "Some errors occurred while deactivating the taxonomies: %s" 37904 ), 37905 messages 37906 ) 37907 } 37908 }); 37909 var deactivate_default2 = deactivateAction2; 37910 37911 // packages/content-types/build-module/taxonomies/actions/delete.mjs 37912 var import_components62 = __toESM(require_components(), 1); 37913 var import_core_data11 = __toESM(require_core_data(), 1); 37914 var import_data16 = __toESM(require_data(), 1); 37915 var import_element140 = __toESM(require_element(), 1); 37916 var import_i18n72 = __toESM(require_i18n(), 1); 37917 var import_notices6 = __toESM(require_notices(), 1); 37918 var import_jsx_runtime188 = __toESM(require_jsx_runtime(), 1); 37919 function DeleteTaxonomyModal({ 37920 items, 37921 closeModal, 37922 onActionPerformed 37923 }) { 37924 const [isDeleting, setIsDeleting] = (0, import_element140.useState)(false); 37925 const { deleteEntityRecord } = (0, import_data16.useDispatch)(import_core_data11.store); 37926 const { createSuccessNotice, createErrorNotice } = (0, import_data16.useDispatch)(import_notices6.store); 37927 const maybeInvalidateCache = useMaybeInvalidateContentTypeCache(); 37928 async function onDelete() { 37929 if (isDeleting) { 37930 return; 37931 } 37932 setIsDeleting(true); 37933 const itemsToDelete = items.filter((item) => item.id !== void 0); 37934 const promiseResult = await Promise.allSettled( 37935 itemsToDelete.map( 37936 (item) => deleteEntityRecord( 37937 "postType", 37938 TAXONOMY_ENTITY, 37939 item.id, 37940 { force: true }, 37941 { throwOnError: true } 37942 ) 37943 ) 37944 ); 37945 if (promiseResult.every(({ status }) => status === "fulfilled")) { 37946 createSuccessNotice( 37947 itemsToDelete.length === 1 ? (0, import_i18n72.sprintf)( 37948 /* translators: %s: The taxonomy's plural label. */ 37949 (0, import_i18n72.__)('"%s" taxonomy deleted.'), 37950 itemsToDelete[0].title.raw 37951 ) : (0, import_i18n72.sprintf)( 37952 /* translators: %d: The number of taxonomies. */ 37953 (0, import_i18n72._n)( 37954 "%d taxonomy deleted.", 37955 "%d taxonomies deleted.", 37956 itemsToDelete.length 37957 ), 37958 itemsToDelete.length 37959 ), 37960 { type: "snackbar" } 37961 ); 37962 } else { 37963 let errorMessage; 37964 if (promiseResult.length === 1) { 37965 const typedError = promiseResult[0]; 37966 if (typedError.reason?.message && typedError.reason.code !== "unknown_error") { 37967 errorMessage = typedError.reason.message; 37968 } else { 37969 errorMessage = (0, import_i18n72.__)("Failed to delete taxonomy."); 37970 } 37971 } else { 37972 const errorMessages = /* @__PURE__ */ new Set(); 37973 const failedPromises = promiseResult.filter( 37974 ({ status }) => status === "rejected" 37975 ); 37976 for (const failedPromise of failedPromises) { 37977 const typedError = failedPromise; 37978 if (typedError.reason?.message && typedError.reason.code !== "unknown_error") { 37979 errorMessages.add(typedError.reason.message); 37980 } 37981 } 37982 if (errorMessages.size === 0) { 37983 errorMessage = (0, import_i18n72.__)("Failed to delete taxonomies."); 37984 } else if (errorMessages.size === 1) { 37985 errorMessage = (0, import_i18n72.sprintf)( 37986 /* translators: %s: an error message */ 37987 (0, import_i18n72.__)( 37988 "An error occurred while deleting the taxonomy: %s" 37989 ), 37990 [...errorMessages][0] 37991 ); 37992 } else { 37993 errorMessage = (0, import_i18n72.sprintf)( 37994 /* translators: %s: a list of comma separated error messages */ 37995 (0, import_i18n72.__)( 37996 "Some errors occurred while deleting the taxonomies: %s" 37997 ), 37998 [...errorMessages].join(",") 37999 ); 38000 } 38001 } 38002 createErrorNotice(errorMessage, { type: "snackbar" }); 38003 } 38004 const deletedRefs = itemsToDelete.filter((_, i2) => promiseResult[i2].status === "fulfilled").flatMap((item) => item.config.object_type); 38005 maybeInvalidateCache(deletedRefs, [], POST_TYPE_ENTITY); 38006 onActionPerformed?.(itemsToDelete); 38007 setIsDeleting(false); 38008 closeModal?.(); 38009 } 38010 return /* @__PURE__ */ (0, import_jsx_runtime188.jsxs)(Stack, { direction: "column", gap: "md", children: [ 38011 /* @__PURE__ */ (0, import_jsx_runtime188.jsx)(Text, { children: items.length > 1 ? (0, import_i18n72.sprintf)( 38012 /* translators: %d: number of taxonomies to delete. */ 38013 (0, import_i18n72._n)( 38014 "Are you sure you want to delete %d taxonomy?", 38015 "Are you sure you want to delete %d taxonomies?", 38016 items.length 38017 ), 38018 items.length 38019 ) : (0, import_i18n72.sprintf)( 38020 /* translators: %s: The taxonomy's plural label. */ 38021 (0, import_i18n72.__)('Are you sure you want to delete "%s"?'), 38022 items[0].title.raw 38023 ) }), 38024 /* @__PURE__ */ (0, import_jsx_runtime188.jsxs)(Stack, { direction: "row", justify: "flex-end", gap: "sm", children: [ 38025 /* @__PURE__ */ (0, import_jsx_runtime188.jsx)( 38026 import_components62.Button, 38027 { 38028 __next40pxDefaultSize: true, 38029 variant: "tertiary", 38030 onClick: closeModal, 38031 disabled: isDeleting, 38032 accessibleWhenDisabled: true, 38033 children: (0, import_i18n72.__)("Cancel") 38034 } 38035 ), 38036 /* @__PURE__ */ (0, import_jsx_runtime188.jsx)( 38037 import_components62.Button, 38038 { 38039 __next40pxDefaultSize: true, 38040 variant: "primary", 38041 isDestructive: true, 38042 isBusy: isDeleting, 38043 disabled: isDeleting, 38044 accessibleWhenDisabled: true, 38045 onClick: onDelete, 38046 children: (0, import_i18n72._x)("Delete", "verb") 38047 } 38048 ) 38049 ] }) 38050 ] }); 38051 } 38052 var deleteTaxonomyAction = { 38053 id: "delete-taxonomy", 38054 label: (0, import_i18n72._x)("Delete", "verb"), 38055 icon: trash_default, 38056 supportsBulk: true, 38057 hideModalHeader: true, 38058 modalFocusOnMount: "firstContentElement", 38059 modalSize: "small", 38060 RenderModal: DeleteTaxonomyModal 38061 }; 38062 var delete_default2 = deleteTaxonomyAction; 38063 38064 // packages/content-types/build-module/taxonomies/actions/duplicate.mjs 38065 var import_components63 = __toESM(require_components(), 1); 38066 var import_core_data14 = __toESM(require_core_data(), 1); 38067 var import_data19 = __toESM(require_data(), 1); 38068 var import_element143 = __toESM(require_element(), 1); 38069 var import_i18n75 = __toESM(require_i18n(), 1); 38070 var import_notices7 = __toESM(require_notices(), 1); 38071 38072 // packages/content-types/build-module/taxonomies/fields/general.mjs 38073 var import_core_data13 = __toESM(require_core_data(), 1); 38074 var import_data18 = __toESM(require_data(), 1); 38075 var import_element142 = __toESM(require_element(), 1); 38076 var import_i18n74 = __toESM(require_i18n(), 1); 38077 var import_url6 = __toESM(require_url(), 1); 38078 38079 // packages/content-types/build-module/taxonomies/utils.mjs 38080 var import_core_data12 = __toESM(require_core_data(), 1); 38081 var import_data17 = __toESM(require_data(), 1); 38082 var import_element141 = __toESM(require_element(), 1); 38083 var import_i18n73 = __toESM(require_i18n(), 1); 38084 var BLANK_RECORD2 = { 38085 slug: "", 38086 status: "publish", 38087 title: { raw: "" }, 38088 config: { 38089 labels: { singular_name: "" }, 38090 object_type: [], 38091 description: "", 38092 public: true, 38093 hierarchical: false, 38094 publicly_queryable: true, 38095 show_ui: true, 38096 show_in_menu: true, 38097 show_in_nav_menus: true, 38098 show_tagcloud: true, 38099 show_in_quick_edit: true, 38100 show_admin_column: false, 38101 show_in_rest: true, 38102 sort: false, 38103 default_term_enabled: false, 38104 default_term: { name: "" } 38105 } 38106 }; 38107 var STRING_LABEL_KEYS2 = [ 38108 "singular_name", 38109 "menu_name", 38110 "all_items", 38111 "edit_item", 38112 "view_item", 38113 "update_item", 38114 "add_new_item", 38115 "new_item_name", 38116 "search_items", 38117 "not_found", 38118 "back_to_items", 38119 "parent_item", 38120 "popular_items", 38121 "separate_items_with_commas", 38122 "parent_item_colon", 38123 "add_or_remove_items", 38124 "choose_from_most_used" 38125 ]; 38126 function deriveLabels2(plural, singular) { 38127 const lcPlural = plural.toLowerCase(); 38128 return { 38129 menu_name: plural, 38130 all_items: (0, import_i18n73.sprintf)( 38131 /* translators: %s: Plural taxonomy label. */ 38132 (0, import_i18n73.__)("All %s"), 38133 plural 38134 ), 38135 edit_item: (0, import_i18n73.sprintf)( 38136 /* translators: %s: Singular taxonomy label. */ 38137 (0, import_i18n73.__)("Edit %s"), 38138 singular 38139 ), 38140 view_item: (0, import_i18n73.sprintf)( 38141 /* translators: %s: Singular taxonomy label. */ 38142 (0, import_i18n73.__)("View %s"), 38143 singular 38144 ), 38145 update_item: (0, import_i18n73.sprintf)( 38146 /* translators: %s: Singular taxonomy label. */ 38147 (0, import_i18n73.__)("Update %s"), 38148 singular 38149 ), 38150 add_new_item: (0, import_i18n73.sprintf)( 38151 /* translators: %s: Singular taxonomy label. */ 38152 (0, import_i18n73.__)("Add New %s"), 38153 singular 38154 ), 38155 new_item_name: (0, import_i18n73.sprintf)( 38156 /* translators: %s: Singular taxonomy label. */ 38157 (0, import_i18n73.__)("New %s Name"), 38158 singular 38159 ), 38160 search_items: (0, import_i18n73.sprintf)( 38161 /* translators: %s: Plural taxonomy label. */ 38162 (0, import_i18n73.__)("Search %s"), 38163 plural 38164 ), 38165 not_found: (0, import_i18n73.sprintf)( 38166 /* translators: %s: Plural taxonomy label, lowercase. */ 38167 (0, import_i18n73.__)("No %s found."), 38168 lcPlural 38169 ), 38170 back_to_items: (0, import_i18n73.sprintf)( 38171 /* translators: %s: Plural taxonomy label. */ 38172 (0, import_i18n73.__)("← Back to %s"), 38173 plural 38174 ), 38175 parent_item: (0, import_i18n73.sprintf)( 38176 /* translators: %s: Singular taxonomy label. */ 38177 (0, import_i18n73.__)("Parent %s"), 38178 singular 38179 ), 38180 popular_items: (0, import_i18n73.sprintf)( 38181 /* translators: %s: Plural taxonomy label. */ 38182 (0, import_i18n73.__)("Popular %s"), 38183 plural 38184 ), 38185 separate_items_with_commas: (0, import_i18n73.sprintf)( 38186 /* translators: %s: Plural taxonomy label, lowercase. */ 38187 (0, import_i18n73.__)("Separate %s with commas"), 38188 lcPlural 38189 ), 38190 parent_item_colon: (0, import_i18n73.sprintf)( 38191 /* translators: %s: Singular taxonomy label. */ 38192 (0, import_i18n73.__)("Parent %s:"), 38193 singular 38194 ), 38195 add_or_remove_items: (0, import_i18n73.sprintf)( 38196 /* translators: %s: Plural taxonomy label, lowercase. */ 38197 (0, import_i18n73.__)("Add or remove %s"), 38198 lcPlural 38199 ), 38200 choose_from_most_used: (0, import_i18n73.sprintf)( 38201 /* translators: %s: Plural taxonomy label, lowercase. */ 38202 (0, import_i18n73.__)("Choose from the most used %s"), 38203 lcPlural 38204 ) 38205 }; 38206 } 38207 function toFormData2(row) { 38208 const config = row.config ?? {}; 38209 const labels = pickStoredLabels( 38210 config.labels, 38211 STRING_LABEL_KEYS2 38212 ); 38213 const defaultTermName = config.default_term?.name ?? ""; 38214 const formConfig = { 38215 labels: { singular_name: "", ...labels }, 38216 object_type: Array.isArray(row.object_type) ? row.object_type : [], 38217 description: config.description ?? "", 38218 public: config.public, 38219 hierarchical: config.hierarchical, 38220 publicly_queryable: config.publicly_queryable, 38221 show_ui: config.show_ui, 38222 show_in_menu: config.show_in_menu, 38223 show_in_nav_menus: config.show_in_nav_menus, 38224 show_tagcloud: config.show_tagcloud, 38225 show_in_quick_edit: config.show_in_quick_edit, 38226 show_admin_column: config.show_admin_column, 38227 show_in_rest: config.show_in_rest, 38228 sort: !!config.sort, 38229 default_term_enabled: defaultTermName !== "", 38230 default_term: { name: defaultTermName } 38231 }; 38232 return { 38233 id: row.id, 38234 slug: row.slug, 38235 status: row.status, 38236 title: { raw: row.title.raw }, 38237 config: formConfig, 38238 count: row.count 38239 }; 38240 } 38241 function serializeForSave2(data) { 38242 const { config } = data; 38243 const labels = serializeLabels( 38244 config.labels, 38245 STRING_LABEL_KEYS2 38246 ); 38247 const description = config.description.trim(); 38248 const defaultTermName = config.default_term.name.trim(); 38249 const includeDefaultTerm = config.default_term_enabled && defaultTermName !== ""; 38250 return { 38251 ...data.id !== void 0 ? { id: data.id } : {}, 38252 slug: data.slug, 38253 status: data.status, 38254 title: data.title.raw, 38255 object_type: config.object_type, 38256 config: { 38257 labels, 38258 public: config.public, 38259 hierarchical: config.hierarchical, 38260 publicly_queryable: config.publicly_queryable, 38261 show_ui: config.show_ui, 38262 show_in_menu: config.show_in_menu, 38263 show_in_nav_menus: config.show_in_nav_menus, 38264 show_tagcloud: config.show_tagcloud, 38265 show_in_quick_edit: config.show_in_quick_edit, 38266 show_admin_column: config.show_admin_column, 38267 show_in_rest: config.show_in_rest, 38268 sort: config.sort, 38269 ...description !== "" ? { description } : {}, 38270 ...includeDefaultTerm ? { default_term: { name: defaultTermName } } : {} 38271 } 38272 }; 38273 } 38274 function usePublicPostTypes() { 38275 const postTypes = (0, import_data17.useSelect)( 38276 (select2) => select2(import_core_data12.store).getPostTypes({ per_page: -1 }), 38277 [] 38278 ); 38279 return (0, import_element141.useMemo)(() => { 38280 return postTypes?.filter(({ viewable }) => viewable).sort((a2, b2) => { 38281 if (a2.slug === "post") { 38282 return -1; 38283 } 38284 if (b2.slug === "post") { 38285 return 1; 38286 } 38287 return a2.name.localeCompare(b2.name); 38288 }); 38289 }, [postTypes]); 38290 } 38291 38292 // packages/content-types/build-module/taxonomies/fields/general.mjs 38293 var import_jsx_runtime189 = __toESM(require_jsx_runtime(), 1); 38294 var descriptionField2 = createDescriptionField( 38295 (0, import_i18n74.__)( 38296 "Optional summary of the taxonomy. Shown in admin UIs that surface taxonomy details." 38297 ) 38298 ); 38299 var hierarchicalField2 = createBooleanField( 38300 "hierarchical", 38301 (0, import_i18n74.__)("Hierarchical"), 38302 { 38303 description: (0, import_i18n74.__)( 38304 "When on, terms behave like categories with parent-child relationships. When off, terms behave like tags." 38305 ) 38306 } 38307 ); 38308 var SLUG_MAX_LENGTH3 = 32; 38309 function useSlugField2(originalSlug, currentValue) { 38310 const registeredTaxonomies = (0, import_data18.useSelect)( 38311 (select2) => select2(import_core_data13.store).getTaxonomies(), 38312 [] 38313 ); 38314 const showRenameWarning = originalSlug !== void 0 && currentValue !== originalSlug; 38315 return (0, import_element142.useMemo)( 38316 () => ({ 38317 id: "slug", 38318 label: (0, import_i18n74.__)("Taxonomy key"), 38319 type: "text", 38320 enableGlobalSearch: true, 38321 description: /* @__PURE__ */ (0, import_jsx_runtime189.jsxs)(Stack, { direction: "column", gap: "sm", render: /* @__PURE__ */ (0, import_jsx_runtime189.jsx)("span", {}), children: [ 38322 showRenameWarning && /* @__PURE__ */ (0, import_jsx_runtime189.jsx)(notice_exports.Root, { intent: "warning", render: /* @__PURE__ */ (0, import_jsx_runtime189.jsx)("span", {}), children: /* @__PURE__ */ (0, import_jsx_runtime189.jsx)(notice_exports.Description, { children: (0, import_i18n74.__)( 38323 "Changing the key renames the taxonomy — existing terms may become inaccessible until a migration updates the database." 38324 ) }) }), 38325 /* @__PURE__ */ (0, import_jsx_runtime189.jsx)("span", { children: (0, import_i18n74.__)( 38326 "Lower case letters, numbers, underscores, and dashes only. Maximum length: 32 characters." 38327 ) }) 38328 ] }), 38329 isValid: { 38330 required: true, 38331 pattern: "^[a-z0-9_\\-]+$", 38332 maxLength: SLUG_MAX_LENGTH3, 38333 custom: async (value) => { 38334 const slug = value.slug; 38335 if (originalSlug !== void 0 && slug === originalSlug) { 38336 return null; 38337 } 38338 const slugTaken = (registeredTaxonomies ?? []).some( 38339 (t2) => t2.slug === slug 38340 ); 38341 if (slugTaken) { 38342 return (0, import_i18n74.__)("This taxonomy key is already in use."); 38343 } 38344 const drafts = await (0, import_data18.resolveSelect)( 38345 import_core_data13.store 38346 ).getEntityRecords("postType", TAXONOMY_ENTITY, { 38347 slug, 38348 status: "draft", 38349 _fields: "id,name", 38350 per_page: 1 38351 }); 38352 return drafts?.length ? (0, import_i18n74.__)("This taxonomy key is already in use.") : null; 38353 } 38354 }, 38355 Edit: SlugEdit, 38356 filterBy: false, 38357 enableSorting: false 38358 }), 38359 [registeredTaxonomies, originalSlug, showRenameWarning] 38360 ); 38361 } 38362 function useObjectTypeField() { 38363 const publicPostTypes = usePublicPostTypes(); 38364 return (0, import_element142.useMemo)(() => { 38365 const elements = (publicPostTypes ?? []).map((pt) => ({ 38366 value: pt.slug, 38367 label: pt.name 38368 })); 38369 const labelMap = Object.fromEntries( 38370 elements.map((e2) => [e2.value, e2.label]) 38371 ); 38372 return { 38373 id: "object_type", 38374 label: (0, import_i18n74.__)("Post types"), 38375 type: "array", 38376 description: (0, import_i18n74.__)( 38377 "One or more post types with which the taxonomy should be associated." 38378 ), 38379 elements, 38380 enableSorting: false, 38381 getValue: ({ item }) => item.config.object_type, 38382 setValue: ({ item, value }) => ({ 38383 config: { 38384 ...item.config, 38385 object_type: Array.isArray(value) ? value : [] 38386 } 38387 }), 38388 render: ({ item }) => { 38389 const slugs = item.config.object_type; 38390 if (!slugs || slugs.length === 0) { 38391 return /* @__PURE__ */ (0, import_jsx_runtime189.jsx)("span", { "aria-hidden": "true", children: "—" }); 38392 } 38393 return /* @__PURE__ */ (0, import_jsx_runtime189.jsx)( 38394 OverflowingBadges, 38395 { 38396 items: slugs.map((s2) => ({ 38397 key: s2, 38398 label: labelMap[s2] ?? s2 38399 })) 38400 } 38401 ); 38402 }, 38403 isValid: { required: true }, 38404 filterBy: { operators: ["isAny"] } 38405 }; 38406 }, [publicPostTypes]); 38407 } 38408 var countField2 = { 38409 id: "count", 38410 label: (0, import_i18n74.__)("Terms"), 38411 type: "integer", 38412 readOnly: true, 38413 render: ({ item }) => { 38414 const count = item.count; 38415 if (item.status !== "publish" || !count) { 38416 return /* @__PURE__ */ (0, import_jsx_runtime189.jsx)("span", { "aria-hidden": "true", children: "—" }); 38417 } 38418 const postType = item.config.object_type?.[0]; 38419 if (!postType) { 38420 return count; 38421 } 38422 return /* @__PURE__ */ (0, import_jsx_runtime189.jsx)( 38423 Link, 38424 { 38425 href: (0, import_url6.addQueryArgs)("edit-tags.php", { 38426 taxonomy: item.slug, 38427 post_type: postType 38428 }), 38429 children: count 38430 } 38431 ); 38432 }, 38433 enableSorting: false, 38434 filterBy: false 38435 }; 38436 var defaultForm2 = { 38437 layout: { type: "regular" }, 38438 fields: [ 38439 "plural_name", 38440 "singular_name", 38441 "slug", 38442 "object_type", 38443 "hierarchical", 38444 "status" 38445 ] 38446 }; 38447 var generalFormFields = [ 38448 "plural_name", 38449 "singular_name", 38450 "slug", 38451 "object_type", 38452 "description", 38453 "hierarchical", 38454 "status" 38455 ]; 38456 38457 // packages/content-types/build-module/taxonomies/actions/duplicate.mjs 38458 var import_jsx_runtime190 = __toESM(require_jsx_runtime(), 1); 38459 var SLUG_MAX_LENGTH4 = 32; 38460 var duplicateForm2 = { 38461 layout: { type: "regular" }, 38462 fields: ["plural_name", "singular_name", "slug"] 38463 }; 38464 function buildCopySlug2(slug) { 38465 const match2 = slug.match(/^(.*?)(\d+)$/); 38466 const base = match2 ? match2[1] : slug; 38467 const nextNumber = String(match2 ? parseInt(match2[2], 10) + 1 : 2); 38468 return `$base.slice( 38469 0, 38470 SLUG_MAX_LENGTH4 - nextNumber.length 38471 )}$nextNumber}`; 38472 } 38473 function DuplicateTaxonomyModal({ 38474 items, 38475 closeModal, 38476 onActionPerformed 38477 }) { 38478 const source = items[0]; 38479 const [data, setData] = (0, import_element143.useState)(() => ({ 38480 ...source, 38481 id: void 0, 38482 status: "draft", 38483 title: { 38484 raw: (0, import_i18n75.sprintf)( 38485 /* translators: %s: existing taxonomy title. */ 38486 (0, import_i18n75._x)("%s (Copy)", "taxonomy"), 38487 source.title.raw 38488 ) 38489 }, 38490 slug: buildCopySlug2(source.slug) 38491 })); 38492 const [isDuplicating, setIsDuplicating] = (0, import_element143.useState)(false); 38493 const slugField = useSlugField2(void 0, data.slug); 38494 const fields = (0, import_element143.useMemo)( 38495 () => [ 38496 pluralLabelField, 38497 singularLabelField, 38498 slugField 38499 ], 38500 [slugField] 38501 ); 38502 const { validity, isValid: isValid2 } = use_form_validity_default( 38503 data, 38504 fields, 38505 duplicateForm2 38506 ); 38507 const { saveEntityRecord } = (0, import_data19.useDispatch)(import_core_data14.store); 38508 const { createSuccessNotice, createErrorNotice } = (0, import_data19.useDispatch)(import_notices7.store); 38509 async function onDuplicate() { 38510 if (isDuplicating || !isValid2) { 38511 return; 38512 } 38513 setIsDuplicating(true); 38514 try { 38515 await saveEntityRecord( 38516 "postType", 38517 TAXONOMY_ENTITY, 38518 serializeForSave2(data), 38519 { throwOnError: true } 38520 ); 38521 createSuccessNotice( 38522 (0, import_i18n75.sprintf)( 38523 /* translators: %s: taxonomy plural label. */ 38524 (0, import_i18n75.__)('"%s" taxonomy created.'), 38525 data.title.raw 38526 ), 38527 { type: "snackbar" } 38528 ); 38529 onActionPerformed?.(items); 38530 closeModal?.(); 38531 } catch (error2) { 38532 const typedError = error2; 38533 createErrorNotice( 38534 typedError?.message && typedError.code !== "unknown_error" ? typedError.message : (0, import_i18n75.__)("Failed to duplicate taxonomy."), 38535 { type: "snackbar" } 38536 ); 38537 } finally { 38538 setIsDuplicating(false); 38539 } 38540 } 38541 return /* @__PURE__ */ (0, import_jsx_runtime190.jsxs)(Stack, { direction: "column", gap: "md", children: [ 38542 /* @__PURE__ */ (0, import_jsx_runtime190.jsx)( 38543 DataForm, 38544 { 38545 data, 38546 fields, 38547 form: duplicateForm2, 38548 validity, 38549 onChange: (edits) => setData( 38550 (prev) => ({ ...prev, ...edits }) 38551 ) 38552 } 38553 ), 38554 /* @__PURE__ */ (0, import_jsx_runtime190.jsxs)(Stack, { direction: "row", justify: "flex-end", gap: "sm", children: [ 38555 /* @__PURE__ */ (0, import_jsx_runtime190.jsx)( 38556 import_components63.Button, 38557 { 38558 __next40pxDefaultSize: true, 38559 variant: "tertiary", 38560 onClick: closeModal, 38561 disabled: isDuplicating, 38562 accessibleWhenDisabled: true, 38563 children: (0, import_i18n75.__)("Cancel") 38564 } 38565 ), 38566 /* @__PURE__ */ (0, import_jsx_runtime190.jsx)( 38567 import_components63.Button, 38568 { 38569 __next40pxDefaultSize: true, 38570 variant: "primary", 38571 isBusy: isDuplicating, 38572 disabled: isDuplicating || !isValid2, 38573 accessibleWhenDisabled: true, 38574 onClick: onDuplicate, 38575 children: (0, import_i18n75._x)("Duplicate", "action label") 38576 } 38577 ) 38578 ] }) 38579 ] }); 38580 } 38581 var duplicateTaxonomyAction = { 38582 id: "duplicate-taxonomy", 38583 label: (0, import_i18n75._x)("Duplicate", "action label"), 38584 icon: copy_default, 38585 modalHeader: (0, import_i18n75.__)("Duplicate taxonomy"), 38586 modalFocusOnMount: "firstContentElement", 38587 RenderModal: DuplicateTaxonomyModal 38588 }; 38589 var duplicate_default2 = duplicateTaxonomyAction; 38590 38591 // packages/content-types/build-module/taxonomies/actions/view-terms.mjs 38592 var import_i18n76 = __toESM(require_i18n(), 1); 38593 var import_url7 = __toESM(require_url(), 1); 38594 var viewTermsAction = { 38595 id: "view-terms", 38596 label: (0, import_i18n76.__)("View terms"), 38597 // Drafts aren't registered, and `edit-tags.php` requires a `post_type` 38598 // query arg to render the term list, so the taxonomy must also be 38599 // attached to at least one post type. 38600 isEligible: (item) => item.status === "publish" && Array.isArray(item.config.object_type) && item.config.object_type.length > 0, 38601 callback: (items, { onActionPerformed }) => { 38602 const item = items[0]; 38603 const postType = item?.config.object_type?.[0]; 38604 if (!item?.slug || !postType) { 38605 return; 38606 } 38607 document.location.href = (0, import_url7.addQueryArgs)("edit-tags.php", { 38608 taxonomy: item.slug, 38609 post_type: postType 38610 }); 38611 onActionPerformed?.(items); 38612 } 38613 }; 38614 var view_terms_default = viewTermsAction; 38615 38616 // packages/content-types/build-module/taxonomies/fields/advanced.mjs 38617 var import_i18n77 = __toESM(require_i18n(), 1); 38618 var sortField = createBooleanField("sort", (0, import_i18n77.__)("Sort terms"), { 38619 description: (0, import_i18n77.__)( 38620 "Whether terms in this taxonomy should be saved in the order they are assigned to an item." 38621 ) 38622 }); 38623 var defaultTermEnabledField = createBooleanField( 38624 "default_term_enabled", 38625 (0, import_i18n77.__)("Set a default term"), 38626 { 38627 description: (0, import_i18n77.__)( 38628 'Default term to be used for the taxonomy, similar to how "Uncategorized" works for categories.' 38629 ) 38630 } 38631 ); 38632 var defaultTermNameField = { 38633 id: "default_term_name", 38634 label: (0, import_i18n77.__)("Default term name"), 38635 type: "text", 38636 description: (0, import_i18n77.__)( 38637 "Once saved, updating the name creates a new term — the previous default term remains in the terms list. To change the term's slug or description, edit it from the terms list." 38638 ), 38639 getValue: ({ item }) => item.config.default_term.name, 38640 setValue: ({ item, value }) => ({ 38641 config: { 38642 ...item.config, 38643 default_term: { name: String(value ?? "") } 38644 } 38645 }), 38646 isValid: { 38647 // `useFormValidity` does not skip invisible fields, so `required: 38648 // true` would mark the form invalid whenever the toggle is off. 38649 // Gate the requirement on the toggle via `custom` instead. 38650 custom: (item) => { 38651 if (!item.config.default_term_enabled) { 38652 return null; 38653 } 38654 return item.config.default_term.name.trim() ? null : (0, import_i18n77.__)("A default term name is required."); 38655 }, 38656 // Mirrors `wp_terms.name` column width (varchar(200)). 38657 maxLength: 200 38658 }, 38659 isVisible: (item) => item.config.default_term_enabled, 38660 enableSorting: false, 38661 filterBy: false 38662 }; 38663 var advancedFormFields = [ 38664 "sort", 38665 "default_term_enabled", 38666 "default_term_name" 38667 ]; 38668 38669 // packages/content-types/build-module/taxonomies/fields/labels.mjs 38670 var import_i18n78 = __toESM(require_i18n(), 1); 38671 var menuNameField2 = createLabelField("menu_name", (0, import_i18n78.__)("Menu name"), { 38672 placeholder: (0, import_i18n78.__)("Categories"), 38673 description: (0, import_i18n78.__)("Defaults to the plural label.") 38674 }); 38675 var allItemsField2 = createLabelField("all_items", (0, import_i18n78.__)("All items"), { 38676 placeholder: (0, import_i18n78.__)("All Categories") 38677 }); 38678 var editItemField2 = createLabelField("edit_item", (0, import_i18n78.__)("Edit item"), { 38679 placeholder: (0, import_i18n78.__)("Edit Category") 38680 }); 38681 var viewItemField2 = createLabelField("view_item", (0, import_i18n78.__)("View item"), { 38682 placeholder: (0, import_i18n78.__)("View Category") 38683 }); 38684 var updateItemField = createLabelField( 38685 "update_item", 38686 (0, import_i18n78.__)("Update item"), 38687 { placeholder: (0, import_i18n78.__)("Update Category") } 38688 ); 38689 var addNewItemLabelField2 = createLabelField( 38690 "add_new_item", 38691 (0, import_i18n78.__)("Add new item"), 38692 { placeholder: (0, import_i18n78.__)("Add New Category") } 38693 ); 38694 var newItemNameField = createLabelField( 38695 "new_item_name", 38696 (0, import_i18n78.__)("New item name"), 38697 { placeholder: (0, import_i18n78.__)("New Category Name") } 38698 ); 38699 var searchItemsField2 = createLabelField( 38700 "search_items", 38701 (0, import_i18n78.__)("Search items"), 38702 { placeholder: (0, import_i18n78.__)("Search Categories") } 38703 ); 38704 var notFoundField2 = createLabelField("not_found", (0, import_i18n78.__)("Not found"), { 38705 placeholder: (0, import_i18n78.__)("No categories found."), 38706 description: (0, import_i18n78.__)( 38707 "The text displayed when no terms are available in the term meta box and tag cloud." 38708 ) 38709 }); 38710 var backToItemsField = createLabelField( 38711 "back_to_items", 38712 (0, import_i18n78.__)("Back to items"), 38713 { 38714 placeholder: (0, import_i18n78.__)("← Back to Categories"), 38715 description: (0, import_i18n78.__)("Label displayed after a term has been updated.") 38716 } 38717 ); 38718 var parentItemField = createLabelField( 38719 "parent_item", 38720 (0, import_i18n78.__)("Parent item"), 38721 { 38722 placeholder: (0, import_i18n78.__)("Parent Category"), 38723 description: (0, import_i18n78.__)("Not used on non-hierarchical taxonomies."), 38724 isVisible: (item) => item.config.hierarchical 38725 } 38726 ); 38727 var popularItemsField = createLabelField( 38728 "popular_items", 38729 (0, import_i18n78.__)("Popular items"), 38730 { 38731 placeholder: (0, import_i18n78.__)("Popular Tags"), 38732 description: (0, import_i18n78.__)( 38733 "The popular items text. Not used on hierarchical taxonomies." 38734 ), 38735 isVisible: (item) => !item.config.hierarchical 38736 } 38737 ); 38738 var separateItemsField = createLabelField( 38739 "separate_items_with_commas", 38740 (0, import_i18n78.__)("Separate items with commas"), 38741 { 38742 placeholder: (0, import_i18n78.__)("Separate tags with commas"), 38743 description: (0, import_i18n78.__)( 38744 "Shown in the taxonomy meta box. Not used on hierarchical taxonomies." 38745 ), 38746 isVisible: (item) => !item.config.hierarchical 38747 } 38748 ); 38749 var parentItemColonField2 = createLabelField( 38750 "parent_item_colon", 38751 (0, import_i18n78.__)("Parent item with colon"), 38752 { 38753 placeholder: (0, import_i18n78.__)("Parent Category:"), 38754 description: (0, import_i18n78.__)("Same as Parent item, with a colon at the end."), 38755 isVisible: (item) => item.config.hierarchical 38756 } 38757 ); 38758 var addOrRemoveItemsField = createLabelField( 38759 "add_or_remove_items", 38760 (0, import_i18n78.__)("Add or remove items"), 38761 { 38762 placeholder: (0, import_i18n78.__)("Add or remove tags"), 38763 description: (0, import_i18n78.__)( 38764 "Shown in the meta box when JavaScript is disabled. Not used on hierarchical taxonomies." 38765 ), 38766 isVisible: (item) => !item.config.hierarchical 38767 } 38768 ); 38769 var chooseFromMostUsedField = createLabelField( 38770 "choose_from_most_used", 38771 (0, import_i18n78.__)("Choose from the most used"), 38772 { 38773 placeholder: (0, import_i18n78.__)("Choose from the most used tags"), 38774 description: (0, import_i18n78.__)( 38775 "Shown in the taxonomy meta box. Not used on hierarchical taxonomies." 38776 ), 38777 isVisible: (item) => !item.config.hierarchical 38778 } 38779 ); 38780 var labelsActionsField2 = createLabelsActionsField( 38781 { 38782 labelKeys: STRING_LABEL_KEYS2, 38783 deriveLabels: deriveLabels2, 38784 helpText: (0, import_i18n78.__)( 38785 "Override the text WordPress shows in admin lists, menus, and forms. Auto-fill replaces every label below with values derived from the current plural and singular names — including any you have already customized. Clearing removes all overrides so WordPress falls back to its defaults. If you rename the taxonomy after auto-filling, click Auto-fill again to keep them in sync." 38786 ) 38787 } 38788 ); 38789 var labelsFormFields = [ 38790 { 38791 id: LABELS_ACTIONS_FIELD_ID, 38792 layout: { type: "regular", labelPosition: "none" } 38793 }, 38794 // singular_name lives in the General card, so exclude it here. 38795 ...STRING_LABEL_KEYS2.filter((key) => key !== "singular_name") 38796 ]; 38797 38798 // packages/content-types/build-module/taxonomies/fields/visibility.mjs 38799 var import_i18n79 = __toESM(require_i18n(), 1); 38800 var publicField2 = createBooleanField("public", (0, import_i18n79.__)("Public"), { 38801 description: (0, import_i18n79.__)( 38802 "Whether a taxonomy is intended for use publicly either via the admin interface or by front-end users." 38803 ) 38804 }); 38805 var showInRestField2 = createBooleanField( 38806 "show_in_rest", 38807 (0, import_i18n79.__)("Show in REST API"), 38808 { 38809 description: (0, import_i18n79.__)( 38810 "Required for the block editor. Turn off only for taxonomies that should not be exposed via REST." 38811 ) 38812 } 38813 ); 38814 var publiclyQueryableField = createBooleanField( 38815 "publicly_queryable", 38816 (0, import_i18n79.__)("Publicly queryable"), 38817 { 38818 description: (0, import_i18n79.__)( 38819 "Whether front-end queries (e.g. ?taxonomy=…&term=…) can return terms from this taxonomy." 38820 ) 38821 } 38822 ); 38823 var showUiField = createBooleanField( 38824 "show_ui", 38825 (0, import_i18n79.__)("Show admin UI"), 38826 { 38827 description: (0, import_i18n79.__)( 38828 "Whether to generate a default admin interface for managing terms." 38829 ) 38830 } 38831 ); 38832 var showInMenuField = createBooleanField( 38833 "show_in_menu", 38834 (0, import_i18n79.__)("Show in admin menu"), 38835 { 38836 description: (0, import_i18n79.__)( 38837 "Whether to show the taxonomy in the admin menu. Has no effect when Show admin UI is off; the value is preserved either way." 38838 ), 38839 // Hide when `show_ui` is off — `show_in_menu` is silently ignored by 38840 // register_taxonomy() in that case, so showing the toggle would be 38841 // misleading. The stored value is preserved across the toggle. 38842 isVisible: (item) => item.config.show_ui 38843 } 38844 ); 38845 var showInQuickEditField = createBooleanField( 38846 "show_in_quick_edit", 38847 (0, import_i18n79.__)("Show in Quick Edit"), 38848 { 38849 description: (0, import_i18n79.__)( 38850 "Whether to show the taxonomy in the Quick/Bulk Edit panel." 38851 ) 38852 } 38853 ); 38854 var showAdminColumnField = createBooleanField( 38855 "show_admin_column", 38856 (0, import_i18n79.__)("Show admin column"), 38857 { 38858 description: (0, import_i18n79.__)( 38859 "Whether to display a column for the taxonomy on the associated post type list tables." 38860 ) 38861 } 38862 ); 38863 var showInNavMenusField = createBooleanField( 38864 "show_in_nav_menus", 38865 (0, import_i18n79.__)("Available in nav menus"), 38866 { 38867 description: (0, import_i18n79.__)( 38868 "Whether terms are selectable in the theme nav menu builder." 38869 ) 38870 } 38871 ); 38872 var showTagcloudField = createBooleanField( 38873 "show_tagcloud", 38874 (0, import_i18n79.__)("Available in Tag Cloud widget"), 38875 { 38876 description: (0, import_i18n79.__)( 38877 "Whether terms can be displayed in the Tag Cloud widget." 38878 ) 38879 } 38880 ); 38881 var visibilityFormFields = [ 38882 "public", 38883 "show_in_rest", 38884 "publicly_queryable", 38885 "show_ui", 38886 "show_in_menu", 38887 "show_in_quick_edit", 38888 "show_in_nav_menus", 38889 "show_tagcloud", 38890 "show_admin_column" 38891 ]; 38892 38893 // packages/content-types/build-module/taxonomies/actions/edit.mjs 38894 var import_element144 = __toESM(require_element(), 1); 38895 var import_i18n80 = __toESM(require_i18n(), 1); 38896 import { useNavigate as useNavigate5 } from "@wordpress/route"; 38897 function useEditTaxonomyAction() { 38898 const navigate = useNavigate5(); 38899 return (0, import_element144.useMemo)( 38900 () => ({ 38901 id: "edit-taxonomy", 38902 label: (0, import_i18n80.__)("Edit"), 38903 callback: (items) => { 38904 const item = items[0]; 38905 if (item?.id === void 0) { 38906 return; 38907 } 38908 navigate({ 38909 to: `$TAXONOMIES_PATH}/$item.id}` 38910 }); 38911 } 38912 }), 38913 [navigate] 38914 ); 38915 } 38916 38917 // packages/content-types/build-module/taxonomies/actions/quick-edit.mjs 38918 var import_components64 = __toESM(require_components(), 1); 38919 var import_core_data15 = __toESM(require_core_data(), 1); 38920 var import_data20 = __toESM(require_data(), 1); 38921 var import_element145 = __toESM(require_element(), 1); 38922 var import_i18n81 = __toESM(require_i18n(), 1); 38923 var import_notices8 = __toESM(require_notices(), 1); 38924 var import_jsx_runtime191 = __toESM(require_jsx_runtime(), 1); 38925 function QuickEditTaxonomyModal({ 38926 items, 38927 closeModal 38928 }) { 38929 const item = items[0]; 38930 const [data, setData] = (0, import_element145.useState)(item); 38931 const [isSaving, setIsSaving] = (0, import_element145.useState)(false); 38932 const slugField = useSlugField2(item.slug, data.slug); 38933 const objectTypeField = useObjectTypeField(); 38934 const fields = (0, import_element145.useMemo)( 38935 () => [ 38936 pluralLabelField, 38937 singularLabelField, 38938 slugField, 38939 objectTypeField, 38940 publicField2, 38941 hierarchicalField2, 38942 statusField 38943 ], 38944 [slugField, objectTypeField] 38945 ); 38946 const { validity, isValid: isValid2 } = use_form_validity_default(data, fields, defaultForm2); 38947 const { saveEntityRecord } = (0, import_data20.useDispatch)(import_core_data15.store); 38948 const { createSuccessNotice, createErrorNotice } = (0, import_data20.useDispatch)(import_notices8.store); 38949 const maybeInvalidateCache = useMaybeInvalidateContentTypeCache(); 38950 async function onSave() { 38951 if (isSaving || !isValid2) { 38952 return; 38953 } 38954 setIsSaving(true); 38955 try { 38956 await saveEntityRecord( 38957 "postType", 38958 TAXONOMY_ENTITY, 38959 serializeForSave2({ ...data, id: item.id }), 38960 { throwOnError: true } 38961 ); 38962 createSuccessNotice( 38963 (0, import_i18n81.sprintf)( 38964 /* translators: %s: taxonomy plural label. */ 38965 (0, import_i18n81.__)('"%s" taxonomy updated.'), 38966 data.title.raw 38967 ), 38968 { type: "snackbar" } 38969 ); 38970 maybeInvalidateCache( 38971 item.config.object_type, 38972 data.config.object_type, 38973 POST_TYPE_ENTITY 38974 ); 38975 closeModal?.(); 38976 } catch (error2) { 38977 createErrorNotice( 38978 error2?.message && error2?.code !== "unknown_error" ? error2.message : (0, import_i18n81.__)("Failed to update taxonomy."), 38979 { type: "snackbar" } 38980 ); 38981 } finally { 38982 setIsSaving(false); 38983 } 38984 } 38985 return /* @__PURE__ */ (0, import_jsx_runtime191.jsxs)( 38986 "form", 38987 { 38988 onSubmit: (event) => { 38989 event.preventDefault(); 38990 onSave(); 38991 }, 38992 children: [ 38993 /* @__PURE__ */ (0, import_jsx_runtime191.jsxs)( 38994 Stack, 38995 { 38996 className: "dataviews-action-modal__quick-edit-taxonomy-header", 38997 direction: "row", 38998 justify: "space-between", 38999 align: "center", 39000 children: [ 39001 /* @__PURE__ */ (0, import_jsx_runtime191.jsx)(Text, { variant: "heading-sm", render: /* @__PURE__ */ (0, import_jsx_runtime191.jsx)("h2", {}), children: (0, import_i18n81.__)("Quick edit taxonomy") }), 39002 /* @__PURE__ */ (0, import_jsx_runtime191.jsx)( 39003 import_components64.Button, 39004 { 39005 size: "small", 39006 icon: close_small_default, 39007 label: (0, import_i18n81.__)("Close"), 39008 onClick: closeModal 39009 } 39010 ) 39011 ] 39012 } 39013 ), 39014 /* @__PURE__ */ (0, import_jsx_runtime191.jsx)("div", { className: "dataviews-action-modal__quick-edit-taxonomy-content", children: /* @__PURE__ */ (0, import_jsx_runtime191.jsx)( 39015 DataForm, 39016 { 39017 data, 39018 fields, 39019 form: defaultForm2, 39020 validity, 39021 onChange: (edits) => setData( 39022 (prev) => ({ ...prev, ...edits }) 39023 ) 39024 } 39025 ) }), 39026 /* @__PURE__ */ (0, import_jsx_runtime191.jsxs)( 39027 Stack, 39028 { 39029 className: "dataviews-action-modal__quick-edit-taxonomy-footer", 39030 direction: "row", 39031 gap: "sm", 39032 children: [ 39033 /* @__PURE__ */ (0, import_jsx_runtime191.jsx)( 39034 import_components64.Button, 39035 { 39036 __next40pxDefaultSize: true, 39037 variant: "secondary", 39038 onClick: closeModal, 39039 children: (0, import_i18n81.__)("Cancel") 39040 } 39041 ), 39042 /* @__PURE__ */ (0, import_jsx_runtime191.jsx)( 39043 import_components64.Button, 39044 { 39045 __next40pxDefaultSize: true, 39046 variant: "primary", 39047 type: "submit", 39048 isBusy: isSaving, 39049 disabled: isSaving || !isValid2, 39050 accessibleWhenDisabled: true, 39051 children: (0, import_i18n81.__)("Done") 39052 } 39053 ) 39054 ] 39055 } 39056 ) 39057 ] 39058 } 39059 ); 39060 } 39061 var quickEditTaxonomyAction = { 39062 id: "quick-edit-taxonomy", 39063 label: (0, import_i18n81.__)("Quick edit"), 39064 icon: pencil_default, 39065 isPrimary: true, 39066 hideModalHeader: true, 39067 RenderModal: QuickEditTaxonomyModal 39068 }; 39069 var quick_edit_default2 = quickEditTaxonomyAction; 39070 39071 // packages/content-types/build-module/taxonomies/list.mjs 39072 var import_jsx_runtime192 = __toESM(require_jsx_runtime(), 1); 39073 var defaultLayouts2 = { 39074 table: {} 39075 }; 39076 var DEFAULT_VIEW2 = { 39077 type: "table", 39078 perPage: 20, 39079 page: 1, 39080 fields: ["object_type", "count", "status"], 39081 titleField: "title", 39082 layout: { 39083 styles: { 39084 object_type: { minWidth: 230 } 39085 } 39086 } 39087 }; 39088 function TaxonomiesList() { 39089 const navigate = useNavigate6(); 39090 const searchParams = useSearch2({ from: TAXONOMIES_PATH }); 39091 const handleQueryParamsChange = (0, import_element146.useCallback)( 39092 (params) => { 39093 navigate({ 39094 search: { 39095 ...searchParams, 39096 ...params 39097 } 39098 }); 39099 }, 39100 [searchParams, navigate] 39101 ); 39102 const { view, updateView, isModified, resetToDefault } = useView({ 39103 kind: "postType", 39104 name: TAXONOMY_ENTITY, 39105 slug: "default", 39106 defaultView: DEFAULT_VIEW2, 39107 queryParams: searchParams, 39108 onChangeQueryParams: handleQueryParamsChange 39109 }); 39110 const editAction = useEditTaxonomyAction(); 39111 const taxonomyActions = (0, import_element146.useMemo)( 39112 () => [ 39113 editAction, 39114 quick_edit_default2, 39115 duplicate_default2, 39116 view_terms_default, 39117 activate_default2, 39118 deactivate_default2, 39119 delete_default2 39120 ], 39121 [editAction] 39122 ); 39123 const slugField = useSlugField2(); 39124 const objectTypeField = useObjectTypeField(); 39125 const fields = (0, import_element146.useMemo)( 39126 () => [ 39127 titleField, 39128 objectTypeField, 39129 countField2, 39130 statusField, 39131 publicField2, 39132 slugField, 39133 hierarchicalField2 39134 ], 39135 [slugField, objectTypeField] 39136 ); 39137 const queryArgs = (0, import_element146.useMemo)(() => { 39138 const statusFilter = view.filters?.find( 39139 (filter) => filter.field === "status" 39140 ); 39141 const objectTypeFilter = view.filters?.find( 39142 (filter) => filter.field === "object_type" 39143 ); 39144 return { 39145 per_page: view.perPage, 39146 page: view.page, 39147 context: "edit", 39148 order: view.sort?.direction, 39149 orderby: view.sort?.field, 39150 search: view.search, 39151 status: statusFilter?.value ?? ["publish", "draft"], 39152 object_type: objectTypeFilter?.value 39153 }; 39154 }, [view]); 39155 const { records, isResolving, hasResolved, totalItems, totalPages } = (0, import_core_data16.useEntityRecords)( 39156 "postType", 39157 TAXONOMY_ENTITY, 39158 queryArgs 39159 ); 39160 const data = (0, import_element146.useMemo)( 39161 () => (records ?? []).map(toFormData2), 39162 [records] 39163 ); 39164 const paginationInfo = (0, import_element146.useMemo)( 39165 () => ({ 39166 totalItems: totalItems ?? 0, 39167 totalPages: totalPages ?? 0 39168 }), 39169 [totalItems, totalPages] 39170 ); 39171 return /* @__PURE__ */ (0, import_jsx_runtime192.jsx)( 39172 dataviews_default, 39173 { 39174 data, 39175 fields, 39176 actions: taxonomyActions, 39177 view, 39178 onChangeView: updateView, 39179 onReset: isModified ? resetToDefault : false, 39180 isLoading: isResolving || !hasResolved, 39181 paginationInfo, 39182 defaultLayouts: defaultLayouts2, 39183 getItemId: (item) => String(item.id), 39184 isItemClickable: () => true, 39185 onClickItem: (item) => navigate({ 39186 to: `$TAXONOMIES_PATH}/$item.id}` 39187 }), 39188 header: /* @__PURE__ */ (0, import_jsx_runtime192.jsx)( 39189 import_components65.Button, 39190 { 39191 variant: "primary", 39192 size: "compact", 39193 __next40pxDefaultSize: true, 39194 onClick: () => navigate({ 39195 to: `$TAXONOMIES_PATH}/$NEW_ID}` 39196 }), 39197 children: (0, import_i18n82.__)("Add taxonomy") 39198 } 39199 ) 39200 } 39201 ); 39202 } 39203 39204 // packages/content-types/build-module/taxonomies/edit.mjs 39205 var import_components66 = __toESM(require_components(), 1); 39206 var import_compose21 = __toESM(require_compose(), 1); 39207 var import_core_data17 = __toESM(require_core_data(), 1); 39208 var import_data21 = __toESM(require_data(), 1); 39209 var import_element147 = __toESM(require_element(), 1); 39210 var import_i18n83 = __toESM(require_i18n(), 1); 39211 var import_notices9 = __toESM(require_notices(), 1); 39212 import { useNavigate as useNavigate7, useParams as useParams2 } from "@wordpress/route"; 39213 var import_jsx_runtime193 = __toESM(require_jsx_runtime(), 1); 39214 function TaxonomyEdit() { 39215 const { id } = useParams2({ from: `$TAXONOMIES_PATH}/$id` }); 39216 const navigate = useNavigate7(); 39217 const isAddMode = id === NEW_ID; 39218 const taxonomyId = parseInt(id, 10); 39219 const record = (0, import_data21.useSelect)( 39220 (select2) => { 39221 return !isAddMode && // beforeLoad (route.ts) guarantees the record is in cache. 39222 select2(import_core_data17.store).getEntityRecord( 39223 "postType", 39224 TAXONOMY_ENTITY, 39225 taxonomyId 39226 ); 39227 }, 39228 [isAddMode, taxonomyId] 39229 ); 39230 const initialData = !isAddMode && record ? toFormData2(record) : BLANK_RECORD2; 39231 const title = isAddMode ? (0, import_i18n83.__)("Add taxonomy") : initialData.title.raw; 39232 const commonProps = { initialData, title }; 39233 const taxonomyPageProps = isAddMode ? { 39234 ...commonProps, 39235 isAddMode: true, 39236 breadcrumbLabel: (0, import_i18n83.__)("Add new"), 39237 subTitle: (0, import_i18n83.__)( 39238 "Define a new taxonomy. Fill in the essentials under General; expand Labels to customize." 39239 ), 39240 onSaved: (saved) => navigate({ 39241 to: `$TAXONOMIES_PATH}/$saved.id}` 39242 }) 39243 } : { 39244 ...commonProps, 39245 isAddMode: false, 39246 breadcrumbLabel: title, 39247 subTitle: (0, import_i18n83.__)( 39248 "Edit this taxonomy. Expand the Labels section to adjust labels." 39249 ) 39250 }; 39251 return /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(TaxonomyPage, { ...taxonomyPageProps }, id); 39252 } 39253 function TaxonomyPage({ 39254 isAddMode, 39255 initialData, 39256 title, 39257 breadcrumbLabel, 39258 subTitle, 39259 onSaved 39260 }) { 39261 const [data, setData] = (0, import_element147.useState)(initialData); 39262 const [isSaving, setIsSaving] = (0, import_element147.useState)(false); 39263 const originalSlug = !isAddMode ? initialData.slug : void 0; 39264 const slugField = useSlugField2(originalSlug, data.slug); 39265 const objectTypeField = useObjectTypeField(); 39266 const fields = (0, import_element147.useMemo)( 39267 () => [ 39268 // General 39269 pluralLabelField, 39270 singularLabelField, 39271 slugField, 39272 descriptionField2, 39273 objectTypeField, 39274 hierarchicalField2, 39275 statusField, 39276 // Visibility 39277 publicField2, 39278 showInRestField2, 39279 publiclyQueryableField, 39280 showUiField, 39281 showInMenuField, 39282 showInQuickEditField, 39283 showAdminColumnField, 39284 showInNavMenusField, 39285 showTagcloudField, 39286 // Labels 39287 labelsActionsField2, 39288 menuNameField2, 39289 allItemsField2, 39290 editItemField2, 39291 viewItemField2, 39292 updateItemField, 39293 addNewItemLabelField2, 39294 newItemNameField, 39295 searchItemsField2, 39296 notFoundField2, 39297 backToItemsField, 39298 parentItemField, 39299 popularItemsField, 39300 separateItemsField, 39301 parentItemColonField2, 39302 addOrRemoveItemsField, 39303 chooseFromMostUsedField, 39304 // Advanced 39305 sortField, 39306 defaultTermEnabledField, 39307 defaultTermNameField 39308 ], 39309 [slugField, objectTypeField] 39310 ); 39311 const form = (0, import_element147.useMemo)( 39312 () => ({ 39313 layout: { type: "card", isCollapsible: true }, 39314 fields: [ 39315 { 39316 id: "general", 39317 label: (0, import_i18n83.__)("General"), 39318 description: (0, import_i18n83.__)( 39319 "Core identity, post types, and activation." 39320 ), 39321 layout: { 39322 type: "card", 39323 isCollapsible: true, 39324 isOpened: true 39325 }, 39326 children: generalFormFields 39327 }, 39328 { 39329 id: "visibility", 39330 label: (0, import_i18n83.__)("Visibility"), 39331 description: (0, import_i18n83.__)( 39332 "Where this taxonomy appears: REST API, admin UI, and front-end surfaces." 39333 ), 39334 layout: { 39335 type: "card", 39336 isCollapsible: true, 39337 isOpened: false 39338 }, 39339 children: visibilityFormFields 39340 }, 39341 { 39342 id: "labels", 39343 label: (0, import_i18n83.__)("Labels"), 39344 layout: { 39345 type: "card", 39346 isCollapsible: true, 39347 isOpened: false 39348 }, 39349 children: labelsFormFields 39350 }, 39351 { 39352 id: "advanced", 39353 label: (0, import_i18n83.__)("Advanced"), 39354 layout: { 39355 type: "card", 39356 isCollapsible: true, 39357 isOpened: false 39358 }, 39359 children: advancedFormFields 39360 } 39361 ] 39362 }), 39363 [] 39364 ); 39365 const { validity, isValid: isValid2 } = use_form_validity_default(data, fields, form); 39366 const formId = (0, import_compose21.useInstanceId)(TaxonomyPage, "taxonomy-form"); 39367 const { saveEntityRecord } = (0, import_data21.useDispatch)(import_core_data17.store); 39368 const { createSuccessNotice, createErrorNotice } = (0, import_data21.useDispatch)(import_notices9.store); 39369 const maybeInvalidateCache = useMaybeInvalidateContentTypeCache(); 39370 async function onSave() { 39371 if (isSaving || !isValid2) { 39372 return; 39373 } 39374 setIsSaving(true); 39375 try { 39376 const saved = await saveEntityRecord( 39377 "postType", 39378 TAXONOMY_ENTITY, 39379 serializeForSave2(data), 39380 { throwOnError: true } 39381 ); 39382 const successMessage = isAddMode ? (0, import_i18n83.sprintf)( 39383 /* translators: %s: taxonomy plural label. */ 39384 (0, import_i18n83.__)('"%s" taxonomy created.'), 39385 data.title.raw 39386 ) : (0, import_i18n83.sprintf)( 39387 /* translators: %s: taxonomy plural label. */ 39388 (0, import_i18n83.__)('"%s" taxonomy updated.'), 39389 data.title.raw 39390 ); 39391 createSuccessNotice(successMessage, { type: "snackbar" }); 39392 maybeInvalidateCache( 39393 initialData.config.object_type, 39394 data.config.object_type, 39395 POST_TYPE_ENTITY 39396 ); 39397 if (saved?.id !== void 0) { 39398 onSaved?.({ ...data, id: saved.id }); 39399 } 39400 } catch (error2) { 39401 let errorMessage; 39402 if (error2?.message && error2?.code !== "unknown_error") { 39403 errorMessage = error2.message; 39404 } else if (isAddMode) { 39405 errorMessage = (0, import_i18n83.__)("Failed to create taxonomy."); 39406 } else { 39407 errorMessage = (0, import_i18n83.__)("Failed to update taxonomy."); 39408 } 39409 createErrorNotice(errorMessage, { type: "snackbar" }); 39410 } finally { 39411 setIsSaving(false); 39412 } 39413 } 39414 return /* @__PURE__ */ (0, import_jsx_runtime193.jsx)( 39415 page_default, 39416 { 39417 ariaLabel: title, 39418 breadcrumbs: /* @__PURE__ */ (0, import_jsx_runtime193.jsx)( 39419 breadcrumbs_default, 39420 { 39421 items: [ 39422 { label: (0, import_i18n83.__)("Taxonomies"), to: TAXONOMIES_PATH }, 39423 { label: breadcrumbLabel } 39424 ] 39425 } 39426 ), 39427 subTitle, 39428 actions: /* @__PURE__ */ (0, import_jsx_runtime193.jsx)( 39429 import_components66.Button, 39430 { 39431 __next40pxDefaultSize: true, 39432 variant: "primary", 39433 size: "compact", 39434 type: "submit", 39435 form: formId, 39436 isBusy: isSaving, 39437 disabled: isSaving || !isValid2, 39438 accessibleWhenDisabled: true, 39439 children: isAddMode ? (0, import_i18n83.__)("Create") : (0, import_i18n83.__)("Save") 39440 } 39441 ), 39442 children: /* @__PURE__ */ (0, import_jsx_runtime193.jsx)( 39443 Stack, 39444 { 39445 direction: "column", 39446 gap: "md", 39447 className: "taxonomy-form", 39448 render: /* @__PURE__ */ (0, import_jsx_runtime193.jsx)( 39449 "form", 39450 { 39451 id: formId, 39452 onSubmit: (event) => { 39453 event.preventDefault(); 39454 onSave(); 39455 } 39456 } 39457 ), 39458 children: /* @__PURE__ */ (0, import_jsx_runtime193.jsx)( 39459 DataForm, 39460 { 39461 data, 39462 fields, 39463 form, 39464 validity, 39465 onChange: (edits) => setData( 39466 (prev) => ({ 39467 ...prev, 39468 ...edits 39469 }) 39470 ) 39471 } 39472 ) 39473 } 39474 ) 39475 } 39476 ); 39477 } 39478 export { 39479 Layout, 39480 NEW_ID, 39481 POST_TYPES_PATH, 39482 POST_TYPE_ENTITY, 39483 PostTypeEdit, 39484 PostTypesList, 39485 TAXONOMIES_PATH, 39486 TAXONOMY_ENTITY, 39487 TaxonomiesList, 39488 TaxonomyEdit 39489 }; 39490 /*! Bundled license information: 39491 39492 use-sync-external-store/cjs/use-sync-external-store-shim.development.js: 39493 (** 39494 * @license React 39495 * use-sync-external-store-shim.development.js 39496 * 39497 * Copyright (c) Meta Platforms, Inc. and affiliates. 39498 * 39499 * This source code is licensed under the MIT license found in the 39500 * LICENSE file in the root directory of this source tree. 39501 *) 39502 39503 use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js: 39504 (** 39505 * @license React 39506 * use-sync-external-store-shim/with-selector.development.js 39507 * 39508 * Copyright (c) Meta Platforms, Inc. and affiliates. 39509 * 39510 * This source code is licensed under the MIT license found in the 39511 * LICENSE file in the root directory of this source tree. 39512 *) 39513 39514 tabbable/dist/index.esm.js: 39515 (*! 39516 * tabbable 6.4.0 39517 * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE 39518 *) 39519 */