| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 "use strict"; 2 var wp; 3 (wp ||= {}).mediaUtils = (() => { 4 var __create = Object.create; 5 var __defProp = Object.defineProperty; 6 var __getOwnPropDesc = Object.getOwnPropertyDescriptor; 7 var __getOwnPropNames = Object.getOwnPropertyNames; 8 var __getProtoOf = Object.getPrototypeOf; 9 var __hasOwnProp = Object.prototype.hasOwnProperty; 10 var __commonJS = (cb, mod) => function __require() { 11 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; 12 }; 13 var __export = (target, all) => { 14 for (var name in all) 15 __defProp(target, name, { get: all[name], enumerable: true }); 16 }; 17 var __copyProps = (to, from, except, desc) => { 18 if (from && typeof from === "object" || typeof from === "function") { 19 for (let key of __getOwnPropNames(from)) 20 if (!__hasOwnProp.call(to, key) && key !== except) 21 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); 22 } 23 return to; 24 }; 25 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( 26 // If the importer is in node compatibility mode or this is not an ESM 27 // file that has been converted to a CommonJS file using a Babel- 28 // compatible transform (i.e. "__esModule" has not been set), then set 29 // "default" to the CommonJS "module.exports" for node compatibility. 30 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, 31 mod 32 )); 33 var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); 34 35 // package-external:@wordpress/element 36 var require_element = __commonJS({ 37 "package-external:@wordpress/element"(exports, module) { 38 module.exports = window.wp.element; 39 } 40 }); 41 42 // package-external:@wordpress/i18n 43 var require_i18n = __commonJS({ 44 "package-external:@wordpress/i18n"(exports, module) { 45 module.exports = window.wp.i18n; 46 } 47 }); 48 49 // package-external:@wordpress/blob 50 var require_blob = __commonJS({ 51 "package-external:@wordpress/blob"(exports, module) { 52 module.exports = window.wp.blob; 53 } 54 }); 55 56 // package-external:@wordpress/api-fetch 57 var require_api_fetch = __commonJS({ 58 "package-external:@wordpress/api-fetch"(exports, module) { 59 module.exports = window.wp.apiFetch; 60 } 61 }); 62 63 // package-external:@wordpress/core-data 64 var require_core_data = __commonJS({ 65 "package-external:@wordpress/core-data"(exports, module) { 66 module.exports = window.wp.coreData; 67 } 68 }); 69 70 // package-external:@wordpress/data 71 var require_data = __commonJS({ 72 "package-external:@wordpress/data"(exports, module) { 73 module.exports = window.wp.data; 74 } 75 }); 76 77 // package-external:@wordpress/components 78 var require_components = __commonJS({ 79 "package-external:@wordpress/components"(exports, module) { 80 module.exports = window.wp.components; 81 } 82 }); 83 84 // package-external:@wordpress/primitives 85 var require_primitives = __commonJS({ 86 "package-external:@wordpress/primitives"(exports, module) { 87 module.exports = window.wp.primitives; 88 } 89 }); 90 91 // vendor-external:react/jsx-runtime 92 var require_jsx_runtime = __commonJS({ 93 "vendor-external:react/jsx-runtime"(exports, module) { 94 module.exports = window.ReactJSXRuntime; 95 } 96 }); 97 98 // package-external:@wordpress/compose 99 var require_compose = __commonJS({ 100 "package-external:@wordpress/compose"(exports, module) { 101 module.exports = window.wp.compose; 102 } 103 }); 104 105 // vendor-external:react 106 var require_react = __commonJS({ 107 "vendor-external:react"(exports, module) { 108 module.exports = window.React; 109 } 110 }); 111 112 // vendor-external:react-dom 113 var require_react_dom = __commonJS({ 114 "vendor-external:react-dom"(exports, module) { 115 module.exports = window.ReactDOM; 116 } 117 }); 118 119 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js 120 var require_use_sync_external_store_shim_development = __commonJS({ 121 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports) { 122 "use strict"; 123 (function() { 124 function is(x2, y2) { 125 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2; 126 } 127 function useSyncExternalStore$2(subscribe2, getSnapshot) { 128 didWarnOld18Alpha || void 0 === React50.startTransition || (didWarnOld18Alpha = true, console.error( 129 "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." 130 )); 131 var value = getSnapshot(); 132 if (!didWarnUncachedGetSnapshot) { 133 var cachedValue = getSnapshot(); 134 objectIs(value, cachedValue) || (console.error( 135 "The result of getSnapshot should be cached to avoid an infinite loop" 136 ), didWarnUncachedGetSnapshot = true); 137 } 138 cachedValue = useState42({ 139 inst: { value, getSnapshot } 140 }); 141 var inst = cachedValue[0].inst, forceUpdate = cachedValue[1]; 142 useLayoutEffect6( 143 function() { 144 inst.value = value; 145 inst.getSnapshot = getSnapshot; 146 checkIfSnapshotChanged(inst) && forceUpdate({ inst }); 147 }, 148 [subscribe2, value, getSnapshot] 149 ); 150 useEffect35( 151 function() { 152 checkIfSnapshotChanged(inst) && forceUpdate({ inst }); 153 return subscribe2(function() { 154 checkIfSnapshotChanged(inst) && forceUpdate({ inst }); 155 }); 156 }, 157 [subscribe2] 158 ); 159 useDebugValue2(value); 160 return value; 161 } 162 function checkIfSnapshotChanged(inst) { 163 var latestGetSnapshot = inst.getSnapshot; 164 inst = inst.value; 165 try { 166 var nextValue = latestGetSnapshot(); 167 return !objectIs(inst, nextValue); 168 } catch (error) { 169 return true; 170 } 171 } 172 function useSyncExternalStore$1(subscribe2, getSnapshot) { 173 return getSnapshot(); 174 } 175 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error()); 176 var React50 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is, useState42 = React50.useState, useEffect35 = React50.useEffect, useLayoutEffect6 = React50.useLayoutEffect, useDebugValue2 = React50.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2; 177 exports.useSyncExternalStore = void 0 !== React50.useSyncExternalStore ? React50.useSyncExternalStore : shim; 178 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error()); 179 })(); 180 } 181 }); 182 183 // node_modules/use-sync-external-store/shim/index.js 184 var require_shim = __commonJS({ 185 "node_modules/use-sync-external-store/shim/index.js"(exports, module) { 186 "use strict"; 187 if (false) { 188 module.exports = null; 189 } else { 190 module.exports = require_use_sync_external_store_shim_development(); 191 } 192 } 193 }); 194 195 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js 196 var require_with_selector_development = __commonJS({ 197 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js"(exports) { 198 "use strict"; 199 (function() { 200 function is(x2, y2) { 201 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2; 202 } 203 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error()); 204 var React50 = require_react(), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore3 = shim.useSyncExternalStore, useRef49 = React50.useRef, useEffect35 = React50.useEffect, useMemo42 = React50.useMemo, useDebugValue2 = React50.useDebugValue; 205 exports.useSyncExternalStoreWithSelector = function(subscribe2, getSnapshot, getServerSnapshot, selector2, isEqual) { 206 var instRef = useRef49(null); 207 if (null === instRef.current) { 208 var inst = { hasValue: false, value: null }; 209 instRef.current = inst; 210 } else inst = instRef.current; 211 instRef = useMemo42( 212 function() { 213 function memoizedSelector(nextSnapshot) { 214 if (!hasMemo) { 215 hasMemo = true; 216 memoizedSnapshot = nextSnapshot; 217 nextSnapshot = selector2(nextSnapshot); 218 if (void 0 !== isEqual && inst.hasValue) { 219 var currentSelection = inst.value; 220 if (isEqual(currentSelection, nextSnapshot)) 221 return memoizedSelection = currentSelection; 222 } 223 return memoizedSelection = nextSnapshot; 224 } 225 currentSelection = memoizedSelection; 226 if (objectIs(memoizedSnapshot, nextSnapshot)) 227 return currentSelection; 228 var nextSelection = selector2(nextSnapshot); 229 if (void 0 !== isEqual && isEqual(currentSelection, nextSelection)) 230 return memoizedSnapshot = nextSnapshot, currentSelection; 231 memoizedSnapshot = nextSnapshot; 232 return memoizedSelection = nextSelection; 233 } 234 var hasMemo = false, memoizedSnapshot, memoizedSelection, maybeGetServerSnapshot = void 0 === getServerSnapshot ? null : getServerSnapshot; 235 return [ 236 function() { 237 return memoizedSelector(getSnapshot()); 238 }, 239 null === maybeGetServerSnapshot ? void 0 : function() { 240 return memoizedSelector(maybeGetServerSnapshot()); 241 } 242 ]; 243 }, 244 [getSnapshot, getServerSnapshot, selector2, isEqual] 245 ); 246 var value = useSyncExternalStore3(subscribe2, instRef[0], instRef[1]); 247 useEffect35( 248 function() { 249 inst.hasValue = true; 250 inst.value = value; 251 }, 252 [value] 253 ); 254 useDebugValue2(value); 255 return value; 256 }; 257 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error()); 258 })(); 259 } 260 }); 261 262 // node_modules/use-sync-external-store/shim/with-selector.js 263 var require_with_selector = __commonJS({ 264 "node_modules/use-sync-external-store/shim/with-selector.js"(exports, module) { 265 "use strict"; 266 if (false) { 267 module.exports = null; 268 } else { 269 module.exports = require_with_selector_development(); 270 } 271 } 272 }); 273 274 // package-external:@wordpress/theme 275 var require_theme = __commonJS({ 276 "package-external:@wordpress/theme"(exports, module) { 277 module.exports = window.wp.theme; 278 } 279 }); 280 281 // package-external:@wordpress/private-apis 282 var require_private_apis = __commonJS({ 283 "package-external:@wordpress/private-apis"(exports, module) { 284 module.exports = window.wp.privateApis; 285 } 286 }); 287 288 // package-external:@wordpress/keycodes 289 var require_keycodes = __commonJS({ 290 "package-external:@wordpress/keycodes"(exports, module) { 291 module.exports = window.wp.keycodes; 292 } 293 }); 294 295 // node_modules/remove-accents/index.js 296 var require_remove_accents = __commonJS({ 297 "node_modules/remove-accents/index.js"(exports, module) { 298 var characterMap = { 299 "\xC0": "A", 300 "\xC1": "A", 301 "\xC2": "A", 302 "\xC3": "A", 303 "\xC4": "A", 304 "\xC5": "A", 305 "\u1EA4": "A", 306 "\u1EAE": "A", 307 "\u1EB2": "A", 308 "\u1EB4": "A", 309 "\u1EB6": "A", 310 "\xC6": "AE", 311 "\u1EA6": "A", 312 "\u1EB0": "A", 313 "\u0202": "A", 314 "\u1EA2": "A", 315 "\u1EA0": "A", 316 "\u1EA8": "A", 317 "\u1EAA": "A", 318 "\u1EAC": "A", 319 "\xC7": "C", 320 "\u1E08": "C", 321 "\xC8": "E", 322 "\xC9": "E", 323 "\xCA": "E", 324 "\xCB": "E", 325 "\u1EBE": "E", 326 "\u1E16": "E", 327 "\u1EC0": "E", 328 "\u1E14": "E", 329 "\u1E1C": "E", 330 "\u0206": "E", 331 "\u1EBA": "E", 332 "\u1EBC": "E", 333 "\u1EB8": "E", 334 "\u1EC2": "E", 335 "\u1EC4": "E", 336 "\u1EC6": "E", 337 "\xCC": "I", 338 "\xCD": "I", 339 "\xCE": "I", 340 "\xCF": "I", 341 "\u1E2E": "I", 342 "\u020A": "I", 343 "\u1EC8": "I", 344 "\u1ECA": "I", 345 "\xD0": "D", 346 "\xD1": "N", 347 "\xD2": "O", 348 "\xD3": "O", 349 "\xD4": "O", 350 "\xD5": "O", 351 "\xD6": "O", 352 "\xD8": "O", 353 "\u1ED0": "O", 354 "\u1E4C": "O", 355 "\u1E52": "O", 356 "\u020E": "O", 357 "\u1ECE": "O", 358 "\u1ECC": "O", 359 "\u1ED4": "O", 360 "\u1ED6": "O", 361 "\u1ED8": "O", 362 "\u1EDC": "O", 363 "\u1EDE": "O", 364 "\u1EE0": "O", 365 "\u1EDA": "O", 366 "\u1EE2": "O", 367 "\xD9": "U", 368 "\xDA": "U", 369 "\xDB": "U", 370 "\xDC": "U", 371 "\u1EE6": "U", 372 "\u1EE4": "U", 373 "\u1EEC": "U", 374 "\u1EEE": "U", 375 "\u1EF0": "U", 376 "\xDD": "Y", 377 "\xE0": "a", 378 "\xE1": "a", 379 "\xE2": "a", 380 "\xE3": "a", 381 "\xE4": "a", 382 "\xE5": "a", 383 "\u1EA5": "a", 384 "\u1EAF": "a", 385 "\u1EB3": "a", 386 "\u1EB5": "a", 387 "\u1EB7": "a", 388 "\xE6": "ae", 389 "\u1EA7": "a", 390 "\u1EB1": "a", 391 "\u0203": "a", 392 "\u1EA3": "a", 393 "\u1EA1": "a", 394 "\u1EA9": "a", 395 "\u1EAB": "a", 396 "\u1EAD": "a", 397 "\xE7": "c", 398 "\u1E09": "c", 399 "\xE8": "e", 400 "\xE9": "e", 401 "\xEA": "e", 402 "\xEB": "e", 403 "\u1EBF": "e", 404 "\u1E17": "e", 405 "\u1EC1": "e", 406 "\u1E15": "e", 407 "\u1E1D": "e", 408 "\u0207": "e", 409 "\u1EBB": "e", 410 "\u1EBD": "e", 411 "\u1EB9": "e", 412 "\u1EC3": "e", 413 "\u1EC5": "e", 414 "\u1EC7": "e", 415 "\xEC": "i", 416 "\xED": "i", 417 "\xEE": "i", 418 "\xEF": "i", 419 "\u1E2F": "i", 420 "\u020B": "i", 421 "\u1EC9": "i", 422 "\u1ECB": "i", 423 "\xF0": "d", 424 "\xF1": "n", 425 "\xF2": "o", 426 "\xF3": "o", 427 "\xF4": "o", 428 "\xF5": "o", 429 "\xF6": "o", 430 "\xF8": "o", 431 "\u1ED1": "o", 432 "\u1E4D": "o", 433 "\u1E53": "o", 434 "\u020F": "o", 435 "\u1ECF": "o", 436 "\u1ECD": "o", 437 "\u1ED5": "o", 438 "\u1ED7": "o", 439 "\u1ED9": "o", 440 "\u1EDD": "o", 441 "\u1EDF": "o", 442 "\u1EE1": "o", 443 "\u1EDB": "o", 444 "\u1EE3": "o", 445 "\xF9": "u", 446 "\xFA": "u", 447 "\xFB": "u", 448 "\xFC": "u", 449 "\u1EE7": "u", 450 "\u1EE5": "u", 451 "\u1EED": "u", 452 "\u1EEF": "u", 453 "\u1EF1": "u", 454 "\xFD": "y", 455 "\xFF": "y", 456 "\u0100": "A", 457 "\u0101": "a", 458 "\u0102": "A", 459 "\u0103": "a", 460 "\u0104": "A", 461 "\u0105": "a", 462 "\u0106": "C", 463 "\u0107": "c", 464 "\u0108": "C", 465 "\u0109": "c", 466 "\u010A": "C", 467 "\u010B": "c", 468 "\u010C": "C", 469 "\u010D": "c", 470 "C\u0306": "C", 471 "c\u0306": "c", 472 "\u010E": "D", 473 "\u010F": "d", 474 "\u0110": "D", 475 "\u0111": "d", 476 "\u0112": "E", 477 "\u0113": "e", 478 "\u0114": "E", 479 "\u0115": "e", 480 "\u0116": "E", 481 "\u0117": "e", 482 "\u0118": "E", 483 "\u0119": "e", 484 "\u011A": "E", 485 "\u011B": "e", 486 "\u011C": "G", 487 "\u01F4": "G", 488 "\u011D": "g", 489 "\u01F5": "g", 490 "\u011E": "G", 491 "\u011F": "g", 492 "\u0120": "G", 493 "\u0121": "g", 494 "\u0122": "G", 495 "\u0123": "g", 496 "\u0124": "H", 497 "\u0125": "h", 498 "\u0126": "H", 499 "\u0127": "h", 500 "\u1E2A": "H", 501 "\u1E2B": "h", 502 "\u0128": "I", 503 "\u0129": "i", 504 "\u012A": "I", 505 "\u012B": "i", 506 "\u012C": "I", 507 "\u012D": "i", 508 "\u012E": "I", 509 "\u012F": "i", 510 "\u0130": "I", 511 "\u0131": "i", 512 "\u0132": "IJ", 513 "\u0133": "ij", 514 "\u0134": "J", 515 "\u0135": "j", 516 "\u0136": "K", 517 "\u0137": "k", 518 "\u1E30": "K", 519 "\u1E31": "k", 520 "K\u0306": "K", 521 "k\u0306": "k", 522 "\u0139": "L", 523 "\u013A": "l", 524 "\u013B": "L", 525 "\u013C": "l", 526 "\u013D": "L", 527 "\u013E": "l", 528 "\u013F": "L", 529 "\u0140": "l", 530 "\u0141": "l", 531 "\u0142": "l", 532 "\u1E3E": "M", 533 "\u1E3F": "m", 534 "M\u0306": "M", 535 "m\u0306": "m", 536 "\u0143": "N", 537 "\u0144": "n", 538 "\u0145": "N", 539 "\u0146": "n", 540 "\u0147": "N", 541 "\u0148": "n", 542 "\u0149": "n", 543 "N\u0306": "N", 544 "n\u0306": "n", 545 "\u014C": "O", 546 "\u014D": "o", 547 "\u014E": "O", 548 "\u014F": "o", 549 "\u0150": "O", 550 "\u0151": "o", 551 "\u0152": "OE", 552 "\u0153": "oe", 553 "P\u0306": "P", 554 "p\u0306": "p", 555 "\u0154": "R", 556 "\u0155": "r", 557 "\u0156": "R", 558 "\u0157": "r", 559 "\u0158": "R", 560 "\u0159": "r", 561 "R\u0306": "R", 562 "r\u0306": "r", 563 "\u0212": "R", 564 "\u0213": "r", 565 "\u015A": "S", 566 "\u015B": "s", 567 "\u015C": "S", 568 "\u015D": "s", 569 "\u015E": "S", 570 "\u0218": "S", 571 "\u0219": "s", 572 "\u015F": "s", 573 "\u0160": "S", 574 "\u0161": "s", 575 "\u0162": "T", 576 "\u0163": "t", 577 "\u021B": "t", 578 "\u021A": "T", 579 "\u0164": "T", 580 "\u0165": "t", 581 "\u0166": "T", 582 "\u0167": "t", 583 "T\u0306": "T", 584 "t\u0306": "t", 585 "\u0168": "U", 586 "\u0169": "u", 587 "\u016A": "U", 588 "\u016B": "u", 589 "\u016C": "U", 590 "\u016D": "u", 591 "\u016E": "U", 592 "\u016F": "u", 593 "\u0170": "U", 594 "\u0171": "u", 595 "\u0172": "U", 596 "\u0173": "u", 597 "\u0216": "U", 598 "\u0217": "u", 599 "V\u0306": "V", 600 "v\u0306": "v", 601 "\u0174": "W", 602 "\u0175": "w", 603 "\u1E82": "W", 604 "\u1E83": "w", 605 "X\u0306": "X", 606 "x\u0306": "x", 607 "\u0176": "Y", 608 "\u0177": "y", 609 "\u0178": "Y", 610 "Y\u0306": "Y", 611 "y\u0306": "y", 612 "\u0179": "Z", 613 "\u017A": "z", 614 "\u017B": "Z", 615 "\u017C": "z", 616 "\u017D": "Z", 617 "\u017E": "z", 618 "\u017F": "s", 619 "\u0192": "f", 620 "\u01A0": "O", 621 "\u01A1": "o", 622 "\u01AF": "U", 623 "\u01B0": "u", 624 "\u01CD": "A", 625 "\u01CE": "a", 626 "\u01CF": "I", 627 "\u01D0": "i", 628 "\u01D1": "O", 629 "\u01D2": "o", 630 "\u01D3": "U", 631 "\u01D4": "u", 632 "\u01D5": "U", 633 "\u01D6": "u", 634 "\u01D7": "U", 635 "\u01D8": "u", 636 "\u01D9": "U", 637 "\u01DA": "u", 638 "\u01DB": "U", 639 "\u01DC": "u", 640 "\u1EE8": "U", 641 "\u1EE9": "u", 642 "\u1E78": "U", 643 "\u1E79": "u", 644 "\u01FA": "A", 645 "\u01FB": "a", 646 "\u01FC": "AE", 647 "\u01FD": "ae", 648 "\u01FE": "O", 649 "\u01FF": "o", 650 "\xDE": "TH", 651 "\xFE": "th", 652 "\u1E54": "P", 653 "\u1E55": "p", 654 "\u1E64": "S", 655 "\u1E65": "s", 656 "X\u0301": "X", 657 "x\u0301": "x", 658 "\u0403": "\u0413", 659 "\u0453": "\u0433", 660 "\u040C": "\u041A", 661 "\u045C": "\u043A", 662 "A\u030B": "A", 663 "a\u030B": "a", 664 "E\u030B": "E", 665 "e\u030B": "e", 666 "I\u030B": "I", 667 "i\u030B": "i", 668 "\u01F8": "N", 669 "\u01F9": "n", 670 "\u1ED2": "O", 671 "\u1ED3": "o", 672 "\u1E50": "O", 673 "\u1E51": "o", 674 "\u1EEA": "U", 675 "\u1EEB": "u", 676 "\u1E80": "W", 677 "\u1E81": "w", 678 "\u1EF2": "Y", 679 "\u1EF3": "y", 680 "\u0200": "A", 681 "\u0201": "a", 682 "\u0204": "E", 683 "\u0205": "e", 684 "\u0208": "I", 685 "\u0209": "i", 686 "\u020C": "O", 687 "\u020D": "o", 688 "\u0210": "R", 689 "\u0211": "r", 690 "\u0214": "U", 691 "\u0215": "u", 692 "B\u030C": "B", 693 "b\u030C": "b", 694 "\u010C\u0323": "C", 695 "\u010D\u0323": "c", 696 "\xCA\u030C": "E", 697 "\xEA\u030C": "e", 698 "F\u030C": "F", 699 "f\u030C": "f", 700 "\u01E6": "G", 701 "\u01E7": "g", 702 "\u021E": "H", 703 "\u021F": "h", 704 "J\u030C": "J", 705 "\u01F0": "j", 706 "\u01E8": "K", 707 "\u01E9": "k", 708 "M\u030C": "M", 709 "m\u030C": "m", 710 "P\u030C": "P", 711 "p\u030C": "p", 712 "Q\u030C": "Q", 713 "q\u030C": "q", 714 "\u0158\u0329": "R", 715 "\u0159\u0329": "r", 716 "\u1E66": "S", 717 "\u1E67": "s", 718 "V\u030C": "V", 719 "v\u030C": "v", 720 "W\u030C": "W", 721 "w\u030C": "w", 722 "X\u030C": "X", 723 "x\u030C": "x", 724 "Y\u030C": "Y", 725 "y\u030C": "y", 726 "A\u0327": "A", 727 "a\u0327": "a", 728 "B\u0327": "B", 729 "b\u0327": "b", 730 "\u1E10": "D", 731 "\u1E11": "d", 732 "\u0228": "E", 733 "\u0229": "e", 734 "\u0190\u0327": "E", 735 "\u025B\u0327": "e", 736 "\u1E28": "H", 737 "\u1E29": "h", 738 "I\u0327": "I", 739 "i\u0327": "i", 740 "\u0197\u0327": "I", 741 "\u0268\u0327": "i", 742 "M\u0327": "M", 743 "m\u0327": "m", 744 "O\u0327": "O", 745 "o\u0327": "o", 746 "Q\u0327": "Q", 747 "q\u0327": "q", 748 "U\u0327": "U", 749 "u\u0327": "u", 750 "X\u0327": "X", 751 "x\u0327": "x", 752 "Z\u0327": "Z", 753 "z\u0327": "z", 754 "\u0439": "\u0438", 755 "\u0419": "\u0418", 756 "\u0451": "\u0435", 757 "\u0401": "\u0415" 758 }; 759 var chars = Object.keys(characterMap).join("|"); 760 var allAccents = new RegExp(chars, "g"); 761 var firstAccent = new RegExp(chars, ""); 762 function matcher(match2) { 763 return characterMap[match2]; 764 } 765 var removeAccents2 = function(string) { 766 return string.replace(allAccents, matcher); 767 }; 768 var hasAccents = function(string) { 769 return !!string.match(firstAccent); 770 }; 771 module.exports = removeAccents2; 772 module.exports.has = hasAccents; 773 module.exports.remove = removeAccents2; 774 } 775 }); 776 777 // node_modules/fast-deep-equal/es6/index.js 778 var require_es6 = __commonJS({ 779 "node_modules/fast-deep-equal/es6/index.js"(exports, module) { 780 "use strict"; 781 module.exports = function equal(a2, b2) { 782 if (a2 === b2) return true; 783 if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") { 784 if (a2.constructor !== b2.constructor) return false; 785 var length, i2, keys; 786 if (Array.isArray(a2)) { 787 length = a2.length; 788 if (length != b2.length) return false; 789 for (i2 = length; i2-- !== 0; ) 790 if (!equal(a2[i2], b2[i2])) return false; 791 return true; 792 } 793 if (a2 instanceof Map && b2 instanceof Map) { 794 if (a2.size !== b2.size) return false; 795 for (i2 of a2.entries()) 796 if (!b2.has(i2[0])) return false; 797 for (i2 of a2.entries()) 798 if (!equal(i2[1], b2.get(i2[0]))) return false; 799 return true; 800 } 801 if (a2 instanceof Set && b2 instanceof Set) { 802 if (a2.size !== b2.size) return false; 803 for (i2 of a2.entries()) 804 if (!b2.has(i2[0])) return false; 805 return true; 806 } 807 if (ArrayBuffer.isView(a2) && ArrayBuffer.isView(b2)) { 808 length = a2.length; 809 if (length != b2.length) return false; 810 for (i2 = length; i2-- !== 0; ) 811 if (a2[i2] !== b2[i2]) return false; 812 return true; 813 } 814 if (a2.constructor === RegExp) return a2.source === b2.source && a2.flags === b2.flags; 815 if (a2.valueOf !== Object.prototype.valueOf) return a2.valueOf() === b2.valueOf(); 816 if (a2.toString !== Object.prototype.toString) return a2.toString() === b2.toString(); 817 keys = Object.keys(a2); 818 length = keys.length; 819 if (length !== Object.keys(b2).length) return false; 820 for (i2 = length; i2-- !== 0; ) 821 if (!Object.prototype.hasOwnProperty.call(b2, keys[i2])) return false; 822 for (i2 = length; i2-- !== 0; ) { 823 var key = keys[i2]; 824 if (!equal(a2[key], b2[key])) return false; 825 } 826 return true; 827 } 828 return a2 !== a2 && b2 !== b2; 829 }; 830 } 831 }); 832 833 // package-external:@wordpress/date 834 var require_date = __commonJS({ 835 "package-external:@wordpress/date"(exports, module) { 836 module.exports = window.wp.date; 837 } 838 }); 839 840 // package-external:@wordpress/warning 841 var require_warning = __commonJS({ 842 "package-external:@wordpress/warning"(exports, module) { 843 module.exports = window.wp.warning; 844 } 845 }); 846 847 // package-external:@wordpress/preferences 848 var require_preferences = __commonJS({ 849 "package-external:@wordpress/preferences"(exports, module) { 850 module.exports = window.wp.preferences; 851 } 852 }); 853 854 // package-external:@wordpress/url 855 var require_url = __commonJS({ 856 "package-external:@wordpress/url"(exports, module) { 857 module.exports = window.wp.url; 858 } 859 }); 860 861 // package-external:@wordpress/notices 862 var require_notices = __commonJS({ 863 "package-external:@wordpress/notices"(exports, module) { 864 module.exports = window.wp.notices; 865 } 866 }); 867 868 // packages/media-utils/build-module/index.mjs 869 var index_exports = {}; 870 __export(index_exports, { 871 MediaUpload: () => media_upload_default, 872 privateApis: () => privateApis12, 873 transformAttachment: () => transformAttachment, 874 uploadMedia: () => uploadMedia, 875 validateFileSize: () => validateFileSize, 876 validateMimeType: () => validateMimeType, 877 validateMimeTypeForUser: () => validateMimeTypeForUser 878 }); 879 880 // packages/media-utils/build-module/components/media-upload/index.mjs 881 var import_element = __toESM(require_element(), 1); 882 var import_i18n = __toESM(require_i18n(), 1); 883 var DEFAULT_EMPTY_GALLERY = []; 884 var getFeaturedImageMediaFrame = () => { 885 const { wp } = window; 886 return wp.media.view.MediaFrame.Select.extend({ 887 /** 888 * Enables the Set Featured Image Button. 889 * 890 * @param {Object} toolbar toolbar for featured image state 891 * @return {void} 892 */ 893 featuredImageToolbar(toolbar) { 894 this.createSelectToolbar(toolbar, { 895 text: wp.media.view.l10n.setFeaturedImage, 896 state: this.options.state 897 }); 898 }, 899 /** 900 * Handle the edit state requirements of selected media item. 901 * 902 * @return {void} 903 */ 904 editState() { 905 const selection = this.state("featured-image").get("selection"); 906 const view = new wp.media.view.EditImage({ 907 model: selection.single(), 908 controller: this 909 }).render(); 910 this.content.set(view); 911 view.loadEditor(); 912 }, 913 /** 914 * Create the default states. 915 * 916 * @return {void} 917 */ 918 createStates: function createStates() { 919 this.on( 920 "toolbar:create:featured-image", 921 this.featuredImageToolbar, 922 this 923 ); 924 this.on("content:render:edit-image", this.editState, this); 925 this.states.add([ 926 new wp.media.controller.FeaturedImage(), 927 new wp.media.controller.EditImage({ 928 model: this.options.editImage 929 }) 930 ]); 931 } 932 }); 933 }; 934 var getSingleMediaFrame = () => { 935 const { wp } = window; 936 return wp.media.view.MediaFrame.Select.extend({ 937 /** 938 * Create the default states on the frame. 939 */ 940 createStates() { 941 const options = this.options; 942 if (this.options.states) { 943 return; 944 } 945 this.states.add([ 946 // Main states. 947 new wp.media.controller.Library({ 948 library: wp.media.query(options.library), 949 multiple: options.multiple, 950 title: options.title, 951 priority: 20, 952 filterable: "uploaded" 953 // Allow filtering by uploaded images. 954 }), 955 new wp.media.controller.EditImage({ 956 model: options.editImage 957 }) 958 ]); 959 } 960 }); 961 }; 962 var getGalleryDetailsMediaFrame = () => { 963 const { wp } = window; 964 return wp.media.view.MediaFrame.Post.extend({ 965 /** 966 * Set up gallery toolbar. 967 * 968 * @return {void} 969 */ 970 galleryToolbar() { 971 const editing = this.state().get("editing"); 972 this.toolbar.set( 973 new wp.media.view.Toolbar({ 974 controller: this, 975 items: { 976 insert: { 977 style: "primary", 978 text: editing ? wp.media.view.l10n.updateGallery : wp.media.view.l10n.insertGallery, 979 priority: 80, 980 requires: { library: true }, 981 /** 982 * @fires wp.media.controller.State#update 983 */ 984 click() { 985 const controller = this.controller, state = controller.state(); 986 controller.close(); 987 state.trigger( 988 "update", 989 state.get("library") 990 ); 991 controller.setState(controller.options.state); 992 controller.reset(); 993 } 994 } 995 } 996 }) 997 ); 998 }, 999 /** 1000 * Handle the edit state requirements of selected media item. 1001 * 1002 * @return {void} 1003 */ 1004 editState() { 1005 const selection = this.state("gallery").get("selection"); 1006 const view = new wp.media.view.EditImage({ 1007 model: selection.single(), 1008 controller: this 1009 }).render(); 1010 this.content.set(view); 1011 view.loadEditor(); 1012 }, 1013 /** 1014 * Create the default states. 1015 * 1016 * @return {void} 1017 */ 1018 createStates: function createStates() { 1019 this.on("toolbar:create:main-gallery", this.galleryToolbar, this); 1020 this.on("content:render:edit-image", this.editState, this); 1021 this.states.add([ 1022 new wp.media.controller.Library({ 1023 id: "gallery", 1024 title: wp.media.view.l10n.createGalleryTitle, 1025 priority: 40, 1026 toolbar: "main-gallery", 1027 filterable: "uploaded", 1028 multiple: "add", 1029 editable: false, 1030 library: wp.media.query({ 1031 type: "image", 1032 ...this.options.library 1033 }) 1034 }), 1035 new wp.media.controller.EditImage({ 1036 model: this.options.editImage 1037 }), 1038 new wp.media.controller.GalleryEdit({ 1039 library: this.options.selection, 1040 editing: this.options.editing, 1041 menu: "gallery", 1042 displaySettings: false, 1043 multiple: true 1044 }), 1045 new wp.media.controller.GalleryAdd() 1046 ]); 1047 } 1048 }); 1049 }; 1050 var slimImageObject = (img) => { 1051 const attrSet = [ 1052 "sizes", 1053 "mime", 1054 "type", 1055 "subtype", 1056 "id", 1057 "url", 1058 "alt", 1059 "link", 1060 "caption" 1061 ]; 1062 return attrSet.reduce((result, key) => { 1063 if (img?.hasOwnProperty(key)) { 1064 result[key] = img[key]; 1065 } 1066 return result; 1067 }, {}); 1068 }; 1069 var getAttachmentsCollection = (ids) => { 1070 const { wp } = window; 1071 return wp.media.query({ 1072 order: "ASC", 1073 orderby: "post__in", 1074 post__in: ids, 1075 posts_per_page: -1, 1076 query: true, 1077 type: "image" 1078 }); 1079 }; 1080 var MediaUpload = class extends import_element.Component { 1081 constructor() { 1082 super(...arguments); 1083 this.openModal = this.openModal.bind(this); 1084 this.onOpen = this.onOpen.bind(this); 1085 this.onSelect = this.onSelect.bind(this); 1086 this.onUpdate = this.onUpdate.bind(this); 1087 this.onClose = this.onClose.bind(this); 1088 } 1089 initializeListeners() { 1090 this.frame.on("select", this.onSelect); 1091 this.frame.on("update", this.onUpdate); 1092 this.frame.on("open", this.onOpen); 1093 this.frame.on("close", this.onClose); 1094 } 1095 /** 1096 * Sets the Gallery frame and initializes listeners. 1097 * 1098 * @return {void} 1099 */ 1100 buildAndSetGalleryFrame() { 1101 const { 1102 addToGallery = false, 1103 allowedTypes, 1104 multiple = false, 1105 value = DEFAULT_EMPTY_GALLERY 1106 } = this.props; 1107 if (value === this.lastGalleryValue) { 1108 return; 1109 } 1110 const { wp } = window; 1111 this.lastGalleryValue = value; 1112 if (this.frame) { 1113 this.frame.remove(); 1114 } 1115 let currentState; 1116 if (addToGallery) { 1117 currentState = "gallery-library"; 1118 } else { 1119 currentState = value && value.length ? "gallery-edit" : "gallery"; 1120 } 1121 if (!this.GalleryDetailsMediaFrame) { 1122 this.GalleryDetailsMediaFrame = getGalleryDetailsMediaFrame(); 1123 } 1124 const attachments = getAttachmentsCollection(value); 1125 const selection = new wp.media.model.Selection(attachments.models, { 1126 props: attachments.props.toJSON(), 1127 multiple 1128 }); 1129 this.frame = new this.GalleryDetailsMediaFrame({ 1130 mimeType: allowedTypes, 1131 state: currentState, 1132 multiple, 1133 selection, 1134 editing: !!value?.length 1135 }); 1136 wp.media.frame = this.frame; 1137 this.initializeListeners(); 1138 } 1139 /** 1140 * Initializes the Media Library requirements for the featured image flow. 1141 * 1142 * @return {void} 1143 */ 1144 buildAndSetFeatureImageFrame() { 1145 const { wp } = window; 1146 const { value: featuredImageId, multiple, allowedTypes } = this.props; 1147 const featuredImageFrame = getFeaturedImageMediaFrame(); 1148 const attachments = getAttachmentsCollection(featuredImageId); 1149 const selection = new wp.media.model.Selection(attachments.models, { 1150 props: attachments.props.toJSON() 1151 }); 1152 this.frame = new featuredImageFrame({ 1153 mimeType: allowedTypes, 1154 state: "featured-image", 1155 multiple, 1156 selection, 1157 editing: featuredImageId 1158 }); 1159 wp.media.frame = this.frame; 1160 wp.media.view.settings.post = { 1161 ...wp.media.view.settings.post, 1162 featuredImageId: featuredImageId || -1 1163 }; 1164 } 1165 /** 1166 * Initializes the Media Library requirements for the single image flow. 1167 * 1168 * @return {void} 1169 */ 1170 buildAndSetSingleMediaFrame() { 1171 const { wp } = window; 1172 const { 1173 allowedTypes, 1174 multiple = false, 1175 title = (0, import_i18n.__)("Select or Upload Media"), 1176 value 1177 } = this.props; 1178 const frameConfig = { 1179 title, 1180 multiple 1181 }; 1182 if (!!allowedTypes) { 1183 frameConfig.library = { type: allowedTypes }; 1184 } 1185 if (this.frame) { 1186 this.frame.remove(); 1187 } 1188 const singleImageFrame = getSingleMediaFrame(); 1189 const attachments = getAttachmentsCollection(value); 1190 const selection = new wp.media.model.Selection(attachments.models, { 1191 props: attachments.props.toJSON() 1192 }); 1193 this.frame = new singleImageFrame({ 1194 mimeType: allowedTypes, 1195 multiple, 1196 selection, 1197 ...frameConfig 1198 }); 1199 wp.media.frame = this.frame; 1200 } 1201 componentWillUnmount() { 1202 this.frame?.remove(); 1203 } 1204 onUpdate(selections) { 1205 const { onSelect, multiple = false } = this.props; 1206 const state = this.frame.state(); 1207 const selectedImages = selections || state.get("selection"); 1208 if (!selectedImages || !selectedImages.models.length) { 1209 return; 1210 } 1211 if (multiple) { 1212 onSelect( 1213 selectedImages.models.map( 1214 (model) => slimImageObject(model.toJSON()) 1215 ) 1216 ); 1217 } else { 1218 onSelect(slimImageObject(selectedImages.models[0].toJSON())); 1219 } 1220 } 1221 onSelect() { 1222 const { onSelect, multiple = false } = this.props; 1223 const attachment = this.frame.state().get("selection").toJSON(); 1224 onSelect(multiple ? attachment : attachment[0]); 1225 } 1226 onOpen() { 1227 const { wp } = window; 1228 const { value } = this.props; 1229 this.updateCollection(); 1230 if (this.props.mode) { 1231 this.frame.content.mode(this.props.mode); 1232 } 1233 const hasMedia = Array.isArray(value) ? !!value?.length : !!value; 1234 if (!hasMedia) { 1235 return; 1236 } 1237 const isGallery = this.props.gallery; 1238 const selection = this.frame.state().get("selection"); 1239 const valueArray = Array.isArray(value) ? value : [value]; 1240 if (!isGallery) { 1241 valueArray.forEach((id) => { 1242 selection.add(wp.media.attachment(id)); 1243 }); 1244 } 1245 const attachments = getAttachmentsCollection(valueArray); 1246 attachments.more().done(function() { 1247 if (isGallery && attachments?.models?.length) { 1248 selection.add(attachments.models); 1249 } 1250 }); 1251 } 1252 onClose() { 1253 const { onClose } = this.props; 1254 if (onClose) { 1255 onClose(); 1256 } 1257 this.frame.detach(); 1258 } 1259 updateCollection() { 1260 const frameContent = this.frame.content.get(); 1261 if (frameContent && frameContent.collection) { 1262 const collection = frameContent.collection; 1263 collection.toArray().forEach((model) => model.trigger("destroy", model)); 1264 collection.mirroring._hasMore = true; 1265 collection.more(); 1266 } 1267 } 1268 openModal() { 1269 const { 1270 gallery = false, 1271 unstableFeaturedImageFlow = false, 1272 modalClass 1273 } = this.props; 1274 if (gallery) { 1275 this.buildAndSetGalleryFrame(); 1276 } else { 1277 this.buildAndSetSingleMediaFrame(); 1278 } 1279 if (modalClass) { 1280 this.frame.$el.addClass(modalClass); 1281 } 1282 if (unstableFeaturedImageFlow) { 1283 this.buildAndSetFeatureImageFrame(); 1284 } 1285 this.initializeListeners(); 1286 this.frame.open(); 1287 } 1288 render() { 1289 return this.props.render({ open: this.openModal }); 1290 } 1291 }; 1292 var media_upload_default = MediaUpload; 1293 1294 // packages/media-utils/build-module/utils/upload-media.mjs 1295 var import_i18n5 = __toESM(require_i18n(), 1); 1296 var import_blob = __toESM(require_blob(), 1); 1297 1298 // packages/media-utils/build-module/utils/upload-to-server.mjs 1299 var import_api_fetch = __toESM(require_api_fetch(), 1); 1300 1301 // packages/media-utils/build-module/utils/flatten-form-data.mjs 1302 function isPlainObject(data) { 1303 return data !== null && typeof data === "object" && Object.getPrototypeOf(data) === Object.prototype; 1304 } 1305 function flattenFormData(formData, key, data) { 1306 if (isPlainObject(data)) { 1307 for (const [name, value] of Object.entries(data)) { 1308 flattenFormData(formData, `$key}[$name}]`, value); 1309 } 1310 } else if (data !== void 0) { 1311 formData.append(key, String(data)); 1312 } 1313 } 1314 1315 // packages/media-utils/build-module/utils/transform-attachment.mjs 1316 function transformAttachment(attachment) { 1317 const { alt_text, source_url, ...savedMediaProps } = attachment; 1318 return { 1319 ...savedMediaProps, 1320 alt: attachment.alt_text, 1321 caption: attachment.caption?.raw ?? "", 1322 title: attachment.title.raw, 1323 url: attachment.source_url, 1324 poster: attachment._embedded?.["wp:featuredmedia"]?.[0]?.source_url || void 0 1325 }; 1326 } 1327 1328 // packages/media-utils/build-module/utils/upload-to-server.mjs 1329 async function uploadToServer(file, additionalData = {}, signal) { 1330 const data = new FormData(); 1331 data.append("file", file, file.name || file.type.replace("/", ".")); 1332 for (const [key, value] of Object.entries(additionalData)) { 1333 flattenFormData( 1334 data, 1335 key, 1336 value 1337 ); 1338 } 1339 return transformAttachment( 1340 await (0, import_api_fetch.default)({ 1341 // This allows the video block to directly get a video's poster image. 1342 path: "/wp/v2/media?_embed=wp:featuredmedia", 1343 body: data, 1344 method: "POST", 1345 signal 1346 }) 1347 ); 1348 } 1349 1350 // packages/media-utils/build-module/utils/validate-mime-type.mjs 1351 var import_i18n2 = __toESM(require_i18n(), 1); 1352 1353 // packages/media-utils/build-module/utils/upload-error.mjs 1354 var UploadError = class extends Error { 1355 code; 1356 file; 1357 constructor({ code, message: message2, file, cause }) { 1358 super(message2, { cause }); 1359 Object.setPrototypeOf(this, new.target.prototype); 1360 this.code = code; 1361 this.file = file; 1362 } 1363 }; 1364 1365 // packages/media-utils/build-module/utils/validate-mime-type.mjs 1366 function validateMimeType(file, allowedTypes) { 1367 if (!allowedTypes || allowedTypes.includes("*")) { 1368 return; 1369 } 1370 const isAllowedType = allowedTypes.some((allowedType) => { 1371 if (allowedType.includes("/")) { 1372 return allowedType === file.type; 1373 } 1374 return file.type.startsWith(`$allowedType}/`); 1375 }); 1376 if (file.type && !isAllowedType) { 1377 throw new UploadError({ 1378 code: "MIME_TYPE_NOT_SUPPORTED", 1379 message: (0, import_i18n2.sprintf)( 1380 // translators: %s: file name. 1381 (0, import_i18n2.__)("%s: Sorry, this file type is not supported here."), 1382 file.name 1383 ), 1384 file 1385 }); 1386 } 1387 } 1388 1389 // packages/media-utils/build-module/utils/validate-mime-type-for-user.mjs 1390 var import_i18n3 = __toESM(require_i18n(), 1); 1391 1392 // packages/media-utils/build-module/utils/get-mime-types-array.mjs 1393 function getMimeTypesArray(wpMimeTypesObject) { 1394 if (!wpMimeTypesObject) { 1395 return null; 1396 } 1397 return Object.entries(wpMimeTypesObject).flatMap( 1398 ([extensionsString, mime]) => { 1399 const [type] = mime.split("/"); 1400 const extensions = extensionsString.split("|"); 1401 return [ 1402 mime, 1403 ...extensions.map( 1404 (extension) => `$type}/$extension}` 1405 ) 1406 ]; 1407 } 1408 ); 1409 } 1410 1411 // packages/media-utils/build-module/utils/validate-mime-type-for-user.mjs 1412 function validateMimeTypeForUser(file, wpAllowedMimeTypes) { 1413 const allowedMimeTypesForUser = getMimeTypesArray(wpAllowedMimeTypes); 1414 if (!allowedMimeTypesForUser) { 1415 return; 1416 } 1417 const isAllowedMimeTypeForUser = allowedMimeTypesForUser.includes( 1418 file.type 1419 ); 1420 if (file.type && !isAllowedMimeTypeForUser) { 1421 throw new UploadError({ 1422 code: "MIME_TYPE_NOT_ALLOWED_FOR_USER", 1423 message: (0, import_i18n3.sprintf)( 1424 // translators: %s: file name. 1425 (0, import_i18n3.__)( 1426 "%s: Sorry, you are not allowed to upload this file type." 1427 ), 1428 file.name 1429 ), 1430 file 1431 }); 1432 } 1433 } 1434 1435 // packages/media-utils/build-module/utils/validate-file-size.mjs 1436 var import_i18n4 = __toESM(require_i18n(), 1); 1437 function validateFileSize(file, maxUploadFileSize) { 1438 if (file.size <= 0) { 1439 throw new UploadError({ 1440 code: "EMPTY_FILE", 1441 message: (0, import_i18n4.sprintf)( 1442 // translators: %s: file name. 1443 (0, import_i18n4.__)("%s: This file is empty."), 1444 file.name 1445 ), 1446 file 1447 }); 1448 } 1449 if (maxUploadFileSize && file.size > maxUploadFileSize) { 1450 throw new UploadError({ 1451 code: "SIZE_ABOVE_LIMIT", 1452 message: (0, import_i18n4.sprintf)( 1453 // translators: %s: file name. 1454 (0, import_i18n4.__)( 1455 "%s: This file exceeds the maximum upload size for this site." 1456 ), 1457 file.name 1458 ), 1459 file 1460 }); 1461 } 1462 } 1463 1464 // packages/media-utils/build-module/utils/upload-media.mjs 1465 function uploadMedia({ 1466 wpAllowedMimeTypes, 1467 allowedTypes, 1468 additionalData = {}, 1469 filesList, 1470 maxUploadFileSize, 1471 onError, 1472 onFileChange, 1473 signal, 1474 multiple = true 1475 }) { 1476 if (!multiple && filesList.length > 1) { 1477 onError?.(new Error((0, import_i18n5.__)("Only one file can be used here."))); 1478 return; 1479 } 1480 const validFiles = []; 1481 const filesSet = []; 1482 const setAndUpdateFiles = (index2, value) => { 1483 if (!window.__clientSideMediaProcessing) { 1484 if (filesSet[index2]?.url) { 1485 (0, import_blob.revokeBlobURL)(filesSet[index2].url); 1486 } 1487 } 1488 filesSet[index2] = value; 1489 onFileChange?.( 1490 filesSet.filter((attachment) => attachment !== null) 1491 ); 1492 }; 1493 for (const mediaFile of filesList) { 1494 try { 1495 validateMimeTypeForUser(mediaFile, wpAllowedMimeTypes); 1496 } catch (error) { 1497 onError?.(error); 1498 continue; 1499 } 1500 try { 1501 validateMimeType(mediaFile, allowedTypes); 1502 } catch (error) { 1503 onError?.(error); 1504 continue; 1505 } 1506 try { 1507 validateFileSize(mediaFile, maxUploadFileSize); 1508 } catch (error) { 1509 onError?.(error); 1510 continue; 1511 } 1512 validFiles.push(mediaFile); 1513 if (!window.__clientSideMediaProcessing) { 1514 filesSet.push({ url: (0, import_blob.createBlobURL)(mediaFile) }); 1515 onFileChange?.(filesSet); 1516 } 1517 } 1518 validFiles.map(async (file, index2) => { 1519 try { 1520 const attachment = await uploadToServer( 1521 file, 1522 additionalData, 1523 signal 1524 ); 1525 setAndUpdateFiles(index2, attachment); 1526 } catch (error) { 1527 setAndUpdateFiles(index2, null); 1528 let message2; 1529 if (typeof error === "object" && error !== null && "message" in error) { 1530 message2 = typeof error.message === "string" ? error.message : String(error.message); 1531 } else { 1532 message2 = (0, import_i18n5.sprintf)( 1533 // translators: %s: file name 1534 (0, import_i18n5.__)("Error while uploading file %s to the media library."), 1535 file.name 1536 ); 1537 } 1538 onError?.( 1539 new UploadError({ 1540 code: "GENERAL", 1541 message: message2, 1542 file, 1543 cause: error instanceof Error ? error : void 0 1544 }) 1545 ); 1546 } 1547 }); 1548 } 1549 1550 // packages/media-utils/build-module/utils/sideload-media.mjs 1551 var import_i18n6 = __toESM(require_i18n(), 1); 1552 1553 // packages/media-utils/build-module/utils/sideload-to-server.mjs 1554 var import_api_fetch2 = __toESM(require_api_fetch(), 1); 1555 async function sideloadToServer(file, attachmentId, additionalData = {}, signal) { 1556 const data = new FormData(); 1557 data.append("file", file, file.name || file.type.replace("/", ".")); 1558 for (const [key, value] of Object.entries(additionalData)) { 1559 flattenFormData( 1560 data, 1561 key, 1562 value 1563 ); 1564 } 1565 return (0, import_api_fetch2.default)({ 1566 path: `/wp/v2/media/$attachmentId}/sideload`, 1567 body: data, 1568 method: "POST", 1569 signal 1570 }); 1571 } 1572 1573 // packages/media-utils/build-module/utils/sideload-media.mjs 1574 var noop = () => { 1575 }; 1576 async function sideloadMedia({ 1577 file, 1578 attachmentId, 1579 additionalData = {}, 1580 signal, 1581 onSuccess, 1582 onError = noop 1583 }) { 1584 try { 1585 const subSizeData = await sideloadToServer( 1586 file, 1587 attachmentId, 1588 additionalData, 1589 signal 1590 ); 1591 onSuccess?.(subSizeData); 1592 } catch (error) { 1593 let message2; 1594 if (error instanceof Error) { 1595 message2 = error.message; 1596 } else { 1597 message2 = (0, import_i18n6.sprintf)( 1598 // translators: %s: file name 1599 (0, import_i18n6.__)("Error while sideloading file %s to the server."), 1600 file.name 1601 ); 1602 } 1603 onError( 1604 new UploadError({ 1605 code: "GENERAL", 1606 message: message2, 1607 file, 1608 cause: error instanceof Error ? error : void 0 1609 }) 1610 ); 1611 } 1612 } 1613 1614 // node_modules/clsx/dist/clsx.mjs 1615 function r(e2) { 1616 var t2, f2, n2 = ""; 1617 if ("string" == typeof e2 || "number" == typeof e2) n2 += e2; 1618 else if ("object" == typeof e2) if (Array.isArray(e2)) { 1619 var o2 = e2.length; 1620 for (t2 = 0; t2 < o2; t2++) e2[t2] && (f2 = r(e2[t2])) && (n2 && (n2 += " "), n2 += f2); 1621 } else for (f2 in e2) e2[f2] && (n2 && (n2 += " "), n2 += f2); 1622 return n2; 1623 } 1624 function clsx() { 1625 for (var e2, t2, f2 = 0, n2 = "", o2 = arguments.length; f2 < o2; f2++) (e2 = arguments[f2]) && (t2 = r(e2)) && (n2 && (n2 += " "), n2 += t2); 1626 return n2; 1627 } 1628 var clsx_default = clsx; 1629 1630 // packages/media-utils/build-module/components/media-upload-modal/index.mjs 1631 var import_element83 = __toESM(require_element(), 1); 1632 var import_i18n67 = __toESM(require_i18n(), 1); 1633 var import_core_data6 = __toESM(require_core_data(), 1); 1634 var import_data13 = __toESM(require_data(), 1); 1635 var import_components53 = __toESM(require_components(), 1); 1636 1637 // packages/icons/build-module/library/arrow-down.mjs 1638 var import_primitives = __toESM(require_primitives(), 1); 1639 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1); 1640 var arrow_down_default = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_primitives.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_primitives.Path, { d: "m16.5 13.5-3.7 3.7V4h-1.5v13.2l-3.8-3.7-1 1 5.5 5.6 5.5-5.6z" }) }); 1641 1642 // packages/icons/build-module/library/arrow-left.mjs 1643 var import_primitives2 = __toESM(require_primitives(), 1); 1644 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1); 1645 var arrow_left_default = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_primitives2.Path, { d: "M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z" }) }); 1646 1647 // packages/icons/build-module/library/arrow-right.mjs 1648 var import_primitives3 = __toESM(require_primitives(), 1); 1649 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1); 1650 var arrow_right_default = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_primitives3.Path, { d: "m14.5 6.5-1 1 3.7 3.7H4v1.6h13.2l-3.7 3.7 1 1 5.6-5.5z" }) }); 1651 1652 // packages/icons/build-module/library/arrow-up.mjs 1653 var import_primitives4 = __toESM(require_primitives(), 1); 1654 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1); 1655 var arrow_up_default = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives4.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives4.Path, { d: "M12 3.9 6.5 9.5l1 1 3.8-3.7V20h1.5V6.8l3.7 3.7 1-1z" }) }); 1656 1657 // packages/icons/build-module/library/audio.mjs 1658 var import_primitives5 = __toESM(require_primitives(), 1); 1659 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1); 1660 var audio_default = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives5.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives5.Path, { d: "M17.7 4.3c-1.2 0-2.8 0-3.8 1-.6.6-.9 1.5-.9 2.6V14c-.6-.6-1.5-1-2.5-1C8.6 13 7 14.6 7 16.5S8.6 20 10.5 20c1.5 0 2.8-1 3.3-2.3.5-.8.7-1.8.7-2.5V7.9c0-.7.2-1.2.5-1.6.6-.6 1.8-.6 2.8-.6h.3V4.3h-.4z" }) }); 1661 1662 // packages/icons/build-module/library/block-table.mjs 1663 var import_primitives6 = __toESM(require_primitives(), 1); 1664 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1); 1665 var block_table_default = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives6.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives6.Path, { 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" }) }); 1666 1667 // packages/icons/build-module/library/category.mjs 1668 var import_primitives7 = __toESM(require_primitives(), 1); 1669 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1); 1670 var category_default = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives7.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives7.Path, { 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" }) }); 1671 1672 // packages/icons/build-module/library/check.mjs 1673 var import_primitives8 = __toESM(require_primitives(), 1); 1674 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1); 1675 var check_default = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives8.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives8.Path, { d: "M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z" }) }); 1676 1677 // packages/icons/build-module/library/chevron-down.mjs 1678 var import_primitives9 = __toESM(require_primitives(), 1); 1679 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1); 1680 var chevron_down_default = /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_primitives9.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_primitives9.Path, { d: "M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z" }) }); 1681 1682 // packages/icons/build-module/library/close-small.mjs 1683 var import_primitives10 = __toESM(require_primitives(), 1); 1684 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1); 1685 var close_small_default = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_primitives10.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_primitives10.Path, { 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" }) }); 1686 1687 // packages/icons/build-module/library/cog.mjs 1688 var import_primitives11 = __toESM(require_primitives(), 1); 1689 var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1); 1690 var cog_default = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives11.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives11.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "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" }) }); 1691 1692 // packages/icons/build-module/library/comment-author-avatar.mjs 1693 var import_primitives12 = __toESM(require_primitives(), 1); 1694 var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1); 1695 var comment_author_avatar_default = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives12.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives12.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M7.25 16.437a6.5 6.5 0 1 1 9.5 0V16A2.75 2.75 0 0 0 14 13.25h-4A2.75 2.75 0 0 0 7.25 16v.437Zm1.5 1.193a6.47 6.47 0 0 0 3.25.87 6.47 6.47 0 0 0 3.25-.87V16c0-.69-.56-1.25-1.25-1.25h-4c-.69 0-1.25.56-1.25 1.25v1.63ZM4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Zm10-2a2 2 0 1 1-4 0 2 2 0 0 1 4 0Z" }) }); 1696 1697 // packages/icons/build-module/library/envelope.mjs 1698 var import_primitives13 = __toESM(require_primitives(), 1); 1699 var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1); 1700 var envelope_default = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives13.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives13.Path, { 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" }) }); 1701 1702 // packages/icons/build-module/library/error.mjs 1703 var import_primitives14 = __toESM(require_primitives(), 1); 1704 var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1); 1705 var error_default = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives14.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives14.Path, { 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" }) }); 1706 1707 // packages/icons/build-module/library/file.mjs 1708 var import_primitives15 = __toESM(require_primitives(), 1); 1709 var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1); 1710 var file_default = /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives15.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives15.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M12.848 8a1 1 0 0 1-.914-.594l-.723-1.63a.5.5 0 0 0-.447-.276H5a.5.5 0 0 0-.5.5v11.5a.5.5 0 0 0 .5.5h14a.5.5 0 0 0 .5-.5v-9A.5.5 0 0 0 19 8h-6.152Zm.612-1.5a.5.5 0 0 1-.462-.31l-.445-1.084A2 2 0 0 0 10.763 4H5a2 2 0 0 0-2 2v11.5a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-9a2 2 0 0 0-2-2h-5.54Z" }) }); 1711 1712 // packages/icons/build-module/library/format-list-bullets-rtl.mjs 1713 var import_primitives16 = __toESM(require_primitives(), 1); 1714 var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1); 1715 var format_list_bullets_rtl_default = /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives16.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives16.Path, { d: "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" }) }); 1716 1717 // packages/icons/build-module/library/format-list-bullets.mjs 1718 var import_primitives17 = __toESM(require_primitives(), 1); 1719 var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1); 1720 var format_list_bullets_default = /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives17.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives17.Path, { d: "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" }) }); 1721 1722 // packages/icons/build-module/library/funnel.mjs 1723 var import_primitives18 = __toESM(require_primitives(), 1); 1724 var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1); 1725 var funnel_default = /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives18.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives18.Path, { d: "M10 17.5H14V16H10V17.5ZM6 6V7.5H18V6H6ZM8 12.5H16V11H8V12.5Z" }) }); 1726 1727 // packages/icons/build-module/library/image.mjs 1728 var import_primitives19 = __toESM(require_primitives(), 1); 1729 var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1); 1730 var image_default = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives19.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives19.Path, { d: "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.5v8.4l-3-2.9c-.3-.3-.8-.3-1 0L11.9 14 9 12c-.3-.2-.6-.2-.8 0l-3.6 2.6V5c-.1-.3.1-.5.4-.5zm14 15H5c-.3 0-.5-.2-.5-.5v-2.4l4.1-3 3 1.9c.3.2.7.2.9-.1L16 12l3.5 3.4V19c0 .3-.2.5-.5.5z" }) }); 1731 1732 // packages/icons/build-module/library/link.mjs 1733 var import_primitives20 = __toESM(require_primitives(), 1); 1734 var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1); 1735 var link_default = /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives20.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives20.Path, { 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" }) }); 1736 1737 // packages/icons/build-module/library/mobile.mjs 1738 var import_primitives21 = __toESM(require_primitives(), 1); 1739 var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1); 1740 var mobile_default = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives21.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives21.Path, { d: "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" }) }); 1741 1742 // packages/icons/build-module/library/more-vertical.mjs 1743 var import_primitives22 = __toESM(require_primitives(), 1); 1744 var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1); 1745 var more_vertical_default = /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives22.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives22.Path, { d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" }) }); 1746 1747 // packages/icons/build-module/library/next.mjs 1748 var import_primitives23 = __toESM(require_primitives(), 1); 1749 var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1); 1750 var next_default = /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives23.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives23.Path, { d: "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" }) }); 1751 1752 // packages/icons/build-module/library/previous.mjs 1753 var import_primitives24 = __toESM(require_primitives(), 1); 1754 var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1); 1755 var previous_default = /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives24.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives24.Path, { d: "M11.6 7l-1.1-1L5 12l5.5 6 1.1-1L7 12l4.6-5zm6 0l-1.1-1-5.5 6 5.5 6 1.1-1-4.6-5 4.6-5z" }) }); 1756 1757 // packages/icons/build-module/library/scheduled.mjs 1758 var import_primitives25 = __toESM(require_primitives(), 1); 1759 var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1); 1760 var scheduled_default = /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives25.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives25.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M12 18.5a6.5 6.5 0 1 1 0-13 6.5 6.5 0 0 1 0 13ZM4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Zm9 1V8h-1.5v3.5h-2V13H13Z" }) }); 1761 1762 // packages/icons/build-module/library/search.mjs 1763 var import_primitives26 = __toESM(require_primitives(), 1); 1764 var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1); 1765 var search_default = /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives26.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives26.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" }) }); 1766 1767 // packages/icons/build-module/library/seen.mjs 1768 var import_primitives27 = __toESM(require_primitives(), 1); 1769 var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1); 1770 var seen_default = /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives27.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives27.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" }) }); 1771 1772 // packages/icons/build-module/library/unseen.mjs 1773 var import_primitives28 = __toESM(require_primitives(), 1); 1774 var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1); 1775 var unseen_default = /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives28.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives28.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" }) }); 1776 1777 // packages/icons/build-module/library/upload.mjs 1778 var import_primitives29 = __toESM(require_primitives(), 1); 1779 var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1); 1780 var upload_default = /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives29.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives29.Path, { d: "M18.5 15v3.5H13V6.7l4.5 4.1 1-1.1-6.2-5.8-5.8 5.8 1 1.1 4-4v11.7h-6V15H4v5h16v-5z" }) }); 1781 1782 // packages/icons/build-module/library/video.mjs 1783 var import_primitives30 = __toESM(require_primitives(), 1); 1784 var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1); 1785 var video_default = /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives30.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives30.Path, { d: "M18.7 3H5.3C4 3 3 4 3 5.3v13.4C3 20 4 21 5.3 21h13.4c1.3 0 2.3-1 2.3-2.3V5.3C21 4 20 3 18.7 3zm.8 15.7c0 .4-.4.8-.8.8H5.3c-.4 0-.8-.4-.8-.8V5.3c0-.4.4-.8.8-.8h13.4c.4 0 .8.4.8.8v13.4zM10 15l5-3-5-3v6z" }) }); 1786 1787 // node_modules/@base-ui/utils/esm/safeReact.js 1788 var React = __toESM(require_react(), 1); 1789 var SafeReact = { 1790 ...React 1791 }; 1792 1793 // node_modules/@base-ui/utils/esm/useRefWithInit.js 1794 var React2 = __toESM(require_react(), 1); 1795 var UNINITIALIZED = {}; 1796 function useRefWithInit(init2, initArg) { 1797 const ref = React2.useRef(UNINITIALIZED); 1798 if (ref.current === UNINITIALIZED) { 1799 ref.current = init2(initArg); 1800 } 1801 return ref; 1802 } 1803 1804 // node_modules/@base-ui/utils/esm/useStableCallback.js 1805 var useInsertionEffect = SafeReact.useInsertionEffect; 1806 var useSafeInsertionEffect = ( 1807 // React 17 doesn't have useInsertionEffect. 1808 useInsertionEffect && // Preact replaces useInsertionEffect with useLayoutEffect and fires too late. 1809 useInsertionEffect !== SafeReact.useLayoutEffect ? useInsertionEffect : (fn) => fn() 1810 ); 1811 function useStableCallback(callback) { 1812 const stable = useRefWithInit(createStableCallback).current; 1813 stable.next = callback; 1814 useSafeInsertionEffect(stable.effect); 1815 return stable.trampoline; 1816 } 1817 function createStableCallback() { 1818 const stable = { 1819 next: void 0, 1820 callback: assertNotCalled, 1821 trampoline: (...args) => stable.callback?.(...args), 1822 effect: () => { 1823 stable.callback = stable.next; 1824 } 1825 }; 1826 return stable; 1827 } 1828 function assertNotCalled() { 1829 if (true) { 1830 throw ( 1831 /* minify-error-disabled */ 1832 new Error("Base UI: Cannot call an event handler while rendering.") 1833 ); 1834 } 1835 } 1836 1837 // node_modules/@base-ui/utils/esm/useIsoLayoutEffect.js 1838 var React3 = __toESM(require_react(), 1); 1839 var noop2 = () => { 1840 }; 1841 var useIsoLayoutEffect = typeof document !== "undefined" ? React3.useLayoutEffect : noop2; 1842 1843 // node_modules/@base-ui/utils/esm/warn.js 1844 var set; 1845 if (true) { 1846 set = /* @__PURE__ */ new Set(); 1847 } 1848 function warn(...messages) { 1849 if (true) { 1850 const messageKey = messages.join(" "); 1851 if (!set.has(messageKey)) { 1852 set.add(messageKey); 1853 console.warn(`Base UI: $messageKey}`); 1854 } 1855 } 1856 } 1857 1858 // node_modules/@base-ui/react/esm/internals/direction-context/DirectionContext.js 1859 var React4 = __toESM(require_react(), 1); 1860 var DirectionContext = /* @__PURE__ */ React4.createContext(void 0); 1861 if (true) DirectionContext.displayName = "DirectionContext"; 1862 function useDirection() { 1863 const context = React4.useContext(DirectionContext); 1864 return context?.direction ?? "ltr"; 1865 } 1866 1867 // node_modules/@base-ui/react/esm/internals/useRenderElement.js 1868 var React7 = __toESM(require_react(), 1); 1869 1870 // node_modules/@base-ui/utils/esm/useMergedRefs.js 1871 function useMergedRefs(a2, b2, c2, d2) { 1872 const forkRef = useRefWithInit(createForkRef).current; 1873 if (didChange(forkRef, a2, b2, c2, d2)) { 1874 update(forkRef, [a2, b2, c2, d2]); 1875 } 1876 return forkRef.callback; 1877 } 1878 function useMergedRefsN(refs) { 1879 const forkRef = useRefWithInit(createForkRef).current; 1880 if (didChangeN(forkRef, refs)) { 1881 update(forkRef, refs); 1882 } 1883 return forkRef.callback; 1884 } 1885 function createForkRef() { 1886 return { 1887 callback: null, 1888 cleanup: null, 1889 refs: [] 1890 }; 1891 } 1892 function didChange(forkRef, a2, b2, c2, d2) { 1893 return forkRef.refs[0] !== a2 || forkRef.refs[1] !== b2 || forkRef.refs[2] !== c2 || forkRef.refs[3] !== d2; 1894 } 1895 function didChangeN(forkRef, newRefs) { 1896 return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index2) => ref !== newRefs[index2]); 1897 } 1898 function update(forkRef, refs) { 1899 forkRef.refs = refs; 1900 if (refs.every((ref) => ref == null)) { 1901 forkRef.callback = null; 1902 return; 1903 } 1904 forkRef.callback = (instance) => { 1905 if (forkRef.cleanup) { 1906 forkRef.cleanup(); 1907 forkRef.cleanup = null; 1908 } 1909 if (instance != null) { 1910 const cleanupCallbacks = Array(refs.length).fill(null); 1911 for (let i2 = 0; i2 < refs.length; i2 += 1) { 1912 const ref = refs[i2]; 1913 if (ref == null) { 1914 continue; 1915 } 1916 switch (typeof ref) { 1917 case "function": { 1918 const refCleanup = ref(instance); 1919 if (typeof refCleanup === "function") { 1920 cleanupCallbacks[i2] = refCleanup; 1921 } 1922 break; 1923 } 1924 case "object": { 1925 ref.current = instance; 1926 break; 1927 } 1928 default: 1929 } 1930 } 1931 forkRef.cleanup = () => { 1932 for (let i2 = 0; i2 < refs.length; i2 += 1) { 1933 const ref = refs[i2]; 1934 if (ref == null) { 1935 continue; 1936 } 1937 switch (typeof ref) { 1938 case "function": { 1939 const cleanupCallback = cleanupCallbacks[i2]; 1940 if (typeof cleanupCallback === "function") { 1941 cleanupCallback(); 1942 } else { 1943 ref(null); 1944 } 1945 break; 1946 } 1947 case "object": { 1948 ref.current = null; 1949 break; 1950 } 1951 default: 1952 } 1953 } 1954 }; 1955 } 1956 }; 1957 } 1958 1959 // node_modules/@base-ui/utils/esm/getReactElementRef.js 1960 var React6 = __toESM(require_react(), 1); 1961 1962 // node_modules/@base-ui/utils/esm/reactVersion.js 1963 var React5 = __toESM(require_react(), 1); 1964 var majorVersion = parseInt(React5.version, 10); 1965 function isReactVersionAtLeast(reactVersionToCheck) { 1966 return majorVersion >= reactVersionToCheck; 1967 } 1968 1969 // node_modules/@base-ui/utils/esm/getReactElementRef.js 1970 function getReactElementRef(element) { 1971 if (!/* @__PURE__ */ React6.isValidElement(element)) { 1972 return null; 1973 } 1974 const reactElement = element; 1975 const propsWithRef = reactElement.props; 1976 return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null; 1977 } 1978 1979 // node_modules/@base-ui/utils/esm/mergeObjects.js 1980 function mergeObjects(a2, b2) { 1981 if (a2 && !b2) { 1982 return a2; 1983 } 1984 if (!a2 && b2) { 1985 return b2; 1986 } 1987 if (a2 || b2) { 1988 return { 1989 ...a2, 1990 ...b2 1991 }; 1992 } 1993 return void 0; 1994 } 1995 1996 // node_modules/@base-ui/utils/esm/empty.js 1997 function NOOP() { 1998 } 1999 var EMPTY_ARRAY = Object.freeze([]); 2000 var EMPTY_OBJECT = Object.freeze({}); 2001 2002 // node_modules/@base-ui/react/esm/internals/getStateAttributesProps.js 2003 function getStateAttributesProps(state, customMapping) { 2004 const props = {}; 2005 for (const key in state) { 2006 const value = state[key]; 2007 if (customMapping?.hasOwnProperty(key)) { 2008 const customProps = customMapping[key](value); 2009 if (customProps != null) { 2010 Object.assign(props, customProps); 2011 } 2012 continue; 2013 } 2014 if (value === true) { 2015 props[`data-$key.toLowerCase()}`] = ""; 2016 } else if (value) { 2017 props[`data-$key.toLowerCase()}`] = value.toString(); 2018 } 2019 } 2020 return props; 2021 } 2022 2023 // node_modules/@base-ui/react/esm/utils/resolveClassName.js 2024 function resolveClassName(className, state) { 2025 return typeof className === "function" ? className(state) : className; 2026 } 2027 2028 // node_modules/@base-ui/react/esm/utils/resolveStyle.js 2029 function resolveStyle(style, state) { 2030 return typeof style === "function" ? style(state) : style; 2031 } 2032 2033 // node_modules/@base-ui/react/esm/merge-props/mergeProps.js 2034 var EMPTY_PROPS = {}; 2035 function mergeProps(a2, b2, c2, d2, e2) { 2036 if (!c2 && !d2 && !e2 && !a2) { 2037 return createInitialMergedProps(b2); 2038 } 2039 let merged = createInitialMergedProps(a2); 2040 if (b2) { 2041 merged = mergeInto(merged, b2); 2042 } 2043 if (c2) { 2044 merged = mergeInto(merged, c2); 2045 } 2046 if (d2) { 2047 merged = mergeInto(merged, d2); 2048 } 2049 if (e2) { 2050 merged = mergeInto(merged, e2); 2051 } 2052 return merged; 2053 } 2054 function mergePropsN(props) { 2055 if (props.length === 0) { 2056 return EMPTY_PROPS; 2057 } 2058 if (props.length === 1) { 2059 return createInitialMergedProps(props[0]); 2060 } 2061 let merged = createInitialMergedProps(props[0]); 2062 for (let i2 = 1; i2 < props.length; i2 += 1) { 2063 merged = mergeInto(merged, props[i2]); 2064 } 2065 return merged; 2066 } 2067 function createInitialMergedProps(inputProps) { 2068 if (isPropsGetter(inputProps)) { 2069 return { 2070 ...resolvePropsGetter(inputProps, EMPTY_PROPS) 2071 }; 2072 } 2073 return copyInitialProps(inputProps); 2074 } 2075 function mergeInto(merged, inputProps) { 2076 if (isPropsGetter(inputProps)) { 2077 return resolvePropsGetter(inputProps, merged); 2078 } 2079 return mutablyMergeInto(merged, inputProps); 2080 } 2081 function copyInitialProps(inputProps) { 2082 const copiedProps = { 2083 ...inputProps 2084 }; 2085 for (const propName in copiedProps) { 2086 const propValue = copiedProps[propName]; 2087 if (isEventHandler(propName, propValue)) { 2088 copiedProps[propName] = wrapEventHandler(propValue); 2089 } 2090 } 2091 return copiedProps; 2092 } 2093 function mutablyMergeInto(mergedProps, externalProps) { 2094 if (!externalProps) { 2095 return mergedProps; 2096 } 2097 for (const propName in externalProps) { 2098 const externalPropValue = externalProps[propName]; 2099 switch (propName) { 2100 case "style": { 2101 mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue); 2102 break; 2103 } 2104 case "className": { 2105 mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue); 2106 break; 2107 } 2108 default: { 2109 if (isEventHandler(propName, externalPropValue)) { 2110 mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue); 2111 } else { 2112 mergedProps[propName] = externalPropValue; 2113 } 2114 } 2115 } 2116 } 2117 return mergedProps; 2118 } 2119 function isEventHandler(key, value) { 2120 const code0 = key.charCodeAt(0); 2121 const code1 = key.charCodeAt(1); 2122 const code2 = key.charCodeAt(2); 2123 return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined"); 2124 } 2125 function isPropsGetter(inputProps) { 2126 return typeof inputProps === "function"; 2127 } 2128 function resolvePropsGetter(inputProps, previousProps) { 2129 if (isPropsGetter(inputProps)) { 2130 return inputProps(previousProps); 2131 } 2132 return inputProps ?? EMPTY_PROPS; 2133 } 2134 function mergeEventHandlers(ourHandler, theirHandler) { 2135 if (!theirHandler) { 2136 return ourHandler; 2137 } 2138 if (!ourHandler) { 2139 return wrapEventHandler(theirHandler); 2140 } 2141 return (...args) => { 2142 const event = args[0]; 2143 if (isSyntheticEvent(event)) { 2144 const baseUIEvent = event; 2145 makeEventPreventable(baseUIEvent); 2146 const result2 = theirHandler(...args); 2147 if (!baseUIEvent.baseUIHandlerPrevented) { 2148 ourHandler?.(...args); 2149 } 2150 return result2; 2151 } 2152 const result = theirHandler(...args); 2153 ourHandler?.(...args); 2154 return result; 2155 }; 2156 } 2157 function wrapEventHandler(handler) { 2158 if (!handler) { 2159 return handler; 2160 } 2161 return (...args) => { 2162 const event = args[0]; 2163 if (isSyntheticEvent(event)) { 2164 makeEventPreventable(event); 2165 } 2166 return handler(...args); 2167 }; 2168 } 2169 function makeEventPreventable(event) { 2170 event.preventBaseUIHandler = () => { 2171 event.baseUIHandlerPrevented = true; 2172 }; 2173 return event; 2174 } 2175 function mergeClassNames(ourClassName, theirClassName) { 2176 if (theirClassName) { 2177 if (ourClassName) { 2178 return theirClassName + " " + ourClassName; 2179 } 2180 return theirClassName; 2181 } 2182 return ourClassName; 2183 } 2184 function isSyntheticEvent(event) { 2185 return event != null && typeof event === "object" && "nativeEvent" in event; 2186 } 2187 2188 // node_modules/@base-ui/react/esm/internals/useRenderElement.js 2189 var import_react = __toESM(require_react(), 1); 2190 function useRenderElement(element, componentProps, params = {}) { 2191 const renderProp = componentProps.render; 2192 const outProps = useRenderElementProps(componentProps, params); 2193 if (params.enabled === false) { 2194 return null; 2195 } 2196 const state = params.state ?? EMPTY_OBJECT; 2197 return evaluateRenderProp(element, renderProp, outProps, state); 2198 } 2199 function useRenderElementProps(componentProps, params = {}) { 2200 const { 2201 className: classNameProp, 2202 style: styleProp, 2203 render: renderProp 2204 } = componentProps; 2205 const { 2206 state = EMPTY_OBJECT, 2207 ref, 2208 props, 2209 stateAttributesMapping: stateAttributesMapping3, 2210 enabled = true 2211 } = params; 2212 const className = enabled ? resolveClassName(classNameProp, state) : void 0; 2213 const style = enabled ? resolveStyle(styleProp, state) : void 0; 2214 const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping3) : EMPTY_OBJECT; 2215 const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0; 2216 const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT; 2217 if (typeof document !== "undefined") { 2218 if (!enabled) { 2219 useMergedRefs(null, null); 2220 } else if (Array.isArray(ref)) { 2221 outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]); 2222 } else { 2223 outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref); 2224 } 2225 } 2226 if (!enabled) { 2227 return EMPTY_OBJECT; 2228 } 2229 if (className !== void 0) { 2230 outProps.className = mergeClassNames(outProps.className, className); 2231 } 2232 if (style !== void 0) { 2233 outProps.style = mergeObjects(outProps.style, style); 2234 } 2235 return outProps; 2236 } 2237 function resolveRenderFunctionProps(props) { 2238 if (Array.isArray(props)) { 2239 return mergePropsN(props); 2240 } 2241 return mergeProps(void 0, props); 2242 } 2243 var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy"); 2244 var COMPONENT_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9$]*$/; 2245 var LOWERCASE_CHARACTER_PATTERN = /[a-z]/; 2246 function evaluateRenderProp(element, render4, props, state) { 2247 if (render4) { 2248 if (typeof render4 === "function") { 2249 if (true) { 2250 warnIfRenderPropLooksLikeComponent(render4); 2251 } 2252 return render4(props, state); 2253 } 2254 const mergedProps = mergeProps(props, render4.props); 2255 mergedProps.ref = props.ref; 2256 let newElement = render4; 2257 if (newElement?.$$typeof === REACT_LAZY_TYPE) { 2258 const children = React7.Children.toArray(render4); 2259 newElement = children[0]; 2260 } 2261 if (true) { 2262 if (!/* @__PURE__ */ React7.isValidElement(newElement)) { 2263 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")); 2264 } 2265 } 2266 return /* @__PURE__ */ React7.cloneElement(newElement, mergedProps); 2267 } 2268 if (element) { 2269 if (typeof element === "string") { 2270 return renderTag(element, props); 2271 } 2272 } 2273 throw new Error(true ? "Base UI: Render element or function are not defined." : formatErrorMessage_default(8)); 2274 } 2275 function warnIfRenderPropLooksLikeComponent(renderFn) { 2276 const functionName = renderFn.name; 2277 if (functionName.length === 0) { 2278 return; 2279 } 2280 if (!COMPONENT_IDENTIFIER_PATTERN.test(functionName)) { 2281 return; 2282 } 2283 if (!LOWERCASE_CHARACTER_PATTERN.test(functionName)) { 2284 return; 2285 } 2286 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"); 2287 } 2288 function renderTag(Tag, props) { 2289 if (Tag === "button") { 2290 return /* @__PURE__ */ (0, import_react.createElement)("button", { 2291 type: "button", 2292 ...props, 2293 key: props.key 2294 }); 2295 } 2296 if (Tag === "img") { 2297 return /* @__PURE__ */ (0, import_react.createElement)("img", { 2298 alt: "", 2299 ...props, 2300 key: props.key 2301 }); 2302 } 2303 return /* @__PURE__ */ React7.createElement(Tag, props); 2304 } 2305 2306 // node_modules/@base-ui/react/esm/internals/reason-parts.js 2307 var reason_parts_exports = {}; 2308 __export(reason_parts_exports, { 2309 cancelOpen: () => cancelOpen, 2310 chipRemovePress: () => chipRemovePress, 2311 clearPress: () => clearPress, 2312 closePress: () => closePress, 2313 closeWatcher: () => closeWatcher, 2314 decrementPress: () => decrementPress, 2315 disabled: () => disabled, 2316 drag: () => drag, 2317 escapeKey: () => escapeKey, 2318 focusOut: () => focusOut, 2319 imperativeAction: () => imperativeAction, 2320 incrementPress: () => incrementPress, 2321 initial: () => initial, 2322 inputBlur: () => inputBlur, 2323 inputChange: () => inputChange, 2324 inputClear: () => inputClear, 2325 inputPaste: () => inputPaste, 2326 inputPress: () => inputPress, 2327 itemPress: () => itemPress, 2328 keyboard: () => keyboard, 2329 linkPress: () => linkPress, 2330 listNavigation: () => listNavigation, 2331 missing: () => missing, 2332 none: () => none, 2333 outsidePress: () => outsidePress, 2334 pointer: () => pointer, 2335 scrub: () => scrub, 2336 siblingOpen: () => siblingOpen, 2337 swipe: () => swipe, 2338 trackPress: () => trackPress, 2339 triggerFocus: () => triggerFocus, 2340 triggerHover: () => triggerHover, 2341 triggerPress: () => triggerPress, 2342 wheel: () => wheel, 2343 windowResize: () => windowResize 2344 }); 2345 var none = "none"; 2346 var triggerPress = "trigger-press"; 2347 var triggerHover = "trigger-hover"; 2348 var triggerFocus = "trigger-focus"; 2349 var outsidePress = "outside-press"; 2350 var itemPress = "item-press"; 2351 var closePress = "close-press"; 2352 var linkPress = "link-press"; 2353 var clearPress = "clear-press"; 2354 var chipRemovePress = "chip-remove-press"; 2355 var trackPress = "track-press"; 2356 var incrementPress = "increment-press"; 2357 var decrementPress = "decrement-press"; 2358 var inputChange = "input-change"; 2359 var inputClear = "input-clear"; 2360 var inputBlur = "input-blur"; 2361 var inputPaste = "input-paste"; 2362 var inputPress = "input-press"; 2363 var focusOut = "focus-out"; 2364 var escapeKey = "escape-key"; 2365 var closeWatcher = "close-watcher"; 2366 var listNavigation = "list-navigation"; 2367 var keyboard = "keyboard"; 2368 var pointer = "pointer"; 2369 var drag = "drag"; 2370 var wheel = "wheel"; 2371 var scrub = "scrub"; 2372 var cancelOpen = "cancel-open"; 2373 var siblingOpen = "sibling-open"; 2374 var disabled = "disabled"; 2375 var missing = "missing"; 2376 var initial = "initial"; 2377 var imperativeAction = "imperative-action"; 2378 var swipe = "swipe"; 2379 var windowResize = "window-resize"; 2380 2381 // node_modules/@base-ui/react/esm/internals/createBaseUIEventDetails.js 2382 function createChangeEventDetails(reason, event, trigger, customProperties) { 2383 let canceled = false; 2384 let allowPropagation = false; 2385 const custom = customProperties ?? EMPTY_OBJECT; 2386 const details = { 2387 reason, 2388 event: event ?? new Event("base-ui"), 2389 cancel() { 2390 canceled = true; 2391 }, 2392 allowPropagation() { 2393 allowPropagation = true; 2394 }, 2395 get isCanceled() { 2396 return canceled; 2397 }, 2398 get isPropagationAllowed() { 2399 return allowPropagation; 2400 }, 2401 trigger, 2402 ...custom 2403 }; 2404 return details; 2405 } 2406 2407 // node_modules/@base-ui/utils/esm/useId.js 2408 var React8 = __toESM(require_react(), 1); 2409 var globalId = 0; 2410 function useGlobalId(idOverride, prefix = "mui") { 2411 const [defaultId, setDefaultId] = React8.useState(idOverride); 2412 const id = idOverride || defaultId; 2413 React8.useEffect(() => { 2414 if (defaultId == null) { 2415 globalId += 1; 2416 setDefaultId(`$prefix}-$globalId}`); 2417 } 2418 }, [defaultId, prefix]); 2419 return id; 2420 } 2421 var maybeReactUseId = SafeReact.useId; 2422 function useId(idOverride, prefix) { 2423 if (maybeReactUseId !== void 0) { 2424 const reactId = maybeReactUseId(); 2425 return idOverride ?? (prefix ? `$prefix}-$reactId}` : reactId); 2426 } 2427 return useGlobalId(idOverride, prefix); 2428 } 2429 2430 // node_modules/@base-ui/react/esm/internals/useBaseUiId.js 2431 function useBaseUiId(idOverride) { 2432 return useId(idOverride, "base-ui"); 2433 } 2434 2435 // node_modules/@base-ui/react/esm/internals/useTransitionStatus.js 2436 var React10 = __toESM(require_react(), 1); 2437 2438 // node_modules/@base-ui/utils/esm/useOnMount.js 2439 var React9 = __toESM(require_react(), 1); 2440 var EMPTY = []; 2441 function useOnMount(fn) { 2442 React9.useEffect(fn, EMPTY); 2443 } 2444 2445 // node_modules/@base-ui/utils/esm/useAnimationFrame.js 2446 var EMPTY2 = null; 2447 var LAST_RAF = globalThis.requestAnimationFrame; 2448 var Scheduler = class { 2449 /* This implementation uses an array as a backing data-structure for frame callbacks. 2450 * It allows `O(1)` callback cancelling by inserting a `null` in the array, though it 2451 * never calls the native `cancelAnimationFrame` if there are no frames left. This can 2452 * be much more efficient if there is a call pattern that alterns as 2453 * "request-cancel-request-cancel-…". 2454 * But in the case of "request-request-…-cancel-cancel-…", it leaves the final animation 2455 * frame to run anyway. We turn that frame into a `O(1)` no-op via `callbacksCount`. */ 2456 callbacks = []; 2457 callbacksCount = 0; 2458 nextId = 1; 2459 startId = 1; 2460 isScheduled = false; 2461 tick = (timestamp) => { 2462 this.isScheduled = false; 2463 const currentCallbacks = this.callbacks; 2464 const currentCallbacksCount = this.callbacksCount; 2465 this.callbacks = []; 2466 this.callbacksCount = 0; 2467 this.startId = this.nextId; 2468 if (currentCallbacksCount > 0) { 2469 for (let i2 = 0; i2 < currentCallbacks.length; i2 += 1) { 2470 currentCallbacks[i2]?.(timestamp); 2471 } 2472 } 2473 }; 2474 request(fn) { 2475 const id = this.nextId; 2476 this.nextId += 1; 2477 this.callbacks.push(fn); 2478 this.callbacksCount += 1; 2479 const didRAFChange = LAST_RAF !== requestAnimationFrame && (LAST_RAF = requestAnimationFrame, true); 2480 if (!this.isScheduled || didRAFChange) { 2481 requestAnimationFrame(this.tick); 2482 this.isScheduled = true; 2483 } 2484 return id; 2485 } 2486 cancel(id) { 2487 const index2 = id - this.startId; 2488 if (index2 < 0 || index2 >= this.callbacks.length) { 2489 return; 2490 } 2491 this.callbacks[index2] = null; 2492 this.callbacksCount -= 1; 2493 } 2494 }; 2495 var scheduler = new Scheduler(); 2496 var AnimationFrame = class _AnimationFrame { 2497 static create() { 2498 return new _AnimationFrame(); 2499 } 2500 static request(fn) { 2501 return scheduler.request(fn); 2502 } 2503 static cancel(id) { 2504 return scheduler.cancel(id); 2505 } 2506 currentId = EMPTY2; 2507 /** 2508 * Executes `fn` after `delay`, clearing any previously scheduled call. 2509 */ 2510 request(fn) { 2511 this.cancel(); 2512 this.currentId = scheduler.request(() => { 2513 this.currentId = EMPTY2; 2514 fn(); 2515 }); 2516 } 2517 cancel = () => { 2518 if (this.currentId !== EMPTY2) { 2519 scheduler.cancel(this.currentId); 2520 this.currentId = EMPTY2; 2521 } 2522 }; 2523 disposeEffect = () => { 2524 return this.cancel; 2525 }; 2526 }; 2527 function useAnimationFrame() { 2528 const timeout = useRefWithInit(AnimationFrame.create).current; 2529 useOnMount(timeout.disposeEffect); 2530 return timeout; 2531 } 2532 2533 // node_modules/@base-ui/react/esm/internals/useTransitionStatus.js 2534 function useTransitionStatus(open, enableIdleState = false, deferEndingState = false) { 2535 const [transitionStatus, setTransitionStatus] = React10.useState(open && enableIdleState ? "idle" : void 0); 2536 const [mounted, setMounted] = React10.useState(open); 2537 if (open && !mounted) { 2538 setMounted(true); 2539 setTransitionStatus("starting"); 2540 } 2541 if (!open && mounted && transitionStatus !== "ending" && !deferEndingState) { 2542 setTransitionStatus("ending"); 2543 } 2544 if (!open && !mounted && transitionStatus === "ending") { 2545 setTransitionStatus(void 0); 2546 } 2547 useIsoLayoutEffect(() => { 2548 if (!open && mounted && transitionStatus !== "ending" && deferEndingState) { 2549 const frame = AnimationFrame.request(() => { 2550 setTransitionStatus("ending"); 2551 }); 2552 return () => { 2553 AnimationFrame.cancel(frame); 2554 }; 2555 } 2556 return void 0; 2557 }, [open, mounted, transitionStatus, deferEndingState]); 2558 useIsoLayoutEffect(() => { 2559 if (!open || enableIdleState) { 2560 return void 0; 2561 } 2562 const frame = AnimationFrame.request(() => { 2563 setTransitionStatus(void 0); 2564 }); 2565 return () => { 2566 AnimationFrame.cancel(frame); 2567 }; 2568 }, [enableIdleState, open]); 2569 useIsoLayoutEffect(() => { 2570 if (!open || !enableIdleState) { 2571 return void 0; 2572 } 2573 if (open && mounted && transitionStatus !== "idle") { 2574 setTransitionStatus("starting"); 2575 } 2576 const frame = AnimationFrame.request(() => { 2577 setTransitionStatus("idle"); 2578 }); 2579 return () => { 2580 AnimationFrame.cancel(frame); 2581 }; 2582 }, [enableIdleState, open, mounted, transitionStatus]); 2583 return { 2584 mounted, 2585 setMounted, 2586 transitionStatus 2587 }; 2588 } 2589 2590 // node_modules/@base-ui/react/esm/internals/stateAttributesMapping.js 2591 var TransitionStatusDataAttributes = /* @__PURE__ */ (function(TransitionStatusDataAttributes2) { 2592 TransitionStatusDataAttributes2["startingStyle"] = "data-starting-style"; 2593 TransitionStatusDataAttributes2["endingStyle"] = "data-ending-style"; 2594 return TransitionStatusDataAttributes2; 2595 })({}); 2596 var STARTING_HOOK = { 2597 [TransitionStatusDataAttributes.startingStyle]: "" 2598 }; 2599 var ENDING_HOOK = { 2600 [TransitionStatusDataAttributes.endingStyle]: "" 2601 }; 2602 var transitionStatusMapping = { 2603 transitionStatus(value) { 2604 if (value === "starting") { 2605 return STARTING_HOOK; 2606 } 2607 if (value === "ending") { 2608 return ENDING_HOOK; 2609 } 2610 return null; 2611 } 2612 }; 2613 2614 // node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs 2615 function hasWindow() { 2616 return typeof window !== "undefined"; 2617 } 2618 function getNodeName(node) { 2619 if (isNode(node)) { 2620 return (node.nodeName || "").toLowerCase(); 2621 } 2622 return "#document"; 2623 } 2624 function getWindow(node) { 2625 var _node$ownerDocument; 2626 return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window; 2627 } 2628 function getDocumentElement(node) { 2629 var _ref; 2630 return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement; 2631 } 2632 function isNode(value) { 2633 if (!hasWindow()) { 2634 return false; 2635 } 2636 return value instanceof Node || value instanceof getWindow(value).Node; 2637 } 2638 function isElement(value) { 2639 if (!hasWindow()) { 2640 return false; 2641 } 2642 return value instanceof Element || value instanceof getWindow(value).Element; 2643 } 2644 function isHTMLElement(value) { 2645 if (!hasWindow()) { 2646 return false; 2647 } 2648 return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement; 2649 } 2650 function isShadowRoot(value) { 2651 if (!hasWindow() || typeof ShadowRoot === "undefined") { 2652 return false; 2653 } 2654 return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot; 2655 } 2656 function isOverflowElement(element) { 2657 const { 2658 overflow, 2659 overflowX, 2660 overflowY, 2661 display 2662 } = getComputedStyle2(element); 2663 return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== "inline" && display !== "contents"; 2664 } 2665 function isTableElement(element) { 2666 return /^(table|td|th)$/.test(getNodeName(element)); 2667 } 2668 function isTopLayer(element) { 2669 try { 2670 if (element.matches(":popover-open")) { 2671 return true; 2672 } 2673 } catch (_e) { 2674 } 2675 try { 2676 return element.matches(":modal"); 2677 } catch (_e) { 2678 return false; 2679 } 2680 } 2681 var willChangeRe = /transform|translate|scale|rotate|perspective|filter/; 2682 var containRe = /paint|layout|strict|content/; 2683 var isNotNone = (value) => !!value && value !== "none"; 2684 var isWebKitValue; 2685 function isContainingBlock(elementOrCss) { 2686 const css = isElement(elementOrCss) ? getComputedStyle2(elementOrCss) : elementOrCss; 2687 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 || ""); 2688 } 2689 function getContainingBlock(element) { 2690 let currentNode = getParentNode(element); 2691 while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) { 2692 if (isContainingBlock(currentNode)) { 2693 return currentNode; 2694 } else if (isTopLayer(currentNode)) { 2695 return null; 2696 } 2697 currentNode = getParentNode(currentNode); 2698 } 2699 return null; 2700 } 2701 function isWebKit() { 2702 if (isWebKitValue == null) { 2703 isWebKitValue = typeof CSS !== "undefined" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none"); 2704 } 2705 return isWebKitValue; 2706 } 2707 function isLastTraversableNode(node) { 2708 return /^(html|body|#document)$/.test(getNodeName(node)); 2709 } 2710 function getComputedStyle2(element) { 2711 return getWindow(element).getComputedStyle(element); 2712 } 2713 function getNodeScroll(element) { 2714 if (isElement(element)) { 2715 return { 2716 scrollLeft: element.scrollLeft, 2717 scrollTop: element.scrollTop 2718 }; 2719 } 2720 return { 2721 scrollLeft: element.scrollX, 2722 scrollTop: element.scrollY 2723 }; 2724 } 2725 function getParentNode(node) { 2726 if (getNodeName(node) === "html") { 2727 return node; 2728 } 2729 const result = ( 2730 // Step into the shadow DOM of the parent of a slotted node. 2731 node.assignedSlot || // DOM Element detected. 2732 node.parentNode || // ShadowRoot detected. 2733 isShadowRoot(node) && node.host || // Fallback. 2734 getDocumentElement(node) 2735 ); 2736 return isShadowRoot(result) ? result.host : result; 2737 } 2738 function getNearestOverflowAncestor(node) { 2739 const parentNode = getParentNode(node); 2740 if (isLastTraversableNode(parentNode)) { 2741 return node.ownerDocument ? node.ownerDocument.body : node.body; 2742 } 2743 if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) { 2744 return parentNode; 2745 } 2746 return getNearestOverflowAncestor(parentNode); 2747 } 2748 function getOverflowAncestors(node, list, traverseIframes) { 2749 var _node$ownerDocument2; 2750 if (list === void 0) { 2751 list = []; 2752 } 2753 if (traverseIframes === void 0) { 2754 traverseIframes = true; 2755 } 2756 const scrollableAncestor = getNearestOverflowAncestor(node); 2757 const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body); 2758 const win = getWindow(scrollableAncestor); 2759 if (isBody) { 2760 const frameElement = getFrameElement(win); 2761 return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []); 2762 } else { 2763 return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes)); 2764 } 2765 } 2766 function getFrameElement(win) { 2767 return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null; 2768 } 2769 2770 // node_modules/@base-ui/utils/esm/detectBrowser.js 2771 var hasNavigator = typeof navigator !== "undefined"; 2772 var nav = getNavigatorData(); 2773 var platform = getPlatform(); 2774 var userAgent = getUserAgent(); 2775 var isWebKit2 = typeof CSS === "undefined" || !CSS.supports ? false : CSS.supports("-webkit-backdrop-filter:none"); 2776 var isIOS = ( 2777 // iPads can claim to be MacIntel 2778 nav.platform === "MacIntel" && nav.maxTouchPoints > 1 ? true : /iP(hone|ad|od)|iOS/.test(nav.platform) 2779 ); 2780 var isFirefox = hasNavigator && /firefox/i.test(userAgent); 2781 var isSafari = hasNavigator && /apple/i.test(navigator.vendor); 2782 var isEdge = hasNavigator && /Edg/i.test(userAgent); 2783 var isAndroid = hasNavigator && /android/i.test(platform) || /android/i.test(userAgent); 2784 var isMac = hasNavigator && platform.toLowerCase().startsWith("mac") && !navigator.maxTouchPoints; 2785 var isJSDOM = userAgent.includes("jsdom/"); 2786 function getNavigatorData() { 2787 if (!hasNavigator) { 2788 return { 2789 platform: "", 2790 maxTouchPoints: -1 2791 }; 2792 } 2793 const uaData = navigator.userAgentData; 2794 if (uaData?.platform) { 2795 return { 2796 platform: uaData.platform, 2797 maxTouchPoints: navigator.maxTouchPoints 2798 }; 2799 } 2800 return { 2801 platform: navigator.platform ?? "", 2802 maxTouchPoints: navigator.maxTouchPoints ?? -1 2803 }; 2804 } 2805 function getUserAgent() { 2806 if (!hasNavigator) { 2807 return ""; 2808 } 2809 const uaData = navigator.userAgentData; 2810 if (uaData && Array.isArray(uaData.brands)) { 2811 return uaData.brands.map(({ 2812 brand, 2813 version: version2 2814 }) => `$brand}/$version2}`).join(" "); 2815 } 2816 return navigator.userAgent; 2817 } 2818 function getPlatform() { 2819 if (!hasNavigator) { 2820 return ""; 2821 } 2822 const uaData = navigator.userAgentData; 2823 if (uaData?.platform) { 2824 return uaData.platform; 2825 } 2826 return navigator.platform ?? ""; 2827 } 2828 2829 // node_modules/@base-ui/react/esm/floating-ui-react/utils/constants.js 2830 var FOCUSABLE_ATTRIBUTE = "data-base-ui-focusable"; 2831 var TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])"; 2832 2833 // node_modules/@base-ui/react/esm/internals/shadowDom.js 2834 function activeElement(doc) { 2835 let element = doc.activeElement; 2836 while (element?.shadowRoot?.activeElement != null) { 2837 element = element.shadowRoot.activeElement; 2838 } 2839 return element; 2840 } 2841 function contains(parent, child) { 2842 if (!parent || !child) { 2843 return false; 2844 } 2845 const rootNode = child.getRootNode?.(); 2846 if (parent.contains(child)) { 2847 return true; 2848 } 2849 if (rootNode && isShadowRoot(rootNode)) { 2850 let next = child; 2851 while (next) { 2852 if (parent === next) { 2853 return true; 2854 } 2855 next = next.parentNode || next.host; 2856 } 2857 } 2858 return false; 2859 } 2860 function getTarget(event) { 2861 if ("composedPath" in event) { 2862 return event.composedPath()[0]; 2863 } 2864 return event.target; 2865 } 2866 2867 // node_modules/@base-ui/react/esm/floating-ui-react/utils/element.js 2868 function isTargetInsideEnabledTrigger(target, triggerElements) { 2869 if (!isElement(target)) { 2870 return false; 2871 } 2872 const targetElement = target; 2873 if (triggerElements.hasElement(targetElement)) { 2874 return !targetElement.hasAttribute("data-trigger-disabled"); 2875 } 2876 for (const [, trigger] of triggerElements.entries()) { 2877 if (contains(trigger, targetElement)) { 2878 return !trigger.hasAttribute("data-trigger-disabled"); 2879 } 2880 } 2881 return false; 2882 } 2883 function isEventTargetWithin(event, node) { 2884 if (node == null) { 2885 return false; 2886 } 2887 if ("composedPath" in event) { 2888 return event.composedPath().includes(node); 2889 } 2890 const eventAgain = event; 2891 return eventAgain.target != null && node.contains(eventAgain.target); 2892 } 2893 function isRootElement(element) { 2894 return element.matches("html,body"); 2895 } 2896 function isTypeableElement(element) { 2897 return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR); 2898 } 2899 function isInteractiveElement(element) { 2900 return element?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),$TYPEABLE_SELECTOR}`) != null; 2901 } 2902 function matchesFocusVisible(element) { 2903 if (!element || isJSDOM) { 2904 return true; 2905 } 2906 try { 2907 return element.matches(":focus-visible"); 2908 } catch (_e) { 2909 return true; 2910 } 2911 } 2912 2913 // node_modules/@base-ui/react/esm/floating-ui-react/utils/nodes.js 2914 function getNodeChildren(nodes, id, onlyOpenChildren = true) { 2915 const directChildren = nodes.filter((node) => node.parentId === id); 2916 return directChildren.flatMap((child) => [...!onlyOpenChildren || child.context?.open ? [child] : [], ...getNodeChildren(nodes, child.id, onlyOpenChildren)]); 2917 } 2918 2919 // node_modules/@base-ui/react/esm/floating-ui-react/utils/event.js 2920 function isReactEvent(event) { 2921 return "nativeEvent" in event; 2922 } 2923 function isMouseLikePointerType(pointerType, strict) { 2924 const values = ["mouse", "pen"]; 2925 if (!strict) { 2926 values.push("", void 0); 2927 } 2928 return values.includes(pointerType); 2929 } 2930 function isClickLikeEvent(event) { 2931 const type = event.type; 2932 return type === "click" || type === "mousedown" || type === "keydown" || type === "keyup"; 2933 } 2934 2935 // node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs 2936 var sides = ["top", "right", "bottom", "left"]; 2937 var min = Math.min; 2938 var max = Math.max; 2939 var round = Math.round; 2940 var floor = Math.floor; 2941 var createCoords = (v2) => ({ 2942 x: v2, 2943 y: v2 2944 }); 2945 var oppositeSideMap = { 2946 left: "right", 2947 right: "left", 2948 bottom: "top", 2949 top: "bottom" 2950 }; 2951 function clamp(start, value, end) { 2952 return max(start, min(value, end)); 2953 } 2954 function evaluate(value, param) { 2955 return typeof value === "function" ? value(param) : value; 2956 } 2957 function getSide(placement) { 2958 return placement.split("-")[0]; 2959 } 2960 function getAlignment(placement) { 2961 return placement.split("-")[1]; 2962 } 2963 function getOppositeAxis(axis) { 2964 return axis === "x" ? "y" : "x"; 2965 } 2966 function getAxisLength(axis) { 2967 return axis === "y" ? "height" : "width"; 2968 } 2969 function getSideAxis(placement) { 2970 const firstChar = placement[0]; 2971 return firstChar === "t" || firstChar === "b" ? "y" : "x"; 2972 } 2973 function getAlignmentAxis(placement) { 2974 return getOppositeAxis(getSideAxis(placement)); 2975 } 2976 function getAlignmentSides(placement, rects, rtl) { 2977 if (rtl === void 0) { 2978 rtl = false; 2979 } 2980 const alignment = getAlignment(placement); 2981 const alignmentAxis = getAlignmentAxis(placement); 2982 const length = getAxisLength(alignmentAxis); 2983 let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top"; 2984 if (rects.reference[length] > rects.floating[length]) { 2985 mainAlignmentSide = getOppositePlacement(mainAlignmentSide); 2986 } 2987 return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)]; 2988 } 2989 function getExpandedPlacements(placement) { 2990 const oppositePlacement = getOppositePlacement(placement); 2991 return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)]; 2992 } 2993 function getOppositeAlignmentPlacement(placement) { 2994 return placement.includes("start") ? placement.replace("start", "end") : placement.replace("end", "start"); 2995 } 2996 var lrPlacement = ["left", "right"]; 2997 var rlPlacement = ["right", "left"]; 2998 var tbPlacement = ["top", "bottom"]; 2999 var btPlacement = ["bottom", "top"]; 3000 function getSideList(side, isStart, rtl) { 3001 switch (side) { 3002 case "top": 3003 case "bottom": 3004 if (rtl) return isStart ? rlPlacement : lrPlacement; 3005 return isStart ? lrPlacement : rlPlacement; 3006 case "left": 3007 case "right": 3008 return isStart ? tbPlacement : btPlacement; 3009 default: 3010 return []; 3011 } 3012 } 3013 function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) { 3014 const alignment = getAlignment(placement); 3015 let list = getSideList(getSide(placement), direction === "start", rtl); 3016 if (alignment) { 3017 list = list.map((side) => side + "-" + alignment); 3018 if (flipAlignment) { 3019 list = list.concat(list.map(getOppositeAlignmentPlacement)); 3020 } 3021 } 3022 return list; 3023 } 3024 function getOppositePlacement(placement) { 3025 const side = getSide(placement); 3026 return oppositeSideMap[side] + placement.slice(side.length); 3027 } 3028 function expandPaddingObject(padding) { 3029 return { 3030 top: 0, 3031 right: 0, 3032 bottom: 0, 3033 left: 0, 3034 ...padding 3035 }; 3036 } 3037 function getPaddingObject(padding) { 3038 return typeof padding !== "number" ? expandPaddingObject(padding) : { 3039 top: padding, 3040 right: padding, 3041 bottom: padding, 3042 left: padding 3043 }; 3044 } 3045 function rectToClientRect(rect) { 3046 const { 3047 x: x2, 3048 y: y2, 3049 width, 3050 height 3051 } = rect; 3052 return { 3053 width, 3054 height, 3055 top: y2, 3056 left: x2, 3057 right: x2 + width, 3058 bottom: y2 + height, 3059 x: x2, 3060 y: y2 3061 }; 3062 } 3063 3064 // node_modules/@base-ui/react/esm/floating-ui-react/utils/composite.js 3065 function isHiddenByStyles(styles) { 3066 return styles.visibility === "hidden" || styles.visibility === "collapse"; 3067 } 3068 function isElementVisible(element, styles = element ? getComputedStyle2(element) : null) { 3069 if (!element || !element.isConnected || !styles || isHiddenByStyles(styles)) { 3070 return false; 3071 } 3072 if (typeof element.checkVisibility === "function") { 3073 return element.checkVisibility(); 3074 } 3075 return styles.display !== "none" && styles.display !== "contents"; 3076 } 3077 3078 // node_modules/@base-ui/utils/esm/owner.js 3079 function ownerDocument(node) { 3080 return node?.ownerDocument || document; 3081 } 3082 3083 // node_modules/@base-ui/react/esm/floating-ui-react/utils/tabbable.js 3084 var CANDIDATE_SELECTOR = 'a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]'; 3085 function getParentElement(element) { 3086 const assignedSlot = element.assignedSlot; 3087 if (assignedSlot) { 3088 return assignedSlot; 3089 } 3090 if (element.parentElement) { 3091 return element.parentElement; 3092 } 3093 const rootNode = element.getRootNode(); 3094 return isShadowRoot(rootNode) ? rootNode.host : null; 3095 } 3096 function getDetailsSummary(details) { 3097 for (const child of Array.from(details.children)) { 3098 if (getNodeName(child) === "summary") { 3099 return child; 3100 } 3101 } 3102 return null; 3103 } 3104 function isWithinOpenDetailsSummary(element, details) { 3105 const summary = getDetailsSummary(details); 3106 return !!summary && (element === summary || contains(summary, element)); 3107 } 3108 function isFocusableCandidate(element) { 3109 const nodeName = element ? getNodeName(element) : ""; 3110 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"); 3111 } 3112 function isFocusableElement(element) { 3113 if (!isFocusableCandidate(element) || !element.isConnected || element.matches(":disabled")) { 3114 return false; 3115 } 3116 for (let current = element; current; current = getParentElement(current)) { 3117 const isAncestor = current !== element; 3118 const isSlot = getNodeName(current) === "slot"; 3119 if (current.hasAttribute("inert")) { 3120 return false; 3121 } 3122 if (isAncestor && getNodeName(current) === "details" && !current.open && !isWithinOpenDetailsSummary(element, current) || current.hasAttribute("hidden") || !isSlot && !isVisibleInTabbableTree(current, isAncestor)) { 3123 return false; 3124 } 3125 } 3126 return true; 3127 } 3128 function isVisibleInTabbableTree(element, isAncestor) { 3129 const styles = getComputedStyle2(element); 3130 if (!isAncestor) { 3131 return isElementVisible(element, styles); 3132 } 3133 return styles.display !== "none"; 3134 } 3135 function getTabIndex(element) { 3136 const tabIndex = element.tabIndex; 3137 if (tabIndex < 0) { 3138 const nodeName = getNodeName(element); 3139 if (nodeName === "details" || nodeName === "audio" || nodeName === "video" || isHTMLElement(element) && element.isContentEditable) { 3140 return 0; 3141 } 3142 } 3143 return tabIndex; 3144 } 3145 function getNamedRadioInput(element) { 3146 if (getNodeName(element) !== "input") { 3147 return null; 3148 } 3149 const input = element; 3150 return input.type === "radio" && input.name !== "" ? input : null; 3151 } 3152 function isTabbableRadio(element, candidates) { 3153 const input = getNamedRadioInput(element); 3154 if (!input) { 3155 return true; 3156 } 3157 const checkedRadio = candidates.find((candidate) => { 3158 const radio = getNamedRadioInput(candidate); 3159 return radio?.name === input.name && radio.form === input.form && radio.checked; 3160 }); 3161 if (checkedRadio) { 3162 return checkedRadio === input; 3163 } 3164 return candidates.find((candidate) => { 3165 const radio = getNamedRadioInput(candidate); 3166 return radio?.name === input.name && radio.form === input.form; 3167 }) === input; 3168 } 3169 function getComposedChildren(container) { 3170 if (isHTMLElement(container) && getNodeName(container) === "slot") { 3171 const assignedElements = container.assignedElements({ 3172 flatten: true 3173 }); 3174 if (assignedElements.length > 0) { 3175 return assignedElements; 3176 } 3177 } 3178 if (isHTMLElement(container) && container.shadowRoot) { 3179 return Array.from(container.shadowRoot.children); 3180 } 3181 return Array.from(container.children); 3182 } 3183 function appendCandidates(container, list) { 3184 getComposedChildren(container).forEach((child) => { 3185 if (isFocusableCandidate(child)) { 3186 list.push(child); 3187 } 3188 appendCandidates(child, list); 3189 }); 3190 } 3191 function appendMatchingElements(container, selector2, list) { 3192 getComposedChildren(container).forEach((child) => { 3193 if (isHTMLElement(child) && child.matches(selector2)) { 3194 list.push(child); 3195 } 3196 appendMatchingElements(child, selector2, list); 3197 }); 3198 } 3199 function focusable(container) { 3200 const candidates = []; 3201 appendCandidates(container, candidates); 3202 return candidates.filter(isFocusableElement); 3203 } 3204 function tabbable(container) { 3205 const candidates = focusable(container); 3206 return candidates.filter((element) => getTabIndex(element) >= 0 && isTabbableRadio(element, candidates)); 3207 } 3208 function getTabbableIn(container, dir) { 3209 const list = tabbable(container); 3210 const len = list.length; 3211 if (len === 0) { 3212 return void 0; 3213 } 3214 const active = activeElement(ownerDocument(container)); 3215 const index2 = list.indexOf(active); 3216 const nextIndex = index2 === -1 ? dir === 1 ? 0 : len - 1 : index2 + dir; 3217 return list[nextIndex]; 3218 } 3219 function getNextTabbable(referenceElement) { 3220 return getTabbableIn(ownerDocument(referenceElement).body, 1) || referenceElement; 3221 } 3222 function getPreviousTabbable(referenceElement) { 3223 return getTabbableIn(ownerDocument(referenceElement).body, -1) || referenceElement; 3224 } 3225 function isOutsideEvent(event, container) { 3226 const containerElement = container || event.currentTarget; 3227 const relatedTarget = event.relatedTarget; 3228 return !relatedTarget || !contains(containerElement, relatedTarget); 3229 } 3230 function disableFocusInside(container) { 3231 const tabbableElements = tabbable(container); 3232 tabbableElements.forEach((element) => { 3233 element.dataset.tabindex = element.getAttribute("tabindex") || ""; 3234 element.setAttribute("tabindex", "-1"); 3235 }); 3236 } 3237 function enableFocusInside(container) { 3238 const elements = []; 3239 appendMatchingElements(container, "[data-tabindex]", elements); 3240 elements.forEach((element) => { 3241 const tabindex = element.dataset.tabindex; 3242 delete element.dataset.tabindex; 3243 if (tabindex) { 3244 element.setAttribute("tabindex", tabindex); 3245 } else { 3246 element.removeAttribute("tabindex"); 3247 } 3248 }); 3249 } 3250 3251 // node_modules/@base-ui/utils/esm/addEventListener.js 3252 function addEventListener(target, type, listener, options) { 3253 target.addEventListener(type, listener, options); 3254 return () => { 3255 target.removeEventListener(type, listener, options); 3256 }; 3257 } 3258 3259 // node_modules/@base-ui/utils/esm/useValueAsRef.js 3260 function useValueAsRef(value) { 3261 const latest = useRefWithInit(createLatestRef, value).current; 3262 latest.next = value; 3263 useIsoLayoutEffect(latest.effect); 3264 return latest; 3265 } 3266 function createLatestRef(value) { 3267 const latest = { 3268 current: value, 3269 next: value, 3270 effect: () => { 3271 latest.current = latest.next; 3272 } 3273 }; 3274 return latest; 3275 } 3276 3277 // node_modules/@base-ui/react/esm/internals/useOpenChangeComplete.js 3278 var React11 = __toESM(require_react(), 1); 3279 3280 // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js 3281 var ReactDOM = __toESM(require_react_dom(), 1); 3282 3283 // node_modules/@base-ui/react/esm/utils/resolveRef.js 3284 function resolveRef(maybeRef) { 3285 if (maybeRef == null) { 3286 return maybeRef; 3287 } 3288 return "current" in maybeRef ? maybeRef.current : maybeRef; 3289 } 3290 3291 // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js 3292 function useAnimationsFinished(elementOrRef, waitForStartingStyleRemoved = false, treatAbortedAsFinished = true) { 3293 const frame = useAnimationFrame(); 3294 return useStableCallback((fnToExecute, signal = null) => { 3295 frame.cancel(); 3296 const element = resolveRef(elementOrRef); 3297 if (element == null) { 3298 return; 3299 } 3300 const resolvedElement = element; 3301 const done = () => { 3302 ReactDOM.flushSync(fnToExecute); 3303 }; 3304 if (typeof resolvedElement.getAnimations !== "function" || globalThis.BASE_UI_ANIMATIONS_DISABLED) { 3305 fnToExecute(); 3306 return; 3307 } 3308 function exec() { 3309 Promise.all(resolvedElement.getAnimations().map((animation) => animation.finished)).then(() => { 3310 if (!signal?.aborted) { 3311 done(); 3312 } 3313 }).catch(() => { 3314 if (treatAbortedAsFinished) { 3315 if (!signal?.aborted) { 3316 done(); 3317 } 3318 return; 3319 } 3320 const currentAnimations = resolvedElement.getAnimations(); 3321 if (!signal?.aborted && currentAnimations.length > 0 && currentAnimations.some((animation) => animation.pending || animation.playState !== "finished")) { 3322 exec(); 3323 } 3324 }); 3325 } 3326 if (waitForStartingStyleRemoved) { 3327 const startingStyleAttribute = TransitionStatusDataAttributes.startingStyle; 3328 if (!resolvedElement.hasAttribute(startingStyleAttribute)) { 3329 frame.request(exec); 3330 return; 3331 } 3332 const attributeObserver = new MutationObserver(() => { 3333 if (!resolvedElement.hasAttribute(startingStyleAttribute)) { 3334 attributeObserver.disconnect(); 3335 exec(); 3336 } 3337 }); 3338 attributeObserver.observe(resolvedElement, { 3339 attributes: true, 3340 attributeFilter: [startingStyleAttribute] 3341 }); 3342 signal?.addEventListener("abort", () => attributeObserver.disconnect(), { 3343 once: true 3344 }); 3345 return; 3346 } 3347 frame.request(exec); 3348 }); 3349 } 3350 3351 // node_modules/@base-ui/react/esm/internals/useOpenChangeComplete.js 3352 function useOpenChangeComplete(parameters) { 3353 const { 3354 enabled = true, 3355 open, 3356 ref, 3357 onComplete: onCompleteParam 3358 } = parameters; 3359 const onComplete = useStableCallback(onCompleteParam); 3360 const runOnceAnimationsFinish = useAnimationsFinished(ref, open, false); 3361 React11.useEffect(() => { 3362 if (!enabled) { 3363 return void 0; 3364 } 3365 const abortController = new AbortController(); 3366 runOnceAnimationsFinish(onComplete, abortController.signal); 3367 return () => { 3368 abortController.abort(); 3369 }; 3370 }, [enabled, open, onComplete, runOnceAnimationsFinish]); 3371 } 3372 3373 // node_modules/@base-ui/utils/esm/useOnFirstRender.js 3374 var React12 = __toESM(require_react(), 1); 3375 function useOnFirstRender(fn) { 3376 const ref = React12.useRef(true); 3377 if (ref.current) { 3378 ref.current = false; 3379 fn(); 3380 } 3381 } 3382 3383 // node_modules/@base-ui/utils/esm/useTimeout.js 3384 var EMPTY3 = 0; 3385 var Timeout = class _Timeout { 3386 static create() { 3387 return new _Timeout(); 3388 } 3389 currentId = EMPTY3; 3390 /** 3391 * Executes `fn` after `delay`, clearing any previously scheduled call. 3392 */ 3393 start(delay, fn) { 3394 this.clear(); 3395 this.currentId = setTimeout(() => { 3396 this.currentId = EMPTY3; 3397 fn(); 3398 }, delay); 3399 } 3400 isStarted() { 3401 return this.currentId !== EMPTY3; 3402 } 3403 clear = () => { 3404 if (this.currentId !== EMPTY3) { 3405 clearTimeout(this.currentId); 3406 this.currentId = EMPTY3; 3407 } 3408 }; 3409 disposeEffect = () => { 3410 return this.clear; 3411 }; 3412 }; 3413 function useTimeout() { 3414 const timeout = useRefWithInit(Timeout.create).current; 3415 useOnMount(timeout.disposeEffect); 3416 return timeout; 3417 } 3418 3419 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingDelayGroup.js 3420 var React13 = __toESM(require_react(), 1); 3421 3422 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverShared.js 3423 function resolveValue(value, pointerType) { 3424 if (pointerType != null && !isMouseLikePointerType(pointerType)) { 3425 return 0; 3426 } 3427 if (typeof value === "function") { 3428 return value(); 3429 } 3430 return value; 3431 } 3432 function getDelay(value, prop, pointerType) { 3433 const result = resolveValue(value, pointerType); 3434 if (typeof result === "number") { 3435 return result; 3436 } 3437 return result?.[prop]; 3438 } 3439 function getRestMs(value) { 3440 if (typeof value === "function") { 3441 return value(); 3442 } 3443 return value; 3444 } 3445 function isClickLikeOpenEvent(openEventType, interactedInside) { 3446 return interactedInside || openEventType === "click" || openEventType === "mousedown"; 3447 } 3448 function isHoverOpenEvent(openEventType) { 3449 return openEventType?.includes("mouse") && openEventType !== "mousedown"; 3450 } 3451 3452 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingDelayGroup.js 3453 var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1); 3454 var FloatingDelayGroupContext = /* @__PURE__ */ React13.createContext({ 3455 hasProvider: false, 3456 timeoutMs: 0, 3457 delayRef: { 3458 current: 0 3459 }, 3460 initialDelayRef: { 3461 current: 0 3462 }, 3463 timeout: new Timeout(), 3464 currentIdRef: { 3465 current: null 3466 }, 3467 currentContextRef: { 3468 current: null 3469 } 3470 }); 3471 if (true) FloatingDelayGroupContext.displayName = "FloatingDelayGroupContext"; 3472 function FloatingDelayGroup(props) { 3473 const { 3474 children, 3475 delay, 3476 timeoutMs = 0 3477 } = props; 3478 const delayRef = React13.useRef(delay); 3479 const initialDelayRef = React13.useRef(delay); 3480 const currentIdRef = React13.useRef(null); 3481 const currentContextRef = React13.useRef(null); 3482 const timeout = useTimeout(); 3483 return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(FloatingDelayGroupContext.Provider, { 3484 value: React13.useMemo(() => ({ 3485 hasProvider: true, 3486 delayRef, 3487 initialDelayRef, 3488 currentIdRef, 3489 timeoutMs, 3490 currentContextRef, 3491 timeout 3492 }), [timeoutMs, timeout]), 3493 children 3494 }); 3495 } 3496 function useDelayGroup(context, options = { 3497 open: false 3498 }) { 3499 const { 3500 open 3501 } = options; 3502 const store = "rootStore" in context ? context.rootStore : context; 3503 const floatingId = store.useState("floatingId"); 3504 const groupContext = React13.useContext(FloatingDelayGroupContext); 3505 const { 3506 currentIdRef, 3507 delayRef, 3508 timeoutMs, 3509 initialDelayRef, 3510 currentContextRef, 3511 hasProvider, 3512 timeout 3513 } = groupContext; 3514 const [isInstantPhase, setIsInstantPhase] = React13.useState(false); 3515 useIsoLayoutEffect(() => { 3516 function unset() { 3517 setIsInstantPhase(false); 3518 currentContextRef.current?.setIsInstantPhase(false); 3519 currentIdRef.current = null; 3520 currentContextRef.current = null; 3521 delayRef.current = initialDelayRef.current; 3522 } 3523 if (!currentIdRef.current) { 3524 return void 0; 3525 } 3526 if (!open && currentIdRef.current === floatingId) { 3527 setIsInstantPhase(false); 3528 if (timeoutMs) { 3529 const closingId = floatingId; 3530 timeout.start(timeoutMs, () => { 3531 if (store.select("open") || currentIdRef.current && currentIdRef.current !== closingId) { 3532 return; 3533 } 3534 unset(); 3535 }); 3536 return () => { 3537 timeout.clear(); 3538 }; 3539 } 3540 unset(); 3541 } 3542 return void 0; 3543 }, [open, floatingId, currentIdRef, delayRef, timeoutMs, initialDelayRef, currentContextRef, timeout, store]); 3544 useIsoLayoutEffect(() => { 3545 if (!open) { 3546 return; 3547 } 3548 const prevContext = currentContextRef.current; 3549 const prevId = currentIdRef.current; 3550 timeout.clear(); 3551 currentContextRef.current = { 3552 onOpenChange: store.setOpen, 3553 setIsInstantPhase 3554 }; 3555 currentIdRef.current = floatingId; 3556 delayRef.current = { 3557 open: 0, 3558 close: getDelay(initialDelayRef.current, "close") 3559 }; 3560 if (prevId !== null && prevId !== floatingId) { 3561 setIsInstantPhase(true); 3562 prevContext?.setIsInstantPhase(true); 3563 prevContext?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.none)); 3564 } else { 3565 setIsInstantPhase(false); 3566 prevContext?.setIsInstantPhase(false); 3567 } 3568 }, [open, floatingId, store, currentIdRef, delayRef, initialDelayRef, currentContextRef, timeout]); 3569 useIsoLayoutEffect(() => { 3570 return () => { 3571 currentContextRef.current = null; 3572 }; 3573 }, [currentContextRef]); 3574 return React13.useMemo(() => ({ 3575 hasProvider, 3576 delayRef, 3577 isInstantPhase 3578 }), [hasProvider, delayRef, isInstantPhase]); 3579 } 3580 3581 // node_modules/@base-ui/utils/esm/mergeCleanups.js 3582 function mergeCleanups(...cleanups) { 3583 return () => { 3584 for (let i2 = 0; i2 < cleanups.length; i2 += 1) { 3585 const cleanup = cleanups[i2]; 3586 if (cleanup) { 3587 cleanup(); 3588 } 3589 } 3590 }; 3591 } 3592 3593 // node_modules/@base-ui/react/esm/utils/FocusGuard.js 3594 var React14 = __toESM(require_react(), 1); 3595 3596 // node_modules/@base-ui/utils/esm/visuallyHidden.js 3597 var visuallyHiddenBase = { 3598 clipPath: "inset(50%)", 3599 overflow: "hidden", 3600 whiteSpace: "nowrap", 3601 border: 0, 3602 padding: 0, 3603 width: 1, 3604 height: 1, 3605 margin: -1 3606 }; 3607 var visuallyHidden = { 3608 ...visuallyHiddenBase, 3609 position: "fixed", 3610 top: 0, 3611 left: 0 3612 }; 3613 var visuallyHiddenInput = { 3614 ...visuallyHiddenBase, 3615 position: "absolute" 3616 }; 3617 3618 // node_modules/@base-ui/react/esm/utils/FocusGuard.js 3619 var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1); 3620 var FocusGuard = /* @__PURE__ */ React14.forwardRef(function FocusGuard2(props, ref) { 3621 const [role, setRole] = React14.useState(); 3622 useIsoLayoutEffect(() => { 3623 if (isSafari) { 3624 setRole("button"); 3625 } 3626 }, []); 3627 const restProps = { 3628 tabIndex: 0, 3629 // Role is only for VoiceOver 3630 role 3631 }; 3632 return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { 3633 ...props, 3634 ref, 3635 style: visuallyHidden, 3636 "aria-hidden": role ? void 0 : true, 3637 ...restProps, 3638 "data-base-ui-focus-guard": "" 3639 }); 3640 }); 3641 if (true) FocusGuard.displayName = "FocusGuard"; 3642 3643 // node_modules/@base-ui/react/esm/floating-ui-react/utils/createAttribute.js 3644 function createAttribute(name) { 3645 return `data-base-ui-$name}`; 3646 } 3647 3648 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingPortal.js 3649 var React15 = __toESM(require_react(), 1); 3650 var ReactDOM2 = __toESM(require_react_dom(), 1); 3651 3652 // node_modules/@base-ui/react/esm/internals/constants.js 3653 var DISABLED_TRANSITIONS_STYLE = { 3654 style: { 3655 transition: "none" 3656 } 3657 }; 3658 var BASE_UI_SWIPE_IGNORE_ATTRIBUTE = "data-base-ui-swipe-ignore"; 3659 var LEGACY_SWIPE_IGNORE_ATTRIBUTE = "data-swipe-ignore"; 3660 var BASE_UI_SWIPE_IGNORE_SELECTOR = `[$BASE_UI_SWIPE_IGNORE_ATTRIBUTE}]`; 3661 var LEGACY_SWIPE_IGNORE_SELECTOR = `[$LEGACY_SWIPE_IGNORE_ATTRIBUTE}]`; 3662 var POPUP_COLLISION_AVOIDANCE = { 3663 fallbackAxisSide: "end" 3664 }; 3665 var ownerVisuallyHidden = { 3666 clipPath: "inset(50%)", 3667 position: "fixed", 3668 top: 0, 3669 left: 0 3670 }; 3671 3672 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingPortal.js 3673 var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1); 3674 var PortalContext = /* @__PURE__ */ React15.createContext(null); 3675 if (true) PortalContext.displayName = "PortalContext"; 3676 var usePortalContext = () => React15.useContext(PortalContext); 3677 var attr = createAttribute("portal"); 3678 function useFloatingPortalNode(props = {}) { 3679 const { 3680 ref, 3681 container: containerProp, 3682 componentProps = EMPTY_OBJECT, 3683 elementProps 3684 } = props; 3685 const uniqueId = useId(); 3686 const portalContext = usePortalContext(); 3687 const parentPortalNode = portalContext?.portalNode; 3688 const [containerElement, setContainerElement] = React15.useState(null); 3689 const [portalNode, setPortalNode] = React15.useState(null); 3690 const setPortalNodeRef = useStableCallback((node) => { 3691 if (node !== null) { 3692 setPortalNode(node); 3693 } 3694 }); 3695 const containerRef = React15.useRef(null); 3696 useIsoLayoutEffect(() => { 3697 if (containerProp === null) { 3698 if (containerRef.current) { 3699 containerRef.current = null; 3700 setPortalNode(null); 3701 setContainerElement(null); 3702 } 3703 return; 3704 } 3705 if (uniqueId == null) { 3706 return; 3707 } 3708 const resolvedContainer = (containerProp && (isNode(containerProp) ? containerProp : containerProp.current)) ?? parentPortalNode ?? document.body; 3709 if (resolvedContainer == null) { 3710 if (containerRef.current) { 3711 containerRef.current = null; 3712 setPortalNode(null); 3713 setContainerElement(null); 3714 } 3715 return; 3716 } 3717 if (containerRef.current !== resolvedContainer) { 3718 containerRef.current = resolvedContainer; 3719 setPortalNode(null); 3720 setContainerElement(resolvedContainer); 3721 } 3722 }, [containerProp, parentPortalNode, uniqueId]); 3723 const portalElement = useRenderElement("div", componentProps, { 3724 ref: [ref, setPortalNodeRef], 3725 props: [{ 3726 id: uniqueId, 3727 [attr]: "" 3728 }, elementProps] 3729 }); 3730 const portalSubtree = containerElement && portalElement ? /* @__PURE__ */ ReactDOM2.createPortal(portalElement, containerElement) : null; 3731 return { 3732 portalNode, 3733 portalSubtree 3734 }; 3735 } 3736 var FloatingPortal = /* @__PURE__ */ React15.forwardRef(function FloatingPortal2(componentProps, forwardedRef) { 3737 const { 3738 render: render4, 3739 className, 3740 style, 3741 children, 3742 container, 3743 renderGuards, 3744 ...elementProps 3745 } = componentProps; 3746 const { 3747 portalNode, 3748 portalSubtree 3749 } = useFloatingPortalNode({ 3750 container, 3751 ref: forwardedRef, 3752 componentProps, 3753 elementProps 3754 }); 3755 const beforeOutsideRef = React15.useRef(null); 3756 const afterOutsideRef = React15.useRef(null); 3757 const beforeInsideRef = React15.useRef(null); 3758 const afterInsideRef = React15.useRef(null); 3759 const [focusManagerState, setFocusManagerState] = React15.useState(null); 3760 const focusInsideDisabledRef = React15.useRef(false); 3761 const modal = focusManagerState?.modal; 3762 const open = focusManagerState?.open; 3763 const shouldRenderGuards = typeof renderGuards === "boolean" ? renderGuards : !!focusManagerState && !focusManagerState.modal && focusManagerState.open && !!portalNode; 3764 React15.useEffect(() => { 3765 if (!portalNode || modal) { 3766 return void 0; 3767 } 3768 function onFocus(event) { 3769 if (portalNode && event.relatedTarget && isOutsideEvent(event)) { 3770 if (event.type === "focusin") { 3771 if (focusInsideDisabledRef.current) { 3772 enableFocusInside(portalNode); 3773 focusInsideDisabledRef.current = false; 3774 } 3775 } else { 3776 disableFocusInside(portalNode); 3777 focusInsideDisabledRef.current = true; 3778 } 3779 } 3780 } 3781 return mergeCleanups(addEventListener(portalNode, "focusin", onFocus, true), addEventListener(portalNode, "focusout", onFocus, true)); 3782 }, [portalNode, modal]); 3783 React15.useEffect(() => { 3784 if (!portalNode || open !== false) { 3785 return; 3786 } 3787 enableFocusInside(portalNode); 3788 focusInsideDisabledRef.current = false; 3789 }, [open, portalNode]); 3790 const portalContextValue = React15.useMemo(() => ({ 3791 beforeOutsideRef, 3792 afterOutsideRef, 3793 beforeInsideRef, 3794 afterInsideRef, 3795 portalNode, 3796 setFocusManagerState 3797 }), [portalNode]); 3798 return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(React15.Fragment, { 3799 children: [portalSubtree, /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(PortalContext.Provider, { 3800 value: portalContextValue, 3801 children: [shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(FocusGuard, { 3802 "data-type": "outside", 3803 ref: beforeOutsideRef, 3804 onFocus: (event) => { 3805 if (isOutsideEvent(event, portalNode)) { 3806 beforeInsideRef.current?.focus(); 3807 } else { 3808 const domReference = focusManagerState ? focusManagerState.domReference : null; 3809 const prevTabbable = getPreviousTabbable(domReference); 3810 prevTabbable?.focus(); 3811 } 3812 } 3813 }), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { 3814 "aria-owns": portalNode.id, 3815 style: ownerVisuallyHidden 3816 }), portalNode && /* @__PURE__ */ ReactDOM2.createPortal(children, portalNode), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(FocusGuard, { 3817 "data-type": "outside", 3818 ref: afterOutsideRef, 3819 onFocus: (event) => { 3820 if (isOutsideEvent(event, portalNode)) { 3821 afterInsideRef.current?.focus(); 3822 } else { 3823 const domReference = focusManagerState ? focusManagerState.domReference : null; 3824 const nextTabbable = getNextTabbable(domReference); 3825 nextTabbable?.focus(); 3826 if (focusManagerState?.closeOnFocusOut) { 3827 focusManagerState?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.focusOut, event.nativeEvent)); 3828 } 3829 } 3830 } 3831 })] 3832 })] 3833 }); 3834 }); 3835 if (true) FloatingPortal.displayName = "FloatingPortal"; 3836 3837 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingTree.js 3838 var React16 = __toESM(require_react(), 1); 3839 3840 // node_modules/@base-ui/react/esm/floating-ui-react/utils/createEventEmitter.js 3841 function createEventEmitter() { 3842 const map = /* @__PURE__ */ new Map(); 3843 return { 3844 emit(event, data) { 3845 map.get(event)?.forEach((listener) => listener(data)); 3846 }, 3847 on(event, listener) { 3848 if (!map.has(event)) { 3849 map.set(event, /* @__PURE__ */ new Set()); 3850 } 3851 map.get(event).add(listener); 3852 }, 3853 off(event, listener) { 3854 map.get(event)?.delete(listener); 3855 } 3856 }; 3857 } 3858 3859 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingTree.js 3860 var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1); 3861 var FloatingNodeContext = /* @__PURE__ */ React16.createContext(null); 3862 if (true) FloatingNodeContext.displayName = "FloatingNodeContext"; 3863 var FloatingTreeContext = /* @__PURE__ */ React16.createContext(null); 3864 if (true) FloatingTreeContext.displayName = "FloatingTreeContext"; 3865 var useFloatingParentNodeId = () => React16.useContext(FloatingNodeContext)?.id || null; 3866 var useFloatingTree = (externalTree) => { 3867 const contextTree = React16.useContext(FloatingTreeContext); 3868 return externalTree ?? contextTree; 3869 }; 3870 3871 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useClientPoint.js 3872 var React17 = __toESM(require_react(), 1); 3873 function createVirtualElement(domElement, data) { 3874 let offsetX = null; 3875 let offsetY = null; 3876 let isAutoUpdateEvent = false; 3877 return { 3878 contextElement: domElement || void 0, 3879 getBoundingClientRect() { 3880 const domRect = domElement?.getBoundingClientRect() || { 3881 width: 0, 3882 height: 0, 3883 x: 0, 3884 y: 0 3885 }; 3886 const isXAxis = data.axis === "x" || data.axis === "both"; 3887 const isYAxis = data.axis === "y" || data.axis === "both"; 3888 const canTrackCursorOnAutoUpdate = ["mouseenter", "mousemove"].includes(data.dataRef.current.openEvent?.type || "") && data.pointerType !== "touch"; 3889 let width = domRect.width; 3890 let height = domRect.height; 3891 let x2 = domRect.x; 3892 let y2 = domRect.y; 3893 if (offsetX == null && data.x && isXAxis) { 3894 offsetX = domRect.x - data.x; 3895 } 3896 if (offsetY == null && data.y && isYAxis) { 3897 offsetY = domRect.y - data.y; 3898 } 3899 x2 -= offsetX || 0; 3900 y2 -= offsetY || 0; 3901 width = 0; 3902 height = 0; 3903 if (!isAutoUpdateEvent || canTrackCursorOnAutoUpdate) { 3904 width = data.axis === "y" ? domRect.width : 0; 3905 height = data.axis === "x" ? domRect.height : 0; 3906 x2 = isXAxis && data.x != null ? data.x : x2; 3907 y2 = isYAxis && data.y != null ? data.y : y2; 3908 } else if (isAutoUpdateEvent && !canTrackCursorOnAutoUpdate) { 3909 height = data.axis === "x" ? domRect.height : height; 3910 width = data.axis === "y" ? domRect.width : width; 3911 } 3912 isAutoUpdateEvent = true; 3913 return { 3914 width, 3915 height, 3916 x: x2, 3917 y: y2, 3918 top: y2, 3919 right: x2 + width, 3920 bottom: y2 + height, 3921 left: x2 3922 }; 3923 } 3924 }; 3925 } 3926 function isMouseBasedEvent(event) { 3927 return event != null && event.clientX != null; 3928 } 3929 function useClientPoint(context, props = {}) { 3930 const { 3931 enabled = true, 3932 axis = "both" 3933 } = props; 3934 const store = "rootStore" in context ? context.rootStore : context; 3935 const open = store.useState("open"); 3936 const floating = store.useState("floatingElement"); 3937 const domReference = store.useState("domReferenceElement"); 3938 const dataRef = store.context.dataRef; 3939 const initialRef = React17.useRef(false); 3940 const cleanupListenerRef = React17.useRef(null); 3941 const [pointerType, setPointerType] = React17.useState(); 3942 const [reactive, setReactive] = React17.useState([]); 3943 const resetReference = useStableCallback((reference2) => { 3944 store.set("positionReference", reference2); 3945 }); 3946 const setReference = useStableCallback((newX, newY, referenceElement) => { 3947 if (initialRef.current) { 3948 return; 3949 } 3950 if (dataRef.current.openEvent && !isMouseBasedEvent(dataRef.current.openEvent)) { 3951 return; 3952 } 3953 store.set("positionReference", createVirtualElement(referenceElement ?? domReference, { 3954 x: newX, 3955 y: newY, 3956 axis, 3957 dataRef, 3958 pointerType 3959 })); 3960 }); 3961 const handleReferenceEnterOrMove = useStableCallback((event) => { 3962 if (!open) { 3963 setReference(event.clientX, event.clientY, event.currentTarget); 3964 } else if (!cleanupListenerRef.current) { 3965 setReference(event.clientX, event.clientY, event.currentTarget); 3966 setReactive([]); 3967 } 3968 }); 3969 const openCheck = isMouseLikePointerType(pointerType) ? floating : open; 3970 React17.useEffect(() => { 3971 if (!enabled) { 3972 resetReference(domReference); 3973 return void 0; 3974 } 3975 if (!openCheck) { 3976 return void 0; 3977 } 3978 function cleanupListener() { 3979 cleanupListenerRef.current?.(); 3980 cleanupListenerRef.current = null; 3981 } 3982 const win = getWindow(floating); 3983 function handleMouseMove(event) { 3984 const target = getTarget(event); 3985 if (!contains(floating, target)) { 3986 setReference(event.clientX, event.clientY); 3987 } else { 3988 cleanupListener(); 3989 } 3990 } 3991 if (!dataRef.current.openEvent || isMouseBasedEvent(dataRef.current.openEvent)) { 3992 cleanupListenerRef.current = addEventListener(win, "mousemove", handleMouseMove); 3993 } else { 3994 resetReference(domReference); 3995 } 3996 return cleanupListener; 3997 }, [openCheck, enabled, floating, dataRef, domReference, store, setReference, resetReference, reactive]); 3998 React17.useEffect(() => () => { 3999 store.set("positionReference", null); 4000 }, [store]); 4001 React17.useEffect(() => { 4002 if (enabled && !floating) { 4003 initialRef.current = false; 4004 } 4005 }, [enabled, floating]); 4006 React17.useEffect(() => { 4007 if (!enabled && open) { 4008 initialRef.current = true; 4009 } 4010 }, [enabled, open]); 4011 const reference = React17.useMemo(() => { 4012 function setPointerTypeRef(event) { 4013 setPointerType(event.pointerType); 4014 } 4015 return { 4016 onPointerDown: setPointerTypeRef, 4017 onPointerEnter: setPointerTypeRef, 4018 onMouseMove: handleReferenceEnterOrMove, 4019 onMouseEnter: handleReferenceEnterOrMove 4020 }; 4021 }, [handleReferenceEnterOrMove]); 4022 return React17.useMemo(() => enabled ? { 4023 reference, 4024 trigger: reference 4025 } : {}, [enabled, reference]); 4026 } 4027 4028 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useDismiss.js 4029 var React18 = __toESM(require_react(), 1); 4030 var bubbleHandlerKeys = { 4031 intentional: "onClick", 4032 sloppy: "onPointerDown" 4033 }; 4034 function alwaysFalse() { 4035 return false; 4036 } 4037 function normalizeProp(normalizable) { 4038 return { 4039 escapeKey: typeof normalizable === "boolean" ? normalizable : normalizable?.escapeKey ?? false, 4040 outsidePress: typeof normalizable === "boolean" ? normalizable : normalizable?.outsidePress ?? true 4041 }; 4042 } 4043 function useDismiss(context, props = {}) { 4044 const { 4045 enabled = true, 4046 escapeKey: escapeKey2 = true, 4047 outsidePress: outsidePressProp = true, 4048 outsidePressEvent = "sloppy", 4049 referencePress = alwaysFalse, 4050 referencePressEvent = "sloppy", 4051 bubbles, 4052 externalTree 4053 } = props; 4054 const store = "rootStore" in context ? context.rootStore : context; 4055 const open = store.useState("open"); 4056 const floatingElement = store.useState("floatingElement"); 4057 const { 4058 dataRef 4059 } = store.context; 4060 const tree = useFloatingTree(externalTree); 4061 const outsidePressFn = useStableCallback(typeof outsidePressProp === "function" ? outsidePressProp : () => false); 4062 const outsidePress2 = typeof outsidePressProp === "function" ? outsidePressFn : outsidePressProp; 4063 const outsidePressEnabled = outsidePress2 !== false; 4064 const getOutsidePressEventProp = useStableCallback(() => outsidePressEvent); 4065 const { 4066 escapeKey: escapeKeyBubbles, 4067 outsidePress: outsidePressBubbles 4068 } = normalizeProp(bubbles); 4069 const pressStartedInsideRef = React18.useRef(false); 4070 const pressStartPreventedRef = React18.useRef(false); 4071 const suppressNextOutsideClickRef = React18.useRef(false); 4072 const isComposingRef = React18.useRef(false); 4073 const currentPointerTypeRef = React18.useRef(""); 4074 const touchStateRef = React18.useRef(null); 4075 const cancelDismissOnEndTimeout = useTimeout(); 4076 const clearInsideReactTreeTimeout = useTimeout(); 4077 const clearInsideReactTree = useStableCallback(() => { 4078 clearInsideReactTreeTimeout.clear(); 4079 dataRef.current.insideReactTree = false; 4080 }); 4081 const hasBlockingChild = useStableCallback((bubbleKey) => { 4082 const nodeId = dataRef.current.floatingContext?.nodeId; 4083 const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : []; 4084 return children.some((child) => child.context?.open && !child.context.dataRef.current[bubbleKey]); 4085 }); 4086 const isEventWithinOwnElements = useStableCallback((event) => { 4087 return isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement")); 4088 }); 4089 const closeOnReferencePress = useStableCallback((event) => { 4090 if (!referencePress()) { 4091 return; 4092 } 4093 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent)); 4094 }); 4095 const closeOnEscapeKeyDown = useStableCallback((event) => { 4096 if (!open || !enabled || !escapeKey2 || event.key !== "Escape") { 4097 return; 4098 } 4099 if (isComposingRef.current) { 4100 return; 4101 } 4102 if (!escapeKeyBubbles && hasBlockingChild("__escapeKeyBubbles")) { 4103 return; 4104 } 4105 const native = isReactEvent(event) ? event.nativeEvent : event; 4106 const eventDetails = createChangeEventDetails(reason_parts_exports.escapeKey, native); 4107 store.setOpen(false, eventDetails); 4108 if (!eventDetails.isCanceled) { 4109 event.preventDefault(); 4110 } 4111 if (!escapeKeyBubbles && !eventDetails.isPropagationAllowed) { 4112 event.stopPropagation(); 4113 } 4114 }); 4115 const markInsideReactTree = useStableCallback(() => { 4116 dataRef.current.insideReactTree = true; 4117 clearInsideReactTreeTimeout.start(0, clearInsideReactTree); 4118 }); 4119 const markPressStartedInsideReactTree = useStableCallback((event) => { 4120 if (!open || !enabled || event.button !== 0) { 4121 return; 4122 } 4123 const target = getTarget(event.nativeEvent); 4124 if (!contains(store.select("floatingElement"), target)) { 4125 return; 4126 } 4127 if (!pressStartedInsideRef.current) { 4128 pressStartedInsideRef.current = true; 4129 pressStartPreventedRef.current = false; 4130 } 4131 }); 4132 const markInsidePressStartPrevented = useStableCallback((event) => { 4133 if (!open || !enabled) { 4134 return; 4135 } 4136 if (!(event.defaultPrevented || event.nativeEvent.defaultPrevented)) { 4137 return; 4138 } 4139 if (pressStartedInsideRef.current) { 4140 pressStartPreventedRef.current = true; 4141 } 4142 }); 4143 React18.useEffect(() => { 4144 if (!open || !enabled) { 4145 return void 0; 4146 } 4147 dataRef.current.__escapeKeyBubbles = escapeKeyBubbles; 4148 dataRef.current.__outsidePressBubbles = outsidePressBubbles; 4149 const compositionTimeout = new Timeout(); 4150 const preventedPressSuppressionTimeout = new Timeout(); 4151 function handleCompositionStart() { 4152 compositionTimeout.clear(); 4153 isComposingRef.current = true; 4154 } 4155 function handleCompositionEnd() { 4156 compositionTimeout.start( 4157 // 0ms or 1ms don't work in Safari. 5ms appears to consistently work. 4158 // Only apply to WebKit for the test to remain 0ms. 4159 isWebKit() ? 5 : 0, 4160 () => { 4161 isComposingRef.current = false; 4162 } 4163 ); 4164 } 4165 function suppressImmediateOutsideClickAfterPreventedStart() { 4166 suppressNextOutsideClickRef.current = true; 4167 preventedPressSuppressionTimeout.start(0, () => { 4168 suppressNextOutsideClickRef.current = false; 4169 }); 4170 } 4171 function resetPressStartState() { 4172 pressStartedInsideRef.current = false; 4173 pressStartPreventedRef.current = false; 4174 } 4175 function getOutsidePressEvent() { 4176 const type = currentPointerTypeRef.current; 4177 const computedType = type === "pen" || !type ? "mouse" : type; 4178 const outsidePressEventValue = getOutsidePressEventProp(); 4179 const resolved = typeof outsidePressEventValue === "function" ? outsidePressEventValue() : outsidePressEventValue; 4180 if (typeof resolved === "string") { 4181 return resolved; 4182 } 4183 return resolved[computedType]; 4184 } 4185 function shouldIgnoreEvent(event) { 4186 const computedOutsidePressEvent = getOutsidePressEvent(); 4187 return computedOutsidePressEvent === "intentional" && event.type !== "click" || computedOutsidePressEvent === "sloppy" && event.type === "click"; 4188 } 4189 function isEventWithinFloatingTree(event) { 4190 const nodeId = dataRef.current.floatingContext?.nodeId; 4191 const targetIsInsideChildren = tree && getNodeChildren(tree.nodesRef.current, nodeId).some((node) => isEventTargetWithin(event, node.context?.elements.floating)); 4192 return isEventWithinOwnElements(event) || targetIsInsideChildren; 4193 } 4194 function closeOnPressOutside(event) { 4195 if (shouldIgnoreEvent(event)) { 4196 if (event.type !== "click" && !isEventWithinOwnElements(event)) { 4197 preventedPressSuppressionTimeout.clear(); 4198 suppressNextOutsideClickRef.current = false; 4199 } 4200 clearInsideReactTree(); 4201 return; 4202 } 4203 if (dataRef.current.insideReactTree) { 4204 clearInsideReactTree(); 4205 return; 4206 } 4207 const target = getTarget(event); 4208 const inertSelector = `[$createAttribute("inert")}]`; 4209 const targetRoot = isElement(target) ? target.getRootNode() : null; 4210 const markers = Array.from((isShadowRoot(targetRoot) ? targetRoot : ownerDocument(store.select("floatingElement"))).querySelectorAll(inertSelector)); 4211 const triggers = store.context.triggerElements; 4212 if (target && (triggers.hasElement(target) || triggers.hasMatchingElement((trigger) => contains(trigger, target)))) { 4213 return; 4214 } 4215 let targetRootAncestor = isElement(target) ? target : null; 4216 while (targetRootAncestor && !isLastTraversableNode(targetRootAncestor)) { 4217 const nextParent = getParentNode(targetRootAncestor); 4218 if (isLastTraversableNode(nextParent) || !isElement(nextParent)) { 4219 break; 4220 } 4221 targetRootAncestor = nextParent; 4222 } 4223 if (markers.length && isElement(target) && !isRootElement(target) && // Clicked on a direct ancestor (e.g. FloatingOverlay). 4224 !contains(target, store.select("floatingElement")) && // If the target root element contains none of the markers, then the 4225 // element was injected after the floating element rendered. 4226 markers.every((marker) => !contains(targetRootAncestor, marker))) { 4227 return; 4228 } 4229 if (isHTMLElement(target) && !("touches" in event)) { 4230 const lastTraversableNode = isLastTraversableNode(target); 4231 const style = getComputedStyle2(target); 4232 const scrollRe = /auto|scroll/; 4233 const isScrollableX = lastTraversableNode || scrollRe.test(style.overflowX); 4234 const isScrollableY = lastTraversableNode || scrollRe.test(style.overflowY); 4235 const canScrollX = isScrollableX && target.clientWidth > 0 && target.scrollWidth > target.clientWidth; 4236 const canScrollY = isScrollableY && target.clientHeight > 0 && target.scrollHeight > target.clientHeight; 4237 const isRTL7 = style.direction === "rtl"; 4238 const pressedVerticalScrollbar = canScrollY && (isRTL7 ? event.offsetX <= target.offsetWidth - target.clientWidth : event.offsetX > target.clientWidth); 4239 const pressedHorizontalScrollbar = canScrollX && event.offsetY > target.clientHeight; 4240 if (pressedVerticalScrollbar || pressedHorizontalScrollbar) { 4241 return; 4242 } 4243 } 4244 if (isEventWithinFloatingTree(event)) { 4245 return; 4246 } 4247 if (getOutsidePressEvent() === "intentional" && suppressNextOutsideClickRef.current) { 4248 preventedPressSuppressionTimeout.clear(); 4249 suppressNextOutsideClickRef.current = false; 4250 return; 4251 } 4252 if (typeof outsidePress2 === "function" && !outsidePress2(event)) { 4253 return; 4254 } 4255 if (hasBlockingChild("__outsidePressBubbles")) { 4256 return; 4257 } 4258 store.setOpen(false, createChangeEventDetails(reason_parts_exports.outsidePress, event)); 4259 clearInsideReactTree(); 4260 } 4261 function handlePointerDown(event) { 4262 if (getOutsidePressEvent() !== "sloppy" || event.pointerType === "touch" || !store.select("open") || !enabled || isEventWithinOwnElements(event)) { 4263 return; 4264 } 4265 closeOnPressOutside(event); 4266 } 4267 function handleTouchStart(event) { 4268 if (getOutsidePressEvent() !== "sloppy" || !store.select("open") || !enabled || isEventWithinOwnElements(event)) { 4269 return; 4270 } 4271 const touch = event.touches[0]; 4272 if (touch) { 4273 touchStateRef.current = { 4274 startTime: Date.now(), 4275 startX: touch.clientX, 4276 startY: touch.clientY, 4277 dismissOnTouchEnd: false, 4278 dismissOnMouseDown: true 4279 }; 4280 cancelDismissOnEndTimeout.start(1e3, () => { 4281 if (touchStateRef.current) { 4282 touchStateRef.current.dismissOnTouchEnd = false; 4283 touchStateRef.current.dismissOnMouseDown = false; 4284 } 4285 }); 4286 } 4287 } 4288 function addTargetEventListenerOnce(event, listener) { 4289 const target = getTarget(event); 4290 if (!target) { 4291 return; 4292 } 4293 const unsubscribe2 = addEventListener(target, event.type, () => { 4294 listener(event); 4295 unsubscribe2(); 4296 }); 4297 } 4298 function handleTouchStartCapture(event) { 4299 currentPointerTypeRef.current = "touch"; 4300 addTargetEventListenerOnce(event, handleTouchStart); 4301 } 4302 function closeOnPressOutsideCapture(event) { 4303 cancelDismissOnEndTimeout.clear(); 4304 if (event.type === "pointerdown") { 4305 currentPointerTypeRef.current = event.pointerType; 4306 } 4307 if (event.type === "mousedown" && touchStateRef.current && !touchStateRef.current.dismissOnMouseDown) { 4308 return; 4309 } 4310 addTargetEventListenerOnce(event, (targetEvent) => { 4311 if (targetEvent.type === "pointerdown") { 4312 handlePointerDown(targetEvent); 4313 } else { 4314 closeOnPressOutside(targetEvent); 4315 } 4316 }); 4317 } 4318 function handlePressEndCapture(event) { 4319 if (!pressStartedInsideRef.current) { 4320 return; 4321 } 4322 const pressStartedInsideDefaultPrevented = pressStartPreventedRef.current; 4323 resetPressStartState(); 4324 if (getOutsidePressEvent() !== "intentional") { 4325 return; 4326 } 4327 if (event.type === "pointercancel") { 4328 if (pressStartedInsideDefaultPrevented) { 4329 suppressImmediateOutsideClickAfterPreventedStart(); 4330 } 4331 return; 4332 } 4333 if (isEventWithinFloatingTree(event)) { 4334 return; 4335 } 4336 if (pressStartedInsideDefaultPrevented) { 4337 suppressImmediateOutsideClickAfterPreventedStart(); 4338 return; 4339 } 4340 if (typeof outsidePress2 === "function" && !outsidePress2(event)) { 4341 return; 4342 } 4343 preventedPressSuppressionTimeout.clear(); 4344 suppressNextOutsideClickRef.current = true; 4345 clearInsideReactTree(); 4346 } 4347 function handleTouchMove(event) { 4348 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) { 4349 return; 4350 } 4351 const touch = event.touches[0]; 4352 if (!touch) { 4353 return; 4354 } 4355 const deltaX = Math.abs(touch.clientX - touchStateRef.current.startX); 4356 const deltaY = Math.abs(touch.clientY - touchStateRef.current.startY); 4357 const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY); 4358 if (distance > 5) { 4359 touchStateRef.current.dismissOnTouchEnd = true; 4360 } 4361 if (distance > 10) { 4362 closeOnPressOutside(event); 4363 cancelDismissOnEndTimeout.clear(); 4364 touchStateRef.current = null; 4365 } 4366 } 4367 function handleTouchMoveCapture(event) { 4368 addTargetEventListenerOnce(event, handleTouchMove); 4369 } 4370 function handleTouchEnd(event) { 4371 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) { 4372 return; 4373 } 4374 if (touchStateRef.current.dismissOnTouchEnd) { 4375 closeOnPressOutside(event); 4376 } 4377 cancelDismissOnEndTimeout.clear(); 4378 touchStateRef.current = null; 4379 } 4380 function handleTouchEndCapture(event) { 4381 addTargetEventListenerOnce(event, handleTouchEnd); 4382 } 4383 const doc = ownerDocument(floatingElement); 4384 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))); 4385 return () => { 4386 unsubscribe(); 4387 compositionTimeout.clear(); 4388 preventedPressSuppressionTimeout.clear(); 4389 resetPressStartState(); 4390 suppressNextOutsideClickRef.current = false; 4391 }; 4392 }, [dataRef, floatingElement, escapeKey2, outsidePressEnabled, outsidePress2, open, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, clearInsideReactTree, getOutsidePressEventProp, hasBlockingChild, isEventWithinOwnElements, tree, store, cancelDismissOnEndTimeout]); 4393 React18.useEffect(clearInsideReactTree, [outsidePress2, clearInsideReactTree]); 4394 const reference = React18.useMemo(() => ({ 4395 onKeyDown: closeOnEscapeKeyDown, 4396 [bubbleHandlerKeys[referencePressEvent]]: closeOnReferencePress, 4397 ...referencePressEvent !== "intentional" && { 4398 onClick: closeOnReferencePress 4399 } 4400 }), [closeOnEscapeKeyDown, closeOnReferencePress, referencePressEvent]); 4401 const floating = React18.useMemo(() => ({ 4402 onKeyDown: closeOnEscapeKeyDown, 4403 // `onMouseDown` may be blocked if `event.preventDefault()` is called in 4404 // `onPointerDown`, such as with <NumberField.ScrubArea>. 4405 // See https://github.com/mui/base-ui/pull/3379 4406 onPointerDown: markInsidePressStartPrevented, 4407 onMouseDown: markInsidePressStartPrevented, 4408 onClickCapture: markInsideReactTree, 4409 onMouseDownCapture(event) { 4410 markInsideReactTree(); 4411 markPressStartedInsideReactTree(event); 4412 }, 4413 onPointerDownCapture(event) { 4414 markInsideReactTree(); 4415 markPressStartedInsideReactTree(event); 4416 }, 4417 onMouseUpCapture: markInsideReactTree, 4418 onTouchEndCapture: markInsideReactTree, 4419 onTouchMoveCapture: markInsideReactTree 4420 }), [closeOnEscapeKeyDown, markInsideReactTree, markPressStartedInsideReactTree, markInsidePressStartPrevented]); 4421 return React18.useMemo(() => enabled ? { 4422 reference, 4423 floating, 4424 trigger: reference 4425 } : {}, [enabled, reference, floating]); 4426 } 4427 4428 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloating.js 4429 var React25 = __toESM(require_react(), 1); 4430 4431 // node_modules/@floating-ui/core/dist/floating-ui.core.mjs 4432 function computeCoordsFromPlacement(_ref, placement, rtl) { 4433 let { 4434 reference, 4435 floating 4436 } = _ref; 4437 const sideAxis = getSideAxis(placement); 4438 const alignmentAxis = getAlignmentAxis(placement); 4439 const alignLength = getAxisLength(alignmentAxis); 4440 const side = getSide(placement); 4441 const isVertical = sideAxis === "y"; 4442 const commonX = reference.x + reference.width / 2 - floating.width / 2; 4443 const commonY = reference.y + reference.height / 2 - floating.height / 2; 4444 const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2; 4445 let coords; 4446 switch (side) { 4447 case "top": 4448 coords = { 4449 x: commonX, 4450 y: reference.y - floating.height 4451 }; 4452 break; 4453 case "bottom": 4454 coords = { 4455 x: commonX, 4456 y: reference.y + reference.height 4457 }; 4458 break; 4459 case "right": 4460 coords = { 4461 x: reference.x + reference.width, 4462 y: commonY 4463 }; 4464 break; 4465 case "left": 4466 coords = { 4467 x: reference.x - floating.width, 4468 y: commonY 4469 }; 4470 break; 4471 default: 4472 coords = { 4473 x: reference.x, 4474 y: reference.y 4475 }; 4476 } 4477 switch (getAlignment(placement)) { 4478 case "start": 4479 coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1); 4480 break; 4481 case "end": 4482 coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1); 4483 break; 4484 } 4485 return coords; 4486 } 4487 async function detectOverflow(state, options) { 4488 var _await$platform$isEle; 4489 if (options === void 0) { 4490 options = {}; 4491 } 4492 const { 4493 x: x2, 4494 y: y2, 4495 platform: platform3, 4496 rects, 4497 elements, 4498 strategy 4499 } = state; 4500 const { 4501 boundary = "clippingAncestors", 4502 rootBoundary = "viewport", 4503 elementContext = "floating", 4504 altBoundary = false, 4505 padding = 0 4506 } = evaluate(options, state); 4507 const paddingObject = getPaddingObject(padding); 4508 const altContext = elementContext === "floating" ? "reference" : "floating"; 4509 const element = elements[altBoundary ? altContext : elementContext]; 4510 const clippingClientRect = rectToClientRect(await platform3.getClippingRect({ 4511 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)), 4512 boundary, 4513 rootBoundary, 4514 strategy 4515 })); 4516 const rect = elementContext === "floating" ? { 4517 x: x2, 4518 y: y2, 4519 width: rects.floating.width, 4520 height: rects.floating.height 4521 } : rects.reference; 4522 const offsetParent = await (platform3.getOffsetParent == null ? void 0 : platform3.getOffsetParent(elements.floating)); 4523 const offsetScale = await (platform3.isElement == null ? void 0 : platform3.isElement(offsetParent)) ? await (platform3.getScale == null ? void 0 : platform3.getScale(offsetParent)) || { 4524 x: 1, 4525 y: 1 4526 } : { 4527 x: 1, 4528 y: 1 4529 }; 4530 const elementClientRect = rectToClientRect(platform3.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform3.convertOffsetParentRelativeRectToViewportRelativeRect({ 4531 elements, 4532 rect, 4533 offsetParent, 4534 strategy 4535 }) : rect); 4536 return { 4537 top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y, 4538 bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y, 4539 left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x, 4540 right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x 4541 }; 4542 } 4543 var MAX_RESET_COUNT = 50; 4544 var computePosition = async (reference, floating, config) => { 4545 const { 4546 placement = "bottom", 4547 strategy = "absolute", 4548 middleware = [], 4549 platform: platform3 4550 } = config; 4551 const platformWithDetectOverflow = platform3.detectOverflow ? platform3 : { 4552 ...platform3, 4553 detectOverflow 4554 }; 4555 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(floating)); 4556 let rects = await platform3.getElementRects({ 4557 reference, 4558 floating, 4559 strategy 4560 }); 4561 let { 4562 x: x2, 4563 y: y2 4564 } = computeCoordsFromPlacement(rects, placement, rtl); 4565 let statefulPlacement = placement; 4566 let resetCount = 0; 4567 const middlewareData = {}; 4568 for (let i2 = 0; i2 < middleware.length; i2++) { 4569 const currentMiddleware = middleware[i2]; 4570 if (!currentMiddleware) { 4571 continue; 4572 } 4573 const { 4574 name, 4575 fn 4576 } = currentMiddleware; 4577 const { 4578 x: nextX, 4579 y: nextY, 4580 data, 4581 reset 4582 } = await fn({ 4583 x: x2, 4584 y: y2, 4585 initialPlacement: placement, 4586 placement: statefulPlacement, 4587 strategy, 4588 middlewareData, 4589 rects, 4590 platform: platformWithDetectOverflow, 4591 elements: { 4592 reference, 4593 floating 4594 } 4595 }); 4596 x2 = nextX != null ? nextX : x2; 4597 y2 = nextY != null ? nextY : y2; 4598 middlewareData[name] = { 4599 ...middlewareData[name], 4600 ...data 4601 }; 4602 if (reset && resetCount < MAX_RESET_COUNT) { 4603 resetCount++; 4604 if (typeof reset === "object") { 4605 if (reset.placement) { 4606 statefulPlacement = reset.placement; 4607 } 4608 if (reset.rects) { 4609 rects = reset.rects === true ? await platform3.getElementRects({ 4610 reference, 4611 floating, 4612 strategy 4613 }) : reset.rects; 4614 } 4615 ({ 4616 x: x2, 4617 y: y2 4618 } = computeCoordsFromPlacement(rects, statefulPlacement, rtl)); 4619 } 4620 i2 = -1; 4621 } 4622 } 4623 return { 4624 x: x2, 4625 y: y2, 4626 placement: statefulPlacement, 4627 strategy, 4628 middlewareData 4629 }; 4630 }; 4631 var flip = function(options) { 4632 if (options === void 0) { 4633 options = {}; 4634 } 4635 return { 4636 name: "flip", 4637 options, 4638 async fn(state) { 4639 var _middlewareData$arrow, _middlewareData$flip; 4640 const { 4641 placement, 4642 middlewareData, 4643 rects, 4644 initialPlacement, 4645 platform: platform3, 4646 elements 4647 } = state; 4648 const { 4649 mainAxis: checkMainAxis = true, 4650 crossAxis: checkCrossAxis = true, 4651 fallbackPlacements: specifiedFallbackPlacements, 4652 fallbackStrategy = "bestFit", 4653 fallbackAxisSideDirection = "none", 4654 flipAlignment = true, 4655 ...detectOverflowOptions 4656 } = evaluate(options, state); 4657 if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) { 4658 return {}; 4659 } 4660 const side = getSide(placement); 4661 const initialSideAxis = getSideAxis(initialPlacement); 4662 const isBasePlacement = getSide(initialPlacement) === initialPlacement; 4663 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating)); 4664 const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement)); 4665 const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none"; 4666 if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) { 4667 fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl)); 4668 } 4669 const placements2 = [initialPlacement, ...fallbackPlacements]; 4670 const overflow = await platform3.detectOverflow(state, detectOverflowOptions); 4671 const overflows = []; 4672 let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || []; 4673 if (checkMainAxis) { 4674 overflows.push(overflow[side]); 4675 } 4676 if (checkCrossAxis) { 4677 const sides2 = getAlignmentSides(placement, rects, rtl); 4678 overflows.push(overflow[sides2[0]], overflow[sides2[1]]); 4679 } 4680 overflowsData = [...overflowsData, { 4681 placement, 4682 overflows 4683 }]; 4684 if (!overflows.every((side2) => side2 <= 0)) { 4685 var _middlewareData$flip2, _overflowsData$filter; 4686 const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1; 4687 const nextPlacement = placements2[nextIndex]; 4688 if (nextPlacement) { 4689 const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false; 4690 if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis 4691 // overflows the main axis. 4692 overflowsData.every((d2) => getSideAxis(d2.placement) === initialSideAxis ? d2.overflows[0] > 0 : true)) { 4693 return { 4694 data: { 4695 index: nextIndex, 4696 overflows: overflowsData 4697 }, 4698 reset: { 4699 placement: nextPlacement 4700 } 4701 }; 4702 } 4703 } 4704 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; 4705 if (!resetPlacement) { 4706 switch (fallbackStrategy) { 4707 case "bestFit": { 4708 var _overflowsData$filter2; 4709 const placement2 = (_overflowsData$filter2 = overflowsData.filter((d2) => { 4710 if (hasFallbackAxisSideDirection) { 4711 const currentSideAxis = getSideAxis(d2.placement); 4712 return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal 4713 // reading directions favoring greater width. 4714 currentSideAxis === "y"; 4715 } 4716 return true; 4717 }).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]; 4718 if (placement2) { 4719 resetPlacement = placement2; 4720 } 4721 break; 4722 } 4723 case "initialPlacement": 4724 resetPlacement = initialPlacement; 4725 break; 4726 } 4727 } 4728 if (placement !== resetPlacement) { 4729 return { 4730 reset: { 4731 placement: resetPlacement 4732 } 4733 }; 4734 } 4735 } 4736 return {}; 4737 } 4738 }; 4739 }; 4740 function getSideOffsets(overflow, rect) { 4741 return { 4742 top: overflow.top - rect.height, 4743 right: overflow.right - rect.width, 4744 bottom: overflow.bottom - rect.height, 4745 left: overflow.left - rect.width 4746 }; 4747 } 4748 function isAnySideFullyClipped(overflow) { 4749 return sides.some((side) => overflow[side] >= 0); 4750 } 4751 var hide = function(options) { 4752 if (options === void 0) { 4753 options = {}; 4754 } 4755 return { 4756 name: "hide", 4757 options, 4758 async fn(state) { 4759 const { 4760 rects, 4761 platform: platform3 4762 } = state; 4763 const { 4764 strategy = "referenceHidden", 4765 ...detectOverflowOptions 4766 } = evaluate(options, state); 4767 switch (strategy) { 4768 case "referenceHidden": { 4769 const overflow = await platform3.detectOverflow(state, { 4770 ...detectOverflowOptions, 4771 elementContext: "reference" 4772 }); 4773 const offsets = getSideOffsets(overflow, rects.reference); 4774 return { 4775 data: { 4776 referenceHiddenOffsets: offsets, 4777 referenceHidden: isAnySideFullyClipped(offsets) 4778 } 4779 }; 4780 } 4781 case "escaped": { 4782 const overflow = await platform3.detectOverflow(state, { 4783 ...detectOverflowOptions, 4784 altBoundary: true 4785 }); 4786 const offsets = getSideOffsets(overflow, rects.floating); 4787 return { 4788 data: { 4789 escapedOffsets: offsets, 4790 escaped: isAnySideFullyClipped(offsets) 4791 } 4792 }; 4793 } 4794 default: { 4795 return {}; 4796 } 4797 } 4798 } 4799 }; 4800 }; 4801 var originSides = /* @__PURE__ */ new Set(["left", "top"]); 4802 async function convertValueToCoords(state, options) { 4803 const { 4804 placement, 4805 platform: platform3, 4806 elements 4807 } = state; 4808 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating)); 4809 const side = getSide(placement); 4810 const alignment = getAlignment(placement); 4811 const isVertical = getSideAxis(placement) === "y"; 4812 const mainAxisMulti = originSides.has(side) ? -1 : 1; 4813 const crossAxisMulti = rtl && isVertical ? -1 : 1; 4814 const rawValue = evaluate(options, state); 4815 let { 4816 mainAxis, 4817 crossAxis, 4818 alignmentAxis 4819 } = typeof rawValue === "number" ? { 4820 mainAxis: rawValue, 4821 crossAxis: 0, 4822 alignmentAxis: null 4823 } : { 4824 mainAxis: rawValue.mainAxis || 0, 4825 crossAxis: rawValue.crossAxis || 0, 4826 alignmentAxis: rawValue.alignmentAxis 4827 }; 4828 if (alignment && typeof alignmentAxis === "number") { 4829 crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis; 4830 } 4831 return isVertical ? { 4832 x: crossAxis * crossAxisMulti, 4833 y: mainAxis * mainAxisMulti 4834 } : { 4835 x: mainAxis * mainAxisMulti, 4836 y: crossAxis * crossAxisMulti 4837 }; 4838 } 4839 var offset = function(options) { 4840 if (options === void 0) { 4841 options = 0; 4842 } 4843 return { 4844 name: "offset", 4845 options, 4846 async fn(state) { 4847 var _middlewareData$offse, _middlewareData$arrow; 4848 const { 4849 x: x2, 4850 y: y2, 4851 placement, 4852 middlewareData 4853 } = state; 4854 const diffCoords = await convertValueToCoords(state, options); 4855 if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) { 4856 return {}; 4857 } 4858 return { 4859 x: x2 + diffCoords.x, 4860 y: y2 + diffCoords.y, 4861 data: { 4862 ...diffCoords, 4863 placement 4864 } 4865 }; 4866 } 4867 }; 4868 }; 4869 var shift = function(options) { 4870 if (options === void 0) { 4871 options = {}; 4872 } 4873 return { 4874 name: "shift", 4875 options, 4876 async fn(state) { 4877 const { 4878 x: x2, 4879 y: y2, 4880 placement, 4881 platform: platform3 4882 } = state; 4883 const { 4884 mainAxis: checkMainAxis = true, 4885 crossAxis: checkCrossAxis = false, 4886 limiter = { 4887 fn: (_ref) => { 4888 let { 4889 x: x3, 4890 y: y3 4891 } = _ref; 4892 return { 4893 x: x3, 4894 y: y3 4895 }; 4896 } 4897 }, 4898 ...detectOverflowOptions 4899 } = evaluate(options, state); 4900 const coords = { 4901 x: x2, 4902 y: y2 4903 }; 4904 const overflow = await platform3.detectOverflow(state, detectOverflowOptions); 4905 const crossAxis = getSideAxis(getSide(placement)); 4906 const mainAxis = getOppositeAxis(crossAxis); 4907 let mainAxisCoord = coords[mainAxis]; 4908 let crossAxisCoord = coords[crossAxis]; 4909 if (checkMainAxis) { 4910 const minSide = mainAxis === "y" ? "top" : "left"; 4911 const maxSide = mainAxis === "y" ? "bottom" : "right"; 4912 const min2 = mainAxisCoord + overflow[minSide]; 4913 const max2 = mainAxisCoord - overflow[maxSide]; 4914 mainAxisCoord = clamp(min2, mainAxisCoord, max2); 4915 } 4916 if (checkCrossAxis) { 4917 const minSide = crossAxis === "y" ? "top" : "left"; 4918 const maxSide = crossAxis === "y" ? "bottom" : "right"; 4919 const min2 = crossAxisCoord + overflow[minSide]; 4920 const max2 = crossAxisCoord - overflow[maxSide]; 4921 crossAxisCoord = clamp(min2, crossAxisCoord, max2); 4922 } 4923 const limitedCoords = limiter.fn({ 4924 ...state, 4925 [mainAxis]: mainAxisCoord, 4926 [crossAxis]: crossAxisCoord 4927 }); 4928 return { 4929 ...limitedCoords, 4930 data: { 4931 x: limitedCoords.x - x2, 4932 y: limitedCoords.y - y2, 4933 enabled: { 4934 [mainAxis]: checkMainAxis, 4935 [crossAxis]: checkCrossAxis 4936 } 4937 } 4938 }; 4939 } 4940 }; 4941 }; 4942 var limitShift = function(options) { 4943 if (options === void 0) { 4944 options = {}; 4945 } 4946 return { 4947 options, 4948 fn(state) { 4949 const { 4950 x: x2, 4951 y: y2, 4952 placement, 4953 rects, 4954 middlewareData 4955 } = state; 4956 const { 4957 offset: offset4 = 0, 4958 mainAxis: checkMainAxis = true, 4959 crossAxis: checkCrossAxis = true 4960 } = evaluate(options, state); 4961 const coords = { 4962 x: x2, 4963 y: y2 4964 }; 4965 const crossAxis = getSideAxis(placement); 4966 const mainAxis = getOppositeAxis(crossAxis); 4967 let mainAxisCoord = coords[mainAxis]; 4968 let crossAxisCoord = coords[crossAxis]; 4969 const rawOffset = evaluate(offset4, state); 4970 const computedOffset = typeof rawOffset === "number" ? { 4971 mainAxis: rawOffset, 4972 crossAxis: 0 4973 } : { 4974 mainAxis: 0, 4975 crossAxis: 0, 4976 ...rawOffset 4977 }; 4978 if (checkMainAxis) { 4979 const len = mainAxis === "y" ? "height" : "width"; 4980 const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis; 4981 const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis; 4982 if (mainAxisCoord < limitMin) { 4983 mainAxisCoord = limitMin; 4984 } else if (mainAxisCoord > limitMax) { 4985 mainAxisCoord = limitMax; 4986 } 4987 } 4988 if (checkCrossAxis) { 4989 var _middlewareData$offse, _middlewareData$offse2; 4990 const len = mainAxis === "y" ? "width" : "height"; 4991 const isOriginSide = originSides.has(getSide(placement)); 4992 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); 4993 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); 4994 if (crossAxisCoord < limitMin) { 4995 crossAxisCoord = limitMin; 4996 } else if (crossAxisCoord > limitMax) { 4997 crossAxisCoord = limitMax; 4998 } 4999 } 5000 return { 5001 [mainAxis]: mainAxisCoord, 5002 [crossAxis]: crossAxisCoord 5003 }; 5004 } 5005 }; 5006 }; 5007 var size = function(options) { 5008 if (options === void 0) { 5009 options = {}; 5010 } 5011 return { 5012 name: "size", 5013 options, 5014 async fn(state) { 5015 var _state$middlewareData, _state$middlewareData2; 5016 const { 5017 placement, 5018 rects, 5019 platform: platform3, 5020 elements 5021 } = state; 5022 const { 5023 apply = () => { 5024 }, 5025 ...detectOverflowOptions 5026 } = evaluate(options, state); 5027 const overflow = await platform3.detectOverflow(state, detectOverflowOptions); 5028 const side = getSide(placement); 5029 const alignment = getAlignment(placement); 5030 const isYAxis = getSideAxis(placement) === "y"; 5031 const { 5032 width, 5033 height 5034 } = rects.floating; 5035 let heightSide; 5036 let widthSide; 5037 if (side === "top" || side === "bottom") { 5038 heightSide = side; 5039 widthSide = alignment === (await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right"; 5040 } else { 5041 widthSide = side; 5042 heightSide = alignment === "end" ? "top" : "bottom"; 5043 } 5044 const maximumClippingHeight = height - overflow.top - overflow.bottom; 5045 const maximumClippingWidth = width - overflow.left - overflow.right; 5046 const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight); 5047 const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth); 5048 const noShift = !state.middlewareData.shift; 5049 let availableHeight = overflowAvailableHeight; 5050 let availableWidth = overflowAvailableWidth; 5051 if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) { 5052 availableWidth = maximumClippingWidth; 5053 } 5054 if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) { 5055 availableHeight = maximumClippingHeight; 5056 } 5057 if (noShift && !alignment) { 5058 const xMin = max(overflow.left, 0); 5059 const xMax = max(overflow.right, 0); 5060 const yMin = max(overflow.top, 0); 5061 const yMax = max(overflow.bottom, 0); 5062 if (isYAxis) { 5063 availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right)); 5064 } else { 5065 availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom)); 5066 } 5067 } 5068 await apply({ 5069 ...state, 5070 availableWidth, 5071 availableHeight 5072 }); 5073 const nextDimensions = await platform3.getDimensions(elements.floating); 5074 if (width !== nextDimensions.width || height !== nextDimensions.height) { 5075 return { 5076 reset: { 5077 rects: true 5078 } 5079 }; 5080 } 5081 return {}; 5082 } 5083 }; 5084 }; 5085 5086 // node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs 5087 function getCssDimensions(element) { 5088 const css = getComputedStyle2(element); 5089 let width = parseFloat(css.width) || 0; 5090 let height = parseFloat(css.height) || 0; 5091 const hasOffset = isHTMLElement(element); 5092 const offsetWidth = hasOffset ? element.offsetWidth : width; 5093 const offsetHeight = hasOffset ? element.offsetHeight : height; 5094 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight; 5095 if (shouldFallback) { 5096 width = offsetWidth; 5097 height = offsetHeight; 5098 } 5099 return { 5100 width, 5101 height, 5102 $: shouldFallback 5103 }; 5104 } 5105 function unwrapElement(element) { 5106 return !isElement(element) ? element.contextElement : element; 5107 } 5108 function getScale(element) { 5109 const domElement = unwrapElement(element); 5110 if (!isHTMLElement(domElement)) { 5111 return createCoords(1); 5112 } 5113 const rect = domElement.getBoundingClientRect(); 5114 const { 5115 width, 5116 height, 5117 $: $2 5118 } = getCssDimensions(domElement); 5119 let x2 = ($2 ? round(rect.width) : rect.width) / width; 5120 let y2 = ($2 ? round(rect.height) : rect.height) / height; 5121 if (!x2 || !Number.isFinite(x2)) { 5122 x2 = 1; 5123 } 5124 if (!y2 || !Number.isFinite(y2)) { 5125 y2 = 1; 5126 } 5127 return { 5128 x: x2, 5129 y: y2 5130 }; 5131 } 5132 var noOffsets = /* @__PURE__ */ createCoords(0); 5133 function getVisualOffsets(element) { 5134 const win = getWindow(element); 5135 if (!isWebKit() || !win.visualViewport) { 5136 return noOffsets; 5137 } 5138 return { 5139 x: win.visualViewport.offsetLeft, 5140 y: win.visualViewport.offsetTop 5141 }; 5142 } 5143 function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) { 5144 if (isFixed === void 0) { 5145 isFixed = false; 5146 } 5147 if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) { 5148 return false; 5149 } 5150 return isFixed; 5151 } 5152 function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) { 5153 if (includeScale === void 0) { 5154 includeScale = false; 5155 } 5156 if (isFixedStrategy === void 0) { 5157 isFixedStrategy = false; 5158 } 5159 const clientRect = element.getBoundingClientRect(); 5160 const domElement = unwrapElement(element); 5161 let scale = createCoords(1); 5162 if (includeScale) { 5163 if (offsetParent) { 5164 if (isElement(offsetParent)) { 5165 scale = getScale(offsetParent); 5166 } 5167 } else { 5168 scale = getScale(element); 5169 } 5170 } 5171 const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0); 5172 let x2 = (clientRect.left + visualOffsets.x) / scale.x; 5173 let y2 = (clientRect.top + visualOffsets.y) / scale.y; 5174 let width = clientRect.width / scale.x; 5175 let height = clientRect.height / scale.y; 5176 if (domElement) { 5177 const win = getWindow(domElement); 5178 const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent; 5179 let currentWin = win; 5180 let currentIFrame = getFrameElement(currentWin); 5181 while (currentIFrame && offsetParent && offsetWin !== currentWin) { 5182 const iframeScale = getScale(currentIFrame); 5183 const iframeRect = currentIFrame.getBoundingClientRect(); 5184 const css = getComputedStyle2(currentIFrame); 5185 const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x; 5186 const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y; 5187 x2 *= iframeScale.x; 5188 y2 *= iframeScale.y; 5189 width *= iframeScale.x; 5190 height *= iframeScale.y; 5191 x2 += left; 5192 y2 += top; 5193 currentWin = getWindow(currentIFrame); 5194 currentIFrame = getFrameElement(currentWin); 5195 } 5196 } 5197 return rectToClientRect({ 5198 width, 5199 height, 5200 x: x2, 5201 y: y2 5202 }); 5203 } 5204 function getWindowScrollBarX(element, rect) { 5205 const leftScroll = getNodeScroll(element).scrollLeft; 5206 if (!rect) { 5207 return getBoundingClientRect(getDocumentElement(element)).left + leftScroll; 5208 } 5209 return rect.left + leftScroll; 5210 } 5211 function getHTMLOffset(documentElement, scroll) { 5212 const htmlRect = documentElement.getBoundingClientRect(); 5213 const x2 = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect); 5214 const y2 = htmlRect.top + scroll.scrollTop; 5215 return { 5216 x: x2, 5217 y: y2 5218 }; 5219 } 5220 function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) { 5221 let { 5222 elements, 5223 rect, 5224 offsetParent, 5225 strategy 5226 } = _ref; 5227 const isFixed = strategy === "fixed"; 5228 const documentElement = getDocumentElement(offsetParent); 5229 const topLayer = elements ? isTopLayer(elements.floating) : false; 5230 if (offsetParent === documentElement || topLayer && isFixed) { 5231 return rect; 5232 } 5233 let scroll = { 5234 scrollLeft: 0, 5235 scrollTop: 0 5236 }; 5237 let scale = createCoords(1); 5238 const offsets = createCoords(0); 5239 const isOffsetParentAnElement = isHTMLElement(offsetParent); 5240 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) { 5241 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) { 5242 scroll = getNodeScroll(offsetParent); 5243 } 5244 if (isOffsetParentAnElement) { 5245 const offsetRect = getBoundingClientRect(offsetParent); 5246 scale = getScale(offsetParent); 5247 offsets.x = offsetRect.x + offsetParent.clientLeft; 5248 offsets.y = offsetRect.y + offsetParent.clientTop; 5249 } 5250 } 5251 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0); 5252 return { 5253 width: rect.width * scale.x, 5254 height: rect.height * scale.y, 5255 x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x, 5256 y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y 5257 }; 5258 } 5259 function getClientRects(element) { 5260 return Array.from(element.getClientRects()); 5261 } 5262 function getDocumentRect(element) { 5263 const html = getDocumentElement(element); 5264 const scroll = getNodeScroll(element); 5265 const body = element.ownerDocument.body; 5266 const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth); 5267 const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight); 5268 let x2 = -scroll.scrollLeft + getWindowScrollBarX(element); 5269 const y2 = -scroll.scrollTop; 5270 if (getComputedStyle2(body).direction === "rtl") { 5271 x2 += max(html.clientWidth, body.clientWidth) - width; 5272 } 5273 return { 5274 width, 5275 height, 5276 x: x2, 5277 y: y2 5278 }; 5279 } 5280 var SCROLLBAR_MAX = 25; 5281 function getViewportRect(element, strategy) { 5282 const win = getWindow(element); 5283 const html = getDocumentElement(element); 5284 const visualViewport = win.visualViewport; 5285 let width = html.clientWidth; 5286 let height = html.clientHeight; 5287 let x2 = 0; 5288 let y2 = 0; 5289 if (visualViewport) { 5290 width = visualViewport.width; 5291 height = visualViewport.height; 5292 const visualViewportBased = isWebKit(); 5293 if (!visualViewportBased || visualViewportBased && strategy === "fixed") { 5294 x2 = visualViewport.offsetLeft; 5295 y2 = visualViewport.offsetTop; 5296 } 5297 } 5298 const windowScrollbarX = getWindowScrollBarX(html); 5299 if (windowScrollbarX <= 0) { 5300 const doc = html.ownerDocument; 5301 const body = doc.body; 5302 const bodyStyles = getComputedStyle(body); 5303 const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0; 5304 const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline); 5305 if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) { 5306 width -= clippingStableScrollbarWidth; 5307 } 5308 } else if (windowScrollbarX <= SCROLLBAR_MAX) { 5309 width += windowScrollbarX; 5310 } 5311 return { 5312 width, 5313 height, 5314 x: x2, 5315 y: y2 5316 }; 5317 } 5318 function getInnerBoundingClientRect(element, strategy) { 5319 const clientRect = getBoundingClientRect(element, true, strategy === "fixed"); 5320 const top = clientRect.top + element.clientTop; 5321 const left = clientRect.left + element.clientLeft; 5322 const scale = isHTMLElement(element) ? getScale(element) : createCoords(1); 5323 const width = element.clientWidth * scale.x; 5324 const height = element.clientHeight * scale.y; 5325 const x2 = left * scale.x; 5326 const y2 = top * scale.y; 5327 return { 5328 width, 5329 height, 5330 x: x2, 5331 y: y2 5332 }; 5333 } 5334 function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) { 5335 let rect; 5336 if (clippingAncestor === "viewport") { 5337 rect = getViewportRect(element, strategy); 5338 } else if (clippingAncestor === "document") { 5339 rect = getDocumentRect(getDocumentElement(element)); 5340 } else if (isElement(clippingAncestor)) { 5341 rect = getInnerBoundingClientRect(clippingAncestor, strategy); 5342 } else { 5343 const visualOffsets = getVisualOffsets(element); 5344 rect = { 5345 x: clippingAncestor.x - visualOffsets.x, 5346 y: clippingAncestor.y - visualOffsets.y, 5347 width: clippingAncestor.width, 5348 height: clippingAncestor.height 5349 }; 5350 } 5351 return rectToClientRect(rect); 5352 } 5353 function hasFixedPositionAncestor(element, stopNode) { 5354 const parentNode = getParentNode(element); 5355 if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) { 5356 return false; 5357 } 5358 return getComputedStyle2(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode); 5359 } 5360 function getClippingElementAncestors(element, cache) { 5361 const cachedResult = cache.get(element); 5362 if (cachedResult) { 5363 return cachedResult; 5364 } 5365 let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body"); 5366 let currentContainingBlockComputedStyle = null; 5367 const elementIsFixed = getComputedStyle2(element).position === "fixed"; 5368 let currentNode = elementIsFixed ? getParentNode(element) : element; 5369 while (isElement(currentNode) && !isLastTraversableNode(currentNode)) { 5370 const computedStyle = getComputedStyle2(currentNode); 5371 const currentNodeIsContaining = isContainingBlock(currentNode); 5372 if (!currentNodeIsContaining && computedStyle.position === "fixed") { 5373 currentContainingBlockComputedStyle = null; 5374 } 5375 const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && (currentContainingBlockComputedStyle.position === "absolute" || currentContainingBlockComputedStyle.position === "fixed") || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode); 5376 if (shouldDropCurrentNode) { 5377 result = result.filter((ancestor) => ancestor !== currentNode); 5378 } else { 5379 currentContainingBlockComputedStyle = computedStyle; 5380 } 5381 currentNode = getParentNode(currentNode); 5382 } 5383 cache.set(element, result); 5384 return result; 5385 } 5386 function getClippingRect(_ref) { 5387 let { 5388 element, 5389 boundary, 5390 rootBoundary, 5391 strategy 5392 } = _ref; 5393 const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary); 5394 const clippingAncestors = [...elementClippingAncestors, rootBoundary]; 5395 const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy); 5396 let top = firstRect.top; 5397 let right = firstRect.right; 5398 let bottom = firstRect.bottom; 5399 let left = firstRect.left; 5400 for (let i2 = 1; i2 < clippingAncestors.length; i2++) { 5401 const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i2], strategy); 5402 top = max(rect.top, top); 5403 right = min(rect.right, right); 5404 bottom = min(rect.bottom, bottom); 5405 left = max(rect.left, left); 5406 } 5407 return { 5408 width: right - left, 5409 height: bottom - top, 5410 x: left, 5411 y: top 5412 }; 5413 } 5414 function getDimensions(element) { 5415 const { 5416 width, 5417 height 5418 } = getCssDimensions(element); 5419 return { 5420 width, 5421 height 5422 }; 5423 } 5424 function getRectRelativeToOffsetParent(element, offsetParent, strategy) { 5425 const isOffsetParentAnElement = isHTMLElement(offsetParent); 5426 const documentElement = getDocumentElement(offsetParent); 5427 const isFixed = strategy === "fixed"; 5428 const rect = getBoundingClientRect(element, true, isFixed, offsetParent); 5429 let scroll = { 5430 scrollLeft: 0, 5431 scrollTop: 0 5432 }; 5433 const offsets = createCoords(0); 5434 function setLeftRTLScrollbarOffset() { 5435 offsets.x = getWindowScrollBarX(documentElement); 5436 } 5437 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) { 5438 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) { 5439 scroll = getNodeScroll(offsetParent); 5440 } 5441 if (isOffsetParentAnElement) { 5442 const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent); 5443 offsets.x = offsetRect.x + offsetParent.clientLeft; 5444 offsets.y = offsetRect.y + offsetParent.clientTop; 5445 } else if (documentElement) { 5446 setLeftRTLScrollbarOffset(); 5447 } 5448 } 5449 if (isFixed && !isOffsetParentAnElement && documentElement) { 5450 setLeftRTLScrollbarOffset(); 5451 } 5452 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0); 5453 const x2 = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x; 5454 const y2 = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y; 5455 return { 5456 x: x2, 5457 y: y2, 5458 width: rect.width, 5459 height: rect.height 5460 }; 5461 } 5462 function isStaticPositioned(element) { 5463 return getComputedStyle2(element).position === "static"; 5464 } 5465 function getTrueOffsetParent(element, polyfill) { 5466 if (!isHTMLElement(element) || getComputedStyle2(element).position === "fixed") { 5467 return null; 5468 } 5469 if (polyfill) { 5470 return polyfill(element); 5471 } 5472 let rawOffsetParent = element.offsetParent; 5473 if (getDocumentElement(element) === rawOffsetParent) { 5474 rawOffsetParent = rawOffsetParent.ownerDocument.body; 5475 } 5476 return rawOffsetParent; 5477 } 5478 function getOffsetParent(element, polyfill) { 5479 const win = getWindow(element); 5480 if (isTopLayer(element)) { 5481 return win; 5482 } 5483 if (!isHTMLElement(element)) { 5484 let svgOffsetParent = getParentNode(element); 5485 while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) { 5486 if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) { 5487 return svgOffsetParent; 5488 } 5489 svgOffsetParent = getParentNode(svgOffsetParent); 5490 } 5491 return win; 5492 } 5493 let offsetParent = getTrueOffsetParent(element, polyfill); 5494 while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) { 5495 offsetParent = getTrueOffsetParent(offsetParent, polyfill); 5496 } 5497 if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) { 5498 return win; 5499 } 5500 return offsetParent || getContainingBlock(element) || win; 5501 } 5502 var getElementRects = async function(data) { 5503 const getOffsetParentFn = this.getOffsetParent || getOffsetParent; 5504 const getDimensionsFn = this.getDimensions; 5505 const floatingDimensions = await getDimensionsFn(data.floating); 5506 return { 5507 reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy), 5508 floating: { 5509 x: 0, 5510 y: 0, 5511 width: floatingDimensions.width, 5512 height: floatingDimensions.height 5513 } 5514 }; 5515 }; 5516 function isRTL(element) { 5517 return getComputedStyle2(element).direction === "rtl"; 5518 } 5519 var platform2 = { 5520 convertOffsetParentRelativeRectToViewportRelativeRect, 5521 getDocumentElement, 5522 getClippingRect, 5523 getOffsetParent, 5524 getElementRects, 5525 getClientRects, 5526 getDimensions, 5527 getScale, 5528 isElement, 5529 isRTL 5530 }; 5531 function rectsAreEqual(a2, b2) { 5532 return a2.x === b2.x && a2.y === b2.y && a2.width === b2.width && a2.height === b2.height; 5533 } 5534 function observeMove(element, onMove) { 5535 let io = null; 5536 let timeoutId; 5537 const root = getDocumentElement(element); 5538 function cleanup() { 5539 var _io; 5540 clearTimeout(timeoutId); 5541 (_io = io) == null || _io.disconnect(); 5542 io = null; 5543 } 5544 function refresh(skip, threshold) { 5545 if (skip === void 0) { 5546 skip = false; 5547 } 5548 if (threshold === void 0) { 5549 threshold = 1; 5550 } 5551 cleanup(); 5552 const elementRectForRootMargin = element.getBoundingClientRect(); 5553 const { 5554 left, 5555 top, 5556 width, 5557 height 5558 } = elementRectForRootMargin; 5559 if (!skip) { 5560 onMove(); 5561 } 5562 if (!width || !height) { 5563 return; 5564 } 5565 const insetTop = floor(top); 5566 const insetRight = floor(root.clientWidth - (left + width)); 5567 const insetBottom = floor(root.clientHeight - (top + height)); 5568 const insetLeft = floor(left); 5569 const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px"; 5570 const options = { 5571 rootMargin, 5572 threshold: max(0, min(1, threshold)) || 1 5573 }; 5574 let isFirstUpdate = true; 5575 function handleObserve(entries) { 5576 const ratio = entries[0].intersectionRatio; 5577 if (ratio !== threshold) { 5578 if (!isFirstUpdate) { 5579 return refresh(); 5580 } 5581 if (!ratio) { 5582 timeoutId = setTimeout(() => { 5583 refresh(false, 1e-7); 5584 }, 1e3); 5585 } else { 5586 refresh(false, ratio); 5587 } 5588 } 5589 if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) { 5590 refresh(); 5591 } 5592 isFirstUpdate = false; 5593 } 5594 try { 5595 io = new IntersectionObserver(handleObserve, { 5596 ...options, 5597 // Handle <iframe>s 5598 root: root.ownerDocument 5599 }); 5600 } catch (_e) { 5601 io = new IntersectionObserver(handleObserve, options); 5602 } 5603 io.observe(element); 5604 } 5605 refresh(true); 5606 return cleanup; 5607 } 5608 function autoUpdate(reference, floating, update2, options) { 5609 if (options === void 0) { 5610 options = {}; 5611 } 5612 const { 5613 ancestorScroll = true, 5614 ancestorResize = true, 5615 elementResize = typeof ResizeObserver === "function", 5616 layoutShift = typeof IntersectionObserver === "function", 5617 animationFrame = false 5618 } = options; 5619 const referenceEl = unwrapElement(reference); 5620 const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...floating ? getOverflowAncestors(floating) : []] : []; 5621 ancestors.forEach((ancestor) => { 5622 ancestorScroll && ancestor.addEventListener("scroll", update2, { 5623 passive: true 5624 }); 5625 ancestorResize && ancestor.addEventListener("resize", update2); 5626 }); 5627 const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update2) : null; 5628 let reobserveFrame = -1; 5629 let resizeObserver = null; 5630 if (elementResize) { 5631 resizeObserver = new ResizeObserver((_ref) => { 5632 let [firstEntry] = _ref; 5633 if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) { 5634 resizeObserver.unobserve(floating); 5635 cancelAnimationFrame(reobserveFrame); 5636 reobserveFrame = requestAnimationFrame(() => { 5637 var _resizeObserver; 5638 (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating); 5639 }); 5640 } 5641 update2(); 5642 }); 5643 if (referenceEl && !animationFrame) { 5644 resizeObserver.observe(referenceEl); 5645 } 5646 if (floating) { 5647 resizeObserver.observe(floating); 5648 } 5649 } 5650 let frameId; 5651 let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null; 5652 if (animationFrame) { 5653 frameLoop(); 5654 } 5655 function frameLoop() { 5656 const nextRefRect = getBoundingClientRect(reference); 5657 if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) { 5658 update2(); 5659 } 5660 prevRefRect = nextRefRect; 5661 frameId = requestAnimationFrame(frameLoop); 5662 } 5663 update2(); 5664 return () => { 5665 var _resizeObserver2; 5666 ancestors.forEach((ancestor) => { 5667 ancestorScroll && ancestor.removeEventListener("scroll", update2); 5668 ancestorResize && ancestor.removeEventListener("resize", update2); 5669 }); 5670 cleanupIo == null || cleanupIo(); 5671 (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect(); 5672 resizeObserver = null; 5673 if (animationFrame) { 5674 cancelAnimationFrame(frameId); 5675 } 5676 }; 5677 } 5678 var offset2 = offset; 5679 var shift2 = shift; 5680 var flip2 = flip; 5681 var size2 = size; 5682 var hide2 = hide; 5683 var limitShift2 = limitShift; 5684 var computePosition2 = (reference, floating, options) => { 5685 const cache = /* @__PURE__ */ new Map(); 5686 const mergedOptions = { 5687 platform: platform2, 5688 ...options 5689 }; 5690 const platformWithCache = { 5691 ...mergedOptions.platform, 5692 _c: cache 5693 }; 5694 return computePosition(reference, floating, { 5695 ...mergedOptions, 5696 platform: platformWithCache 5697 }); 5698 }; 5699 5700 // node_modules/@base-ui/react/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.mjs 5701 var React19 = __toESM(require_react(), 1); 5702 var import_react2 = __toESM(require_react(), 1); 5703 var ReactDOM3 = __toESM(require_react_dom(), 1); 5704 var isClient = typeof document !== "undefined"; 5705 var noop3 = function noop4() { 5706 }; 5707 var index = isClient ? import_react2.useLayoutEffect : noop3; 5708 function deepEqual(a2, b2) { 5709 if (a2 === b2) { 5710 return true; 5711 } 5712 if (typeof a2 !== typeof b2) { 5713 return false; 5714 } 5715 if (typeof a2 === "function" && a2.toString() === b2.toString()) { 5716 return true; 5717 } 5718 let length; 5719 let i2; 5720 let keys; 5721 if (a2 && b2 && typeof a2 === "object") { 5722 if (Array.isArray(a2)) { 5723 length = a2.length; 5724 if (length !== b2.length) return false; 5725 for (i2 = length; i2-- !== 0; ) { 5726 if (!deepEqual(a2[i2], b2[i2])) { 5727 return false; 5728 } 5729 } 5730 return true; 5731 } 5732 keys = Object.keys(a2); 5733 length = keys.length; 5734 if (length !== Object.keys(b2).length) { 5735 return false; 5736 } 5737 for (i2 = length; i2-- !== 0; ) { 5738 if (!{}.hasOwnProperty.call(b2, keys[i2])) { 5739 return false; 5740 } 5741 } 5742 for (i2 = length; i2-- !== 0; ) { 5743 const key = keys[i2]; 5744 if (key === "_owner" && a2.$$typeof) { 5745 continue; 5746 } 5747 if (!deepEqual(a2[key], b2[key])) { 5748 return false; 5749 } 5750 } 5751 return true; 5752 } 5753 return a2 !== a2 && b2 !== b2; 5754 } 5755 function getDPR(element) { 5756 if (typeof window === "undefined") { 5757 return 1; 5758 } 5759 const win = element.ownerDocument.defaultView || window; 5760 return win.devicePixelRatio || 1; 5761 } 5762 function roundByDPR(element, value) { 5763 const dpr = getDPR(element); 5764 return Math.round(value * dpr) / dpr; 5765 } 5766 function useLatestRef(value) { 5767 const ref = React19.useRef(value); 5768 index(() => { 5769 ref.current = value; 5770 }); 5771 return ref; 5772 } 5773 function useFloating(options) { 5774 if (options === void 0) { 5775 options = {}; 5776 } 5777 const { 5778 placement = "bottom", 5779 strategy = "absolute", 5780 middleware = [], 5781 platform: platform3, 5782 elements: { 5783 reference: externalReference, 5784 floating: externalFloating 5785 } = {}, 5786 transform = true, 5787 whileElementsMounted, 5788 open 5789 } = options; 5790 const [data, setData] = React19.useState({ 5791 x: 0, 5792 y: 0, 5793 strategy, 5794 placement, 5795 middlewareData: {}, 5796 isPositioned: false 5797 }); 5798 const [latestMiddleware, setLatestMiddleware] = React19.useState(middleware); 5799 if (!deepEqual(latestMiddleware, middleware)) { 5800 setLatestMiddleware(middleware); 5801 } 5802 const [_reference, _setReference] = React19.useState(null); 5803 const [_floating, _setFloating] = React19.useState(null); 5804 const setReference = React19.useCallback((node) => { 5805 if (node !== referenceRef.current) { 5806 referenceRef.current = node; 5807 _setReference(node); 5808 } 5809 }, []); 5810 const setFloating = React19.useCallback((node) => { 5811 if (node !== floatingRef.current) { 5812 floatingRef.current = node; 5813 _setFloating(node); 5814 } 5815 }, []); 5816 const referenceEl = externalReference || _reference; 5817 const floatingEl = externalFloating || _floating; 5818 const referenceRef = React19.useRef(null); 5819 const floatingRef = React19.useRef(null); 5820 const dataRef = React19.useRef(data); 5821 const hasWhileElementsMounted = whileElementsMounted != null; 5822 const whileElementsMountedRef = useLatestRef(whileElementsMounted); 5823 const platformRef = useLatestRef(platform3); 5824 const openRef = useLatestRef(open); 5825 const update2 = React19.useCallback(() => { 5826 if (!referenceRef.current || !floatingRef.current) { 5827 return; 5828 } 5829 const config = { 5830 placement, 5831 strategy, 5832 middleware: latestMiddleware 5833 }; 5834 if (platformRef.current) { 5835 config.platform = platformRef.current; 5836 } 5837 computePosition2(referenceRef.current, floatingRef.current, config).then((data2) => { 5838 const fullData = { 5839 ...data2, 5840 // The floating element's position may be recomputed while it's closed 5841 // but still mounted (such as when transitioning out). To ensure 5842 // `isPositioned` will be `false` initially on the next open, avoid 5843 // setting it to `true` when `open === false` (must be specified). 5844 isPositioned: openRef.current !== false 5845 }; 5846 if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) { 5847 dataRef.current = fullData; 5848 ReactDOM3.flushSync(() => { 5849 setData(fullData); 5850 }); 5851 } 5852 }); 5853 }, [latestMiddleware, placement, strategy, platformRef, openRef]); 5854 index(() => { 5855 if (open === false && dataRef.current.isPositioned) { 5856 dataRef.current.isPositioned = false; 5857 setData((data2) => ({ 5858 ...data2, 5859 isPositioned: false 5860 })); 5861 } 5862 }, [open]); 5863 const isMountedRef = React19.useRef(false); 5864 index(() => { 5865 isMountedRef.current = true; 5866 return () => { 5867 isMountedRef.current = false; 5868 }; 5869 }, []); 5870 index(() => { 5871 if (referenceEl) referenceRef.current = referenceEl; 5872 if (floatingEl) floatingRef.current = floatingEl; 5873 if (referenceEl && floatingEl) { 5874 if (whileElementsMountedRef.current) { 5875 return whileElementsMountedRef.current(referenceEl, floatingEl, update2); 5876 } 5877 update2(); 5878 } 5879 }, [referenceEl, floatingEl, update2, whileElementsMountedRef, hasWhileElementsMounted]); 5880 const refs = React19.useMemo(() => ({ 5881 reference: referenceRef, 5882 floating: floatingRef, 5883 setReference, 5884 setFloating 5885 }), [setReference, setFloating]); 5886 const elements = React19.useMemo(() => ({ 5887 reference: referenceEl, 5888 floating: floatingEl 5889 }), [referenceEl, floatingEl]); 5890 const floatingStyles = React19.useMemo(() => { 5891 const initialStyles = { 5892 position: strategy, 5893 left: 0, 5894 top: 0 5895 }; 5896 if (!elements.floating) { 5897 return initialStyles; 5898 } 5899 const x2 = roundByDPR(elements.floating, data.x); 5900 const y2 = roundByDPR(elements.floating, data.y); 5901 if (transform) { 5902 return { 5903 ...initialStyles, 5904 transform: "translate(" + x2 + "px, " + y2 + "px)", 5905 ...getDPR(elements.floating) >= 1.5 && { 5906 willChange: "transform" 5907 } 5908 }; 5909 } 5910 return { 5911 position: strategy, 5912 left: x2, 5913 top: y2 5914 }; 5915 }, [strategy, transform, elements.floating, data.x, data.y]); 5916 return React19.useMemo(() => ({ 5917 ...data, 5918 update: update2, 5919 refs, 5920 elements, 5921 floatingStyles 5922 }), [data, update2, refs, elements, floatingStyles]); 5923 } 5924 var offset3 = (options, deps) => { 5925 const result = offset2(options); 5926 return { 5927 name: result.name, 5928 fn: result.fn, 5929 options: [options, deps] 5930 }; 5931 }; 5932 var shift3 = (options, deps) => { 5933 const result = shift2(options); 5934 return { 5935 name: result.name, 5936 fn: result.fn, 5937 options: [options, deps] 5938 }; 5939 }; 5940 var limitShift3 = (options, deps) => { 5941 const result = limitShift2(options); 5942 return { 5943 fn: result.fn, 5944 options: [options, deps] 5945 }; 5946 }; 5947 var flip3 = (options, deps) => { 5948 const result = flip2(options); 5949 return { 5950 name: result.name, 5951 fn: result.fn, 5952 options: [options, deps] 5953 }; 5954 }; 5955 var size3 = (options, deps) => { 5956 const result = size2(options); 5957 return { 5958 name: result.name, 5959 fn: result.fn, 5960 options: [options, deps] 5961 }; 5962 }; 5963 var hide3 = (options, deps) => { 5964 const result = hide2(options); 5965 return { 5966 name: result.name, 5967 fn: result.fn, 5968 options: [options, deps] 5969 }; 5970 }; 5971 5972 // node_modules/@base-ui/react/esm/utils/popups/popupStoreUtils.js 5973 var React24 = __toESM(require_react(), 1); 5974 5975 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useSyncedFloatingRootContext.js 5976 var React23 = __toESM(require_react(), 1); 5977 5978 // node_modules/@base-ui/utils/esm/store/createSelector.js 5979 var createSelector = (a2, b2, c2, d2, e2, f2, ...other) => { 5980 if (other.length > 0) { 5981 throw new Error(true ? "Unsupported number of selectors" : formatErrorMessage_default(1)); 5982 } 5983 let selector2; 5984 if (a2 && b2 && c2 && d2 && e2 && f2) { 5985 selector2 = (state, a1, a22, a3) => { 5986 const va = a2(state, a1, a22, a3); 5987 const vb = b2(state, a1, a22, a3); 5988 const vc = c2(state, a1, a22, a3); 5989 const vd = d2(state, a1, a22, a3); 5990 const ve = e2(state, a1, a22, a3); 5991 return f2(va, vb, vc, vd, ve, a1, a22, a3); 5992 }; 5993 } else if (a2 && b2 && c2 && d2 && e2) { 5994 selector2 = (state, a1, a22, a3) => { 5995 const va = a2(state, a1, a22, a3); 5996 const vb = b2(state, a1, a22, a3); 5997 const vc = c2(state, a1, a22, a3); 5998 const vd = d2(state, a1, a22, a3); 5999 return e2(va, vb, vc, vd, a1, a22, a3); 6000 }; 6001 } else if (a2 && b2 && c2 && d2) { 6002 selector2 = (state, a1, a22, a3) => { 6003 const va = a2(state, a1, a22, a3); 6004 const vb = b2(state, a1, a22, a3); 6005 const vc = c2(state, a1, a22, a3); 6006 return d2(va, vb, vc, a1, a22, a3); 6007 }; 6008 } else if (a2 && b2 && c2) { 6009 selector2 = (state, a1, a22, a3) => { 6010 const va = a2(state, a1, a22, a3); 6011 const vb = b2(state, a1, a22, a3); 6012 return c2(va, vb, a1, a22, a3); 6013 }; 6014 } else if (a2 && b2) { 6015 selector2 = (state, a1, a22, a3) => { 6016 const va = a2(state, a1, a22, a3); 6017 return b2(va, a1, a22, a3); 6018 }; 6019 } else if (a2) { 6020 selector2 = a2; 6021 } else { 6022 throw ( 6023 /* minify-error-disabled */ 6024 new Error("Missing arguments") 6025 ); 6026 } 6027 return selector2; 6028 }; 6029 6030 // node_modules/@base-ui/utils/esm/store/useStore.js 6031 var React21 = __toESM(require_react(), 1); 6032 var import_shim = __toESM(require_shim(), 1); 6033 var import_with_selector = __toESM(require_with_selector(), 1); 6034 6035 // node_modules/@base-ui/utils/esm/fastHooks.js 6036 var React20 = __toESM(require_react(), 1); 6037 var hooks = []; 6038 var currentInstance = void 0; 6039 function getInstance() { 6040 return currentInstance; 6041 } 6042 function register(hook) { 6043 hooks.push(hook); 6044 } 6045 function fastComponent(fn) { 6046 const FastComponent = (props, forwardedRef) => { 6047 const instance = useRefWithInit(createInstance).current; 6048 let result; 6049 try { 6050 currentInstance = instance; 6051 for (const hook of hooks) { 6052 hook.before(instance); 6053 } 6054 result = fn(props, forwardedRef); 6055 for (const hook of hooks) { 6056 hook.after(instance); 6057 } 6058 instance.didInitialize = true; 6059 } finally { 6060 currentInstance = void 0; 6061 } 6062 return result; 6063 }; 6064 FastComponent.displayName = fn.displayName || fn.name; 6065 return FastComponent; 6066 } 6067 function fastComponentRef(fn) { 6068 return /* @__PURE__ */ React20.forwardRef(fastComponent(fn)); 6069 } 6070 function createInstance() { 6071 return { 6072 didInitialize: false 6073 }; 6074 } 6075 6076 // node_modules/@base-ui/utils/esm/store/useStore.js 6077 var canUseRawUseSyncExternalStore = isReactVersionAtLeast(19); 6078 var useStoreImplementation = canUseRawUseSyncExternalStore ? useStoreFast : useStoreLegacy; 6079 function useStore(store, selector2, a1, a2, a3) { 6080 return useStoreImplementation(store, selector2, a1, a2, a3); 6081 } 6082 function useStoreR19(store, selector2, a1, a2, a3) { 6083 const getSelection = React21.useCallback(() => selector2(store.getSnapshot(), a1, a2, a3), [store, selector2, a1, a2, a3]); 6084 return (0, import_shim.useSyncExternalStore)(store.subscribe, getSelection, getSelection); 6085 } 6086 register({ 6087 before(instance) { 6088 instance.syncIndex = 0; 6089 if (!instance.didInitialize) { 6090 instance.syncTick = 1; 6091 instance.syncHooks = []; 6092 instance.didChangeStore = true; 6093 instance.getSnapshot = () => { 6094 let didChange2 = false; 6095 for (let i2 = 0; i2 < instance.syncHooks.length; i2 += 1) { 6096 const hook = instance.syncHooks[i2]; 6097 const value = hook.selector(hook.store.state, hook.a1, hook.a2, hook.a3); 6098 if (hook.didChange || !Object.is(hook.value, value)) { 6099 didChange2 = true; 6100 hook.value = value; 6101 hook.didChange = false; 6102 } 6103 } 6104 if (didChange2) { 6105 instance.syncTick += 1; 6106 } 6107 return instance.syncTick; 6108 }; 6109 } 6110 }, 6111 after(instance) { 6112 if (instance.syncHooks.length > 0) { 6113 if (instance.didChangeStore) { 6114 instance.didChangeStore = false; 6115 instance.subscribe = (onStoreChange) => { 6116 const stores = /* @__PURE__ */ new Set(); 6117 for (const hook of instance.syncHooks) { 6118 stores.add(hook.store); 6119 } 6120 const unsubscribes = []; 6121 for (const store of stores) { 6122 unsubscribes.push(store.subscribe(onStoreChange)); 6123 } 6124 return () => { 6125 for (const unsubscribe of unsubscribes) { 6126 unsubscribe(); 6127 } 6128 }; 6129 }; 6130 } 6131 (0, import_shim.useSyncExternalStore)(instance.subscribe, instance.getSnapshot, instance.getSnapshot); 6132 } 6133 } 6134 }); 6135 function useStoreFast(store, selector2, a1, a2, a3) { 6136 const instance = getInstance(); 6137 if (!instance) { 6138 return useStoreR19(store, selector2, a1, a2, a3); 6139 } 6140 const index2 = instance.syncIndex; 6141 instance.syncIndex += 1; 6142 let hook; 6143 if (!instance.didInitialize) { 6144 hook = { 6145 store, 6146 selector: selector2, 6147 a1, 6148 a2, 6149 a3, 6150 value: selector2(store.getSnapshot(), a1, a2, a3), 6151 didChange: false 6152 }; 6153 instance.syncHooks.push(hook); 6154 } else { 6155 hook = instance.syncHooks[index2]; 6156 if (hook.store !== store || hook.selector !== selector2 || !Object.is(hook.a1, a1) || !Object.is(hook.a2, a2) || !Object.is(hook.a3, a3)) { 6157 if (hook.store !== store) { 6158 instance.didChangeStore = true; 6159 } 6160 hook.store = store; 6161 hook.selector = selector2; 6162 hook.a1 = a1; 6163 hook.a2 = a2; 6164 hook.a3 = a3; 6165 hook.didChange = true; 6166 } 6167 } 6168 return hook.value; 6169 } 6170 function useStoreLegacy(store, selector2, a1, a2, a3) { 6171 return (0, import_with_selector.useSyncExternalStoreWithSelector)(store.subscribe, store.getSnapshot, store.getSnapshot, (state) => selector2(state, a1, a2, a3)); 6172 } 6173 6174 // node_modules/@base-ui/utils/esm/store/Store.js 6175 var Store = class { 6176 /** 6177 * The current state of the store. 6178 * This property is updated immediately when the state changes as a result of calling {@link setState}, {@link update}, or {@link set}. 6179 * 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). 6180 * The values can be used directly (to avoid subscribing to the store) in effects or event handlers. 6181 * 6182 * Do not modify properties in state directly. Instead, use the provided methods to ensure proper state management and listener notification. 6183 */ 6184 // Internal state to handle recursive `setState()` calls 6185 constructor(state) { 6186 this.state = state; 6187 this.listeners = /* @__PURE__ */ new Set(); 6188 this.updateTick = 0; 6189 } 6190 /** 6191 * Registers a listener that will be called whenever the store's state changes. 6192 * 6193 * @param fn The listener function to be called on state changes. 6194 * @returns A function to unsubscribe the listener. 6195 */ 6196 subscribe = (fn) => { 6197 this.listeners.add(fn); 6198 return () => { 6199 this.listeners.delete(fn); 6200 }; 6201 }; 6202 /** 6203 * Returns the current state of the store. 6204 */ 6205 getSnapshot = () => { 6206 return this.state; 6207 }; 6208 /** 6209 * Updates the entire store's state and notifies all registered listeners. 6210 * 6211 * @param newState The new state to set for the store. 6212 */ 6213 setState(newState) { 6214 if (this.state === newState) { 6215 return; 6216 } 6217 this.state = newState; 6218 this.updateTick += 1; 6219 const currentTick = this.updateTick; 6220 for (const listener of this.listeners) { 6221 if (currentTick !== this.updateTick) { 6222 return; 6223 } 6224 listener(newState); 6225 } 6226 } 6227 /** 6228 * Merges the provided changes into the current state and notifies listeners if there are changes. 6229 * 6230 * @param changes An object containing the changes to apply to the current state. 6231 */ 6232 update(changes) { 6233 for (const key in changes) { 6234 if (!Object.is(this.state[key], changes[key])) { 6235 this.setState({ 6236 ...this.state, 6237 ...changes 6238 }); 6239 return; 6240 } 6241 } 6242 } 6243 /** 6244 * Sets a specific key in the store's state to a new value and notifies listeners if the value has changed. 6245 * 6246 * @param key The key in the store's state to update. 6247 * @param value The new value to set for the specified key. 6248 */ 6249 set(key, value) { 6250 if (!Object.is(this.state[key], value)) { 6251 this.setState({ 6252 ...this.state, 6253 [key]: value 6254 }); 6255 } 6256 } 6257 /** 6258 * Gives the state a new reference and updates all registered listeners. 6259 */ 6260 notifyAll() { 6261 const newState = { 6262 ...this.state 6263 }; 6264 this.setState(newState); 6265 } 6266 use(selector2, a1, a2, a3) { 6267 return useStore(this, selector2, a1, a2, a3); 6268 } 6269 }; 6270 6271 // node_modules/@base-ui/utils/esm/store/ReactStore.js 6272 var React22 = __toESM(require_react(), 1); 6273 var ReactStore = class extends Store { 6274 /** 6275 * Creates a new ReactStore instance. 6276 * 6277 * @param state Initial state of the store. 6278 * @param context Non-reactive context values. 6279 * @param selectors Optional selectors for use with `useState`. 6280 */ 6281 constructor(state, context = {}, selectors3) { 6282 super(state); 6283 this.context = context; 6284 this.selectors = selectors3; 6285 } 6286 /** 6287 * Non-reactive values such as refs, callbacks, etc. 6288 */ 6289 /** 6290 * Synchronizes a single external value into the store. 6291 * 6292 * Note that the while the value in `state` is updated immediately, the value returned 6293 * by `useState` is updated before the next render (similarly to React's `useState`). 6294 */ 6295 useSyncedValue(key, value) { 6296 React22.useDebugValue(key); 6297 const store = this; 6298 useIsoLayoutEffect(() => { 6299 if (store.state[key] !== value) { 6300 store.set(key, value); 6301 } 6302 }, [store, key, value]); 6303 } 6304 /** 6305 * Synchronizes a single external value into the store and 6306 * cleans it up (sets to `undefined`) on unmount. 6307 * 6308 * Note that the while the value in `state` is updated immediately, the value returned 6309 * by `useState` is updated before the next render (similarly to React's `useState`). 6310 */ 6311 useSyncedValueWithCleanup(key, value) { 6312 const store = this; 6313 useIsoLayoutEffect(() => { 6314 if (store.state[key] !== value) { 6315 store.set(key, value); 6316 } 6317 return () => { 6318 store.set(key, void 0); 6319 }; 6320 }, [store, key, value]); 6321 } 6322 /** 6323 * Synchronizes multiple external values into the store. 6324 * 6325 * Note that the while the values in `state` are updated immediately, the values returned 6326 * by `useState` are updated before the next render (similarly to React's `useState`). 6327 */ 6328 useSyncedValues(statePart) { 6329 const store = this; 6330 if (true) { 6331 React22.useDebugValue(statePart, (p2) => Object.keys(p2)); 6332 const keys = React22.useRef(Object.keys(statePart)).current; 6333 const nextKeys = Object.keys(statePart); 6334 if (keys.length !== nextKeys.length || keys.some((key, index2) => key !== nextKeys[index2])) { 6335 console.error("ReactStore.useSyncedValues expects the same prop keys on every render. Keys should be stable."); 6336 } 6337 } 6338 const dependencies = Object.values(statePart); 6339 useIsoLayoutEffect(() => { 6340 store.update(statePart); 6341 }, [store, ...dependencies]); 6342 } 6343 /** 6344 * Registers a controllable prop pair (`controlled`, `defaultValue`) for a specific key. If `controlled` 6345 * is non-undefined, the store's state at `key` is updated to match `controlled`. 6346 */ 6347 useControlledProp(key, controlled) { 6348 React22.useDebugValue(key); 6349 const store = this; 6350 const isControlled = controlled !== void 0; 6351 useIsoLayoutEffect(() => { 6352 if (isControlled && !Object.is(store.state[key], controlled)) { 6353 store.setState({ 6354 ...store.state, 6355 [key]: controlled 6356 }); 6357 } 6358 }, [store, key, controlled, isControlled]); 6359 if (true) { 6360 const cache = this.controlledValues ??= /* @__PURE__ */ new Map(); 6361 if (!cache.has(key)) { 6362 cache.set(key, isControlled); 6363 } 6364 const previouslyControlled = cache.get(key); 6365 if (previouslyControlled !== void 0 && previouslyControlled !== isControlled) { 6366 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).`); 6367 } 6368 } 6369 } 6370 /** Gets the current value from the store using a selector with the provided key. 6371 * 6372 * @param key Key of the selector to use. 6373 */ 6374 select(key, a1, a2, a3) { 6375 const selector2 = this.selectors[key]; 6376 return selector2(this.state, a1, a2, a3); 6377 } 6378 /** 6379 * Returns a value from the store's state using a selector function. 6380 * Used to subscribe to specific parts of the state. 6381 * This methods causes a rerender whenever the selected state changes. 6382 * 6383 * @param key Key of the selector to use. 6384 */ 6385 useState(key, a1, a2, a3) { 6386 React22.useDebugValue(key); 6387 return useStore(this, this.selectors[key], a1, a2, a3); 6388 } 6389 /** 6390 * Wraps a function with `useStableCallback` to ensure it has a stable reference 6391 * and assigns it to the context. 6392 * 6393 * @param key Key of the event callback. Must be a function in the context. 6394 * @param fn Function to assign. 6395 */ 6396 useContextCallback(key, fn) { 6397 React22.useDebugValue(key); 6398 const stableFunction = useStableCallback(fn ?? NOOP); 6399 this.context[key] = stableFunction; 6400 } 6401 /** 6402 * Returns a stable setter function for a specific key in the store's state. 6403 * It's commonly used to pass as a ref callback to React elements. 6404 * 6405 * @param key Key of the state to set. 6406 */ 6407 useStateSetter(key) { 6408 const ref = React22.useRef(void 0); 6409 if (ref.current === void 0) { 6410 ref.current = (value) => { 6411 this.set(key, value); 6412 }; 6413 } 6414 return ref.current; 6415 } 6416 /** 6417 * Observes changes derived from the store's selectors and calls the listener when the selected value changes. 6418 * 6419 * @param key Key of the selector to observe. 6420 * @param listener Listener function called when the selector result changes. 6421 */ 6422 observe(selector2, listener) { 6423 let selectFn; 6424 if (typeof selector2 === "function") { 6425 selectFn = selector2; 6426 } else { 6427 selectFn = this.selectors[selector2]; 6428 } 6429 let prevValue = selectFn(this.state); 6430 listener(prevValue, prevValue, this); 6431 return this.subscribe((nextState) => { 6432 const nextValue = selectFn(nextState); 6433 if (!Object.is(prevValue, nextValue)) { 6434 const oldValue = prevValue; 6435 prevValue = nextValue; 6436 listener(nextValue, oldValue, this); 6437 } 6438 }); 6439 } 6440 }; 6441 6442 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingRootStore.js 6443 var selectors = { 6444 open: createSelector((state) => state.open), 6445 transitionStatus: createSelector((state) => state.transitionStatus), 6446 domReferenceElement: createSelector((state) => state.domReferenceElement), 6447 referenceElement: createSelector((state) => state.positionReference ?? state.referenceElement), 6448 floatingElement: createSelector((state) => state.floatingElement), 6449 floatingId: createSelector((state) => state.floatingId) 6450 }; 6451 var FloatingRootStore = class extends ReactStore { 6452 constructor(options) { 6453 const { 6454 syncOnly, 6455 nested, 6456 onOpenChange, 6457 triggerElements, 6458 ...initialState 6459 } = options; 6460 super({ 6461 ...initialState, 6462 positionReference: initialState.referenceElement, 6463 domReferenceElement: initialState.referenceElement 6464 }, { 6465 onOpenChange, 6466 dataRef: { 6467 current: {} 6468 }, 6469 events: createEventEmitter(), 6470 nested, 6471 triggerElements 6472 }, selectors); 6473 this.syncOnly = syncOnly; 6474 } 6475 /** 6476 * Syncs the event used by hover logic to distinguish hover-open from click-like interaction. 6477 */ 6478 syncOpenEvent = (newOpen, event) => { 6479 if (!newOpen || !this.state.open || // Prevent a pending hover-open from overwriting a click-open event, while allowing 6480 // click events to upgrade a hover-open. 6481 event != null && isClickLikeEvent(event)) { 6482 this.context.dataRef.current.openEvent = newOpen ? event : void 0; 6483 } 6484 }; 6485 /** 6486 * Runs the root-owned side effects for an open state change. 6487 */ 6488 dispatchOpenChange = (newOpen, eventDetails) => { 6489 this.syncOpenEvent(newOpen, eventDetails.event); 6490 const details = { 6491 open: newOpen, 6492 reason: eventDetails.reason, 6493 nativeEvent: eventDetails.event, 6494 nested: this.context.nested, 6495 triggerElement: eventDetails.trigger 6496 }; 6497 this.context.events.emit("openchange", details); 6498 }; 6499 /** 6500 * Emits the `openchange` event through the internal event emitter and calls the `onOpenChange` handler with the provided arguments. 6501 * 6502 * @param newOpen The new open state. 6503 * @param eventDetails Details about the event that triggered the open state change. 6504 */ 6505 setOpen = (newOpen, eventDetails) => { 6506 if (this.syncOnly) { 6507 this.context.onOpenChange?.(newOpen, eventDetails); 6508 return; 6509 } 6510 this.dispatchOpenChange(newOpen, eventDetails); 6511 this.context.onOpenChange?.(newOpen, eventDetails); 6512 }; 6513 }; 6514 6515 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useSyncedFloatingRootContext.js 6516 function useSyncedFloatingRootContext(options) { 6517 const { 6518 popupStore, 6519 treatPopupAsFloatingElement = false, 6520 floatingRootContext: floatingRootContextProp, 6521 floatingId, 6522 nested, 6523 onOpenChange 6524 } = options; 6525 const open = popupStore.useState("open"); 6526 const referenceElement = popupStore.useState("activeTriggerElement"); 6527 const floatingElement = popupStore.useState(treatPopupAsFloatingElement ? "popupElement" : "positionerElement"); 6528 const triggerElements = popupStore.context.triggerElements; 6529 const handleOpenChange = onOpenChange; 6530 const internalStoreRef = React23.useRef(null); 6531 if (floatingRootContextProp === void 0 && internalStoreRef.current === null) { 6532 internalStoreRef.current = new FloatingRootStore({ 6533 open, 6534 transitionStatus: void 0, 6535 referenceElement, 6536 floatingElement, 6537 triggerElements, 6538 onOpenChange: handleOpenChange, 6539 floatingId, 6540 syncOnly: true, 6541 nested 6542 }); 6543 } 6544 const store = floatingRootContextProp ?? internalStoreRef.current; 6545 popupStore.useSyncedValue("floatingId", floatingId); 6546 useIsoLayoutEffect(() => { 6547 const valuesToSync = { 6548 open, 6549 floatingId, 6550 referenceElement, 6551 floatingElement 6552 }; 6553 if (isElement(referenceElement)) { 6554 valuesToSync.domReferenceElement = referenceElement; 6555 } 6556 if (store.state.positionReference === store.state.referenceElement) { 6557 valuesToSync.positionReference = referenceElement; 6558 } 6559 store.update(valuesToSync); 6560 }, [open, floatingId, referenceElement, floatingElement, store]); 6561 store.context.onOpenChange = handleOpenChange; 6562 store.context.nested = nested; 6563 return store; 6564 } 6565 6566 // node_modules/@base-ui/react/esm/utils/popups/popupStoreUtils.js 6567 var FOCUSABLE_POPUP_PROPS = { 6568 tabIndex: -1, 6569 [FOCUSABLE_ATTRIBUTE]: "" 6570 }; 6571 function usePopupStore(externalStore, createStore2, treatPopupAsFloatingElement = false) { 6572 const floatingId = useId(); 6573 const nested = useFloatingParentNodeId() != null; 6574 const internalStoreRef = React24.useRef(null); 6575 if (externalStore === void 0 && internalStoreRef.current === null) { 6576 internalStoreRef.current = createStore2(floatingId, nested); 6577 } 6578 const store = externalStore ?? internalStoreRef.current; 6579 useSyncedFloatingRootContext({ 6580 popupStore: store, 6581 treatPopupAsFloatingElement, 6582 floatingRootContext: store.state.floatingRootContext, 6583 floatingId, 6584 nested, 6585 onOpenChange: store.setOpen 6586 }); 6587 return { 6588 store, 6589 internalStore: internalStoreRef.current 6590 }; 6591 } 6592 function useTriggerRegistration(id, store) { 6593 const registeredElementIdRef = React24.useRef(null); 6594 const registeredElementRef = React24.useRef(null); 6595 return React24.useCallback((element) => { 6596 if (id === void 0) { 6597 return; 6598 } 6599 let shouldSyncTriggerCount = false; 6600 if (registeredElementIdRef.current !== null) { 6601 const registeredId = registeredElementIdRef.current; 6602 const registeredElement = registeredElementRef.current; 6603 const currentElement = store.context.triggerElements.getById(registeredId); 6604 if (registeredElement && currentElement === registeredElement) { 6605 store.context.triggerElements.delete(registeredId); 6606 shouldSyncTriggerCount = true; 6607 } 6608 registeredElementIdRef.current = null; 6609 registeredElementRef.current = null; 6610 } 6611 if (element !== null) { 6612 registeredElementIdRef.current = id; 6613 registeredElementRef.current = element; 6614 store.context.triggerElements.add(id, element); 6615 shouldSyncTriggerCount = true; 6616 } 6617 if (shouldSyncTriggerCount) { 6618 const triggerCount = store.context.triggerElements.size; 6619 if (store.select("open") && store.state.triggerCount !== triggerCount) { 6620 store.set("triggerCount", triggerCount); 6621 } 6622 } 6623 }, [store, id]); 6624 } 6625 function setOpenTriggerState(state, open, trigger) { 6626 const triggerId = trigger?.id ?? null; 6627 if (triggerId || open) { 6628 state.activeTriggerId = triggerId; 6629 state.activeTriggerElement = trigger ?? null; 6630 } 6631 } 6632 function useTriggerDataForwarding(triggerId, triggerElementRef, store, stateUpdates) { 6633 const isMountedByThisTrigger = store.useState("isMountedByTrigger", triggerId); 6634 const baseRegisterTrigger = useTriggerRegistration(triggerId, store); 6635 const registerTrigger = useStableCallback((element) => { 6636 baseRegisterTrigger(element); 6637 if (!element) { 6638 return; 6639 } 6640 const open = store.select("open"); 6641 const activeTriggerId = store.select("activeTriggerId"); 6642 if (activeTriggerId === triggerId) { 6643 store.update({ 6644 activeTriggerElement: element, 6645 ...open ? stateUpdates : null 6646 }); 6647 return; 6648 } 6649 if (activeTriggerId == null && open) { 6650 store.update({ 6651 activeTriggerId: triggerId, 6652 activeTriggerElement: element, 6653 ...stateUpdates 6654 }); 6655 } 6656 }); 6657 useIsoLayoutEffect(() => { 6658 if (isMountedByThisTrigger) { 6659 store.update({ 6660 activeTriggerElement: triggerElementRef.current, 6661 ...stateUpdates 6662 }); 6663 } 6664 }, [isMountedByThisTrigger, store, triggerElementRef, ...Object.values(stateUpdates)]); 6665 return { 6666 registerTrigger, 6667 isMountedByThisTrigger 6668 }; 6669 } 6670 function useImplicitActiveTrigger(store) { 6671 const open = store.useState("open"); 6672 const reactiveTriggerCount = store.useState("triggerCount"); 6673 useIsoLayoutEffect(() => { 6674 if (!open) { 6675 if (store.state.triggerCount !== 0) { 6676 store.set("triggerCount", 0); 6677 } 6678 return; 6679 } 6680 const triggerCount = store.context.triggerElements.size; 6681 const stateUpdates = {}; 6682 if (store.state.triggerCount !== triggerCount) { 6683 stateUpdates.triggerCount = triggerCount; 6684 } 6685 if (!store.select("activeTriggerId") && triggerCount === 1) { 6686 const iteratorResult = store.context.triggerElements.entries().next(); 6687 if (!iteratorResult.done) { 6688 const [implicitTriggerId, implicitTriggerElement] = iteratorResult.value; 6689 stateUpdates.activeTriggerId = implicitTriggerId; 6690 stateUpdates.activeTriggerElement = implicitTriggerElement; 6691 } 6692 } 6693 if (stateUpdates.triggerCount !== void 0 || stateUpdates.activeTriggerId !== void 0) { 6694 store.update(stateUpdates); 6695 } 6696 }, [open, store, reactiveTriggerCount]); 6697 } 6698 function useOpenStateTransitions(open, store, onUnmount) { 6699 const { 6700 mounted, 6701 setMounted, 6702 transitionStatus 6703 } = useTransitionStatus(open); 6704 store.useSyncedValues({ 6705 mounted, 6706 transitionStatus 6707 }); 6708 const forceUnmount = useStableCallback(() => { 6709 setMounted(false); 6710 store.update({ 6711 activeTriggerId: null, 6712 activeTriggerElement: null, 6713 mounted: false, 6714 preventUnmountingOnClose: false 6715 }); 6716 onUnmount?.(); 6717 store.context.onOpenChangeComplete?.(false); 6718 }); 6719 const preventUnmountingOnClose = store.useState("preventUnmountingOnClose"); 6720 useOpenChangeComplete({ 6721 enabled: mounted && !open && !preventUnmountingOnClose, 6722 open, 6723 ref: store.context.popupRef, 6724 onComplete() { 6725 if (!open) { 6726 forceUnmount(); 6727 } 6728 } 6729 }); 6730 return { 6731 forceUnmount, 6732 transitionStatus 6733 }; 6734 } 6735 function usePopupInteractionProps(store, statePart) { 6736 store.useSyncedValues(statePart); 6737 useIsoLayoutEffect(() => () => { 6738 store.update({ 6739 activeTriggerProps: EMPTY_OBJECT, 6740 inactiveTriggerProps: EMPTY_OBJECT, 6741 popupProps: EMPTY_OBJECT 6742 }); 6743 }, [store]); 6744 } 6745 6746 // node_modules/@base-ui/react/esm/utils/popups/popupTriggerMap.js 6747 var PopupTriggerMap = class { 6748 constructor() { 6749 this.elementsSet = /* @__PURE__ */ new Set(); 6750 this.idMap = /* @__PURE__ */ new Map(); 6751 } 6752 /** 6753 * Adds a trigger element with the given ID. 6754 * 6755 * Note: The provided element is assumed to not be registered under multiple IDs. 6756 */ 6757 add(id, element) { 6758 const existingElement = this.idMap.get(id); 6759 if (existingElement === element) { 6760 return; 6761 } 6762 if (existingElement !== void 0) { 6763 this.elementsSet.delete(existingElement); 6764 } 6765 this.elementsSet.add(element); 6766 this.idMap.set(id, element); 6767 if (true) { 6768 if (this.elementsSet.size !== this.idMap.size) { 6769 throw new Error("Base UI: A trigger element cannot be registered under multiple IDs in PopupTriggerMap."); 6770 } 6771 } 6772 } 6773 /** 6774 * Removes the trigger element with the given ID. 6775 */ 6776 delete(id) { 6777 const element = this.idMap.get(id); 6778 if (element) { 6779 this.elementsSet.delete(element); 6780 this.idMap.delete(id); 6781 } 6782 } 6783 /** 6784 * Whether the given element is registered as a trigger. 6785 */ 6786 hasElement(element) { 6787 return this.elementsSet.has(element); 6788 } 6789 /** 6790 * Whether there is a registered trigger element matching the given predicate. 6791 */ 6792 hasMatchingElement(predicate) { 6793 for (const element of this.elementsSet) { 6794 if (predicate(element)) { 6795 return true; 6796 } 6797 } 6798 return false; 6799 } 6800 /** 6801 * Returns the trigger element associated with the given ID, or undefined if no such element exists. 6802 */ 6803 getById(id) { 6804 return this.idMap.get(id); 6805 } 6806 /** 6807 * Returns an iterable of all registered trigger entries, where each entry is a tuple of [id, element]. 6808 */ 6809 entries() { 6810 return this.idMap.entries(); 6811 } 6812 /** 6813 * Returns an iterable of all registered trigger elements. 6814 */ 6815 elements() { 6816 return this.elementsSet.values(); 6817 } 6818 /** 6819 * Returns the number of registered trigger elements. 6820 */ 6821 get size() { 6822 return this.idMap.size; 6823 } 6824 }; 6825 6826 // node_modules/@base-ui/react/esm/floating-ui-react/utils/getEmptyRootContext.js 6827 function getEmptyRootContext() { 6828 return new FloatingRootStore({ 6829 open: false, 6830 transitionStatus: void 0, 6831 floatingElement: null, 6832 referenceElement: null, 6833 triggerElements: new PopupTriggerMap(), 6834 floatingId: void 0, 6835 syncOnly: false, 6836 nested: false, 6837 onOpenChange: void 0 6838 }); 6839 } 6840 6841 // node_modules/@base-ui/react/esm/utils/popups/store.js 6842 function createInitialPopupStoreState() { 6843 return { 6844 open: false, 6845 openProp: void 0, 6846 mounted: false, 6847 transitionStatus: void 0, 6848 floatingRootContext: getEmptyRootContext(), 6849 floatingId: void 0, 6850 triggerCount: 0, 6851 preventUnmountingOnClose: false, 6852 payload: void 0, 6853 activeTriggerId: null, 6854 activeTriggerElement: null, 6855 triggerIdProp: void 0, 6856 popupElement: null, 6857 positionerElement: null, 6858 activeTriggerProps: EMPTY_OBJECT, 6859 inactiveTriggerProps: EMPTY_OBJECT, 6860 popupProps: EMPTY_OBJECT 6861 }; 6862 } 6863 function createPopupFloatingRootContext(triggerElements, floatingId, nested = false) { 6864 return new FloatingRootStore({ 6865 open: false, 6866 transitionStatus: void 0, 6867 floatingElement: null, 6868 referenceElement: null, 6869 triggerElements, 6870 floatingId, 6871 syncOnly: true, 6872 nested, 6873 onOpenChange: void 0 6874 }); 6875 } 6876 var activeTriggerIdSelector = createSelector((state) => state.triggerIdProp ?? state.activeTriggerId); 6877 var openSelector = createSelector((state) => state.openProp ?? state.open); 6878 var popupIdSelector = createSelector((state) => { 6879 const popupId = state.popupElement?.id ?? state.floatingId; 6880 return popupId || void 0; 6881 }); 6882 function triggerOwnsOpenPopup(state, triggerId) { 6883 return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) === triggerId; 6884 } 6885 function triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) { 6886 if (triggerOwnsOpenPopup(state, triggerId)) { 6887 return true; 6888 } 6889 return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) == null && state.triggerCount === 1; 6890 } 6891 var popupStoreSelectors = { 6892 open: openSelector, 6893 mounted: createSelector((state) => state.mounted), 6894 transitionStatus: createSelector((state) => state.transitionStatus), 6895 floatingRootContext: createSelector((state) => state.floatingRootContext), 6896 triggerCount: createSelector((state) => state.triggerCount), 6897 preventUnmountingOnClose: createSelector((state) => state.preventUnmountingOnClose), 6898 payload: createSelector((state) => state.payload), 6899 activeTriggerId: activeTriggerIdSelector, 6900 activeTriggerElement: createSelector((state) => state.mounted ? state.activeTriggerElement : null), 6901 popupId: popupIdSelector, 6902 /** 6903 * Whether the trigger with the given ID was used to open the popup. 6904 */ 6905 isTriggerActive: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId), 6906 /** 6907 * Whether the popup is open and was activated by a trigger with the given ID. 6908 */ 6909 isOpenedByTrigger: createSelector((state, triggerId) => triggerOwnsOpenPopup(state, triggerId)), 6910 /** 6911 * Whether the popup is mounted and was activated by a trigger with the given ID. 6912 */ 6913 isMountedByTrigger: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId && state.mounted), 6914 triggerProps: createSelector((state, isActive) => isActive ? state.activeTriggerProps : state.inactiveTriggerProps), 6915 /** 6916 * Popup id for the trigger that currently owns the open popup. 6917 */ 6918 triggerPopupId: createSelector((state, triggerId) => triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) ? popupIdSelector(state) : void 0), 6919 popupProps: createSelector((state) => state.popupProps), 6920 popupElement: createSelector((state) => state.popupElement), 6921 positionerElement: createSelector((state) => state.positionerElement) 6922 }; 6923 6924 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloatingRootContext.js 6925 function useFloatingRootContext(options) { 6926 const { 6927 open = false, 6928 onOpenChange, 6929 elements = {} 6930 } = options; 6931 const floatingId = useId(); 6932 const nested = useFloatingParentNodeId() != null; 6933 if (true) { 6934 const optionDomReference = elements.reference; 6935 if (optionDomReference && !isElement(optionDomReference)) { 6936 console.error("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `context.setPositionReference()`", "instead."); 6937 } 6938 } 6939 const store = useRefWithInit(() => new FloatingRootStore({ 6940 open, 6941 transitionStatus: void 0, 6942 onOpenChange, 6943 referenceElement: elements.reference ?? null, 6944 floatingElement: elements.floating ?? null, 6945 triggerElements: new PopupTriggerMap(), 6946 floatingId, 6947 syncOnly: false, 6948 nested 6949 })).current; 6950 useIsoLayoutEffect(() => { 6951 const valuesToSync = { 6952 open, 6953 floatingId 6954 }; 6955 if (elements.reference !== void 0) { 6956 valuesToSync.referenceElement = elements.reference; 6957 valuesToSync.domReferenceElement = isElement(elements.reference) ? elements.reference : null; 6958 } 6959 if (elements.floating !== void 0) { 6960 valuesToSync.floatingElement = elements.floating; 6961 } 6962 store.update(valuesToSync); 6963 }, [open, floatingId, elements.reference, elements.floating, store]); 6964 store.context.onOpenChange = onOpenChange; 6965 store.context.nested = nested; 6966 return store; 6967 } 6968 6969 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloating.js 6970 function useFloating2(options = {}) { 6971 const { 6972 nodeId, 6973 externalTree 6974 } = options; 6975 const internalStore = useFloatingRootContext(options); 6976 const store = options.rootContext || internalStore; 6977 const referenceElement = store.useState("referenceElement"); 6978 const floatingElement = store.useState("floatingElement"); 6979 const domReferenceElement = store.useState("domReferenceElement"); 6980 const open = store.useState("open"); 6981 const floatingId = store.useState("floatingId"); 6982 const [positionReference, setPositionReferenceRaw] = React25.useState(null); 6983 const [localDomReference, setLocalDomReference] = React25.useState(void 0); 6984 const [localFloatingElement, setLocalFloatingElement] = React25.useState(void 0); 6985 const domReferenceRef = React25.useRef(null); 6986 const tree = useFloatingTree(externalTree); 6987 const storeElements = React25.useMemo(() => ({ 6988 reference: referenceElement, 6989 floating: floatingElement, 6990 domReference: domReferenceElement 6991 }), [referenceElement, floatingElement, domReferenceElement]); 6992 const position = useFloating({ 6993 ...options, 6994 elements: { 6995 ...storeElements, 6996 ...positionReference && { 6997 reference: positionReference 6998 } 6999 } 7000 }); 7001 const localDomReferenceElement = isElement(localDomReference) ? localDomReference : null; 7002 const syncedFloatingElement = localFloatingElement === void 0 ? store.state.floatingElement : localFloatingElement; 7003 store.useSyncedValue("referenceElement", localDomReference ?? null); 7004 store.useSyncedValue("domReferenceElement", localDomReference === void 0 ? domReferenceElement : localDomReferenceElement); 7005 store.useSyncedValue("floatingElement", syncedFloatingElement); 7006 const setPositionReference = React25.useCallback((node) => { 7007 const computedPositionReference = isElement(node) ? { 7008 getBoundingClientRect: () => node.getBoundingClientRect(), 7009 getClientRects: () => node.getClientRects(), 7010 contextElement: node 7011 } : node; 7012 setPositionReferenceRaw(computedPositionReference); 7013 position.refs.setReference(computedPositionReference); 7014 }, [position.refs]); 7015 const setReference = React25.useCallback((node) => { 7016 if (isElement(node) || node === null) { 7017 domReferenceRef.current = node; 7018 setLocalDomReference(node); 7019 } 7020 if (isElement(position.refs.reference.current) || position.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to 7021 // `null` to support `positionReference` + an unstable `reference` 7022 // callback ref. 7023 node !== null && !isElement(node)) { 7024 position.refs.setReference(node); 7025 } 7026 }, [position.refs, setLocalDomReference]); 7027 const setFloating = React25.useCallback((node) => { 7028 setLocalFloatingElement(node); 7029 position.refs.setFloating(node); 7030 }, [position.refs]); 7031 const refs = React25.useMemo(() => ({ 7032 ...position.refs, 7033 setReference, 7034 setFloating, 7035 setPositionReference, 7036 domReference: domReferenceRef 7037 }), [position.refs, setReference, setFloating, setPositionReference]); 7038 const elements = React25.useMemo(() => ({ 7039 ...position.elements, 7040 domReference: domReferenceElement 7041 }), [position.elements, domReferenceElement]); 7042 const context = React25.useMemo(() => ({ 7043 ...position, 7044 dataRef: store.context.dataRef, 7045 open, 7046 onOpenChange: store.setOpen, 7047 events: store.context.events, 7048 floatingId, 7049 refs, 7050 elements, 7051 nodeId, 7052 rootStore: store 7053 }), [position, refs, elements, nodeId, store, open, floatingId]); 7054 useIsoLayoutEffect(() => { 7055 if (domReferenceElement) { 7056 domReferenceRef.current = domReferenceElement; 7057 } 7058 }, [domReferenceElement]); 7059 useIsoLayoutEffect(() => { 7060 store.context.dataRef.current.floatingContext = context; 7061 const node = tree?.nodesRef.current.find((n2) => n2.id === nodeId); 7062 if (node) { 7063 node.context = context; 7064 } 7065 }); 7066 return React25.useMemo(() => ({ 7067 ...position, 7068 context, 7069 refs, 7070 elements, 7071 rootStore: store 7072 }), [position, refs, elements, context, store]); 7073 } 7074 7075 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFocus.js 7076 var React26 = __toESM(require_react(), 1); 7077 var isMacSafari = isMac && isSafari; 7078 function useFocus(context, props = {}) { 7079 const { 7080 enabled = true, 7081 delay 7082 } = props; 7083 const store = "rootStore" in context ? context.rootStore : context; 7084 const { 7085 events, 7086 dataRef 7087 } = store.context; 7088 const blockFocusRef = React26.useRef(false); 7089 const blockedReferenceRef = React26.useRef(null); 7090 const keyboardModalityRef = React26.useRef(true); 7091 const timeout = useTimeout(); 7092 React26.useEffect(() => { 7093 const domReference = store.select("domReferenceElement"); 7094 if (!enabled) { 7095 return void 0; 7096 } 7097 const win = getWindow(domReference); 7098 function onBlur() { 7099 const currentDomReference = store.select("domReferenceElement"); 7100 if (!store.select("open") && isHTMLElement(currentDomReference) && currentDomReference === activeElement(ownerDocument(currentDomReference))) { 7101 blockFocusRef.current = true; 7102 } 7103 } 7104 function onKeyDown() { 7105 keyboardModalityRef.current = true; 7106 } 7107 function onPointerDown() { 7108 keyboardModalityRef.current = false; 7109 } 7110 return mergeCleanups(addEventListener(win, "blur", onBlur), isMacSafari && addEventListener(win, "keydown", onKeyDown, true), isMacSafari && addEventListener(win, "pointerdown", onPointerDown, true)); 7111 }, [store, enabled]); 7112 React26.useEffect(() => { 7113 if (!enabled) { 7114 return void 0; 7115 } 7116 function onOpenChangeLocal(details) { 7117 if (details.reason === reason_parts_exports.triggerPress || details.reason === reason_parts_exports.escapeKey) { 7118 const referenceElement = store.select("domReferenceElement"); 7119 if (isElement(referenceElement)) { 7120 blockedReferenceRef.current = referenceElement; 7121 blockFocusRef.current = true; 7122 } 7123 } 7124 } 7125 events.on("openchange", onOpenChangeLocal); 7126 return () => { 7127 events.off("openchange", onOpenChangeLocal); 7128 }; 7129 }, [events, enabled, store]); 7130 const reference = React26.useMemo(() => { 7131 function resetBlockedFocus() { 7132 blockFocusRef.current = false; 7133 blockedReferenceRef.current = null; 7134 } 7135 return { 7136 onMouseLeave() { 7137 resetBlockedFocus(); 7138 }, 7139 onFocus(event) { 7140 const focusTarget = event.currentTarget; 7141 if (blockFocusRef.current) { 7142 if (blockedReferenceRef.current === focusTarget) { 7143 return; 7144 } 7145 resetBlockedFocus(); 7146 } 7147 const target = getTarget(event.nativeEvent); 7148 if (isElement(target)) { 7149 if (isMacSafari && !event.relatedTarget) { 7150 if (!keyboardModalityRef.current && !isTypeableElement(target)) { 7151 return; 7152 } 7153 } else if (!matchesFocusVisible(target)) { 7154 return; 7155 } 7156 } 7157 const movedFromOtherEnabledTrigger = isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements); 7158 const { 7159 nativeEvent, 7160 currentTarget 7161 } = event; 7162 const delayValue = typeof delay === "function" ? delay() : delay; 7163 if (store.select("open") && movedFromOtherEnabledTrigger || delayValue === 0 || delayValue === void 0) { 7164 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget)); 7165 return; 7166 } 7167 timeout.start(delayValue, () => { 7168 if (blockFocusRef.current) { 7169 return; 7170 } 7171 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget)); 7172 }); 7173 }, 7174 onBlur(event) { 7175 resetBlockedFocus(); 7176 const relatedTarget = event.relatedTarget; 7177 const nativeEvent = event.nativeEvent; 7178 const movedToFocusGuard = isElement(relatedTarget) && relatedTarget.hasAttribute(createAttribute("focus-guard")) && relatedTarget.getAttribute("data-type") === "outside"; 7179 timeout.start(0, () => { 7180 const domReference = store.select("domReferenceElement"); 7181 const activeEl = activeElement(ownerDocument(domReference)); 7182 if (!relatedTarget && activeEl === domReference) { 7183 return; 7184 } 7185 if (contains(dataRef.current.floatingContext?.refs.floating.current, activeEl) || contains(domReference, activeEl) || movedToFocusGuard) { 7186 return; 7187 } 7188 const nextFocusedElement = relatedTarget ?? activeEl; 7189 if (isTargetInsideEnabledTrigger(nextFocusedElement, store.context.triggerElements)) { 7190 return; 7191 } 7192 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent)); 7193 }); 7194 } 7195 }; 7196 }, [dataRef, delay, store, timeout]); 7197 return React26.useMemo(() => enabled ? { 7198 reference, 7199 trigger: reference 7200 } : {}, [enabled, reference]); 7201 } 7202 7203 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverFloatingInteraction.js 7204 var React27 = __toESM(require_react(), 1); 7205 7206 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverInteractionSharedState.js 7207 var HoverInteraction = class _HoverInteraction { 7208 constructor() { 7209 this.pointerType = void 0; 7210 this.interactedInside = false; 7211 this.handler = void 0; 7212 this.blockMouseMove = true; 7213 this.performedPointerEventsMutation = false; 7214 this.pointerEventsScopeElement = null; 7215 this.pointerEventsReferenceElement = null; 7216 this.pointerEventsFloatingElement = null; 7217 this.restTimeoutPending = false; 7218 this.openChangeTimeout = new Timeout(); 7219 this.restTimeout = new Timeout(); 7220 this.handleCloseOptions = void 0; 7221 } 7222 static create() { 7223 return new _HoverInteraction(); 7224 } 7225 dispose = () => { 7226 this.openChangeTimeout.clear(); 7227 this.restTimeout.clear(); 7228 }; 7229 disposeEffect = () => { 7230 return this.dispose; 7231 }; 7232 }; 7233 var pointerEventsMutationOwnerByScopeElement = /* @__PURE__ */ new WeakMap(); 7234 function clearSafePolygonPointerEventsMutation(instance) { 7235 if (!instance.performedPointerEventsMutation) { 7236 return; 7237 } 7238 const scopeElement = instance.pointerEventsScopeElement; 7239 if (scopeElement && pointerEventsMutationOwnerByScopeElement.get(scopeElement) === instance) { 7240 instance.pointerEventsScopeElement?.style.removeProperty("pointer-events"); 7241 instance.pointerEventsReferenceElement?.style.removeProperty("pointer-events"); 7242 instance.pointerEventsFloatingElement?.style.removeProperty("pointer-events"); 7243 pointerEventsMutationOwnerByScopeElement.delete(scopeElement); 7244 } 7245 instance.performedPointerEventsMutation = false; 7246 instance.pointerEventsScopeElement = null; 7247 instance.pointerEventsReferenceElement = null; 7248 instance.pointerEventsFloatingElement = null; 7249 } 7250 function applySafePolygonPointerEventsMutation(instance, options) { 7251 const { 7252 scopeElement, 7253 referenceElement, 7254 floatingElement 7255 } = options; 7256 const existingOwner = pointerEventsMutationOwnerByScopeElement.get(scopeElement); 7257 if (existingOwner && existingOwner !== instance) { 7258 clearSafePolygonPointerEventsMutation(existingOwner); 7259 } 7260 clearSafePolygonPointerEventsMutation(instance); 7261 instance.performedPointerEventsMutation = true; 7262 instance.pointerEventsScopeElement = scopeElement; 7263 instance.pointerEventsReferenceElement = referenceElement; 7264 instance.pointerEventsFloatingElement = floatingElement; 7265 pointerEventsMutationOwnerByScopeElement.set(scopeElement, instance); 7266 scopeElement.style.pointerEvents = "none"; 7267 referenceElement.style.pointerEvents = "auto"; 7268 floatingElement.style.pointerEvents = "auto"; 7269 } 7270 function useHoverInteractionSharedState(store) { 7271 const data = store.context.dataRef.current; 7272 const instance = useRefWithInit(() => data.hoverInteractionState ?? HoverInteraction.create()).current; 7273 if (!data.hoverInteractionState) { 7274 data.hoverInteractionState = instance; 7275 } 7276 useOnMount(data.hoverInteractionState.disposeEffect); 7277 return data.hoverInteractionState; 7278 } 7279 7280 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverFloatingInteraction.js 7281 function useHoverFloatingInteraction(context, parameters = {}) { 7282 const { 7283 enabled = true, 7284 closeDelay: closeDelayProp = 0, 7285 nodeId: nodeIdProp 7286 } = parameters; 7287 const store = "rootStore" in context ? context.rootStore : context; 7288 const open = store.useState("open"); 7289 const floatingElement = store.useState("floatingElement"); 7290 const domReferenceElement = store.useState("domReferenceElement"); 7291 const { 7292 dataRef 7293 } = store.context; 7294 const tree = useFloatingTree(); 7295 const parentId = useFloatingParentNodeId(); 7296 const instance = useHoverInteractionSharedState(store); 7297 const childClosedTimeout = useTimeout(); 7298 const isClickLikeOpenEvent2 = useStableCallback(() => { 7299 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside); 7300 }); 7301 const isHoverOpen = useStableCallback(() => { 7302 return isHoverOpenEvent(dataRef.current.openEvent?.type); 7303 }); 7304 const clearPointerEvents = useStableCallback(() => { 7305 clearSafePolygonPointerEventsMutation(instance); 7306 }); 7307 useIsoLayoutEffect(() => { 7308 if (!open) { 7309 instance.pointerType = void 0; 7310 instance.restTimeoutPending = false; 7311 instance.interactedInside = false; 7312 clearPointerEvents(); 7313 } 7314 }, [open, instance, clearPointerEvents]); 7315 React27.useEffect(() => { 7316 return clearPointerEvents; 7317 }, [clearPointerEvents]); 7318 useIsoLayoutEffect(() => { 7319 if (!enabled) { 7320 return void 0; 7321 } 7322 if (open && instance.handleCloseOptions?.blockPointerEvents && isHoverOpen() && isElement(domReferenceElement) && floatingElement) { 7323 const ref = domReferenceElement; 7324 const floatingEl = floatingElement; 7325 const doc = ownerDocument(floatingElement); 7326 const parentFloating = tree?.nodesRef.current.find((node) => node.id === parentId)?.context?.elements.floating; 7327 if (parentFloating) { 7328 parentFloating.style.pointerEvents = ""; 7329 } 7330 const cachedScopeElement = instance.pointerEventsScopeElement !== floatingEl ? instance.pointerEventsScopeElement : null; 7331 const parentScopeElement = parentFloating !== floatingEl ? parentFloating : null; 7332 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? cachedScopeElement ?? parentScopeElement ?? ref.closest("[data-rootownerid]") ?? doc.body; 7333 applySafePolygonPointerEventsMutation(instance, { 7334 scopeElement, 7335 referenceElement: ref, 7336 floatingElement: floatingEl 7337 }); 7338 return () => { 7339 clearPointerEvents(); 7340 }; 7341 } 7342 return void 0; 7343 }, [enabled, open, domReferenceElement, floatingElement, instance, isHoverOpen, tree, parentId, clearPointerEvents]); 7344 React27.useEffect(() => { 7345 if (!enabled) { 7346 return void 0; 7347 } 7348 function hasParentChildren() { 7349 return !!(tree && parentId && getNodeChildren(tree.nodesRef.current, parentId).length > 0); 7350 } 7351 function closeWithDelay(event) { 7352 const closeDelay = getDelay(closeDelayProp, "close", instance.pointerType); 7353 const close = () => { 7354 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event)); 7355 tree?.events.emit("floating.closed", event); 7356 }; 7357 if (closeDelay) { 7358 instance.openChangeTimeout.start(closeDelay, close); 7359 } else { 7360 instance.openChangeTimeout.clear(); 7361 close(); 7362 } 7363 } 7364 function handleInteractInside(event) { 7365 const target = getTarget(event); 7366 if (!isInteractiveElement(target)) { 7367 instance.interactedInside = false; 7368 return; 7369 } 7370 instance.interactedInside = target?.closest("[aria-haspopup]") != null; 7371 } 7372 function onFloatingMouseEnter() { 7373 instance.openChangeTimeout.clear(); 7374 childClosedTimeout.clear(); 7375 tree?.events.off("floating.closed", onNodeClosed); 7376 clearPointerEvents(); 7377 } 7378 function onFloatingMouseLeave(event) { 7379 if (hasParentChildren() && tree) { 7380 tree.events.on("floating.closed", onNodeClosed); 7381 return; 7382 } 7383 if (isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements)) { 7384 return; 7385 } 7386 const currentNodeId = dataRef.current.floatingContext?.nodeId ?? nodeIdProp; 7387 const relatedTarget = event.relatedTarget; 7388 const isMovingIntoDescendantFloating = tree && currentNodeId && isElement(relatedTarget) && getNodeChildren(tree.nodesRef.current, currentNodeId, false).some((node) => contains(node.context?.elements.floating, relatedTarget)); 7389 if (isMovingIntoDescendantFloating) { 7390 return; 7391 } 7392 if (instance.handler) { 7393 instance.handler(event); 7394 return; 7395 } 7396 clearPointerEvents(); 7397 if (!isClickLikeOpenEvent2()) { 7398 closeWithDelay(event); 7399 } 7400 } 7401 function onNodeClosed(event) { 7402 if (!tree || !parentId || hasParentChildren()) { 7403 return; 7404 } 7405 childClosedTimeout.start(0, () => { 7406 tree.events.off("floating.closed", onNodeClosed); 7407 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event)); 7408 tree.events.emit("floating.closed", event); 7409 }); 7410 } 7411 const floating = floatingElement; 7412 return mergeCleanups(floating && addEventListener(floating, "mouseenter", onFloatingMouseEnter), floating && addEventListener(floating, "mouseleave", onFloatingMouseLeave), floating && addEventListener(floating, "pointerdown", handleInteractInside, true), () => { 7413 tree?.events.off("floating.closed", onNodeClosed); 7414 }); 7415 }, [enabled, floatingElement, store, dataRef, closeDelayProp, nodeIdProp, isClickLikeOpenEvent2, clearPointerEvents, instance, tree, parentId, childClosedTimeout]); 7416 } 7417 7418 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverReferenceInteraction.js 7419 var React28 = __toESM(require_react(), 1); 7420 var ReactDOM4 = __toESM(require_react_dom(), 1); 7421 var EMPTY_REF = { 7422 current: null 7423 }; 7424 function useHoverReferenceInteraction(context, props = {}) { 7425 const { 7426 enabled = true, 7427 delay = 0, 7428 handleClose = null, 7429 mouseOnly = false, 7430 restMs = 0, 7431 move = true, 7432 triggerElementRef = EMPTY_REF, 7433 externalTree, 7434 isActiveTrigger = true, 7435 getHandleCloseContext, 7436 isClosing, 7437 shouldOpen: shouldOpenProp 7438 } = props; 7439 const store = "rootStore" in context ? context.rootStore : context; 7440 const { 7441 dataRef, 7442 events 7443 } = store.context; 7444 const tree = useFloatingTree(externalTree); 7445 const instance = useHoverInteractionSharedState(store); 7446 const isHoverCloseActiveRef = React28.useRef(false); 7447 const handleCloseRef = useValueAsRef(handleClose); 7448 const delayRef = useValueAsRef(delay); 7449 const restMsRef = useValueAsRef(restMs); 7450 const enabledRef = useValueAsRef(enabled); 7451 const shouldOpenRef = useValueAsRef(shouldOpenProp); 7452 const isClosingRef = useValueAsRef(isClosing); 7453 const isClickLikeOpenEvent2 = useStableCallback(() => { 7454 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside); 7455 }); 7456 const checkShouldOpen = useStableCallback(() => { 7457 return shouldOpenRef.current?.() !== false; 7458 }); 7459 const isOverInactiveTrigger = useStableCallback((currentDomReference, currentTarget, target) => { 7460 const allTriggers = store.context.triggerElements; 7461 if (allTriggers.hasElement(currentTarget)) { 7462 return !currentDomReference || !contains(currentDomReference, currentTarget); 7463 } 7464 if (!isElement(target)) { 7465 return false; 7466 } 7467 const targetElement = target; 7468 return allTriggers.hasMatchingElement((trigger) => contains(trigger, targetElement)) && (!currentDomReference || !contains(currentDomReference, targetElement)); 7469 }); 7470 const cleanupMouseMoveHandler = useStableCallback(() => { 7471 if (!instance.handler) { 7472 return; 7473 } 7474 const doc = ownerDocument(store.select("domReferenceElement")); 7475 doc.removeEventListener("mousemove", instance.handler); 7476 instance.handler = void 0; 7477 }); 7478 const clearPointerEvents = useStableCallback(() => { 7479 clearSafePolygonPointerEventsMutation(instance); 7480 }); 7481 if (isActiveTrigger) { 7482 instance.handleCloseOptions = handleCloseRef.current?.__options; 7483 } 7484 React28.useEffect(() => cleanupMouseMoveHandler, [cleanupMouseMoveHandler]); 7485 React28.useEffect(() => { 7486 if (!enabled) { 7487 return void 0; 7488 } 7489 function onOpenChangeLocal(details) { 7490 if (!details.open) { 7491 isHoverCloseActiveRef.current = details.reason === reason_parts_exports.triggerHover; 7492 cleanupMouseMoveHandler(); 7493 instance.openChangeTimeout.clear(); 7494 instance.restTimeout.clear(); 7495 instance.blockMouseMove = true; 7496 instance.restTimeoutPending = false; 7497 } else { 7498 isHoverCloseActiveRef.current = false; 7499 } 7500 } 7501 events.on("openchange", onOpenChangeLocal); 7502 return () => { 7503 events.off("openchange", onOpenChangeLocal); 7504 }; 7505 }, [enabled, events, instance, cleanupMouseMoveHandler]); 7506 React28.useEffect(() => { 7507 if (!enabled) { 7508 return void 0; 7509 } 7510 function closeWithDelay(event, runElseBranch = true) { 7511 const closeDelay = getDelay(delayRef.current, "close", instance.pointerType); 7512 if (closeDelay) { 7513 instance.openChangeTimeout.start(closeDelay, () => { 7514 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event)); 7515 tree?.events.emit("floating.closed", event); 7516 }); 7517 } else if (runElseBranch) { 7518 instance.openChangeTimeout.clear(); 7519 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event)); 7520 tree?.events.emit("floating.closed", event); 7521 } 7522 } 7523 const trigger = triggerElementRef.current ?? (isActiveTrigger ? store.select("domReferenceElement") : null); 7524 if (!isElement(trigger)) { 7525 return void 0; 7526 } 7527 function onMouseEnter(event) { 7528 instance.openChangeTimeout.clear(); 7529 instance.blockMouseMove = false; 7530 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) { 7531 return; 7532 } 7533 const restMsValue = getRestMs(restMsRef.current); 7534 const openDelay = getDelay(delayRef.current, "open", instance.pointerType); 7535 const eventTarget = getTarget(event); 7536 const currentTarget = event.currentTarget ?? null; 7537 const currentDomReference = store.select("domReferenceElement"); 7538 let triggerNode = currentTarget; 7539 if (isElement(eventTarget) && !store.context.triggerElements.hasElement(eventTarget)) { 7540 for (const triggerElement of store.context.triggerElements.elements()) { 7541 if (contains(triggerElement, eventTarget)) { 7542 triggerNode = triggerElement; 7543 break; 7544 } 7545 } 7546 } 7547 if (isElement(currentTarget) && isElement(currentDomReference) && !store.context.triggerElements.hasElement(currentTarget) && contains(currentTarget, currentDomReference)) { 7548 triggerNode = currentDomReference; 7549 } 7550 const isOverInactive = triggerNode == null ? false : isOverInactiveTrigger(currentDomReference, triggerNode, eventTarget); 7551 const isOpen = store.select("open"); 7552 const isInClosingTransition = isClosingRef.current?.() ?? store.select("transitionStatus") === "ending"; 7553 const isHoverCloseTransition = !isOpen && isInClosingTransition && isHoverCloseActiveRef.current; 7554 const isReenteringSameTriggerDuringCloseTransition = !isOverInactive && isElement(triggerNode) && isElement(currentDomReference) && contains(currentDomReference, triggerNode) && isHoverCloseTransition; 7555 const isRestOnlyDelay = restMsValue > 0 && !openDelay; 7556 const shouldOpenImmediately = isOverInactive && (isOpen || isHoverCloseTransition) || isReenteringSameTriggerDuringCloseTransition; 7557 const shouldOpen = !isOpen || isOverInactive; 7558 if (shouldOpenImmediately) { 7559 if (checkShouldOpen()) { 7560 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode)); 7561 } 7562 return; 7563 } 7564 if (isRestOnlyDelay) { 7565 return; 7566 } 7567 if (openDelay) { 7568 instance.openChangeTimeout.start(openDelay, () => { 7569 if (shouldOpen && checkShouldOpen()) { 7570 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode)); 7571 } 7572 }); 7573 } else if (shouldOpen) { 7574 if (checkShouldOpen()) { 7575 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode)); 7576 } 7577 } 7578 } 7579 function onMouseLeave(event) { 7580 if (isClickLikeOpenEvent2()) { 7581 clearPointerEvents(); 7582 return; 7583 } 7584 cleanupMouseMoveHandler(); 7585 const domReferenceElement = store.select("domReferenceElement"); 7586 const doc = ownerDocument(domReferenceElement); 7587 instance.restTimeout.clear(); 7588 instance.restTimeoutPending = false; 7589 const handleCloseContextBase = dataRef.current.floatingContext ?? getHandleCloseContext?.(); 7590 if (isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements)) { 7591 return; 7592 } 7593 if (handleCloseRef.current && handleCloseContextBase) { 7594 if (!store.select("open")) { 7595 instance.openChangeTimeout.clear(); 7596 } 7597 const currentTrigger = triggerElementRef.current; 7598 instance.handler = handleCloseRef.current({ 7599 ...handleCloseContextBase, 7600 tree, 7601 x: event.clientX, 7602 y: event.clientY, 7603 onClose() { 7604 clearPointerEvents(); 7605 cleanupMouseMoveHandler(); 7606 if (enabledRef.current && !isClickLikeOpenEvent2() && currentTrigger === store.select("domReferenceElement")) { 7607 closeWithDelay(event, true); 7608 } 7609 } 7610 }); 7611 doc.addEventListener("mousemove", instance.handler); 7612 instance.handler(event); 7613 return; 7614 } 7615 const shouldClose = instance.pointerType === "touch" ? !contains(store.select("floatingElement"), event.relatedTarget) : true; 7616 if (shouldClose) { 7617 closeWithDelay(event); 7618 } 7619 } 7620 if (move) { 7621 return mergeCleanups(addEventListener(trigger, "mousemove", onMouseEnter, { 7622 once: true 7623 }), addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave)); 7624 } 7625 return mergeCleanups(addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave)); 7626 }, [cleanupMouseMoveHandler, clearPointerEvents, dataRef, delayRef, store, enabled, handleCloseRef, instance, isActiveTrigger, isOverInactiveTrigger, isClickLikeOpenEvent2, mouseOnly, move, restMsRef, triggerElementRef, tree, enabledRef, getHandleCloseContext, isClosingRef, checkShouldOpen]); 7627 return React28.useMemo(() => { 7628 if (!enabled) { 7629 return void 0; 7630 } 7631 function setPointerRef(event) { 7632 instance.pointerType = event.pointerType; 7633 } 7634 return { 7635 onPointerDown: setPointerRef, 7636 onPointerEnter: setPointerRef, 7637 onMouseMove(event) { 7638 const { 7639 nativeEvent 7640 } = event; 7641 const trigger = event.currentTarget; 7642 const currentDomReference = store.select("domReferenceElement"); 7643 const currentOpen = store.select("open"); 7644 const isOverInactive = isOverInactiveTrigger(currentDomReference, trigger, event.target); 7645 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) { 7646 return; 7647 } 7648 if (currentOpen && isOverInactive && instance.handleCloseOptions?.blockPointerEvents) { 7649 const floatingElement = store.select("floatingElement"); 7650 if (floatingElement) { 7651 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? trigger.ownerDocument.body; 7652 applySafePolygonPointerEventsMutation(instance, { 7653 scopeElement, 7654 referenceElement: trigger, 7655 floatingElement 7656 }); 7657 } 7658 } 7659 const restMsValue = getRestMs(restMsRef.current); 7660 if (currentOpen && !isOverInactive || restMsValue === 0) { 7661 return; 7662 } 7663 if (!isOverInactive && instance.restTimeoutPending && event.movementX ** 2 + event.movementY ** 2 < 2) { 7664 return; 7665 } 7666 instance.restTimeout.clear(); 7667 function handleMouseMove() { 7668 instance.restTimeoutPending = false; 7669 if (isClickLikeOpenEvent2()) { 7670 return; 7671 } 7672 const latestOpen = store.select("open"); 7673 if (!instance.blockMouseMove && (!latestOpen || isOverInactive) && checkShouldOpen()) { 7674 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, nativeEvent, trigger)); 7675 } 7676 } 7677 if (instance.pointerType === "touch") { 7678 ReactDOM4.flushSync(() => { 7679 handleMouseMove(); 7680 }); 7681 } else if (isOverInactive && currentOpen) { 7682 handleMouseMove(); 7683 } else { 7684 instance.restTimeoutPending = true; 7685 instance.restTimeout.start(restMsValue, handleMouseMove); 7686 } 7687 } 7688 }; 7689 }, [enabled, instance, isClickLikeOpenEvent2, isOverInactiveTrigger, mouseOnly, store, restMsRef, checkShouldOpen]); 7690 } 7691 7692 // node_modules/@base-ui/react/esm/floating-ui-react/safePolygon.js 7693 var CURSOR_SPEED_THRESHOLD = 0.1; 7694 var CURSOR_SPEED_THRESHOLD_SQUARED = CURSOR_SPEED_THRESHOLD * CURSOR_SPEED_THRESHOLD; 7695 var POLYGON_BUFFER = 0.5; 7696 function hasIntersectingEdge(pointX, pointY, xi, yi, xj, yj) { 7697 return yi >= pointY !== yj >= pointY && pointX <= (xj - xi) * (pointY - yi) / (yj - yi) + xi; 7698 } 7699 function isPointInQuadrilateral(pointX, pointY, x1, y1, x2, y2, x3, y3, x4, y4) { 7700 let isInsideValue = false; 7701 if (hasIntersectingEdge(pointX, pointY, x1, y1, x2, y2)) { 7702 isInsideValue = !isInsideValue; 7703 } 7704 if (hasIntersectingEdge(pointX, pointY, x2, y2, x3, y3)) { 7705 isInsideValue = !isInsideValue; 7706 } 7707 if (hasIntersectingEdge(pointX, pointY, x3, y3, x4, y4)) { 7708 isInsideValue = !isInsideValue; 7709 } 7710 if (hasIntersectingEdge(pointX, pointY, x4, y4, x1, y1)) { 7711 isInsideValue = !isInsideValue; 7712 } 7713 return isInsideValue; 7714 } 7715 function isInsideRect(pointX, pointY, rect) { 7716 return pointX >= rect.x && pointX <= rect.x + rect.width && pointY >= rect.y && pointY <= rect.y + rect.height; 7717 } 7718 function isInsideAxisAlignedRect(pointX, pointY, x1, y1, x2, y2) { 7719 const minX = Math.min(x1, x2); 7720 const maxX = Math.max(x1, x2); 7721 const minY = Math.min(y1, y2); 7722 const maxY = Math.max(y1, y2); 7723 return pointX >= minX && pointX <= maxX && pointY >= minY && pointY <= maxY; 7724 } 7725 function safePolygon(options = {}) { 7726 const { 7727 blockPointerEvents = false 7728 } = options; 7729 const timeout = new Timeout(); 7730 const fn = ({ 7731 x: x2, 7732 y: y2, 7733 placement, 7734 elements, 7735 onClose, 7736 nodeId, 7737 tree 7738 }) => { 7739 const side = placement?.split("-")[0]; 7740 let hasLanded = false; 7741 let lastX = null; 7742 let lastY = null; 7743 let lastCursorTime = typeof performance !== "undefined" ? performance.now() : 0; 7744 function isCursorMovingSlowly(nextX, nextY) { 7745 const currentTime = performance.now(); 7746 const elapsedTime = currentTime - lastCursorTime; 7747 if (lastX === null || lastY === null || elapsedTime === 0) { 7748 lastX = nextX; 7749 lastY = nextY; 7750 lastCursorTime = currentTime; 7751 return false; 7752 } 7753 const deltaX = nextX - lastX; 7754 const deltaY = nextY - lastY; 7755 const distanceSquared = deltaX * deltaX + deltaY * deltaY; 7756 const thresholdSquared = elapsedTime * elapsedTime * CURSOR_SPEED_THRESHOLD_SQUARED; 7757 lastX = nextX; 7758 lastY = nextY; 7759 lastCursorTime = currentTime; 7760 return distanceSquared < thresholdSquared; 7761 } 7762 function close() { 7763 timeout.clear(); 7764 onClose(); 7765 } 7766 return function onMouseMove(event) { 7767 timeout.clear(); 7768 const domReference = elements.domReference; 7769 const floating = elements.floating; 7770 if (!domReference || !floating || side == null || x2 == null || y2 == null) { 7771 return void 0; 7772 } 7773 const { 7774 clientX, 7775 clientY 7776 } = event; 7777 const target = getTarget(event); 7778 const isLeave = event.type === "mouseleave"; 7779 const isOverFloatingEl = contains(floating, target); 7780 const isOverReferenceEl = contains(domReference, target); 7781 if (isOverFloatingEl) { 7782 hasLanded = true; 7783 if (!isLeave) { 7784 return void 0; 7785 } 7786 } 7787 if (isOverReferenceEl) { 7788 hasLanded = false; 7789 if (!isLeave) { 7790 hasLanded = true; 7791 return void 0; 7792 } 7793 } 7794 if (isLeave && isElement(event.relatedTarget) && contains(floating, event.relatedTarget)) { 7795 return void 0; 7796 } 7797 function hasOpenChildNode() { 7798 return Boolean(tree && getNodeChildren(tree.nodesRef.current, nodeId).length > 0); 7799 } 7800 function closeIfNoOpenChild() { 7801 if (!hasOpenChildNode()) { 7802 close(); 7803 } 7804 } 7805 if (hasOpenChildNode()) { 7806 return void 0; 7807 } 7808 const refRect = domReference.getBoundingClientRect(); 7809 const rect = floating.getBoundingClientRect(); 7810 const cursorLeaveFromRight = x2 > rect.right - rect.width / 2; 7811 const cursorLeaveFromBottom = y2 > rect.bottom - rect.height / 2; 7812 const isFloatingWider = rect.width > refRect.width; 7813 const isFloatingTaller = rect.height > refRect.height; 7814 const left = (isFloatingWider ? refRect : rect).left; 7815 const right = (isFloatingWider ? refRect : rect).right; 7816 const top = (isFloatingTaller ? refRect : rect).top; 7817 const bottom = (isFloatingTaller ? refRect : rect).bottom; 7818 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) { 7819 closeIfNoOpenChild(); 7820 return void 0; 7821 } 7822 let isInsideTroughRect = false; 7823 switch (side) { 7824 case "top": 7825 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, refRect.top + 1, right, rect.bottom - 1); 7826 break; 7827 case "bottom": 7828 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, rect.top + 1, right, refRect.bottom - 1); 7829 break; 7830 case "left": 7831 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, rect.right - 1, bottom, refRect.left + 1, top); 7832 break; 7833 case "right": 7834 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, refRect.right - 1, bottom, rect.left + 1, top); 7835 break; 7836 default: 7837 } 7838 if (isInsideTroughRect) { 7839 return void 0; 7840 } 7841 if (hasLanded && !isInsideRect(clientX, clientY, refRect)) { 7842 closeIfNoOpenChild(); 7843 return void 0; 7844 } 7845 if (!isLeave && isCursorMovingSlowly(clientX, clientY)) { 7846 closeIfNoOpenChild(); 7847 return void 0; 7848 } 7849 let isInsidePolygon = false; 7850 switch (side) { 7851 case "top": { 7852 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4; 7853 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset; 7854 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset; 7855 const cursorPointY = y2 + POLYGON_BUFFER + 1; 7856 const commonYLeft = cursorLeaveFromRight ? rect.bottom - POLYGON_BUFFER : isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top; 7857 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top : rect.bottom - POLYGON_BUFFER; 7858 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight); 7859 break; 7860 } 7861 case "bottom": { 7862 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4; 7863 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset; 7864 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset; 7865 const cursorPointY = y2 - POLYGON_BUFFER; 7866 const commonYLeft = cursorLeaveFromRight ? rect.top + POLYGON_BUFFER : isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom; 7867 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom : rect.top + POLYGON_BUFFER; 7868 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight); 7869 break; 7870 } 7871 case "left": { 7872 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4; 7873 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset; 7874 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset; 7875 const cursorPointX = x2 + POLYGON_BUFFER + 1; 7876 const commonXTop = cursorLeaveFromBottom ? rect.right - POLYGON_BUFFER : isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left; 7877 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left : rect.right - POLYGON_BUFFER; 7878 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, commonXTop, rect.top, commonXBottom, rect.bottom, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY); 7879 break; 7880 } 7881 case "right": { 7882 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4; 7883 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset; 7884 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset; 7885 const cursorPointX = x2 - POLYGON_BUFFER; 7886 const commonXTop = cursorLeaveFromBottom ? rect.left + POLYGON_BUFFER : isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right; 7887 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right : rect.left + POLYGON_BUFFER; 7888 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY, commonXTop, rect.top, commonXBottom, rect.bottom); 7889 break; 7890 } 7891 default: 7892 } 7893 if (!isInsidePolygon) { 7894 closeIfNoOpenChild(); 7895 } else if (!hasLanded) { 7896 timeout.start(40, closeIfNoOpenChild); 7897 } 7898 return void 0; 7899 }; 7900 }; 7901 fn.__options = { 7902 ...options, 7903 blockPointerEvents 7904 }; 7905 return fn; 7906 } 7907 7908 // node_modules/@base-ui/react/esm/utils/popupStateMapping.js 7909 var CommonPopupDataAttributes = (function(CommonPopupDataAttributes2) { 7910 CommonPopupDataAttributes2["open"] = "data-open"; 7911 CommonPopupDataAttributes2["closed"] = "data-closed"; 7912 CommonPopupDataAttributes2[CommonPopupDataAttributes2["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle"; 7913 CommonPopupDataAttributes2[CommonPopupDataAttributes2["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle"; 7914 CommonPopupDataAttributes2["anchorHidden"] = "data-anchor-hidden"; 7915 CommonPopupDataAttributes2["side"] = "data-side"; 7916 CommonPopupDataAttributes2["align"] = "data-align"; 7917 return CommonPopupDataAttributes2; 7918 })({}); 7919 var CommonTriggerDataAttributes = /* @__PURE__ */ (function(CommonTriggerDataAttributes2) { 7920 CommonTriggerDataAttributes2["popupOpen"] = "data-popup-open"; 7921 CommonTriggerDataAttributes2["pressed"] = "data-pressed"; 7922 return CommonTriggerDataAttributes2; 7923 })({}); 7924 var TRIGGER_HOOK = { 7925 [CommonTriggerDataAttributes.popupOpen]: "" 7926 }; 7927 var PRESSABLE_TRIGGER_HOOK = { 7928 [CommonTriggerDataAttributes.popupOpen]: "", 7929 [CommonTriggerDataAttributes.pressed]: "" 7930 }; 7931 var POPUP_OPEN_HOOK = { 7932 [CommonPopupDataAttributes.open]: "" 7933 }; 7934 var POPUP_CLOSED_HOOK = { 7935 [CommonPopupDataAttributes.closed]: "" 7936 }; 7937 var ANCHOR_HIDDEN_HOOK = { 7938 [CommonPopupDataAttributes.anchorHidden]: "" 7939 }; 7940 var triggerOpenStateMapping = { 7941 open(value) { 7942 if (value) { 7943 return TRIGGER_HOOK; 7944 } 7945 return null; 7946 } 7947 }; 7948 var popupStateMapping = { 7949 open(value) { 7950 if (value) { 7951 return POPUP_OPEN_HOOK; 7952 } 7953 return POPUP_CLOSED_HOOK; 7954 }, 7955 anchorHidden(value) { 7956 if (value) { 7957 return ANCHOR_HIDDEN_HOOK; 7958 } 7959 return null; 7960 } 7961 }; 7962 7963 // node_modules/@base-ui/utils/esm/inertValue.js 7964 function inertValue(value) { 7965 if (isReactVersionAtLeast(19)) { 7966 return value; 7967 } 7968 return value ? "true" : void 0; 7969 } 7970 7971 // node_modules/@base-ui/react/esm/utils/useAnchorPositioning.js 7972 var React29 = __toESM(require_react(), 1); 7973 7974 // node_modules/@base-ui/react/esm/floating-ui-react/middleware/arrow.js 7975 var baseArrow = (options) => ({ 7976 name: "arrow", 7977 options, 7978 async fn(state) { 7979 const { 7980 x: x2, 7981 y: y2, 7982 placement, 7983 rects, 7984 platform: platform3, 7985 elements, 7986 middlewareData 7987 } = state; 7988 const { 7989 element, 7990 padding = 0, 7991 offsetParent = "real" 7992 } = evaluate(options, state) || {}; 7993 if (element == null) { 7994 return {}; 7995 } 7996 const paddingObject = getPaddingObject(padding); 7997 const coords = { 7998 x: x2, 7999 y: y2 8000 }; 8001 const axis = getAlignmentAxis(placement); 8002 const length = getAxisLength(axis); 8003 const arrowDimensions = await platform3.getDimensions(element); 8004 const isYAxis = axis === "y"; 8005 const minProp = isYAxis ? "top" : "left"; 8006 const maxProp = isYAxis ? "bottom" : "right"; 8007 const clientProp = isYAxis ? "clientHeight" : "clientWidth"; 8008 const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length]; 8009 const startDiff = coords[axis] - rects.reference[axis]; 8010 const arrowOffsetParent = offsetParent === "real" ? await platform3.getOffsetParent?.(element) : elements.floating; 8011 let clientSize = elements.floating[clientProp] || rects.floating[length]; 8012 if (!clientSize || !await platform3.isElement?.(arrowOffsetParent)) { 8013 clientSize = elements.floating[clientProp] || rects.floating[length]; 8014 } 8015 const centerToReference = endDiff / 2 - startDiff / 2; 8016 const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1; 8017 const minPadding = Math.min(paddingObject[minProp], largestPossiblePadding); 8018 const maxPadding = Math.min(paddingObject[maxProp], largestPossiblePadding); 8019 const min2 = minPadding; 8020 const max2 = clientSize - arrowDimensions[length] - maxPadding; 8021 const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference; 8022 const offset4 = clamp(min2, center, max2); 8023 const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset4 && rects.reference[length] / 2 - (center < min2 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0; 8024 const alignmentOffset = shouldAddOffset ? center < min2 ? center - min2 : center - max2 : 0; 8025 return { 8026 [axis]: coords[axis] + alignmentOffset, 8027 data: { 8028 [axis]: offset4, 8029 centerOffset: center - offset4 - alignmentOffset, 8030 ...shouldAddOffset && { 8031 alignmentOffset 8032 } 8033 }, 8034 reset: shouldAddOffset 8035 }; 8036 } 8037 }); 8038 var arrow4 = (options, deps) => ({ 8039 ...baseArrow(options), 8040 options: [options, deps] 8041 }); 8042 8043 // node_modules/@base-ui/react/esm/utils/hideMiddleware.js 8044 var hide4 = { 8045 name: "hide", 8046 async fn(state) { 8047 const { 8048 width, 8049 height, 8050 x: x2, 8051 y: y2 8052 } = state.rects.reference; 8053 const anchorHidden = width === 0 && height === 0 && x2 === 0 && y2 === 0; 8054 const nativeHideResult = await hide3().fn(state); 8055 return { 8056 data: { 8057 referenceHidden: nativeHideResult.data?.referenceHidden || anchorHidden 8058 } 8059 }; 8060 } 8061 }; 8062 8063 // node_modules/@base-ui/react/esm/utils/adaptiveOriginMiddleware.js 8064 var DEFAULT_SIDES = { 8065 sideX: "left", 8066 sideY: "top" 8067 }; 8068 var adaptiveOrigin = { 8069 name: "adaptiveOrigin", 8070 async fn(state) { 8071 const { 8072 x: rawX, 8073 y: rawY, 8074 rects: { 8075 floating: floatRect 8076 }, 8077 elements: { 8078 floating 8079 }, 8080 platform: platform3, 8081 strategy, 8082 placement 8083 } = state; 8084 const win = getWindow(floating); 8085 const styles = win.getComputedStyle(floating); 8086 const hasTransition = styles.transitionDuration !== "0s" && styles.transitionDuration !== ""; 8087 if (!hasTransition) { 8088 return { 8089 x: rawX, 8090 y: rawY, 8091 data: DEFAULT_SIDES 8092 }; 8093 } 8094 const offsetParent = await platform3.getOffsetParent?.(floating); 8095 let offsetDimensions = { 8096 width: 0, 8097 height: 0 8098 }; 8099 if (strategy === "fixed" && win?.visualViewport) { 8100 offsetDimensions = { 8101 width: win.visualViewport.width, 8102 height: win.visualViewport.height 8103 }; 8104 } else if (offsetParent === win) { 8105 const doc = ownerDocument(floating); 8106 offsetDimensions = { 8107 width: doc.documentElement.clientWidth, 8108 height: doc.documentElement.clientHeight 8109 }; 8110 } else if (await platform3.isElement?.(offsetParent)) { 8111 offsetDimensions = await platform3.getDimensions(offsetParent); 8112 } 8113 const currentSide = getSide(placement); 8114 let x2 = rawX; 8115 let y2 = rawY; 8116 if (currentSide === "left") { 8117 x2 = offsetDimensions.width - (rawX + floatRect.width); 8118 } 8119 if (currentSide === "top") { 8120 y2 = offsetDimensions.height - (rawY + floatRect.height); 8121 } 8122 const sideX = currentSide === "left" ? "right" : DEFAULT_SIDES.sideX; 8123 const sideY = currentSide === "top" ? "bottom" : DEFAULT_SIDES.sideY; 8124 return { 8125 x: x2, 8126 y: y2, 8127 data: { 8128 sideX, 8129 sideY 8130 } 8131 }; 8132 } 8133 }; 8134 8135 // node_modules/@base-ui/react/esm/utils/useAnchorPositioning.js 8136 function getLogicalSide(sideParam, renderedSide, isRtl) { 8137 const isLogicalSideParam = sideParam === "inline-start" || sideParam === "inline-end"; 8138 const logicalRight = isRtl ? "inline-start" : "inline-end"; 8139 const logicalLeft = isRtl ? "inline-end" : "inline-start"; 8140 return { 8141 top: "top", 8142 right: isLogicalSideParam ? logicalRight : "right", 8143 bottom: "bottom", 8144 left: isLogicalSideParam ? logicalLeft : "left" 8145 }[renderedSide]; 8146 } 8147 function getOffsetData(state, sideParam, isRtl) { 8148 const { 8149 rects, 8150 placement 8151 } = state; 8152 const data = { 8153 side: getLogicalSide(sideParam, getSide(placement), isRtl), 8154 align: getAlignment(placement) || "center", 8155 anchor: { 8156 width: rects.reference.width, 8157 height: rects.reference.height 8158 }, 8159 positioner: { 8160 width: rects.floating.width, 8161 height: rects.floating.height 8162 } 8163 }; 8164 return data; 8165 } 8166 function useAnchorPositioning(params) { 8167 const { 8168 // Public parameters 8169 anchor, 8170 positionMethod = "absolute", 8171 side: sideParam = "bottom", 8172 sideOffset = 0, 8173 align = "center", 8174 alignOffset = 0, 8175 collisionBoundary, 8176 collisionPadding: collisionPaddingParam = 5, 8177 sticky = false, 8178 arrowPadding = 5, 8179 disableAnchorTracking = false, 8180 inline: inlineMiddleware, 8181 // Private parameters 8182 keepMounted = false, 8183 floatingRootContext, 8184 mounted, 8185 collisionAvoidance, 8186 shiftCrossAxis = false, 8187 nodeId, 8188 adaptiveOrigin: adaptiveOrigin2, 8189 lazyFlip = false, 8190 externalTree 8191 } = params; 8192 const [mountSide, setMountSide] = React29.useState(null); 8193 if (!mounted && mountSide !== null) { 8194 setMountSide(null); 8195 } 8196 const collisionAvoidanceSide = collisionAvoidance.side || "flip"; 8197 const collisionAvoidanceAlign = collisionAvoidance.align || "flip"; 8198 const collisionAvoidanceFallbackAxisSide = collisionAvoidance.fallbackAxisSide || "end"; 8199 const anchorFn = typeof anchor === "function" ? anchor : void 0; 8200 const anchorFnCallback = useStableCallback(anchorFn); 8201 const anchorDep = anchorFn ? anchorFnCallback : anchor; 8202 const anchorValueRef = useValueAsRef(anchor); 8203 const mountedRef = useValueAsRef(mounted); 8204 const direction = useDirection(); 8205 const isRtl = direction === "rtl"; 8206 const side = mountSide || { 8207 top: "top", 8208 right: "right", 8209 bottom: "bottom", 8210 left: "left", 8211 "inline-end": isRtl ? "left" : "right", 8212 "inline-start": isRtl ? "right" : "left" 8213 }[sideParam]; 8214 const placement = align === "center" ? side : `$side}-$align}`; 8215 let collisionPadding = collisionPaddingParam; 8216 const bias = 1; 8217 const biasTop = sideParam === "bottom" ? bias : 0; 8218 const biasBottom = sideParam === "top" ? bias : 0; 8219 const biasLeft = sideParam === "right" ? bias : 0; 8220 const biasRight = sideParam === "left" ? bias : 0; 8221 if (typeof collisionPadding === "number") { 8222 collisionPadding = { 8223 top: collisionPadding + biasTop, 8224 right: collisionPadding + biasRight, 8225 bottom: collisionPadding + biasBottom, 8226 left: collisionPadding + biasLeft 8227 }; 8228 } else if (collisionPadding) { 8229 collisionPadding = { 8230 top: (collisionPadding.top || 0) + biasTop, 8231 right: (collisionPadding.right || 0) + biasRight, 8232 bottom: (collisionPadding.bottom || 0) + biasBottom, 8233 left: (collisionPadding.left || 0) + biasLeft 8234 }; 8235 } 8236 const commonCollisionProps = { 8237 boundary: collisionBoundary === "clipping-ancestors" ? "clippingAncestors" : collisionBoundary, 8238 padding: collisionPadding 8239 }; 8240 const arrowRef = React29.useRef(null); 8241 const sideOffsetRef = useValueAsRef(sideOffset); 8242 const alignOffsetRef = useValueAsRef(alignOffset); 8243 const sideOffsetDep = typeof sideOffset !== "function" ? sideOffset : 0; 8244 const alignOffsetDep = typeof alignOffset !== "function" ? alignOffset : 0; 8245 const middleware = []; 8246 if (inlineMiddleware) { 8247 middleware.push(inlineMiddleware); 8248 } 8249 middleware.push(offset3((state) => { 8250 const data = getOffsetData(state, sideParam, isRtl); 8251 const sideAxis = typeof sideOffsetRef.current === "function" ? sideOffsetRef.current(data) : sideOffsetRef.current; 8252 const alignAxis = typeof alignOffsetRef.current === "function" ? alignOffsetRef.current(data) : alignOffsetRef.current; 8253 return { 8254 mainAxis: sideAxis, 8255 crossAxis: alignAxis, 8256 alignmentAxis: alignAxis 8257 }; 8258 }, [sideOffsetDep, alignOffsetDep, isRtl, sideParam])); 8259 const shiftDisabled = collisionAvoidanceAlign === "none" && collisionAvoidanceSide !== "shift"; 8260 const crossAxisShiftEnabled = !shiftDisabled && (sticky || shiftCrossAxis || collisionAvoidanceSide === "shift"); 8261 const flipMiddleware = collisionAvoidanceSide === "none" ? null : flip3({ 8262 ...commonCollisionProps, 8263 // Ensure the popup flips if it's been limited by its --available-height and it resizes. 8264 // Since the size() padding is smaller than the flip() padding, flip() will take precedence. 8265 padding: { 8266 top: collisionPadding.top + bias, 8267 right: collisionPadding.right + bias, 8268 bottom: collisionPadding.bottom + bias, 8269 left: collisionPadding.left + bias 8270 }, 8271 mainAxis: !shiftCrossAxis && collisionAvoidanceSide === "flip", 8272 crossAxis: collisionAvoidanceAlign === "flip" ? "alignment" : false, 8273 fallbackAxisSideDirection: collisionAvoidanceFallbackAxisSide 8274 }); 8275 const shiftMiddleware = shiftDisabled ? null : shift3((data) => { 8276 const html = ownerDocument(data.elements.floating).documentElement; 8277 return { 8278 ...commonCollisionProps, 8279 // Use the Layout Viewport to avoid shifting around when pinch-zooming 8280 // for context menus. 8281 rootBoundary: shiftCrossAxis ? { 8282 x: 0, 8283 y: 0, 8284 width: html.clientWidth, 8285 height: html.clientHeight 8286 } : void 0, 8287 mainAxis: collisionAvoidanceAlign !== "none", 8288 crossAxis: crossAxisShiftEnabled, 8289 limiter: sticky || shiftCrossAxis ? void 0 : limitShift3((limitData) => { 8290 if (!arrowRef.current) { 8291 return {}; 8292 } 8293 const { 8294 width, 8295 height 8296 } = arrowRef.current.getBoundingClientRect(); 8297 const sideAxis = getSideAxis(getSide(limitData.placement)); 8298 const arrowSize = sideAxis === "y" ? width : height; 8299 const offsetAmount = sideAxis === "y" ? collisionPadding.left + collisionPadding.right : collisionPadding.top + collisionPadding.bottom; 8300 return { 8301 offset: arrowSize / 2 + offsetAmount / 2 8302 }; 8303 }) 8304 }; 8305 }, [commonCollisionProps, sticky, shiftCrossAxis, collisionPadding, collisionAvoidanceAlign]); 8306 if (collisionAvoidanceSide === "shift" || collisionAvoidanceAlign === "shift" || align === "center") { 8307 middleware.push(shiftMiddleware, flipMiddleware); 8308 } else { 8309 middleware.push(flipMiddleware, shiftMiddleware); 8310 } 8311 middleware.push(size3({ 8312 ...commonCollisionProps, 8313 apply({ 8314 elements: { 8315 floating 8316 }, 8317 availableWidth, 8318 availableHeight, 8319 rects 8320 }) { 8321 if (!mountedRef.current) { 8322 return; 8323 } 8324 const floatingStyle = floating.style; 8325 floatingStyle.setProperty("--available-width", `$availableWidth}px`); 8326 floatingStyle.setProperty("--available-height", `$availableHeight}px`); 8327 const dpr = getWindow(floating).devicePixelRatio || 1; 8328 const { 8329 x: x3, 8330 y: y3, 8331 width, 8332 height 8333 } = rects.reference; 8334 const anchorWidth = (Math.round((x3 + width) * dpr) - Math.round(x3 * dpr)) / dpr; 8335 const anchorHeight = (Math.round((y3 + height) * dpr) - Math.round(y3 * dpr)) / dpr; 8336 floatingStyle.setProperty("--anchor-width", `$anchorWidth}px`); 8337 floatingStyle.setProperty("--anchor-height", `$anchorHeight}px`); 8338 } 8339 }), arrow4((state) => ({ 8340 // `transform-origin` calculations rely on an element existing. If the arrow hasn't been set, 8341 // we'll create a fake element. 8342 element: arrowRef.current || ownerDocument(state.elements.floating).createElement("div"), 8343 padding: arrowPadding, 8344 offsetParent: "floating" 8345 }), [arrowPadding]), { 8346 name: "transformOrigin", 8347 fn(state) { 8348 const { 8349 elements: elements2, 8350 middlewareData: middlewareData2, 8351 placement: renderedPlacement2, 8352 rects, 8353 y: y3 8354 } = state; 8355 const currentRenderedSide = getSide(renderedPlacement2); 8356 const currentRenderedAxis = getSideAxis(currentRenderedSide); 8357 const arrowEl = arrowRef.current; 8358 const arrowX = middlewareData2.arrow?.x || 0; 8359 const arrowY = middlewareData2.arrow?.y || 0; 8360 const arrowWidth = arrowEl?.clientWidth || 0; 8361 const arrowHeight = arrowEl?.clientHeight || 0; 8362 const transformX = arrowX + arrowWidth / 2; 8363 const transformY = arrowY + arrowHeight / 2; 8364 const shiftY = Math.abs(middlewareData2.shift?.y || 0); 8365 const halfAnchorHeight = rects.reference.height / 2; 8366 const sideOffsetValue = typeof sideOffset === "function" ? sideOffset(getOffsetData(state, sideParam, isRtl)) : sideOffset; 8367 const isOverlappingAnchor = shiftY > sideOffsetValue; 8368 const adjacentTransformOrigin = { 8369 top: `$transformX}px calc(100% + $sideOffsetValue}px)`, 8370 bottom: `$transformX}px ${-sideOffsetValue}px`, 8371 left: `calc(100% + $sideOffsetValue}px) $transformY}px`, 8372 right: `${-sideOffsetValue}px $transformY}px` 8373 }[currentRenderedSide]; 8374 const overlapTransformOrigin = `$transformX}px $rects.reference.y + halfAnchorHeight - y3}px`; 8375 elements2.floating.style.setProperty("--transform-origin", crossAxisShiftEnabled && currentRenderedAxis === "y" && isOverlappingAnchor ? overlapTransformOrigin : adjacentTransformOrigin); 8376 return {}; 8377 } 8378 }, hide4, adaptiveOrigin2); 8379 useIsoLayoutEffect(() => { 8380 if (!mounted && floatingRootContext) { 8381 floatingRootContext.update({ 8382 referenceElement: null, 8383 floatingElement: null, 8384 domReferenceElement: null, 8385 positionReference: null 8386 }); 8387 } 8388 }, [mounted, floatingRootContext]); 8389 const autoUpdateOptions = React29.useMemo(() => ({ 8390 elementResize: !disableAnchorTracking && typeof ResizeObserver !== "undefined", 8391 layoutShift: !disableAnchorTracking && typeof IntersectionObserver !== "undefined" 8392 }), [disableAnchorTracking]); 8393 const { 8394 refs, 8395 elements, 8396 x: x2, 8397 y: y2, 8398 middlewareData, 8399 update: update2, 8400 placement: renderedPlacement, 8401 context, 8402 isPositioned, 8403 floatingStyles: originalFloatingStyles 8404 } = useFloating2({ 8405 rootContext: floatingRootContext, 8406 open: keepMounted ? mounted : void 0, 8407 placement, 8408 middleware, 8409 strategy: positionMethod, 8410 whileElementsMounted: keepMounted ? void 0 : (...args) => autoUpdate(...args, autoUpdateOptions), 8411 nodeId, 8412 externalTree 8413 }); 8414 const { 8415 sideX, 8416 sideY 8417 } = middlewareData.adaptiveOrigin || DEFAULT_SIDES; 8418 const resolvedPosition = isPositioned ? positionMethod : "fixed"; 8419 const floatingStyles = React29.useMemo(() => { 8420 const base = adaptiveOrigin2 ? { 8421 position: resolvedPosition, 8422 [sideX]: x2, 8423 [sideY]: y2 8424 } : { 8425 position: resolvedPosition, 8426 ...originalFloatingStyles 8427 }; 8428 if (!isPositioned) { 8429 base.opacity = 0; 8430 } 8431 return base; 8432 }, [adaptiveOrigin2, resolvedPosition, sideX, x2, sideY, y2, originalFloatingStyles, isPositioned]); 8433 const registeredPositionReferenceRef = React29.useRef(null); 8434 useIsoLayoutEffect(() => { 8435 if (!mounted) { 8436 return; 8437 } 8438 const anchorValue = anchorValueRef.current; 8439 const resolvedAnchor = typeof anchorValue === "function" ? anchorValue() : anchorValue; 8440 const unwrappedElement = (isRef(resolvedAnchor) ? resolvedAnchor.current : resolvedAnchor) || null; 8441 const finalAnchor = unwrappedElement || null; 8442 if (finalAnchor !== registeredPositionReferenceRef.current) { 8443 refs.setPositionReference(finalAnchor); 8444 registeredPositionReferenceRef.current = finalAnchor; 8445 } 8446 }, [mounted, refs, anchorDep, anchorValueRef]); 8447 React29.useEffect(() => { 8448 if (!mounted) { 8449 return; 8450 } 8451 const anchorValue = anchorValueRef.current; 8452 if (typeof anchorValue === "function") { 8453 return; 8454 } 8455 if (isRef(anchorValue) && anchorValue.current !== registeredPositionReferenceRef.current) { 8456 refs.setPositionReference(anchorValue.current); 8457 registeredPositionReferenceRef.current = anchorValue.current; 8458 } 8459 }, [mounted, refs, anchorDep, anchorValueRef]); 8460 React29.useEffect(() => { 8461 if (keepMounted && mounted && elements.domReference && elements.floating) { 8462 return autoUpdate(elements.domReference, elements.floating, update2, autoUpdateOptions); 8463 } 8464 return void 0; 8465 }, [keepMounted, mounted, elements, update2, autoUpdateOptions]); 8466 const renderedSide = getSide(renderedPlacement); 8467 const logicalRenderedSide = getLogicalSide(sideParam, renderedSide, isRtl); 8468 const renderedAlign = getAlignment(renderedPlacement) || "center"; 8469 const anchorHidden = Boolean(middlewareData.hide?.referenceHidden); 8470 useIsoLayoutEffect(() => { 8471 if (lazyFlip && mounted && isPositioned) { 8472 setMountSide(renderedSide); 8473 } 8474 }, [lazyFlip, mounted, isPositioned, renderedSide]); 8475 const arrowStyles = React29.useMemo(() => ({ 8476 position: "absolute", 8477 top: middlewareData.arrow?.y, 8478 left: middlewareData.arrow?.x 8479 }), [middlewareData.arrow]); 8480 const arrowUncentered = middlewareData.arrow?.centerOffset !== 0; 8481 return React29.useMemo(() => ({ 8482 positionerStyles: floatingStyles, 8483 arrowStyles, 8484 arrowRef, 8485 arrowUncentered, 8486 side: logicalRenderedSide, 8487 align: renderedAlign, 8488 physicalSide: renderedSide, 8489 anchorHidden, 8490 refs, 8491 context, 8492 isPositioned, 8493 update: update2 8494 }), [floatingStyles, arrowStyles, arrowRef, arrowUncentered, logicalRenderedSide, renderedAlign, renderedSide, anchorHidden, refs, context, isPositioned, update2]); 8495 } 8496 function isRef(param) { 8497 return param != null && "current" in param; 8498 } 8499 8500 // node_modules/@base-ui/react/esm/utils/getDisabledMountTransitionStyles.js 8501 function getDisabledMountTransitionStyles(transitionStatus) { 8502 return transitionStatus === "starting" ? DISABLED_TRANSITIONS_STYLE : EMPTY_OBJECT; 8503 } 8504 8505 // node_modules/@base-ui/react/esm/utils/usePositioner.js 8506 function usePositioner(componentProps, state, { 8507 styles, 8508 transitionStatus, 8509 props, 8510 refs, 8511 hidden, 8512 inert = false 8513 }) { 8514 const style = { 8515 ...styles 8516 }; 8517 if (inert) { 8518 style.pointerEvents = "none"; 8519 } 8520 return useRenderElement("div", componentProps, { 8521 state, 8522 ref: refs, 8523 props: [{ 8524 role: "presentation", 8525 hidden, 8526 style 8527 }, getDisabledMountTransitionStyles(transitionStatus), props], 8528 stateAttributesMapping: popupStateMapping 8529 }); 8530 } 8531 8532 // node_modules/@base-ui/react/esm/utils/usePopupViewport.js 8533 var React32 = __toESM(require_react(), 1); 8534 var ReactDOM5 = __toESM(require_react_dom(), 1); 8535 8536 // node_modules/@base-ui/utils/esm/usePreviousValue.js 8537 var React30 = __toESM(require_react(), 1); 8538 function usePreviousValue(value) { 8539 const [state, setState] = React30.useState({ 8540 current: value, 8541 previous: null 8542 }); 8543 if (value !== state.current) { 8544 setState({ 8545 current: value, 8546 previous: state.current 8547 }); 8548 } 8549 return state.previous; 8550 } 8551 8552 // node_modules/@base-ui/react/esm/utils/usePopupAutoResize.js 8553 var React31 = __toESM(require_react(), 1); 8554 8555 // node_modules/@base-ui/react/esm/utils/getCssDimensions.js 8556 function getCssDimensions2(element) { 8557 const css = getComputedStyle2(element); 8558 let width = parseFloat(css.width) || 0; 8559 let height = parseFloat(css.height) || 0; 8560 const hasOffset = isHTMLElement(element); 8561 const offsetWidth = hasOffset ? element.offsetWidth : width; 8562 const offsetHeight = hasOffset ? element.offsetHeight : height; 8563 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight; 8564 if (shouldFallback) { 8565 width = offsetWidth; 8566 height = offsetHeight; 8567 } 8568 return { 8569 width, 8570 height 8571 }; 8572 } 8573 8574 // node_modules/@base-ui/react/esm/utils/usePopupAutoResize.js 8575 var DEFAULT_ENABLED = () => true; 8576 function usePopupAutoResize(parameters) { 8577 const { 8578 popupElement, 8579 positionerElement, 8580 content, 8581 mounted, 8582 enabled = DEFAULT_ENABLED, 8583 onMeasureLayout: onMeasureLayoutParam, 8584 onMeasureLayoutComplete: onMeasureLayoutCompleteParam, 8585 side, 8586 direction 8587 } = parameters; 8588 const runOnceAnimationsFinish = useAnimationsFinished(popupElement, true, false); 8589 const animationFrame = useAnimationFrame(); 8590 const committedDimensionsRef = React31.useRef(null); 8591 const liveDimensionsRef = React31.useRef(null); 8592 const isInitialRenderRef = React31.useRef(true); 8593 const restoreAnchoringStylesRef = React31.useRef(NOOP); 8594 const onMeasureLayout = useStableCallback(onMeasureLayoutParam); 8595 const onMeasureLayoutComplete = useStableCallback(onMeasureLayoutCompleteParam); 8596 const anchoringStyles = React31.useMemo(() => { 8597 let isOriginSide = side === "top"; 8598 let isPhysicalLeft = side === "left"; 8599 if (direction === "rtl") { 8600 isOriginSide = isOriginSide || side === "inline-end"; 8601 isPhysicalLeft = isPhysicalLeft || side === "inline-end"; 8602 } else { 8603 isOriginSide = isOriginSide || side === "inline-start"; 8604 isPhysicalLeft = isPhysicalLeft || side === "inline-start"; 8605 } 8606 return isOriginSide ? { 8607 position: "absolute", 8608 [side === "top" ? "bottom" : "top"]: "0", 8609 [isPhysicalLeft ? "right" : "left"]: "0" 8610 } : EMPTY_OBJECT; 8611 }, [side, direction]); 8612 useIsoLayoutEffect(() => { 8613 if (!mounted || !enabled() || typeof ResizeObserver !== "function") { 8614 restoreAnchoringStylesRef.current = NOOP; 8615 isInitialRenderRef.current = true; 8616 committedDimensionsRef.current = null; 8617 liveDimensionsRef.current = null; 8618 return void 0; 8619 } 8620 if (!popupElement || !positionerElement) { 8621 return void 0; 8622 } 8623 restoreAnchoringStylesRef.current = applyElementStyles(popupElement, anchoringStyles); 8624 const observer = new ResizeObserver((entries) => { 8625 const entry = entries[0]; 8626 if (entry) { 8627 liveDimensionsRef.current = { 8628 width: Math.ceil(entry.borderBoxSize[0].inlineSize), 8629 height: Math.ceil(entry.borderBoxSize[0].blockSize) 8630 }; 8631 } 8632 }); 8633 observer.observe(popupElement); 8634 setPopupCssSize(popupElement, "auto"); 8635 const restorePopupPosition = overrideElementStyle(popupElement, "position", "static"); 8636 const restorePopupTransform = overrideElementStyle(popupElement, "transform", "none"); 8637 const restorePopupScale = overrideElementStyle(popupElement, "scale", "1"); 8638 const restorePositionerAvailableSize = applyElementStyles(positionerElement, { 8639 "--available-width": "max-content", 8640 "--available-height": "max-content" 8641 }); 8642 function restoreMeasurementOverrides() { 8643 restorePopupPosition(); 8644 restorePopupTransform(); 8645 restorePositionerAvailableSize(); 8646 } 8647 function restoreMeasurementOverridesIncludingScale() { 8648 restoreMeasurementOverrides(); 8649 restorePopupScale(); 8650 } 8651 onMeasureLayout?.(); 8652 if (isInitialRenderRef.current || committedDimensionsRef.current === null) { 8653 setPositionerCssSize(positionerElement, "max-content"); 8654 const dimensions = getCssDimensions2(popupElement); 8655 committedDimensionsRef.current = dimensions; 8656 setPositionerCssSize(positionerElement, dimensions); 8657 restoreMeasurementOverridesIncludingScale(); 8658 onMeasureLayoutComplete?.(null, dimensions); 8659 isInitialRenderRef.current = false; 8660 return () => { 8661 observer.disconnect(); 8662 restoreAnchoringStylesRef.current(); 8663 restoreAnchoringStylesRef.current = NOOP; 8664 }; 8665 } 8666 setPopupCssSize(popupElement, "auto"); 8667 setPositionerCssSize(positionerElement, "max-content"); 8668 const previousDimensions = committedDimensionsRef.current ?? liveDimensionsRef.current; 8669 const newDimensions = getCssDimensions2(popupElement); 8670 committedDimensionsRef.current = newDimensions; 8671 if (!previousDimensions) { 8672 setPositionerCssSize(positionerElement, newDimensions); 8673 restoreMeasurementOverridesIncludingScale(); 8674 onMeasureLayoutComplete?.(null, newDimensions); 8675 return () => { 8676 observer.disconnect(); 8677 animationFrame.cancel(); 8678 restoreAnchoringStylesRef.current(); 8679 restoreAnchoringStylesRef.current = NOOP; 8680 }; 8681 } 8682 setPopupCssSize(popupElement, previousDimensions); 8683 restoreMeasurementOverridesIncludingScale(); 8684 onMeasureLayoutComplete?.(previousDimensions, newDimensions); 8685 setPositionerCssSize(positionerElement, newDimensions); 8686 const abortController = new AbortController(); 8687 animationFrame.request(() => { 8688 setPopupCssSize(popupElement, newDimensions); 8689 runOnceAnimationsFinish(() => { 8690 popupElement.style.setProperty("--popup-width", "auto"); 8691 popupElement.style.setProperty("--popup-height", "auto"); 8692 }, abortController.signal); 8693 }); 8694 return () => { 8695 observer.disconnect(); 8696 abortController.abort(); 8697 animationFrame.cancel(); 8698 restoreAnchoringStylesRef.current(); 8699 restoreAnchoringStylesRef.current = NOOP; 8700 }; 8701 }, [content, popupElement, positionerElement, runOnceAnimationsFinish, animationFrame, enabled, mounted, onMeasureLayout, onMeasureLayoutComplete, anchoringStyles]); 8702 } 8703 function overrideElementStyle(element, property, value) { 8704 const originalValue = element.style.getPropertyValue(property); 8705 element.style.setProperty(property, value); 8706 return () => { 8707 element.style.setProperty(property, originalValue); 8708 }; 8709 } 8710 function applyElementStyles(element, styles) { 8711 const restorers = []; 8712 for (const [key, value] of Object.entries(styles)) { 8713 restorers.push(overrideElementStyle(element, key, value)); 8714 } 8715 return restorers.length ? () => { 8716 restorers.forEach((restore) => restore()); 8717 } : NOOP; 8718 } 8719 function setPopupCssSize(popupElement, size4) { 8720 const width = size4 === "auto" ? "auto" : `$size4.width}px`; 8721 const height = size4 === "auto" ? "auto" : `$size4.height}px`; 8722 popupElement.style.setProperty("--popup-width", width); 8723 popupElement.style.setProperty("--popup-height", height); 8724 } 8725 function setPositionerCssSize(positionerElement, size4) { 8726 const width = size4 === "max-content" ? "max-content" : `$size4.width}px`; 8727 const height = size4 === "max-content" ? "max-content" : `$size4.height}px`; 8728 positionerElement.style.setProperty("--positioner-width", width); 8729 positionerElement.style.setProperty("--positioner-height", height); 8730 } 8731 8732 // node_modules/@base-ui/react/esm/utils/usePopupViewport.js 8733 var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1); 8734 function usePopupViewport(parameters) { 8735 const { 8736 store, 8737 side, 8738 cssVars, 8739 children 8740 } = parameters; 8741 const direction = useDirection(); 8742 const activeTrigger = store.useState("activeTriggerElement"); 8743 const activeTriggerId = store.useState("activeTriggerId"); 8744 const open = store.useState("open"); 8745 const payload = store.useState("payload"); 8746 const mounted = store.useState("mounted"); 8747 const popupElement = store.useState("popupElement"); 8748 const positionerElement = store.useState("positionerElement"); 8749 const previousActiveTrigger = usePreviousValue(open ? activeTrigger : null); 8750 const currentContentKey = usePopupContentKey(activeTriggerId, payload); 8751 const capturedNodeRef = React32.useRef(null); 8752 const [previousContentNode, setPreviousContentNode] = React32.useState(null); 8753 const [newTriggerOffset, setNewTriggerOffset] = React32.useState(null); 8754 const currentContainerRef = React32.useRef(null); 8755 const previousContainerRef = React32.useRef(null); 8756 const onAnimationsFinished = useAnimationsFinished(currentContainerRef, true, false); 8757 const cleanupFrame = useAnimationFrame(); 8758 const [previousContentDimensions, setPreviousContentDimensions] = React32.useState(null); 8759 const [showStartingStyleAttribute, setShowStartingStyleAttribute] = React32.useState(false); 8760 useIsoLayoutEffect(() => { 8761 store.set("hasViewport", true); 8762 return () => { 8763 store.set("hasViewport", false); 8764 }; 8765 }, [store]); 8766 const handleMeasureLayout = useStableCallback(() => { 8767 currentContainerRef.current?.style.setProperty("animation", "none"); 8768 currentContainerRef.current?.style.setProperty("transition", "none"); 8769 previousContainerRef.current?.style.setProperty("display", "none"); 8770 }); 8771 const handleMeasureLayoutComplete = useStableCallback((previousDimensions) => { 8772 currentContainerRef.current?.style.removeProperty("animation"); 8773 currentContainerRef.current?.style.removeProperty("transition"); 8774 previousContainerRef.current?.style.removeProperty("display"); 8775 if (previousDimensions) { 8776 setPreviousContentDimensions(previousDimensions); 8777 } 8778 }); 8779 const lastHandledTriggerRef = React32.useRef(null); 8780 useIsoLayoutEffect(() => { 8781 if (activeTrigger && previousActiveTrigger && activeTrigger !== previousActiveTrigger && lastHandledTriggerRef.current !== activeTrigger && capturedNodeRef.current) { 8782 setPreviousContentNode(capturedNodeRef.current); 8783 setShowStartingStyleAttribute(true); 8784 const offset4 = calculateRelativePosition(previousActiveTrigger, activeTrigger); 8785 setNewTriggerOffset(offset4); 8786 cleanupFrame.request(() => { 8787 ReactDOM5.flushSync(() => { 8788 setShowStartingStyleAttribute(false); 8789 }); 8790 onAnimationsFinished(() => { 8791 setPreviousContentNode(null); 8792 setPreviousContentDimensions(null); 8793 capturedNodeRef.current = null; 8794 }); 8795 }); 8796 lastHandledTriggerRef.current = activeTrigger; 8797 } 8798 }, [activeTrigger, previousActiveTrigger, previousContentNode, onAnimationsFinished, cleanupFrame]); 8799 useIsoLayoutEffect(() => { 8800 const source = currentContainerRef.current; 8801 if (!source) { 8802 return; 8803 } 8804 const wrapper = ownerDocument(source).createElement("div"); 8805 for (const child of Array.from(source.childNodes)) { 8806 wrapper.appendChild(child.cloneNode(true)); 8807 } 8808 capturedNodeRef.current = wrapper; 8809 }); 8810 const isTransitioning = previousContentNode != null; 8811 let childrenToRender; 8812 if (!isTransitioning) { 8813 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { 8814 "data-current": true, 8815 ref: currentContainerRef, 8816 children 8817 }, currentContentKey); 8818 } else { 8819 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(React32.Fragment, { 8820 children: [/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { 8821 "data-previous": true, 8822 inert: inertValue(true), 8823 ref: previousContainerRef, 8824 style: { 8825 ...previousContentDimensions ? { 8826 [cssVars.popupWidth]: `$previousContentDimensions.width}px`, 8827 [cssVars.popupHeight]: `$previousContentDimensions.height}px` 8828 } : null, 8829 position: "absolute" 8830 }, 8831 "data-ending-style": showStartingStyleAttribute ? void 0 : "" 8832 }, "previous"), /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { 8833 "data-current": true, 8834 ref: currentContainerRef, 8835 "data-starting-style": showStartingStyleAttribute ? "" : void 0, 8836 children 8837 }, currentContentKey)] 8838 }); 8839 } 8840 useIsoLayoutEffect(() => { 8841 const container = previousContainerRef.current; 8842 if (!container || !previousContentNode) { 8843 return; 8844 } 8845 container.replaceChildren(...Array.from(previousContentNode.childNodes)); 8846 }, [previousContentNode]); 8847 usePopupAutoResize({ 8848 popupElement, 8849 positionerElement, 8850 mounted, 8851 content: payload, 8852 onMeasureLayout: handleMeasureLayout, 8853 onMeasureLayoutComplete: handleMeasureLayoutComplete, 8854 side, 8855 direction 8856 }); 8857 const state = { 8858 activationDirection: getActivationDirection(newTriggerOffset), 8859 transitioning: isTransitioning 8860 }; 8861 return { 8862 children: childrenToRender, 8863 state 8864 }; 8865 } 8866 function getActivationDirection(offset4) { 8867 if (!offset4) { 8868 return void 0; 8869 } 8870 return `$getValueWithTolerance(offset4.horizontal, 5, "right", "left")} $getValueWithTolerance(offset4.vertical, 5, "down", "up")}`; 8871 } 8872 function getValueWithTolerance(value, tolerance, positiveLabel, negativeLabel) { 8873 if (value > tolerance) { 8874 return positiveLabel; 8875 } 8876 if (value < -tolerance) { 8877 return negativeLabel; 8878 } 8879 return ""; 8880 } 8881 function calculateRelativePosition(from, to) { 8882 const fromRect = from.getBoundingClientRect(); 8883 const toRect = to.getBoundingClientRect(); 8884 const fromCenter = { 8885 x: fromRect.left + fromRect.width / 2, 8886 y: fromRect.top + fromRect.height / 2 8887 }; 8888 const toCenter = { 8889 x: toRect.left + toRect.width / 2, 8890 y: toRect.top + toRect.height / 2 8891 }; 8892 return { 8893 horizontal: toCenter.x - fromCenter.x, 8894 vertical: toCenter.y - fromCenter.y 8895 }; 8896 } 8897 function usePopupContentKey(activeTriggerId, payload) { 8898 const [contentKey, setContentKey] = React32.useState(0); 8899 const previousActiveTriggerIdRef = React32.useRef(activeTriggerId); 8900 const previousPayloadRef = React32.useRef(payload); 8901 const pendingPayloadUpdateRef = React32.useRef(false); 8902 useIsoLayoutEffect(() => { 8903 const previousActiveTriggerId = previousActiveTriggerIdRef.current; 8904 const previousPayload = previousPayloadRef.current; 8905 const triggerIdChanged = activeTriggerId !== previousActiveTriggerId; 8906 const payloadChanged = payload !== previousPayload; 8907 if (triggerIdChanged) { 8908 setContentKey((value) => value + 1); 8909 pendingPayloadUpdateRef.current = !payloadChanged; 8910 } else if (pendingPayloadUpdateRef.current && payloadChanged) { 8911 setContentKey((value) => value + 1); 8912 pendingPayloadUpdateRef.current = false; 8913 } 8914 previousActiveTriggerIdRef.current = activeTriggerId; 8915 previousPayloadRef.current = payload; 8916 }, [activeTriggerId, payload]); 8917 return `$activeTriggerId ?? "current"}-$contentKey}`; 8918 } 8919 8920 // node_modules/@base-ui/react/esm/utils/FloatingPortalLite.js 8921 var React33 = __toESM(require_react(), 1); 8922 var ReactDOM6 = __toESM(require_react_dom(), 1); 8923 var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1); 8924 var FloatingPortalLite = /* @__PURE__ */ React33.forwardRef(function FloatingPortalLite2(componentProps, forwardedRef) { 8925 const { 8926 children, 8927 container, 8928 className, 8929 render: render4, 8930 style, 8931 ...elementProps 8932 } = componentProps; 8933 const { 8934 portalNode, 8935 portalSubtree 8936 } = useFloatingPortalNode({ 8937 container, 8938 ref: forwardedRef, 8939 componentProps, 8940 elementProps 8941 }); 8942 if (!portalSubtree && !portalNode) { 8943 return null; 8944 } 8945 return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(React33.Fragment, { 8946 children: [portalSubtree, portalNode && /* @__PURE__ */ ReactDOM6.createPortal(children, portalNode)] 8947 }); 8948 }); 8949 if (true) FloatingPortalLite.displayName = "FloatingPortalLite"; 8950 8951 // node_modules/@base-ui/react/esm/tooltip/index.parts.js 8952 var index_parts_exports = {}; 8953 __export(index_parts_exports, { 8954 Arrow: () => TooltipArrow, 8955 Handle: () => TooltipHandle, 8956 Popup: () => TooltipPopup, 8957 Portal: () => TooltipPortal, 8958 Positioner: () => TooltipPositioner, 8959 Provider: () => TooltipProvider, 8960 Root: () => TooltipRoot, 8961 Trigger: () => TooltipTrigger, 8962 Viewport: () => TooltipViewport, 8963 createHandle: () => createTooltipHandle 8964 }); 8965 8966 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRoot.js 8967 var React36 = __toESM(require_react(), 1); 8968 8969 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRootContext.js 8970 var React34 = __toESM(require_react(), 1); 8971 var TooltipRootContext = /* @__PURE__ */ React34.createContext(void 0); 8972 if (true) TooltipRootContext.displayName = "TooltipRootContext"; 8973 function useTooltipRootContext(optional) { 8974 const context = React34.useContext(TooltipRootContext); 8975 if (context === void 0 && !optional) { 8976 throw new Error(true ? "Base UI: TooltipRootContext is missing. Tooltip parts must be placed within <Tooltip.Root>." : formatErrorMessage_default(72)); 8977 } 8978 return context; 8979 } 8980 8981 // node_modules/@base-ui/react/esm/tooltip/store/TooltipStore.js 8982 var React35 = __toESM(require_react(), 1); 8983 var ReactDOM7 = __toESM(require_react_dom(), 1); 8984 var selectors2 = { 8985 ...popupStoreSelectors, 8986 disabled: createSelector((state) => state.disabled), 8987 instantType: createSelector((state) => state.instantType), 8988 isInstantPhase: createSelector((state) => state.isInstantPhase), 8989 trackCursorAxis: createSelector((state) => state.trackCursorAxis), 8990 disableHoverablePopup: createSelector((state) => state.disableHoverablePopup), 8991 lastOpenChangeReason: createSelector((state) => state.openChangeReason), 8992 closeOnClick: createSelector((state) => state.closeOnClick), 8993 closeDelay: createSelector((state) => state.closeDelay), 8994 hasViewport: createSelector((state) => state.hasViewport) 8995 }; 8996 var TooltipStore = class _TooltipStore extends ReactStore { 8997 constructor(initialState, floatingId, nested = false) { 8998 const triggerElements = new PopupTriggerMap(); 8999 const state = { 9000 ...createInitialState(), 9001 ...initialState 9002 }; 9003 state.floatingRootContext = createPopupFloatingRootContext(triggerElements, floatingId, nested); 9004 super(state, { 9005 popupRef: /* @__PURE__ */ React35.createRef(), 9006 onOpenChange: void 0, 9007 onOpenChangeComplete: void 0, 9008 triggerElements 9009 }, selectors2); 9010 } 9011 setOpen = (nextOpen, eventDetails) => { 9012 const reason = eventDetails.reason; 9013 const isHover = reason === reason_parts_exports.triggerHover; 9014 const isFocusOpen = nextOpen && reason === reason_parts_exports.triggerFocus; 9015 const isDismissClose = !nextOpen && (reason === reason_parts_exports.triggerPress || reason === reason_parts_exports.escapeKey); 9016 eventDetails.preventUnmountOnClose = () => { 9017 this.set("preventUnmountingOnClose", true); 9018 }; 9019 this.context.onOpenChange?.(nextOpen, eventDetails); 9020 if (eventDetails.isCanceled) { 9021 return; 9022 } 9023 this.state.floatingRootContext.dispatchOpenChange(nextOpen, eventDetails); 9024 const changeState = () => { 9025 const updatedState = { 9026 open: nextOpen, 9027 openChangeReason: reason 9028 }; 9029 if (isFocusOpen) { 9030 updatedState.instantType = "focus"; 9031 } else if (isDismissClose) { 9032 updatedState.instantType = "dismiss"; 9033 } else if (reason === reason_parts_exports.triggerHover) { 9034 updatedState.instantType = void 0; 9035 } 9036 setOpenTriggerState(updatedState, nextOpen, eventDetails.trigger); 9037 this.update(updatedState); 9038 }; 9039 if (isHover) { 9040 ReactDOM7.flushSync(changeState); 9041 } else { 9042 changeState(); 9043 } 9044 }; 9045 // Used by trigger clicks to clear a delayed hover open without reporting a public open-state change. 9046 cancelPendingOpen(event) { 9047 this.state.floatingRootContext.dispatchOpenChange(false, createChangeEventDetails(reason_parts_exports.triggerPress, event)); 9048 } 9049 static useStore(externalStore, initialState) { 9050 const store = usePopupStore(externalStore, (floatingId, nested) => new _TooltipStore(initialState, floatingId, nested)).store; 9051 return store; 9052 } 9053 }; 9054 function createInitialState() { 9055 return { 9056 ...createInitialPopupStoreState(), 9057 disabled: false, 9058 instantType: void 0, 9059 isInstantPhase: false, 9060 trackCursorAxis: "none", 9061 disableHoverablePopup: false, 9062 openChangeReason: null, 9063 closeOnClick: true, 9064 closeDelay: 0, 9065 hasViewport: false 9066 }; 9067 } 9068 9069 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRoot.js 9070 var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1); 9071 var TooltipRoot = fastComponent(function TooltipRoot2(props) { 9072 const { 9073 disabled: disabled2 = false, 9074 defaultOpen = false, 9075 open: openProp, 9076 disableHoverablePopup = false, 9077 trackCursorAxis = "none", 9078 actionsRef, 9079 onOpenChange, 9080 onOpenChangeComplete, 9081 handle, 9082 triggerId: triggerIdProp, 9083 defaultTriggerId: defaultTriggerIdProp = null, 9084 children 9085 } = props; 9086 const store = TooltipStore.useStore(handle?.store, { 9087 open: defaultOpen, 9088 openProp, 9089 activeTriggerId: defaultTriggerIdProp, 9090 triggerIdProp 9091 }); 9092 useOnFirstRender(() => { 9093 if (openProp === void 0 && store.state.open === false && defaultOpen === true) { 9094 store.update({ 9095 open: true, 9096 activeTriggerId: defaultTriggerIdProp 9097 }); 9098 } 9099 }); 9100 store.useControlledProp("openProp", openProp); 9101 store.useControlledProp("triggerIdProp", triggerIdProp); 9102 store.useContextCallback("onOpenChange", onOpenChange); 9103 store.useContextCallback("onOpenChangeComplete", onOpenChangeComplete); 9104 const openState = store.useState("open"); 9105 const open = !disabled2 && openState; 9106 const activeTriggerId = store.useState("activeTriggerId"); 9107 const mounted = store.useState("mounted"); 9108 const payload = store.useState("payload"); 9109 store.useSyncedValues({ 9110 trackCursorAxis, 9111 disableHoverablePopup 9112 }); 9113 store.useSyncedValue("disabled", disabled2); 9114 useImplicitActiveTrigger(store); 9115 const { 9116 forceUnmount, 9117 transitionStatus 9118 } = useOpenStateTransitions(open, store); 9119 const isInstantPhase = store.useState("isInstantPhase"); 9120 const instantType = store.useState("instantType"); 9121 const lastOpenChangeReason = store.useState("lastOpenChangeReason"); 9122 const previousInstantTypeRef = React36.useRef(null); 9123 useIsoLayoutEffect(() => { 9124 if (openState && disabled2) { 9125 store.setOpen(false, createChangeEventDetails(reason_parts_exports.disabled)); 9126 } 9127 }, [openState, disabled2, store]); 9128 useIsoLayoutEffect(() => { 9129 if (transitionStatus === "ending" && lastOpenChangeReason === reason_parts_exports.none || transitionStatus !== "ending" && isInstantPhase) { 9130 if (instantType !== "delay") { 9131 previousInstantTypeRef.current = instantType; 9132 } 9133 store.set("instantType", "delay"); 9134 } else if (previousInstantTypeRef.current !== null) { 9135 store.set("instantType", previousInstantTypeRef.current); 9136 previousInstantTypeRef.current = null; 9137 } 9138 }, [transitionStatus, isInstantPhase, lastOpenChangeReason, instantType, store]); 9139 useIsoLayoutEffect(() => { 9140 if (open) { 9141 if (activeTriggerId == null) { 9142 store.set("payload", void 0); 9143 } 9144 } 9145 }, [store, activeTriggerId, open]); 9146 const handleImperativeClose = React36.useCallback(() => { 9147 store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction)); 9148 }, [store]); 9149 React36.useImperativeHandle(actionsRef, () => ({ 9150 unmount: forceUnmount, 9151 close: handleImperativeClose 9152 }), [forceUnmount, handleImperativeClose]); 9153 const shouldRenderInteractions = open || mounted || !disabled2 && trackCursorAxis !== "none"; 9154 return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(TooltipRootContext.Provider, { 9155 value: store, 9156 children: [shouldRenderInteractions && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(TooltipInteractions, { 9157 store, 9158 disabled: disabled2, 9159 trackCursorAxis 9160 }), typeof children === "function" ? children({ 9161 payload 9162 }) : children] 9163 }); 9164 }); 9165 if (true) TooltipRoot.displayName = "TooltipRoot"; 9166 function TooltipInteractions({ 9167 store, 9168 disabled: disabled2, 9169 trackCursorAxis 9170 }) { 9171 const floatingRootContext = store.useState("floatingRootContext"); 9172 const dismiss = useDismiss(floatingRootContext, { 9173 enabled: !disabled2, 9174 referencePress: () => store.select("closeOnClick") 9175 }); 9176 const clientPoint = useClientPoint(floatingRootContext, { 9177 enabled: !disabled2 && trackCursorAxis !== "none", 9178 axis: trackCursorAxis === "none" ? void 0 : trackCursorAxis 9179 }); 9180 const activeTriggerProps = React36.useMemo(() => mergeProps(clientPoint.reference, dismiss.reference), [clientPoint.reference, dismiss.reference]); 9181 const inactiveTriggerProps = React36.useMemo(() => mergeProps(clientPoint.trigger, dismiss.trigger), [clientPoint.trigger, dismiss.trigger]); 9182 const popupProps = React36.useMemo(() => mergeProps(FOCUSABLE_POPUP_PROPS, clientPoint.floating, dismiss.floating), [clientPoint.floating, dismiss.floating]); 9183 usePopupInteractionProps(store, { 9184 activeTriggerProps, 9185 inactiveTriggerProps, 9186 popupProps 9187 }); 9188 return null; 9189 } 9190 9191 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTrigger.js 9192 var React38 = __toESM(require_react(), 1); 9193 9194 // node_modules/@base-ui/react/esm/tooltip/provider/TooltipProviderContext.js 9195 var React37 = __toESM(require_react(), 1); 9196 var TooltipProviderContext = /* @__PURE__ */ React37.createContext(void 0); 9197 if (true) TooltipProviderContext.displayName = "TooltipProviderContext"; 9198 function useTooltipProviderContext() { 9199 return React37.useContext(TooltipProviderContext); 9200 } 9201 9202 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTriggerDataAttributes.js 9203 var TooltipTriggerDataAttributes = (function(TooltipTriggerDataAttributes2) { 9204 TooltipTriggerDataAttributes2[TooltipTriggerDataAttributes2["popupOpen"] = CommonTriggerDataAttributes.popupOpen] = "popupOpen"; 9205 TooltipTriggerDataAttributes2["triggerDisabled"] = "data-trigger-disabled"; 9206 return TooltipTriggerDataAttributes2; 9207 })({}); 9208 9209 // node_modules/@base-ui/react/esm/tooltip/utils/constants.js 9210 var OPEN_DELAY = 600; 9211 9212 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTrigger.js 9213 var TOOLTIP_TRIGGER_IDENTIFIER = "data-base-ui-tooltip-trigger"; 9214 function getTargetElement(event) { 9215 if ("composedPath" in event) { 9216 const path = event.composedPath(); 9217 for (let i2 = 0; i2 < path.length; i2 += 1) { 9218 const element = path[i2]; 9219 if (isElement(element)) { 9220 return element; 9221 } 9222 } 9223 } 9224 const target = event.target; 9225 if (isElement(target)) { 9226 return target; 9227 } 9228 return null; 9229 } 9230 function closestEnabledTooltipTrigger(element) { 9231 let current = element; 9232 while (current) { 9233 if (current.hasAttribute(TOOLTIP_TRIGGER_IDENTIFIER)) { 9234 return current; 9235 } 9236 const parentElement = current.parentElement; 9237 if (parentElement) { 9238 current = parentElement; 9239 continue; 9240 } 9241 const root = current.getRootNode(); 9242 current = "host" in root && isElement(root.host) ? root.host : null; 9243 } 9244 return null; 9245 } 9246 var TooltipTrigger = fastComponentRef(function TooltipTrigger2(componentProps, forwardedRef) { 9247 const { 9248 render: render4, 9249 className, 9250 style, 9251 handle, 9252 payload, 9253 disabled: disabledProp, 9254 delay, 9255 closeOnClick = true, 9256 closeDelay, 9257 id: idProp, 9258 ...elementProps 9259 } = componentProps; 9260 const rootContext = useTooltipRootContext(true); 9261 const store = handle?.store ?? rootContext; 9262 if (!store) { 9263 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)); 9264 } 9265 const thisTriggerId = useBaseUiId(idProp); 9266 const isTriggerActive = store.useState("isTriggerActive", thisTriggerId); 9267 const isOpenedByThisTrigger = store.useState("isOpenedByTrigger", thisTriggerId); 9268 const floatingRootContext = store.useState("floatingRootContext"); 9269 const triggerElementRef = React38.useRef(null); 9270 const delayWithDefault = delay ?? OPEN_DELAY; 9271 const closeDelayWithDefault = closeDelay ?? 0; 9272 const { 9273 registerTrigger, 9274 isMountedByThisTrigger 9275 } = useTriggerDataForwarding(thisTriggerId, triggerElementRef, store, { 9276 payload, 9277 closeOnClick, 9278 closeDelay: closeDelayWithDefault 9279 }); 9280 const providerContext = useTooltipProviderContext(); 9281 const { 9282 delayRef, 9283 isInstantPhase, 9284 hasProvider 9285 } = useDelayGroup(floatingRootContext, { 9286 open: isOpenedByThisTrigger 9287 }); 9288 const hoverInteraction = useHoverInteractionSharedState(floatingRootContext); 9289 store.useSyncedValue("isInstantPhase", isInstantPhase); 9290 const rootDisabled = store.useState("disabled"); 9291 const disabled2 = disabledProp ?? rootDisabled; 9292 const disabledRef = useValueAsRef(disabled2); 9293 const trackCursorAxis = store.useState("trackCursorAxis"); 9294 const disableHoverablePopup = store.useState("disableHoverablePopup"); 9295 const isNestedTriggerHoveredRef = React38.useRef(false); 9296 const nestedTriggerOpenTimeout = useTimeout(); 9297 const pointerTypeRef = React38.useRef(void 0); 9298 function getOpenDelay() { 9299 const providerDelay = providerContext?.delay; 9300 const groupOpenValue = typeof delayRef.current === "object" ? delayRef.current.open : void 0; 9301 let computedOpenDelay = delayWithDefault; 9302 if (hasProvider) { 9303 if (groupOpenValue !== 0) { 9304 computedOpenDelay = delay ?? providerDelay ?? delayWithDefault; 9305 } else { 9306 computedOpenDelay = 0; 9307 } 9308 } 9309 return computedOpenDelay; 9310 } 9311 function isEnabledNestedTriggerTarget(target) { 9312 const triggerEl = triggerElementRef.current; 9313 if (!triggerEl || !target) { 9314 return false; 9315 } 9316 const nearestTrigger = closestEnabledTooltipTrigger(target); 9317 return nearestTrigger !== null && nearestTrigger !== triggerEl && contains(triggerEl, nearestTrigger); 9318 } 9319 function detectNestedTriggerHover(target) { 9320 const nestedTriggerHovered = isEnabledNestedTriggerTarget(target); 9321 isNestedTriggerHoveredRef.current = nestedTriggerHovered; 9322 if (nestedTriggerHovered) { 9323 hoverInteraction.openChangeTimeout.clear(); 9324 hoverInteraction.restTimeout.clear(); 9325 hoverInteraction.restTimeoutPending = false; 9326 nestedTriggerOpenTimeout.clear(); 9327 } 9328 return nestedTriggerHovered; 9329 } 9330 const hoverProps = useHoverReferenceInteraction(floatingRootContext, { 9331 enabled: !disabled2, 9332 mouseOnly: true, 9333 move: false, 9334 handleClose: !disableHoverablePopup && trackCursorAxis !== "both" ? safePolygon() : null, 9335 restMs: getOpenDelay, 9336 delay() { 9337 const closeValue = typeof delayRef.current === "object" ? delayRef.current.close : void 0; 9338 let computedCloseDelay = closeDelayWithDefault; 9339 if (closeDelay == null && hasProvider) { 9340 computedCloseDelay = closeValue; 9341 } 9342 return { 9343 close: computedCloseDelay 9344 }; 9345 }, 9346 triggerElementRef, 9347 isActiveTrigger: isTriggerActive, 9348 isClosing: () => store.select("transitionStatus") === "ending", 9349 shouldOpen() { 9350 return !isNestedTriggerHoveredRef.current; 9351 } 9352 }); 9353 const focusProps = useFocus(floatingRootContext, { 9354 enabled: !disabled2 9355 }).reference; 9356 const handleNestedTriggerHover = (event) => { 9357 const wasNestedTriggerHovered = isNestedTriggerHoveredRef.current; 9358 const target = getTargetElement(event); 9359 const nestedTriggerHovered = detectNestedTriggerHover(target); 9360 const triggerEl = triggerElementRef.current; 9361 const targetInsideTrigger = triggerEl && target && contains(triggerEl, target); 9362 if (nestedTriggerHovered && store.select("open") && store.select("lastOpenChangeReason") === reason_parts_exports.triggerHover) { 9363 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event)); 9364 return; 9365 } 9366 if (wasNestedTriggerHovered && !nestedTriggerHovered && targetInsideTrigger && !disabledRef.current && !store.select("open") && triggerEl && // Match the hover hook's non-strict mouse fallback for mouse-only event sequences. 9367 isMouseLikePointerType(pointerTypeRef.current)) { 9368 const open = () => { 9369 if (!isNestedTriggerHoveredRef.current && !disabledRef.current && !store.select("open")) { 9370 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerEl)); 9371 } 9372 }; 9373 const openDelay = getOpenDelay(); 9374 if (openDelay === 0) { 9375 nestedTriggerOpenTimeout.clear(); 9376 open(); 9377 } else { 9378 nestedTriggerOpenTimeout.start(openDelay, open); 9379 } 9380 } 9381 }; 9382 const rootTriggerProps = store.useState("triggerProps", isMountedByThisTrigger); 9383 const shouldApplyRootTriggerProps = isMountedByThisTrigger || trackCursorAxis !== "none"; 9384 const state = { 9385 open: isOpenedByThisTrigger 9386 }; 9387 const element = useRenderElement("button", componentProps, { 9388 state, 9389 ref: [forwardedRef, registerTrigger, triggerElementRef], 9390 props: [hoverProps, focusProps, shouldApplyRootTriggerProps ? rootTriggerProps : void 0, { 9391 onMouseOver(event) { 9392 handleNestedTriggerHover(event.nativeEvent); 9393 }, 9394 onFocus(event) { 9395 if (isEnabledNestedTriggerTarget(getTargetElement(event.nativeEvent))) { 9396 event.preventBaseUIHandler(); 9397 } 9398 }, 9399 onMouseLeave() { 9400 isNestedTriggerHoveredRef.current = false; 9401 nestedTriggerOpenTimeout.clear(); 9402 pointerTypeRef.current = void 0; 9403 }, 9404 onPointerEnter(event) { 9405 pointerTypeRef.current = event.pointerType; 9406 }, 9407 onPointerDown(event) { 9408 pointerTypeRef.current = event.pointerType; 9409 store.set("closeOnClick", closeOnClick); 9410 if (closeOnClick && !store.select("open")) { 9411 store.cancelPendingOpen(event.nativeEvent); 9412 } 9413 }, 9414 onClick(event) { 9415 if (closeOnClick && !store.select("open")) { 9416 store.cancelPendingOpen(event.nativeEvent); 9417 } 9418 }, 9419 id: thisTriggerId, 9420 [TooltipTriggerDataAttributes.triggerDisabled]: disabled2 ? "" : void 0, 9421 [TOOLTIP_TRIGGER_IDENTIFIER]: disabled2 ? void 0 : "" 9422 }, elementProps], 9423 stateAttributesMapping: triggerOpenStateMapping 9424 }); 9425 return element; 9426 }); 9427 if (true) TooltipTrigger.displayName = "TooltipTrigger"; 9428 9429 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortal.js 9430 var React40 = __toESM(require_react(), 1); 9431 9432 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortalContext.js 9433 var React39 = __toESM(require_react(), 1); 9434 var TooltipPortalContext = /* @__PURE__ */ React39.createContext(void 0); 9435 if (true) TooltipPortalContext.displayName = "TooltipPortalContext"; 9436 function useTooltipPortalContext() { 9437 const value = React39.useContext(TooltipPortalContext); 9438 if (value === void 0) { 9439 throw new Error(true ? "Base UI: <Tooltip.Portal> is missing." : formatErrorMessage_default(70)); 9440 } 9441 return value; 9442 } 9443 9444 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortal.js 9445 var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1); 9446 var TooltipPortal = /* @__PURE__ */ React40.forwardRef(function TooltipPortal2(props, forwardedRef) { 9447 const { 9448 keepMounted = false, 9449 ...portalProps 9450 } = props; 9451 const store = useTooltipRootContext(); 9452 const mounted = store.useState("mounted"); 9453 const shouldRender = mounted || keepMounted; 9454 if (!shouldRender) { 9455 return null; 9456 } 9457 return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(TooltipPortalContext.Provider, { 9458 value: keepMounted, 9459 children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(FloatingPortalLite, { 9460 ref: forwardedRef, 9461 ...portalProps 9462 }) 9463 }); 9464 }); 9465 if (true) TooltipPortal.displayName = "TooltipPortal"; 9466 9467 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositioner.js 9468 var React42 = __toESM(require_react(), 1); 9469 9470 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositionerContext.js 9471 var React41 = __toESM(require_react(), 1); 9472 var TooltipPositionerContext = /* @__PURE__ */ React41.createContext(void 0); 9473 if (true) TooltipPositionerContext.displayName = "TooltipPositionerContext"; 9474 function useTooltipPositionerContext() { 9475 const context = React41.useContext(TooltipPositionerContext); 9476 if (context === void 0) { 9477 throw new Error(true ? "Base UI: TooltipPositionerContext is missing. TooltipPositioner parts must be placed within <Tooltip.Positioner>." : formatErrorMessage_default(71)); 9478 } 9479 return context; 9480 } 9481 9482 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositioner.js 9483 var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1); 9484 var TooltipPositioner = /* @__PURE__ */ React42.forwardRef(function TooltipPositioner2(componentProps, forwardedRef) { 9485 const { 9486 render: render4, 9487 className, 9488 anchor, 9489 positionMethod = "absolute", 9490 side = "top", 9491 align = "center", 9492 sideOffset = 0, 9493 alignOffset = 0, 9494 collisionBoundary = "clipping-ancestors", 9495 collisionPadding = 5, 9496 arrowPadding = 5, 9497 sticky = false, 9498 disableAnchorTracking = false, 9499 collisionAvoidance = POPUP_COLLISION_AVOIDANCE, 9500 style, 9501 ...elementProps 9502 } = componentProps; 9503 const store = useTooltipRootContext(); 9504 const keepMounted = useTooltipPortalContext(); 9505 const open = store.useState("open"); 9506 const mounted = store.useState("mounted"); 9507 const trackCursorAxis = store.useState("trackCursorAxis"); 9508 const disableHoverablePopup = store.useState("disableHoverablePopup"); 9509 const floatingRootContext = store.useState("floatingRootContext"); 9510 const instantType = store.useState("instantType"); 9511 const transitionStatus = store.useState("transitionStatus"); 9512 const hasViewport = store.useState("hasViewport"); 9513 const positioning = useAnchorPositioning({ 9514 anchor, 9515 positionMethod, 9516 floatingRootContext, 9517 mounted, 9518 side, 9519 sideOffset, 9520 align, 9521 alignOffset, 9522 collisionBoundary, 9523 collisionPadding, 9524 sticky, 9525 arrowPadding, 9526 disableAnchorTracking, 9527 keepMounted, 9528 collisionAvoidance, 9529 adaptiveOrigin: hasViewport ? adaptiveOrigin : void 0 9530 }); 9531 const state = React42.useMemo(() => ({ 9532 open, 9533 side: positioning.side, 9534 align: positioning.align, 9535 anchorHidden: positioning.anchorHidden, 9536 instant: trackCursorAxis !== "none" ? "tracking-cursor" : instantType 9537 }), [open, positioning.side, positioning.align, positioning.anchorHidden, trackCursorAxis, instantType]); 9538 const element = usePositioner(componentProps, state, { 9539 styles: positioning.positionerStyles, 9540 transitionStatus, 9541 props: elementProps, 9542 refs: [forwardedRef, store.useStateSetter("positionerElement")], 9543 hidden: !mounted, 9544 inert: !open || trackCursorAxis === "both" || disableHoverablePopup 9545 }); 9546 return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(TooltipPositionerContext.Provider, { 9547 value: positioning, 9548 children: element 9549 }); 9550 }); 9551 if (true) TooltipPositioner.displayName = "TooltipPositioner"; 9552 9553 // node_modules/@base-ui/react/esm/tooltip/popup/TooltipPopup.js 9554 var React43 = __toESM(require_react(), 1); 9555 var stateAttributesMapping = { 9556 ...popupStateMapping, 9557 ...transitionStatusMapping 9558 }; 9559 var TooltipPopup = /* @__PURE__ */ React43.forwardRef(function TooltipPopup2(componentProps, forwardedRef) { 9560 const { 9561 render: render4, 9562 className, 9563 style, 9564 ...elementProps 9565 } = componentProps; 9566 const store = useTooltipRootContext(); 9567 const { 9568 side, 9569 align 9570 } = useTooltipPositionerContext(); 9571 const open = store.useState("open"); 9572 const instantType = store.useState("instantType"); 9573 const transitionStatus = store.useState("transitionStatus"); 9574 const popupProps = store.useState("popupProps"); 9575 const floatingContext = store.useState("floatingRootContext"); 9576 const disabled2 = store.useState("disabled"); 9577 const closeDelay = store.useState("closeDelay"); 9578 useOpenChangeComplete({ 9579 open, 9580 ref: store.context.popupRef, 9581 onComplete() { 9582 if (open) { 9583 store.context.onOpenChangeComplete?.(true); 9584 } 9585 } 9586 }); 9587 useHoverFloatingInteraction(floatingContext, { 9588 enabled: !disabled2, 9589 closeDelay 9590 }); 9591 const setPopupElement = store.useStateSetter("popupElement"); 9592 const state = { 9593 open, 9594 side, 9595 align, 9596 instant: instantType, 9597 transitionStatus 9598 }; 9599 const element = useRenderElement("div", componentProps, { 9600 state, 9601 ref: [forwardedRef, store.context.popupRef, setPopupElement], 9602 props: [popupProps, getDisabledMountTransitionStyles(transitionStatus), elementProps], 9603 stateAttributesMapping 9604 }); 9605 return element; 9606 }); 9607 if (true) TooltipPopup.displayName = "TooltipPopup"; 9608 9609 // node_modules/@base-ui/react/esm/tooltip/arrow/TooltipArrow.js 9610 var React44 = __toESM(require_react(), 1); 9611 var TooltipArrow = /* @__PURE__ */ React44.forwardRef(function TooltipArrow2(componentProps, forwardedRef) { 9612 const { 9613 render: render4, 9614 className, 9615 style, 9616 ...elementProps 9617 } = componentProps; 9618 const store = useTooltipRootContext(); 9619 const { 9620 arrowRef, 9621 side, 9622 align, 9623 arrowUncentered, 9624 arrowStyles 9625 } = useTooltipPositionerContext(); 9626 const open = store.useState("open"); 9627 const instantType = store.useState("instantType"); 9628 const state = { 9629 open, 9630 side, 9631 align, 9632 uncentered: arrowUncentered, 9633 instant: instantType 9634 }; 9635 const element = useRenderElement("div", componentProps, { 9636 state, 9637 ref: [forwardedRef, arrowRef], 9638 props: [{ 9639 style: arrowStyles, 9640 "aria-hidden": true 9641 }, elementProps], 9642 stateAttributesMapping: popupStateMapping 9643 }); 9644 return element; 9645 }); 9646 if (true) TooltipArrow.displayName = "TooltipArrow"; 9647 9648 // node_modules/@base-ui/react/esm/tooltip/provider/TooltipProvider.js 9649 var React45 = __toESM(require_react(), 1); 9650 var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1); 9651 var TooltipProvider = function TooltipProvider2(props) { 9652 const { 9653 delay, 9654 closeDelay, 9655 timeout = 400 9656 } = props; 9657 const contextValue = React45.useMemo(() => ({ 9658 delay, 9659 closeDelay 9660 }), [delay, closeDelay]); 9661 const delayValue = React45.useMemo(() => ({ 9662 open: delay, 9663 close: closeDelay 9664 }), [delay, closeDelay]); 9665 return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(TooltipProviderContext.Provider, { 9666 value: contextValue, 9667 children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(FloatingDelayGroup, { 9668 delay: delayValue, 9669 timeoutMs: timeout, 9670 children: props.children 9671 }) 9672 }); 9673 }; 9674 if (true) TooltipProvider.displayName = "TooltipProvider"; 9675 9676 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewport.js 9677 var React46 = __toESM(require_react(), 1); 9678 9679 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewportCssVars.js 9680 var TooltipViewportCssVars = /* @__PURE__ */ (function(TooltipViewportCssVars2) { 9681 TooltipViewportCssVars2["popupWidth"] = "--popup-width"; 9682 TooltipViewportCssVars2["popupHeight"] = "--popup-height"; 9683 return TooltipViewportCssVars2; 9684 })({}); 9685 9686 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewport.js 9687 var stateAttributesMapping2 = { 9688 activationDirection: (value) => value ? { 9689 "data-activation-direction": value 9690 } : null 9691 }; 9692 var TooltipViewport = /* @__PURE__ */ React46.forwardRef(function TooltipViewport2(componentProps, forwardedRef) { 9693 const { 9694 render: render4, 9695 className, 9696 style, 9697 children, 9698 ...elementProps 9699 } = componentProps; 9700 const store = useTooltipRootContext(); 9701 const positioner = useTooltipPositionerContext(); 9702 const instantType = store.useState("instantType"); 9703 const { 9704 children: childrenToRender, 9705 state: viewportState 9706 } = usePopupViewport({ 9707 store, 9708 side: positioner.side, 9709 cssVars: TooltipViewportCssVars, 9710 children 9711 }); 9712 const state = { 9713 activationDirection: viewportState.activationDirection, 9714 transitioning: viewportState.transitioning, 9715 instant: instantType 9716 }; 9717 return useRenderElement("div", componentProps, { 9718 state, 9719 ref: forwardedRef, 9720 props: [elementProps, { 9721 children: childrenToRender 9722 }], 9723 stateAttributesMapping: stateAttributesMapping2 9724 }); 9725 }); 9726 if (true) TooltipViewport.displayName = "TooltipViewport"; 9727 9728 // node_modules/@base-ui/react/esm/tooltip/store/TooltipHandle.js 9729 var TooltipHandle = class { 9730 /** 9731 * Internal store holding the tooltip state. 9732 * @internal 9733 */ 9734 constructor() { 9735 this.store = new TooltipStore(); 9736 } 9737 /** 9738 * Opens the tooltip and associates it with the trigger with the given ID. 9739 * The trigger must be a Tooltip.Trigger component with this handle passed as a prop. 9740 * 9741 * This method should only be called in an event handler or an effect (not during rendering). 9742 * 9743 * @param triggerId ID of the trigger to associate with the tooltip. 9744 */ 9745 open(triggerId) { 9746 const triggerElement = triggerId ? this.store.context.triggerElements.getById(triggerId) : void 0; 9747 if (triggerId && !triggerElement) { 9748 throw new Error(true ? `Base UI: TooltipHandle.open: No trigger found with id "$triggerId}".` : formatErrorMessage_default(81, triggerId)); 9749 } 9750 this.store.setOpen(true, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, triggerElement)); 9751 } 9752 /** 9753 * Closes the tooltip. 9754 */ 9755 close() { 9756 this.store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, void 0)); 9757 } 9758 /** 9759 * Indicates whether the tooltip is currently open. 9760 */ 9761 get isOpen() { 9762 return this.store.select("open"); 9763 } 9764 }; 9765 function createTooltipHandle() { 9766 return new TooltipHandle(); 9767 } 9768 9769 // node_modules/@base-ui/react/esm/use-render/useRender.js 9770 function useRender(params) { 9771 return useRenderElement(params.defaultTagName ?? "div", params, params); 9772 } 9773 9774 // packages/ui/build-module/utils/render-slot-with-children.mjs 9775 var import_element11 = __toESM(require_element(), 1); 9776 function renderSlotWithChildren(slot, defaultSlot, children) { 9777 return (0, import_element11.cloneElement)(slot ?? defaultSlot, { children }); 9778 } 9779 9780 // packages/ui/build-module/lock-unlock.mjs 9781 var import_private_apis = __toESM(require_private_apis(), 1); 9782 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)( 9783 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.", 9784 "@wordpress/ui" 9785 ); 9786 9787 // packages/ui/build-module/stack/stack.mjs 9788 var import_element12 = __toESM(require_element(), 1); 9789 var STYLE_HASH_ATTRIBUTE = "data-wp-hash"; 9790 function getRuntime() { 9791 const globalScope = globalThis; 9792 if (globalScope.__wpStyleRuntime) { 9793 return globalScope.__wpStyleRuntime; 9794 } 9795 globalScope.__wpStyleRuntime = { 9796 documents: /* @__PURE__ */ new Map(), 9797 styles: /* @__PURE__ */ new Map(), 9798 injectedStyles: /* @__PURE__ */ new WeakMap() 9799 }; 9800 if (typeof document !== "undefined") { 9801 registerDocument(document); 9802 } 9803 return globalScope.__wpStyleRuntime; 9804 } 9805 function documentContainsStyleHash(targetDocument, hash) { 9806 if (!targetDocument.head) { 9807 return false; 9808 } 9809 for (const style of targetDocument.head.querySelectorAll( 9810 `style[$STYLE_HASH_ATTRIBUTE}]` 9811 )) { 9812 if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) { 9813 return true; 9814 } 9815 } 9816 return false; 9817 } 9818 function injectStyle(targetDocument, hash, css) { 9819 if (!targetDocument.head) { 9820 return; 9821 } 9822 const runtime = getRuntime(); 9823 let injectedStyles = runtime.injectedStyles.get(targetDocument); 9824 if (!injectedStyles) { 9825 injectedStyles = /* @__PURE__ */ new Set(); 9826 runtime.injectedStyles.set(targetDocument, injectedStyles); 9827 } 9828 if (injectedStyles.has(hash)) { 9829 return; 9830 } 9831 if (documentContainsStyleHash(targetDocument, hash)) { 9832 injectedStyles.add(hash); 9833 return; 9834 } 9835 const style = targetDocument.createElement("style"); 9836 style.setAttribute(STYLE_HASH_ATTRIBUTE, hash); 9837 style.appendChild(targetDocument.createTextNode(css)); 9838 targetDocument.head.appendChild(style); 9839 injectedStyles.add(hash); 9840 } 9841 function registerDocument(targetDocument) { 9842 const runtime = getRuntime(); 9843 runtime.documents.set( 9844 targetDocument, 9845 (runtime.documents.get(targetDocument) ?? 0) + 1 9846 ); 9847 for (const [hash, css] of runtime.styles) { 9848 injectStyle(targetDocument, hash, css); 9849 } 9850 return () => { 9851 const count = runtime.documents.get(targetDocument); 9852 if (count === void 0) { 9853 return; 9854 } 9855 if (count <= 1) { 9856 runtime.documents.delete(targetDocument); 9857 return; 9858 } 9859 runtime.documents.set(targetDocument, count - 1); 9860 }; 9861 } 9862 function registerStyle(hash, css) { 9863 const runtime = getRuntime(); 9864 runtime.styles.set(hash, css); 9865 for (const targetDocument of runtime.documents.keys()) { 9866 injectStyle(targetDocument, hash, css); 9867 } 9868 } 9869 if (typeof process === "undefined" || true) { 9870 registerStyle("32aba35fe1", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._19ce0419607e1896__stack{display:flex}}}"); 9871 } 9872 var style_default = { "stack": "_19ce0419607e1896__stack" }; 9873 var gapTokens = { 9874 xs: "var(--wpds-dimension-gap-xs, 4px)", 9875 sm: "var(--wpds-dimension-gap-sm, 8px)", 9876 md: "var(--wpds-dimension-gap-md, 12px)", 9877 lg: "var(--wpds-dimension-gap-lg, 16px)", 9878 xl: "var(--wpds-dimension-gap-xl, 24px)", 9879 "2xl": "var(--wpds-dimension-gap-2xl, 32px)", 9880 "3xl": "var(--wpds-dimension-gap-3xl, 40px)" 9881 }; 9882 var Stack = (0, import_element12.forwardRef)(function Stack2({ direction, gap, align, justify, wrap, render: render4, ...props }, ref) { 9883 const style = { 9884 gap: gap && gapTokens[gap], 9885 alignItems: align, 9886 justifyContent: justify, 9887 flexDirection: direction, 9888 flexWrap: wrap 9889 }; 9890 const element = useRender({ 9891 render: render4, 9892 ref, 9893 props: mergeProps(props, { style, className: style_default.stack }) 9894 }); 9895 return element; 9896 }); 9897 9898 // packages/ui/build-module/tooltip/index.mjs 9899 var tooltip_exports = {}; 9900 __export(tooltip_exports, { 9901 Popup: () => Popup, 9902 Portal: () => Portal, 9903 Positioner: () => Positioner, 9904 Provider: () => Provider, 9905 Root: () => Root, 9906 Trigger: () => Trigger 9907 }); 9908 9909 // packages/ui/build-module/tooltip/popup.mjs 9910 var import_element15 = __toESM(require_element(), 1); 9911 var import_theme = __toESM(require_theme(), 1); 9912 9913 // packages/ui/build-module/tooltip/portal.mjs 9914 var import_element13 = __toESM(require_element(), 1); 9915 9916 // packages/ui/build-module/utils/wp-compat-overlay-slot.mjs 9917 var STYLE_HASH_ATTRIBUTE2 = "data-wp-hash"; 9918 function getRuntime2() { 9919 const globalScope = globalThis; 9920 if (globalScope.__wpStyleRuntime) { 9921 return globalScope.__wpStyleRuntime; 9922 } 9923 globalScope.__wpStyleRuntime = { 9924 documents: /* @__PURE__ */ new Map(), 9925 styles: /* @__PURE__ */ new Map(), 9926 injectedStyles: /* @__PURE__ */ new WeakMap() 9927 }; 9928 if (typeof document !== "undefined") { 9929 registerDocument2(document); 9930 } 9931 return globalScope.__wpStyleRuntime; 9932 } 9933 function documentContainsStyleHash2(targetDocument, hash) { 9934 if (!targetDocument.head) { 9935 return false; 9936 } 9937 for (const style of targetDocument.head.querySelectorAll( 9938 `style[$STYLE_HASH_ATTRIBUTE2}]` 9939 )) { 9940 if (style.getAttribute(STYLE_HASH_ATTRIBUTE2) === hash) { 9941 return true; 9942 } 9943 } 9944 return false; 9945 } 9946 function injectStyle2(targetDocument, hash, css) { 9947 if (!targetDocument.head) { 9948 return; 9949 } 9950 const runtime = getRuntime2(); 9951 let injectedStyles = runtime.injectedStyles.get(targetDocument); 9952 if (!injectedStyles) { 9953 injectedStyles = /* @__PURE__ */ new Set(); 9954 runtime.injectedStyles.set(targetDocument, injectedStyles); 9955 } 9956 if (injectedStyles.has(hash)) { 9957 return; 9958 } 9959 if (documentContainsStyleHash2(targetDocument, hash)) { 9960 injectedStyles.add(hash); 9961 return; 9962 } 9963 const style = targetDocument.createElement("style"); 9964 style.setAttribute(STYLE_HASH_ATTRIBUTE2, hash); 9965 style.appendChild(targetDocument.createTextNode(css)); 9966 targetDocument.head.appendChild(style); 9967 injectedStyles.add(hash); 9968 } 9969 function registerDocument2(targetDocument) { 9970 const runtime = getRuntime2(); 9971 runtime.documents.set( 9972 targetDocument, 9973 (runtime.documents.get(targetDocument) ?? 0) + 1 9974 ); 9975 for (const [hash, css] of runtime.styles) { 9976 injectStyle2(targetDocument, hash, css); 9977 } 9978 return () => { 9979 const count = runtime.documents.get(targetDocument); 9980 if (count === void 0) { 9981 return; 9982 } 9983 if (count <= 1) { 9984 runtime.documents.delete(targetDocument); 9985 return; 9986 } 9987 runtime.documents.set(targetDocument, count - 1); 9988 }; 9989 } 9990 function registerStyle2(hash, css) { 9991 const runtime = getRuntime2(); 9992 runtime.styles.set(hash, css); 9993 for (const targetDocument of runtime.documents.keys()) { 9994 injectStyle2(targetDocument, hash, css); 9995 } 9996 } 9997 if (typeof process === "undefined" || true) { 9998 registerStyle2("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}}}"); 9999 } 10000 var wp_compat_overlay_slot_default = { "slot": "_11fc52b637ff8a7e__slot" }; 10001 var WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE = "data-wp-compat-overlay-slot"; 10002 function resolveOwnerDocument() { 10003 return typeof document === "undefined" ? null : document; 10004 } 10005 function isInWordPressEnvironment() { 10006 let topWp; 10007 try { 10008 topWp = window.top?.wp; 10009 } catch { 10010 } 10011 const wp = topWp ?? window.wp; 10012 return typeof wp?.components === "object" && wp.components !== null; 10013 } 10014 var cachedSlot = null; 10015 function createSlot(ownerDocument2) { 10016 const element = ownerDocument2.createElement("div"); 10017 element.setAttribute(WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE, ""); 10018 if (wp_compat_overlay_slot_default.slot) { 10019 element.classList.add(wp_compat_overlay_slot_default.slot); 10020 } 10021 ownerDocument2.body.appendChild(element); 10022 return element; 10023 } 10024 function getWpCompatOverlaySlot() { 10025 if (typeof window === "undefined") { 10026 return void 0; 10027 } 10028 if (!isInWordPressEnvironment() && window.__wpUiCompatOverlaySlotEnabled !== true) { 10029 return void 0; 10030 } 10031 const ownerDocument2 = resolveOwnerDocument(); 10032 if (!ownerDocument2 || !ownerDocument2.body) { 10033 return void 0; 10034 } 10035 if (cachedSlot && cachedSlot.ownerDocument === ownerDocument2 && cachedSlot.isConnected) { 10036 return cachedSlot; 10037 } 10038 const existing = ownerDocument2.querySelector( 10039 `[$WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE}]` 10040 ); 10041 if (existing instanceof HTMLDivElement) { 10042 cachedSlot = existing; 10043 return existing; 10044 } 10045 if (cachedSlot?.isConnected) { 10046 cachedSlot.remove(); 10047 } 10048 cachedSlot = createSlot(ownerDocument2); 10049 return cachedSlot; 10050 } 10051 10052 // packages/ui/build-module/tooltip/portal.mjs 10053 var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1); 10054 var Portal = (0, import_element13.forwardRef)( 10055 function TooltipPortal3({ container, ...restProps }, ref) { 10056 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)( 10057 index_parts_exports.Portal, 10058 { 10059 container: container ?? getWpCompatOverlaySlot(), 10060 ...restProps, 10061 ref 10062 } 10063 ); 10064 } 10065 ); 10066 10067 // packages/ui/build-module/tooltip/positioner.mjs 10068 var import_element14 = __toESM(require_element(), 1); 10069 var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1); 10070 var STYLE_HASH_ATTRIBUTE3 = "data-wp-hash"; 10071 function getRuntime3() { 10072 const globalScope = globalThis; 10073 if (globalScope.__wpStyleRuntime) { 10074 return globalScope.__wpStyleRuntime; 10075 } 10076 globalScope.__wpStyleRuntime = { 10077 documents: /* @__PURE__ */ new Map(), 10078 styles: /* @__PURE__ */ new Map(), 10079 injectedStyles: /* @__PURE__ */ new WeakMap() 10080 }; 10081 if (typeof document !== "undefined") { 10082 registerDocument3(document); 10083 } 10084 return globalScope.__wpStyleRuntime; 10085 } 10086 function documentContainsStyleHash3(targetDocument, hash) { 10087 if (!targetDocument.head) { 10088 return false; 10089 } 10090 for (const style of targetDocument.head.querySelectorAll( 10091 `style[$STYLE_HASH_ATTRIBUTE3}]` 10092 )) { 10093 if (style.getAttribute(STYLE_HASH_ATTRIBUTE3) === hash) { 10094 return true; 10095 } 10096 } 10097 return false; 10098 } 10099 function injectStyle3(targetDocument, hash, css) { 10100 if (!targetDocument.head) { 10101 return; 10102 } 10103 const runtime = getRuntime3(); 10104 let injectedStyles = runtime.injectedStyles.get(targetDocument); 10105 if (!injectedStyles) { 10106 injectedStyles = /* @__PURE__ */ new Set(); 10107 runtime.injectedStyles.set(targetDocument, injectedStyles); 10108 } 10109 if (injectedStyles.has(hash)) { 10110 return; 10111 } 10112 if (documentContainsStyleHash3(targetDocument, hash)) { 10113 injectedStyles.add(hash); 10114 return; 10115 } 10116 const style = targetDocument.createElement("style"); 10117 style.setAttribute(STYLE_HASH_ATTRIBUTE3, hash); 10118 style.appendChild(targetDocument.createTextNode(css)); 10119 targetDocument.head.appendChild(style); 10120 injectedStyles.add(hash); 10121 } 10122 function registerDocument3(targetDocument) { 10123 const runtime = getRuntime3(); 10124 runtime.documents.set( 10125 targetDocument, 10126 (runtime.documents.get(targetDocument) ?? 0) + 1 10127 ); 10128 for (const [hash, css] of runtime.styles) { 10129 injectStyle3(targetDocument, hash, css); 10130 } 10131 return () => { 10132 const count = runtime.documents.get(targetDocument); 10133 if (count === void 0) { 10134 return; 10135 } 10136 if (count <= 1) { 10137 runtime.documents.delete(targetDocument); 10138 return; 10139 } 10140 runtime.documents.set(targetDocument, count - 1); 10141 }; 10142 } 10143 function registerStyle3(hash, css) { 10144 const runtime = getRuntime3(); 10145 runtime.styles.set(hash, css); 10146 for (const targetDocument of runtime.documents.keys()) { 10147 injectStyle3(targetDocument, hash, css); 10148 } 10149 } 10150 if (typeof process === "undefined" || true) { 10151 registerStyle3("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}"); 10152 } 10153 var resets_default = { "box-sizing": "_336cd3e4e743482f__box-sizing" }; 10154 if (typeof process === "undefined" || true) { 10155 registerStyle3("4811d023d1", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-md,4px);box-shadow:var(--wpds-elevation-sm,0 1px 2px 0 #0000000d,0 2px 3px 0 #0000000a,0 6px 6px 0 #00000008,0 8px 8px 0 #00000005);color:var(--wpds-color-fg-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-sm,12px);line-height:1.4;padding:var(--wpds-dimension-padding-xs,4px) var(--wpds-dimension-padding-sm,8px);@media (forced-colors:active){border-bottom-color:CanvasText;border-bottom-style:solid;border-bottom-width:1px;border-left-color:CanvasText;border-left-style:solid;border-left-width:1px;border-right-color:CanvasText;border-right-style:solid;border-right-width:1px;border-top-color:CanvasText;border-top-style:solid;border-top-width:1px}}}}'); 10156 } 10157 var style_default2 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" }; 10158 var Positioner = (0, import_element14.forwardRef)( 10159 function TooltipPositioner3({ align = "center", className, side = "top", sideOffset = 4, ...props }, ref) { 10160 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)( 10161 index_parts_exports.Positioner, 10162 { 10163 ref, 10164 align, 10165 side, 10166 sideOffset, 10167 ...props, 10168 className: clsx_default( 10169 resets_default["box-sizing"], 10170 style_default2.positioner, 10171 className 10172 ) 10173 } 10174 ); 10175 } 10176 ); 10177 10178 // packages/ui/build-module/tooltip/popup.mjs 10179 var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1); 10180 var STYLE_HASH_ATTRIBUTE4 = "data-wp-hash"; 10181 function getRuntime4() { 10182 const globalScope = globalThis; 10183 if (globalScope.__wpStyleRuntime) { 10184 return globalScope.__wpStyleRuntime; 10185 } 10186 globalScope.__wpStyleRuntime = { 10187 documents: /* @__PURE__ */ new Map(), 10188 styles: /* @__PURE__ */ new Map(), 10189 injectedStyles: /* @__PURE__ */ new WeakMap() 10190 }; 10191 if (typeof document !== "undefined") { 10192 registerDocument4(document); 10193 } 10194 return globalScope.__wpStyleRuntime; 10195 } 10196 function documentContainsStyleHash4(targetDocument, hash) { 10197 if (!targetDocument.head) { 10198 return false; 10199 } 10200 for (const style of targetDocument.head.querySelectorAll( 10201 `style[$STYLE_HASH_ATTRIBUTE4}]` 10202 )) { 10203 if (style.getAttribute(STYLE_HASH_ATTRIBUTE4) === hash) { 10204 return true; 10205 } 10206 } 10207 return false; 10208 } 10209 function injectStyle4(targetDocument, hash, css) { 10210 if (!targetDocument.head) { 10211 return; 10212 } 10213 const runtime = getRuntime4(); 10214 let injectedStyles = runtime.injectedStyles.get(targetDocument); 10215 if (!injectedStyles) { 10216 injectedStyles = /* @__PURE__ */ new Set(); 10217 runtime.injectedStyles.set(targetDocument, injectedStyles); 10218 } 10219 if (injectedStyles.has(hash)) { 10220 return; 10221 } 10222 if (documentContainsStyleHash4(targetDocument, hash)) { 10223 injectedStyles.add(hash); 10224 return; 10225 } 10226 const style = targetDocument.createElement("style"); 10227 style.setAttribute(STYLE_HASH_ATTRIBUTE4, hash); 10228 style.appendChild(targetDocument.createTextNode(css)); 10229 targetDocument.head.appendChild(style); 10230 injectedStyles.add(hash); 10231 } 10232 function registerDocument4(targetDocument) { 10233 const runtime = getRuntime4(); 10234 runtime.documents.set( 10235 targetDocument, 10236 (runtime.documents.get(targetDocument) ?? 0) + 1 10237 ); 10238 for (const [hash, css] of runtime.styles) { 10239 injectStyle4(targetDocument, hash, css); 10240 } 10241 return () => { 10242 const count = runtime.documents.get(targetDocument); 10243 if (count === void 0) { 10244 return; 10245 } 10246 if (count <= 1) { 10247 runtime.documents.delete(targetDocument); 10248 return; 10249 } 10250 runtime.documents.set(targetDocument, count - 1); 10251 }; 10252 } 10253 function registerStyle4(hash, css) { 10254 const runtime = getRuntime4(); 10255 runtime.styles.set(hash, css); 10256 for (const targetDocument of runtime.documents.keys()) { 10257 injectStyle4(targetDocument, hash, css); 10258 } 10259 } 10260 if (typeof process === "undefined" || true) { 10261 registerStyle4("4811d023d1", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-md,4px);box-shadow:var(--wpds-elevation-sm,0 1px 2px 0 #0000000d,0 2px 3px 0 #0000000a,0 6px 6px 0 #00000008,0 8px 8px 0 #00000005);color:var(--wpds-color-fg-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-sm,12px);line-height:1.4;padding:var(--wpds-dimension-padding-xs,4px) var(--wpds-dimension-padding-sm,8px);@media (forced-colors:active){border-bottom-color:CanvasText;border-bottom-style:solid;border-bottom-width:1px;border-left-color:CanvasText;border-left-style:solid;border-left-width:1px;border-right-color:CanvasText;border-right-style:solid;border-right-width:1px;border-top-color:CanvasText;border-top-style:solid;border-top-width:1px}}}}'); 10262 } 10263 var style_default3 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" }; 10264 var ThemeProvider = unlock(import_theme.privateApis).ThemeProvider; 10265 var POPUP_COLOR = { background: "#1e1e1e" }; 10266 var Popup = (0, import_element15.forwardRef)(function TooltipPopup3({ portal, positioner, children, className, ...props }, ref) { 10267 const popupContent = /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(ThemeProvider, { color: POPUP_COLOR, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)( 10268 index_parts_exports.Popup, 10269 { 10270 ref, 10271 className: clsx_default(style_default3.popup, className), 10272 ...props, 10273 children 10274 } 10275 ) }); 10276 const positionedPopup = renderSlotWithChildren( 10277 positioner, 10278 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Positioner, {}), 10279 popupContent 10280 ); 10281 return renderSlotWithChildren(portal, /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Portal, {}), positionedPopup); 10282 }); 10283 10284 // packages/ui/build-module/tooltip/trigger.mjs 10285 var import_element16 = __toESM(require_element(), 1); 10286 var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1); 10287 var Trigger = (0, import_element16.forwardRef)( 10288 function TooltipTrigger3(props, ref) { 10289 return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(index_parts_exports.Trigger, { ref, ...props }); 10290 } 10291 ); 10292 10293 // packages/ui/build-module/tooltip/root.mjs 10294 var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1); 10295 function Root(props) { 10296 return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(index_parts_exports.Root, { ...props }); 10297 } 10298 10299 // packages/ui/build-module/tooltip/provider.mjs 10300 var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1); 10301 function Provider({ ...props }) { 10302 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(index_parts_exports.Provider, { ...props }); 10303 } 10304 10305 // packages/ui/build-module/visually-hidden/visually-hidden.mjs 10306 var import_element17 = __toESM(require_element(), 1); 10307 var STYLE_HASH_ATTRIBUTE5 = "data-wp-hash"; 10308 function getRuntime5() { 10309 const globalScope = globalThis; 10310 if (globalScope.__wpStyleRuntime) { 10311 return globalScope.__wpStyleRuntime; 10312 } 10313 globalScope.__wpStyleRuntime = { 10314 documents: /* @__PURE__ */ new Map(), 10315 styles: /* @__PURE__ */ new Map(), 10316 injectedStyles: /* @__PURE__ */ new WeakMap() 10317 }; 10318 if (typeof document !== "undefined") { 10319 registerDocument5(document); 10320 } 10321 return globalScope.__wpStyleRuntime; 10322 } 10323 function documentContainsStyleHash5(targetDocument, hash) { 10324 if (!targetDocument.head) { 10325 return false; 10326 } 10327 for (const style of targetDocument.head.querySelectorAll( 10328 `style[$STYLE_HASH_ATTRIBUTE5}]` 10329 )) { 10330 if (style.getAttribute(STYLE_HASH_ATTRIBUTE5) === hash) { 10331 return true; 10332 } 10333 } 10334 return false; 10335 } 10336 function injectStyle5(targetDocument, hash, css) { 10337 if (!targetDocument.head) { 10338 return; 10339 } 10340 const runtime = getRuntime5(); 10341 let injectedStyles = runtime.injectedStyles.get(targetDocument); 10342 if (!injectedStyles) { 10343 injectedStyles = /* @__PURE__ */ new Set(); 10344 runtime.injectedStyles.set(targetDocument, injectedStyles); 10345 } 10346 if (injectedStyles.has(hash)) { 10347 return; 10348 } 10349 if (documentContainsStyleHash5(targetDocument, hash)) { 10350 injectedStyles.add(hash); 10351 return; 10352 } 10353 const style = targetDocument.createElement("style"); 10354 style.setAttribute(STYLE_HASH_ATTRIBUTE5, hash); 10355 style.appendChild(targetDocument.createTextNode(css)); 10356 targetDocument.head.appendChild(style); 10357 injectedStyles.add(hash); 10358 } 10359 function registerDocument5(targetDocument) { 10360 const runtime = getRuntime5(); 10361 runtime.documents.set( 10362 targetDocument, 10363 (runtime.documents.get(targetDocument) ?? 0) + 1 10364 ); 10365 for (const [hash, css] of runtime.styles) { 10366 injectStyle5(targetDocument, hash, css); 10367 } 10368 return () => { 10369 const count = runtime.documents.get(targetDocument); 10370 if (count === void 0) { 10371 return; 10372 } 10373 if (count <= 1) { 10374 runtime.documents.delete(targetDocument); 10375 return; 10376 } 10377 runtime.documents.set(targetDocument, count - 1); 10378 }; 10379 } 10380 function registerStyle5(hash, css) { 10381 const runtime = getRuntime5(); 10382 runtime.styles.set(hash, css); 10383 for (const targetDocument of runtime.documents.keys()) { 10384 injectStyle5(targetDocument, hash, css); 10385 } 10386 } 10387 if (typeof process === "undefined" || true) { 10388 registerStyle5("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}}}"); 10389 } 10390 var style_default4 = { "visually-hidden": "f37b9e2e191ebd66__visually-hidden" }; 10391 var VisuallyHidden = (0, import_element17.forwardRef)( 10392 function VisuallyHidden2({ render: render4, ...restProps }, ref) { 10393 const element = useRender({ 10394 render: render4, 10395 ref, 10396 props: mergeProps( 10397 { className: style_default4["visually-hidden"] }, 10398 restProps, 10399 { 10400 // @ts-expect-error Arbitrary data-* attributes aren't indexable on the typed div props. Kept hardcoded so consumers can't change or remove it. 10401 "data-visually-hidden": "" 10402 } 10403 ) 10404 }); 10405 return element; 10406 } 10407 ); 10408 10409 // packages/dataviews/build-module/components/dataviews-context/index.mjs 10410 var import_element18 = __toESM(require_element(), 1); 10411 10412 // packages/dataviews/build-module/constants.mjs 10413 var import_i18n7 = __toESM(require_i18n(), 1); 10414 var OPERATOR_IS_ANY = "isAny"; 10415 var OPERATOR_IS_NONE = "isNone"; 10416 var OPERATOR_IS_ALL = "isAll"; 10417 var OPERATOR_IS_NOT_ALL = "isNotAll"; 10418 var OPERATOR_BETWEEN = "between"; 10419 var OPERATOR_IN_THE_PAST = "inThePast"; 10420 var OPERATOR_OVER = "over"; 10421 var OPERATOR_IS = "is"; 10422 var OPERATOR_IS_NOT = "isNot"; 10423 var OPERATOR_LESS_THAN = "lessThan"; 10424 var OPERATOR_GREATER_THAN = "greaterThan"; 10425 var OPERATOR_LESS_THAN_OR_EQUAL = "lessThanOrEqual"; 10426 var OPERATOR_GREATER_THAN_OR_EQUAL = "greaterThanOrEqual"; 10427 var OPERATOR_BEFORE = "before"; 10428 var OPERATOR_AFTER = "after"; 10429 var OPERATOR_BEFORE_INC = "beforeInc"; 10430 var OPERATOR_AFTER_INC = "afterInc"; 10431 var OPERATOR_CONTAINS = "contains"; 10432 var OPERATOR_NOT_CONTAINS = "notContains"; 10433 var OPERATOR_STARTS_WITH = "startsWith"; 10434 var OPERATOR_ON = "on"; 10435 var OPERATOR_NOT_ON = "notOn"; 10436 var SORTING_DIRECTIONS = ["asc", "desc"]; 10437 var sortArrows = { asc: "\u2191", desc: "\u2193" }; 10438 var sortValues = { asc: "ascending", desc: "descending" }; 10439 var sortLabels = { 10440 asc: (0, import_i18n7.__)("Sort ascending"), 10441 desc: (0, import_i18n7.__)("Sort descending") 10442 }; 10443 var sortIcons = { 10444 asc: arrow_up_default, 10445 desc: arrow_down_default 10446 }; 10447 var LAYOUT_TABLE = "table"; 10448 var LAYOUT_GRID = "grid"; 10449 var LAYOUT_LIST = "list"; 10450 var LAYOUT_ACTIVITY = "activity"; 10451 var LAYOUT_PICKER_GRID = "pickerGrid"; 10452 var LAYOUT_PICKER_TABLE = "pickerTable"; 10453 var LAYOUT_PICKER_ACTIVITY = "pickerActivity"; 10454 10455 // packages/dataviews/build-module/components/dataviews-context/index.mjs 10456 var DataViewsContext = (0, import_element18.createContext)({ 10457 view: { type: LAYOUT_TABLE }, 10458 onChangeView: () => { 10459 }, 10460 fields: [], 10461 data: [], 10462 paginationInfo: { 10463 totalItems: 0, 10464 totalPages: 0 10465 }, 10466 selection: [], 10467 onChangeSelection: () => { 10468 }, 10469 setOpenedFilter: () => { 10470 }, 10471 openedFilter: null, 10472 getItemId: (item) => item.id, 10473 isItemClickable: () => true, 10474 renderItemLink: void 0, 10475 containerWidth: 0, 10476 containerRef: (0, import_element18.createRef)(), 10477 resizeObserverRef: () => { 10478 }, 10479 defaultLayouts: { list: {}, grid: {}, table: {} }, 10480 filters: [], 10481 isShowingFilter: false, 10482 setIsShowingFilter: () => { 10483 }, 10484 hasInitiallyLoaded: false, 10485 config: { 10486 perPageSizes: [] 10487 }, 10488 intersectionObserver: null 10489 }); 10490 DataViewsContext.displayName = "DataViewsContext"; 10491 var dataviews_context_default = DataViewsContext; 10492 10493 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs 10494 var import_i18n28 = __toESM(require_i18n(), 1); 10495 10496 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs 10497 var import_i18n15 = __toESM(require_i18n(), 1); 10498 var import_components6 = __toESM(require_components(), 1); 10499 var import_element26 = __toESM(require_element(), 1); 10500 var import_keycodes = __toESM(require_keycodes(), 1); 10501 10502 // packages/dataviews/build-module/components/dataviews-selection-checkbox/index.mjs 10503 var import_components = __toESM(require_components(), 1); 10504 var import_i18n8 = __toESM(require_i18n(), 1); 10505 var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1); 10506 function DataViewsSelectionCheckbox({ 10507 selection, 10508 onChangeSelection, 10509 item, 10510 getItemId, 10511 titleField, 10512 disabled: disabled2, 10513 ...extraProps 10514 }) { 10515 const id = getItemId(item); 10516 const isInSelectionArray = selection.includes(id); 10517 const checked = !disabled2 && isInSelectionArray; 10518 const selectionLabel = titleField?.getValue?.({ item }) || (0, import_i18n8.__)("(no title)"); 10519 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 10520 import_components.CheckboxControl, 10521 { 10522 className: "dataviews-selection-checkbox", 10523 "aria-label": selectionLabel, 10524 "aria-disabled": disabled2, 10525 checked, 10526 onChange: () => { 10527 if (disabled2) { 10528 return; 10529 } 10530 onChangeSelection( 10531 isInSelectionArray ? selection.filter((itemId) => id !== itemId) : [...selection, id] 10532 ); 10533 }, 10534 ...extraProps 10535 } 10536 ); 10537 } 10538 10539 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs 10540 var import_components2 = __toESM(require_components(), 1); 10541 var import_i18n9 = __toESM(require_i18n(), 1); 10542 var import_element19 = __toESM(require_element(), 1); 10543 var import_data = __toESM(require_data(), 1); 10544 var import_compose = __toESM(require_compose(), 1); 10545 10546 // packages/dataviews/build-module/lock-unlock.mjs 10547 var import_private_apis2 = __toESM(require_private_apis(), 1); 10548 var { lock: lock2, unlock: unlock2 } = (0, import_private_apis2.__dangerousOptInToUnstableAPIsOnlyForCoreModules)( 10549 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.", 10550 "@wordpress/dataviews" 10551 ); 10552 10553 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs 10554 var import_jsx_runtime48 = __toESM(require_jsx_runtime(), 1); 10555 var { Menu, kebabCase } = unlock2(import_components2.privateApis); 10556 function ButtonTrigger({ 10557 action, 10558 onClick, 10559 items, 10560 variant 10561 }) { 10562 const label = typeof action.label === "string" ? action.label : action.label(items); 10563 return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)( 10564 import_components2.Button, 10565 { 10566 disabled: !!action.disabled, 10567 accessibleWhenDisabled: true, 10568 size: "compact", 10569 variant, 10570 onClick, 10571 children: label 10572 } 10573 ); 10574 } 10575 function MenuItemTrigger({ 10576 action, 10577 onClick, 10578 items 10579 }) { 10580 const label = typeof action.label === "string" ? action.label : action.label(items); 10581 return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(Menu.Item, { disabled: action.disabled, onClick, children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(Menu.ItemLabel, { children: label }) }); 10582 } 10583 function ActionModal({ 10584 action, 10585 items, 10586 closeModal 10587 }) { 10588 const label = typeof action.label === "string" ? action.label : action.label(items); 10589 const modalHeader = typeof action.modalHeader === "function" ? action.modalHeader(items) : action.modalHeader; 10590 return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)( 10591 import_components2.Modal, 10592 { 10593 title: modalHeader || label, 10594 __experimentalHideHeader: !!action.hideModalHeader, 10595 onRequestClose: closeModal, 10596 focusOnMount: action.modalFocusOnMount ?? true, 10597 size: action.modalSize || "medium", 10598 overlayClassName: `dataviews-action-modal dataviews-action-modal__$kebabCase( 10599 action.id 10600 )}`, 10601 children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(action.RenderModal, { items, closeModal }) 10602 } 10603 ); 10604 } 10605 function ActionsMenuGroup({ 10606 actions, 10607 item, 10608 registry, 10609 setActiveModalAction 10610 }) { 10611 const { primaryActions, regularActions } = (0, import_element19.useMemo)(() => { 10612 return actions.reduce( 10613 (acc, action) => { 10614 (action.isPrimary ? acc.primaryActions : acc.regularActions).push(action); 10615 return acc; 10616 }, 10617 { 10618 primaryActions: [], 10619 regularActions: [] 10620 } 10621 ); 10622 }, [actions]); 10623 const renderActionGroup = (actionList) => actionList.map((action) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)( 10624 MenuItemTrigger, 10625 { 10626 action, 10627 onClick: () => { 10628 if ("RenderModal" in action) { 10629 setActiveModalAction(action); 10630 return; 10631 } 10632 action.callback([item], { registry }); 10633 }, 10634 items: [item] 10635 }, 10636 action.id 10637 )); 10638 return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(Menu.Group, { children: [ 10639 renderActionGroup(primaryActions), 10640 renderActionGroup(regularActions) 10641 ] }); 10642 } 10643 function ItemActions({ 10644 item, 10645 actions, 10646 isCompact 10647 }) { 10648 const registry = (0, import_data.useRegistry)(); 10649 const { primaryActions, eligibleActions } = (0, import_element19.useMemo)(() => { 10650 const _eligibleActions = actions.filter( 10651 (action) => !action.isEligible || action.isEligible(item) 10652 ); 10653 const _primaryActions = _eligibleActions.filter( 10654 (action) => action.isPrimary 10655 ); 10656 return { 10657 primaryActions: _primaryActions, 10658 eligibleActions: _eligibleActions 10659 }; 10660 }, [actions, item]); 10661 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<"); 10662 if (isCompact) { 10663 return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)( 10664 CompactItemActions, 10665 { 10666 item, 10667 actions: eligibleActions, 10668 isSmall: true, 10669 registry 10670 } 10671 ); 10672 } 10673 return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)( 10674 Stack, 10675 { 10676 direction: "row", 10677 justify: "flex-end", 10678 className: "dataviews-item-actions", 10679 style: { 10680 flexShrink: 0, 10681 width: "auto" 10682 }, 10683 children: [ 10684 /* @__PURE__ */ (0, import_jsx_runtime48.jsx)( 10685 PrimaryActions, 10686 { 10687 item, 10688 actions: primaryActions, 10689 registry 10690 } 10691 ), 10692 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu 10693 // there if there are any actions at all. 10694 isMobileViewport) && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)( 10695 CompactItemActions, 10696 { 10697 item, 10698 actions: eligibleActions, 10699 registry 10700 } 10701 ) 10702 ] 10703 } 10704 ); 10705 } 10706 function CompactItemActions({ 10707 item, 10708 actions, 10709 isSmall, 10710 registry 10711 }) { 10712 const [activeModalAction, setActiveModalAction] = (0, import_element19.useState)( 10713 null 10714 ); 10715 return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(import_jsx_runtime48.Fragment, { children: [ 10716 /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(Menu, { placement: "bottom-end", children: [ 10717 /* @__PURE__ */ (0, import_jsx_runtime48.jsx)( 10718 Menu.TriggerButton, 10719 { 10720 render: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)( 10721 import_components2.Button, 10722 { 10723 size: isSmall ? "small" : "compact", 10724 icon: more_vertical_default, 10725 label: (0, import_i18n9.__)("Actions"), 10726 accessibleWhenDisabled: true, 10727 disabled: !actions.length, 10728 className: "dataviews-all-actions-button" 10729 } 10730 ) 10731 } 10732 ), 10733 /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(Menu.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)( 10734 ActionsMenuGroup, 10735 { 10736 actions, 10737 item, 10738 registry, 10739 setActiveModalAction 10740 } 10741 ) }) 10742 ] }), 10743 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)( 10744 ActionModal, 10745 { 10746 action: activeModalAction, 10747 items: [item], 10748 closeModal: () => setActiveModalAction(null) 10749 } 10750 ) 10751 ] }); 10752 } 10753 function PrimaryActions({ 10754 item, 10755 actions, 10756 registry, 10757 buttonVariant 10758 }) { 10759 const [activeModalAction, setActiveModalAction] = (0, import_element19.useState)(null); 10760 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<"); 10761 if (isMobileViewport) { 10762 return null; 10763 } 10764 if (!Array.isArray(actions) || actions.length === 0) { 10765 return null; 10766 } 10767 return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(import_jsx_runtime48.Fragment, { children: [ 10768 actions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)( 10769 ButtonTrigger, 10770 { 10771 action, 10772 onClick: () => { 10773 if ("RenderModal" in action) { 10774 setActiveModalAction(action); 10775 return; 10776 } 10777 action.callback([item], { registry }); 10778 }, 10779 items: [item], 10780 variant: buttonVariant 10781 }, 10782 action.id 10783 )), 10784 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)( 10785 ActionModal, 10786 { 10787 action: activeModalAction, 10788 items: [item], 10789 closeModal: () => setActiveModalAction(null) 10790 } 10791 ) 10792 ] }); 10793 } 10794 10795 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs 10796 var import_components3 = __toESM(require_components(), 1); 10797 var import_i18n11 = __toESM(require_i18n(), 1); 10798 var import_element20 = __toESM(require_element(), 1); 10799 var import_data2 = __toESM(require_data(), 1); 10800 var import_compose2 = __toESM(require_compose(), 1); 10801 10802 // packages/dataviews/build-module/utils/get-footer-message.mjs 10803 var import_i18n10 = __toESM(require_i18n(), 1); 10804 function getFooterMessage(selectionCount, itemsCount, totalItems, onlyTotalCount = false) { 10805 if (selectionCount > 0) { 10806 return (0, import_i18n10.sprintf)( 10807 /* translators: %d: number of items. */ 10808 (0, import_i18n10._n)("%d Item selected", "%d Items selected", selectionCount), 10809 selectionCount 10810 ); 10811 } 10812 if (onlyTotalCount || totalItems <= itemsCount) { 10813 return (0, import_i18n10.sprintf)( 10814 /* translators: %d: number of items. */ 10815 (0, import_i18n10._n)("%d Item", "%d Items", totalItems), 10816 totalItems 10817 ); 10818 } 10819 return (0, import_i18n10.sprintf)( 10820 /* translators: %1$d: number of items. %2$d: total number of items. */ 10821 (0, import_i18n10._n)("%1$d of %2$d Item", "%1$d of %2$d Items", totalItems), 10822 itemsCount, 10823 totalItems 10824 ); 10825 } 10826 10827 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs 10828 var import_jsx_runtime49 = __toESM(require_jsx_runtime(), 1); 10829 function useHasAPossibleBulkAction(actions, item) { 10830 return (0, import_element20.useMemo)(() => { 10831 return actions.some((action) => { 10832 return action.supportsBulk && (!action.isEligible || action.isEligible(item)); 10833 }); 10834 }, [actions, item]); 10835 } 10836 function useSomeItemHasAPossibleBulkAction(actions, data) { 10837 return (0, import_element20.useMemo)(() => { 10838 return data.some((item) => { 10839 return actions.some((action) => { 10840 return action.supportsBulk && (!action.isEligible || action.isEligible(item)); 10841 }); 10842 }); 10843 }, [actions, data]); 10844 } 10845 function BulkSelectionCheckbox({ 10846 selection, 10847 onChangeSelection, 10848 data, 10849 actions, 10850 getItemId, 10851 disableSelectAll = false 10852 }) { 10853 const selectableItems = (0, import_element20.useMemo)(() => { 10854 return data.filter((item) => { 10855 return actions.some( 10856 (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item)) 10857 ); 10858 }); 10859 }, [data, actions]); 10860 const selectedItems = data.filter( 10861 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item) 10862 ); 10863 const hasSelection = selection.length > 0; 10864 const areAllSelected = selectedItems.length === selectableItems.length; 10865 if (disableSelectAll) { 10866 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)( 10867 import_components3.CheckboxControl, 10868 { 10869 className: "dataviews-view-table-selection-checkbox", 10870 checked: hasSelection, 10871 disabled: !hasSelection, 10872 onChange: () => { 10873 onChangeSelection([]); 10874 }, 10875 "aria-label": (0, import_i18n11.__)("Deselect all") 10876 } 10877 ); 10878 } 10879 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)( 10880 import_components3.CheckboxControl, 10881 { 10882 className: "dataviews-view-table-selection-checkbox", 10883 checked: areAllSelected, 10884 indeterminate: !areAllSelected && !!selectedItems.length, 10885 onChange: () => { 10886 if (areAllSelected) { 10887 onChangeSelection([]); 10888 } else { 10889 onChangeSelection( 10890 selectableItems.map((item) => getItemId(item)) 10891 ); 10892 } 10893 }, 10894 "aria-label": areAllSelected ? (0, import_i18n11.__)("Deselect all") : (0, import_i18n11.__)("Select all") 10895 } 10896 ); 10897 } 10898 10899 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs 10900 var import_i18n12 = __toESM(require_i18n(), 1); 10901 var import_components4 = __toESM(require_components(), 1); 10902 var import_element21 = __toESM(require_element(), 1); 10903 10904 // packages/dataviews/build-module/utils/get-hideable-fields.mjs 10905 function getHideableFields(view, fields) { 10906 const togglableFields = [ 10907 view?.titleField, 10908 view?.mediaField, 10909 view?.descriptionField 10910 ].filter(Boolean); 10911 return fields.filter( 10912 (f2) => !togglableFields.includes(f2.id) && f2.type !== "media" && f2.enableHiding !== false 10913 ); 10914 } 10915 10916 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs 10917 var import_jsx_runtime50 = __toESM(require_jsx_runtime(), 1); 10918 var { Menu: Menu2 } = unlock2(import_components4.privateApis); 10919 function WithMenuSeparators({ children }) { 10920 return import_element21.Children.toArray(children).filter(Boolean).map((child, i2) => /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_element21.Fragment, { children: [ 10921 i2 > 0 && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.Separator, {}), 10922 child 10923 ] }, i2)); 10924 } 10925 var _HeaderMenu = (0, import_element21.forwardRef)(function HeaderMenu({ 10926 fieldId, 10927 view, 10928 fields, 10929 onChangeView, 10930 onHide, 10931 setOpenedFilter, 10932 canMove = true, 10933 canInsertLeft = true, 10934 canInsertRight = true 10935 }, ref) { 10936 const visibleFieldIds = view.fields ?? []; 10937 const index2 = visibleFieldIds?.indexOf(fieldId); 10938 const isSorted = view.sort?.field === fieldId; 10939 let isHidable = false; 10940 let isSortable = false; 10941 let canAddFilter = false; 10942 let operators = []; 10943 const field = fields.find((f2) => f2.id === fieldId); 10944 const { setIsShowingFilter } = (0, import_element21.useContext)(dataviews_context_default); 10945 if (!field) { 10946 return null; 10947 } 10948 isHidable = field.enableHiding !== false; 10949 isSortable = field.enableSorting !== false; 10950 const header = field.header; 10951 operators = !!field.filterBy && field.filterBy?.operators || []; 10952 canAddFilter = !view.filters?.some((_filter) => fieldId === _filter.field) && !!(field.hasElements || field.Edit) && field.filterBy !== false && !field.filterBy?.isPrimary; 10953 if (!isSortable && !canMove && !isHidable && !canAddFilter) { 10954 return header; 10955 } 10956 const hiddenFields = getHideableFields(view, fields).filter( 10957 (f2) => !visibleFieldIds.includes(f2.id) 10958 ); 10959 const canInsert = (canInsertLeft || canInsertRight) && !!hiddenFields.length; 10960 const isRtl = (0, import_i18n12.isRTL)(); 10961 return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(Menu2, { children: [ 10962 /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)( 10963 Menu2.TriggerButton, 10964 { 10965 render: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)( 10966 import_components4.Button, 10967 { 10968 size: "compact", 10969 className: "dataviews-view-table-header-button", 10970 ref, 10971 variant: "tertiary" 10972 } 10973 ), 10974 children: [ 10975 header, 10976 view.sort && isSorted && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { "aria-hidden": "true", children: sortArrows[view.sort.direction] }) 10977 ] 10978 } 10979 ), 10980 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.Popover, { style: { minWidth: "240px" }, children: /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(WithMenuSeparators, { children: [ 10981 isSortable && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.Group, { children: SORTING_DIRECTIONS.map( 10982 (direction) => { 10983 const isChecked = view.sort && isSorted && view.sort.direction === direction; 10984 const value = `$fieldId}-$direction}`; 10985 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)( 10986 Menu2.RadioItem, 10987 { 10988 name: "view-table-sorting", 10989 value, 10990 checked: isChecked, 10991 onChange: () => { 10992 onChangeView({ 10993 ...view, 10994 sort: { 10995 field: fieldId, 10996 direction 10997 }, 10998 showLevels: false 10999 }); 11000 }, 11001 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: sortLabels[direction] }) 11002 }, 11003 value 11004 ); 11005 } 11006 ) }), 11007 canAddFilter && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.Group, { children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)( 11008 Menu2.Item, 11009 { 11010 prefix: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_components4.Icon, { icon: funnel_default }), 11011 onClick: () => { 11012 setOpenedFilter(fieldId); 11013 setIsShowingFilter(true); 11014 onChangeView({ 11015 ...view, 11016 page: 1, 11017 filters: [ 11018 ...view.filters || [], 11019 { 11020 field: fieldId, 11021 value: void 0, 11022 operator: operators[0] 11023 } 11024 ] 11025 }); 11026 }, 11027 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: (0, import_i18n12.__)("Add filter") }) 11028 } 11029 ) }), 11030 (canMove || isHidable || canInsert) && field && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(Menu2.Group, { children: [ 11031 canMove && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)( 11032 Menu2.Item, 11033 { 11034 prefix: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_components4.Icon, { icon: arrow_left_default }), 11035 disabled: isRtl ? index2 >= visibleFieldIds.length - 1 : index2 < 1, 11036 onClick: () => { 11037 const targetIndex = isRtl ? index2 + 1 : index2 - 1; 11038 const newFields = [ 11039 ...visibleFieldIds 11040 ]; 11041 newFields.splice(index2, 1); 11042 newFields.splice( 11043 targetIndex, 11044 0, 11045 fieldId 11046 ); 11047 onChangeView({ 11048 ...view, 11049 fields: newFields 11050 }); 11051 }, 11052 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: (0, import_i18n12.__)("Move left") }) 11053 } 11054 ), 11055 canMove && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)( 11056 Menu2.Item, 11057 { 11058 prefix: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_components4.Icon, { icon: arrow_right_default }), 11059 disabled: isRtl ? index2 < 1 : index2 >= visibleFieldIds.length - 1, 11060 onClick: () => { 11061 const targetIndex = isRtl ? index2 - 1 : index2 + 1; 11062 const newFields = [ 11063 ...visibleFieldIds 11064 ]; 11065 newFields.splice(index2, 1); 11066 newFields.splice( 11067 targetIndex, 11068 0, 11069 fieldId 11070 ); 11071 onChangeView({ 11072 ...view, 11073 fields: newFields 11074 }); 11075 }, 11076 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: (0, import_i18n12.__)("Move right") }) 11077 } 11078 ), 11079 canInsertLeft && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(Menu2, { children: [ 11080 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: (0, import_i18n12.__)("Insert left") }) }), 11081 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => { 11082 const insertIndex = isRtl ? index2 + 1 : index2; 11083 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)( 11084 Menu2.Item, 11085 { 11086 onClick: () => { 11087 onChangeView({ 11088 ...view, 11089 fields: [ 11090 ...visibleFieldIds.slice( 11091 0, 11092 insertIndex 11093 ), 11094 hiddenField.id, 11095 ...visibleFieldIds.slice( 11096 insertIndex 11097 ) 11098 ] 11099 }); 11100 }, 11101 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: hiddenField.label }) 11102 }, 11103 hiddenField.id 11104 ); 11105 }) }) 11106 ] }), 11107 canInsertRight && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(Menu2, { children: [ 11108 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: (0, import_i18n12.__)("Insert right") }) }), 11109 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => { 11110 const insertIndex = isRtl ? index2 : index2 + 1; 11111 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)( 11112 Menu2.Item, 11113 { 11114 onClick: () => { 11115 onChangeView({ 11116 ...view, 11117 fields: [ 11118 ...visibleFieldIds.slice( 11119 0, 11120 insertIndex 11121 ), 11122 hiddenField.id, 11123 ...visibleFieldIds.slice( 11124 insertIndex 11125 ) 11126 ] 11127 }); 11128 }, 11129 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: hiddenField.label }) 11130 }, 11131 hiddenField.id 11132 ); 11133 }) }) 11134 ] }), 11135 isHidable && field && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)( 11136 Menu2.Item, 11137 { 11138 prefix: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_components4.Icon, { icon: unseen_default }), 11139 onClick: () => { 11140 onHide(field); 11141 onChangeView({ 11142 ...view, 11143 fields: visibleFieldIds.filter( 11144 (id) => id !== fieldId 11145 ) 11146 }); 11147 }, 11148 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: (0, import_i18n12.__)("Hide column") }) 11149 } 11150 ) 11151 ] }) 11152 ] }) }) 11153 ] }); 11154 }); 11155 var ColumnHeaderMenu = _HeaderMenu; 11156 var column_header_menu_default = ColumnHeaderMenu; 11157 11158 // packages/dataviews/build-module/components/dataviews-layouts/utils/item-click-wrapper.mjs 11159 var import_element22 = __toESM(require_element(), 1); 11160 var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1); 11161 function getClickableItemProps({ 11162 item, 11163 isItemClickable: isItemClickable2, 11164 onClickItem, 11165 className 11166 }) { 11167 if (!isItemClickable2(item) || !onClickItem) { 11168 return { className }; 11169 } 11170 return { 11171 className: className ? `$className} $className}--clickable` : void 0, 11172 role: "button", 11173 tabIndex: 0, 11174 onClick: (event) => { 11175 event.stopPropagation(); 11176 onClickItem(item); 11177 }, 11178 onKeyDown: (event) => { 11179 if (event.key === "Enter" || event.key === "" || event.key === " ") { 11180 event.stopPropagation(); 11181 onClickItem(item); 11182 } 11183 } 11184 }; 11185 } 11186 function ItemClickWrapper({ 11187 item, 11188 isItemClickable: isItemClickable2, 11189 onClickItem, 11190 renderItemLink, 11191 className, 11192 children, 11193 ...extraProps 11194 }) { 11195 if (!isItemClickable2(item)) { 11196 return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className, ...extraProps, children }); 11197 } 11198 if (renderItemLink) { 11199 const renderedElement = renderItemLink({ 11200 item, 11201 className: `$className} $className}--clickable`, 11202 ...extraProps, 11203 children 11204 }); 11205 return (0, import_element22.cloneElement)(renderedElement, { 11206 onClick: (event) => { 11207 event.stopPropagation(); 11208 if (renderedElement.props.onClick) { 11209 renderedElement.props.onClick(event); 11210 } 11211 }, 11212 onKeyDown: (event) => { 11213 if (event.key === "Enter" || event.key === "" || event.key === " ") { 11214 event.stopPropagation(); 11215 if (renderedElement.props.onKeyDown) { 11216 renderedElement.props.onKeyDown(event); 11217 } 11218 } 11219 } 11220 }); 11221 } 11222 const clickProps = getClickableItemProps({ 11223 item, 11224 isItemClickable: isItemClickable2, 11225 onClickItem, 11226 className 11227 }); 11228 return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { ...clickProps, ...extraProps, children }); 11229 } 11230 11231 // packages/dataviews/build-module/components/dataviews-layouts/table/column-primary.mjs 11232 var import_jsx_runtime52 = __toESM(require_jsx_runtime(), 1); 11233 function ColumnPrimary({ 11234 item, 11235 level, 11236 titleField, 11237 mediaField, 11238 descriptionField: descriptionField2, 11239 onClickItem, 11240 renderItemLink, 11241 isItemClickable: isItemClickable2 11242 }) { 11243 return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(Stack, { direction: "row", gap: "md", align: "flex-start", justify: "flex-start", children: [ 11244 mediaField && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)( 11245 ItemClickWrapper, 11246 { 11247 item, 11248 isItemClickable: isItemClickable2, 11249 onClickItem, 11250 renderItemLink, 11251 className: "dataviews-view-table__cell-content-wrapper dataviews-column-primary__media", 11252 "aria-label": isItemClickable2(item) && (!!onClickItem || !!renderItemLink) && !!titleField ? titleField.getValue?.({ item }) : void 0, 11253 children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)( 11254 mediaField.render, 11255 { 11256 item, 11257 field: mediaField, 11258 config: { sizes: "32px" } 11259 } 11260 ) 11261 } 11262 ), 11263 /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)( 11264 Stack, 11265 { 11266 direction: "column", 11267 align: "flex-start", 11268 className: "dataviews-view-table__primary-column-content", 11269 children: [ 11270 titleField && /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)( 11271 ItemClickWrapper, 11272 { 11273 item, 11274 isItemClickable: isItemClickable2, 11275 onClickItem, 11276 renderItemLink, 11277 className: "dataviews-view-table__cell-content-wrapper dataviews-title-field", 11278 children: [ 11279 level !== void 0 && level > 0 && /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("span", { className: "dataviews-view-table__level", children: [ 11280 Array(level).fill("\u2014").join(" "), 11281 "\xA0" 11282 ] }), 11283 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(titleField.render, { item, field: titleField }) 11284 ] 11285 } 11286 ), 11287 descriptionField2 && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)( 11288 descriptionField2.render, 11289 { 11290 item, 11291 field: descriptionField2 11292 } 11293 ) 11294 ] 11295 } 11296 ) 11297 ] }); 11298 } 11299 var column_primary_default = ColumnPrimary; 11300 11301 // packages/dataviews/build-module/components/dataviews-layouts/table/use-scroll-state.mjs 11302 var import_element23 = __toESM(require_element(), 1); 11303 var import_i18n13 = __toESM(require_i18n(), 1); 11304 var isScrolledToEnd = (element) => { 11305 if ((0, import_i18n13.isRTL)()) { 11306 const scrollLeft = Math.abs(element.scrollLeft); 11307 return scrollLeft <= 1; 11308 } 11309 return element.scrollLeft + element.clientWidth >= element.scrollWidth - 1; 11310 }; 11311 function useScrollState({ 11312 scrollContainerRef, 11313 enabledHorizontal = false 11314 }) { 11315 const [isHorizontalScrollEnd, setIsHorizontalScrollEnd] = (0, import_element23.useState)(false); 11316 const [isVerticallyScrolled, setIsVerticallyScrolled] = (0, import_element23.useState)(false); 11317 const handleScroll = (0, import_element23.useCallback)(() => { 11318 const scrollContainer = scrollContainerRef.current; 11319 if (!scrollContainer) { 11320 return; 11321 } 11322 if (enabledHorizontal) { 11323 setIsHorizontalScrollEnd(isScrolledToEnd(scrollContainer)); 11324 } 11325 setIsVerticallyScrolled(scrollContainer.scrollTop > 0); 11326 }, [scrollContainerRef, enabledHorizontal]); 11327 (0, import_element23.useEffect)(() => { 11328 if (typeof window === "undefined" || !scrollContainerRef.current) { 11329 return () => { 11330 }; 11331 } 11332 const scrollContainer = scrollContainerRef.current; 11333 handleScroll(); 11334 scrollContainer.addEventListener("scroll", handleScroll); 11335 window.addEventListener("resize", handleScroll); 11336 return () => { 11337 scrollContainer.removeEventListener("scroll", handleScroll); 11338 window.removeEventListener("resize", handleScroll); 11339 }; 11340 }, [scrollContainerRef, enabledHorizontal, handleScroll]); 11341 return { isHorizontalScrollEnd, isVerticallyScrolled }; 11342 } 11343 11344 // packages/dataviews/build-module/components/dataviews-layouts/utils/get-data-by-group.mjs 11345 function getDataByGroup(data, groupByField) { 11346 return data.reduce((groups, item) => { 11347 const groupName = groupByField.getValue({ item }); 11348 if (!groups.has(groupName)) { 11349 groups.set(groupName, []); 11350 } 11351 groups.get(groupName)?.push(item); 11352 return groups; 11353 }, /* @__PURE__ */ new Map()); 11354 } 11355 11356 // packages/dataviews/build-module/components/dataviews-view-config/properties-section.mjs 11357 var import_components5 = __toESM(require_components(), 1); 11358 var import_i18n14 = __toESM(require_i18n(), 1); 11359 var import_element24 = __toESM(require_element(), 1); 11360 var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1); 11361 function FieldItem({ 11362 field, 11363 isVisible: isVisible2, 11364 onToggleVisibility 11365 }) { 11366 return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_components5.__experimentalItem, { onClick: field.enableHiding ? onToggleVisibility : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(Stack, { direction: "row", gap: "sm", justify: "flex-start", align: "center", children: [ 11367 /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("div", { style: { height: 24, width: 24 }, children: isVisible2 && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_components5.Icon, { icon: check_default }) }), 11368 /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { className: "dataviews-view-config__label", children: field.label }) 11369 ] }) }); 11370 } 11371 function isDefined(item) { 11372 return !!item; 11373 } 11374 function PropertiesSection({ 11375 showLabel = true 11376 }) { 11377 const { view, fields, onChangeView } = (0, import_element24.useContext)(dataviews_context_default); 11378 const regularFields = getHideableFields(view, fields); 11379 if (!regularFields?.length) { 11380 return null; 11381 } 11382 const titleField = fields.find((f2) => f2.id === view.titleField); 11383 const previewField = fields.find((f2) => f2.id === view.mediaField); 11384 const descriptionField2 = fields.find( 11385 (f2) => f2.id === view.descriptionField 11386 ); 11387 const lockedFields = [ 11388 { 11389 field: titleField, 11390 isVisibleFlag: "showTitle" 11391 }, 11392 { 11393 field: previewField, 11394 isVisibleFlag: "showMedia" 11395 }, 11396 { 11397 field: descriptionField2, 11398 isVisibleFlag: "showDescription" 11399 } 11400 ].filter(({ field }) => isDefined(field)); 11401 const visibleFieldIds = view.fields ?? []; 11402 const visibleRegularFieldsCount = regularFields.filter( 11403 (f2) => visibleFieldIds.includes(f2.id) 11404 ).length; 11405 const visibleLockedFields = lockedFields.filter( 11406 ({ isVisibleFlag }) => ( 11407 // @ts-expect-error 11408 view[isVisibleFlag] ?? true 11409 ) 11410 ); 11411 const totalVisibleFields = visibleLockedFields.length + visibleRegularFieldsCount; 11412 const isSingleVisibleLockedField = totalVisibleFields === 1 && visibleLockedFields.length === 1; 11413 return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(Stack, { direction: "column", className: "dataviews-field-control", children: [ 11414 showLabel && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_components5.BaseControl.VisualLabel, { children: (0, import_i18n14.__)("Properties") }), 11415 /* @__PURE__ */ (0, import_jsx_runtime53.jsx)( 11416 Stack, 11417 { 11418 direction: "column", 11419 className: "dataviews-view-config__properties", 11420 children: /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(import_components5.__experimentalItemGroup, { isBordered: true, isSeparated: true, size: "medium", children: [ 11421 lockedFields.map(({ field, isVisibleFlag }) => { 11422 const isVisible2 = view[isVisibleFlag] ?? true; 11423 const fieldToRender = isSingleVisibleLockedField && isVisible2 ? { ...field, enableHiding: false } : field; 11424 return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)( 11425 FieldItem, 11426 { 11427 field: fieldToRender, 11428 isVisible: isVisible2, 11429 onToggleVisibility: () => { 11430 onChangeView({ 11431 ...view, 11432 [isVisibleFlag]: !isVisible2 11433 }); 11434 } 11435 }, 11436 field.id 11437 ); 11438 }), 11439 regularFields.map((field) => { 11440 const isVisible2 = visibleFieldIds.includes(field.id); 11441 const fieldToRender = totalVisibleFields === 1 && isVisible2 ? { ...field, enableHiding: false } : field; 11442 return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)( 11443 FieldItem, 11444 { 11445 field: fieldToRender, 11446 isVisible: isVisible2, 11447 onToggleVisibility: () => { 11448 onChangeView({ 11449 ...view, 11450 fields: isVisible2 ? visibleFieldIds.filter( 11451 (fieldId) => fieldId !== field.id 11452 ) : [...visibleFieldIds, field.id] 11453 }); 11454 } 11455 }, 11456 field.id 11457 ); 11458 }) 11459 ] }) 11460 } 11461 ) 11462 ] }); 11463 } 11464 11465 // packages/dataviews/build-module/hooks/use-delayed-loading.mjs 11466 var import_element25 = __toESM(require_element(), 1); 11467 function useDelayedLoading(isLoading, options = { delay: 400 }) { 11468 const [showLoader, setShowLoader] = (0, import_element25.useState)(false); 11469 (0, import_element25.useEffect)(() => { 11470 if (!isLoading) { 11471 return; 11472 } 11473 const timeout = setTimeout(() => { 11474 setShowLoader(true); 11475 }, options.delay); 11476 return () => { 11477 clearTimeout(timeout); 11478 setShowLoader(false); 11479 }; 11480 }, [isLoading, options.delay]); 11481 return showLoader; 11482 } 11483 11484 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs 11485 var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1); 11486 function getEffectiveAlign(explicitAlign, fieldType) { 11487 if (explicitAlign) { 11488 return explicitAlign; 11489 } 11490 if (fieldType === "integer" || fieldType === "number") { 11491 return "end"; 11492 } 11493 return void 0; 11494 } 11495 function TableColumnField({ 11496 item, 11497 fields, 11498 column, 11499 align 11500 }) { 11501 const field = fields.find((f2) => f2.id === column); 11502 if (!field) { 11503 return null; 11504 } 11505 const className = clsx_default("dataviews-view-table__cell-content-wrapper", { 11506 "dataviews-view-table__cell-align-end": align === "end", 11507 "dataviews-view-table__cell-align-center": align === "center" 11508 }); 11509 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(field.render, { item, field }) }); 11510 } 11511 function TableRow({ 11512 hasBulkActions, 11513 item, 11514 level, 11515 actions, 11516 fields, 11517 id, 11518 view, 11519 titleField, 11520 mediaField, 11521 descriptionField: descriptionField2, 11522 selection, 11523 getItemId, 11524 isItemClickable: isItemClickable2, 11525 onClickItem, 11526 renderItemLink, 11527 onChangeSelection, 11528 isActionsColumnSticky, 11529 posinset 11530 }) { 11531 const { paginationInfo } = (0, import_element26.useContext)(dataviews_context_default); 11532 const hasPossibleBulkAction = useHasAPossibleBulkAction(actions, item); 11533 const isSelected2 = hasPossibleBulkAction && selection.includes(id); 11534 const { 11535 showTitle = true, 11536 showMedia = true, 11537 showDescription = true, 11538 infiniteScrollEnabled 11539 } = view; 11540 const isTouchDeviceRef = (0, import_element26.useRef)(false); 11541 const columns = view.fields ?? []; 11542 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField2 && showDescription; 11543 return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)( 11544 "tr", 11545 { 11546 className: clsx_default("dataviews-view-table__row", { 11547 "is-selected": hasPossibleBulkAction && isSelected2, 11548 "has-bulk-actions": hasPossibleBulkAction 11549 }), 11550 onTouchStart: () => { 11551 isTouchDeviceRef.current = true; 11552 }, 11553 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0, 11554 "aria-posinset": posinset, 11555 role: infiniteScrollEnabled ? "article" : void 0, 11556 onMouseDown: (event) => { 11557 const isMetaClick = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey; 11558 if (event.button === 0 && isMetaClick && window.navigator.userAgent.toLowerCase().includes("firefox")) { 11559 event?.preventDefault(); 11560 } 11561 }, 11562 onClick: (event) => { 11563 if (!hasPossibleBulkAction) { 11564 return; 11565 } 11566 const isModifierKeyPressed = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey; 11567 if (isModifierKeyPressed && !isTouchDeviceRef.current && document.getSelection()?.type !== "Range") { 11568 onChangeSelection( 11569 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id] 11570 ); 11571 } 11572 }, 11573 children: [ 11574 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("td", { className: "dataviews-view-table__checkbox-column", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)( 11575 DataViewsSelectionCheckbox, 11576 { 11577 item, 11578 selection, 11579 onChangeSelection, 11580 getItemId, 11581 titleField, 11582 disabled: !hasPossibleBulkAction 11583 } 11584 ) }) }), 11585 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)( 11586 column_primary_default, 11587 { 11588 item, 11589 level, 11590 titleField: showTitle ? titleField : void 0, 11591 mediaField: showMedia ? mediaField : void 0, 11592 descriptionField: showDescription ? descriptionField2 : void 0, 11593 isItemClickable: isItemClickable2, 11594 onClickItem, 11595 renderItemLink 11596 } 11597 ) }), 11598 columns.map((column) => { 11599 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {}; 11600 const field = fields.find((f2) => f2.id === column); 11601 const effectiveAlign = getEffectiveAlign(align, field?.type); 11602 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)( 11603 "td", 11604 { 11605 style: { 11606 width, 11607 maxWidth, 11608 minWidth 11609 }, 11610 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)( 11611 TableColumnField, 11612 { 11613 fields, 11614 item, 11615 column, 11616 align: effectiveAlign 11617 } 11618 ) 11619 }, 11620 column 11621 ); 11622 }), 11623 !!actions?.length && // Disable reason: we are not making the element interactive, 11624 // but preventing any click events from bubbling up to the 11625 // table row. This allows us to add a click handler to the row 11626 // itself (to toggle row selection) without erroneously 11627 // intercepting click events from ItemActions. 11628 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)( 11629 "td", 11630 { 11631 className: clsx_default("dataviews-view-table__actions-column", { 11632 "dataviews-view-table__actions-column--sticky": true, 11633 "dataviews-view-table__actions-column--stuck": isActionsColumnSticky 11634 }), 11635 onClick: (e2) => e2.stopPropagation(), 11636 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(ItemActions, { item, actions }) 11637 } 11638 ) 11639 ] 11640 } 11641 ); 11642 } 11643 function ViewTable({ 11644 actions, 11645 data, 11646 fields, 11647 getItemId, 11648 getItemLevel, 11649 isLoading = false, 11650 onChangeView, 11651 onChangeSelection, 11652 selection, 11653 setOpenedFilter, 11654 onClickItem, 11655 isItemClickable: isItemClickable2, 11656 renderItemLink, 11657 view, 11658 className, 11659 empty 11660 }) { 11661 const { containerRef } = (0, import_element26.useContext)(dataviews_context_default); 11662 const isDelayedLoading = useDelayedLoading(isLoading); 11663 const headerMenuRefs = (0, import_element26.useRef)(/* @__PURE__ */ new Map()); 11664 const headerMenuToFocusRef = (0, import_element26.useRef)(void 0); 11665 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element26.useState)(); 11666 const [contextMenuAnchor, setContextMenuAnchor] = (0, import_element26.useState)(null); 11667 (0, import_element26.useEffect)(() => { 11668 if (headerMenuToFocusRef.current) { 11669 headerMenuToFocusRef.current.focus(); 11670 headerMenuToFocusRef.current = void 0; 11671 } 11672 }); 11673 const tableNoticeId = (0, import_element26.useId)(); 11674 const { isHorizontalScrollEnd, isVerticallyScrolled } = useScrollState({ 11675 scrollContainerRef: containerRef, 11676 enabledHorizontal: !!actions?.length 11677 }); 11678 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data); 11679 if (nextHeaderMenuToFocus) { 11680 headerMenuToFocusRef.current = nextHeaderMenuToFocus; 11681 setNextHeaderMenuToFocus(void 0); 11682 return; 11683 } 11684 const onHide = (field) => { 11685 const hidden = headerMenuRefs.current.get(field.id); 11686 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0; 11687 setNextHeaderMenuToFocus(fallback?.node); 11688 }; 11689 const handleHeaderContextMenu = (event) => { 11690 event.preventDefault(); 11691 event.stopPropagation(); 11692 const virtualAnchor = { 11693 getBoundingClientRect: () => ({ 11694 x: event.clientX, 11695 y: event.clientY, 11696 top: event.clientY, 11697 left: event.clientX, 11698 right: event.clientX, 11699 bottom: event.clientY, 11700 width: 0, 11701 height: 0, 11702 toJSON: () => ({}) 11703 }) 11704 }; 11705 window.requestAnimationFrame(() => { 11706 setContextMenuAnchor(virtualAnchor); 11707 }); 11708 }; 11709 const hasData = !!data?.length; 11710 const titleField = fields.find((field) => field.id === view.titleField); 11711 const mediaField = fields.find((field) => field.id === view.mediaField); 11712 const descriptionField2 = fields.find( 11713 (field) => field.id === view.descriptionField 11714 ); 11715 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null; 11716 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null; 11717 const { showTitle = true, showMedia = true, showDescription = true } = view; 11718 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField2 && showDescription; 11719 const columns = view.fields ?? []; 11720 const headerMenuRef = (column, index2) => (node) => { 11721 if (node) { 11722 headerMenuRefs.current.set(column, { 11723 node, 11724 fallback: columns[index2 > 0 ? index2 - 1 : 1] 11725 }); 11726 } else { 11727 headerMenuRefs.current.delete(column); 11728 } 11729 }; 11730 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup; 11731 const isRtl = (0, import_i18n15.isRTL)(); 11732 if (!hasData) { 11733 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)( 11734 "div", 11735 { 11736 className: clsx_default("dataviews-no-results", { 11737 "is-refreshing": isDelayedLoading 11738 }), 11739 id: tableNoticeId, 11740 children: empty 11741 } 11742 ); 11743 } 11744 return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(import_jsx_runtime54.Fragment, { children: [ 11745 /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)( 11746 "table", 11747 { 11748 className: clsx_default("dataviews-view-table", className, { 11749 [`has-$view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes( 11750 view.layout.density 11751 ), 11752 "has-bulk-actions": hasBulkActions, 11753 "is-refreshing": !isInfiniteScroll && isDelayedLoading 11754 }), 11755 "aria-busy": isLoading, 11756 "aria-describedby": tableNoticeId, 11757 role: isInfiniteScroll ? "feed" : void 0, 11758 inert: !isInfiniteScroll && isLoading ? "true" : void 0, 11759 children: [ 11760 /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("colgroup", { children: [ 11761 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("col", { className: "dataviews-view-table__col-checkbox" }), 11762 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("col", { className: "dataviews-view-table__col-first-data" }), 11763 columns.map((column, index2) => /* @__PURE__ */ (0, import_jsx_runtime54.jsx)( 11764 "col", 11765 { 11766 className: clsx_default( 11767 `dataviews-view-table__col-$column}`, 11768 { 11769 "dataviews-view-table__col-expand": !hasPrimaryColumn && index2 === columns.length - 1 11770 } 11771 ) 11772 }, 11773 `col-$column}` 11774 )), 11775 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("col", { className: "dataviews-view-table__col-actions" }) 11776 ] }), 11777 contextMenuAnchor && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)( 11778 import_components6.Popover, 11779 { 11780 anchor: contextMenuAnchor, 11781 onClose: () => setContextMenuAnchor(null), 11782 placement: "bottom-start", 11783 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(PropertiesSection, { showLabel: false }) 11784 } 11785 ), 11786 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)( 11787 "thead", 11788 { 11789 className: clsx_default({ 11790 "dataviews-view-table__thead--stuck": isVerticallyScrolled 11791 }), 11792 onContextMenu: handleHeaderContextMenu, 11793 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("tr", { className: "dataviews-view-table__row", children: [ 11794 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)( 11795 "th", 11796 { 11797 className: "dataviews-view-table__checkbox-column", 11798 scope: "col", 11799 onContextMenu: handleHeaderContextMenu, 11800 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)( 11801 BulkSelectionCheckbox, 11802 { 11803 selection, 11804 onChangeSelection, 11805 data, 11806 actions, 11807 getItemId 11808 } 11809 ) 11810 } 11811 ), 11812 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("th", { scope: "col", children: titleField && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)( 11813 column_header_menu_default, 11814 { 11815 ref: headerMenuRef( 11816 titleField.id, 11817 0 11818 ), 11819 fieldId: titleField.id, 11820 view, 11821 fields, 11822 onChangeView, 11823 onHide, 11824 setOpenedFilter, 11825 canMove: false, 11826 canInsertLeft: isRtl ? view.layout?.enableMoving ?? true : false, 11827 canInsertRight: isRtl ? false : view.layout?.enableMoving ?? true 11828 } 11829 ) }), 11830 columns.map((column, index2) => { 11831 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {}; 11832 const field = fields.find( 11833 (f2) => f2.id === column 11834 ); 11835 const effectiveAlign = getEffectiveAlign( 11836 align, 11837 field?.type 11838 ); 11839 const canInsertOrMove = view.layout?.enableMoving ?? true; 11840 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)( 11841 "th", 11842 { 11843 style: { 11844 width, 11845 maxWidth, 11846 minWidth, 11847 textAlign: effectiveAlign 11848 }, 11849 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0, 11850 scope: "col", 11851 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)( 11852 column_header_menu_default, 11853 { 11854 ref: headerMenuRef(column, index2), 11855 fieldId: column, 11856 view, 11857 fields, 11858 onChangeView, 11859 onHide, 11860 setOpenedFilter, 11861 canMove: canInsertOrMove, 11862 canInsertLeft: canInsertOrMove, 11863 canInsertRight: canInsertOrMove 11864 } 11865 ) 11866 }, 11867 column 11868 ); 11869 }), 11870 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)( 11871 "th", 11872 { 11873 className: clsx_default( 11874 "dataviews-view-table__actions-column", 11875 { 11876 "dataviews-view-table__actions-column--sticky": true, 11877 "dataviews-view-table__actions-column--stuck": !isHorizontalScrollEnd 11878 } 11879 ), 11880 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { className: "dataviews-view-table-header", children: (0, import_i18n15.__)("Actions") }) 11881 } 11882 ) 11883 ] }) 11884 } 11885 ), 11886 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map( 11887 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("tbody", { children: [ 11888 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("tr", { className: "dataviews-view-table__group-header-row", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)( 11889 "td", 11890 { 11891 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + (hasBulkActions ? 1 : 0) + (actions?.length ? 1 : 0), 11892 className: "dataviews-view-table__group-header-cell", 11893 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n15.sprintf)( 11894 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". 11895 (0, import_i18n15.__)("%1$s: %2$s"), 11896 groupField.label, 11897 groupName 11898 ) 11899 } 11900 ) }), 11901 groupItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime54.jsx)( 11902 TableRow, 11903 { 11904 item, 11905 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0, 11906 hasBulkActions, 11907 actions, 11908 fields, 11909 id: getItemId(item) || index2.toString(), 11910 view, 11911 titleField, 11912 mediaField, 11913 descriptionField: descriptionField2, 11914 selection, 11915 getItemId, 11916 onChangeSelection, 11917 onClickItem, 11918 renderItemLink, 11919 isItemClickable: isItemClickable2, 11920 isActionsColumnSticky: !isHorizontalScrollEnd 11921 }, 11922 getItemId(item) 11923 )) 11924 ] }, `group-$groupName}`) 11925 ) : /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("tbody", { children: hasData && data.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime54.jsx)( 11926 TableRow, 11927 { 11928 item, 11929 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0, 11930 hasBulkActions, 11931 actions, 11932 fields, 11933 id: getItemId(item) || index2.toString(), 11934 view, 11935 titleField, 11936 mediaField, 11937 descriptionField: descriptionField2, 11938 selection, 11939 getItemId, 11940 onChangeSelection, 11941 onClickItem, 11942 renderItemLink, 11943 isItemClickable: isItemClickable2, 11944 isActionsColumnSticky: !isHorizontalScrollEnd, 11945 posinset: isInfiniteScroll ? index2 + 1 : void 0 11946 }, 11947 getItemId(item) 11948 )) }) 11949 ] 11950 } 11951 ), 11952 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "dataviews-loading", id: tableNoticeId, children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_components6.Spinner, {}) }) }) 11953 ] }); 11954 } 11955 var table_default = ViewTable; 11956 11957 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs 11958 var import_components9 = __toESM(require_components(), 1); 11959 var import_i18n18 = __toESM(require_i18n(), 1); 11960 11961 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs 11962 var import_components8 = __toESM(require_components(), 1); 11963 var import_i18n17 = __toESM(require_i18n(), 1); 11964 var import_compose3 = __toESM(require_compose(), 1); 11965 var import_keycodes2 = __toESM(require_keycodes(), 1); 11966 var import_element30 = __toESM(require_element(), 1); 11967 11968 // packages/dataviews/build-module/components/dataviews-layouts/grid/preview-size-picker.mjs 11969 var import_components7 = __toESM(require_components(), 1); 11970 var import_i18n16 = __toESM(require_i18n(), 1); 11971 var import_element27 = __toESM(require_element(), 1); 11972 var import_jsx_runtime55 = __toESM(require_jsx_runtime(), 1); 11973 var imageSizes = [ 11974 { 11975 value: 120, 11976 breakpoint: 1 11977 }, 11978 { 11979 value: 170, 11980 breakpoint: 1 11981 }, 11982 { 11983 value: 230, 11984 breakpoint: 1 11985 }, 11986 { 11987 value: 290, 11988 breakpoint: 1112 11989 // at minimum image width, 4 images display at this container size 11990 }, 11991 { 11992 value: 350, 11993 breakpoint: 1636 11994 // at minimum image width, 6 images display at this container size 11995 }, 11996 { 11997 value: 430, 11998 breakpoint: 588 11999 // at minimum image width, 2 images display at this container size 12000 } 12001 ]; 12002 var DEFAULT_PREVIEW_SIZE = imageSizes[2].value; 12003 function useGridColumns() { 12004 const context = (0, import_element27.useContext)(dataviews_context_default); 12005 const view = context.view; 12006 return (0, import_element27.useMemo)(() => { 12007 const containerWidth = context.containerWidth; 12008 const gap = 32; 12009 const previewSize = view.layout?.previewSize ?? DEFAULT_PREVIEW_SIZE; 12010 const columns = Math.floor( 12011 (containerWidth + gap) / (previewSize + gap) 12012 ); 12013 return Math.max(1, columns); 12014 }, [context.containerWidth, view.layout?.previewSize]); 12015 } 12016 12017 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-items.mjs 12018 var import_element28 = __toESM(require_element(), 1); 12019 var import_jsx_runtime56 = __toESM(require_jsx_runtime(), 1); 12020 var GridItems = (0, import_element28.forwardRef)(({ className, previewSize, ...props }, ref) => { 12021 return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)( 12022 "div", 12023 { 12024 ref, 12025 className: clsx_default("dataviews-view-grid-items", className), 12026 style: { 12027 gridTemplateColumns: previewSize && `repeat(auto-fill, minmax($previewSize}px, 1fr))` 12028 }, 12029 ...props 12030 } 12031 ); 12032 }); 12033 12034 // packages/dataviews/build-module/components/dataviews-layouts/utils/use-infinite-scroll.mjs 12035 var import_element29 = __toESM(require_element(), 1); 12036 function useIntersectionObserver(elementRef, posinset) { 12037 const { intersectionObserver } = (0, import_element29.useContext)(dataviews_context_default); 12038 (0, import_element29.useEffect)(() => { 12039 const element = elementRef.current; 12040 if (!element || posinset === void 0 || !intersectionObserver) { 12041 return; 12042 } 12043 intersectionObserver.observe(element); 12044 return () => { 12045 intersectionObserver.unobserve(element); 12046 }; 12047 }, [elementRef, intersectionObserver, posinset]); 12048 } 12049 function usePlaceholdersNeeded(data, isInfiniteScroll, gridColumns) { 12050 const hasData = !!data?.length; 12051 const firstItemPosition = hasData && isInfiniteScroll ? data[0].position : void 0; 12052 return firstItemPosition && gridColumns ? (firstItemPosition - 1) % gridColumns : 0; 12053 } 12054 12055 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs 12056 var import_jsx_runtime57 = __toESM(require_jsx_runtime(), 1); 12057 var { Badge: WCBadge } = unlock2(import_components8.privateApis); 12058 function chunk(array, size4) { 12059 const chunks = []; 12060 for (let i2 = 0, j2 = array.length; i2 < j2; i2 += size4) { 12061 chunks.push(array.slice(i2, i2 + size4)); 12062 } 12063 return chunks; 12064 } 12065 var GridItem = (0, import_element30.forwardRef)( 12066 function GridItem2({ 12067 view, 12068 selection, 12069 onChangeSelection, 12070 onClickItem, 12071 isItemClickable: isItemClickable2, 12072 renderItemLink, 12073 getItemId, 12074 item, 12075 actions, 12076 mediaField, 12077 titleField, 12078 descriptionField: descriptionField2, 12079 regularFields, 12080 badgeFields, 12081 hasBulkActions, 12082 config, 12083 posinset, 12084 setsize, 12085 ...props 12086 }, forwardedRef) { 12087 const { 12088 showTitle = true, 12089 showMedia = true, 12090 showDescription = true 12091 } = view; 12092 const hasBulkAction = useHasAPossibleBulkAction(actions, item); 12093 const id = getItemId(item); 12094 const elementRef = (0, import_element30.useRef)(null); 12095 const setRefs = (0, import_element30.useCallback)( 12096 (node) => { 12097 elementRef.current = node; 12098 if (typeof forwardedRef === "function") { 12099 forwardedRef(node); 12100 } else if (forwardedRef) { 12101 forwardedRef.current = node; 12102 } 12103 }, 12104 [forwardedRef] 12105 ); 12106 useIntersectionObserver(elementRef, posinset); 12107 const instanceId = (0, import_compose3.useInstanceId)(GridItem2); 12108 const isSelected2 = selection.includes(id); 12109 const mediaPlaceholder = /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("span", { className: "dataviews-view-grid__media-placeholder" }); 12110 const rendersMediaField = showMedia && mediaField?.render; 12111 const renderedMediaField = rendersMediaField ? /* @__PURE__ */ (0, import_jsx_runtime57.jsx)( 12112 mediaField.render, 12113 { 12114 item, 12115 field: mediaField, 12116 config 12117 } 12118 ) : mediaPlaceholder; 12119 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(titleField.render, { item, field: titleField }) : null; 12120 let mediaA11yProps; 12121 let titleA11yProps; 12122 if (isItemClickable2(item) && onClickItem) { 12123 if (renderedTitleField) { 12124 mediaA11yProps = { 12125 "aria-labelledby": `dataviews-view-grid__title-field-$instanceId}` 12126 }; 12127 titleA11yProps = { 12128 id: `dataviews-view-grid__title-field-$instanceId}` 12129 }; 12130 } else { 12131 mediaA11yProps = { 12132 "aria-label": (0, import_i18n17.__)("Navigate to item") 12133 }; 12134 } 12135 } 12136 return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)( 12137 Stack, 12138 { 12139 direction: "column", 12140 ...props, 12141 ref: setRefs, 12142 "aria-setsize": setsize, 12143 "aria-posinset": posinset, 12144 className: clsx_default( 12145 props.className, 12146 "dataviews-view-grid__row__gridcell", 12147 "dataviews-view-grid__card", 12148 { 12149 "is-selected": hasBulkAction && isSelected2 12150 } 12151 ), 12152 onClickCapture: (event) => { 12153 props.onClickCapture?.(event); 12154 if ((0, import_keycodes2.isAppleOS)() ? event.metaKey : event.ctrlKey) { 12155 event.stopPropagation(); 12156 event.preventDefault(); 12157 if (!hasBulkAction) { 12158 return; 12159 } 12160 onChangeSelection( 12161 isSelected2 ? selection.filter( 12162 (itemId) => id !== itemId 12163 ) : [...selection, id] 12164 ); 12165 } 12166 }, 12167 children: [ 12168 /* @__PURE__ */ (0, import_jsx_runtime57.jsx)( 12169 ItemClickWrapper, 12170 { 12171 item, 12172 isItemClickable: isItemClickable2, 12173 onClickItem, 12174 renderItemLink, 12175 className: clsx_default("dataviews-view-grid__media", { 12176 "dataviews-view-grid__media--placeholder": !rendersMediaField 12177 }), 12178 ...mediaA11yProps, 12179 children: renderedMediaField 12180 } 12181 ), 12182 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)( 12183 DataViewsSelectionCheckbox, 12184 { 12185 item, 12186 selection, 12187 onChangeSelection, 12188 getItemId, 12189 titleField, 12190 disabled: !hasBulkAction 12191 } 12192 ), 12193 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "dataviews-view-grid__media-actions", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)( 12194 ItemActions, 12195 { 12196 item, 12197 actions, 12198 isCompact: true 12199 } 12200 ) }), 12201 showTitle && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "dataviews-view-grid__title-actions", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)( 12202 ItemClickWrapper, 12203 { 12204 item, 12205 isItemClickable: isItemClickable2, 12206 onClickItem, 12207 renderItemLink, 12208 className: "dataviews-view-grid__title-field dataviews-title-field", 12209 ...titleA11yProps, 12210 title: titleField?.getValueFormatted({ 12211 item, 12212 field: titleField 12213 }) || void 0, 12214 children: renderedTitleField 12215 } 12216 ) }), 12217 /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(Stack, { direction: "column", gap: "xs", children: [ 12218 showDescription && descriptionField2?.render && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)( 12219 descriptionField2.render, 12220 { 12221 item, 12222 field: descriptionField2 12223 } 12224 ), 12225 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)( 12226 Stack, 12227 { 12228 direction: "row", 12229 className: "dataviews-view-grid__badge-fields", 12230 gap: "sm", 12231 wrap: "wrap", 12232 align: "top", 12233 justify: "flex-start", 12234 children: badgeFields.map((field) => { 12235 return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)( 12236 WCBadge, 12237 { 12238 className: "dataviews-view-grid__field-value", 12239 children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)( 12240 field.render, 12241 { 12242 item, 12243 field 12244 } 12245 ) 12246 }, 12247 field.id 12248 ); 12249 }) 12250 } 12251 ), 12252 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)( 12253 Stack, 12254 { 12255 direction: "column", 12256 className: "dataviews-view-grid__fields", 12257 gap: "xs", 12258 children: regularFields.map((field) => { 12259 return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)( 12260 import_components8.Flex, 12261 { 12262 className: "dataviews-view-grid__field", 12263 gap: 1, 12264 justify: "flex-start", 12265 expanded: true, 12266 style: { height: "auto" }, 12267 direction: "row", 12268 children: /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(import_jsx_runtime57.Fragment, { children: [ 12269 /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(tooltip_exports.Root, { children: [ 12270 /* @__PURE__ */ (0, import_jsx_runtime57.jsx)( 12271 tooltip_exports.Trigger, 12272 { 12273 render: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(import_components8.FlexItem, { className: "dataviews-view-grid__field-name", children: field.header }) 12274 } 12275 ), 12276 /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(tooltip_exports.Popup, { children: field.label }) 12277 ] }), 12278 /* @__PURE__ */ (0, import_jsx_runtime57.jsx)( 12279 import_components8.FlexItem, 12280 { 12281 className: "dataviews-view-grid__field-value", 12282 style: { maxHeight: "none" }, 12283 children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)( 12284 field.render, 12285 { 12286 item, 12287 field 12288 } 12289 ) 12290 } 12291 ) 12292 ] }) 12293 }, 12294 field.id 12295 ); 12296 }) 12297 } 12298 ) 12299 ] }) 12300 ] 12301 } 12302 ); 12303 } 12304 ); 12305 function CompositeGrid({ 12306 data, 12307 isInfiniteScroll, 12308 className, 12309 inert, 12310 isLoading, 12311 view, 12312 fields, 12313 selection, 12314 onChangeSelection, 12315 onClickItem, 12316 isItemClickable: isItemClickable2, 12317 renderItemLink, 12318 getItemId, 12319 actions 12320 }) { 12321 const { paginationInfo, resizeObserverRef } = (0, import_element30.useContext)(dataviews_context_default); 12322 const gridColumns = useGridColumns(); 12323 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data); 12324 const titleField = fields.find( 12325 (field) => field.id === view?.titleField 12326 ); 12327 const mediaField = fields.find( 12328 (field) => field.id === view?.mediaField 12329 ); 12330 const descriptionField2 = fields.find( 12331 (field) => field.id === view?.descriptionField 12332 ); 12333 const otherFields = view.fields ?? []; 12334 const { regularFields, badgeFields } = otherFields.reduce( 12335 (accumulator, fieldId) => { 12336 const field = fields.find((f2) => f2.id === fieldId); 12337 if (!field) { 12338 return accumulator; 12339 } 12340 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields"; 12341 accumulator[key].push(field); 12342 return accumulator; 12343 }, 12344 { regularFields: [], badgeFields: [] } 12345 ); 12346 const size4 = "900px"; 12347 const totalRows = Math.ceil(data.length / gridColumns); 12348 const placeholdersNeeded = usePlaceholdersNeeded( 12349 data, 12350 isInfiniteScroll, 12351 gridColumns 12352 ); 12353 return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(import_jsx_runtime57.Fragment, { 12354 // Render infinite scroll layout (no rows, feed semantics) 12355 children: [ 12356 isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)( 12357 import_components8.Composite, 12358 { 12359 render: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)( 12360 GridItems, 12361 { 12362 className: clsx_default( 12363 "dataviews-view-grid-infinite-scroll", 12364 className, 12365 { 12366 [`has-$view.layout?.density}-density`]: view.layout?.density && [ 12367 "compact", 12368 "comfortable" 12369 ].includes(view.layout.density) 12370 } 12371 ), 12372 previewSize: view.layout?.previewSize, 12373 "aria-busy": isLoading, 12374 ref: resizeObserverRef 12375 } 12376 ), 12377 role: "feed", 12378 focusWrap: true, 12379 inert, 12380 children: [ 12381 Array.from({ length: placeholdersNeeded }).map( 12382 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)( 12383 import_components8.Composite.Item, 12384 { 12385 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)( 12386 Stack, 12387 { 12388 ...props, 12389 direction: "column", 12390 role: "article", 12391 className: "dataviews-view-grid__row__gridcell dataviews-view-grid__card dataviews-view-grid__placeholder" 12392 } 12393 ), 12394 "aria-hidden": true, 12395 tabIndex: -1 12396 }, 12397 `placeholder-$index2}` 12398 ) 12399 ), 12400 data.map((item) => { 12401 const itemId = getItemId(item); 12402 const stablePosition = item.position; 12403 return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)( 12404 import_components8.Composite.Item, 12405 { 12406 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)( 12407 GridItem, 12408 { 12409 ...props, 12410 id: itemId, 12411 role: "article", 12412 view, 12413 selection, 12414 onChangeSelection, 12415 onClickItem, 12416 isItemClickable: isItemClickable2, 12417 renderItemLink, 12418 getItemId, 12419 item, 12420 actions, 12421 mediaField, 12422 titleField, 12423 descriptionField: descriptionField2, 12424 regularFields, 12425 badgeFields, 12426 hasBulkActions, 12427 posinset: stablePosition, 12428 setsize: paginationInfo.totalItems, 12429 config: { 12430 sizes: size4 12431 } 12432 } 12433 ) 12434 }, 12435 itemId 12436 ); 12437 }) 12438 ] 12439 } 12440 ), 12441 // Render standard grid layout (with rows, grid semantics) 12442 !isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)( 12443 import_components8.Composite, 12444 { 12445 role: "grid", 12446 className: clsx_default("dataviews-view-grid", className, { 12447 [`has-$view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes( 12448 view.layout.density 12449 ) 12450 }), 12451 focusWrap: true, 12452 "aria-busy": isLoading, 12453 "aria-rowcount": totalRows, 12454 ref: resizeObserverRef, 12455 inert, 12456 children: chunk(data, gridColumns).map((row, i2) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)( 12457 import_components8.Composite.Row, 12458 { 12459 render: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)( 12460 "div", 12461 { 12462 role: "row", 12463 "aria-rowindex": i2 + 1, 12464 "aria-label": (0, import_i18n17.sprintf)( 12465 /* translators: %d: The row number in the grid */ 12466 (0, import_i18n17.__)("Row %d"), 12467 i2 + 1 12468 ), 12469 className: "dataviews-view-grid__row", 12470 style: { 12471 gridTemplateColumns: `repeat( $gridColumns}, minmax(0, 1fr) )` 12472 } 12473 } 12474 ), 12475 children: row.map((item) => { 12476 const itemId = getItemId(item); 12477 return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)( 12478 import_components8.Composite.Item, 12479 { 12480 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)( 12481 GridItem, 12482 { 12483 ...props, 12484 id: itemId, 12485 role: "gridcell", 12486 view, 12487 selection, 12488 onChangeSelection, 12489 onClickItem, 12490 isItemClickable: isItemClickable2, 12491 renderItemLink, 12492 getItemId, 12493 item, 12494 actions, 12495 mediaField, 12496 titleField, 12497 descriptionField: descriptionField2, 12498 regularFields, 12499 badgeFields, 12500 hasBulkActions, 12501 config: { 12502 sizes: size4 12503 } 12504 } 12505 ) 12506 }, 12507 itemId 12508 ); 12509 }) 12510 }, 12511 i2 12512 )) 12513 } 12514 ) 12515 ] 12516 }); 12517 } 12518 12519 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs 12520 var import_jsx_runtime58 = __toESM(require_jsx_runtime(), 1); 12521 function ViewGrid({ 12522 actions, 12523 data, 12524 fields, 12525 getItemId, 12526 isLoading, 12527 onChangeSelection, 12528 onClickItem, 12529 isItemClickable: isItemClickable2, 12530 renderItemLink, 12531 selection, 12532 view, 12533 className, 12534 empty 12535 }) { 12536 const isDelayedLoading = useDelayedLoading(!!isLoading); 12537 const hasData = !!data?.length; 12538 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null; 12539 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null; 12540 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup; 12541 if (!hasData) { 12542 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)( 12543 "div", 12544 { 12545 className: clsx_default("dataviews-no-results", { 12546 "is-refreshing": isDelayedLoading 12547 }), 12548 children: empty 12549 } 12550 ); 12551 } 12552 const gridProps = { 12553 className: clsx_default(className, { 12554 "is-refreshing": !isInfiniteScroll && isDelayedLoading 12555 }), 12556 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0, 12557 isLoading, 12558 view, 12559 fields, 12560 selection, 12561 onChangeSelection, 12562 onClickItem, 12563 isItemClickable: isItemClickable2, 12564 renderItemLink, 12565 getItemId, 12566 actions 12567 }; 12568 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_jsx_runtime58.Fragment, { 12569 // Render multiple groups. 12570 children: [ 12571 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(Stack, { direction: "column", gap: "lg", children: Array.from(dataByGroup.entries()).map( 12572 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)( 12573 Stack, 12574 { 12575 direction: "column", 12576 gap: "sm", 12577 children: [ 12578 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("h3", { className: "dataviews-view-grid__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n18.sprintf)( 12579 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". 12580 (0, import_i18n18.__)("%1$s: %2$s"), 12581 groupField.label, 12582 groupName 12583 ) }), 12584 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)( 12585 CompositeGrid, 12586 { 12587 ...gridProps, 12588 data: groupItems, 12589 isInfiniteScroll: false 12590 } 12591 ) 12592 ] 12593 }, 12594 groupName 12595 ) 12596 ) }), 12597 // Render a single grid with all data. 12598 !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)( 12599 CompositeGrid, 12600 { 12601 ...gridProps, 12602 data, 12603 isInfiniteScroll: !!isInfiniteScroll 12604 } 12605 ), 12606 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_components9.Spinner, {}) }) 12607 ] 12608 }); 12609 } 12610 var grid_default = ViewGrid; 12611 12612 // packages/dataviews/build-module/components/dataviews-layouts/list/index.mjs 12613 var import_compose4 = __toESM(require_compose(), 1); 12614 var import_components10 = __toESM(require_components(), 1); 12615 var import_element31 = __toESM(require_element(), 1); 12616 var import_i18n19 = __toESM(require_i18n(), 1); 12617 var import_data3 = __toESM(require_data(), 1); 12618 var import_jsx_runtime59 = __toESM(require_jsx_runtime(), 1); 12619 var { Menu: Menu3 } = unlock2(import_components10.privateApis); 12620 function generateItemWrapperCompositeId(idPrefix) { 12621 return `$idPrefix}-item-wrapper`; 12622 } 12623 function generatePrimaryActionCompositeId(idPrefix, primaryActionId) { 12624 return `$idPrefix}-primary-action-$primaryActionId}`; 12625 } 12626 function generateDropdownTriggerCompositeId(idPrefix) { 12627 return `$idPrefix}-dropdown`; 12628 } 12629 function PrimaryActionGridCell({ 12630 idPrefix, 12631 primaryAction, 12632 item 12633 }) { 12634 const registry = (0, import_data3.useRegistry)(); 12635 const [isModalOpen, setIsModalOpen] = (0, import_element31.useState)(false); 12636 const compositeItemId = generatePrimaryActionCompositeId( 12637 idPrefix, 12638 primaryAction.id 12639 ); 12640 const label = typeof primaryAction.label === "string" ? primaryAction.label : primaryAction.label([item]); 12641 return "RenderModal" in primaryAction ? /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 12642 import_components10.Composite.Item, 12643 { 12644 id: compositeItemId, 12645 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 12646 import_components10.Button, 12647 { 12648 disabled: !!primaryAction.disabled, 12649 accessibleWhenDisabled: true, 12650 text: label, 12651 size: "small", 12652 onClick: () => setIsModalOpen(true) 12653 } 12654 ), 12655 children: isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 12656 ActionModal, 12657 { 12658 action: primaryAction, 12659 items: [item], 12660 closeModal: () => setIsModalOpen(false) 12661 } 12662 ) 12663 } 12664 ) }, primaryAction.id) : /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 12665 import_components10.Composite.Item, 12666 { 12667 id: compositeItemId, 12668 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 12669 import_components10.Button, 12670 { 12671 disabled: !!primaryAction.disabled, 12672 accessibleWhenDisabled: true, 12673 size: "small", 12674 onClick: () => { 12675 primaryAction.callback([item], { registry }); 12676 }, 12677 children: label 12678 } 12679 ) 12680 } 12681 ) }, primaryAction.id); 12682 } 12683 function ListItem({ 12684 view, 12685 actions, 12686 idPrefix, 12687 isSelected: isSelected2, 12688 item, 12689 titleField, 12690 mediaField, 12691 descriptionField: descriptionField2, 12692 onSelect, 12693 otherFields, 12694 onDropdownTriggerKeyDown, 12695 posinset 12696 }) { 12697 const { 12698 showTitle = true, 12699 showMedia = true, 12700 showDescription = true, 12701 infiniteScrollEnabled 12702 } = view; 12703 const itemRef = (0, import_element31.useRef)(null); 12704 const labelId = `$idPrefix}-label`; 12705 const descriptionId = `$idPrefix}-description`; 12706 const registry = (0, import_data3.useRegistry)(); 12707 const [isHovered, setIsHovered] = (0, import_element31.useState)(false); 12708 const [activeModalAction, setActiveModalAction] = (0, import_element31.useState)( 12709 null 12710 ); 12711 const handleHover = ({ type }) => { 12712 const isHover = type === "mouseenter"; 12713 setIsHovered(isHover); 12714 }; 12715 const { paginationInfo } = (0, import_element31.useContext)(dataviews_context_default); 12716 (0, import_element31.useEffect)(() => { 12717 if (isSelected2) { 12718 itemRef.current?.scrollIntoView({ 12719 behavior: "auto", 12720 block: "nearest", 12721 inline: "nearest" 12722 }); 12723 } 12724 }, [isSelected2]); 12725 const { primaryAction, eligibleActions } = (0, import_element31.useMemo)(() => { 12726 const _eligibleActions = actions.filter( 12727 (action) => !action.isEligible || action.isEligible(item) 12728 ); 12729 const _primaryActions = _eligibleActions.filter( 12730 (action) => action.isPrimary 12731 ); 12732 return { 12733 primaryAction: _primaryActions[0], 12734 eligibleActions: _eligibleActions 12735 }; 12736 }, [actions, item]); 12737 const hasOnlyOnePrimaryAction = primaryAction && actions.length === 1; 12738 const renderedMediaField = showMedia && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className: "dataviews-view-list__media-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 12739 mediaField.render, 12740 { 12741 item, 12742 field: mediaField, 12743 config: { sizes: "52px" } 12744 } 12745 ) }) : null; 12746 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(titleField.render, { item, field: titleField }) : null; 12747 const renderDescription = showDescription && descriptionField2?.render; 12748 const hasOnlyMediaAndTitle = !!renderedMediaField && !renderDescription && !otherFields.length; 12749 const usedActions = eligibleActions?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)( 12750 Stack, 12751 { 12752 direction: "row", 12753 gap: "md", 12754 className: "dataviews-view-list__item-actions", 12755 children: [ 12756 primaryAction && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 12757 PrimaryActionGridCell, 12758 { 12759 idPrefix, 12760 primaryAction, 12761 item 12762 } 12763 ), 12764 !hasOnlyOnePrimaryAction && /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)("div", { role: "gridcell", children: [ 12765 /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(Menu3, { placement: "bottom-end", children: [ 12766 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 12767 Menu3.TriggerButton, 12768 { 12769 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 12770 import_components10.Composite.Item, 12771 { 12772 id: generateDropdownTriggerCompositeId( 12773 idPrefix 12774 ), 12775 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 12776 import_components10.Button, 12777 { 12778 size: "small", 12779 icon: more_vertical_default, 12780 label: (0, import_i18n19.__)("Actions"), 12781 accessibleWhenDisabled: true, 12782 disabled: !actions.length, 12783 onKeyDown: onDropdownTriggerKeyDown 12784 } 12785 ) 12786 } 12787 ) 12788 } 12789 ), 12790 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(Menu3.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 12791 ActionsMenuGroup, 12792 { 12793 actions: eligibleActions, 12794 item, 12795 registry, 12796 setActiveModalAction 12797 } 12798 ) }) 12799 ] }), 12800 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 12801 ActionModal, 12802 { 12803 action: activeModalAction, 12804 items: [item], 12805 closeModal: () => setActiveModalAction(null) 12806 } 12807 ) 12808 ] }) 12809 ] 12810 } 12811 ); 12812 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 12813 import_components10.Composite.Row, 12814 { 12815 ref: itemRef, 12816 render: ( 12817 /* aria-posinset breaks Composite.Row if passed to it directly. */ 12818 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 12819 "div", 12820 { 12821 "aria-posinset": posinset, 12822 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0 12823 } 12824 ) 12825 ), 12826 role: infiniteScrollEnabled ? "article" : "row", 12827 className: clsx_default({ 12828 "is-selected": isSelected2, 12829 "is-hovered": isHovered 12830 }), 12831 onMouseEnter: handleHover, 12832 onMouseLeave: handleHover, 12833 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)( 12834 Stack, 12835 { 12836 direction: "row", 12837 className: "dataviews-view-list__item-wrapper", 12838 children: [ 12839 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 12840 import_components10.Composite.Item, 12841 { 12842 id: generateItemWrapperCompositeId(idPrefix), 12843 "aria-pressed": isSelected2, 12844 "aria-labelledby": labelId, 12845 "aria-describedby": descriptionId, 12846 className: "dataviews-view-list__item", 12847 onClick: () => onSelect(item) 12848 } 12849 ) }), 12850 /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)( 12851 Stack, 12852 { 12853 direction: "row", 12854 gap: "md", 12855 justify: "start", 12856 align: hasOnlyMediaAndTitle ? "center" : "flex-start", 12857 style: { flex: 1, minWidth: 0 }, 12858 children: [ 12859 renderedMediaField, 12860 /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)( 12861 Stack, 12862 { 12863 direction: "column", 12864 gap: "xs", 12865 className: "dataviews-view-list__field-wrapper", 12866 children: [ 12867 /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(Stack, { direction: "row", align: "center", children: [ 12868 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 12869 "div", 12870 { 12871 className: "dataviews-title-field dataviews-view-list__title-field", 12872 id: labelId, 12873 children: renderedTitleField 12874 } 12875 ), 12876 usedActions 12877 ] }), 12878 renderDescription && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className: "dataviews-view-list__field", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 12879 descriptionField2.render, 12880 { 12881 item, 12882 field: descriptionField2 12883 } 12884 ) }), 12885 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 12886 "div", 12887 { 12888 className: "dataviews-view-list__fields", 12889 id: descriptionId, 12890 children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)( 12891 "div", 12892 { 12893 className: "dataviews-view-list__field", 12894 children: [ 12895 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 12896 VisuallyHidden, 12897 { 12898 className: "dataviews-view-list__field-label", 12899 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("span", {}), 12900 children: field.label 12901 } 12902 ), 12903 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("span", { className: "dataviews-view-list__field-value", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 12904 field.render, 12905 { 12906 item, 12907 field 12908 } 12909 ) }) 12910 ] 12911 }, 12912 field.id 12913 )) 12914 } 12915 ) 12916 ] 12917 } 12918 ) 12919 ] 12920 } 12921 ) 12922 ] 12923 } 12924 ) 12925 } 12926 ); 12927 } 12928 function isDefined2(item) { 12929 return !!item; 12930 } 12931 function ViewList(props) { 12932 const { 12933 actions, 12934 data, 12935 fields, 12936 getItemId, 12937 isLoading, 12938 onChangeSelection, 12939 selection, 12940 view, 12941 className, 12942 empty 12943 } = props; 12944 const baseId = (0, import_compose4.useInstanceId)(ViewList, "view-list"); 12945 const isDelayedLoading = useDelayedLoading(!!isLoading); 12946 const selectedItem = data?.findLast( 12947 (item) => selection.includes(getItemId(item)) 12948 ); 12949 const titleField = fields.find((field) => field.id === view.titleField); 12950 const mediaField = fields.find((field) => field.id === view.mediaField); 12951 const descriptionField2 = fields.find( 12952 (field) => field.id === view.descriptionField 12953 ); 12954 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined2); 12955 const onSelect = (item) => onChangeSelection([getItemId(item)]); 12956 const generateCompositeItemIdPrefix = (0, import_element31.useCallback)( 12957 (item) => `$baseId}-$getItemId(item)}`, 12958 [baseId, getItemId] 12959 ); 12960 const isActiveCompositeItem = (0, import_element31.useCallback)( 12961 (item, idToCheck) => { 12962 return idToCheck.startsWith( 12963 generateCompositeItemIdPrefix(item) 12964 ); 12965 }, 12966 [generateCompositeItemIdPrefix] 12967 ); 12968 const [activeCompositeId, setActiveCompositeId] = (0, import_element31.useState)(void 0); 12969 const compositeRef = (0, import_element31.useRef)(null); 12970 (0, import_element31.useEffect)(() => { 12971 if (selectedItem) { 12972 setActiveCompositeId( 12973 generateItemWrapperCompositeId( 12974 generateCompositeItemIdPrefix(selectedItem) 12975 ) 12976 ); 12977 } 12978 }, [selectedItem, generateCompositeItemIdPrefix]); 12979 const activeItemIndex = data.findIndex( 12980 (item) => isActiveCompositeItem(item, activeCompositeId ?? "") 12981 ); 12982 const previousActiveItemIndex = (0, import_compose4.usePrevious)(activeItemIndex); 12983 const isActiveIdInList = activeItemIndex !== -1; 12984 const selectCompositeItem = (0, import_element31.useCallback)( 12985 (targetIndex, generateCompositeId) => { 12986 const clampedIndex = Math.min( 12987 data.length - 1, 12988 Math.max(0, targetIndex) 12989 ); 12990 if (!data[clampedIndex]) { 12991 return; 12992 } 12993 const itemIdPrefix = generateCompositeItemIdPrefix( 12994 data[clampedIndex] 12995 ); 12996 const targetCompositeItemId = generateCompositeId(itemIdPrefix); 12997 setActiveCompositeId(targetCompositeItemId); 12998 if (compositeRef.current?.contains( 12999 compositeRef.current.ownerDocument.activeElement 13000 )) { 13001 document.getElementById(targetCompositeItemId)?.focus(); 13002 } 13003 }, 13004 [data, generateCompositeItemIdPrefix] 13005 ); 13006 (0, import_element31.useEffect)(() => { 13007 const wasActiveIdInList = previousActiveItemIndex !== void 0 && previousActiveItemIndex !== -1; 13008 if (!isActiveIdInList && wasActiveIdInList) { 13009 selectCompositeItem( 13010 previousActiveItemIndex, 13011 generateItemWrapperCompositeId 13012 ); 13013 } 13014 }, [isActiveIdInList, selectCompositeItem, previousActiveItemIndex]); 13015 const onDropdownTriggerKeyDown = (0, import_element31.useCallback)( 13016 (event) => { 13017 if (event.key === "ArrowDown") { 13018 event.preventDefault(); 13019 selectCompositeItem( 13020 activeItemIndex + 1, 13021 generateDropdownTriggerCompositeId 13022 ); 13023 } 13024 if (event.key === "ArrowUp") { 13025 event.preventDefault(); 13026 selectCompositeItem( 13027 activeItemIndex - 1, 13028 generateDropdownTriggerCompositeId 13029 ); 13030 } 13031 }, 13032 [selectCompositeItem, activeItemIndex] 13033 ); 13034 const hasData = !!data?.length; 13035 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null; 13036 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null; 13037 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup; 13038 if (!hasData) { 13039 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 13040 "div", 13041 { 13042 className: clsx_default("dataviews-no-results", { 13043 "is-refreshing": isDelayedLoading 13044 }), 13045 children: empty 13046 } 13047 ); 13048 } 13049 if (hasData && groupField && dataByGroup) { 13050 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 13051 import_components10.Composite, 13052 { 13053 ref: compositeRef, 13054 id: `$baseId}`, 13055 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", {}), 13056 className: "dataviews-view-list__group", 13057 role: "grid", 13058 activeId: activeCompositeId, 13059 setActiveId: setActiveCompositeId, 13060 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 13061 Stack, 13062 { 13063 direction: "column", 13064 gap: "lg", 13065 className: clsx_default("dataviews-view-list", className), 13066 children: Array.from(dataByGroup.entries()).map( 13067 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)( 13068 Stack, 13069 { 13070 direction: "column", 13071 gap: "sm", 13072 children: [ 13073 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("h3", { className: "dataviews-view-list__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n19.sprintf)( 13074 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". 13075 (0, import_i18n19.__)("%1$s: %2$s"), 13076 groupField.label, 13077 groupName 13078 ) }), 13079 groupItems.map((item) => { 13080 const id = generateCompositeItemIdPrefix(item); 13081 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 13082 ListItem, 13083 { 13084 view, 13085 idPrefix: id, 13086 actions, 13087 item, 13088 isSelected: item === selectedItem, 13089 onSelect, 13090 mediaField, 13091 titleField, 13092 descriptionField: descriptionField2, 13093 otherFields, 13094 onDropdownTriggerKeyDown 13095 }, 13096 id 13097 ); 13098 }) 13099 ] 13100 }, 13101 groupName 13102 ) 13103 ) 13104 } 13105 ) 13106 } 13107 ); 13108 } 13109 return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(import_jsx_runtime59.Fragment, { children: [ 13110 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 13111 import_components10.Composite, 13112 { 13113 ref: compositeRef, 13114 id: baseId, 13115 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", {}), 13116 className: clsx_default("dataviews-view-list", className, { 13117 [`has-$view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes( 13118 view.layout.density 13119 ), 13120 "is-refreshing": !isInfiniteScroll && isDelayedLoading 13121 }), 13122 role: view.infiniteScrollEnabled ? "feed" : "grid", 13123 activeId: activeCompositeId, 13124 setActiveId: setActiveCompositeId, 13125 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0, 13126 children: data.map((item, index2) => { 13127 const id = generateCompositeItemIdPrefix(item); 13128 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 13129 ListItem, 13130 { 13131 view, 13132 idPrefix: id, 13133 actions, 13134 item, 13135 isSelected: item === selectedItem, 13136 onSelect, 13137 mediaField, 13138 titleField, 13139 descriptionField: descriptionField2, 13140 otherFields, 13141 onDropdownTriggerKeyDown, 13142 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0 13143 }, 13144 id 13145 ); 13146 }) 13147 } 13148 ), 13149 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_components10.Spinner, {}) }) 13150 ] }); 13151 } 13152 13153 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs 13154 var import_components11 = __toESM(require_components(), 1); 13155 13156 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-group.mjs 13157 var import_i18n20 = __toESM(require_i18n(), 1); 13158 var import_element32 = __toESM(require_element(), 1); 13159 var import_jsx_runtime60 = __toESM(require_jsx_runtime(), 1); 13160 function ActivityGroup({ 13161 groupName, 13162 groupData, 13163 groupField, 13164 showLabel = true, 13165 children 13166 }) { 13167 const groupHeader = showLabel ? (0, import_element32.createInterpolateElement)( 13168 // translators: %s: The label of the field e.g. "Status". 13169 (0, import_i18n20.sprintf)((0, import_i18n20.__)("%s: <groupName />"), groupField.label).trim(), 13170 { 13171 groupName: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)( 13172 groupField.render, 13173 { 13174 item: groupData[0], 13175 field: groupField 13176 } 13177 ) 13178 } 13179 ) : /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(groupField.render, { item: groupData[0], field: groupField }); 13180 return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)( 13181 Stack, 13182 { 13183 direction: "column", 13184 className: "dataviews-view-activity__group", 13185 children: [ 13186 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("h3", { className: "dataviews-view-activity__group-header", children: groupHeader }), 13187 children 13188 ] 13189 }, 13190 groupName 13191 ); 13192 } 13193 13194 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-item.mjs 13195 var import_element33 = __toESM(require_element(), 1); 13196 var import_data4 = __toESM(require_data(), 1); 13197 var import_compose5 = __toESM(require_compose(), 1); 13198 var import_jsx_runtime61 = __toESM(require_jsx_runtime(), 1); 13199 function ActivityItem(props) { 13200 const { 13201 view, 13202 actions, 13203 item, 13204 titleField, 13205 mediaField, 13206 descriptionField: descriptionField2, 13207 otherFields, 13208 posinset, 13209 onClickItem, 13210 renderItemLink, 13211 isItemClickable: isItemClickable2 13212 } = props; 13213 const { 13214 showTitle = true, 13215 showMedia = true, 13216 showDescription = true, 13217 infiniteScrollEnabled 13218 } = view; 13219 const itemRef = (0, import_element33.useRef)(null); 13220 const registry = (0, import_data4.useRegistry)(); 13221 const { paginationInfo } = (0, import_element33.useContext)(dataviews_context_default); 13222 const { primaryActions, eligibleActions } = (0, import_element33.useMemo)(() => { 13223 const _eligibleActions = actions.filter( 13224 (action) => !action.isEligible || action.isEligible(item) 13225 ); 13226 const _primaryActions = _eligibleActions.filter( 13227 (action) => action.isPrimary 13228 ); 13229 return { 13230 primaryActions: _primaryActions, 13231 eligibleActions: _eligibleActions 13232 }; 13233 }, [actions, item]); 13234 const isMobileViewport = (0, import_compose5.useViewportMatch)("medium", "<"); 13235 const density = view.layout?.density ?? "balanced"; 13236 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 13237 mediaField.render, 13238 { 13239 item, 13240 field: mediaField, 13241 config: { 13242 sizes: density === "comfortable" ? "32px" : "24px" 13243 } 13244 } 13245 ) : null; 13246 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("div", { className: "dataviews-view-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 13247 "span", 13248 { 13249 className: "dataviews-view-activity__item-bullet", 13250 "aria-hidden": "true" 13251 } 13252 ) }); 13253 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(titleField.render, { item, field: titleField }) : null; 13254 const verticalGap = (0, import_element33.useMemo)(() => { 13255 switch (density) { 13256 case "comfortable": 13257 return "md"; 13258 default: 13259 return "sm"; 13260 } 13261 }, [density]); 13262 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 13263 "div", 13264 { 13265 ref: itemRef, 13266 role: infiniteScrollEnabled ? "article" : void 0, 13267 "aria-posinset": posinset, 13268 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0, 13269 className: clsx_default( 13270 "dataviews-view-activity__item", 13271 density === "compact" && "is-compact", 13272 density === "balanced" && "is-balanced", 13273 density === "comfortable" && "is-comfortable" 13274 ), 13275 children: /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [ 13276 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 13277 Stack, 13278 { 13279 direction: "column", 13280 gap: "xs", 13281 align: "center", 13282 className: "dataviews-view-activity__item-type", 13283 children: renderedMediaField 13284 } 13285 ), 13286 /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)( 13287 Stack, 13288 { 13289 direction: "column", 13290 gap: verticalGap, 13291 align: "flex-start", 13292 className: "dataviews-view-activity__item-content", 13293 children: [ 13294 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 13295 ItemClickWrapper, 13296 { 13297 item, 13298 isItemClickable: isItemClickable2, 13299 onClickItem, 13300 renderItemLink, 13301 className: "dataviews-view-activity__item-title", 13302 children: renderedTitleField 13303 } 13304 ), 13305 showDescription && descriptionField2 && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("div", { className: "dataviews-view-activity__item-description", children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 13306 descriptionField2.render, 13307 { 13308 item, 13309 field: descriptionField2 13310 } 13311 ) }), 13312 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("div", { className: "dataviews-view-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)( 13313 "div", 13314 { 13315 className: "dataviews-view-activity__item-field", 13316 children: [ 13317 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 13318 VisuallyHidden, 13319 { 13320 className: "dataviews-view-activity__item-field-label", 13321 render: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("span", {}), 13322 children: field.label 13323 } 13324 ), 13325 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("span", { className: "dataviews-view-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 13326 field.render, 13327 { 13328 item, 13329 field 13330 } 13331 ) }) 13332 ] 13333 }, 13334 field.id 13335 )) }), 13336 !!primaryActions?.length && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 13337 PrimaryActions, 13338 { 13339 item, 13340 actions: primaryActions, 13341 registry, 13342 buttonVariant: "secondary" 13343 } 13344 ) 13345 ] 13346 } 13347 ), 13348 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu 13349 // there if there are any actions at all. 13350 isMobileViewport && // At the same time, only show the menu if there are actions to show. 13351 eligibleActions.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("div", { className: "dataviews-view-activity__item-actions", children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 13352 ItemActions, 13353 { 13354 item, 13355 actions: eligibleActions, 13356 isCompact: true 13357 } 13358 ) }) 13359 ] }) 13360 } 13361 ); 13362 } 13363 var activity_item_default = ActivityItem; 13364 13365 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-items.mjs 13366 var import_react5 = __toESM(require_react(), 1); 13367 function isDefined3(item) { 13368 return !!item; 13369 } 13370 function ActivityItems(props) { 13371 const { data, fields, getItemId, view } = props; 13372 const titleField = fields.find((field) => field.id === view.titleField); 13373 const mediaField = fields.find((field) => field.id === view.mediaField); 13374 const descriptionField2 = fields.find( 13375 (field) => field.id === view.descriptionField 13376 ); 13377 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined3); 13378 return data.map((item, index2) => { 13379 return /* @__PURE__ */ (0, import_react5.createElement)( 13380 activity_item_default, 13381 { 13382 ...props, 13383 key: getItemId(item), 13384 item, 13385 mediaField, 13386 titleField, 13387 descriptionField: descriptionField2, 13388 otherFields, 13389 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0 13390 } 13391 ); 13392 }); 13393 } 13394 13395 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs 13396 var import_jsx_runtime62 = __toESM(require_jsx_runtime(), 1); 13397 function ViewActivity(props) { 13398 const { empty, data, fields, isLoading, view, className } = props; 13399 const isDelayedLoading = useDelayedLoading(!!isLoading); 13400 const hasData = !!data?.length; 13401 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null; 13402 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null; 13403 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup; 13404 if (!hasData) { 13405 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)( 13406 "div", 13407 { 13408 className: clsx_default("dataviews-no-results", { 13409 "is-refreshing": isDelayedLoading 13410 }), 13411 children: empty 13412 } 13413 ); 13414 } 13415 const isInert = !isInfiniteScroll && !!isLoading; 13416 const wrapperClassName = clsx_default("dataviews-view-activity", className, { 13417 "is-refreshing": !isInfiniteScroll && isDelayedLoading 13418 }); 13419 const groupedEntries = dataByGroup ? Array.from(dataByGroup.entries()) : []; 13420 if (hasData && groupField && dataByGroup) { 13421 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)( 13422 Stack, 13423 { 13424 direction: "column", 13425 gap: "sm", 13426 className: wrapperClassName, 13427 inert: isInert ? "true" : void 0, 13428 children: groupedEntries.map( 13429 ([groupName, groupData]) => /* @__PURE__ */ (0, import_jsx_runtime62.jsx)( 13430 ActivityGroup, 13431 { 13432 groupName, 13433 groupData, 13434 groupField, 13435 showLabel: view.groupBy?.showLabel !== false, 13436 children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)( 13437 ActivityItems, 13438 { 13439 ...props, 13440 data: groupData 13441 } 13442 ) 13443 }, 13444 groupName 13445 ) 13446 ) 13447 } 13448 ); 13449 } 13450 return /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(import_jsx_runtime62.Fragment, { children: [ 13451 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)( 13452 "div", 13453 { 13454 className: wrapperClassName, 13455 role: view.infiniteScrollEnabled ? "feed" : void 0, 13456 inert: isInert ? "true" : void 0, 13457 children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(ActivityItems, { ...props }) 13458 } 13459 ), 13460 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(import_components11.Spinner, {}) }) 13461 ] }); 13462 } 13463 13464 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs 13465 var import_components14 = __toESM(require_components(), 1); 13466 var import_i18n23 = __toESM(require_i18n(), 1); 13467 var import_compose6 = __toESM(require_compose(), 1); 13468 var import_element36 = __toESM(require_element(), 1); 13469 13470 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs 13471 var import_components13 = __toESM(require_components(), 1); 13472 var import_data5 = __toESM(require_data(), 1); 13473 var import_element35 = __toESM(require_element(), 1); 13474 var import_i18n22 = __toESM(require_i18n(), 1); 13475 13476 // packages/dataviews/build-module/components/dataviews-pagination/index.mjs 13477 var import_components12 = __toESM(require_components(), 1); 13478 var import_element34 = __toESM(require_element(), 1); 13479 var import_i18n21 = __toESM(require_i18n(), 1); 13480 var import_jsx_runtime63 = __toESM(require_jsx_runtime(), 1); 13481 function DataViewsPagination() { 13482 const { 13483 view, 13484 onChangeView, 13485 paginationInfo: { totalItems = 0, totalPages } 13486 } = (0, import_element34.useContext)(dataviews_context_default); 13487 if (!totalItems || !totalPages || view.infiniteScrollEnabled) { 13488 return null; 13489 } 13490 const currentPage = view.page ?? 1; 13491 const pageSelectOptions = Array.from(Array(totalPages)).map( 13492 (_, i2) => { 13493 const page = i2 + 1; 13494 return { 13495 value: page.toString(), 13496 label: page.toString(), 13497 "aria-label": currentPage === page ? (0, import_i18n21.sprintf)( 13498 // translators: 1: current page number. 2: total number of pages. 13499 (0, import_i18n21.__)("Page %1$d of %2$d"), 13500 currentPage, 13501 totalPages 13502 ) : page.toString() 13503 }; 13504 } 13505 ); 13506 return !!totalItems && totalPages !== 1 && /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)( 13507 Stack, 13508 { 13509 direction: "row", 13510 className: "dataviews-pagination", 13511 justify: "end", 13512 align: "center", 13513 gap: "xl", 13514 children: [ 13515 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)( 13516 Stack, 13517 { 13518 direction: "row", 13519 justify: "flex-start", 13520 align: "center", 13521 gap: "xs", 13522 className: "dataviews-pagination__page-select", 13523 children: (0, import_element34.createInterpolateElement)( 13524 (0, import_i18n21.sprintf)( 13525 // translators: 1: Current page number, 2: Total number of pages. 13526 (0, import_i18n21._x)( 13527 "<div>Page</div>%1$s<div>of %2$d</div>", 13528 "paging" 13529 ), 13530 "<CurrentPage />", 13531 totalPages 13532 ), 13533 { 13534 div: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("div", { "aria-hidden": true }), 13535 // @ts-expect-error — Tag injected via sprintf argument, not visible in format string. 13536 CurrentPage: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)( 13537 import_components12.SelectControl, 13538 { 13539 "aria-label": (0, import_i18n21.__)("Current page"), 13540 value: currentPage.toString(), 13541 options: pageSelectOptions, 13542 onChange: (newValue) => { 13543 onChangeView({ 13544 ...view, 13545 page: +newValue 13546 }); 13547 }, 13548 size: "small", 13549 variant: "minimal" 13550 } 13551 ) 13552 } 13553 ) 13554 } 13555 ), 13556 /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(Stack, { direction: "row", gap: "xs", align: "center", children: [ 13557 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)( 13558 import_components12.Button, 13559 { 13560 onClick: () => onChangeView({ 13561 ...view, 13562 page: currentPage - 1 13563 }), 13564 disabled: currentPage === 1, 13565 accessibleWhenDisabled: true, 13566 label: (0, import_i18n21.__)("Previous page"), 13567 icon: (0, import_i18n21.isRTL)() ? next_default : previous_default, 13568 showTooltip: true, 13569 size: "compact", 13570 tooltipPosition: "top" 13571 } 13572 ), 13573 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)( 13574 import_components12.Button, 13575 { 13576 onClick: () => onChangeView({ ...view, page: currentPage + 1 }), 13577 disabled: currentPage >= totalPages, 13578 accessibleWhenDisabled: true, 13579 label: (0, import_i18n21.__)("Next page"), 13580 icon: (0, import_i18n21.isRTL)() ? previous_default : next_default, 13581 showTooltip: true, 13582 size: "compact", 13583 tooltipPosition: "top" 13584 } 13585 ) 13586 ] }) 13587 ] 13588 } 13589 ); 13590 } 13591 var dataviews_pagination_default = (0, import_element34.memo)(DataViewsPagination); 13592 13593 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs 13594 var import_jsx_runtime64 = __toESM(require_jsx_runtime(), 1); 13595 var EMPTY_ARRAY2 = []; 13596 function useIsMultiselectPicker(actions) { 13597 return (0, import_element35.useMemo)(() => { 13598 return actions?.every((action) => action.supportsBulk); 13599 }, [actions]); 13600 } 13601 function BulkSelectionCheckbox2({ 13602 selection, 13603 selectedItems, 13604 onChangeSelection, 13605 data, 13606 getItemId, 13607 disableSelectAll = false 13608 }) { 13609 const hasSelection = selection.length > 0; 13610 const areAllSelected = selectedItems.length === data.length; 13611 if (disableSelectAll) { 13612 return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)( 13613 import_components13.CheckboxControl, 13614 { 13615 className: "dataviews-view-table-selection-checkbox", 13616 checked: hasSelection, 13617 disabled: !hasSelection, 13618 onChange: () => { 13619 onChangeSelection([]); 13620 }, 13621 "aria-label": (0, import_i18n22.__)("Deselect all") 13622 } 13623 ); 13624 } 13625 return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)( 13626 import_components13.CheckboxControl, 13627 { 13628 className: "dataviews-view-table-selection-checkbox", 13629 checked: areAllSelected, 13630 indeterminate: !areAllSelected && !!selectedItems.length, 13631 onChange: () => { 13632 if (areAllSelected) { 13633 onChangeSelection( 13634 selection.filter( 13635 (id) => !data.some( 13636 (item) => id === getItemId(item) 13637 ) 13638 ) 13639 ); 13640 } else { 13641 const selectionSet = /* @__PURE__ */ new Set([ 13642 ...selection, 13643 ...data.map((item) => getItemId(item)) 13644 ]); 13645 onChangeSelection(Array.from(selectionSet)); 13646 } 13647 }, 13648 "aria-label": areAllSelected ? (0, import_i18n22.__)("Deselect all") : (0, import_i18n22.__)("Select all") 13649 } 13650 ); 13651 } 13652 function ActionButtons({ 13653 actions, 13654 items, 13655 selection 13656 }) { 13657 const registry = (0, import_data5.useRegistry)(); 13658 const [actionInProgress, setActionInProgress] = (0, import_element35.useState)( 13659 null 13660 ); 13661 return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Stack, { direction: "row", gap: "xs", children: actions.map((action) => { 13662 if (!("callback" in action)) { 13663 return null; 13664 } 13665 const { id, label, icon, isPrimary, callback } = action; 13666 const _label = typeof label === "string" ? label : label(items); 13667 const variant = isPrimary ? "primary" : "tertiary"; 13668 const isInProgress = id === actionInProgress; 13669 return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)( 13670 import_components13.Button, 13671 { 13672 accessibleWhenDisabled: true, 13673 icon, 13674 disabled: isInProgress || !selection?.length, 13675 isBusy: isInProgress, 13676 onClick: async () => { 13677 setActionInProgress(id); 13678 await callback(items, { 13679 registry 13680 }); 13681 setActionInProgress(null); 13682 }, 13683 size: "compact", 13684 variant, 13685 children: _label 13686 }, 13687 id 13688 ); 13689 }) }); 13690 } 13691 function DataViewsPickerFooter() { 13692 const { 13693 data, 13694 selection, 13695 onChangeSelection, 13696 getItemId, 13697 actions = EMPTY_ARRAY2, 13698 paginationInfo, 13699 view 13700 } = (0, import_element35.useContext)(dataviews_context_default); 13701 const isMultiselect = useIsMultiselectPicker(actions); 13702 const message2 = getFooterMessage( 13703 selection.length, 13704 data.length, 13705 paginationInfo.totalItems, 13706 !!view.infiniteScrollEnabled 13707 ); 13708 const selectedItems = (0, import_element35.useMemo)( 13709 () => data.filter((item) => selection.includes(getItemId(item))), 13710 [selection, getItemId, data] 13711 ); 13712 return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)( 13713 Stack, 13714 { 13715 direction: "row", 13716 justify: "space-between", 13717 align: "center", 13718 className: "dataviews-footer", 13719 gap: "sm", 13720 children: [ 13721 /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)( 13722 Stack, 13723 { 13724 direction: "row", 13725 className: "dataviews-picker-footer__bulk-selection", 13726 gap: "md", 13727 align: "center", 13728 children: [ 13729 isMultiselect && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)( 13730 BulkSelectionCheckbox2, 13731 { 13732 selection, 13733 selectedItems, 13734 onChangeSelection, 13735 data, 13736 getItemId, 13737 disableSelectAll: !!view.infiniteScrollEnabled 13738 } 13739 ), 13740 /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("span", { className: "dataviews-bulk-actions-footer__item-count", children: message2 }) 13741 ] 13742 } 13743 ), 13744 /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(dataviews_pagination_default, {}), 13745 Boolean(actions?.length) && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { className: "dataviews-picker-footer__actions", children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)( 13746 ActionButtons, 13747 { 13748 actions, 13749 items: selectedItems, 13750 selection 13751 } 13752 ) }) 13753 ] 13754 } 13755 ); 13756 } 13757 13758 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs 13759 var import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1); 13760 var { Badge: WCBadge2 } = unlock2(import_components14.privateApis); 13761 function GridItem3({ 13762 view, 13763 multiselect, 13764 selection, 13765 onChangeSelection, 13766 getItemId, 13767 item, 13768 mediaField, 13769 titleField, 13770 descriptionField: descriptionField2, 13771 regularFields, 13772 badgeFields, 13773 config, 13774 posinset, 13775 setsize 13776 }) { 13777 const { showTitle = true, showMedia = true, showDescription = true } = view; 13778 const id = getItemId(item); 13779 const elementRef = (0, import_element36.useRef)(null); 13780 const isSelected2 = selection.includes(id); 13781 useIntersectionObserver(elementRef, posinset); 13782 const renderedMediaField = mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime65.jsx)( 13783 mediaField.render, 13784 { 13785 item, 13786 field: mediaField, 13787 config 13788 } 13789 ) : null; 13790 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(titleField.render, { item, field: titleField }) : null; 13791 return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)( 13792 import_components14.Composite.Item, 13793 { 13794 ref: elementRef, 13795 "aria-label": titleField ? titleField.getValue({ item }) || (0, import_i18n23.__)("(no title)") : void 0, 13796 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(Stack, { direction: "column", children, ...props }), 13797 role: "option", 13798 "aria-posinset": posinset, 13799 "aria-setsize": setsize, 13800 className: clsx_default("dataviews-view-picker-grid__card", { 13801 "is-selected": isSelected2 13802 }), 13803 "aria-selected": isSelected2, 13804 onClick: () => { 13805 if (isSelected2) { 13806 onChangeSelection( 13807 selection.filter((itemId) => id !== itemId) 13808 ); 13809 } else { 13810 const newSelection = multiselect ? [...selection, id] : [id]; 13811 onChangeSelection(newSelection); 13812 } 13813 }, 13814 children: [ 13815 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: "dataviews-view-picker-grid__media", children: renderedMediaField }), 13816 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)( 13817 DataViewsSelectionCheckbox, 13818 { 13819 item, 13820 selection, 13821 onChangeSelection, 13822 getItemId, 13823 titleField, 13824 disabled: false, 13825 "aria-hidden": true, 13826 tabIndex: -1 13827 } 13828 ), 13829 showTitle && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)( 13830 Stack, 13831 { 13832 direction: "row", 13833 justify: "space-between", 13834 className: "dataviews-view-picker-grid__title-actions", 13835 children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: "dataviews-view-picker-grid__title-field dataviews-title-field", children: renderedTitleField }) 13836 } 13837 ), 13838 /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(Stack, { direction: "column", gap: "xs", children: [ 13839 showDescription && descriptionField2?.render && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)( 13840 descriptionField2.render, 13841 { 13842 item, 13843 field: descriptionField2 13844 } 13845 ), 13846 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)( 13847 Stack, 13848 { 13849 direction: "row", 13850 className: "dataviews-view-picker-grid__badge-fields", 13851 gap: "sm", 13852 wrap: "wrap", 13853 align: "top", 13854 justify: "flex-start", 13855 children: badgeFields.map((field) => { 13856 return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)( 13857 WCBadge2, 13858 { 13859 className: "dataviews-view-picker-grid__field-value", 13860 children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)( 13861 field.render, 13862 { 13863 item, 13864 field 13865 } 13866 ) 13867 }, 13868 field.id 13869 ); 13870 }) 13871 } 13872 ), 13873 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)( 13874 Stack, 13875 { 13876 direction: "column", 13877 className: "dataviews-view-picker-grid__fields", 13878 gap: "xs", 13879 children: regularFields.map((field) => { 13880 return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)( 13881 import_components14.Flex, 13882 { 13883 className: "dataviews-view-picker-grid__field", 13884 gap: 1, 13885 justify: "flex-start", 13886 expanded: true, 13887 style: { height: "auto" }, 13888 direction: "row", 13889 children: /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(import_jsx_runtime65.Fragment, { children: [ 13890 /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_components14.FlexItem, { className: "dataviews-view-picker-grid__field-name", children: field.header }), 13891 /* @__PURE__ */ (0, import_jsx_runtime65.jsx)( 13892 import_components14.FlexItem, 13893 { 13894 className: "dataviews-view-picker-grid__field-value", 13895 style: { maxHeight: "none" }, 13896 children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)( 13897 field.render, 13898 { 13899 item, 13900 field 13901 } 13902 ) 13903 } 13904 ) 13905 ] }) 13906 }, 13907 field.id 13908 ); 13909 }) 13910 } 13911 ) 13912 ] }) 13913 ] 13914 }, 13915 id 13916 ); 13917 } 13918 function GridGroup({ 13919 groupName, 13920 groupField, 13921 showLabel = true, 13922 children 13923 }) { 13924 const headerId = (0, import_compose6.useInstanceId)( 13925 GridGroup, 13926 "dataviews-view-picker-grid-group__header" 13927 ); 13928 return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)( 13929 Stack, 13930 { 13931 direction: "column", 13932 gap: "sm", 13933 role: "group", 13934 "aria-labelledby": headerId, 13935 children: [ 13936 /* @__PURE__ */ (0, import_jsx_runtime65.jsx)( 13937 "h3", 13938 { 13939 className: "dataviews-view-picker-grid-group__header", 13940 id: headerId, 13941 children: showLabel ? (0, import_i18n23.sprintf)( 13942 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". 13943 (0, import_i18n23.__)("%1$s: %2$s"), 13944 groupField.label, 13945 groupName 13946 ) : groupName 13947 } 13948 ), 13949 children 13950 ] 13951 }, 13952 groupName 13953 ); 13954 } 13955 function ViewPickerGrid({ 13956 actions, 13957 data, 13958 fields, 13959 getItemId, 13960 isLoading, 13961 onChangeSelection, 13962 selection, 13963 view, 13964 className, 13965 empty 13966 }) { 13967 const { resizeObserverRef, paginationInfo, itemListLabel } = (0, import_element36.useContext)(dataviews_context_default); 13968 const titleField = fields.find( 13969 (field) => field.id === view?.titleField 13970 ); 13971 const mediaField = fields.find( 13972 (field) => field.id === view?.mediaField 13973 ); 13974 const descriptionField2 = fields.find( 13975 (field) => field.id === view?.descriptionField 13976 ); 13977 const otherFields = view.fields ?? []; 13978 const { regularFields, badgeFields } = otherFields.reduce( 13979 (accumulator, fieldId) => { 13980 const field = fields.find((f2) => f2.id === fieldId); 13981 if (!field) { 13982 return accumulator; 13983 } 13984 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields"; 13985 accumulator[key].push(field); 13986 return accumulator; 13987 }, 13988 { regularFields: [], badgeFields: [] } 13989 ); 13990 const hasData = !!data?.length; 13991 const usedPreviewSize = view.layout?.previewSize; 13992 const isMultiselect = useIsMultiselectPicker(actions); 13993 const size4 = "900px"; 13994 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null; 13995 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null; 13996 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false; 13997 const currentPage = view?.page ?? 1; 13998 const perPage = view?.perPage ?? 0; 13999 const setSize = isInfiniteScroll ? paginationInfo?.totalItems : void 0; 14000 const gridColumns = useGridColumns(); 14001 const placeholdersNeeded = usePlaceholdersNeeded( 14002 data, 14003 isInfiniteScroll, 14004 gridColumns 14005 ); 14006 return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(import_jsx_runtime65.Fragment, { 14007 // Render multiple groups. 14008 children: [ 14009 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)( 14010 import_components14.Composite, 14011 { 14012 virtualFocus: true, 14013 orientation: "horizontal", 14014 role: "listbox", 14015 "aria-multiselectable": isMultiselect, 14016 className: clsx_default( 14017 "dataviews-view-picker-grid", 14018 className, 14019 { 14020 [`has-$view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes( 14021 view.layout.density 14022 ) 14023 } 14024 ), 14025 "aria-label": itemListLabel, 14026 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime65.jsx)( 14027 Stack, 14028 { 14029 direction: "column", 14030 gap: "lg", 14031 children, 14032 ...props 14033 } 14034 ), 14035 children: Array.from(dataByGroup.entries()).map( 14036 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime65.jsx)( 14037 GridGroup, 14038 { 14039 groupName, 14040 groupField, 14041 showLabel: view.groupBy?.showLabel !== false, 14042 children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)( 14043 GridItems, 14044 { 14045 previewSize: usedPreviewSize, 14046 style: { 14047 gridTemplateColumns: usedPreviewSize && `repeat(auto-fill, minmax($usedPreviewSize}px, 1fr))` 14048 }, 14049 "aria-busy": isLoading, 14050 ref: resizeObserverRef, 14051 children: groupItems.map((item) => { 14052 const posInSet = item.position ?? (currentPage - 1) * perPage + data.indexOf(item) + 1; 14053 return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)( 14054 GridItem3, 14055 { 14056 view, 14057 multiselect: isMultiselect, 14058 selection, 14059 onChangeSelection, 14060 getItemId, 14061 item, 14062 mediaField, 14063 titleField, 14064 descriptionField: descriptionField2, 14065 regularFields, 14066 badgeFields, 14067 config: { 14068 sizes: size4 14069 }, 14070 posinset: posInSet, 14071 setsize: setSize 14072 }, 14073 getItemId(item) 14074 ); 14075 }) 14076 } 14077 ) 14078 }, 14079 groupName 14080 ) 14081 ) 14082 } 14083 ), 14084 // Render a single grid with all data. 14085 hasData && !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)( 14086 import_components14.Composite, 14087 { 14088 render: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)( 14089 GridItems, 14090 { 14091 className: clsx_default( 14092 "dataviews-view-picker-grid", 14093 className, 14094 { 14095 [`has-$view.layout?.density}-density`]: view.layout?.density && [ 14096 "compact", 14097 "comfortable" 14098 ].includes(view.layout.density) 14099 } 14100 ), 14101 previewSize: usedPreviewSize, 14102 "aria-busy": isLoading, 14103 ref: resizeObserverRef 14104 } 14105 ), 14106 virtualFocus: true, 14107 orientation: "horizontal", 14108 role: "listbox", 14109 "aria-multiselectable": isMultiselect, 14110 "aria-label": itemListLabel, 14111 children: [ 14112 Array.from({ length: placeholdersNeeded }).map( 14113 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime65.jsx)( 14114 import_components14.Composite.Item, 14115 { 14116 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime65.jsx)( 14117 Stack, 14118 { 14119 direction: "column", 14120 children, 14121 ...props 14122 } 14123 ), 14124 role: "option", 14125 "aria-hidden": true, 14126 tabIndex: -1, 14127 className: "dataviews-view-picker-grid__card dataviews-view-picker-grid__placeholder" 14128 }, 14129 `placeholder-$index2}` 14130 ) 14131 ), 14132 data.map((item) => { 14133 const posinset = item.position; 14134 return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)( 14135 GridItem3, 14136 { 14137 view, 14138 multiselect: isMultiselect, 14139 selection, 14140 onChangeSelection, 14141 getItemId, 14142 item, 14143 mediaField, 14144 titleField, 14145 descriptionField: descriptionField2, 14146 regularFields, 14147 badgeFields, 14148 config: { 14149 sizes: size4 14150 }, 14151 posinset, 14152 setsize: setSize 14153 }, 14154 getItemId(item) 14155 ); 14156 }) 14157 ] 14158 } 14159 ), 14160 // Render empty state. 14161 !hasData && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)( 14162 "div", 14163 { 14164 className: clsx_default({ 14165 "dataviews-loading": isLoading, 14166 "dataviews-no-results": !isLoading 14167 }), 14168 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_components14.Spinner, {}) }) : empty 14169 } 14170 ), 14171 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_components14.Spinner, {}) }) 14172 ] 14173 }); 14174 } 14175 var picker_grid_default = ViewPickerGrid; 14176 14177 // packages/dataviews/build-module/components/dataviews-layouts/picker-table/index.mjs 14178 var import_i18n24 = __toESM(require_i18n(), 1); 14179 var import_components15 = __toESM(require_components(), 1); 14180 var import_element37 = __toESM(require_element(), 1); 14181 var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1); 14182 function TableColumnField2({ 14183 item, 14184 fields, 14185 column, 14186 align 14187 }) { 14188 const field = fields.find((f2) => f2.id === column); 14189 if (!field) { 14190 return null; 14191 } 14192 const className = clsx_default("dataviews-view-table__cell-content-wrapper", { 14193 "dataviews-view-table__cell-align-end": align === "end", 14194 "dataviews-view-table__cell-align-center": align === "center" 14195 }); 14196 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(field.render, { item, field }) }); 14197 } 14198 function TableRow2({ 14199 item, 14200 fields, 14201 id, 14202 view, 14203 titleField, 14204 mediaField, 14205 descriptionField: descriptionField2, 14206 selection, 14207 getItemId, 14208 onChangeSelection, 14209 multiselect, 14210 posinset 14211 }) { 14212 const { paginationInfo } = (0, import_element37.useContext)(dataviews_context_default); 14213 const isSelected2 = selection.includes(id); 14214 const [isHovered, setIsHovered] = (0, import_element37.useState)(false); 14215 const elementRef = (0, import_element37.useRef)(null); 14216 useIntersectionObserver(elementRef, posinset); 14217 const { 14218 showTitle = true, 14219 showMedia = true, 14220 showDescription = true, 14221 infiniteScrollEnabled 14222 } = view; 14223 const handleMouseEnter = () => { 14224 setIsHovered(true); 14225 }; 14226 const handleMouseLeave = () => { 14227 setIsHovered(false); 14228 }; 14229 const columns = view.fields ?? []; 14230 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField2 && showDescription; 14231 return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)( 14232 import_components15.Composite.Item, 14233 { 14234 ref: elementRef, 14235 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)( 14236 "tr", 14237 { 14238 className: clsx_default("dataviews-view-table__row", { 14239 "is-selected": isSelected2, 14240 "is-hovered": isHovered 14241 }), 14242 onMouseEnter: handleMouseEnter, 14243 onMouseLeave: handleMouseLeave, 14244 children, 14245 ...props 14246 } 14247 ), 14248 "aria-selected": isSelected2, 14249 "aria-setsize": paginationInfo.totalItems || void 0, 14250 "aria-posinset": posinset, 14251 role: infiniteScrollEnabled ? "article" : "option", 14252 onMouseDown: (event) => { 14253 if (event.button !== 0) { 14254 return; 14255 } 14256 event.currentTarget.parentElement?.focus({ 14257 preventScroll: true 14258 }); 14259 }, 14260 onClick: () => { 14261 if (isSelected2) { 14262 onChangeSelection( 14263 selection.filter((itemId) => id !== itemId) 14264 ); 14265 } else { 14266 const newSelection = multiselect ? [...selection, id] : [id]; 14267 onChangeSelection(newSelection); 14268 } 14269 }, 14270 children: [ 14271 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)( 14272 "td", 14273 { 14274 className: "dataviews-view-table__checkbox-column", 14275 role: "presentation", 14276 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)( 14277 DataViewsSelectionCheckbox, 14278 { 14279 item, 14280 selection, 14281 onChangeSelection, 14282 getItemId, 14283 titleField, 14284 disabled: false, 14285 "aria-hidden": true, 14286 tabIndex: -1 14287 } 14288 ) }) 14289 } 14290 ), 14291 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)( 14292 "td", 14293 { 14294 role: "presentation", 14295 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)( 14296 column_primary_default, 14297 { 14298 item, 14299 titleField: showTitle ? titleField : void 0, 14300 mediaField: showMedia ? mediaField : void 0, 14301 descriptionField: showDescription ? descriptionField2 : void 0, 14302 isItemClickable: () => false 14303 } 14304 ) 14305 } 14306 ), 14307 columns.map((column) => { 14308 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {}; 14309 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)( 14310 "td", 14311 { 14312 style: { 14313 width, 14314 maxWidth, 14315 minWidth 14316 }, 14317 role: "presentation", 14318 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)( 14319 TableColumnField2, 14320 { 14321 fields, 14322 item, 14323 column, 14324 align 14325 } 14326 ) 14327 }, 14328 column 14329 ); 14330 }) 14331 ] 14332 }, 14333 id 14334 ); 14335 } 14336 function ViewPickerTable({ 14337 actions, 14338 data, 14339 fields, 14340 getItemId, 14341 isLoading = false, 14342 onChangeView, 14343 onChangeSelection, 14344 selection, 14345 setOpenedFilter, 14346 view, 14347 className, 14348 empty 14349 }) { 14350 const headerMenuRefs = (0, import_element37.useRef)(/* @__PURE__ */ new Map()); 14351 const headerMenuToFocusRef = (0, import_element37.useRef)(void 0); 14352 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element37.useState)(); 14353 const isMultiselect = useIsMultiselectPicker(actions) ?? false; 14354 (0, import_element37.useEffect)(() => { 14355 if (headerMenuToFocusRef.current) { 14356 headerMenuToFocusRef.current.focus(); 14357 headerMenuToFocusRef.current = void 0; 14358 } 14359 }); 14360 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null; 14361 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null; 14362 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup; 14363 const tableNoticeId = (0, import_element37.useId)(); 14364 if (nextHeaderMenuToFocus) { 14365 headerMenuToFocusRef.current = nextHeaderMenuToFocus; 14366 setNextHeaderMenuToFocus(void 0); 14367 return; 14368 } 14369 const onHide = (field) => { 14370 const hidden = headerMenuRefs.current.get(field.id); 14371 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0; 14372 setNextHeaderMenuToFocus(fallback?.node); 14373 }; 14374 const hasData = !!data?.length; 14375 const titleField = fields.find((field) => field.id === view.titleField); 14376 const mediaField = fields.find((field) => field.id === view.mediaField); 14377 const descriptionField2 = fields.find( 14378 (field) => field.id === view.descriptionField 14379 ); 14380 const { showTitle = true, showMedia = true, showDescription = true } = view; 14381 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField2 && showDescription; 14382 const columns = view.fields ?? []; 14383 const headerMenuRef = (column, index2) => (node) => { 14384 if (node) { 14385 headerMenuRefs.current.set(column, { 14386 node, 14387 fallback: columns[index2 > 0 ? index2 - 1 : 1] 14388 }); 14389 } else { 14390 headerMenuRefs.current.delete(column); 14391 } 14392 }; 14393 return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(import_jsx_runtime66.Fragment, { children: [ 14394 /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)( 14395 "table", 14396 { 14397 className: clsx_default( 14398 "dataviews-view-table", 14399 "dataviews-view-picker-table", 14400 className, 14401 { 14402 [`has-$view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes( 14403 view.layout.density 14404 ) 14405 } 14406 ), 14407 "aria-busy": isLoading, 14408 "aria-describedby": tableNoticeId, 14409 role: isInfiniteScroll ? "feed" : "listbox", 14410 children: [ 14411 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("thead", { role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)( 14412 "tr", 14413 { 14414 className: "dataviews-view-table__row", 14415 role: "presentation", 14416 children: [ 14417 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("th", { className: "dataviews-view-table__checkbox-column", children: isMultiselect && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)( 14418 BulkSelectionCheckbox, 14419 { 14420 selection, 14421 onChangeSelection, 14422 data, 14423 actions, 14424 getItemId, 14425 disableSelectAll: isInfiniteScroll 14426 } 14427 ) }), 14428 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("th", { children: titleField && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)( 14429 column_header_menu_default, 14430 { 14431 ref: headerMenuRef( 14432 titleField.id, 14433 0 14434 ), 14435 fieldId: titleField.id, 14436 view, 14437 fields, 14438 onChangeView, 14439 onHide, 14440 setOpenedFilter, 14441 canMove: false 14442 } 14443 ) }), 14444 columns.map((column, index2) => { 14445 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {}; 14446 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)( 14447 "th", 14448 { 14449 style: { 14450 width, 14451 maxWidth, 14452 minWidth, 14453 textAlign: align 14454 }, 14455 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0, 14456 scope: "col", 14457 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)( 14458 column_header_menu_default, 14459 { 14460 ref: headerMenuRef(column, index2), 14461 fieldId: column, 14462 view, 14463 fields, 14464 onChangeView, 14465 onHide, 14466 setOpenedFilter, 14467 canMove: view.layout?.enableMoving ?? true 14468 } 14469 ) 14470 }, 14471 column 14472 ); 14473 }) 14474 ] 14475 } 14476 ) }), 14477 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map( 14478 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)( 14479 import_components15.Composite, 14480 { 14481 virtualFocus: true, 14482 orientation: "vertical", 14483 render: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("tbody", { role: "group" }), 14484 children: [ 14485 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)( 14486 "tr", 14487 { 14488 className: "dataviews-view-table__group-header-row", 14489 role: "presentation", 14490 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)( 14491 "td", 14492 { 14493 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + 1, 14494 className: "dataviews-view-table__group-header-cell", 14495 role: "presentation", 14496 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n24.sprintf)( 14497 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". 14498 (0, import_i18n24.__)("%1$s: %2$s"), 14499 groupField.label, 14500 groupName 14501 ) 14502 } 14503 ) 14504 } 14505 ), 14506 groupItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)( 14507 TableRow2, 14508 { 14509 item, 14510 fields, 14511 id: getItemId(item) || index2.toString(), 14512 view, 14513 titleField, 14514 mediaField, 14515 descriptionField: descriptionField2, 14516 selection, 14517 getItemId, 14518 onChangeSelection, 14519 multiselect: isMultiselect 14520 }, 14521 getItemId(item) 14522 )) 14523 ] 14524 }, 14525 `group-$groupName}` 14526 ) 14527 ) : /* @__PURE__ */ (0, import_jsx_runtime66.jsx)( 14528 import_components15.Composite, 14529 { 14530 render: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("tbody", { role: "presentation" }), 14531 virtualFocus: true, 14532 orientation: "vertical", 14533 children: hasData && data.map((item, index2) => { 14534 const itemId = getItemId(item); 14535 const posinset = item.position; 14536 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)( 14537 TableRow2, 14538 { 14539 item, 14540 fields, 14541 id: itemId || index2.toString(), 14542 view, 14543 titleField, 14544 mediaField, 14545 descriptionField: descriptionField2, 14546 selection, 14547 getItemId, 14548 onChangeSelection, 14549 multiselect: isMultiselect, 14550 posinset 14551 }, 14552 itemId 14553 ); 14554 }) 14555 } 14556 ) 14557 ] 14558 } 14559 ), 14560 /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)( 14561 "div", 14562 { 14563 className: clsx_default({ 14564 "dataviews-loading": isLoading, 14565 "dataviews-no-results": !hasData && !isLoading 14566 }), 14567 id: tableNoticeId, 14568 children: [ 14569 !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_components15.Spinner, {}) }) : empty), 14570 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_components15.Spinner, {}) }) 14571 ] 14572 } 14573 ) 14574 ] }); 14575 } 14576 var picker_table_default = ViewPickerTable; 14577 14578 // packages/dataviews/build-module/components/dataviews-layouts/picker-activity/index.mjs 14579 var import_components16 = __toESM(require_components(), 1); 14580 var import_element38 = __toESM(require_element(), 1); 14581 var import_compose7 = __toESM(require_compose(), 1); 14582 var import_i18n25 = __toESM(require_i18n(), 1); 14583 var import_jsx_runtime67 = __toESM(require_jsx_runtime(), 1); 14584 function isDefined4(item) { 14585 return !!item; 14586 } 14587 function PickerActivityItem({ 14588 view, 14589 multiselect, 14590 selection, 14591 onChangeSelection, 14592 getItemId, 14593 item, 14594 titleField, 14595 mediaField, 14596 descriptionField: descriptionField2, 14597 otherFields, 14598 posinset, 14599 setsize 14600 }) { 14601 const elementRef = (0, import_element38.useRef)(null); 14602 useIntersectionObserver(elementRef, posinset); 14603 const { showTitle = true, showMedia = true, showDescription = true } = view; 14604 const id = getItemId(item); 14605 const isSelected2 = selection.includes(id); 14606 const density = view.layout?.density ?? "balanced"; 14607 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime67.jsx)( 14608 mediaField.render, 14609 { 14610 item, 14611 field: mediaField, 14612 config: { 14613 sizes: density === "comfortable" ? "32px" : "24px" 14614 } 14615 } 14616 ) : null; 14617 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "dataviews-view-picker-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime67.jsx)( 14618 "span", 14619 { 14620 className: "dataviews-view-picker-activity__item-bullet", 14621 "aria-hidden": "true" 14622 } 14623 ) }); 14624 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(titleField.render, { item, field: titleField }) : null; 14625 const renderedDescriptionField = showDescription && descriptionField2?.render ? /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(descriptionField2.render, { item, field: descriptionField2 }) : null; 14626 const verticalGap = (0, import_element38.useMemo)(() => { 14627 switch (density) { 14628 case "comfortable": 14629 return "md"; 14630 default: 14631 return "sm"; 14632 } 14633 }, [density]); 14634 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)( 14635 import_components16.Composite.Item, 14636 { 14637 ref: elementRef, 14638 role: "option", 14639 "aria-label": titleField ? titleField.getValue({ item }) || void 0 : void 0, 14640 "aria-posinset": posinset, 14641 "aria-setsize": setsize, 14642 "aria-selected": isSelected2, 14643 className: clsx_default( 14644 "dataviews-view-picker-activity__item", 14645 density === "compact" && "is-compact", 14646 density === "balanced" && "is-balanced", 14647 density === "comfortable" && "is-comfortable", 14648 isSelected2 && "is-selected" 14649 ), 14650 onClick: () => { 14651 if (isSelected2) { 14652 onChangeSelection( 14653 selection.filter((itemId) => id !== itemId) 14654 ); 14655 } else { 14656 const newSelection = multiselect ? [...selection, id] : [id]; 14657 onChangeSelection(newSelection); 14658 } 14659 }, 14660 render: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", {}), 14661 children: /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [ 14662 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)( 14663 Stack, 14664 { 14665 direction: "column", 14666 gap: "xs", 14667 align: "center", 14668 className: "dataviews-view-picker-activity__item-type", 14669 children: renderedMediaField 14670 } 14671 ), 14672 /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)( 14673 Stack, 14674 { 14675 direction: "column", 14676 gap: verticalGap, 14677 align: "flex-start", 14678 className: "dataviews-view-picker-activity__item-content", 14679 children: [ 14680 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "dataviews-view-picker-activity__item-title", children: renderedTitleField }), 14681 renderedDescriptionField && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "dataviews-view-picker-activity__item-description", children: renderedDescriptionField }), 14682 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "dataviews-view-picker-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)( 14683 "div", 14684 { 14685 className: "dataviews-view-picker-activity__item-field", 14686 children: [ 14687 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)( 14688 VisuallyHidden, 14689 { 14690 render: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("span", {}), 14691 className: "dataviews-view-picker-activity__item-field-label", 14692 children: field.label 14693 } 14694 ), 14695 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("span", { className: "dataviews-view-picker-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)( 14696 field.render, 14697 { 14698 item, 14699 field 14700 } 14701 ) }) 14702 ] 14703 }, 14704 field.id 14705 )) }) 14706 ] 14707 } 14708 ) 14709 ] }) 14710 } 14711 ); 14712 } 14713 function PickerActivityGroup({ 14714 groupName, 14715 groupField, 14716 showLabel = true, 14717 children 14718 }) { 14719 const headerId = (0, import_compose7.useInstanceId)( 14720 PickerActivityGroup, 14721 "dataviews-view-picker-activity-group__header" 14722 ); 14723 return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)( 14724 Stack, 14725 { 14726 direction: "column", 14727 role: "group", 14728 "aria-labelledby": headerId, 14729 className: "dataviews-view-picker-activity-group", 14730 children: [ 14731 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)( 14732 "h3", 14733 { 14734 className: "dataviews-view-picker-activity-group__header", 14735 id: headerId, 14736 children: showLabel ? (0, import_i18n25.sprintf)( 14737 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". 14738 (0, import_i18n25.__)("%1$s: %2$s"), 14739 groupField.label, 14740 groupName 14741 ) : groupName 14742 } 14743 ), 14744 children 14745 ] 14746 } 14747 ); 14748 } 14749 function ViewPickerActivity({ 14750 data, 14751 fields, 14752 getItemId, 14753 isLoading, 14754 onChangeSelection, 14755 selection, 14756 view, 14757 actions, 14758 className, 14759 empty 14760 }) { 14761 const { itemListLabel, paginationInfo } = (0, import_element38.useContext)(dataviews_context_default); 14762 const isMultiselect = useIsMultiselectPicker(actions); 14763 const titleField = fields.find( 14764 (field) => field.id === view?.titleField 14765 ); 14766 const mediaField = fields.find( 14767 (field) => field.id === view?.mediaField 14768 ); 14769 const descriptionField2 = fields.find( 14770 (field) => field.id === view?.descriptionField 14771 ); 14772 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined4); 14773 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null; 14774 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null; 14775 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false; 14776 const setsize = isInfiniteScroll ? paginationInfo?.totalItems : void 0; 14777 const hasData = !!data?.length; 14778 const isGrouped = !!(groupField && dataByGroup); 14779 const renderItem = (item) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)( 14780 PickerActivityItem, 14781 { 14782 view, 14783 multiselect: isMultiselect, 14784 selection, 14785 onChangeSelection, 14786 getItemId, 14787 item, 14788 titleField, 14789 mediaField, 14790 descriptionField: descriptionField2, 14791 otherFields, 14792 posinset: item.position, 14793 setsize 14794 }, 14795 getItemId(item) 14796 ); 14797 if (!hasData) { 14798 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)( 14799 "div", 14800 { 14801 className: clsx_default({ 14802 "dataviews-loading": isLoading, 14803 "dataviews-no-results": !isLoading 14804 }), 14805 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_components16.Spinner, {}) }) : empty 14806 } 14807 ); 14808 } 14809 return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(import_jsx_runtime67.Fragment, { children: [ 14810 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)( 14811 import_components16.Composite, 14812 { 14813 virtualFocus: true, 14814 orientation: "vertical", 14815 role: "listbox", 14816 "aria-multiselectable": isMultiselect, 14817 "aria-label": itemListLabel, 14818 "aria-busy": isLoading, 14819 render: isGrouped ? /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Stack, { direction: "column", gap: "sm" }) : void 0, 14820 className: clsx_default( 14821 "dataviews-view-picker-activity", 14822 className 14823 ), 14824 children: isGrouped && dataByGroup ? Array.from(dataByGroup.entries()).map( 14825 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)( 14826 PickerActivityGroup, 14827 { 14828 groupName, 14829 groupField, 14830 showLabel: view.groupBy?.showLabel !== false, 14831 children: groupItems.map(renderItem) 14832 }, 14833 groupName 14834 ) 14835 ) : data.map(renderItem) 14836 } 14837 ), 14838 isLoading && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_components16.Spinner, {}) }) 14839 ] }); 14840 } 14841 14842 // packages/dataviews/build-module/components/dataviews-layouts/utils/density-picker.mjs 14843 var import_components17 = __toESM(require_components(), 1); 14844 var import_i18n26 = __toESM(require_i18n(), 1); 14845 var import_element39 = __toESM(require_element(), 1); 14846 var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1); 14847 function DensityPicker() { 14848 const context = (0, import_element39.useContext)(dataviews_context_default); 14849 const view = context.view; 14850 return /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)( 14851 import_components17.__experimentalToggleGroupControl, 14852 { 14853 size: "__unstable-large", 14854 label: (0, import_i18n26.__)("Density"), 14855 value: view.layout?.density || "balanced", 14856 onChange: (value) => { 14857 context.onChangeView({ 14858 ...view, 14859 layout: { 14860 ...view.layout, 14861 density: value 14862 } 14863 }); 14864 }, 14865 isBlock: true, 14866 children: [ 14867 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)( 14868 import_components17.__experimentalToggleGroupControlOption, 14869 { 14870 value: "comfortable", 14871 label: (0, import_i18n26._x)( 14872 "Comfortable", 14873 "Density option for DataView layout" 14874 ) 14875 }, 14876 "comfortable" 14877 ), 14878 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)( 14879 import_components17.__experimentalToggleGroupControlOption, 14880 { 14881 value: "balanced", 14882 label: (0, import_i18n26._x)("Balanced", "Density option for DataView layout") 14883 }, 14884 "balanced" 14885 ), 14886 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)( 14887 import_components17.__experimentalToggleGroupControlOption, 14888 { 14889 value: "compact", 14890 label: (0, import_i18n26._x)("Compact", "Density option for DataView layout") 14891 }, 14892 "compact" 14893 ) 14894 ] 14895 } 14896 ); 14897 } 14898 14899 // packages/dataviews/build-module/components/dataviews-layouts/utils/preview-size-picker.mjs 14900 var import_components18 = __toESM(require_components(), 1); 14901 var import_i18n27 = __toESM(require_i18n(), 1); 14902 var import_element40 = __toESM(require_element(), 1); 14903 var import_jsx_runtime69 = __toESM(require_jsx_runtime(), 1); 14904 var imageSizes2 = [ 14905 { 14906 value: 120, 14907 breakpoint: 1 14908 }, 14909 { 14910 value: 170, 14911 breakpoint: 1 14912 }, 14913 { 14914 value: 230, 14915 breakpoint: 1 14916 }, 14917 { 14918 value: 290, 14919 breakpoint: 1112 14920 // at minimum image width, 4 images display at this container size 14921 }, 14922 { 14923 value: 350, 14924 breakpoint: 1636 14925 // at minimum image width, 6 images display at this container size 14926 }, 14927 { 14928 value: 430, 14929 breakpoint: 588 14930 // at minimum image width, 2 images display at this container size 14931 } 14932 ]; 14933 function PreviewSizePicker() { 14934 const context = (0, import_element40.useContext)(dataviews_context_default); 14935 const view = context.view; 14936 const breakValues = imageSizes2.filter((size4) => { 14937 return context.containerWidth >= size4.breakpoint; 14938 }); 14939 const layoutPreviewSize = view.layout?.previewSize ?? 230; 14940 const previewSizeToUse = breakValues.map((size4, index2) => ({ ...size4, index: index2 })).filter((size4) => size4.value <= layoutPreviewSize).sort((a2, b2) => b2.value - a2.value)[0]?.index ?? 0; 14941 const marks = breakValues.map((size4, index2) => { 14942 return { 14943 value: index2 14944 }; 14945 }); 14946 return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)( 14947 import_components18.RangeControl, 14948 { 14949 __next40pxDefaultSize: true, 14950 showTooltip: false, 14951 label: (0, import_i18n27.__)("Preview size"), 14952 value: previewSizeToUse, 14953 min: 0, 14954 max: breakValues.length - 1, 14955 withInputField: false, 14956 onChange: (value = 0) => { 14957 context.onChangeView({ 14958 ...view, 14959 layout: { 14960 ...view.layout, 14961 previewSize: breakValues[value].value 14962 } 14963 }); 14964 }, 14965 step: 1, 14966 marks 14967 } 14968 ); 14969 } 14970 14971 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-config-options.mjs 14972 var import_jsx_runtime70 = __toESM(require_jsx_runtime(), 1); 14973 function GridConfigOptions() { 14974 return /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(import_jsx_runtime70.Fragment, { children: [ 14975 /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(DensityPicker, {}), 14976 /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(PreviewSizePicker, {}) 14977 ] }); 14978 } 14979 14980 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs 14981 var VIEW_LAYOUTS = [ 14982 { 14983 type: LAYOUT_TABLE, 14984 label: (0, import_i18n28.__)("Table"), 14985 component: table_default, 14986 icon: block_table_default, 14987 viewConfigOptions: DensityPicker 14988 }, 14989 { 14990 type: LAYOUT_GRID, 14991 label: (0, import_i18n28.__)("Grid"), 14992 component: grid_default, 14993 icon: category_default, 14994 viewConfigOptions: GridConfigOptions 14995 }, 14996 { 14997 type: LAYOUT_LIST, 14998 label: (0, import_i18n28.__)("List"), 14999 component: ViewList, 15000 icon: (0, import_i18n28.isRTL)() ? format_list_bullets_rtl_default : format_list_bullets_default, 15001 viewConfigOptions: DensityPicker 15002 }, 15003 { 15004 type: LAYOUT_ACTIVITY, 15005 label: (0, import_i18n28.__)("Activity"), 15006 component: ViewActivity, 15007 icon: scheduled_default, 15008 viewConfigOptions: DensityPicker 15009 }, 15010 { 15011 type: LAYOUT_PICKER_GRID, 15012 label: (0, import_i18n28.__)("Grid"), 15013 component: picker_grid_default, 15014 icon: category_default, 15015 viewConfigOptions: GridConfigOptions, 15016 isPicker: true 15017 }, 15018 { 15019 type: LAYOUT_PICKER_TABLE, 15020 label: (0, import_i18n28.__)("Table"), 15021 component: picker_table_default, 15022 icon: block_table_default, 15023 viewConfigOptions: DensityPicker, 15024 isPicker: true 15025 }, 15026 { 15027 type: LAYOUT_PICKER_ACTIVITY, 15028 label: (0, import_i18n28.__)("Activity"), 15029 component: ViewPickerActivity, 15030 icon: scheduled_default, 15031 viewConfigOptions: DensityPicker, 15032 isPicker: true 15033 } 15034 ]; 15035 15036 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs 15037 var import_element48 = __toESM(require_element(), 1); 15038 15039 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs 15040 var import_components21 = __toESM(require_components(), 1); 15041 var import_i18n31 = __toESM(require_i18n(), 1); 15042 var import_element45 = __toESM(require_element(), 1); 15043 15044 // node_modules/@ariakit/core/esm/__chunks/XMCVU3LR.js 15045 function noop5(..._) { 15046 } 15047 function applyState(argument, currentValue) { 15048 if (isUpdater(argument)) { 15049 const value = isLazyValue(currentValue) ? currentValue() : currentValue; 15050 return argument(value); 15051 } 15052 return argument; 15053 } 15054 function isUpdater(argument) { 15055 return typeof argument === "function"; 15056 } 15057 function isLazyValue(value) { 15058 return typeof value === "function"; 15059 } 15060 function hasOwnProperty(object, prop) { 15061 if (typeof Object.hasOwn === "function") { 15062 return Object.hasOwn(object, prop); 15063 } 15064 return Object.prototype.hasOwnProperty.call(object, prop); 15065 } 15066 function chain(...fns) { 15067 return (...args) => { 15068 for (const fn of fns) { 15069 if (typeof fn === "function") { 15070 fn(...args); 15071 } 15072 } 15073 }; 15074 } 15075 function normalizeString(str) { 15076 return str.normalize("NFD").replace(/[\u0300-\u036f]/g, ""); 15077 } 15078 function omit(object, keys) { 15079 const result = { ...object }; 15080 for (const key of keys) { 15081 if (hasOwnProperty(result, key)) { 15082 delete result[key]; 15083 } 15084 } 15085 return result; 15086 } 15087 function pick(object, paths) { 15088 const result = {}; 15089 for (const key of paths) { 15090 if (hasOwnProperty(object, key)) { 15091 result[key] = object[key]; 15092 } 15093 } 15094 return result; 15095 } 15096 function identity(value) { 15097 return value; 15098 } 15099 function invariant(condition, message2) { 15100 if (condition) return; 15101 if (typeof message2 !== "string") throw new Error("Invariant failed"); 15102 throw new Error(message2); 15103 } 15104 function getKeys(obj) { 15105 return Object.keys(obj); 15106 } 15107 function isFalsyBooleanCallback(booleanOrCallback, ...args) { 15108 const result = typeof booleanOrCallback === "function" ? booleanOrCallback(...args) : booleanOrCallback; 15109 if (result == null) return false; 15110 return !result; 15111 } 15112 function disabledFromProps(props) { 15113 return props.disabled || props["aria-disabled"] === true || props["aria-disabled"] === "true"; 15114 } 15115 function removeUndefinedValues(obj) { 15116 const result = {}; 15117 for (const key in obj) { 15118 if (obj[key] !== void 0) { 15119 result[key] = obj[key]; 15120 } 15121 } 15122 return result; 15123 } 15124 function defaultValue(...values) { 15125 for (const value of values) { 15126 if (value !== void 0) return value; 15127 } 15128 return void 0; 15129 } 15130 15131 // node_modules/@ariakit/react-core/esm/__chunks/YXGXYGQX.js 15132 var import_react6 = __toESM(require_react(), 1); 15133 function setRef(ref, value) { 15134 if (typeof ref === "function") { 15135 ref(value); 15136 } else if (ref) { 15137 ref.current = value; 15138 } 15139 } 15140 function isValidElementWithRef(element) { 15141 if (!element) return false; 15142 if (!(0, import_react6.isValidElement)(element)) return false; 15143 if ("ref" in element.props) return true; 15144 if ("ref" in element) return true; 15145 return false; 15146 } 15147 function getRefProperty(element) { 15148 if (!isValidElementWithRef(element)) return null; 15149 const props = { ...element.props }; 15150 return props.ref || element.ref; 15151 } 15152 function mergeProps2(base, overrides) { 15153 const props = { ...base }; 15154 for (const key in overrides) { 15155 if (!hasOwnProperty(overrides, key)) continue; 15156 if (key === "className") { 15157 const prop = "className"; 15158 props[prop] = base[prop] ? `$base[prop]} $overrides[prop]}` : overrides[prop]; 15159 continue; 15160 } 15161 if (key === "style") { 15162 const prop = "style"; 15163 props[prop] = base[prop] ? { ...base[prop], ...overrides[prop] } : overrides[prop]; 15164 continue; 15165 } 15166 const overrideValue = overrides[key]; 15167 if (typeof overrideValue === "function" && key.startsWith("on")) { 15168 const baseValue = base[key]; 15169 if (typeof baseValue === "function") { 15170 props[key] = (...args) => { 15171 overrideValue(...args); 15172 baseValue(...args); 15173 }; 15174 continue; 15175 } 15176 } 15177 props[key] = overrideValue; 15178 } 15179 return props; 15180 } 15181 15182 // node_modules/@ariakit/core/esm/__chunks/3DNM6L6E.js 15183 var canUseDOM = checkIsBrowser(); 15184 function checkIsBrowser() { 15185 var _a; 15186 return typeof window !== "undefined" && !!((_a = window.document) == null ? void 0 : _a.createElement); 15187 } 15188 function getDocument(node) { 15189 if (!node) return document; 15190 if ("self" in node) return node.document; 15191 return node.ownerDocument || document; 15192 } 15193 function getActiveElement(node, activeDescendant = false) { 15194 var _a; 15195 const { activeElement: activeElement2 } = getDocument(node); 15196 if (!(activeElement2 == null ? void 0 : activeElement2.nodeName)) { 15197 return null; 15198 } 15199 if (isFrame(activeElement2) && ((_a = activeElement2.contentDocument) == null ? void 0 : _a.body)) { 15200 return getActiveElement( 15201 activeElement2.contentDocument.body, 15202 activeDescendant 15203 ); 15204 } 15205 if (activeDescendant) { 15206 const id = activeElement2.getAttribute("aria-activedescendant"); 15207 if (id) { 15208 const element = getDocument(activeElement2).getElementById(id); 15209 if (element) { 15210 return element; 15211 } 15212 } 15213 } 15214 return activeElement2; 15215 } 15216 function contains2(parent, child) { 15217 return parent === child || parent.contains(child); 15218 } 15219 function isFrame(element) { 15220 return element.tagName === "IFRAME"; 15221 } 15222 function isButton(element) { 15223 const tagName = element.tagName.toLowerCase(); 15224 if (tagName === "button") return true; 15225 if (tagName === "input" && element.type) { 15226 return buttonInputTypes.indexOf(element.type) !== -1; 15227 } 15228 return false; 15229 } 15230 var buttonInputTypes = [ 15231 "button", 15232 "color", 15233 "file", 15234 "image", 15235 "reset", 15236 "submit" 15237 ]; 15238 function isVisible(element) { 15239 if (typeof element.checkVisibility === "function") { 15240 return element.checkVisibility(); 15241 } 15242 const htmlElement = element; 15243 return htmlElement.offsetWidth > 0 || htmlElement.offsetHeight > 0 || element.getClientRects().length > 0; 15244 } 15245 function isTextField(element) { 15246 try { 15247 const isTextInput = element instanceof HTMLInputElement && element.selectionStart !== null; 15248 const isTextArea = element.tagName === "TEXTAREA"; 15249 return isTextInput || isTextArea || false; 15250 } catch (_error) { 15251 return false; 15252 } 15253 } 15254 function isTextbox(element) { 15255 return element.isContentEditable || isTextField(element); 15256 } 15257 function getTextboxValue(element) { 15258 if (isTextField(element)) { 15259 return element.value; 15260 } 15261 if (element.isContentEditable) { 15262 const range = getDocument(element).createRange(); 15263 range.selectNodeContents(element); 15264 return range.toString(); 15265 } 15266 return ""; 15267 } 15268 function getTextboxSelection(element) { 15269 let start = 0; 15270 let end = 0; 15271 if (isTextField(element)) { 15272 start = element.selectionStart || 0; 15273 end = element.selectionEnd || 0; 15274 } else if (element.isContentEditable) { 15275 const selection = getDocument(element).getSelection(); 15276 if ((selection == null ? void 0 : selection.rangeCount) && selection.anchorNode && contains2(element, selection.anchorNode) && selection.focusNode && contains2(element, selection.focusNode)) { 15277 const range = selection.getRangeAt(0); 15278 const nextRange = range.cloneRange(); 15279 nextRange.selectNodeContents(element); 15280 nextRange.setEnd(range.startContainer, range.startOffset); 15281 start = nextRange.toString().length; 15282 nextRange.setEnd(range.endContainer, range.endOffset); 15283 end = nextRange.toString().length; 15284 } 15285 } 15286 return { start, end }; 15287 } 15288 function getPopupRole(element, fallback) { 15289 const allowedPopupRoles = ["dialog", "menu", "listbox", "tree", "grid"]; 15290 const role = element == null ? void 0 : element.getAttribute("role"); 15291 if (role && allowedPopupRoles.indexOf(role) !== -1) { 15292 return role; 15293 } 15294 return fallback; 15295 } 15296 function getScrollingElement(element) { 15297 if (!element) return null; 15298 const isScrollableOverflow = (overflow) => { 15299 if (overflow === "auto") return true; 15300 if (overflow === "scroll") return true; 15301 return false; 15302 }; 15303 if (element.clientHeight && element.scrollHeight > element.clientHeight) { 15304 const { overflowY } = getComputedStyle(element); 15305 if (isScrollableOverflow(overflowY)) return element; 15306 } else if (element.clientWidth && element.scrollWidth > element.clientWidth) { 15307 const { overflowX } = getComputedStyle(element); 15308 if (isScrollableOverflow(overflowX)) return element; 15309 } 15310 return getScrollingElement(element.parentElement) || document.scrollingElement || document.body; 15311 } 15312 function setSelectionRange(element, ...args) { 15313 if (/text|search|password|tel|url/i.test(element.type)) { 15314 element.setSelectionRange(...args); 15315 } 15316 } 15317 function sortBasedOnDOMPosition(items, getElement) { 15318 const pairs = items.map((item, index2) => [index2, item]); 15319 let isOrderDifferent = false; 15320 pairs.sort(([indexA, a2], [indexB, b2]) => { 15321 const elementA = getElement(a2); 15322 const elementB = getElement(b2); 15323 if (elementA === elementB) return 0; 15324 if (!elementA || !elementB) return 0; 15325 if (isElementPreceding(elementA, elementB)) { 15326 if (indexA > indexB) { 15327 isOrderDifferent = true; 15328 } 15329 return -1; 15330 } 15331 if (indexA < indexB) { 15332 isOrderDifferent = true; 15333 } 15334 return 1; 15335 }); 15336 if (isOrderDifferent) { 15337 return pairs.map(([_, item]) => item); 15338 } 15339 return items; 15340 } 15341 function isElementPreceding(a2, b2) { 15342 return Boolean( 15343 b2.compareDocumentPosition(a2) & Node.DOCUMENT_POSITION_PRECEDING 15344 ); 15345 } 15346 15347 // node_modules/@ariakit/core/esm/__chunks/SNHYQNEZ.js 15348 function isTouchDevice() { 15349 return canUseDOM && !!navigator.maxTouchPoints; 15350 } 15351 function isApple() { 15352 if (!canUseDOM) return false; 15353 return /mac|iphone|ipad|ipod/i.test(navigator.platform); 15354 } 15355 function isSafari2() { 15356 return canUseDOM && isApple() && /apple/i.test(navigator.vendor); 15357 } 15358 function isFirefox2() { 15359 return canUseDOM && /firefox\//i.test(navigator.userAgent); 15360 } 15361 15362 // node_modules/@ariakit/core/esm/utils/events.js 15363 function isPortalEvent(event) { 15364 return Boolean( 15365 event.currentTarget && !contains2(event.currentTarget, event.target) 15366 ); 15367 } 15368 function isSelfTarget(event) { 15369 return event.target === event.currentTarget; 15370 } 15371 function isOpeningInNewTab(event) { 15372 const element = event.currentTarget; 15373 if (!element) return false; 15374 const isAppleDevice = isApple(); 15375 if (isAppleDevice && !event.metaKey) return false; 15376 if (!isAppleDevice && !event.ctrlKey) return false; 15377 const tagName = element.tagName.toLowerCase(); 15378 if (tagName === "a") return true; 15379 if (tagName === "button" && element.type === "submit") return true; 15380 if (tagName === "input" && element.type === "submit") return true; 15381 return false; 15382 } 15383 function isDownloading(event) { 15384 const element = event.currentTarget; 15385 if (!element) return false; 15386 const tagName = element.tagName.toLowerCase(); 15387 if (!event.altKey) return false; 15388 if (tagName === "a") return true; 15389 if (tagName === "button" && element.type === "submit") return true; 15390 if (tagName === "input" && element.type === "submit") return true; 15391 return false; 15392 } 15393 function fireBlurEvent(element, eventInit) { 15394 const event = new FocusEvent("blur", eventInit); 15395 const defaultAllowed = element.dispatchEvent(event); 15396 const bubbleInit = { ...eventInit, bubbles: true }; 15397 element.dispatchEvent(new FocusEvent("focusout", bubbleInit)); 15398 return defaultAllowed; 15399 } 15400 function fireKeyboardEvent(element, type, eventInit) { 15401 const event = new KeyboardEvent(type, eventInit); 15402 return element.dispatchEvent(event); 15403 } 15404 function fireClickEvent(element, eventInit) { 15405 const event = new MouseEvent("click", eventInit); 15406 return element.dispatchEvent(event); 15407 } 15408 function isFocusEventOutside(event, container) { 15409 const containerElement = container || event.currentTarget; 15410 const relatedTarget = event.relatedTarget; 15411 return !relatedTarget || !contains2(containerElement, relatedTarget); 15412 } 15413 function queueBeforeEvent(element, type, callback, timeout) { 15414 const createTimer = (callback2) => { 15415 if (timeout) { 15416 const timerId2 = setTimeout(callback2, timeout); 15417 return () => clearTimeout(timerId2); 15418 } 15419 const timerId = requestAnimationFrame(callback2); 15420 return () => cancelAnimationFrame(timerId); 15421 }; 15422 const cancelTimer = createTimer(() => { 15423 element.removeEventListener(type, callSync, true); 15424 callback(); 15425 }); 15426 const callSync = () => { 15427 cancelTimer(); 15428 callback(); 15429 }; 15430 element.addEventListener(type, callSync, { once: true, capture: true }); 15431 return cancelTimer; 15432 } 15433 function addGlobalEventListener(type, listener, options, scope = window) { 15434 const children = []; 15435 try { 15436 scope.document.addEventListener(type, listener, options); 15437 for (const frame of Array.from(scope.frames)) { 15438 children.push(addGlobalEventListener(type, listener, options, frame)); 15439 } 15440 } catch (e2) { 15441 } 15442 const removeEventListener = () => { 15443 try { 15444 scope.document.removeEventListener(type, listener, options); 15445 } catch (e2) { 15446 } 15447 for (const remove of children) { 15448 remove(); 15449 } 15450 }; 15451 return removeEventListener; 15452 } 15453 15454 // node_modules/@ariakit/react-core/esm/__chunks/KPHZR4MB.js 15455 var React47 = __toESM(require_react(), 1); 15456 var import_react7 = __toESM(require_react(), 1); 15457 var _React = { ...React47 }; 15458 var useReactId = _React.useId; 15459 var useReactDeferredValue = _React.useDeferredValue; 15460 var useReactInsertionEffect = _React.useInsertionEffect; 15461 var useSafeLayoutEffect = canUseDOM ? import_react7.useLayoutEffect : import_react7.useEffect; 15462 function useInitialValue(value) { 15463 const [initialValue] = (0, import_react7.useState)(value); 15464 return initialValue; 15465 } 15466 function useLiveRef(value) { 15467 const ref = (0, import_react7.useRef)(value); 15468 useSafeLayoutEffect(() => { 15469 ref.current = value; 15470 }); 15471 return ref; 15472 } 15473 function useEvent(callback) { 15474 const ref = (0, import_react7.useRef)(() => { 15475 throw new Error("Cannot call an event handler while rendering."); 15476 }); 15477 if (useReactInsertionEffect) { 15478 useReactInsertionEffect(() => { 15479 ref.current = callback; 15480 }); 15481 } else { 15482 ref.current = callback; 15483 } 15484 return (0, import_react7.useCallback)((...args) => { 15485 var _a; 15486 return (_a = ref.current) == null ? void 0 : _a.call(ref, ...args); 15487 }, []); 15488 } 15489 function useTransactionState(callback) { 15490 const [state, setState] = (0, import_react7.useState)(null); 15491 useSafeLayoutEffect(() => { 15492 if (state == null) return; 15493 if (!callback) return; 15494 let prevState = null; 15495 callback((prev) => { 15496 prevState = prev; 15497 return state; 15498 }); 15499 return () => { 15500 callback(prevState); 15501 }; 15502 }, [state, callback]); 15503 return [state, setState]; 15504 } 15505 function useMergeRefs(...refs) { 15506 return (0, import_react7.useMemo)(() => { 15507 if (!refs.some(Boolean)) return; 15508 return (value) => { 15509 for (const ref of refs) { 15510 setRef(ref, value); 15511 } 15512 }; 15513 }, refs); 15514 } 15515 function useId4(defaultId) { 15516 if (useReactId) { 15517 const reactId = useReactId(); 15518 if (defaultId) return defaultId; 15519 return reactId; 15520 } 15521 const [id, setId] = (0, import_react7.useState)(defaultId); 15522 useSafeLayoutEffect(() => { 15523 if (defaultId || id) return; 15524 const random = Math.random().toString(36).slice(2, 8); 15525 setId(`id-$random}`); 15526 }, [defaultId, id]); 15527 return defaultId || id; 15528 } 15529 function useTagName(refOrElement, type) { 15530 const stringOrUndefined = (type2) => { 15531 if (typeof type2 !== "string") return; 15532 return type2; 15533 }; 15534 const [tagName, setTagName] = (0, import_react7.useState)(() => stringOrUndefined(type)); 15535 useSafeLayoutEffect(() => { 15536 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement; 15537 setTagName((element == null ? void 0 : element.tagName.toLowerCase()) || stringOrUndefined(type)); 15538 }, [refOrElement, type]); 15539 return tagName; 15540 } 15541 function useAttribute(refOrElement, attributeName, defaultValue2) { 15542 const initialValue = useInitialValue(defaultValue2); 15543 const [attribute, setAttribute] = (0, import_react7.useState)(initialValue); 15544 (0, import_react7.useEffect)(() => { 15545 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement; 15546 if (!element) return; 15547 const callback = () => { 15548 const value = element.getAttribute(attributeName); 15549 setAttribute(value == null ? initialValue : value); 15550 }; 15551 const observer = new MutationObserver(callback); 15552 observer.observe(element, { attributeFilter: [attributeName] }); 15553 callback(); 15554 return () => observer.disconnect(); 15555 }, [refOrElement, attributeName, initialValue]); 15556 return attribute; 15557 } 15558 function useUpdateEffect(effect, deps) { 15559 const mounted = (0, import_react7.useRef)(false); 15560 (0, import_react7.useEffect)(() => { 15561 if (mounted.current) { 15562 return effect(); 15563 } 15564 mounted.current = true; 15565 }, deps); 15566 (0, import_react7.useEffect)( 15567 () => () => { 15568 mounted.current = false; 15569 }, 15570 [] 15571 ); 15572 } 15573 function useUpdateLayoutEffect(effect, deps) { 15574 const mounted = (0, import_react7.useRef)(false); 15575 useSafeLayoutEffect(() => { 15576 if (mounted.current) { 15577 return effect(); 15578 } 15579 mounted.current = true; 15580 }, deps); 15581 useSafeLayoutEffect( 15582 () => () => { 15583 mounted.current = false; 15584 }, 15585 [] 15586 ); 15587 } 15588 function useForceUpdate() { 15589 return (0, import_react7.useReducer)(() => [], []); 15590 } 15591 function useBooleanEvent(booleanOrCallback) { 15592 return useEvent( 15593 typeof booleanOrCallback === "function" ? booleanOrCallback : () => booleanOrCallback 15594 ); 15595 } 15596 function useWrapElement(props, callback, deps = []) { 15597 const wrapElement = (0, import_react7.useCallback)( 15598 (element) => { 15599 if (props.wrapElement) { 15600 element = props.wrapElement(element); 15601 } 15602 return callback(element); 15603 }, 15604 [...deps, props.wrapElement] 15605 ); 15606 return { ...props, wrapElement }; 15607 } 15608 function useMetadataProps(props, key, value) { 15609 const parent = props.onLoadedMetadataCapture; 15610 const onLoadedMetadataCapture = (0, import_react7.useMemo)(() => { 15611 return Object.assign(() => { 15612 }, { ...parent, [key]: value }); 15613 }, [parent, key, value]); 15614 return [parent == null ? void 0 : parent[key], { onLoadedMetadataCapture }]; 15615 } 15616 var hasInstalledGlobalEventListeners = false; 15617 function useIsMouseMoving() { 15618 (0, import_react7.useEffect)(() => { 15619 if (hasInstalledGlobalEventListeners) return; 15620 addGlobalEventListener("mousemove", setMouseMoving, true); 15621 addGlobalEventListener("mousedown", resetMouseMoving, true); 15622 addGlobalEventListener("mouseup", resetMouseMoving, true); 15623 addGlobalEventListener("keydown", resetMouseMoving, true); 15624 addGlobalEventListener("scroll", resetMouseMoving, true); 15625 hasInstalledGlobalEventListeners = true; 15626 }, []); 15627 const isMouseMoving = useEvent(() => mouseMoving); 15628 return isMouseMoving; 15629 } 15630 var mouseMoving = false; 15631 var previousScreenX = 0; 15632 var previousScreenY = 0; 15633 function hasMouseMovement(event) { 15634 const movementX = event.movementX || event.screenX - previousScreenX; 15635 const movementY = event.movementY || event.screenY - previousScreenY; 15636 previousScreenX = event.screenX; 15637 previousScreenY = event.screenY; 15638 return movementX || movementY || false; 15639 } 15640 function setMouseMoving(event) { 15641 if (!hasMouseMovement(event)) return; 15642 mouseMoving = true; 15643 } 15644 function resetMouseMoving() { 15645 mouseMoving = false; 15646 } 15647 15648 // node_modules/@ariakit/react-core/esm/__chunks/GWSL6KNJ.js 15649 var React48 = __toESM(require_react(), 1); 15650 var import_jsx_runtime71 = __toESM(require_jsx_runtime(), 1); 15651 function forwardRef22(render4) { 15652 const Role = React48.forwardRef( 15653 // @ts-ignore Incompatible with React 19 types. Ignore for now. 15654 (props, ref) => render4({ ...props, ref }) 15655 ); 15656 Role.displayName = render4.displayName || render4.name; 15657 return Role; 15658 } 15659 function memo22(Component2, propsAreEqual) { 15660 return React48.memo(Component2, propsAreEqual); 15661 } 15662 function createElement3(Type, props) { 15663 const { wrapElement, render: render4, ...rest } = props; 15664 const mergedRef = useMergeRefs(props.ref, getRefProperty(render4)); 15665 let element; 15666 if (React48.isValidElement(render4)) { 15667 const renderProps = { 15668 // @ts-ignore Incompatible with React 19 types. Ignore for now. 15669 ...render4.props, 15670 ref: mergedRef 15671 }; 15672 element = React48.cloneElement(render4, mergeProps2(rest, renderProps)); 15673 } else if (render4) { 15674 element = render4(rest); 15675 } else { 15676 element = /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(Type, { ...rest }); 15677 } 15678 if (wrapElement) { 15679 return wrapElement(element); 15680 } 15681 return element; 15682 } 15683 function createHook(useProps) { 15684 const useRole = (props = {}) => { 15685 return useProps(props); 15686 }; 15687 useRole.displayName = useProps.name; 15688 return useRole; 15689 } 15690 function createStoreContext(providers = [], scopedProviders = []) { 15691 const context = React48.createContext(void 0); 15692 const scopedContext = React48.createContext(void 0); 15693 const useContext210 = () => React48.useContext(context); 15694 const useScopedContext = (onlyScoped = false) => { 15695 const scoped = React48.useContext(scopedContext); 15696 const store = useContext210(); 15697 if (onlyScoped) return scoped; 15698 return scoped || store; 15699 }; 15700 const useProviderContext = () => { 15701 const scoped = React48.useContext(scopedContext); 15702 const store = useContext210(); 15703 if (scoped && scoped === store) return; 15704 return store; 15705 }; 15706 const ContextProvider = (props) => { 15707 return providers.reduceRight( 15708 (children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(Provider2, { ...props, children }), 15709 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(context.Provider, { ...props }) 15710 ); 15711 }; 15712 const ScopedContextProvider = (props) => { 15713 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(ContextProvider, { ...props, children: scopedProviders.reduceRight( 15714 (children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(Provider2, { ...props, children }), 15715 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(scopedContext.Provider, { ...props }) 15716 ) }); 15717 }; 15718 return { 15719 context, 15720 scopedContext, 15721 useContext: useContext210, 15722 useScopedContext, 15723 useProviderContext, 15724 ContextProvider, 15725 ScopedContextProvider 15726 }; 15727 } 15728 15729 // node_modules/@ariakit/react-core/esm/__chunks/SMPCIMZM.js 15730 var ctx = createStoreContext(); 15731 var useCollectionContext = ctx.useContext; 15732 var useCollectionScopedContext = ctx.useScopedContext; 15733 var useCollectionProviderContext = ctx.useProviderContext; 15734 var CollectionContextProvider = ctx.ContextProvider; 15735 var CollectionScopedContextProvider = ctx.ScopedContextProvider; 15736 15737 // node_modules/@ariakit/react-core/esm/__chunks/AVVXDJMZ.js 15738 var import_react8 = __toESM(require_react(), 1); 15739 var ctx2 = createStoreContext( 15740 [CollectionContextProvider], 15741 [CollectionScopedContextProvider] 15742 ); 15743 var useCompositeContext = ctx2.useContext; 15744 var useCompositeScopedContext = ctx2.useScopedContext; 15745 var useCompositeProviderContext = ctx2.useProviderContext; 15746 var CompositeContextProvider = ctx2.ContextProvider; 15747 var CompositeScopedContextProvider = ctx2.ScopedContextProvider; 15748 var CompositeItemContext = (0, import_react8.createContext)( 15749 void 0 15750 ); 15751 var CompositeRowContext = (0, import_react8.createContext)( 15752 void 0 15753 ); 15754 15755 // node_modules/@ariakit/react-core/esm/__chunks/5VQZOHHZ.js 15756 function findFirstEnabledItem(items, excludeId) { 15757 return items.find((item) => { 15758 if (excludeId) { 15759 return !item.disabled && item.id !== excludeId; 15760 } 15761 return !item.disabled; 15762 }); 15763 } 15764 function getEnabledItem(store, id) { 15765 if (!id) return null; 15766 return store.item(id) || null; 15767 } 15768 function groupItemsByRows(items) { 15769 const rows = []; 15770 for (const item of items) { 15771 const row = rows.find((currentRow) => { 15772 var _a; 15773 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId; 15774 }); 15775 if (row) { 15776 row.push(item); 15777 } else { 15778 rows.push([item]); 15779 } 15780 } 15781 return rows; 15782 } 15783 function selectTextField(element, collapseToEnd = false) { 15784 if (isTextField(element)) { 15785 element.setSelectionRange( 15786 collapseToEnd ? element.value.length : 0, 15787 element.value.length 15788 ); 15789 } else if (element.isContentEditable) { 15790 const selection = getDocument(element).getSelection(); 15791 selection == null ? void 0 : selection.selectAllChildren(element); 15792 if (collapseToEnd) { 15793 selection == null ? void 0 : selection.collapseToEnd(); 15794 } 15795 } 15796 } 15797 var FOCUS_SILENTLY = /* @__PURE__ */ Symbol("FOCUS_SILENTLY"); 15798 function focusSilently(element) { 15799 element[FOCUS_SILENTLY] = true; 15800 element.focus({ preventScroll: true }); 15801 } 15802 function silentlyFocused(element) { 15803 const isSilentlyFocused = element[FOCUS_SILENTLY]; 15804 delete element[FOCUS_SILENTLY]; 15805 return isSilentlyFocused; 15806 } 15807 function isItem(store, element, exclude) { 15808 if (!element) return false; 15809 if (element === exclude) return false; 15810 const item = store.item(element.id); 15811 if (!item) return false; 15812 if (exclude && item.element === exclude) return false; 15813 return true; 15814 } 15815 15816 // node_modules/@ariakit/react-core/esm/__chunks/Z2O3VLAQ.js 15817 var import_react9 = __toESM(require_react(), 1); 15818 var TagName = "div"; 15819 var useCollectionItem = createHook( 15820 function useCollectionItem2({ 15821 store, 15822 shouldRegisterItem = true, 15823 getItem = identity, 15824 // @ts-expect-error This prop may come from a collection renderer. 15825 element, 15826 ...props 15827 }) { 15828 const context = useCollectionContext(); 15829 store = store || context; 15830 const id = useId4(props.id); 15831 const ref = (0, import_react9.useRef)(element); 15832 (0, import_react9.useEffect)(() => { 15833 const element2 = ref.current; 15834 if (!id) return; 15835 if (!element2) return; 15836 if (!shouldRegisterItem) return; 15837 const item = getItem({ id, element: element2 }); 15838 return store == null ? void 0 : store.renderItem(item); 15839 }, [id, shouldRegisterItem, getItem, store]); 15840 props = { 15841 ...props, 15842 ref: useMergeRefs(ref, props.ref) 15843 }; 15844 return removeUndefinedValues(props); 15845 } 15846 ); 15847 var CollectionItem = forwardRef22(function CollectionItem2(props) { 15848 const htmlProps = useCollectionItem(props); 15849 return createElement3(TagName, htmlProps); 15850 }); 15851 15852 // node_modules/@ariakit/react-core/esm/__chunks/SWN3JYXT.js 15853 var import_react10 = __toESM(require_react(), 1); 15854 var FocusableContext = (0, import_react10.createContext)(true); 15855 15856 // node_modules/@ariakit/core/esm/utils/focus.js 15857 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'])"; 15858 function isFocusable(element) { 15859 if (!element.matches(selector)) return false; 15860 if (!isVisible(element)) return false; 15861 if (element.closest("[inert]")) return false; 15862 return true; 15863 } 15864 function getClosestFocusable(element) { 15865 while (element && !isFocusable(element)) { 15866 element = element.closest(selector); 15867 } 15868 return element || null; 15869 } 15870 function hasFocus(element) { 15871 const activeElement2 = getActiveElement(element); 15872 if (!activeElement2) return false; 15873 if (activeElement2 === element) return true; 15874 const activeDescendant = activeElement2.getAttribute("aria-activedescendant"); 15875 if (!activeDescendant) return false; 15876 return activeDescendant === element.id; 15877 } 15878 function hasFocusWithin(element) { 15879 const activeElement2 = getActiveElement(element); 15880 if (!activeElement2) return false; 15881 if (contains2(element, activeElement2)) return true; 15882 const activeDescendant = activeElement2.getAttribute("aria-activedescendant"); 15883 if (!activeDescendant) return false; 15884 if (!("id" in element)) return false; 15885 if (activeDescendant === element.id) return true; 15886 return !!element.querySelector(`#$CSS.escape(activeDescendant)}`); 15887 } 15888 function focusIfNeeded(element) { 15889 if (!hasFocusWithin(element) && isFocusable(element)) { 15890 element.focus(); 15891 } 15892 } 15893 function focusIntoView(element, options) { 15894 if (!("scrollIntoView" in element)) { 15895 element.focus(); 15896 } else { 15897 element.focus({ preventScroll: true }); 15898 element.scrollIntoView({ block: "nearest", inline: "nearest", ...options }); 15899 } 15900 } 15901 15902 // node_modules/@ariakit/react-core/esm/__chunks/U6HHPQDW.js 15903 var import_react11 = __toESM(require_react(), 1); 15904 var TagName2 = "div"; 15905 var isSafariBrowser = isSafari2(); 15906 var alwaysFocusVisibleInputTypes = [ 15907 "text", 15908 "search", 15909 "url", 15910 "tel", 15911 "email", 15912 "password", 15913 "number", 15914 "date", 15915 "month", 15916 "week", 15917 "time", 15918 "datetime", 15919 "datetime-local" 15920 ]; 15921 var safariFocusAncestorSymbol = /* @__PURE__ */ Symbol("safariFocusAncestor"); 15922 function markSafariFocusAncestor(element, value) { 15923 if (!element) return; 15924 element[safariFocusAncestorSymbol] = value; 15925 } 15926 function isAlwaysFocusVisible(element) { 15927 const { tagName, readOnly, type } = element; 15928 if (tagName === "TEXTAREA" && !readOnly) return true; 15929 if (tagName === "SELECT" && !readOnly) return true; 15930 if (tagName === "INPUT" && !readOnly) { 15931 return alwaysFocusVisibleInputTypes.includes(type); 15932 } 15933 if (element.isContentEditable) return true; 15934 const role = element.getAttribute("role"); 15935 if (role === "combobox" && element.dataset.name) { 15936 return true; 15937 } 15938 return false; 15939 } 15940 function getLabels(element) { 15941 if ("labels" in element) { 15942 return element.labels; 15943 } 15944 return null; 15945 } 15946 function isNativeCheckboxOrRadio(element) { 15947 const tagName = element.tagName.toLowerCase(); 15948 if (tagName === "input" && element.type) { 15949 return element.type === "radio" || element.type === "checkbox"; 15950 } 15951 return false; 15952 } 15953 function isNativeTabbable(tagName) { 15954 if (!tagName) return true; 15955 return tagName === "button" || tagName === "summary" || tagName === "input" || tagName === "select" || tagName === "textarea" || tagName === "a"; 15956 } 15957 function supportsDisabledAttribute(tagName) { 15958 if (!tagName) return true; 15959 return tagName === "button" || tagName === "input" || tagName === "select" || tagName === "textarea"; 15960 } 15961 function getTabIndex2(focusable2, trulyDisabled, nativeTabbable, supportsDisabled, tabIndexProp) { 15962 if (!focusable2) { 15963 return tabIndexProp; 15964 } 15965 if (trulyDisabled) { 15966 if (nativeTabbable && !supportsDisabled) { 15967 return -1; 15968 } 15969 return; 15970 } 15971 if (nativeTabbable) { 15972 return tabIndexProp; 15973 } 15974 return tabIndexProp || 0; 15975 } 15976 function useDisableEvent(onEvent, disabled2) { 15977 return useEvent((event) => { 15978 onEvent == null ? void 0 : onEvent(event); 15979 if (event.defaultPrevented) return; 15980 if (disabled2) { 15981 event.stopPropagation(); 15982 event.preventDefault(); 15983 } 15984 }); 15985 } 15986 var hasInstalledGlobalEventListeners2 = false; 15987 var isKeyboardModality = true; 15988 function onGlobalMouseDown(event) { 15989 const target = event.target; 15990 if (target && "hasAttribute" in target) { 15991 if (!target.hasAttribute("data-focus-visible")) { 15992 isKeyboardModality = false; 15993 } 15994 } 15995 } 15996 function onGlobalKeyDown(event) { 15997 if (event.metaKey) return; 15998 if (event.ctrlKey) return; 15999 if (event.altKey) return; 16000 isKeyboardModality = true; 16001 } 16002 var useFocusable = createHook( 16003 function useFocusable2({ 16004 focusable: focusable2 = true, 16005 accessibleWhenDisabled, 16006 autoFocus, 16007 onFocusVisible, 16008 ...props 16009 }) { 16010 const ref = (0, import_react11.useRef)(null); 16011 (0, import_react11.useEffect)(() => { 16012 if (!focusable2) return; 16013 if (hasInstalledGlobalEventListeners2) return; 16014 addGlobalEventListener("mousedown", onGlobalMouseDown, true); 16015 addGlobalEventListener("keydown", onGlobalKeyDown, true); 16016 hasInstalledGlobalEventListeners2 = true; 16017 }, [focusable2]); 16018 if (isSafariBrowser) { 16019 (0, import_react11.useEffect)(() => { 16020 if (!focusable2) return; 16021 const element = ref.current; 16022 if (!element) return; 16023 if (!isNativeCheckboxOrRadio(element)) return; 16024 const labels = getLabels(element); 16025 if (!labels) return; 16026 const onMouseUp = () => queueMicrotask(() => element.focus()); 16027 for (const label of labels) { 16028 label.addEventListener("mouseup", onMouseUp); 16029 } 16030 return () => { 16031 for (const label of labels) { 16032 label.removeEventListener("mouseup", onMouseUp); 16033 } 16034 }; 16035 }, [focusable2]); 16036 } 16037 const disabled2 = focusable2 && disabledFromProps(props); 16038 const trulyDisabled = !!disabled2 && !accessibleWhenDisabled; 16039 const [focusVisible, setFocusVisible] = (0, import_react11.useState)(false); 16040 (0, import_react11.useEffect)(() => { 16041 if (!focusable2) return; 16042 if (trulyDisabled && focusVisible) { 16043 setFocusVisible(false); 16044 } 16045 }, [focusable2, trulyDisabled, focusVisible]); 16046 (0, import_react11.useEffect)(() => { 16047 if (!focusable2) return; 16048 if (!focusVisible) return; 16049 const element = ref.current; 16050 if (!element) return; 16051 if (typeof IntersectionObserver === "undefined") return; 16052 const observer = new IntersectionObserver(() => { 16053 if (!isFocusable(element)) { 16054 setFocusVisible(false); 16055 } 16056 }); 16057 observer.observe(element); 16058 return () => observer.disconnect(); 16059 }, [focusable2, focusVisible]); 16060 const onKeyPressCapture = useDisableEvent( 16061 props.onKeyPressCapture, 16062 disabled2 16063 ); 16064 const onMouseDownCapture = useDisableEvent( 16065 props.onMouseDownCapture, 16066 disabled2 16067 ); 16068 const onClickCapture = useDisableEvent(props.onClickCapture, disabled2); 16069 const onMouseDownProp = props.onMouseDown; 16070 const onMouseDown = useEvent((event) => { 16071 onMouseDownProp == null ? void 0 : onMouseDownProp(event); 16072 if (event.defaultPrevented) return; 16073 if (!focusable2) return; 16074 const element = event.currentTarget; 16075 if (!isSafariBrowser) return; 16076 if (isPortalEvent(event)) return; 16077 if (!isButton(element) && !isNativeCheckboxOrRadio(element)) return; 16078 let receivedFocus = false; 16079 const onFocus = () => { 16080 receivedFocus = true; 16081 }; 16082 const options = { capture: true, once: true }; 16083 element.addEventListener("focusin", onFocus, options); 16084 const focusableContainer = getClosestFocusable(element.parentElement); 16085 markSafariFocusAncestor(focusableContainer, true); 16086 queueBeforeEvent(element, "mouseup", () => { 16087 element.removeEventListener("focusin", onFocus, true); 16088 markSafariFocusAncestor(focusableContainer, false); 16089 if (receivedFocus) return; 16090 focusIfNeeded(element); 16091 }); 16092 }); 16093 const handleFocusVisible = (event, currentTarget) => { 16094 if (currentTarget) { 16095 event.currentTarget = currentTarget; 16096 } 16097 if (!focusable2) return; 16098 const element = event.currentTarget; 16099 if (!element) return; 16100 if (!hasFocus(element)) return; 16101 onFocusVisible == null ? void 0 : onFocusVisible(event); 16102 if (event.defaultPrevented) return; 16103 element.dataset.focusVisible = "true"; 16104 setFocusVisible(true); 16105 }; 16106 const onKeyDownCaptureProp = props.onKeyDownCapture; 16107 const onKeyDownCapture = useEvent((event) => { 16108 onKeyDownCaptureProp == null ? void 0 : onKeyDownCaptureProp(event); 16109 if (event.defaultPrevented) return; 16110 if (!focusable2) return; 16111 if (focusVisible) return; 16112 if (event.metaKey) return; 16113 if (event.altKey) return; 16114 if (event.ctrlKey) return; 16115 if (!isSelfTarget(event)) return; 16116 const element = event.currentTarget; 16117 const applyFocusVisible = () => handleFocusVisible(event, element); 16118 queueBeforeEvent(element, "focusout", applyFocusVisible); 16119 }); 16120 const onFocusCaptureProp = props.onFocusCapture; 16121 const onFocusCapture = useEvent((event) => { 16122 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event); 16123 if (event.defaultPrevented) return; 16124 if (!focusable2) return; 16125 if (!isSelfTarget(event)) { 16126 setFocusVisible(false); 16127 return; 16128 } 16129 const element = event.currentTarget; 16130 const applyFocusVisible = () => handleFocusVisible(event, element); 16131 if (isKeyboardModality || isAlwaysFocusVisible(event.target)) { 16132 queueBeforeEvent(event.target, "focusout", applyFocusVisible); 16133 } else { 16134 setFocusVisible(false); 16135 } 16136 }); 16137 const onBlurProp = props.onBlur; 16138 const onBlur = useEvent((event) => { 16139 onBlurProp == null ? void 0 : onBlurProp(event); 16140 if (!focusable2) return; 16141 if (!isFocusEventOutside(event)) return; 16142 event.currentTarget.removeAttribute("data-focus-visible"); 16143 setFocusVisible(false); 16144 }); 16145 const autoFocusOnShow = (0, import_react11.useContext)(FocusableContext); 16146 const autoFocusRef = useEvent((element) => { 16147 if (!focusable2) return; 16148 if (!autoFocus) return; 16149 if (!element) return; 16150 if (!autoFocusOnShow) return; 16151 queueMicrotask(() => { 16152 if (hasFocus(element)) return; 16153 if (!isFocusable(element)) return; 16154 element.focus(); 16155 }); 16156 }); 16157 const tagName = useTagName(ref); 16158 const nativeTabbable = focusable2 && isNativeTabbable(tagName); 16159 const supportsDisabled = focusable2 && supportsDisabledAttribute(tagName); 16160 const styleProp = props.style; 16161 const style = (0, import_react11.useMemo)(() => { 16162 if (trulyDisabled) { 16163 return { pointerEvents: "none", ...styleProp }; 16164 } 16165 return styleProp; 16166 }, [trulyDisabled, styleProp]); 16167 props = { 16168 "data-focus-visible": focusable2 && focusVisible || void 0, 16169 "data-autofocus": autoFocus || void 0, 16170 "aria-disabled": disabled2 || void 0, 16171 ...props, 16172 ref: useMergeRefs(ref, autoFocusRef, props.ref), 16173 style, 16174 tabIndex: getTabIndex2( 16175 focusable2, 16176 trulyDisabled, 16177 nativeTabbable, 16178 supportsDisabled, 16179 props.tabIndex 16180 ), 16181 disabled: supportsDisabled && trulyDisabled ? true : void 0, 16182 // TODO: Test Focusable contentEditable. 16183 contentEditable: disabled2 ? void 0 : props.contentEditable, 16184 onKeyPressCapture, 16185 onClickCapture, 16186 onMouseDownCapture, 16187 onMouseDown, 16188 onKeyDownCapture, 16189 onFocusCapture, 16190 onBlur 16191 }; 16192 return removeUndefinedValues(props); 16193 } 16194 ); 16195 var Focusable = forwardRef22(function Focusable2(props) { 16196 const htmlProps = useFocusable(props); 16197 return createElement3(TagName2, htmlProps); 16198 }); 16199 16200 // node_modules/@ariakit/react-core/esm/__chunks/PZ3OL7I2.js 16201 var import_react12 = __toESM(require_react(), 1); 16202 var TagName3 = "button"; 16203 function isNativeClick(event) { 16204 if (!event.isTrusted) return false; 16205 const element = event.currentTarget; 16206 if (event.key === "Enter") { 16207 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "A"; 16208 } 16209 if (event.key === " ") { 16210 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "INPUT" || element.tagName === "SELECT"; 16211 } 16212 return false; 16213 } 16214 var symbol = /* @__PURE__ */ Symbol("command"); 16215 var useCommand = createHook( 16216 function useCommand2({ clickOnEnter = true, clickOnSpace = true, ...props }) { 16217 const ref = (0, import_react12.useRef)(null); 16218 const [isNativeButton, setIsNativeButton] = (0, import_react12.useState)(false); 16219 (0, import_react12.useEffect)(() => { 16220 if (!ref.current) return; 16221 setIsNativeButton(isButton(ref.current)); 16222 }, []); 16223 const [active, setActive] = (0, import_react12.useState)(false); 16224 const activeRef = (0, import_react12.useRef)(false); 16225 const disabled2 = disabledFromProps(props); 16226 const [isDuplicate, metadataProps] = useMetadataProps(props, symbol, true); 16227 const onKeyDownProp = props.onKeyDown; 16228 const onKeyDown = useEvent((event) => { 16229 onKeyDownProp == null ? void 0 : onKeyDownProp(event); 16230 const element = event.currentTarget; 16231 if (event.defaultPrevented) return; 16232 if (isDuplicate) return; 16233 if (disabled2) return; 16234 if (!isSelfTarget(event)) return; 16235 if (isTextField(element)) return; 16236 if (element.isContentEditable) return; 16237 const isEnter = clickOnEnter && event.key === "Enter"; 16238 const isSpace = clickOnSpace && event.key === " "; 16239 const shouldPreventEnter = event.key === "Enter" && !clickOnEnter; 16240 const shouldPreventSpace = event.key === " " && !clickOnSpace; 16241 if (shouldPreventEnter || shouldPreventSpace) { 16242 event.preventDefault(); 16243 return; 16244 } 16245 if (isEnter || isSpace) { 16246 const nativeClick = isNativeClick(event); 16247 if (isEnter) { 16248 if (!nativeClick) { 16249 event.preventDefault(); 16250 const { view, ...eventInit } = event; 16251 const click = () => fireClickEvent(element, eventInit); 16252 if (isFirefox2()) { 16253 queueBeforeEvent(element, "keyup", click); 16254 } else { 16255 queueMicrotask(click); 16256 } 16257 } 16258 } else if (isSpace) { 16259 activeRef.current = true; 16260 if (!nativeClick) { 16261 event.preventDefault(); 16262 setActive(true); 16263 } 16264 } 16265 } 16266 }); 16267 const onKeyUpProp = props.onKeyUp; 16268 const onKeyUp = useEvent((event) => { 16269 onKeyUpProp == null ? void 0 : onKeyUpProp(event); 16270 if (event.defaultPrevented) return; 16271 if (isDuplicate) return; 16272 if (disabled2) return; 16273 if (event.metaKey) return; 16274 const isSpace = clickOnSpace && event.key === " "; 16275 if (activeRef.current && isSpace) { 16276 activeRef.current = false; 16277 if (!isNativeClick(event)) { 16278 event.preventDefault(); 16279 setActive(false); 16280 const element = event.currentTarget; 16281 const { view, ...eventInit } = event; 16282 queueMicrotask(() => fireClickEvent(element, eventInit)); 16283 } 16284 } 16285 }); 16286 props = { 16287 "data-active": active || void 0, 16288 type: isNativeButton ? "button" : void 0, 16289 ...metadataProps, 16290 ...props, 16291 ref: useMergeRefs(ref, props.ref), 16292 onKeyDown, 16293 onKeyUp 16294 }; 16295 props = useFocusable(props); 16296 return props; 16297 } 16298 ); 16299 var Command = forwardRef22(function Command2(props) { 16300 const htmlProps = useCommand(props); 16301 return createElement3(TagName3, htmlProps); 16302 }); 16303 16304 // node_modules/@ariakit/core/esm/__chunks/SXKM4CGU.js 16305 function getInternal(store, key) { 16306 const internals = store.__unstableInternals; 16307 invariant(internals, "Invalid store"); 16308 return internals[key]; 16309 } 16310 function createStore(initialState, ...stores) { 16311 let state = initialState; 16312 let prevStateBatch = state; 16313 let lastUpdate = /* @__PURE__ */ Symbol(); 16314 let destroy = noop5; 16315 const instances = /* @__PURE__ */ new Set(); 16316 const updatedKeys = /* @__PURE__ */ new Set(); 16317 const setups = /* @__PURE__ */ new Set(); 16318 const listeners = /* @__PURE__ */ new Set(); 16319 const batchListeners = /* @__PURE__ */ new Set(); 16320 const disposables = /* @__PURE__ */ new WeakMap(); 16321 const listenerKeys = /* @__PURE__ */ new WeakMap(); 16322 const storeSetup = (callback) => { 16323 setups.add(callback); 16324 return () => setups.delete(callback); 16325 }; 16326 const storeInit = () => { 16327 const initialized = instances.size; 16328 const instance = /* @__PURE__ */ Symbol(); 16329 instances.add(instance); 16330 const maybeDestroy = () => { 16331 instances.delete(instance); 16332 if (instances.size) return; 16333 destroy(); 16334 }; 16335 if (initialized) return maybeDestroy; 16336 const desyncs = getKeys(state).map( 16337 (key) => chain( 16338 ...stores.map((store) => { 16339 var _a; 16340 const storeState = (_a = store == null ? void 0 : store.getState) == null ? void 0 : _a.call(store); 16341 if (!storeState) return; 16342 if (!hasOwnProperty(storeState, key)) return; 16343 return sync(store, [key], (state2) => { 16344 setState( 16345 key, 16346 state2[key], 16347 // @ts-expect-error - Not public API. This is just to prevent 16348 // infinite loops. 16349 true 16350 ); 16351 }); 16352 }) 16353 ) 16354 ); 16355 const teardowns = []; 16356 for (const setup2 of setups) { 16357 teardowns.push(setup2()); 16358 } 16359 const cleanups = stores.map(init); 16360 destroy = chain(...desyncs, ...teardowns, ...cleanups); 16361 return maybeDestroy; 16362 }; 16363 const sub = (keys, listener, set2 = listeners) => { 16364 set2.add(listener); 16365 listenerKeys.set(listener, keys); 16366 return () => { 16367 var _a; 16368 (_a = disposables.get(listener)) == null ? void 0 : _a(); 16369 disposables.delete(listener); 16370 listenerKeys.delete(listener); 16371 set2.delete(listener); 16372 }; 16373 }; 16374 const storeSubscribe = (keys, listener) => sub(keys, listener); 16375 const storeSync = (keys, listener) => { 16376 disposables.set(listener, listener(state, state)); 16377 return sub(keys, listener); 16378 }; 16379 const storeBatch = (keys, listener) => { 16380 disposables.set(listener, listener(state, prevStateBatch)); 16381 return sub(keys, listener, batchListeners); 16382 }; 16383 const storePick = (keys) => createStore(pick(state, keys), finalStore); 16384 const storeOmit = (keys) => createStore(omit(state, keys), finalStore); 16385 const getState = () => state; 16386 const setState = (key, value, fromStores = false) => { 16387 var _a; 16388 if (!hasOwnProperty(state, key)) return; 16389 const nextValue = applyState(value, state[key]); 16390 if (nextValue === state[key]) return; 16391 if (!fromStores) { 16392 for (const store of stores) { 16393 (_a = store == null ? void 0 : store.setState) == null ? void 0 : _a.call(store, key, nextValue); 16394 } 16395 } 16396 const prevState = state; 16397 state = { ...state, [key]: nextValue }; 16398 const thisUpdate = /* @__PURE__ */ Symbol(); 16399 lastUpdate = thisUpdate; 16400 updatedKeys.add(key); 16401 const run = (listener, prev, uKeys) => { 16402 var _a2; 16403 const keys = listenerKeys.get(listener); 16404 const updated = (k) => uKeys ? uKeys.has(k) : k === key; 16405 if (!keys || keys.some(updated)) { 16406 (_a2 = disposables.get(listener)) == null ? void 0 : _a2(); 16407 disposables.set(listener, listener(state, prev)); 16408 } 16409 }; 16410 for (const listener of listeners) { 16411 run(listener, prevState); 16412 } 16413 queueMicrotask(() => { 16414 if (lastUpdate !== thisUpdate) return; 16415 const snapshot = state; 16416 for (const listener of batchListeners) { 16417 run(listener, prevStateBatch, updatedKeys); 16418 } 16419 prevStateBatch = snapshot; 16420 updatedKeys.clear(); 16421 }); 16422 }; 16423 const finalStore = { 16424 getState, 16425 setState, 16426 __unstableInternals: { 16427 setup: storeSetup, 16428 init: storeInit, 16429 subscribe: storeSubscribe, 16430 sync: storeSync, 16431 batch: storeBatch, 16432 pick: storePick, 16433 omit: storeOmit 16434 } 16435 }; 16436 return finalStore; 16437 } 16438 function setup(store, ...args) { 16439 if (!store) return; 16440 return getInternal(store, "setup")(...args); 16441 } 16442 function init(store, ...args) { 16443 if (!store) return; 16444 return getInternal(store, "init")(...args); 16445 } 16446 function subscribe(store, ...args) { 16447 if (!store) return; 16448 return getInternal(store, "subscribe")(...args); 16449 } 16450 function sync(store, ...args) { 16451 if (!store) return; 16452 return getInternal(store, "sync")(...args); 16453 } 16454 function batch(store, ...args) { 16455 if (!store) return; 16456 return getInternal(store, "batch")(...args); 16457 } 16458 function omit2(store, ...args) { 16459 if (!store) return; 16460 return getInternal(store, "omit")(...args); 16461 } 16462 function pick2(store, ...args) { 16463 if (!store) return; 16464 return getInternal(store, "pick")(...args); 16465 } 16466 function mergeStore(...stores) { 16467 var _a; 16468 const initialState = {}; 16469 for (const store2 of stores) { 16470 const nextState = (_a = store2 == null ? void 0 : store2.getState) == null ? void 0 : _a.call(store2); 16471 if (nextState) { 16472 Object.assign(initialState, nextState); 16473 } 16474 } 16475 const store = createStore(initialState, ...stores); 16476 return Object.assign({}, ...stores, store); 16477 } 16478 function throwOnConflictingProps(props, store) { 16479 if (false) return; 16480 if (!store) return; 16481 const defaultKeys = Object.entries(props).filter(([key, value]) => key.startsWith("default") && value !== void 0).map(([key]) => { 16482 var _a; 16483 const stateKey = key.replace("default", ""); 16484 return `${((_a = stateKey[0]) == null ? void 0 : _a.toLowerCase()) || ""}$stateKey.slice(1)}`; 16485 }); 16486 if (!defaultKeys.length) return; 16487 const storeState = store.getState(); 16488 const conflictingProps = defaultKeys.filter( 16489 (key) => hasOwnProperty(storeState, key) 16490 ); 16491 if (!conflictingProps.length) return; 16492 throw new Error( 16493 `Passing a store prop in conjunction with a default state is not supported. 16494 16495 const store = useSelectStore(); 16496 <SelectProvider store={store} defaultValue="Apple" /> 16497 ^ ^ 16498 16499 Instead, pass the default state to the topmost store: 16500 16501 const store = useSelectStore({ defaultValue: "Apple" }); 16502 <SelectProvider store={store} /> 16503 16504 See https://github.com/ariakit/ariakit/pull/2745 for more details. 16505 16506 If there's a particular need for this, please submit a feature request at https://github.com/ariakit/ariakit 16507 ` 16508 ); 16509 } 16510 16511 // node_modules/@ariakit/react-core/esm/__chunks/Q5W46E73.js 16512 var React49 = __toESM(require_react(), 1); 16513 var import_shim2 = __toESM(require_shim(), 1); 16514 var { useSyncExternalStore: useSyncExternalStore2 } = import_shim2.default; 16515 var noopSubscribe = () => () => { 16516 }; 16517 function useStoreState(store, keyOrSelector = identity) { 16518 const storeSubscribe = React49.useCallback( 16519 (callback) => { 16520 if (!store) return noopSubscribe(); 16521 return subscribe(store, null, callback); 16522 }, 16523 [store] 16524 ); 16525 const getSnapshot = () => { 16526 const key = typeof keyOrSelector === "string" ? keyOrSelector : null; 16527 const selector2 = typeof keyOrSelector === "function" ? keyOrSelector : null; 16528 const state = store == null ? void 0 : store.getState(); 16529 if (selector2) return selector2(state); 16530 if (!state) return; 16531 if (!key) return; 16532 if (!hasOwnProperty(state, key)) return; 16533 return state[key]; 16534 }; 16535 return useSyncExternalStore2(storeSubscribe, getSnapshot, getSnapshot); 16536 } 16537 function useStoreStateObject(store, object) { 16538 const objRef = React49.useRef( 16539 {} 16540 ); 16541 const storeSubscribe = React49.useCallback( 16542 (callback) => { 16543 if (!store) return noopSubscribe(); 16544 return subscribe(store, null, callback); 16545 }, 16546 [store] 16547 ); 16548 const getSnapshot = () => { 16549 const state = store == null ? void 0 : store.getState(); 16550 let updated = false; 16551 const obj = objRef.current; 16552 for (const prop in object) { 16553 const keyOrSelector = object[prop]; 16554 if (typeof keyOrSelector === "function") { 16555 const value = keyOrSelector(state); 16556 if (value !== obj[prop]) { 16557 obj[prop] = value; 16558 updated = true; 16559 } 16560 } 16561 if (typeof keyOrSelector === "string") { 16562 if (!state) continue; 16563 if (!hasOwnProperty(state, keyOrSelector)) continue; 16564 const value = state[keyOrSelector]; 16565 if (value !== obj[prop]) { 16566 obj[prop] = value; 16567 updated = true; 16568 } 16569 } 16570 } 16571 if (updated) { 16572 objRef.current = { ...obj }; 16573 } 16574 return objRef.current; 16575 }; 16576 return useSyncExternalStore2(storeSubscribe, getSnapshot, getSnapshot); 16577 } 16578 function useStoreProps(store, props, key, setKey) { 16579 const value = hasOwnProperty(props, key) ? props[key] : void 0; 16580 const setValue = setKey ? props[setKey] : void 0; 16581 const propsRef = useLiveRef({ value, setValue }); 16582 useSafeLayoutEffect(() => { 16583 return sync(store, [key], (state, prev) => { 16584 const { value: value2, setValue: setValue2 } = propsRef.current; 16585 if (!setValue2) return; 16586 if (state[key] === prev[key]) return; 16587 if (state[key] === value2) return; 16588 setValue2(state[key]); 16589 }); 16590 }, [store, key]); 16591 useSafeLayoutEffect(() => { 16592 if (value === void 0) return; 16593 store.setState(key, value); 16594 return batch(store, [key], () => { 16595 if (value === void 0) return; 16596 store.setState(key, value); 16597 }); 16598 }); 16599 } 16600 function useStore2(createStore2, props) { 16601 const [store, setStore] = React49.useState(() => createStore2(props)); 16602 useSafeLayoutEffect(() => init(store), [store]); 16603 const useState210 = React49.useCallback( 16604 (keyOrSelector) => useStoreState(store, keyOrSelector), 16605 [store] 16606 ); 16607 const memoizedStore = React49.useMemo( 16608 () => ({ ...store, useState: useState210 }), 16609 [store, useState210] 16610 ); 16611 const updateStore = useEvent(() => { 16612 setStore((store2) => createStore2({ ...props, ...store2.getState() })); 16613 }); 16614 return [memoizedStore, updateStore]; 16615 } 16616 16617 // node_modules/@ariakit/react-core/esm/__chunks/WZWDIE3S.js 16618 var import_react13 = __toESM(require_react(), 1); 16619 var import_jsx_runtime72 = __toESM(require_jsx_runtime(), 1); 16620 var TagName4 = "button"; 16621 function isEditableElement(element) { 16622 if (isTextbox(element)) return true; 16623 return element.tagName === "INPUT" && !isButton(element); 16624 } 16625 function getNextPageOffset(scrollingElement, pageUp = false) { 16626 const height = scrollingElement.clientHeight; 16627 const { top } = scrollingElement.getBoundingClientRect(); 16628 const pageSize = Math.max(height * 0.875, height - 40) * 1.5; 16629 const pageOffset = pageUp ? height - pageSize + top : pageSize + top; 16630 if (scrollingElement.tagName === "HTML") { 16631 return pageOffset + scrollingElement.scrollTop; 16632 } 16633 return pageOffset; 16634 } 16635 function getItemOffset(itemElement, pageUp = false) { 16636 const { top } = itemElement.getBoundingClientRect(); 16637 if (pageUp) { 16638 return top + itemElement.clientHeight; 16639 } 16640 return top; 16641 } 16642 function findNextPageItemId(element, store, next, pageUp = false) { 16643 var _a; 16644 if (!store) return; 16645 if (!next) return; 16646 const { renderedItems } = store.getState(); 16647 const scrollingElement = getScrollingElement(element); 16648 if (!scrollingElement) return; 16649 const nextPageOffset = getNextPageOffset(scrollingElement, pageUp); 16650 let id; 16651 let prevDifference; 16652 for (let i2 = 0; i2 < renderedItems.length; i2 += 1) { 16653 const previousId = id; 16654 id = next(i2); 16655 if (!id) break; 16656 if (id === previousId) continue; 16657 const itemElement = (_a = getEnabledItem(store, id)) == null ? void 0 : _a.element; 16658 if (!itemElement) continue; 16659 const itemOffset = getItemOffset(itemElement, pageUp); 16660 const difference = itemOffset - nextPageOffset; 16661 const absDifference = Math.abs(difference); 16662 if (pageUp && difference <= 0 || !pageUp && difference >= 0) { 16663 if (prevDifference !== void 0 && prevDifference < absDifference) { 16664 id = previousId; 16665 } 16666 break; 16667 } 16668 prevDifference = absDifference; 16669 } 16670 return id; 16671 } 16672 function targetIsAnotherItem(event, store) { 16673 if (isSelfTarget(event)) return false; 16674 return isItem(store, event.target); 16675 } 16676 var useCompositeItem = createHook( 16677 function useCompositeItem2({ 16678 store, 16679 rowId: rowIdProp, 16680 preventScrollOnKeyDown = false, 16681 moveOnKeyPress = true, 16682 tabbable: tabbable2 = false, 16683 getItem: getItemProp, 16684 "aria-setsize": ariaSetSizeProp, 16685 "aria-posinset": ariaPosInSetProp, 16686 ...props 16687 }) { 16688 const context = useCompositeContext(); 16689 store = store || context; 16690 const id = useId4(props.id); 16691 const ref = (0, import_react13.useRef)(null); 16692 const row = (0, import_react13.useContext)(CompositeRowContext); 16693 const disabled2 = disabledFromProps(props); 16694 const trulyDisabled = disabled2 && !props.accessibleWhenDisabled; 16695 const { 16696 rowId, 16697 baseElement, 16698 isActiveItem, 16699 ariaSetSize, 16700 ariaPosInSet, 16701 isTabbable 16702 } = useStoreStateObject(store, { 16703 rowId(state) { 16704 if (rowIdProp) return rowIdProp; 16705 if (!state) return; 16706 if (!(row == null ? void 0 : row.baseElement)) return; 16707 if (row.baseElement !== state.baseElement) return; 16708 return row.id; 16709 }, 16710 baseElement(state) { 16711 return (state == null ? void 0 : state.baseElement) || void 0; 16712 }, 16713 isActiveItem(state) { 16714 return !!state && state.activeId === id; 16715 }, 16716 ariaSetSize(state) { 16717 if (ariaSetSizeProp != null) return ariaSetSizeProp; 16718 if (!state) return; 16719 if (!(row == null ? void 0 : row.ariaSetSize)) return; 16720 if (row.baseElement !== state.baseElement) return; 16721 return row.ariaSetSize; 16722 }, 16723 ariaPosInSet(state) { 16724 if (ariaPosInSetProp != null) return ariaPosInSetProp; 16725 if (!state) return; 16726 if (!(row == null ? void 0 : row.ariaPosInSet)) return; 16727 if (row.baseElement !== state.baseElement) return; 16728 const itemsInRow = state.renderedItems.filter( 16729 (item) => item.rowId === rowId 16730 ); 16731 return row.ariaPosInSet + itemsInRow.findIndex((item) => item.id === id); 16732 }, 16733 isTabbable(state) { 16734 if (!(state == null ? void 0 : state.renderedItems.length)) return true; 16735 if (state.virtualFocus) return false; 16736 if (tabbable2) return true; 16737 if (state.activeId === null) return false; 16738 const item = store == null ? void 0 : store.item(state.activeId); 16739 if (item == null ? void 0 : item.disabled) return true; 16740 if (!(item == null ? void 0 : item.element)) return true; 16741 return state.activeId === id; 16742 } 16743 }); 16744 const getItem = (0, import_react13.useCallback)( 16745 (item) => { 16746 var _a; 16747 const nextItem = { 16748 ...item, 16749 id: id || item.id, 16750 rowId, 16751 disabled: !!trulyDisabled, 16752 children: (_a = item.element) == null ? void 0 : _a.textContent 16753 }; 16754 if (getItemProp) { 16755 return getItemProp(nextItem); 16756 } 16757 return nextItem; 16758 }, 16759 [id, rowId, trulyDisabled, getItemProp] 16760 ); 16761 const onFocusProp = props.onFocus; 16762 const hasFocusedComposite = (0, import_react13.useRef)(false); 16763 const onFocus = useEvent((event) => { 16764 onFocusProp == null ? void 0 : onFocusProp(event); 16765 if (event.defaultPrevented) return; 16766 if (isPortalEvent(event)) return; 16767 if (!id) return; 16768 if (!store) return; 16769 if (targetIsAnotherItem(event, store)) return; 16770 const { virtualFocus, baseElement: baseElement2 } = store.getState(); 16771 store.setActiveId(id); 16772 if (isTextbox(event.currentTarget)) { 16773 selectTextField(event.currentTarget); 16774 } 16775 if (!virtualFocus) return; 16776 if (!isSelfTarget(event)) return; 16777 if (isEditableElement(event.currentTarget)) return; 16778 if (!(baseElement2 == null ? void 0 : baseElement2.isConnected)) return; 16779 if (isSafari2() && event.currentTarget.hasAttribute("data-autofocus")) { 16780 event.currentTarget.scrollIntoView({ 16781 block: "nearest", 16782 inline: "nearest" 16783 }); 16784 } 16785 hasFocusedComposite.current = true; 16786 const fromComposite = event.relatedTarget === baseElement2 || isItem(store, event.relatedTarget); 16787 if (fromComposite) { 16788 focusSilently(baseElement2); 16789 } else { 16790 baseElement2.focus(); 16791 } 16792 }); 16793 const onBlurCaptureProp = props.onBlurCapture; 16794 const onBlurCapture = useEvent((event) => { 16795 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event); 16796 if (event.defaultPrevented) return; 16797 const state = store == null ? void 0 : store.getState(); 16798 if ((state == null ? void 0 : state.virtualFocus) && hasFocusedComposite.current) { 16799 hasFocusedComposite.current = false; 16800 event.preventDefault(); 16801 event.stopPropagation(); 16802 } 16803 }); 16804 const onKeyDownProp = props.onKeyDown; 16805 const preventScrollOnKeyDownProp = useBooleanEvent(preventScrollOnKeyDown); 16806 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress); 16807 const onKeyDown = useEvent((event) => { 16808 onKeyDownProp == null ? void 0 : onKeyDownProp(event); 16809 if (event.defaultPrevented) return; 16810 if (!isSelfTarget(event)) return; 16811 if (!store) return; 16812 const { currentTarget } = event; 16813 const state = store.getState(); 16814 const item = store.item(id); 16815 const isGrid2 = !!(item == null ? void 0 : item.rowId); 16816 const isVertical = state.orientation !== "horizontal"; 16817 const isHorizontal = state.orientation !== "vertical"; 16818 const canHomeEnd = () => { 16819 if (isGrid2) return true; 16820 if (isHorizontal) return true; 16821 if (!state.baseElement) return true; 16822 if (!isTextField(state.baseElement)) return true; 16823 return false; 16824 }; 16825 const keyMap = { 16826 ArrowUp: (isGrid2 || isVertical) && store.up, 16827 ArrowRight: (isGrid2 || isHorizontal) && store.next, 16828 ArrowDown: (isGrid2 || isVertical) && store.down, 16829 ArrowLeft: (isGrid2 || isHorizontal) && store.previous, 16830 Home: () => { 16831 if (!canHomeEnd()) return; 16832 if (!isGrid2 || event.ctrlKey) { 16833 return store == null ? void 0 : store.first(); 16834 } 16835 return store == null ? void 0 : store.previous(-1); 16836 }, 16837 End: () => { 16838 if (!canHomeEnd()) return; 16839 if (!isGrid2 || event.ctrlKey) { 16840 return store == null ? void 0 : store.last(); 16841 } 16842 return store == null ? void 0 : store.next(-1); 16843 }, 16844 PageUp: () => { 16845 return findNextPageItemId(currentTarget, store, store == null ? void 0 : store.up, true); 16846 }, 16847 PageDown: () => { 16848 return findNextPageItemId(currentTarget, store, store == null ? void 0 : store.down); 16849 } 16850 }; 16851 const action = keyMap[event.key]; 16852 if (action) { 16853 if (isTextbox(currentTarget)) { 16854 const selection = getTextboxSelection(currentTarget); 16855 const isLeft = isHorizontal && event.key === "ArrowLeft"; 16856 const isRight = isHorizontal && event.key === "ArrowRight"; 16857 const isUp = isVertical && event.key === "ArrowUp"; 16858 const isDown = isVertical && event.key === "ArrowDown"; 16859 if (isRight || isDown) { 16860 const { length: valueLength } = getTextboxValue(currentTarget); 16861 if (selection.end !== valueLength) return; 16862 } else if ((isLeft || isUp) && selection.start !== 0) return; 16863 } 16864 const nextId = action(); 16865 if (preventScrollOnKeyDownProp(event) || nextId !== void 0) { 16866 if (!moveOnKeyPressProp(event)) return; 16867 event.preventDefault(); 16868 store.move(nextId); 16869 } 16870 } 16871 }); 16872 const providerValue = (0, import_react13.useMemo)( 16873 () => ({ id, baseElement }), 16874 [id, baseElement] 16875 ); 16876 props = useWrapElement( 16877 props, 16878 (element) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(CompositeItemContext.Provider, { value: providerValue, children: element }), 16879 [providerValue] 16880 ); 16881 props = { 16882 id, 16883 "data-active-item": isActiveItem || void 0, 16884 ...props, 16885 ref: useMergeRefs(ref, props.ref), 16886 tabIndex: isTabbable ? props.tabIndex : -1, 16887 onFocus, 16888 onBlurCapture, 16889 onKeyDown 16890 }; 16891 props = useCommand(props); 16892 props = useCollectionItem({ 16893 store, 16894 ...props, 16895 getItem, 16896 shouldRegisterItem: id ? props.shouldRegisterItem : false 16897 }); 16898 return removeUndefinedValues({ 16899 ...props, 16900 "aria-setsize": ariaSetSize, 16901 "aria-posinset": ariaPosInSet 16902 }); 16903 } 16904 ); 16905 var CompositeItem = memo22( 16906 forwardRef22(function CompositeItem2(props) { 16907 const htmlProps = useCompositeItem(props); 16908 return createElement3(TagName4, htmlProps); 16909 }) 16910 ); 16911 16912 // node_modules/@ariakit/core/esm/__chunks/7PRQYBBV.js 16913 function toArray(arg) { 16914 if (Array.isArray(arg)) { 16915 return arg; 16916 } 16917 return typeof arg !== "undefined" ? [arg] : []; 16918 } 16919 function flatten2DArray(array) { 16920 const flattened = []; 16921 for (const row of array) { 16922 flattened.push(...row); 16923 } 16924 return flattened; 16925 } 16926 function reverseArray(array) { 16927 return array.slice().reverse(); 16928 } 16929 16930 // node_modules/@ariakit/react-core/esm/__chunks/ZMWF7ASR.js 16931 var import_react14 = __toESM(require_react(), 1); 16932 var import_jsx_runtime73 = __toESM(require_jsx_runtime(), 1); 16933 var TagName5 = "div"; 16934 function isGrid(items) { 16935 return items.some((item) => !!item.rowId); 16936 } 16937 function isPrintableKey(event) { 16938 const target = event.target; 16939 if (target && !isTextField(target)) return false; 16940 return event.key.length === 1 && !event.ctrlKey && !event.metaKey; 16941 } 16942 function isModifierKey(event) { 16943 return event.key === "Shift" || event.key === "Control" || event.key === "Alt" || event.key === "Meta"; 16944 } 16945 function useKeyboardEventProxy(store, onKeyboardEvent, previousElementRef) { 16946 return useEvent((event) => { 16947 var _a; 16948 onKeyboardEvent == null ? void 0 : onKeyboardEvent(event); 16949 if (event.defaultPrevented) return; 16950 if (event.isPropagationStopped()) return; 16951 if (!isSelfTarget(event)) return; 16952 if (isModifierKey(event)) return; 16953 if (isPrintableKey(event)) return; 16954 const state = store.getState(); 16955 const activeElement2 = (_a = getEnabledItem(store, state.activeId)) == null ? void 0 : _a.element; 16956 if (!activeElement2) return; 16957 const { view, ...eventInit } = event; 16958 const previousElement = previousElementRef == null ? void 0 : previousElementRef.current; 16959 if (activeElement2 !== previousElement) { 16960 activeElement2.focus(); 16961 } 16962 if (!fireKeyboardEvent(activeElement2, event.type, eventInit)) { 16963 event.preventDefault(); 16964 } 16965 if (event.currentTarget.contains(activeElement2)) { 16966 event.stopPropagation(); 16967 } 16968 }); 16969 } 16970 function findFirstEnabledItemInTheLastRow(items) { 16971 return findFirstEnabledItem( 16972 flatten2DArray(reverseArray(groupItemsByRows(items))) 16973 ); 16974 } 16975 function useScheduleFocus(store) { 16976 const [scheduled, setScheduled] = (0, import_react14.useState)(false); 16977 const schedule = (0, import_react14.useCallback)(() => setScheduled(true), []); 16978 const activeItem = store.useState( 16979 (state) => getEnabledItem(store, state.activeId) 16980 ); 16981 (0, import_react14.useEffect)(() => { 16982 const activeElement2 = activeItem == null ? void 0 : activeItem.element; 16983 if (!scheduled) return; 16984 if (!activeElement2) return; 16985 setScheduled(false); 16986 activeElement2.focus({ preventScroll: true }); 16987 }, [activeItem, scheduled]); 16988 return schedule; 16989 } 16990 var useComposite = createHook( 16991 function useComposite2({ 16992 store, 16993 composite = true, 16994 focusOnMove = composite, 16995 moveOnKeyPress = true, 16996 ...props 16997 }) { 16998 const context = useCompositeProviderContext(); 16999 store = store || context; 17000 invariant( 17001 store, 17002 "Composite must receive a `store` prop or be wrapped in a CompositeProvider component." 17003 ); 17004 const ref = (0, import_react14.useRef)(null); 17005 const previousElementRef = (0, import_react14.useRef)(null); 17006 const scheduleFocus = useScheduleFocus(store); 17007 const moves = store.useState("moves"); 17008 const [, setBaseElement] = useTransactionState( 17009 composite ? store.setBaseElement : null 17010 ); 17011 (0, import_react14.useEffect)(() => { 17012 var _a; 17013 if (!store) return; 17014 if (!moves) return; 17015 if (!composite) return; 17016 if (!focusOnMove) return; 17017 const { activeId: activeId2 } = store.getState(); 17018 const itemElement = (_a = getEnabledItem(store, activeId2)) == null ? void 0 : _a.element; 17019 if (!itemElement) return; 17020 focusIntoView(itemElement); 17021 }, [store, moves, composite, focusOnMove]); 17022 useSafeLayoutEffect(() => { 17023 if (!store) return; 17024 if (!moves) return; 17025 if (!composite) return; 17026 const { baseElement, activeId: activeId2 } = store.getState(); 17027 const isSelfAcive = activeId2 === null; 17028 if (!isSelfAcive) return; 17029 if (!baseElement) return; 17030 const previousElement = previousElementRef.current; 17031 previousElementRef.current = null; 17032 if (previousElement) { 17033 fireBlurEvent(previousElement, { relatedTarget: baseElement }); 17034 } 17035 if (!hasFocus(baseElement)) { 17036 baseElement.focus(); 17037 } 17038 }, [store, moves, composite]); 17039 const activeId = store.useState("activeId"); 17040 const virtualFocus = store.useState("virtualFocus"); 17041 useSafeLayoutEffect(() => { 17042 var _a; 17043 if (!store) return; 17044 if (!composite) return; 17045 if (!virtualFocus) return; 17046 const previousElement = previousElementRef.current; 17047 previousElementRef.current = null; 17048 if (!previousElement) return; 17049 const activeElement2 = (_a = getEnabledItem(store, activeId)) == null ? void 0 : _a.element; 17050 const relatedTarget = activeElement2 || getActiveElement(previousElement); 17051 if (relatedTarget === previousElement) return; 17052 fireBlurEvent(previousElement, { relatedTarget }); 17053 }, [store, activeId, virtualFocus, composite]); 17054 const onKeyDownCapture = useKeyboardEventProxy( 17055 store, 17056 props.onKeyDownCapture, 17057 previousElementRef 17058 ); 17059 const onKeyUpCapture = useKeyboardEventProxy( 17060 store, 17061 props.onKeyUpCapture, 17062 previousElementRef 17063 ); 17064 const onFocusCaptureProp = props.onFocusCapture; 17065 const onFocusCapture = useEvent((event) => { 17066 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event); 17067 if (event.defaultPrevented) return; 17068 if (!store) return; 17069 const { virtualFocus: virtualFocus2 } = store.getState(); 17070 if (!virtualFocus2) return; 17071 const previousActiveElement = event.relatedTarget; 17072 const isSilentlyFocused = silentlyFocused(event.currentTarget); 17073 if (isSelfTarget(event) && isSilentlyFocused) { 17074 event.stopPropagation(); 17075 previousElementRef.current = previousActiveElement; 17076 } 17077 }); 17078 const onFocusProp = props.onFocus; 17079 const onFocus = useEvent((event) => { 17080 onFocusProp == null ? void 0 : onFocusProp(event); 17081 if (event.defaultPrevented) return; 17082 if (!composite) return; 17083 if (!store) return; 17084 const { relatedTarget } = event; 17085 const { virtualFocus: virtualFocus2 } = store.getState(); 17086 if (virtualFocus2) { 17087 if (isSelfTarget(event) && !isItem(store, relatedTarget)) { 17088 queueMicrotask(scheduleFocus); 17089 } 17090 } else if (isSelfTarget(event)) { 17091 store.setActiveId(null); 17092 } 17093 }); 17094 const onBlurCaptureProp = props.onBlurCapture; 17095 const onBlurCapture = useEvent((event) => { 17096 var _a; 17097 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event); 17098 if (event.defaultPrevented) return; 17099 if (!store) return; 17100 const { virtualFocus: virtualFocus2, activeId: activeId2 } = store.getState(); 17101 if (!virtualFocus2) return; 17102 const activeElement2 = (_a = getEnabledItem(store, activeId2)) == null ? void 0 : _a.element; 17103 const nextActiveElement = event.relatedTarget; 17104 const nextActiveElementIsItem = isItem(store, nextActiveElement); 17105 const previousElement = previousElementRef.current; 17106 previousElementRef.current = null; 17107 if (isSelfTarget(event) && nextActiveElementIsItem) { 17108 if (nextActiveElement === activeElement2) { 17109 if (previousElement && previousElement !== nextActiveElement) { 17110 fireBlurEvent(previousElement, event); 17111 } 17112 } else if (activeElement2) { 17113 fireBlurEvent(activeElement2, event); 17114 } else if (previousElement) { 17115 fireBlurEvent(previousElement, event); 17116 } 17117 event.stopPropagation(); 17118 } else { 17119 const targetIsItem = isItem(store, event.target); 17120 if (!targetIsItem && activeElement2) { 17121 fireBlurEvent(activeElement2, event); 17122 } 17123 } 17124 }); 17125 const onKeyDownProp = props.onKeyDown; 17126 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress); 17127 const onKeyDown = useEvent((event) => { 17128 var _a; 17129 onKeyDownProp == null ? void 0 : onKeyDownProp(event); 17130 if (event.nativeEvent.isComposing) return; 17131 if (event.defaultPrevented) return; 17132 if (!store) return; 17133 if (!isSelfTarget(event)) return; 17134 const { orientation, renderedItems, activeId: activeId2 } = store.getState(); 17135 const activeItem = getEnabledItem(store, activeId2); 17136 if ((_a = activeItem == null ? void 0 : activeItem.element) == null ? void 0 : _a.isConnected) return; 17137 const isVertical = orientation !== "horizontal"; 17138 const isHorizontal = orientation !== "vertical"; 17139 const grid = isGrid(renderedItems); 17140 const isHorizontalKey = event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "Home" || event.key === "End"; 17141 if (isHorizontalKey && isTextField(event.currentTarget)) return; 17142 const up = () => { 17143 if (grid) { 17144 const item = findFirstEnabledItemInTheLastRow(renderedItems); 17145 return item == null ? void 0 : item.id; 17146 } 17147 return store == null ? void 0 : store.last(); 17148 }; 17149 const keyMap = { 17150 ArrowUp: (grid || isVertical) && up, 17151 ArrowRight: (grid || isHorizontal) && store.first, 17152 ArrowDown: (grid || isVertical) && store.first, 17153 ArrowLeft: (grid || isHorizontal) && store.last, 17154 Home: store.first, 17155 End: store.last, 17156 PageUp: store.first, 17157 PageDown: store.last 17158 }; 17159 const action = keyMap[event.key]; 17160 if (action) { 17161 const id = action(); 17162 if (id !== void 0) { 17163 if (!moveOnKeyPressProp(event)) return; 17164 event.preventDefault(); 17165 store.move(id); 17166 } 17167 } 17168 }); 17169 props = useWrapElement( 17170 props, 17171 (element) => /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(CompositeContextProvider, { value: store, children: element }), 17172 [store] 17173 ); 17174 const activeDescendant = store.useState((state) => { 17175 var _a; 17176 if (!store) return; 17177 if (!composite) return; 17178 if (!state.virtualFocus) return; 17179 return (_a = getEnabledItem(store, state.activeId)) == null ? void 0 : _a.id; 17180 }); 17181 props = { 17182 "aria-activedescendant": activeDescendant, 17183 ...props, 17184 ref: useMergeRefs(ref, setBaseElement, props.ref), 17185 onKeyDownCapture, 17186 onKeyUpCapture, 17187 onFocusCapture, 17188 onFocus, 17189 onBlurCapture, 17190 onKeyDown 17191 }; 17192 const focusable2 = store.useState( 17193 (state) => composite && (state.virtualFocus || state.activeId === null) 17194 ); 17195 props = useFocusable({ focusable: focusable2, ...props }); 17196 return props; 17197 } 17198 ); 17199 var Composite6 = forwardRef22(function Composite22(props) { 17200 const htmlProps = useComposite(props); 17201 return createElement3(TagName5, htmlProps); 17202 }); 17203 17204 // node_modules/@ariakit/react-core/esm/__chunks/LVDQFHCH.js 17205 var ctx3 = createStoreContext(); 17206 var useDisclosureContext = ctx3.useContext; 17207 var useDisclosureScopedContext = ctx3.useScopedContext; 17208 var useDisclosureProviderContext = ctx3.useProviderContext; 17209 var DisclosureContextProvider = ctx3.ContextProvider; 17210 var DisclosureScopedContextProvider = ctx3.ScopedContextProvider; 17211 17212 // node_modules/@ariakit/react-core/esm/__chunks/A62MDFCW.js 17213 var import_react15 = __toESM(require_react(), 1); 17214 var ctx4 = createStoreContext( 17215 [DisclosureContextProvider], 17216 [DisclosureScopedContextProvider] 17217 ); 17218 var useDialogContext = ctx4.useContext; 17219 var useDialogScopedContext = ctx4.useScopedContext; 17220 var useDialogProviderContext = ctx4.useProviderContext; 17221 var DialogContextProvider = ctx4.ContextProvider; 17222 var DialogScopedContextProvider = ctx4.ScopedContextProvider; 17223 var DialogHeadingContext = (0, import_react15.createContext)(void 0); 17224 var DialogDescriptionContext = (0, import_react15.createContext)(void 0); 17225 17226 // node_modules/@ariakit/react-core/esm/__chunks/6B3RXHKP.js 17227 var import_react16 = __toESM(require_react(), 1); 17228 var import_react_dom4 = __toESM(require_react_dom(), 1); 17229 var import_jsx_runtime74 = __toESM(require_jsx_runtime(), 1); 17230 var TagName6 = "div"; 17231 function afterTimeout(timeoutMs, cb) { 17232 const timeoutId = setTimeout(cb, timeoutMs); 17233 return () => clearTimeout(timeoutId); 17234 } 17235 function afterPaint2(cb) { 17236 let raf = requestAnimationFrame(() => { 17237 raf = requestAnimationFrame(cb); 17238 }); 17239 return () => cancelAnimationFrame(raf); 17240 } 17241 function parseCSSTime(...times) { 17242 return times.join(", ").split(", ").reduce((longestTime, currentTimeString) => { 17243 const multiplier = currentTimeString.endsWith("ms") ? 1 : 1e3; 17244 const currentTime = Number.parseFloat(currentTimeString || "0s") * multiplier; 17245 if (currentTime > longestTime) return currentTime; 17246 return longestTime; 17247 }, 0); 17248 } 17249 function isHidden(mounted, hidden, alwaysVisible) { 17250 return !alwaysVisible && hidden !== false && (!mounted || !!hidden); 17251 } 17252 var useDisclosureContent = createHook(function useDisclosureContent2({ store, alwaysVisible, ...props }) { 17253 const context = useDisclosureProviderContext(); 17254 store = store || context; 17255 invariant( 17256 store, 17257 "DisclosureContent must receive a `store` prop or be wrapped in a DisclosureProvider component." 17258 ); 17259 const ref = (0, import_react16.useRef)(null); 17260 const id = useId4(props.id); 17261 const [transition, setTransition] = (0, import_react16.useState)(null); 17262 const open = store.useState("open"); 17263 const mounted = store.useState("mounted"); 17264 const animated = store.useState("animated"); 17265 const contentElement = store.useState("contentElement"); 17266 const otherElement = useStoreState(store.disclosure, "contentElement"); 17267 useSafeLayoutEffect(() => { 17268 if (!ref.current) return; 17269 store == null ? void 0 : store.setContentElement(ref.current); 17270 }, [store]); 17271 useSafeLayoutEffect(() => { 17272 let previousAnimated; 17273 store == null ? void 0 : store.setState("animated", (animated2) => { 17274 previousAnimated = animated2; 17275 return true; 17276 }); 17277 return () => { 17278 if (previousAnimated === void 0) return; 17279 store == null ? void 0 : store.setState("animated", previousAnimated); 17280 }; 17281 }, [store]); 17282 useSafeLayoutEffect(() => { 17283 if (!animated) return; 17284 if (!(contentElement == null ? void 0 : contentElement.isConnected)) { 17285 setTransition(null); 17286 return; 17287 } 17288 return afterPaint2(() => { 17289 setTransition(open ? "enter" : mounted ? "leave" : null); 17290 }); 17291 }, [animated, contentElement, open, mounted]); 17292 useSafeLayoutEffect(() => { 17293 if (!store) return; 17294 if (!animated) return; 17295 if (!transition) return; 17296 if (!contentElement) return; 17297 const stopAnimation = () => store == null ? void 0 : store.setState("animating", false); 17298 const stopAnimationSync = () => (0, import_react_dom4.flushSync)(stopAnimation); 17299 if (transition === "leave" && open) return; 17300 if (transition === "enter" && !open) return; 17301 if (typeof animated === "number") { 17302 const timeout2 = animated; 17303 return afterTimeout(timeout2, stopAnimationSync); 17304 } 17305 const { 17306 transitionDuration, 17307 animationDuration, 17308 transitionDelay, 17309 animationDelay 17310 } = getComputedStyle(contentElement); 17311 const { 17312 transitionDuration: transitionDuration2 = "0", 17313 animationDuration: animationDuration2 = "0", 17314 transitionDelay: transitionDelay2 = "0", 17315 animationDelay: animationDelay2 = "0" 17316 } = otherElement ? getComputedStyle(otherElement) : {}; 17317 const delay = parseCSSTime( 17318 transitionDelay, 17319 animationDelay, 17320 transitionDelay2, 17321 animationDelay2 17322 ); 17323 const duration = parseCSSTime( 17324 transitionDuration, 17325 animationDuration, 17326 transitionDuration2, 17327 animationDuration2 17328 ); 17329 const timeout = delay + duration; 17330 if (!timeout) { 17331 if (transition === "enter") { 17332 store.setState("animated", false); 17333 } 17334 stopAnimation(); 17335 return; 17336 } 17337 const frameRate = 1e3 / 60; 17338 const maxTimeout = Math.max(timeout - frameRate, 0); 17339 return afterTimeout(maxTimeout, stopAnimationSync); 17340 }, [store, animated, contentElement, otherElement, open, transition]); 17341 props = useWrapElement( 17342 props, 17343 (element) => /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(DialogScopedContextProvider, { value: store, children: element }), 17344 [store] 17345 ); 17346 const hidden = isHidden(mounted, props.hidden, alwaysVisible); 17347 const styleProp = props.style; 17348 const style = (0, import_react16.useMemo)(() => { 17349 if (hidden) { 17350 return { ...styleProp, display: "none" }; 17351 } 17352 return styleProp; 17353 }, [hidden, styleProp]); 17354 props = { 17355 id, 17356 "data-open": open || void 0, 17357 "data-enter": transition === "enter" || void 0, 17358 "data-leave": transition === "leave" || void 0, 17359 hidden, 17360 ...props, 17361 ref: useMergeRefs(id ? store.setContentElement : null, ref, props.ref), 17362 style 17363 }; 17364 return removeUndefinedValues(props); 17365 }); 17366 var DisclosureContentImpl = forwardRef22(function DisclosureContentImpl2(props) { 17367 const htmlProps = useDisclosureContent(props); 17368 return createElement3(TagName6, htmlProps); 17369 }); 17370 var DisclosureContent = forwardRef22(function DisclosureContent2({ 17371 unmountOnHide, 17372 ...props 17373 }) { 17374 const context = useDisclosureProviderContext(); 17375 const store = props.store || context; 17376 const mounted = useStoreState( 17377 store, 17378 (state) => !unmountOnHide || (state == null ? void 0 : state.mounted) 17379 ); 17380 if (mounted === false) return null; 17381 return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(DisclosureContentImpl, { ...props }); 17382 }); 17383 17384 // node_modules/@ariakit/core/esm/__chunks/75BJEVSH.js 17385 function createDisclosureStore(props = {}) { 17386 const store = mergeStore( 17387 props.store, 17388 omit2(props.disclosure, ["contentElement", "disclosureElement"]) 17389 ); 17390 throwOnConflictingProps(props, store); 17391 const syncState = store == null ? void 0 : store.getState(); 17392 const open = defaultValue( 17393 props.open, 17394 syncState == null ? void 0 : syncState.open, 17395 props.defaultOpen, 17396 false 17397 ); 17398 const animated = defaultValue(props.animated, syncState == null ? void 0 : syncState.animated, false); 17399 const initialState = { 17400 open, 17401 animated, 17402 animating: !!animated && open, 17403 mounted: open, 17404 contentElement: defaultValue(syncState == null ? void 0 : syncState.contentElement, null), 17405 disclosureElement: defaultValue(syncState == null ? void 0 : syncState.disclosureElement, null) 17406 }; 17407 const disclosure = createStore(initialState, store); 17408 setup( 17409 disclosure, 17410 () => sync(disclosure, ["animated", "animating"], (state) => { 17411 if (state.animated) return; 17412 disclosure.setState("animating", false); 17413 }) 17414 ); 17415 setup( 17416 disclosure, 17417 () => subscribe(disclosure, ["open"], () => { 17418 if (!disclosure.getState().animated) return; 17419 disclosure.setState("animating", true); 17420 }) 17421 ); 17422 setup( 17423 disclosure, 17424 () => sync(disclosure, ["open", "animating"], (state) => { 17425 disclosure.setState("mounted", state.open || state.animating); 17426 }) 17427 ); 17428 return { 17429 ...disclosure, 17430 disclosure: props.disclosure, 17431 setOpen: (value) => disclosure.setState("open", value), 17432 show: () => disclosure.setState("open", true), 17433 hide: () => disclosure.setState("open", false), 17434 toggle: () => disclosure.setState("open", (open2) => !open2), 17435 stopAnimation: () => disclosure.setState("animating", false), 17436 setContentElement: (value) => disclosure.setState("contentElement", value), 17437 setDisclosureElement: (value) => disclosure.setState("disclosureElement", value) 17438 }; 17439 } 17440 17441 // node_modules/@ariakit/react-core/esm/__chunks/WLZ6H5FH.js 17442 function useDisclosureStoreProps(store, update2, props) { 17443 useUpdateEffect(update2, [props.store, props.disclosure]); 17444 useStoreProps(store, props, "open", "setOpen"); 17445 useStoreProps(store, props, "mounted", "setMounted"); 17446 useStoreProps(store, props, "animated"); 17447 return Object.assign(store, { disclosure: props.disclosure }); 17448 } 17449 17450 // node_modules/@ariakit/react-core/esm/__chunks/JMU4N4M5.js 17451 var ctx5 = createStoreContext( 17452 [DialogContextProvider], 17453 [DialogScopedContextProvider] 17454 ); 17455 var usePopoverContext = ctx5.useContext; 17456 var usePopoverScopedContext = ctx5.useScopedContext; 17457 var usePopoverProviderContext = ctx5.useProviderContext; 17458 var PopoverContextProvider = ctx5.ContextProvider; 17459 var PopoverScopedContextProvider = ctx5.ScopedContextProvider; 17460 17461 // node_modules/@ariakit/core/esm/__chunks/N5XGANPW.js 17462 function getCommonParent(items) { 17463 var _a; 17464 const firstItem = items.find((item) => !!item.element); 17465 const lastItem = [...items].reverse().find((item) => !!item.element); 17466 let parentElement = (_a = firstItem == null ? void 0 : firstItem.element) == null ? void 0 : _a.parentElement; 17467 while (parentElement && (lastItem == null ? void 0 : lastItem.element)) { 17468 const parent = parentElement; 17469 if (lastItem && parent.contains(lastItem.element)) { 17470 return parentElement; 17471 } 17472 parentElement = parentElement.parentElement; 17473 } 17474 return getDocument(parentElement).body; 17475 } 17476 function getPrivateStore(store) { 17477 return store == null ? void 0 : store.__unstablePrivateStore; 17478 } 17479 function createCollectionStore(props = {}) { 17480 var _a; 17481 throwOnConflictingProps(props, props.store); 17482 const syncState = (_a = props.store) == null ? void 0 : _a.getState(); 17483 const items = defaultValue( 17484 props.items, 17485 syncState == null ? void 0 : syncState.items, 17486 props.defaultItems, 17487 [] 17488 ); 17489 const itemsMap = new Map(items.map((item) => [item.id, item])); 17490 const initialState = { 17491 items, 17492 renderedItems: defaultValue(syncState == null ? void 0 : syncState.renderedItems, []) 17493 }; 17494 const syncPrivateStore = getPrivateStore(props.store); 17495 const privateStore = createStore( 17496 { items, renderedItems: initialState.renderedItems }, 17497 syncPrivateStore 17498 ); 17499 const collection = createStore(initialState, props.store); 17500 const sortItems = (renderedItems) => { 17501 const sortedItems = sortBasedOnDOMPosition(renderedItems, (i2) => i2.element); 17502 privateStore.setState("renderedItems", sortedItems); 17503 collection.setState("renderedItems", sortedItems); 17504 }; 17505 setup(collection, () => init(privateStore)); 17506 setup(privateStore, () => { 17507 return batch(privateStore, ["items"], (state) => { 17508 collection.setState("items", state.items); 17509 }); 17510 }); 17511 setup(privateStore, () => { 17512 return batch(privateStore, ["renderedItems"], (state) => { 17513 let firstRun = true; 17514 let raf = requestAnimationFrame(() => { 17515 const { renderedItems } = collection.getState(); 17516 if (state.renderedItems === renderedItems) return; 17517 sortItems(state.renderedItems); 17518 }); 17519 if (typeof IntersectionObserver !== "function") { 17520 return () => cancelAnimationFrame(raf); 17521 } 17522 const ioCallback = () => { 17523 if (firstRun) { 17524 firstRun = false; 17525 return; 17526 } 17527 cancelAnimationFrame(raf); 17528 raf = requestAnimationFrame(() => sortItems(state.renderedItems)); 17529 }; 17530 const root = getCommonParent(state.renderedItems); 17531 const observer = new IntersectionObserver(ioCallback, { root }); 17532 for (const item of state.renderedItems) { 17533 if (!item.element) continue; 17534 observer.observe(item.element); 17535 } 17536 return () => { 17537 cancelAnimationFrame(raf); 17538 observer.disconnect(); 17539 }; 17540 }); 17541 }); 17542 const mergeItem = (item, setItems, canDeleteFromMap = false) => { 17543 let prevItem; 17544 setItems((items2) => { 17545 const index2 = items2.findIndex(({ id }) => id === item.id); 17546 const nextItems = items2.slice(); 17547 if (index2 !== -1) { 17548 prevItem = items2[index2]; 17549 const nextItem = { ...prevItem, ...item }; 17550 nextItems[index2] = nextItem; 17551 itemsMap.set(item.id, nextItem); 17552 } else { 17553 nextItems.push(item); 17554 itemsMap.set(item.id, item); 17555 } 17556 return nextItems; 17557 }); 17558 const unmergeItem = () => { 17559 setItems((items2) => { 17560 if (!prevItem) { 17561 if (canDeleteFromMap) { 17562 itemsMap.delete(item.id); 17563 } 17564 return items2.filter(({ id }) => id !== item.id); 17565 } 17566 const index2 = items2.findIndex(({ id }) => id === item.id); 17567 if (index2 === -1) return items2; 17568 const nextItems = items2.slice(); 17569 nextItems[index2] = prevItem; 17570 itemsMap.set(item.id, prevItem); 17571 return nextItems; 17572 }); 17573 }; 17574 return unmergeItem; 17575 }; 17576 const registerItem = (item) => mergeItem( 17577 item, 17578 (getItems) => privateStore.setState("items", getItems), 17579 true 17580 ); 17581 return { 17582 ...collection, 17583 registerItem, 17584 renderItem: (item) => chain( 17585 registerItem(item), 17586 mergeItem( 17587 item, 17588 (getItems) => privateStore.setState("renderedItems", getItems) 17589 ) 17590 ), 17591 item: (id) => { 17592 if (!id) return null; 17593 let item = itemsMap.get(id); 17594 if (!item) { 17595 const { items: items2 } = privateStore.getState(); 17596 item = items2.find((item2) => item2.id === id); 17597 if (item) { 17598 itemsMap.set(id, item); 17599 } 17600 } 17601 return item || null; 17602 }, 17603 // @ts-expect-error Internal 17604 __unstablePrivateStore: privateStore 17605 }; 17606 } 17607 17608 // node_modules/@ariakit/react-core/esm/__chunks/GVAFFF2B.js 17609 function useCollectionStoreProps(store, update2, props) { 17610 useUpdateEffect(update2, [props.store]); 17611 useStoreProps(store, props, "items", "setItems"); 17612 return store; 17613 } 17614 17615 // node_modules/@ariakit/core/esm/__chunks/RVTIKFRL.js 17616 var NULL_ITEM = { id: null }; 17617 function findFirstEnabledItem2(items, excludeId) { 17618 return items.find((item) => { 17619 if (excludeId) { 17620 return !item.disabled && item.id !== excludeId; 17621 } 17622 return !item.disabled; 17623 }); 17624 } 17625 function getEnabledItems(items, excludeId) { 17626 return items.filter((item) => { 17627 if (excludeId) { 17628 return !item.disabled && item.id !== excludeId; 17629 } 17630 return !item.disabled; 17631 }); 17632 } 17633 function getItemsInRow(items, rowId) { 17634 return items.filter((item) => item.rowId === rowId); 17635 } 17636 function flipItems(items, activeId, shouldInsertNullItem = false) { 17637 const index2 = items.findIndex((item) => item.id === activeId); 17638 return [ 17639 ...items.slice(index2 + 1), 17640 ...shouldInsertNullItem ? [NULL_ITEM] : [], 17641 ...items.slice(0, index2) 17642 ]; 17643 } 17644 function groupItemsByRows2(items) { 17645 const rows = []; 17646 for (const item of items) { 17647 const row = rows.find((currentRow) => { 17648 var _a; 17649 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId; 17650 }); 17651 if (row) { 17652 row.push(item); 17653 } else { 17654 rows.push([item]); 17655 } 17656 } 17657 return rows; 17658 } 17659 function getMaxRowLength(array) { 17660 let maxLength = 0; 17661 for (const { length } of array) { 17662 if (length > maxLength) { 17663 maxLength = length; 17664 } 17665 } 17666 return maxLength; 17667 } 17668 function createEmptyItem(rowId) { 17669 return { 17670 id: "__EMPTY_ITEM__", 17671 disabled: true, 17672 rowId 17673 }; 17674 } 17675 function normalizeRows(rows, activeId, focusShift) { 17676 const maxLength = getMaxRowLength(rows); 17677 for (const row of rows) { 17678 for (let i2 = 0; i2 < maxLength; i2 += 1) { 17679 const item = row[i2]; 17680 if (!item || focusShift && item.disabled) { 17681 const isFirst = i2 === 0; 17682 const previousItem = isFirst && focusShift ? findFirstEnabledItem2(row) : row[i2 - 1]; 17683 row[i2] = previousItem && activeId !== previousItem.id && focusShift ? previousItem : createEmptyItem(previousItem == null ? void 0 : previousItem.rowId); 17684 } 17685 } 17686 } 17687 return rows; 17688 } 17689 function verticalizeItems(items) { 17690 const rows = groupItemsByRows2(items); 17691 const maxLength = getMaxRowLength(rows); 17692 const verticalized = []; 17693 for (let i2 = 0; i2 < maxLength; i2 += 1) { 17694 for (const row of rows) { 17695 const item = row[i2]; 17696 if (item) { 17697 verticalized.push({ 17698 ...item, 17699 // If there's no rowId, it means that it's not a grid composite, but 17700 // a single row instead. So, instead of verticalizing it, that is, 17701 // assigning a different rowId based on the column index, we keep it 17702 // undefined so they will be part of the same row. This is useful 17703 // when using up/down on one-dimensional composites. 17704 rowId: item.rowId ? `$i2}` : void 0 17705 }); 17706 } 17707 } 17708 } 17709 return verticalized; 17710 } 17711 function createCompositeStore(props = {}) { 17712 var _a; 17713 const syncState = (_a = props.store) == null ? void 0 : _a.getState(); 17714 const collection = createCollectionStore(props); 17715 const activeId = defaultValue( 17716 props.activeId, 17717 syncState == null ? void 0 : syncState.activeId, 17718 props.defaultActiveId 17719 ); 17720 const initialState = { 17721 ...collection.getState(), 17722 id: defaultValue( 17723 props.id, 17724 syncState == null ? void 0 : syncState.id, 17725 `id-$Math.random().toString(36).slice(2, 8)}` 17726 ), 17727 activeId, 17728 baseElement: defaultValue(syncState == null ? void 0 : syncState.baseElement, null), 17729 includesBaseElement: defaultValue( 17730 props.includesBaseElement, 17731 syncState == null ? void 0 : syncState.includesBaseElement, 17732 activeId === null 17733 ), 17734 moves: defaultValue(syncState == null ? void 0 : syncState.moves, 0), 17735 orientation: defaultValue( 17736 props.orientation, 17737 syncState == null ? void 0 : syncState.orientation, 17738 "both" 17739 ), 17740 rtl: defaultValue(props.rtl, syncState == null ? void 0 : syncState.rtl, false), 17741 virtualFocus: defaultValue( 17742 props.virtualFocus, 17743 syncState == null ? void 0 : syncState.virtualFocus, 17744 false 17745 ), 17746 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, false), 17747 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, false), 17748 focusShift: defaultValue(props.focusShift, syncState == null ? void 0 : syncState.focusShift, false) 17749 }; 17750 const composite = createStore(initialState, collection, props.store); 17751 setup( 17752 composite, 17753 () => sync(composite, ["renderedItems", "activeId"], (state) => { 17754 composite.setState("activeId", (activeId2) => { 17755 var _a2; 17756 if (activeId2 !== void 0) return activeId2; 17757 return (_a2 = findFirstEnabledItem2(state.renderedItems)) == null ? void 0 : _a2.id; 17758 }); 17759 }) 17760 ); 17761 const getNextId = (direction = "next", options = {}) => { 17762 var _a2, _b; 17763 const defaultState = composite.getState(); 17764 const { 17765 skip = 0, 17766 activeId: activeId2 = defaultState.activeId, 17767 focusShift = defaultState.focusShift, 17768 focusLoop = defaultState.focusLoop, 17769 focusWrap = defaultState.focusWrap, 17770 includesBaseElement = defaultState.includesBaseElement, 17771 renderedItems = defaultState.renderedItems, 17772 rtl = defaultState.rtl 17773 } = options; 17774 const isVerticalDirection = direction === "up" || direction === "down"; 17775 const isNextDirection = direction === "next" || direction === "down"; 17776 const canReverse = isNextDirection ? rtl && !isVerticalDirection : !rtl || isVerticalDirection; 17777 const canShift = focusShift && !skip; 17778 let items = !isVerticalDirection ? renderedItems : flatten2DArray( 17779 normalizeRows(groupItemsByRows2(renderedItems), activeId2, canShift) 17780 ); 17781 items = canReverse ? reverseArray(items) : items; 17782 items = isVerticalDirection ? verticalizeItems(items) : items; 17783 if (activeId2 == null) { 17784 return (_a2 = findFirstEnabledItem2(items)) == null ? void 0 : _a2.id; 17785 } 17786 const activeItem = items.find((item) => item.id === activeId2); 17787 if (!activeItem) { 17788 return (_b = findFirstEnabledItem2(items)) == null ? void 0 : _b.id; 17789 } 17790 const isGrid2 = items.some((item) => item.rowId); 17791 const activeIndex = items.indexOf(activeItem); 17792 const nextItems = items.slice(activeIndex + 1); 17793 const nextItemsInRow = getItemsInRow(nextItems, activeItem.rowId); 17794 if (skip) { 17795 const nextEnabledItemsInRow = getEnabledItems(nextItemsInRow, activeId2); 17796 const nextItem2 = nextEnabledItemsInRow.slice(skip)[0] || // If we can't find an item, just return the last one. 17797 nextEnabledItemsInRow[nextEnabledItemsInRow.length - 1]; 17798 return nextItem2 == null ? void 0 : nextItem2.id; 17799 } 17800 const canLoop = focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical"); 17801 const canWrap = isGrid2 && focusWrap && (isVerticalDirection ? focusWrap !== "horizontal" : focusWrap !== "vertical"); 17802 const hasNullItem = isNextDirection ? (!isGrid2 || isVerticalDirection) && canLoop && includesBaseElement : isVerticalDirection ? includesBaseElement : false; 17803 if (canLoop) { 17804 const loopItems = canWrap && !hasNullItem ? items : getItemsInRow(items, activeItem.rowId); 17805 const sortedItems = flipItems(loopItems, activeId2, hasNullItem); 17806 const nextItem2 = findFirstEnabledItem2(sortedItems, activeId2); 17807 return nextItem2 == null ? void 0 : nextItem2.id; 17808 } 17809 if (canWrap) { 17810 const nextItem2 = findFirstEnabledItem2( 17811 // We can use nextItems, which contains all the next items, including 17812 // items from other rows, to wrap between rows. However, if there is a 17813 // null item (the composite container), we'll only use the next items in 17814 // the row. So moving next from the last item will focus on the 17815 // composite container. On grid composites, horizontal navigation never 17816 // focuses on the composite container, only vertical. 17817 hasNullItem ? nextItemsInRow : nextItems, 17818 activeId2 17819 ); 17820 const nextId = hasNullItem ? (nextItem2 == null ? void 0 : nextItem2.id) || null : nextItem2 == null ? void 0 : nextItem2.id; 17821 return nextId; 17822 } 17823 const nextItem = findFirstEnabledItem2(nextItemsInRow, activeId2); 17824 if (!nextItem && hasNullItem) { 17825 return null; 17826 } 17827 return nextItem == null ? void 0 : nextItem.id; 17828 }; 17829 return { 17830 ...collection, 17831 ...composite, 17832 setBaseElement: (element) => composite.setState("baseElement", element), 17833 setActiveId: (id) => composite.setState("activeId", id), 17834 move: (id) => { 17835 if (id === void 0) return; 17836 composite.setState("activeId", id); 17837 composite.setState("moves", (moves) => moves + 1); 17838 }, 17839 first: () => { 17840 var _a2; 17841 return (_a2 = findFirstEnabledItem2(composite.getState().renderedItems)) == null ? void 0 : _a2.id; 17842 }, 17843 last: () => { 17844 var _a2; 17845 return (_a2 = findFirstEnabledItem2(reverseArray(composite.getState().renderedItems))) == null ? void 0 : _a2.id; 17846 }, 17847 next: (options) => { 17848 if (options !== void 0 && typeof options === "number") { 17849 options = { skip: options }; 17850 } 17851 return getNextId("next", options); 17852 }, 17853 previous: (options) => { 17854 if (options !== void 0 && typeof options === "number") { 17855 options = { skip: options }; 17856 } 17857 return getNextId("previous", options); 17858 }, 17859 down: (options) => { 17860 if (options !== void 0 && typeof options === "number") { 17861 options = { skip: options }; 17862 } 17863 return getNextId("down", options); 17864 }, 17865 up: (options) => { 17866 if (options !== void 0 && typeof options === "number") { 17867 options = { skip: options }; 17868 } 17869 return getNextId("up", options); 17870 } 17871 }; 17872 } 17873 17874 // node_modules/@ariakit/react-core/esm/__chunks/IQYAUKXT.js 17875 function useCompositeStoreOptions(props) { 17876 const id = useId4(props.id); 17877 return { id, ...props }; 17878 } 17879 function useCompositeStoreProps(store, update2, props) { 17880 store = useCollectionStoreProps(store, update2, props); 17881 useStoreProps(store, props, "activeId", "setActiveId"); 17882 useStoreProps(store, props, "includesBaseElement"); 17883 useStoreProps(store, props, "virtualFocus"); 17884 useStoreProps(store, props, "orientation"); 17885 useStoreProps(store, props, "rtl"); 17886 useStoreProps(store, props, "focusLoop"); 17887 useStoreProps(store, props, "focusWrap"); 17888 useStoreProps(store, props, "focusShift"); 17889 return store; 17890 } 17891 17892 // node_modules/@ariakit/react-core/esm/__chunks/CVCFNOHX.js 17893 var import_react17 = __toESM(require_react(), 1); 17894 var ComboboxListRoleContext = (0, import_react17.createContext)( 17895 void 0 17896 ); 17897 var ctx6 = createStoreContext( 17898 [PopoverContextProvider, CompositeContextProvider], 17899 [PopoverScopedContextProvider, CompositeScopedContextProvider] 17900 ); 17901 var useComboboxContext = ctx6.useContext; 17902 var useComboboxScopedContext = ctx6.useScopedContext; 17903 var useComboboxProviderContext = ctx6.useProviderContext; 17904 var ComboboxContextProvider = ctx6.ContextProvider; 17905 var ComboboxScopedContextProvider = ctx6.ScopedContextProvider; 17906 var ComboboxItemValueContext = (0, import_react17.createContext)( 17907 void 0 17908 ); 17909 var ComboboxItemCheckedContext = (0, import_react17.createContext)(false); 17910 17911 // node_modules/@ariakit/core/esm/__chunks/KMAUV3TY.js 17912 function createDialogStore(props = {}) { 17913 return createDisclosureStore(props); 17914 } 17915 17916 // node_modules/@ariakit/react-core/esm/__chunks/4NYSH4UO.js 17917 function useDialogStoreProps(store, update2, props) { 17918 return useDisclosureStoreProps(store, update2, props); 17919 } 17920 17921 // node_modules/@ariakit/core/esm/__chunks/BFGNM53A.js 17922 function createPopoverStore({ 17923 popover: otherPopover, 17924 ...props 17925 } = {}) { 17926 const store = mergeStore( 17927 props.store, 17928 omit2(otherPopover, [ 17929 "arrowElement", 17930 "anchorElement", 17931 "contentElement", 17932 "popoverElement", 17933 "disclosureElement" 17934 ]) 17935 ); 17936 throwOnConflictingProps(props, store); 17937 const syncState = store == null ? void 0 : store.getState(); 17938 const dialog = createDialogStore({ ...props, store }); 17939 const placement = defaultValue( 17940 props.placement, 17941 syncState == null ? void 0 : syncState.placement, 17942 "bottom" 17943 ); 17944 const initialState = { 17945 ...dialog.getState(), 17946 placement, 17947 currentPlacement: placement, 17948 anchorElement: defaultValue(syncState == null ? void 0 : syncState.anchorElement, null), 17949 popoverElement: defaultValue(syncState == null ? void 0 : syncState.popoverElement, null), 17950 arrowElement: defaultValue(syncState == null ? void 0 : syncState.arrowElement, null), 17951 rendered: /* @__PURE__ */ Symbol("rendered") 17952 }; 17953 const popover = createStore(initialState, dialog, store); 17954 return { 17955 ...dialog, 17956 ...popover, 17957 setAnchorElement: (element) => popover.setState("anchorElement", element), 17958 setPopoverElement: (element) => popover.setState("popoverElement", element), 17959 setArrowElement: (element) => popover.setState("arrowElement", element), 17960 render: () => popover.setState("rendered", /* @__PURE__ */ Symbol("rendered")) 17961 }; 17962 } 17963 17964 // node_modules/@ariakit/react-core/esm/__chunks/B6FLPFJM.js 17965 function usePopoverStoreProps(store, update2, props) { 17966 useUpdateEffect(update2, [props.popover]); 17967 useStoreProps(store, props, "placement"); 17968 return useDialogStoreProps(store, update2, props); 17969 } 17970 17971 // node_modules/@ariakit/react-core/esm/__chunks/4POTBZ2J.js 17972 var TagName7 = "div"; 17973 var usePopoverAnchor = createHook( 17974 function usePopoverAnchor2({ store, ...props }) { 17975 const context = usePopoverProviderContext(); 17976 store = store || context; 17977 props = { 17978 ...props, 17979 ref: useMergeRefs(store == null ? void 0 : store.setAnchorElement, props.ref) 17980 }; 17981 return props; 17982 } 17983 ); 17984 var PopoverAnchor = forwardRef22(function PopoverAnchor2(props) { 17985 const htmlProps = usePopoverAnchor(props); 17986 return createElement3(TagName7, htmlProps); 17987 }); 17988 17989 // node_modules/@ariakit/react-core/esm/__chunks/X6LNAU2F.js 17990 var import_react18 = __toESM(require_react(), 1); 17991 var TagName8 = "div"; 17992 function getMouseDestination(event) { 17993 const relatedTarget = event.relatedTarget; 17994 if ((relatedTarget == null ? void 0 : relatedTarget.nodeType) === Node.ELEMENT_NODE) { 17995 return relatedTarget; 17996 } 17997 return null; 17998 } 17999 function hoveringInside(event) { 18000 const nextElement = getMouseDestination(event); 18001 if (!nextElement) return false; 18002 return contains2(event.currentTarget, nextElement); 18003 } 18004 var symbol2 = /* @__PURE__ */ Symbol("composite-hover"); 18005 function movingToAnotherItem(event) { 18006 let dest = getMouseDestination(event); 18007 if (!dest) return false; 18008 do { 18009 if (hasOwnProperty(dest, symbol2) && dest[symbol2]) return true; 18010 dest = dest.parentElement; 18011 } while (dest); 18012 return false; 18013 } 18014 var useCompositeHover = createHook( 18015 function useCompositeHover2({ 18016 store, 18017 focusOnHover = true, 18018 blurOnHoverEnd = !!focusOnHover, 18019 ...props 18020 }) { 18021 const context = useCompositeContext(); 18022 store = store || context; 18023 invariant( 18024 store, 18025 "CompositeHover must be wrapped in a Composite component." 18026 ); 18027 const isMouseMoving = useIsMouseMoving(); 18028 const onMouseMoveProp = props.onMouseMove; 18029 const focusOnHoverProp = useBooleanEvent(focusOnHover); 18030 const onMouseMove = useEvent((event) => { 18031 onMouseMoveProp == null ? void 0 : onMouseMoveProp(event); 18032 if (event.defaultPrevented) return; 18033 if (!isMouseMoving()) return; 18034 if (!focusOnHoverProp(event)) return; 18035 if (!hasFocusWithin(event.currentTarget)) { 18036 const baseElement = store == null ? void 0 : store.getState().baseElement; 18037 if (baseElement && !hasFocus(baseElement)) { 18038 baseElement.focus(); 18039 } 18040 } 18041 store == null ? void 0 : store.setActiveId(event.currentTarget.id); 18042 }); 18043 const onMouseLeaveProp = props.onMouseLeave; 18044 const blurOnHoverEndProp = useBooleanEvent(blurOnHoverEnd); 18045 const onMouseLeave = useEvent((event) => { 18046 var _a; 18047 onMouseLeaveProp == null ? void 0 : onMouseLeaveProp(event); 18048 if (event.defaultPrevented) return; 18049 if (!isMouseMoving()) return; 18050 if (hoveringInside(event)) return; 18051 if (movingToAnotherItem(event)) return; 18052 if (!focusOnHoverProp(event)) return; 18053 if (!blurOnHoverEndProp(event)) return; 18054 store == null ? void 0 : store.setActiveId(null); 18055 (_a = store == null ? void 0 : store.getState().baseElement) == null ? void 0 : _a.focus(); 18056 }); 18057 const ref = (0, import_react18.useCallback)((element) => { 18058 if (!element) return; 18059 element[symbol2] = true; 18060 }, []); 18061 props = { 18062 ...props, 18063 ref: useMergeRefs(ref, props.ref), 18064 onMouseMove, 18065 onMouseLeave 18066 }; 18067 return removeUndefinedValues(props); 18068 } 18069 ); 18070 var CompositeHover = memo22( 18071 forwardRef22(function CompositeHover2(props) { 18072 const htmlProps = useCompositeHover(props); 18073 return createElement3(TagName8, htmlProps); 18074 }) 18075 ); 18076 18077 // node_modules/@ariakit/react-core/esm/combobox/combobox.js 18078 var import_react19 = __toESM(require_react(), 1); 18079 var TagName9 = "input"; 18080 function isFirstItemAutoSelected(items, activeValue, autoSelect) { 18081 if (!autoSelect) return false; 18082 const firstItem = items.find((item) => !item.disabled && item.value); 18083 return (firstItem == null ? void 0 : firstItem.value) === activeValue; 18084 } 18085 function hasCompletionString(value, activeValue) { 18086 if (!activeValue) return false; 18087 if (value == null) return false; 18088 value = normalizeString(value); 18089 return activeValue.length > value.length && activeValue.toLowerCase().indexOf(value.toLowerCase()) === 0; 18090 } 18091 function isInputEvent(event) { 18092 return event.type === "input"; 18093 } 18094 function isAriaAutoCompleteValue(value) { 18095 return value === "inline" || value === "list" || value === "both" || value === "none"; 18096 } 18097 function getDefaultAutoSelectId(items) { 18098 const item = items.find((item2) => { 18099 var _a; 18100 if (item2.disabled) return false; 18101 return ((_a = item2.element) == null ? void 0 : _a.getAttribute("role")) !== "tab"; 18102 }); 18103 return item == null ? void 0 : item.id; 18104 } 18105 var useCombobox = createHook( 18106 function useCombobox2({ 18107 store, 18108 focusable: focusable2 = true, 18109 autoSelect: autoSelectProp = false, 18110 getAutoSelectId, 18111 setValueOnChange, 18112 showMinLength = 0, 18113 showOnChange, 18114 showOnMouseDown, 18115 showOnClick = showOnMouseDown, 18116 showOnKeyDown, 18117 showOnKeyPress = showOnKeyDown, 18118 blurActiveItemOnClick, 18119 setValueOnClick = true, 18120 moveOnKeyPress = true, 18121 autoComplete = "list", 18122 ...props 18123 }) { 18124 const context = useComboboxProviderContext(); 18125 store = store || context; 18126 invariant( 18127 store, 18128 "Combobox must receive a `store` prop or be wrapped in a ComboboxProvider component." 18129 ); 18130 const ref = (0, import_react19.useRef)(null); 18131 const [valueUpdated, forceValueUpdate] = useForceUpdate(); 18132 const canAutoSelectRef = (0, import_react19.useRef)(false); 18133 const composingRef = (0, import_react19.useRef)(false); 18134 const autoSelect = store.useState( 18135 (state) => state.virtualFocus && autoSelectProp 18136 ); 18137 const inline4 = autoComplete === "inline" || autoComplete === "both"; 18138 const [canInline, setCanInline] = (0, import_react19.useState)(inline4); 18139 useUpdateLayoutEffect(() => { 18140 if (!inline4) return; 18141 setCanInline(true); 18142 }, [inline4]); 18143 const storeValue = store.useState("value"); 18144 const prevSelectedValueRef = (0, import_react19.useRef)(void 0); 18145 (0, import_react19.useEffect)(() => { 18146 return sync(store, ["selectedValue", "activeId"], (_, prev) => { 18147 prevSelectedValueRef.current = prev.selectedValue; 18148 }); 18149 }, []); 18150 const inlineActiveValue = store.useState((state) => { 18151 var _a; 18152 if (!inline4) return; 18153 if (!canInline) return; 18154 if (state.activeValue && Array.isArray(state.selectedValue)) { 18155 if (state.selectedValue.includes(state.activeValue)) return; 18156 if ((_a = prevSelectedValueRef.current) == null ? void 0 : _a.includes(state.activeValue)) return; 18157 } 18158 return state.activeValue; 18159 }); 18160 const items = store.useState("renderedItems"); 18161 const open = store.useState("open"); 18162 const contentElement = store.useState("contentElement"); 18163 const value = (0, import_react19.useMemo)(() => { 18164 if (!inline4) return storeValue; 18165 if (!canInline) return storeValue; 18166 const firstItemAutoSelected = isFirstItemAutoSelected( 18167 items, 18168 inlineActiveValue, 18169 autoSelect 18170 ); 18171 if (firstItemAutoSelected) { 18172 if (hasCompletionString(storeValue, inlineActiveValue)) { 18173 const slice = (inlineActiveValue == null ? void 0 : inlineActiveValue.slice(storeValue.length)) || ""; 18174 return storeValue + slice; 18175 } 18176 return storeValue; 18177 } 18178 return inlineActiveValue || storeValue; 18179 }, [inline4, canInline, items, inlineActiveValue, autoSelect, storeValue]); 18180 (0, import_react19.useEffect)(() => { 18181 const element = ref.current; 18182 if (!element) return; 18183 const onCompositeItemMove = () => setCanInline(true); 18184 element.addEventListener("combobox-item-move", onCompositeItemMove); 18185 return () => { 18186 element.removeEventListener("combobox-item-move", onCompositeItemMove); 18187 }; 18188 }, []); 18189 (0, import_react19.useEffect)(() => { 18190 if (!inline4) return; 18191 if (!canInline) return; 18192 if (!inlineActiveValue) return; 18193 const firstItemAutoSelected = isFirstItemAutoSelected( 18194 items, 18195 inlineActiveValue, 18196 autoSelect 18197 ); 18198 if (!firstItemAutoSelected) return; 18199 if (!hasCompletionString(storeValue, inlineActiveValue)) return; 18200 let cleanup = noop5; 18201 queueMicrotask(() => { 18202 const element = ref.current; 18203 if (!element) return; 18204 const { start: prevStart, end: prevEnd } = getTextboxSelection(element); 18205 const nextStart = storeValue.length; 18206 const nextEnd = inlineActiveValue.length; 18207 setSelectionRange(element, nextStart, nextEnd); 18208 cleanup = () => { 18209 if (!hasFocus(element)) return; 18210 const { start, end } = getTextboxSelection(element); 18211 if (start !== nextStart) return; 18212 if (end !== nextEnd) return; 18213 setSelectionRange(element, prevStart, prevEnd); 18214 }; 18215 }); 18216 return () => cleanup(); 18217 }, [ 18218 valueUpdated, 18219 inline4, 18220 canInline, 18221 inlineActiveValue, 18222 items, 18223 autoSelect, 18224 storeValue 18225 ]); 18226 const scrollingElementRef = (0, import_react19.useRef)(null); 18227 const getAutoSelectIdProp = useEvent(getAutoSelectId); 18228 const autoSelectIdRef = (0, import_react19.useRef)(null); 18229 (0, import_react19.useEffect)(() => { 18230 if (!open) return; 18231 if (!contentElement) return; 18232 const scrollingElement = getScrollingElement(contentElement); 18233 if (!scrollingElement) return; 18234 scrollingElementRef.current = scrollingElement; 18235 const onUserScroll = () => { 18236 canAutoSelectRef.current = false; 18237 }; 18238 const onScroll = () => { 18239 if (!store) return; 18240 if (!canAutoSelectRef.current) return; 18241 const { activeId } = store.getState(); 18242 if (activeId === null) return; 18243 if (activeId === autoSelectIdRef.current) return; 18244 canAutoSelectRef.current = false; 18245 }; 18246 const options = { passive: true, capture: true }; 18247 scrollingElement.addEventListener("wheel", onUserScroll, options); 18248 scrollingElement.addEventListener("touchmove", onUserScroll, options); 18249 scrollingElement.addEventListener("scroll", onScroll, options); 18250 return () => { 18251 scrollingElement.removeEventListener("wheel", onUserScroll, true); 18252 scrollingElement.removeEventListener("touchmove", onUserScroll, true); 18253 scrollingElement.removeEventListener("scroll", onScroll, true); 18254 }; 18255 }, [open, contentElement, store]); 18256 useSafeLayoutEffect(() => { 18257 if (!storeValue) return; 18258 if (composingRef.current) return; 18259 canAutoSelectRef.current = true; 18260 }, [storeValue]); 18261 useSafeLayoutEffect(() => { 18262 if (autoSelect !== "always" && open) return; 18263 canAutoSelectRef.current = open; 18264 }, [autoSelect, open]); 18265 const resetValueOnSelect = store.useState("resetValueOnSelect"); 18266 useUpdateEffect(() => { 18267 var _a, _b; 18268 const canAutoSelect = canAutoSelectRef.current; 18269 if (!store) return; 18270 if (!open) return; 18271 if (!canAutoSelect && !resetValueOnSelect) return; 18272 const { baseElement, contentElement: contentElement2, activeId } = store.getState(); 18273 if (baseElement && !hasFocus(baseElement)) return; 18274 if (contentElement2 == null ? void 0 : contentElement2.hasAttribute("data-placing")) { 18275 const observer = new MutationObserver(forceValueUpdate); 18276 observer.observe(contentElement2, { attributeFilter: ["data-placing"] }); 18277 return () => observer.disconnect(); 18278 } 18279 if (autoSelect && canAutoSelect) { 18280 const userAutoSelectId = getAutoSelectIdProp(items); 18281 const autoSelectId = userAutoSelectId !== void 0 ? userAutoSelectId : (_a = getDefaultAutoSelectId(items)) != null ? _a : store.first(); 18282 autoSelectIdRef.current = autoSelectId; 18283 store.move(autoSelectId != null ? autoSelectId : null); 18284 } else { 18285 const element = (_b = store.item(activeId || store.first())) == null ? void 0 : _b.element; 18286 if (element && "scrollIntoView" in element) { 18287 element.scrollIntoView({ block: "nearest", inline: "nearest" }); 18288 } 18289 } 18290 return; 18291 }, [ 18292 store, 18293 open, 18294 valueUpdated, 18295 storeValue, 18296 autoSelect, 18297 resetValueOnSelect, 18298 getAutoSelectIdProp, 18299 items 18300 ]); 18301 (0, import_react19.useEffect)(() => { 18302 if (!inline4) return; 18303 const combobox = ref.current; 18304 if (!combobox) return; 18305 const elements = [combobox, contentElement].filter( 18306 (value2) => !!value2 18307 ); 18308 const onBlur2 = (event) => { 18309 if (elements.every((el) => isFocusEventOutside(event, el))) { 18310 store == null ? void 0 : store.setValue(value); 18311 } 18312 }; 18313 for (const element of elements) { 18314 element.addEventListener("focusout", onBlur2); 18315 } 18316 return () => { 18317 for (const element of elements) { 18318 element.removeEventListener("focusout", onBlur2); 18319 } 18320 }; 18321 }, [inline4, contentElement, store, value]); 18322 const canShow = (event) => { 18323 const currentTarget = event.currentTarget; 18324 return currentTarget.value.length >= showMinLength; 18325 }; 18326 const onChangeProp = props.onChange; 18327 const showOnChangeProp = useBooleanEvent(showOnChange != null ? showOnChange : canShow); 18328 const setValueOnChangeProp = useBooleanEvent( 18329 // If the combobox is combined with tags, the value will be set by the tag 18330 // input component. 18331 setValueOnChange != null ? setValueOnChange : !store.tag 18332 ); 18333 const onChange = useEvent((event) => { 18334 onChangeProp == null ? void 0 : onChangeProp(event); 18335 if (event.defaultPrevented) return; 18336 if (!store) return; 18337 const currentTarget = event.currentTarget; 18338 const { value: value2, selectionStart, selectionEnd } = currentTarget; 18339 const nativeEvent = event.nativeEvent; 18340 canAutoSelectRef.current = true; 18341 if (isInputEvent(nativeEvent)) { 18342 if (nativeEvent.isComposing) { 18343 canAutoSelectRef.current = false; 18344 composingRef.current = true; 18345 } 18346 if (inline4) { 18347 const textInserted = nativeEvent.inputType === "insertText" || nativeEvent.inputType === "insertCompositionText"; 18348 const caretAtEnd = selectionStart === value2.length; 18349 setCanInline(textInserted && caretAtEnd); 18350 } 18351 } 18352 if (setValueOnChangeProp(event)) { 18353 const isSameValue = value2 === store.getState().value; 18354 store.setValue(value2); 18355 queueMicrotask(() => { 18356 setSelectionRange(currentTarget, selectionStart, selectionEnd); 18357 }); 18358 if (inline4 && autoSelect && isSameValue) { 18359 forceValueUpdate(); 18360 } 18361 } 18362 if (showOnChangeProp(event)) { 18363 store.show(); 18364 } 18365 if (!autoSelect || !canAutoSelectRef.current) { 18366 store.setActiveId(null); 18367 } 18368 }); 18369 const onCompositionEndProp = props.onCompositionEnd; 18370 const onCompositionEnd = useEvent((event) => { 18371 canAutoSelectRef.current = true; 18372 composingRef.current = false; 18373 onCompositionEndProp == null ? void 0 : onCompositionEndProp(event); 18374 if (event.defaultPrevented) return; 18375 if (!autoSelect) return; 18376 forceValueUpdate(); 18377 }); 18378 const onMouseDownProp = props.onMouseDown; 18379 const blurActiveItemOnClickProp = useBooleanEvent( 18380 blurActiveItemOnClick != null ? blurActiveItemOnClick : (() => !!(store == null ? void 0 : store.getState().includesBaseElement)) 18381 ); 18382 const setValueOnClickProp = useBooleanEvent(setValueOnClick); 18383 const showOnClickProp = useBooleanEvent(showOnClick != null ? showOnClick : canShow); 18384 const onMouseDown = useEvent((event) => { 18385 onMouseDownProp == null ? void 0 : onMouseDownProp(event); 18386 if (event.defaultPrevented) return; 18387 if (event.button) return; 18388 if (event.ctrlKey) return; 18389 if (!store) return; 18390 if (blurActiveItemOnClickProp(event)) { 18391 store.setActiveId(null); 18392 } 18393 if (setValueOnClickProp(event)) { 18394 store.setValue(value); 18395 } 18396 if (showOnClickProp(event)) { 18397 queueBeforeEvent(event.currentTarget, "mouseup", store.show); 18398 } 18399 }); 18400 const onKeyDownProp = props.onKeyDown; 18401 const showOnKeyPressProp = useBooleanEvent(showOnKeyPress != null ? showOnKeyPress : canShow); 18402 const onKeyDown = useEvent((event) => { 18403 onKeyDownProp == null ? void 0 : onKeyDownProp(event); 18404 if (!event.repeat) { 18405 canAutoSelectRef.current = false; 18406 } 18407 if (event.defaultPrevented) return; 18408 if (event.ctrlKey) return; 18409 if (event.altKey) return; 18410 if (event.shiftKey) return; 18411 if (event.metaKey) return; 18412 if (!store) return; 18413 const { open: open2 } = store.getState(); 18414 if (open2) return; 18415 if (event.key === "ArrowUp" || event.key === "ArrowDown") { 18416 if (showOnKeyPressProp(event)) { 18417 event.preventDefault(); 18418 store.show(); 18419 } 18420 } 18421 }); 18422 const onBlurProp = props.onBlur; 18423 const onBlur = useEvent((event) => { 18424 canAutoSelectRef.current = false; 18425 onBlurProp == null ? void 0 : onBlurProp(event); 18426 if (event.defaultPrevented) return; 18427 }); 18428 const id = useId4(props.id); 18429 const ariaAutoComplete = isAriaAutoCompleteValue(autoComplete) ? autoComplete : void 0; 18430 const isActiveItem = store.useState((state) => state.activeId === null); 18431 props = { 18432 id, 18433 role: "combobox", 18434 "aria-autocomplete": ariaAutoComplete, 18435 "aria-haspopup": getPopupRole(contentElement, "listbox"), 18436 "aria-expanded": open, 18437 "aria-controls": contentElement == null ? void 0 : contentElement.id, 18438 "data-active-item": isActiveItem || void 0, 18439 value, 18440 ...props, 18441 ref: useMergeRefs(ref, props.ref), 18442 onChange, 18443 onCompositionEnd, 18444 onMouseDown, 18445 onKeyDown, 18446 onBlur 18447 }; 18448 props = useComposite({ 18449 store, 18450 focusable: focusable2, 18451 ...props, 18452 // Enable inline autocomplete when the user moves from the combobox input 18453 // to an item. 18454 moveOnKeyPress: (event) => { 18455 if (isFalsyBooleanCallback(moveOnKeyPress, event)) return false; 18456 if (inline4) setCanInline(true); 18457 return true; 18458 } 18459 }); 18460 props = usePopoverAnchor({ store, ...props }); 18461 return { autoComplete: "off", ...props }; 18462 } 18463 ); 18464 var Combobox = forwardRef22(function Combobox2(props) { 18465 const htmlProps = useCombobox(props); 18466 return createElement3(TagName9, htmlProps); 18467 }); 18468 18469 // node_modules/@ariakit/react-core/esm/__chunks/IBXZ2LQC.js 18470 var import_react20 = __toESM(require_react(), 1); 18471 var import_jsx_runtime75 = __toESM(require_jsx_runtime(), 1); 18472 var TagName10 = "div"; 18473 function isSelected(storeValue, itemValue) { 18474 if (itemValue == null) return; 18475 if (storeValue == null) return false; 18476 if (Array.isArray(storeValue)) { 18477 return storeValue.includes(itemValue); 18478 } 18479 return storeValue === itemValue; 18480 } 18481 function getItemRole(popupRole) { 18482 var _a; 18483 const itemRoleByPopupRole = { 18484 menu: "menuitem", 18485 listbox: "option", 18486 tree: "treeitem" 18487 }; 18488 const key = popupRole; 18489 return (_a = itemRoleByPopupRole[key]) != null ? _a : "option"; 18490 } 18491 var useComboboxItem = createHook( 18492 function useComboboxItem2({ 18493 store, 18494 value, 18495 hideOnClick, 18496 setValueOnClick, 18497 selectValueOnClick = true, 18498 resetValueOnSelect, 18499 focusOnHover = false, 18500 moveOnKeyPress = true, 18501 getItem: getItemProp, 18502 ...props 18503 }) { 18504 var _a; 18505 const context = useComboboxScopedContext(); 18506 store = store || context; 18507 invariant( 18508 store, 18509 "ComboboxItem must be wrapped in a ComboboxList or ComboboxPopover component." 18510 ); 18511 const { resetValueOnSelectState, multiSelectable, selected } = useStoreStateObject(store, { 18512 resetValueOnSelectState: "resetValueOnSelect", 18513 multiSelectable(state) { 18514 return Array.isArray(state.selectedValue); 18515 }, 18516 selected(state) { 18517 return isSelected(state.selectedValue, value); 18518 } 18519 }); 18520 const getItem = (0, import_react20.useCallback)( 18521 (item) => { 18522 const nextItem = { ...item, value }; 18523 if (getItemProp) { 18524 return getItemProp(nextItem); 18525 } 18526 return nextItem; 18527 }, 18528 [value, getItemProp] 18529 ); 18530 setValueOnClick = setValueOnClick != null ? setValueOnClick : !multiSelectable; 18531 hideOnClick = hideOnClick != null ? hideOnClick : value != null && !multiSelectable; 18532 const onClickProp = props.onClick; 18533 const setValueOnClickProp = useBooleanEvent(setValueOnClick); 18534 const selectValueOnClickProp = useBooleanEvent(selectValueOnClick); 18535 const resetValueOnSelectProp = useBooleanEvent( 18536 (_a = resetValueOnSelect != null ? resetValueOnSelect : resetValueOnSelectState) != null ? _a : multiSelectable 18537 ); 18538 const hideOnClickProp = useBooleanEvent(hideOnClick); 18539 const onClick = useEvent((event) => { 18540 onClickProp == null ? void 0 : onClickProp(event); 18541 if (event.defaultPrevented) return; 18542 if (isDownloading(event)) return; 18543 if (isOpeningInNewTab(event)) return; 18544 if (value != null) { 18545 if (selectValueOnClickProp(event)) { 18546 if (resetValueOnSelectProp(event)) { 18547 store == null ? void 0 : store.resetValue(); 18548 } 18549 store == null ? void 0 : store.setSelectedValue((prevValue) => { 18550 if (!Array.isArray(prevValue)) return value; 18551 if (prevValue.includes(value)) { 18552 return prevValue.filter((v2) => v2 !== value); 18553 } 18554 return [...prevValue, value]; 18555 }); 18556 } 18557 if (setValueOnClickProp(event)) { 18558 store == null ? void 0 : store.setValue(value); 18559 } 18560 } 18561 if (hideOnClickProp(event)) { 18562 store == null ? void 0 : store.hide(); 18563 } 18564 }); 18565 const onKeyDownProp = props.onKeyDown; 18566 const onKeyDown = useEvent((event) => { 18567 onKeyDownProp == null ? void 0 : onKeyDownProp(event); 18568 if (event.defaultPrevented) return; 18569 const baseElement = store == null ? void 0 : store.getState().baseElement; 18570 if (!baseElement) return; 18571 if (hasFocus(baseElement)) return; 18572 const printable = event.key.length === 1; 18573 if (printable || event.key === "Backspace" || event.key === "Delete") { 18574 queueMicrotask(() => baseElement.focus()); 18575 if (isTextField(baseElement)) { 18576 store == null ? void 0 : store.setValue(baseElement.value); 18577 } 18578 } 18579 }); 18580 if (multiSelectable && selected != null) { 18581 props = { 18582 "aria-selected": selected, 18583 ...props 18584 }; 18585 } 18586 props = useWrapElement( 18587 props, 18588 (element) => /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(ComboboxItemValueContext.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(ComboboxItemCheckedContext.Provider, { value: selected != null ? selected : false, children: element }) }), 18589 [value, selected] 18590 ); 18591 const popupRole = (0, import_react20.useContext)(ComboboxListRoleContext); 18592 props = { 18593 role: getItemRole(popupRole), 18594 children: value, 18595 ...props, 18596 onClick, 18597 onKeyDown 18598 }; 18599 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress); 18600 props = useCompositeItem({ 18601 store, 18602 ...props, 18603 getItem, 18604 // Dispatch a custom event on the combobox input when moving to an item 18605 // with the keyboard so the Combobox component can enable inline 18606 // autocompletion. 18607 moveOnKeyPress: (event) => { 18608 if (!moveOnKeyPressProp(event)) return false; 18609 const moveEvent = new Event("combobox-item-move"); 18610 const baseElement = store == null ? void 0 : store.getState().baseElement; 18611 baseElement == null ? void 0 : baseElement.dispatchEvent(moveEvent); 18612 return true; 18613 } 18614 }); 18615 props = useCompositeHover({ store, focusOnHover, ...props }); 18616 return props; 18617 } 18618 ); 18619 var ComboboxItem = memo22( 18620 forwardRef22(function ComboboxItem2(props) { 18621 const htmlProps = useComboboxItem(props); 18622 return createElement3(TagName10, htmlProps); 18623 }) 18624 ); 18625 18626 // node_modules/@ariakit/react-core/esm/combobox/combobox-item-value.js 18627 var import_react21 = __toESM(require_react(), 1); 18628 var import_jsx_runtime76 = __toESM(require_jsx_runtime(), 1); 18629 var TagName11 = "span"; 18630 function normalizeValue(value) { 18631 return normalizeString(value).toLowerCase(); 18632 } 18633 function getOffsets(string, values) { 18634 const offsets = []; 18635 for (const value of values) { 18636 let pos = 0; 18637 const length = value.length; 18638 while (string.indexOf(value, pos) !== -1) { 18639 const index2 = string.indexOf(value, pos); 18640 if (index2 !== -1) { 18641 offsets.push([index2, length]); 18642 } 18643 pos = index2 + 1; 18644 } 18645 } 18646 return offsets; 18647 } 18648 function filterOverlappingOffsets(offsets) { 18649 return offsets.filter(([offset4, length], i2, arr) => { 18650 return !arr.some( 18651 ([o2, l2], j2) => j2 !== i2 && o2 <= offset4 && o2 + l2 >= offset4 + length 18652 ); 18653 }); 18654 } 18655 function sortOffsets(offsets) { 18656 return offsets.sort(([a2], [b2]) => a2 - b2); 18657 } 18658 function splitValue(itemValue, userValue) { 18659 if (!itemValue) return itemValue; 18660 if (!userValue) return itemValue; 18661 const userValues = toArray(userValue).filter(Boolean).map(normalizeValue); 18662 const parts = []; 18663 const span = (value, autocomplete = false) => /* @__PURE__ */ (0, import_jsx_runtime76.jsx)( 18664 "span", 18665 { 18666 "data-autocomplete-value": autocomplete ? "" : void 0, 18667 "data-user-value": autocomplete ? void 0 : "", 18668 children: value 18669 }, 18670 parts.length 18671 ); 18672 const offsets = sortOffsets( 18673 filterOverlappingOffsets( 18674 // Convert userValues into a set to avoid duplicates 18675 getOffsets(normalizeValue(itemValue), new Set(userValues)) 18676 ) 18677 ); 18678 if (!offsets.length) { 18679 parts.push(span(itemValue, true)); 18680 return parts; 18681 } 18682 const [firstOffset] = offsets[0]; 18683 const values = [ 18684 itemValue.slice(0, firstOffset), 18685 ...offsets.flatMap(([offset4, length], i2) => { 18686 var _a; 18687 const value = itemValue.slice(offset4, offset4 + length); 18688 const nextOffset = (_a = offsets[i2 + 1]) == null ? void 0 : _a[0]; 18689 const nextValue = itemValue.slice(offset4 + length, nextOffset); 18690 return [value, nextValue]; 18691 }) 18692 ]; 18693 values.forEach((value, i2) => { 18694 if (!value) return; 18695 parts.push(span(value, i2 % 2 === 0)); 18696 }); 18697 return parts; 18698 } 18699 var useComboboxItemValue = createHook(function useComboboxItemValue2({ store, value, userValue, ...props }) { 18700 const context = useComboboxScopedContext(); 18701 store = store || context; 18702 const itemContext = (0, import_react21.useContext)(ComboboxItemValueContext); 18703 const itemValue = value != null ? value : itemContext; 18704 const inputValue = useStoreState(store, (state) => userValue != null ? userValue : state == null ? void 0 : state.value); 18705 const children = (0, import_react21.useMemo)(() => { 18706 if (!itemValue) return; 18707 if (!inputValue) return itemValue; 18708 return splitValue(itemValue, inputValue); 18709 }, [itemValue, inputValue]); 18710 props = { 18711 children, 18712 ...props 18713 }; 18714 return removeUndefinedValues(props); 18715 }); 18716 var ComboboxItemValue = forwardRef22(function ComboboxItemValue2(props) { 18717 const htmlProps = useComboboxItemValue(props); 18718 return createElement3(TagName11, htmlProps); 18719 }); 18720 18721 // node_modules/@ariakit/react-core/esm/combobox/combobox-label.js 18722 var TagName12 = "label"; 18723 var useComboboxLabel = createHook( 18724 function useComboboxLabel2({ store, ...props }) { 18725 const context = useComboboxProviderContext(); 18726 store = store || context; 18727 invariant( 18728 store, 18729 "ComboboxLabel must receive a `store` prop or be wrapped in a ComboboxProvider component." 18730 ); 18731 const comboboxId = store.useState((state) => { 18732 var _a; 18733 return (_a = state.baseElement) == null ? void 0 : _a.id; 18734 }); 18735 props = { 18736 htmlFor: comboboxId, 18737 ...props 18738 }; 18739 return removeUndefinedValues(props); 18740 } 18741 ); 18742 var ComboboxLabel = memo22( 18743 forwardRef22(function ComboboxLabel2(props) { 18744 const htmlProps = useComboboxLabel(props); 18745 return createElement3(TagName12, htmlProps); 18746 }) 18747 ); 18748 18749 // node_modules/@ariakit/react-core/esm/__chunks/2G6YEJT4.js 18750 var import_react22 = __toESM(require_react(), 1); 18751 var import_jsx_runtime77 = __toESM(require_jsx_runtime(), 1); 18752 var TagName13 = "div"; 18753 var useComboboxList = createHook( 18754 function useComboboxList2({ store, alwaysVisible, ...props }) { 18755 const scopedContext = useComboboxScopedContext(true); 18756 const context = useComboboxContext(); 18757 store = store || context; 18758 const scopedContextSameStore = !!store && store === scopedContext; 18759 invariant( 18760 store, 18761 "ComboboxList must receive a `store` prop or be wrapped in a ComboboxProvider component." 18762 ); 18763 const ref = (0, import_react22.useRef)(null); 18764 const id = useId4(props.id); 18765 const mounted = store.useState("mounted"); 18766 const hidden = isHidden(mounted, props.hidden, alwaysVisible); 18767 const style = hidden ? { ...props.style, display: "none" } : props.style; 18768 const multiSelectable = store.useState( 18769 (state) => Array.isArray(state.selectedValue) 18770 ); 18771 const role = useAttribute(ref, "role", props.role); 18772 const isCompositeRole = role === "listbox" || role === "tree" || role === "grid"; 18773 const ariaMultiSelectable = isCompositeRole ? multiSelectable || void 0 : void 0; 18774 const [hasListboxInside, setHasListboxInside] = (0, import_react22.useState)(false); 18775 const contentElement = store.useState("contentElement"); 18776 useSafeLayoutEffect(() => { 18777 if (!mounted) return; 18778 const element = ref.current; 18779 if (!element) return; 18780 if (contentElement !== element) return; 18781 const callback = () => { 18782 setHasListboxInside(!!element.querySelector("[role='listbox']")); 18783 }; 18784 const observer = new MutationObserver(callback); 18785 observer.observe(element, { 18786 subtree: true, 18787 childList: true, 18788 attributeFilter: ["role"] 18789 }); 18790 callback(); 18791 return () => observer.disconnect(); 18792 }, [mounted, contentElement]); 18793 if (!hasListboxInside) { 18794 props = { 18795 role: "listbox", 18796 "aria-multiselectable": ariaMultiSelectable, 18797 ...props 18798 }; 18799 } 18800 props = useWrapElement( 18801 props, 18802 (element) => /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(ComboboxScopedContextProvider, { value: store, children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(ComboboxListRoleContext.Provider, { value: role, children: element }) }), 18803 [store, role] 18804 ); 18805 const setContentElement = id && (!scopedContext || !scopedContextSameStore) ? store.setContentElement : null; 18806 props = { 18807 id, 18808 hidden, 18809 ...props, 18810 ref: useMergeRefs(setContentElement, ref, props.ref), 18811 style 18812 }; 18813 return removeUndefinedValues(props); 18814 } 18815 ); 18816 var ComboboxList = forwardRef22(function ComboboxList2(props) { 18817 const htmlProps = useComboboxList(props); 18818 return createElement3(TagName13, htmlProps); 18819 }); 18820 18821 // node_modules/@ariakit/react-core/esm/__chunks/XSIEPKGA.js 18822 var import_react23 = __toESM(require_react(), 1); 18823 var TagValueContext = (0, import_react23.createContext)(null); 18824 var TagRemoveIdContext = (0, import_react23.createContext)( 18825 null 18826 ); 18827 var ctx7 = createStoreContext( 18828 [CompositeContextProvider], 18829 [CompositeScopedContextProvider] 18830 ); 18831 var useTagContext = ctx7.useContext; 18832 var useTagScopedContext = ctx7.useScopedContext; 18833 var useTagProviderContext = ctx7.useProviderContext; 18834 var TagContextProvider = ctx7.ContextProvider; 18835 var TagScopedContextProvider = ctx7.ScopedContextProvider; 18836 18837 // node_modules/@ariakit/core/esm/combobox/combobox-store.js 18838 var isTouchSafari = isSafari2() && isTouchDevice(); 18839 function createComboboxStore({ 18840 tag, 18841 ...props 18842 } = {}) { 18843 const store = mergeStore(props.store, pick2(tag, ["value", "rtl"])); 18844 throwOnConflictingProps(props, store); 18845 const tagState = tag == null ? void 0 : tag.getState(); 18846 const syncState = store == null ? void 0 : store.getState(); 18847 const activeId = defaultValue( 18848 props.activeId, 18849 syncState == null ? void 0 : syncState.activeId, 18850 props.defaultActiveId, 18851 null 18852 ); 18853 const composite = createCompositeStore({ 18854 ...props, 18855 activeId, 18856 includesBaseElement: defaultValue( 18857 props.includesBaseElement, 18858 syncState == null ? void 0 : syncState.includesBaseElement, 18859 true 18860 ), 18861 orientation: defaultValue( 18862 props.orientation, 18863 syncState == null ? void 0 : syncState.orientation, 18864 "vertical" 18865 ), 18866 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, true), 18867 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, true), 18868 virtualFocus: defaultValue( 18869 props.virtualFocus, 18870 syncState == null ? void 0 : syncState.virtualFocus, 18871 true 18872 ) 18873 }); 18874 const popover = createPopoverStore({ 18875 ...props, 18876 placement: defaultValue( 18877 props.placement, 18878 syncState == null ? void 0 : syncState.placement, 18879 "bottom-start" 18880 ) 18881 }); 18882 const value = defaultValue( 18883 props.value, 18884 syncState == null ? void 0 : syncState.value, 18885 props.defaultValue, 18886 "" 18887 ); 18888 const selectedValue = defaultValue( 18889 props.selectedValue, 18890 syncState == null ? void 0 : syncState.selectedValue, 18891 tagState == null ? void 0 : tagState.values, 18892 props.defaultSelectedValue, 18893 "" 18894 ); 18895 const multiSelectable = Array.isArray(selectedValue); 18896 const initialState = { 18897 ...composite.getState(), 18898 ...popover.getState(), 18899 value, 18900 selectedValue, 18901 resetValueOnSelect: defaultValue( 18902 props.resetValueOnSelect, 18903 syncState == null ? void 0 : syncState.resetValueOnSelect, 18904 multiSelectable 18905 ), 18906 resetValueOnHide: defaultValue( 18907 props.resetValueOnHide, 18908 syncState == null ? void 0 : syncState.resetValueOnHide, 18909 multiSelectable && !tag 18910 ), 18911 activeValue: syncState == null ? void 0 : syncState.activeValue 18912 }; 18913 const combobox = createStore(initialState, composite, popover, store); 18914 if (isTouchSafari) { 18915 setup( 18916 combobox, 18917 () => sync(combobox, ["virtualFocus"], () => { 18918 combobox.setState("virtualFocus", false); 18919 }) 18920 ); 18921 } 18922 setup(combobox, () => { 18923 if (!tag) return; 18924 return chain( 18925 sync(combobox, ["selectedValue"], (state) => { 18926 if (!Array.isArray(state.selectedValue)) return; 18927 tag.setValues(state.selectedValue); 18928 }), 18929 sync(tag, ["values"], (state) => { 18930 combobox.setState("selectedValue", state.values); 18931 }) 18932 ); 18933 }); 18934 setup( 18935 combobox, 18936 () => sync(combobox, ["resetValueOnHide", "mounted"], (state) => { 18937 if (!state.resetValueOnHide) return; 18938 if (state.mounted) return; 18939 combobox.setState("value", value); 18940 }) 18941 ); 18942 setup( 18943 combobox, 18944 () => sync(combobox, ["open"], (state) => { 18945 if (state.open) return; 18946 combobox.setState("activeId", activeId); 18947 combobox.setState("moves", 0); 18948 }) 18949 ); 18950 setup( 18951 combobox, 18952 () => sync(combobox, ["moves", "activeId"], (state, prevState) => { 18953 if (state.moves === prevState.moves) { 18954 combobox.setState("activeValue", void 0); 18955 } 18956 }) 18957 ); 18958 setup( 18959 combobox, 18960 () => batch(combobox, ["moves", "renderedItems"], (state, prev) => { 18961 if (state.moves === prev.moves) return; 18962 const { activeId: activeId2 } = combobox.getState(); 18963 const activeItem = composite.item(activeId2); 18964 combobox.setState("activeValue", activeItem == null ? void 0 : activeItem.value); 18965 }) 18966 ); 18967 return { 18968 ...popover, 18969 ...composite, 18970 ...combobox, 18971 tag, 18972 setValue: (value2) => combobox.setState("value", value2), 18973 resetValue: () => combobox.setState("value", initialState.value), 18974 setSelectedValue: (selectedValue2) => combobox.setState("selectedValue", selectedValue2) 18975 }; 18976 } 18977 18978 // node_modules/@ariakit/react-core/esm/__chunks/SVN33SY6.js 18979 function useComboboxStoreOptions(props) { 18980 const tag = useTagContext(); 18981 props = { 18982 ...props, 18983 tag: props.tag !== void 0 ? props.tag : tag 18984 }; 18985 return useCompositeStoreOptions(props); 18986 } 18987 function useComboboxStoreProps(store, update2, props) { 18988 useUpdateEffect(update2, [props.tag]); 18989 useStoreProps(store, props, "value", "setValue"); 18990 useStoreProps(store, props, "selectedValue", "setSelectedValue"); 18991 useStoreProps(store, props, "resetValueOnHide"); 18992 useStoreProps(store, props, "resetValueOnSelect"); 18993 return Object.assign( 18994 useCompositeStoreProps( 18995 usePopoverStoreProps(store, update2, props), 18996 update2, 18997 props 18998 ), 18999 { tag: props.tag } 19000 ); 19001 } 19002 function useComboboxStore(props = {}) { 19003 props = useComboboxStoreOptions(props); 19004 const [store, update2] = useStore2(createComboboxStore, props); 19005 return useComboboxStoreProps(store, update2, props); 19006 } 19007 19008 // node_modules/@ariakit/react-core/esm/combobox/combobox-provider.js 19009 var import_jsx_runtime78 = __toESM(require_jsx_runtime(), 1); 19010 function ComboboxProvider(props = {}) { 19011 const store = useComboboxStore(props); 19012 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(ComboboxContextProvider, { value: store, children: props.children }); 19013 } 19014 19015 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs 19016 var import_remove_accents = __toESM(require_remove_accents(), 1); 19017 var import_compose8 = __toESM(require_compose(), 1); 19018 var import_i18n29 = __toESM(require_i18n(), 1); 19019 var import_element42 = __toESM(require_element(), 1); 19020 var import_components19 = __toESM(require_components(), 1); 19021 19022 // packages/dataviews/build-module/components/dataviews-filters/utils.mjs 19023 var EMPTY_ARRAY3 = []; 19024 var getCurrentValue = (filterDefinition, currentFilter) => { 19025 if (filterDefinition.singleSelection) { 19026 return currentFilter?.value; 19027 } 19028 if (Array.isArray(currentFilter?.value)) { 19029 return currentFilter.value; 19030 } 19031 if (!Array.isArray(currentFilter?.value) && !!currentFilter?.value) { 19032 return [currentFilter.value]; 19033 } 19034 return EMPTY_ARRAY3; 19035 }; 19036 19037 // packages/dataviews/build-module/hooks/use-elements.mjs 19038 var import_element41 = __toESM(require_element(), 1); 19039 var EMPTY_ARRAY4 = []; 19040 function useElements({ 19041 elements, 19042 getElements 19043 }) { 19044 const staticElements = Array.isArray(elements) && elements.length > 0 ? elements : EMPTY_ARRAY4; 19045 const [records, setRecords] = (0, import_element41.useState)(staticElements); 19046 const [isLoading, setIsLoading] = (0, import_element41.useState)(false); 19047 (0, import_element41.useEffect)(() => { 19048 if (!getElements) { 19049 setRecords(staticElements); 19050 return; 19051 } 19052 let cancelled = false; 19053 setIsLoading(true); 19054 getElements().then((fetchedElements) => { 19055 if (!cancelled) { 19056 const dynamicElements = Array.isArray(fetchedElements) && fetchedElements.length > 0 ? fetchedElements : staticElements; 19057 setRecords(dynamicElements); 19058 } 19059 }).catch(() => { 19060 if (!cancelled) { 19061 setRecords(staticElements); 19062 } 19063 }).finally(() => { 19064 if (!cancelled) { 19065 setIsLoading(false); 19066 } 19067 }); 19068 return () => { 19069 cancelled = true; 19070 }; 19071 }, [getElements, staticElements]); 19072 return { 19073 elements: records, 19074 isLoading 19075 }; 19076 } 19077 19078 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs 19079 var import_jsx_runtime79 = __toESM(require_jsx_runtime(), 1); 19080 function normalizeSearchInput(input = "") { 19081 return (0, import_remove_accents.default)(input.trim().toLowerCase()); 19082 } 19083 var getNewValue = (filterDefinition, currentFilter, value) => { 19084 if (filterDefinition.singleSelection) { 19085 return value; 19086 } 19087 if (Array.isArray(currentFilter?.value)) { 19088 return currentFilter.value.includes(value) ? currentFilter.value.filter((v2) => v2 !== value) : [...currentFilter.value, value]; 19089 } 19090 return [value]; 19091 }; 19092 function generateFilterElementCompositeItemId(prefix, filterElementValue) { 19093 return `$prefix}-$filterElementValue}`; 19094 } 19095 var MultiSelectionOption = ({ selected }) => { 19096 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)( 19097 "span", 19098 { 19099 className: clsx_default( 19100 "dataviews-filters__search-widget-listitem-multi-selection", 19101 { "is-selected": selected } 19102 ), 19103 children: selected && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(import_components19.Icon, { icon: check_default }) 19104 } 19105 ); 19106 }; 19107 var SingleSelectionOption = ({ selected }) => { 19108 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)( 19109 "span", 19110 { 19111 className: clsx_default( 19112 "dataviews-filters__search-widget-listitem-single-selection", 19113 { "is-selected": selected } 19114 ) 19115 } 19116 ); 19117 }; 19118 function ListBox({ view, filter, onChangeView }) { 19119 const baseId = (0, import_compose8.useInstanceId)(ListBox, "dataviews-filter-list-box"); 19120 const [activeCompositeId, setActiveCompositeId] = (0, import_element42.useState)( 19121 // When there are one or less operators, the first item is set as active 19122 // (by setting the initial `activeId` to `undefined`). 19123 // With 2 or more operators, the focus is moved on the operators control 19124 // (by setting the initial `activeId` to `null`), meaning that there won't 19125 // be an active item initially. Focus is then managed via the 19126 // `onFocusVisible` callback. 19127 filter.operators?.length === 1 ? void 0 : null 19128 ); 19129 const currentFilter = view.filters?.find( 19130 (f2) => f2.field === filter.field 19131 ); 19132 const currentValue = getCurrentValue(filter, currentFilter); 19133 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)( 19134 import_components19.Composite, 19135 { 19136 virtualFocus: true, 19137 focusLoop: true, 19138 activeId: activeCompositeId, 19139 setActiveId: setActiveCompositeId, 19140 role: "listbox", 19141 className: "dataviews-filters__search-widget-listbox", 19142 "aria-label": (0, import_i18n29.sprintf)( 19143 /* translators: List of items for a filter. 1: Filter name. e.g.: "List of: Author". */ 19144 (0, import_i18n29.__)("List of: %1$s"), 19145 filter.name 19146 ), 19147 onFocusVisible: () => { 19148 if (!activeCompositeId && filter.elements.length) { 19149 setActiveCompositeId( 19150 generateFilterElementCompositeItemId( 19151 baseId, 19152 filter.elements[0].value 19153 ) 19154 ); 19155 } 19156 }, 19157 render: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(import_components19.Composite.Typeahead, {}), 19158 children: filter.elements.map((element) => /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)( 19159 import_components19.Composite.Hover, 19160 { 19161 render: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)( 19162 import_components19.Composite.Item, 19163 { 19164 id: generateFilterElementCompositeItemId( 19165 baseId, 19166 element.value 19167 ), 19168 render: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)( 19169 "div", 19170 { 19171 "aria-label": element.label, 19172 role: "option", 19173 className: "dataviews-filters__search-widget-listitem" 19174 } 19175 ), 19176 onClick: () => { 19177 const newFilters = currentFilter ? [ 19178 ...(view.filters ?? []).map( 19179 (_filter) => { 19180 if (_filter.field === filter.field) { 19181 return { 19182 ..._filter, 19183 operator: currentFilter.operator || filter.operators[0], 19184 value: getNewValue( 19185 filter, 19186 currentFilter, 19187 element.value 19188 ) 19189 }; 19190 } 19191 return _filter; 19192 } 19193 ) 19194 ] : [ 19195 ...view.filters ?? [], 19196 { 19197 field: filter.field, 19198 operator: filter.operators[0], 19199 value: getNewValue( 19200 filter, 19201 currentFilter, 19202 element.value 19203 ) 19204 } 19205 ]; 19206 onChangeView({ 19207 ...view, 19208 page: 1, 19209 filters: newFilters 19210 }); 19211 } 19212 } 19213 ), 19214 children: [ 19215 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)( 19216 SingleSelectionOption, 19217 { 19218 selected: currentValue === element.value 19219 } 19220 ), 19221 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)( 19222 MultiSelectionOption, 19223 { 19224 selected: currentValue.includes(element.value) 19225 } 19226 ), 19227 /* @__PURE__ */ (0, import_jsx_runtime79.jsx)( 19228 "span", 19229 { 19230 className: "dataviews-filters__search-widget-listitem-value", 19231 title: element.label, 19232 children: element.label 19233 } 19234 ) 19235 ] 19236 }, 19237 element.value 19238 )) 19239 } 19240 ); 19241 } 19242 function ComboboxList22({ view, filter, onChangeView }) { 19243 const [searchValue, setSearchValue] = (0, import_element42.useState)(""); 19244 const deferredSearchValue = (0, import_element42.useDeferredValue)(searchValue); 19245 const currentFilter = view.filters?.find( 19246 (_filter) => _filter.field === filter.field 19247 ); 19248 const currentValue = getCurrentValue(filter, currentFilter); 19249 const matches = (0, import_element42.useMemo)(() => { 19250 const normalizedSearch = normalizeSearchInput(deferredSearchValue); 19251 return filter.elements.filter( 19252 (item) => normalizeSearchInput(item.label).includes(normalizedSearch) 19253 ); 19254 }, [filter.elements, deferredSearchValue]); 19255 return /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)( 19256 ComboboxProvider, 19257 { 19258 selectedValue: currentValue, 19259 setSelectedValue: (value) => { 19260 const newFilters = currentFilter ? [ 19261 ...(view.filters ?? []).map((_filter) => { 19262 if (_filter.field === filter.field) { 19263 return { 19264 ..._filter, 19265 operator: currentFilter.operator || filter.operators[0], 19266 value 19267 }; 19268 } 19269 return _filter; 19270 }) 19271 ] : [ 19272 ...view.filters ?? [], 19273 { 19274 field: filter.field, 19275 operator: filter.operators[0], 19276 value 19277 } 19278 ]; 19279 onChangeView({ 19280 ...view, 19281 page: 1, 19282 filters: newFilters 19283 }); 19284 }, 19285 setValue: setSearchValue, 19286 children: [ 19287 /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)("div", { className: "dataviews-filters__search-widget-filter-combobox__wrapper", children: [ 19288 /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(ComboboxLabel, {}), children: (0, import_i18n29.__)("Search items") }), 19289 /* @__PURE__ */ (0, import_jsx_runtime79.jsx)( 19290 Combobox, 19291 { 19292 autoSelect: "always", 19293 placeholder: (0, import_i18n29.__)("Search"), 19294 className: "dataviews-filters__search-widget-filter-combobox__input" 19295 } 19296 ), 19297 /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("div", { className: "dataviews-filters__search-widget-filter-combobox__icon", children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(import_components19.Icon, { icon: search_default }) }) 19298 ] }), 19299 /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)( 19300 ComboboxList, 19301 { 19302 className: "dataviews-filters__search-widget-filter-combobox-list", 19303 alwaysVisible: true, 19304 children: [ 19305 matches.map((element) => { 19306 return /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)( 19307 ComboboxItem, 19308 { 19309 resetValueOnSelect: false, 19310 value: element.value, 19311 className: "dataviews-filters__search-widget-listitem", 19312 hideOnClick: false, 19313 setValueOnClick: false, 19314 focusOnHover: true, 19315 children: [ 19316 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)( 19317 SingleSelectionOption, 19318 { 19319 selected: currentValue === element.value 19320 } 19321 ), 19322 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)( 19323 MultiSelectionOption, 19324 { 19325 selected: currentValue.includes( 19326 element.value 19327 ) 19328 } 19329 ), 19330 /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)( 19331 "span", 19332 { 19333 className: "dataviews-filters__search-widget-listitem-value", 19334 title: element.label, 19335 children: [ 19336 /* @__PURE__ */ (0, import_jsx_runtime79.jsx)( 19337 ComboboxItemValue, 19338 { 19339 className: "dataviews-filters__search-widget-filter-combobox-item-value", 19340 value: element.label 19341 } 19342 ), 19343 !!element.description && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("span", { className: "dataviews-filters__search-widget-listitem-description", children: element.description }) 19344 ] 19345 } 19346 ) 19347 ] 19348 }, 19349 element.value 19350 ); 19351 }), 19352 !matches.length && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("p", { children: (0, import_i18n29.__)("No results found") }) 19353 ] 19354 } 19355 ) 19356 ] 19357 } 19358 ); 19359 } 19360 function SearchWidget(props) { 19361 const { elements, isLoading } = useElements({ 19362 elements: props.filter.elements, 19363 getElements: props.filter.getElements 19364 }); 19365 if (isLoading) { 19366 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(import_components19.Spinner, {}) }); 19367 } 19368 if (elements.length === 0) { 19369 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: (0, import_i18n29.__)("No elements found") }); 19370 } 19371 const Widget = elements.length > 10 ? ComboboxList22 : ListBox; 19372 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(Widget, { ...props, filter: { ...props.filter, elements } }); 19373 } 19374 19375 // packages/dataviews/build-module/components/dataviews-filters/input-widget.mjs 19376 var import_es6 = __toESM(require_es6(), 1); 19377 var import_compose9 = __toESM(require_compose(), 1); 19378 var import_element43 = __toESM(require_element(), 1); 19379 var import_components20 = __toESM(require_components(), 1); 19380 var import_jsx_runtime80 = __toESM(require_jsx_runtime(), 1); 19381 function InputWidget({ 19382 filter, 19383 view, 19384 onChangeView, 19385 fields 19386 }) { 19387 const currentFilter = view.filters?.find( 19388 (f2) => f2.field === filter.field 19389 ); 19390 const currentValue = getCurrentValue(filter, currentFilter); 19391 const field = (0, import_element43.useMemo)(() => { 19392 const currentField = fields.find((f2) => f2.id === filter.field); 19393 if (currentField) { 19394 return { 19395 ...currentField, 19396 // Deactivate validation for filters. 19397 isValid: {}, 19398 // Filter controls are always enabled. 19399 isDisabled: () => false, 19400 // Filter controls are always visible. 19401 isVisible: () => true, 19402 // Configure getValue/setValue as if Item was a plain object. 19403 getValue: ({ item }) => item[currentField.id], 19404 setValue: ({ value }) => ({ 19405 [currentField.id]: value 19406 }) 19407 }; 19408 } 19409 return currentField; 19410 }, [fields, filter.field]); 19411 const data = (0, import_element43.useMemo)(() => { 19412 return (view.filters ?? []).reduce( 19413 (acc, activeFilter) => { 19414 acc[activeFilter.field] = activeFilter.value; 19415 return acc; 19416 }, 19417 {} 19418 ); 19419 }, [view.filters]); 19420 const handleChange = (0, import_compose9.useEvent)((updatedData) => { 19421 if (!field || !currentFilter) { 19422 return; 19423 } 19424 const nextValue = field.getValue({ item: updatedData }); 19425 if ((0, import_es6.default)(nextValue, currentValue)) { 19426 return; 19427 } 19428 onChangeView({ 19429 ...view, 19430 filters: (view.filters ?? []).map( 19431 (_filter) => _filter.field === filter.field ? { 19432 ..._filter, 19433 operator: currentFilter.operator || filter.operators[0], 19434 // Consider empty strings as undefined: 19435 // 19436 // - undefined as value means the filter is unset: the filter widget displays no value and the search returns all records 19437 // - empty string as value means "search empty string": returns only the records that have an empty string as value 19438 // 19439 // In practice, this means the filter will not be able to find an empty string as the value. 19440 value: nextValue === "" ? void 0 : nextValue 19441 } : _filter 19442 ) 19443 }); 19444 }); 19445 if (!field || !field.Edit || !currentFilter) { 19446 return null; 19447 } 19448 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)( 19449 import_components20.Flex, 19450 { 19451 className: "dataviews-filters__user-input-widget", 19452 gap: 2.5, 19453 direction: "column", 19454 children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)( 19455 field.Edit, 19456 { 19457 hideLabelFromVision: true, 19458 data, 19459 field, 19460 operator: currentFilter.operator, 19461 onChange: handleChange 19462 } 19463 ) 19464 } 19465 ); 19466 } 19467 19468 // node_modules/date-fns/constants.js 19469 var daysInYear = 365.2425; 19470 var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3; 19471 var minTime = -maxTime; 19472 var millisecondsInWeek = 6048e5; 19473 var millisecondsInDay = 864e5; 19474 var secondsInHour = 3600; 19475 var secondsInDay = secondsInHour * 24; 19476 var secondsInWeek = secondsInDay * 7; 19477 var secondsInYear = secondsInDay * daysInYear; 19478 var secondsInMonth = secondsInYear / 12; 19479 var secondsInQuarter = secondsInMonth * 3; 19480 var constructFromSymbol = /* @__PURE__ */ Symbol.for("constructDateFrom"); 19481 19482 // node_modules/date-fns/constructFrom.js 19483 function constructFrom(date, value) { 19484 if (typeof date === "function") return date(value); 19485 if (date && typeof date === "object" && constructFromSymbol in date) 19486 return date[constructFromSymbol](value); 19487 if (date instanceof Date) return new date.constructor(value); 19488 return new Date(value); 19489 } 19490 19491 // node_modules/date-fns/toDate.js 19492 function toDate(argument, context) { 19493 return constructFrom(context || argument, argument); 19494 } 19495 19496 // node_modules/date-fns/addDays.js 19497 function addDays(date, amount, options) { 19498 const _date = toDate(date, options?.in); 19499 if (isNaN(amount)) return constructFrom(options?.in || date, NaN); 19500 if (!amount) return _date; 19501 _date.setDate(_date.getDate() + amount); 19502 return _date; 19503 } 19504 19505 // node_modules/date-fns/addMonths.js 19506 function addMonths(date, amount, options) { 19507 const _date = toDate(date, options?.in); 19508 if (isNaN(amount)) return constructFrom(options?.in || date, NaN); 19509 if (!amount) { 19510 return _date; 19511 } 19512 const dayOfMonth = _date.getDate(); 19513 const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime()); 19514 endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0); 19515 const daysInMonth = endOfDesiredMonth.getDate(); 19516 if (dayOfMonth >= daysInMonth) { 19517 return endOfDesiredMonth; 19518 } else { 19519 _date.setFullYear( 19520 endOfDesiredMonth.getFullYear(), 19521 endOfDesiredMonth.getMonth(), 19522 dayOfMonth 19523 ); 19524 return _date; 19525 } 19526 } 19527 19528 // node_modules/date-fns/_lib/defaultOptions.js 19529 var defaultOptions = {}; 19530 function getDefaultOptions() { 19531 return defaultOptions; 19532 } 19533 19534 // node_modules/date-fns/startOfWeek.js 19535 function startOfWeek(date, options) { 19536 const defaultOptions2 = getDefaultOptions(); 19537 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0; 19538 const _date = toDate(date, options?.in); 19539 const day = _date.getDay(); 19540 const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn; 19541 _date.setDate(_date.getDate() - diff); 19542 _date.setHours(0, 0, 0, 0); 19543 return _date; 19544 } 19545 19546 // node_modules/date-fns/startOfISOWeek.js 19547 function startOfISOWeek(date, options) { 19548 return startOfWeek(date, { ...options, weekStartsOn: 1 }); 19549 } 19550 19551 // node_modules/date-fns/getISOWeekYear.js 19552 function getISOWeekYear(date, options) { 19553 const _date = toDate(date, options?.in); 19554 const year = _date.getFullYear(); 19555 const fourthOfJanuaryOfNextYear = constructFrom(_date, 0); 19556 fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4); 19557 fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0); 19558 const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear); 19559 const fourthOfJanuaryOfThisYear = constructFrom(_date, 0); 19560 fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4); 19561 fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0); 19562 const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear); 19563 if (_date.getTime() >= startOfNextYear.getTime()) { 19564 return year + 1; 19565 } else if (_date.getTime() >= startOfThisYear.getTime()) { 19566 return year; 19567 } else { 19568 return year - 1; 19569 } 19570 } 19571 19572 // node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js 19573 function getTimezoneOffsetInMilliseconds(date) { 19574 const _date = toDate(date); 19575 const utcDate = new Date( 19576 Date.UTC( 19577 _date.getFullYear(), 19578 _date.getMonth(), 19579 _date.getDate(), 19580 _date.getHours(), 19581 _date.getMinutes(), 19582 _date.getSeconds(), 19583 _date.getMilliseconds() 19584 ) 19585 ); 19586 utcDate.setUTCFullYear(_date.getFullYear()); 19587 return +date - +utcDate; 19588 } 19589 19590 // node_modules/date-fns/_lib/normalizeDates.js 19591 function normalizeDates(context, ...dates) { 19592 const normalize = constructFrom.bind( 19593 null, 19594 context || dates.find((date) => typeof date === "object") 19595 ); 19596 return dates.map(normalize); 19597 } 19598 19599 // node_modules/date-fns/startOfDay.js 19600 function startOfDay(date, options) { 19601 const _date = toDate(date, options?.in); 19602 _date.setHours(0, 0, 0, 0); 19603 return _date; 19604 } 19605 19606 // node_modules/date-fns/differenceInCalendarDays.js 19607 function differenceInCalendarDays(laterDate, earlierDate, options) { 19608 const [laterDate_, earlierDate_] = normalizeDates( 19609 options?.in, 19610 laterDate, 19611 earlierDate 19612 ); 19613 const laterStartOfDay = startOfDay(laterDate_); 19614 const earlierStartOfDay = startOfDay(earlierDate_); 19615 const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay); 19616 const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay); 19617 return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay); 19618 } 19619 19620 // node_modules/date-fns/startOfISOWeekYear.js 19621 function startOfISOWeekYear(date, options) { 19622 const year = getISOWeekYear(date, options); 19623 const fourthOfJanuary = constructFrom(options?.in || date, 0); 19624 fourthOfJanuary.setFullYear(year, 0, 4); 19625 fourthOfJanuary.setHours(0, 0, 0, 0); 19626 return startOfISOWeek(fourthOfJanuary); 19627 } 19628 19629 // node_modules/date-fns/addWeeks.js 19630 function addWeeks(date, amount, options) { 19631 return addDays(date, amount * 7, options); 19632 } 19633 19634 // node_modules/date-fns/addYears.js 19635 function addYears(date, amount, options) { 19636 return addMonths(date, amount * 12, options); 19637 } 19638 19639 // node_modules/date-fns/isDate.js 19640 function isDate(value) { 19641 return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]"; 19642 } 19643 19644 // node_modules/date-fns/isValid.js 19645 function isValid(date) { 19646 return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date))); 19647 } 19648 19649 // node_modules/date-fns/startOfMonth.js 19650 function startOfMonth(date, options) { 19651 const _date = toDate(date, options?.in); 19652 _date.setDate(1); 19653 _date.setHours(0, 0, 0, 0); 19654 return _date; 19655 } 19656 19657 // node_modules/date-fns/startOfYear.js 19658 function startOfYear(date, options) { 19659 const date_ = toDate(date, options?.in); 19660 date_.setFullYear(date_.getFullYear(), 0, 1); 19661 date_.setHours(0, 0, 0, 0); 19662 return date_; 19663 } 19664 19665 // node_modules/date-fns/locale/en-US/_lib/formatDistance.js 19666 var formatDistanceLocale = { 19667 lessThanXSeconds: { 19668 one: "less than a second", 19669 other: "less than {{count}} seconds" 19670 }, 19671 xSeconds: { 19672 one: "1 second", 19673 other: "{{count}} seconds" 19674 }, 19675 halfAMinute: "half a minute", 19676 lessThanXMinutes: { 19677 one: "less than a minute", 19678 other: "less than {{count}} minutes" 19679 }, 19680 xMinutes: { 19681 one: "1 minute", 19682 other: "{{count}} minutes" 19683 }, 19684 aboutXHours: { 19685 one: "about 1 hour", 19686 other: "about {{count}} hours" 19687 }, 19688 xHours: { 19689 one: "1 hour", 19690 other: "{{count}} hours" 19691 }, 19692 xDays: { 19693 one: "1 day", 19694 other: "{{count}} days" 19695 }, 19696 aboutXWeeks: { 19697 one: "about 1 week", 19698 other: "about {{count}} weeks" 19699 }, 19700 xWeeks: { 19701 one: "1 week", 19702 other: "{{count}} weeks" 19703 }, 19704 aboutXMonths: { 19705 one: "about 1 month", 19706 other: "about {{count}} months" 19707 }, 19708 xMonths: { 19709 one: "1 month", 19710 other: "{{count}} months" 19711 }, 19712 aboutXYears: { 19713 one: "about 1 year", 19714 other: "about {{count}} years" 19715 }, 19716 xYears: { 19717 one: "1 year", 19718 other: "{{count}} years" 19719 }, 19720 overXYears: { 19721 one: "over 1 year", 19722 other: "over {{count}} years" 19723 }, 19724 almostXYears: { 19725 one: "almost 1 year", 19726 other: "almost {{count}} years" 19727 } 19728 }; 19729 var formatDistance = (token, count, options) => { 19730 let result; 19731 const tokenValue = formatDistanceLocale[token]; 19732 if (typeof tokenValue === "string") { 19733 result = tokenValue; 19734 } else if (count === 1) { 19735 result = tokenValue.one; 19736 } else { 19737 result = tokenValue.other.replace("{{count}}", count.toString()); 19738 } 19739 if (options?.addSuffix) { 19740 if (options.comparison && options.comparison > 0) { 19741 return "in " + result; 19742 } else { 19743 return result + " ago"; 19744 } 19745 } 19746 return result; 19747 }; 19748 19749 // node_modules/date-fns/locale/_lib/buildFormatLongFn.js 19750 function buildFormatLongFn(args) { 19751 return (options = {}) => { 19752 const width = options.width ? String(options.width) : args.defaultWidth; 19753 const format6 = args.formats[width] || args.formats[args.defaultWidth]; 19754 return format6; 19755 }; 19756 } 19757 19758 // node_modules/date-fns/locale/en-US/_lib/formatLong.js 19759 var dateFormats = { 19760 full: "EEEE, MMMM do, y", 19761 long: "MMMM do, y", 19762 medium: "MMM d, y", 19763 short: "MM/dd/yyyy" 19764 }; 19765 var timeFormats = { 19766 full: "h:mm:ss a zzzz", 19767 long: "h:mm:ss a z", 19768 medium: "h:mm:ss a", 19769 short: "h:mm a" 19770 }; 19771 var dateTimeFormats = { 19772 full: "{{date}} 'at' {{time}}", 19773 long: "{{date}} 'at' {{time}}", 19774 medium: "{{date}}, {{time}}", 19775 short: "{{date}}, {{time}}" 19776 }; 19777 var formatLong = { 19778 date: buildFormatLongFn({ 19779 formats: dateFormats, 19780 defaultWidth: "full" 19781 }), 19782 time: buildFormatLongFn({ 19783 formats: timeFormats, 19784 defaultWidth: "full" 19785 }), 19786 dateTime: buildFormatLongFn({ 19787 formats: dateTimeFormats, 19788 defaultWidth: "full" 19789 }) 19790 }; 19791 19792 // node_modules/date-fns/locale/en-US/_lib/formatRelative.js 19793 var formatRelativeLocale = { 19794 lastWeek: "'last' eeee 'at' p", 19795 yesterday: "'yesterday at' p", 19796 today: "'today at' p", 19797 tomorrow: "'tomorrow at' p", 19798 nextWeek: "eeee 'at' p", 19799 other: "P" 19800 }; 19801 var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token]; 19802 19803 // node_modules/date-fns/locale/_lib/buildLocalizeFn.js 19804 function buildLocalizeFn(args) { 19805 return (value, options) => { 19806 const context = options?.context ? String(options.context) : "standalone"; 19807 let valuesArray; 19808 if (context === "formatting" && args.formattingValues) { 19809 const defaultWidth = args.defaultFormattingWidth || args.defaultWidth; 19810 const width = options?.width ? String(options.width) : defaultWidth; 19811 valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth]; 19812 } else { 19813 const defaultWidth = args.defaultWidth; 19814 const width = options?.width ? String(options.width) : args.defaultWidth; 19815 valuesArray = args.values[width] || args.values[defaultWidth]; 19816 } 19817 const index2 = args.argumentCallback ? args.argumentCallback(value) : value; 19818 return valuesArray[index2]; 19819 }; 19820 } 19821 19822 // node_modules/date-fns/locale/en-US/_lib/localize.js 19823 var eraValues = { 19824 narrow: ["B", "A"], 19825 abbreviated: ["BC", "AD"], 19826 wide: ["Before Christ", "Anno Domini"] 19827 }; 19828 var quarterValues = { 19829 narrow: ["1", "2", "3", "4"], 19830 abbreviated: ["Q1", "Q2", "Q3", "Q4"], 19831 wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"] 19832 }; 19833 var monthValues = { 19834 narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"], 19835 abbreviated: [ 19836 "Jan", 19837 "Feb", 19838 "Mar", 19839 "Apr", 19840 "May", 19841 "Jun", 19842 "Jul", 19843 "Aug", 19844 "Sep", 19845 "Oct", 19846 "Nov", 19847 "Dec" 19848 ], 19849 wide: [ 19850 "January", 19851 "February", 19852 "March", 19853 "April", 19854 "May", 19855 "June", 19856 "July", 19857 "August", 19858 "September", 19859 "October", 19860 "November", 19861 "December" 19862 ] 19863 }; 19864 var dayValues = { 19865 narrow: ["S", "M", "T", "W", "T", "F", "S"], 19866 short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], 19867 abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], 19868 wide: [ 19869 "Sunday", 19870 "Monday", 19871 "Tuesday", 19872 "Wednesday", 19873 "Thursday", 19874 "Friday", 19875 "Saturday" 19876 ] 19877 }; 19878 var dayPeriodValues = { 19879 narrow: { 19880 am: "a", 19881 pm: "p", 19882 midnight: "mi", 19883 noon: "n", 19884 morning: "morning", 19885 afternoon: "afternoon", 19886 evening: "evening", 19887 night: "night" 19888 }, 19889 abbreviated: { 19890 am: "AM", 19891 pm: "PM", 19892 midnight: "midnight", 19893 noon: "noon", 19894 morning: "morning", 19895 afternoon: "afternoon", 19896 evening: "evening", 19897 night: "night" 19898 }, 19899 wide: { 19900 am: "a.m.", 19901 pm: "p.m.", 19902 midnight: "midnight", 19903 noon: "noon", 19904 morning: "morning", 19905 afternoon: "afternoon", 19906 evening: "evening", 19907 night: "night" 19908 } 19909 }; 19910 var formattingDayPeriodValues = { 19911 narrow: { 19912 am: "a", 19913 pm: "p", 19914 midnight: "mi", 19915 noon: "n", 19916 morning: "in the morning", 19917 afternoon: "in the afternoon", 19918 evening: "in the evening", 19919 night: "at night" 19920 }, 19921 abbreviated: { 19922 am: "AM", 19923 pm: "PM", 19924 midnight: "midnight", 19925 noon: "noon", 19926 morning: "in the morning", 19927 afternoon: "in the afternoon", 19928 evening: "in the evening", 19929 night: "at night" 19930 }, 19931 wide: { 19932 am: "a.m.", 19933 pm: "p.m.", 19934 midnight: "midnight", 19935 noon: "noon", 19936 morning: "in the morning", 19937 afternoon: "in the afternoon", 19938 evening: "in the evening", 19939 night: "at night" 19940 } 19941 }; 19942 var ordinalNumber = (dirtyNumber, _options) => { 19943 const number = Number(dirtyNumber); 19944 const rem100 = number % 100; 19945 if (rem100 > 20 || rem100 < 10) { 19946 switch (rem100 % 10) { 19947 case 1: 19948 return number + "st"; 19949 case 2: 19950 return number + "nd"; 19951 case 3: 19952 return number + "rd"; 19953 } 19954 } 19955 return number + "th"; 19956 }; 19957 var localize = { 19958 ordinalNumber, 19959 era: buildLocalizeFn({ 19960 values: eraValues, 19961 defaultWidth: "wide" 19962 }), 19963 quarter: buildLocalizeFn({ 19964 values: quarterValues, 19965 defaultWidth: "wide", 19966 argumentCallback: (quarter) => quarter - 1 19967 }), 19968 month: buildLocalizeFn({ 19969 values: monthValues, 19970 defaultWidth: "wide" 19971 }), 19972 day: buildLocalizeFn({ 19973 values: dayValues, 19974 defaultWidth: "wide" 19975 }), 19976 dayPeriod: buildLocalizeFn({ 19977 values: dayPeriodValues, 19978 defaultWidth: "wide", 19979 formattingValues: formattingDayPeriodValues, 19980 defaultFormattingWidth: "wide" 19981 }) 19982 }; 19983 19984 // node_modules/date-fns/locale/_lib/buildMatchFn.js 19985 function buildMatchFn(args) { 19986 return (string, options = {}) => { 19987 const width = options.width; 19988 const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth]; 19989 const matchResult = string.match(matchPattern); 19990 if (!matchResult) { 19991 return null; 19992 } 19993 const matchedString = matchResult[0]; 19994 const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth]; 19995 const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : ( 19996 // [TODO] -- I challenge you to fix the type 19997 findKey(parsePatterns, (pattern) => pattern.test(matchedString)) 19998 ); 19999 let value; 20000 value = args.valueCallback ? args.valueCallback(key) : key; 20001 value = options.valueCallback ? ( 20002 // [TODO] -- I challenge you to fix the type 20003 options.valueCallback(value) 20004 ) : value; 20005 const rest = string.slice(matchedString.length); 20006 return { value, rest }; 20007 }; 20008 } 20009 function findKey(object, predicate) { 20010 for (const key in object) { 20011 if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) { 20012 return key; 20013 } 20014 } 20015 return void 0; 20016 } 20017 function findIndex(array, predicate) { 20018 for (let key = 0; key < array.length; key++) { 20019 if (predicate(array[key])) { 20020 return key; 20021 } 20022 } 20023 return void 0; 20024 } 20025 20026 // node_modules/date-fns/locale/_lib/buildMatchPatternFn.js 20027 function buildMatchPatternFn(args) { 20028 return (string, options = {}) => { 20029 const matchResult = string.match(args.matchPattern); 20030 if (!matchResult) return null; 20031 const matchedString = matchResult[0]; 20032 const parseResult = string.match(args.parsePattern); 20033 if (!parseResult) return null; 20034 let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0]; 20035 value = options.valueCallback ? options.valueCallback(value) : value; 20036 const rest = string.slice(matchedString.length); 20037 return { value, rest }; 20038 }; 20039 } 20040 20041 // node_modules/date-fns/locale/en-US/_lib/match.js 20042 var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i; 20043 var parseOrdinalNumberPattern = /\d+/i; 20044 var matchEraPatterns = { 20045 narrow: /^(b|a)/i, 20046 abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i, 20047 wide: /^(before christ|before common era|anno domini|common era)/i 20048 }; 20049 var parseEraPatterns = { 20050 any: [/^b/i, /^(a|c)/i] 20051 }; 20052 var matchQuarterPatterns = { 20053 narrow: /^[1234]/i, 20054 abbreviated: /^q[1234]/i, 20055 wide: /^[1234](th|st|nd|rd)? quarter/i 20056 }; 20057 var parseQuarterPatterns = { 20058 any: [/1/i, /2/i, /3/i, /4/i] 20059 }; 20060 var matchMonthPatterns = { 20061 narrow: /^[jfmasond]/i, 20062 abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i, 20063 wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i 20064 }; 20065 var parseMonthPatterns = { 20066 narrow: [ 20067 /^j/i, 20068 /^f/i, 20069 /^m/i, 20070 /^a/i, 20071 /^m/i, 20072 /^j/i, 20073 /^j/i, 20074 /^a/i, 20075 /^s/i, 20076 /^o/i, 20077 /^n/i, 20078 /^d/i 20079 ], 20080 any: [ 20081 /^ja/i, 20082 /^f/i, 20083 /^mar/i, 20084 /^ap/i, 20085 /^may/i, 20086 /^jun/i, 20087 /^jul/i, 20088 /^au/i, 20089 /^s/i, 20090 /^o/i, 20091 /^n/i, 20092 /^d/i 20093 ] 20094 }; 20095 var matchDayPatterns = { 20096 narrow: /^[smtwf]/i, 20097 short: /^(su|mo|tu|we|th|fr|sa)/i, 20098 abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i, 20099 wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i 20100 }; 20101 var parseDayPatterns = { 20102 narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i], 20103 any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i] 20104 }; 20105 var matchDayPeriodPatterns = { 20106 narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i, 20107 any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i 20108 }; 20109 var parseDayPeriodPatterns = { 20110 any: { 20111 am: /^a/i, 20112 pm: /^p/i, 20113 midnight: /^mi/i, 20114 noon: /^no/i, 20115 morning: /morning/i, 20116 afternoon: /afternoon/i, 20117 evening: /evening/i, 20118 night: /night/i 20119 } 20120 }; 20121 var match = { 20122 ordinalNumber: buildMatchPatternFn({ 20123 matchPattern: matchOrdinalNumberPattern, 20124 parsePattern: parseOrdinalNumberPattern, 20125 valueCallback: (value) => parseInt(value, 10) 20126 }), 20127 era: buildMatchFn({ 20128 matchPatterns: matchEraPatterns, 20129 defaultMatchWidth: "wide", 20130 parsePatterns: parseEraPatterns, 20131 defaultParseWidth: "any" 20132 }), 20133 quarter: buildMatchFn({ 20134 matchPatterns: matchQuarterPatterns, 20135 defaultMatchWidth: "wide", 20136 parsePatterns: parseQuarterPatterns, 20137 defaultParseWidth: "any", 20138 valueCallback: (index2) => index2 + 1 20139 }), 20140 month: buildMatchFn({ 20141 matchPatterns: matchMonthPatterns, 20142 defaultMatchWidth: "wide", 20143 parsePatterns: parseMonthPatterns, 20144 defaultParseWidth: "any" 20145 }), 20146 day: buildMatchFn({ 20147 matchPatterns: matchDayPatterns, 20148 defaultMatchWidth: "wide", 20149 parsePatterns: parseDayPatterns, 20150 defaultParseWidth: "any" 20151 }), 20152 dayPeriod: buildMatchFn({ 20153 matchPatterns: matchDayPeriodPatterns, 20154 defaultMatchWidth: "any", 20155 parsePatterns: parseDayPeriodPatterns, 20156 defaultParseWidth: "any" 20157 }) 20158 }; 20159 20160 // node_modules/date-fns/locale/en-US.js 20161 var enUS = { 20162 code: "en-US", 20163 formatDistance, 20164 formatLong, 20165 formatRelative, 20166 localize, 20167 match, 20168 options: { 20169 weekStartsOn: 0, 20170 firstWeekContainsDate: 1 20171 } 20172 }; 20173 20174 // node_modules/date-fns/getDayOfYear.js 20175 function getDayOfYear(date, options) { 20176 const _date = toDate(date, options?.in); 20177 const diff = differenceInCalendarDays(_date, startOfYear(_date)); 20178 const dayOfYear = diff + 1; 20179 return dayOfYear; 20180 } 20181 20182 // node_modules/date-fns/getISOWeek.js 20183 function getISOWeek(date, options) { 20184 const _date = toDate(date, options?.in); 20185 const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date); 20186 return Math.round(diff / millisecondsInWeek) + 1; 20187 } 20188 20189 // node_modules/date-fns/getWeekYear.js 20190 function getWeekYear(date, options) { 20191 const _date = toDate(date, options?.in); 20192 const year = _date.getFullYear(); 20193 const defaultOptions2 = getDefaultOptions(); 20194 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1; 20195 const firstWeekOfNextYear = constructFrom(options?.in || date, 0); 20196 firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate); 20197 firstWeekOfNextYear.setHours(0, 0, 0, 0); 20198 const startOfNextYear = startOfWeek(firstWeekOfNextYear, options); 20199 const firstWeekOfThisYear = constructFrom(options?.in || date, 0); 20200 firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate); 20201 firstWeekOfThisYear.setHours(0, 0, 0, 0); 20202 const startOfThisYear = startOfWeek(firstWeekOfThisYear, options); 20203 if (+_date >= +startOfNextYear) { 20204 return year + 1; 20205 } else if (+_date >= +startOfThisYear) { 20206 return year; 20207 } else { 20208 return year - 1; 20209 } 20210 } 20211 20212 // node_modules/date-fns/startOfWeekYear.js 20213 function startOfWeekYear(date, options) { 20214 const defaultOptions2 = getDefaultOptions(); 20215 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1; 20216 const year = getWeekYear(date, options); 20217 const firstWeek = constructFrom(options?.in || date, 0); 20218 firstWeek.setFullYear(year, 0, firstWeekContainsDate); 20219 firstWeek.setHours(0, 0, 0, 0); 20220 const _date = startOfWeek(firstWeek, options); 20221 return _date; 20222 } 20223 20224 // node_modules/date-fns/getWeek.js 20225 function getWeek(date, options) { 20226 const _date = toDate(date, options?.in); 20227 const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options); 20228 return Math.round(diff / millisecondsInWeek) + 1; 20229 } 20230 20231 // node_modules/date-fns/_lib/addLeadingZeros.js 20232 function addLeadingZeros(number, targetLength) { 20233 const sign = number < 0 ? "-" : ""; 20234 const output = Math.abs(number).toString().padStart(targetLength, "0"); 20235 return sign + output; 20236 } 20237 20238 // node_modules/date-fns/_lib/format/lightFormatters.js 20239 var lightFormatters = { 20240 // Year 20241 y(date, token) { 20242 const signedYear = date.getFullYear(); 20243 const year = signedYear > 0 ? signedYear : 1 - signedYear; 20244 return addLeadingZeros(token === "yy" ? year % 100 : year, token.length); 20245 }, 20246 // Month 20247 M(date, token) { 20248 const month = date.getMonth(); 20249 return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2); 20250 }, 20251 // Day of the month 20252 d(date, token) { 20253 return addLeadingZeros(date.getDate(), token.length); 20254 }, 20255 // AM or PM 20256 a(date, token) { 20257 const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am"; 20258 switch (token) { 20259 case "a": 20260 case "aa": 20261 return dayPeriodEnumValue.toUpperCase(); 20262 case "aaa": 20263 return dayPeriodEnumValue; 20264 case "aaaaa": 20265 return dayPeriodEnumValue[0]; 20266 case "aaaa": 20267 default: 20268 return dayPeriodEnumValue === "am" ? "a.m." : "p.m."; 20269 } 20270 }, 20271 // Hour [1-12] 20272 h(date, token) { 20273 return addLeadingZeros(date.getHours() % 12 || 12, token.length); 20274 }, 20275 // Hour [0-23] 20276 H(date, token) { 20277 return addLeadingZeros(date.getHours(), token.length); 20278 }, 20279 // Minute 20280 m(date, token) { 20281 return addLeadingZeros(date.getMinutes(), token.length); 20282 }, 20283 // Second 20284 s(date, token) { 20285 return addLeadingZeros(date.getSeconds(), token.length); 20286 }, 20287 // Fraction of second 20288 S(date, token) { 20289 const numberOfDigits = token.length; 20290 const milliseconds = date.getMilliseconds(); 20291 const fractionalSeconds = Math.trunc( 20292 milliseconds * Math.pow(10, numberOfDigits - 3) 20293 ); 20294 return addLeadingZeros(fractionalSeconds, token.length); 20295 } 20296 }; 20297 20298 // node_modules/date-fns/_lib/format/formatters.js 20299 var dayPeriodEnum = { 20300 am: "am", 20301 pm: "pm", 20302 midnight: "midnight", 20303 noon: "noon", 20304 morning: "morning", 20305 afternoon: "afternoon", 20306 evening: "evening", 20307 night: "night" 20308 }; 20309 var formatters = { 20310 // Era 20311 G: function(date, token, localize2) { 20312 const era = date.getFullYear() > 0 ? 1 : 0; 20313 switch (token) { 20314 // AD, BC 20315 case "G": 20316 case "GG": 20317 case "GGG": 20318 return localize2.era(era, { width: "abbreviated" }); 20319 // A, B 20320 case "GGGGG": 20321 return localize2.era(era, { width: "narrow" }); 20322 // Anno Domini, Before Christ 20323 case "GGGG": 20324 default: 20325 return localize2.era(era, { width: "wide" }); 20326 } 20327 }, 20328 // Year 20329 y: function(date, token, localize2) { 20330 if (token === "yo") { 20331 const signedYear = date.getFullYear(); 20332 const year = signedYear > 0 ? signedYear : 1 - signedYear; 20333 return localize2.ordinalNumber(year, { unit: "year" }); 20334 } 20335 return lightFormatters.y(date, token); 20336 }, 20337 // Local week-numbering year 20338 Y: function(date, token, localize2, options) { 20339 const signedWeekYear = getWeekYear(date, options); 20340 const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear; 20341 if (token === "YY") { 20342 const twoDigitYear = weekYear % 100; 20343 return addLeadingZeros(twoDigitYear, 2); 20344 } 20345 if (token === "Yo") { 20346 return localize2.ordinalNumber(weekYear, { unit: "year" }); 20347 } 20348 return addLeadingZeros(weekYear, token.length); 20349 }, 20350 // ISO week-numbering year 20351 R: function(date, token) { 20352 const isoWeekYear = getISOWeekYear(date); 20353 return addLeadingZeros(isoWeekYear, token.length); 20354 }, 20355 // Extended year. This is a single number designating the year of this calendar system. 20356 // The main difference between `y` and `u` localizers are B.C. years: 20357 // | Year | `y` | `u` | 20358 // |------|-----|-----| 20359 // | AC 1 | 1 | 1 | 20360 // | BC 1 | 1 | 0 | 20361 // | BC 2 | 2 | -1 | 20362 // Also `yy` always returns the last two digits of a year, 20363 // while `uu` pads single digit years to 2 characters and returns other years unchanged. 20364 u: function(date, token) { 20365 const year = date.getFullYear(); 20366 return addLeadingZeros(year, token.length); 20367 }, 20368 // Quarter 20369 Q: function(date, token, localize2) { 20370 const quarter = Math.ceil((date.getMonth() + 1) / 3); 20371 switch (token) { 20372 // 1, 2, 3, 4 20373 case "Q": 20374 return String(quarter); 20375 // 01, 02, 03, 04 20376 case "QQ": 20377 return addLeadingZeros(quarter, 2); 20378 // 1st, 2nd, 3rd, 4th 20379 case "Qo": 20380 return localize2.ordinalNumber(quarter, { unit: "quarter" }); 20381 // Q1, Q2, Q3, Q4 20382 case "QQQ": 20383 return localize2.quarter(quarter, { 20384 width: "abbreviated", 20385 context: "formatting" 20386 }); 20387 // 1, 2, 3, 4 (narrow quarter; could be not numerical) 20388 case "QQQQQ": 20389 return localize2.quarter(quarter, { 20390 width: "narrow", 20391 context: "formatting" 20392 }); 20393 // 1st quarter, 2nd quarter, ... 20394 case "QQQQ": 20395 default: 20396 return localize2.quarter(quarter, { 20397 width: "wide", 20398 context: "formatting" 20399 }); 20400 } 20401 }, 20402 // Stand-alone quarter 20403 q: function(date, token, localize2) { 20404 const quarter = Math.ceil((date.getMonth() + 1) / 3); 20405 switch (token) { 20406 // 1, 2, 3, 4 20407 case "q": 20408 return String(quarter); 20409 // 01, 02, 03, 04 20410 case "qq": 20411 return addLeadingZeros(quarter, 2); 20412 // 1st, 2nd, 3rd, 4th 20413 case "qo": 20414 return localize2.ordinalNumber(quarter, { unit: "quarter" }); 20415 // Q1, Q2, Q3, Q4 20416 case "qqq": 20417 return localize2.quarter(quarter, { 20418 width: "abbreviated", 20419 context: "standalone" 20420 }); 20421 // 1, 2, 3, 4 (narrow quarter; could be not numerical) 20422 case "qqqqq": 20423 return localize2.quarter(quarter, { 20424 width: "narrow", 20425 context: "standalone" 20426 }); 20427 // 1st quarter, 2nd quarter, ... 20428 case "qqqq": 20429 default: 20430 return localize2.quarter(quarter, { 20431 width: "wide", 20432 context: "standalone" 20433 }); 20434 } 20435 }, 20436 // Month 20437 M: function(date, token, localize2) { 20438 const month = date.getMonth(); 20439 switch (token) { 20440 case "M": 20441 case "MM": 20442 return lightFormatters.M(date, token); 20443 // 1st, 2nd, ..., 12th 20444 case "Mo": 20445 return localize2.ordinalNumber(month + 1, { unit: "month" }); 20446 // Jan, Feb, ..., Dec 20447 case "MMM": 20448 return localize2.month(month, { 20449 width: "abbreviated", 20450 context: "formatting" 20451 }); 20452 // J, F, ..., D 20453 case "MMMMM": 20454 return localize2.month(month, { 20455 width: "narrow", 20456 context: "formatting" 20457 }); 20458 // January, February, ..., December 20459 case "MMMM": 20460 default: 20461 return localize2.month(month, { width: "wide", context: "formatting" }); 20462 } 20463 }, 20464 // Stand-alone month 20465 L: function(date, token, localize2) { 20466 const month = date.getMonth(); 20467 switch (token) { 20468 // 1, 2, ..., 12 20469 case "L": 20470 return String(month + 1); 20471 // 01, 02, ..., 12 20472 case "LL": 20473 return addLeadingZeros(month + 1, 2); 20474 // 1st, 2nd, ..., 12th 20475 case "Lo": 20476 return localize2.ordinalNumber(month + 1, { unit: "month" }); 20477 // Jan, Feb, ..., Dec 20478 case "LLL": 20479 return localize2.month(month, { 20480 width: "abbreviated", 20481 context: "standalone" 20482 }); 20483 // J, F, ..., D 20484 case "LLLLL": 20485 return localize2.month(month, { 20486 width: "narrow", 20487 context: "standalone" 20488 }); 20489 // January, February, ..., December 20490 case "LLLL": 20491 default: 20492 return localize2.month(month, { width: "wide", context: "standalone" }); 20493 } 20494 }, 20495 // Local week of year 20496 w: function(date, token, localize2, options) { 20497 const week = getWeek(date, options); 20498 if (token === "wo") { 20499 return localize2.ordinalNumber(week, { unit: "week" }); 20500 } 20501 return addLeadingZeros(week, token.length); 20502 }, 20503 // ISO week of year 20504 I: function(date, token, localize2) { 20505 const isoWeek = getISOWeek(date); 20506 if (token === "Io") { 20507 return localize2.ordinalNumber(isoWeek, { unit: "week" }); 20508 } 20509 return addLeadingZeros(isoWeek, token.length); 20510 }, 20511 // Day of the month 20512 d: function(date, token, localize2) { 20513 if (token === "do") { 20514 return localize2.ordinalNumber(date.getDate(), { unit: "date" }); 20515 } 20516 return lightFormatters.d(date, token); 20517 }, 20518 // Day of year 20519 D: function(date, token, localize2) { 20520 const dayOfYear = getDayOfYear(date); 20521 if (token === "Do") { 20522 return localize2.ordinalNumber(dayOfYear, { unit: "dayOfYear" }); 20523 } 20524 return addLeadingZeros(dayOfYear, token.length); 20525 }, 20526 // Day of week 20527 E: function(date, token, localize2) { 20528 const dayOfWeek = date.getDay(); 20529 switch (token) { 20530 // Tue 20531 case "E": 20532 case "EE": 20533 case "EEE": 20534 return localize2.day(dayOfWeek, { 20535 width: "abbreviated", 20536 context: "formatting" 20537 }); 20538 // T 20539 case "EEEEE": 20540 return localize2.day(dayOfWeek, { 20541 width: "narrow", 20542 context: "formatting" 20543 }); 20544 // Tu 20545 case "EEEEEE": 20546 return localize2.day(dayOfWeek, { 20547 width: "short", 20548 context: "formatting" 20549 }); 20550 // Tuesday 20551 case "EEEE": 20552 default: 20553 return localize2.day(dayOfWeek, { 20554 width: "wide", 20555 context: "formatting" 20556 }); 20557 } 20558 }, 20559 // Local day of week 20560 e: function(date, token, localize2, options) { 20561 const dayOfWeek = date.getDay(); 20562 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7; 20563 switch (token) { 20564 // Numerical value (Nth day of week with current locale or weekStartsOn) 20565 case "e": 20566 return String(localDayOfWeek); 20567 // Padded numerical value 20568 case "ee": 20569 return addLeadingZeros(localDayOfWeek, 2); 20570 // 1st, 2nd, ..., 7th 20571 case "eo": 20572 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" }); 20573 case "eee": 20574 return localize2.day(dayOfWeek, { 20575 width: "abbreviated", 20576 context: "formatting" 20577 }); 20578 // T 20579 case "eeeee": 20580 return localize2.day(dayOfWeek, { 20581 width: "narrow", 20582 context: "formatting" 20583 }); 20584 // Tu 20585 case "eeeeee": 20586 return localize2.day(dayOfWeek, { 20587 width: "short", 20588 context: "formatting" 20589 }); 20590 // Tuesday 20591 case "eeee": 20592 default: 20593 return localize2.day(dayOfWeek, { 20594 width: "wide", 20595 context: "formatting" 20596 }); 20597 } 20598 }, 20599 // Stand-alone local day of week 20600 c: function(date, token, localize2, options) { 20601 const dayOfWeek = date.getDay(); 20602 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7; 20603 switch (token) { 20604 // Numerical value (same as in `e`) 20605 case "c": 20606 return String(localDayOfWeek); 20607 // Padded numerical value 20608 case "cc": 20609 return addLeadingZeros(localDayOfWeek, token.length); 20610 // 1st, 2nd, ..., 7th 20611 case "co": 20612 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" }); 20613 case "ccc": 20614 return localize2.day(dayOfWeek, { 20615 width: "abbreviated", 20616 context: "standalone" 20617 }); 20618 // T 20619 case "ccccc": 20620 return localize2.day(dayOfWeek, { 20621 width: "narrow", 20622 context: "standalone" 20623 }); 20624 // Tu 20625 case "cccccc": 20626 return localize2.day(dayOfWeek, { 20627 width: "short", 20628 context: "standalone" 20629 }); 20630 // Tuesday 20631 case "cccc": 20632 default: 20633 return localize2.day(dayOfWeek, { 20634 width: "wide", 20635 context: "standalone" 20636 }); 20637 } 20638 }, 20639 // ISO day of week 20640 i: function(date, token, localize2) { 20641 const dayOfWeek = date.getDay(); 20642 const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek; 20643 switch (token) { 20644 // 2 20645 case "i": 20646 return String(isoDayOfWeek); 20647 // 02 20648 case "ii": 20649 return addLeadingZeros(isoDayOfWeek, token.length); 20650 // 2nd 20651 case "io": 20652 return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" }); 20653 // Tue 20654 case "iii": 20655 return localize2.day(dayOfWeek, { 20656 width: "abbreviated", 20657 context: "formatting" 20658 }); 20659 // T 20660 case "iiiii": 20661 return localize2.day(dayOfWeek, { 20662 width: "narrow", 20663 context: "formatting" 20664 }); 20665 // Tu 20666 case "iiiiii": 20667 return localize2.day(dayOfWeek, { 20668 width: "short", 20669 context: "formatting" 20670 }); 20671 // Tuesday 20672 case "iiii": 20673 default: 20674 return localize2.day(dayOfWeek, { 20675 width: "wide", 20676 context: "formatting" 20677 }); 20678 } 20679 }, 20680 // AM or PM 20681 a: function(date, token, localize2) { 20682 const hours = date.getHours(); 20683 const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am"; 20684 switch (token) { 20685 case "a": 20686 case "aa": 20687 return localize2.dayPeriod(dayPeriodEnumValue, { 20688 width: "abbreviated", 20689 context: "formatting" 20690 }); 20691 case "aaa": 20692 return localize2.dayPeriod(dayPeriodEnumValue, { 20693 width: "abbreviated", 20694 context: "formatting" 20695 }).toLowerCase(); 20696 case "aaaaa": 20697 return localize2.dayPeriod(dayPeriodEnumValue, { 20698 width: "narrow", 20699 context: "formatting" 20700 }); 20701 case "aaaa": 20702 default: 20703 return localize2.dayPeriod(dayPeriodEnumValue, { 20704 width: "wide", 20705 context: "formatting" 20706 }); 20707 } 20708 }, 20709 // AM, PM, midnight, noon 20710 b: function(date, token, localize2) { 20711 const hours = date.getHours(); 20712 let dayPeriodEnumValue; 20713 if (hours === 12) { 20714 dayPeriodEnumValue = dayPeriodEnum.noon; 20715 } else if (hours === 0) { 20716 dayPeriodEnumValue = dayPeriodEnum.midnight; 20717 } else { 20718 dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am"; 20719 } 20720 switch (token) { 20721 case "b": 20722 case "bb": 20723 return localize2.dayPeriod(dayPeriodEnumValue, { 20724 width: "abbreviated", 20725 context: "formatting" 20726 }); 20727 case "bbb": 20728 return localize2.dayPeriod(dayPeriodEnumValue, { 20729 width: "abbreviated", 20730 context: "formatting" 20731 }).toLowerCase(); 20732 case "bbbbb": 20733 return localize2.dayPeriod(dayPeriodEnumValue, { 20734 width: "narrow", 20735 context: "formatting" 20736 }); 20737 case "bbbb": 20738 default: 20739 return localize2.dayPeriod(dayPeriodEnumValue, { 20740 width: "wide", 20741 context: "formatting" 20742 }); 20743 } 20744 }, 20745 // in the morning, in the afternoon, in the evening, at night 20746 B: function(date, token, localize2) { 20747 const hours = date.getHours(); 20748 let dayPeriodEnumValue; 20749 if (hours >= 17) { 20750 dayPeriodEnumValue = dayPeriodEnum.evening; 20751 } else if (hours >= 12) { 20752 dayPeriodEnumValue = dayPeriodEnum.afternoon; 20753 } else if (hours >= 4) { 20754 dayPeriodEnumValue = dayPeriodEnum.morning; 20755 } else { 20756 dayPeriodEnumValue = dayPeriodEnum.night; 20757 } 20758 switch (token) { 20759 case "B": 20760 case "BB": 20761 case "BBB": 20762 return localize2.dayPeriod(dayPeriodEnumValue, { 20763 width: "abbreviated", 20764 context: "formatting" 20765 }); 20766 case "BBBBB": 20767 return localize2.dayPeriod(dayPeriodEnumValue, { 20768 width: "narrow", 20769 context: "formatting" 20770 }); 20771 case "BBBB": 20772 default: 20773 return localize2.dayPeriod(dayPeriodEnumValue, { 20774 width: "wide", 20775 context: "formatting" 20776 }); 20777 } 20778 }, 20779 // Hour [1-12] 20780 h: function(date, token, localize2) { 20781 if (token === "ho") { 20782 let hours = date.getHours() % 12; 20783 if (hours === 0) hours = 12; 20784 return localize2.ordinalNumber(hours, { unit: "hour" }); 20785 } 20786 return lightFormatters.h(date, token); 20787 }, 20788 // Hour [0-23] 20789 H: function(date, token, localize2) { 20790 if (token === "Ho") { 20791 return localize2.ordinalNumber(date.getHours(), { unit: "hour" }); 20792 } 20793 return lightFormatters.H(date, token); 20794 }, 20795 // Hour [0-11] 20796 K: function(date, token, localize2) { 20797 const hours = date.getHours() % 12; 20798 if (token === "Ko") { 20799 return localize2.ordinalNumber(hours, { unit: "hour" }); 20800 } 20801 return addLeadingZeros(hours, token.length); 20802 }, 20803 // Hour [1-24] 20804 k: function(date, token, localize2) { 20805 let hours = date.getHours(); 20806 if (hours === 0) hours = 24; 20807 if (token === "ko") { 20808 return localize2.ordinalNumber(hours, { unit: "hour" }); 20809 } 20810 return addLeadingZeros(hours, token.length); 20811 }, 20812 // Minute 20813 m: function(date, token, localize2) { 20814 if (token === "mo") { 20815 return localize2.ordinalNumber(date.getMinutes(), { unit: "minute" }); 20816 } 20817 return lightFormatters.m(date, token); 20818 }, 20819 // Second 20820 s: function(date, token, localize2) { 20821 if (token === "so") { 20822 return localize2.ordinalNumber(date.getSeconds(), { unit: "second" }); 20823 } 20824 return lightFormatters.s(date, token); 20825 }, 20826 // Fraction of second 20827 S: function(date, token) { 20828 return lightFormatters.S(date, token); 20829 }, 20830 // Timezone (ISO-8601. If offset is 0, output is always `'Z'`) 20831 X: function(date, token, _localize) { 20832 const timezoneOffset = date.getTimezoneOffset(); 20833 if (timezoneOffset === 0) { 20834 return "Z"; 20835 } 20836 switch (token) { 20837 // Hours and optional minutes 20838 case "X": 20839 return formatTimezoneWithOptionalMinutes(timezoneOffset); 20840 // Hours, minutes and optional seconds without `:` delimiter 20841 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets 20842 // so this token always has the same output as `XX` 20843 case "XXXX": 20844 case "XX": 20845 return formatTimezone(timezoneOffset); 20846 // Hours, minutes and optional seconds with `:` delimiter 20847 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets 20848 // so this token always has the same output as `XXX` 20849 case "XXXXX": 20850 case "XXX": 20851 // Hours and minutes with `:` delimiter 20852 default: 20853 return formatTimezone(timezoneOffset, ":"); 20854 } 20855 }, 20856 // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent) 20857 x: function(date, token, _localize) { 20858 const timezoneOffset = date.getTimezoneOffset(); 20859 switch (token) { 20860 // Hours and optional minutes 20861 case "x": 20862 return formatTimezoneWithOptionalMinutes(timezoneOffset); 20863 // Hours, minutes and optional seconds without `:` delimiter 20864 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets 20865 // so this token always has the same output as `xx` 20866 case "xxxx": 20867 case "xx": 20868 return formatTimezone(timezoneOffset); 20869 // Hours, minutes and optional seconds with `:` delimiter 20870 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets 20871 // so this token always has the same output as `xxx` 20872 case "xxxxx": 20873 case "xxx": 20874 // Hours and minutes with `:` delimiter 20875 default: 20876 return formatTimezone(timezoneOffset, ":"); 20877 } 20878 }, 20879 // Timezone (GMT) 20880 O: function(date, token, _localize) { 20881 const timezoneOffset = date.getTimezoneOffset(); 20882 switch (token) { 20883 // Short 20884 case "O": 20885 case "OO": 20886 case "OOO": 20887 return "GMT" + formatTimezoneShort(timezoneOffset, ":"); 20888 // Long 20889 case "OOOO": 20890 default: 20891 return "GMT" + formatTimezone(timezoneOffset, ":"); 20892 } 20893 }, 20894 // Timezone (specific non-location) 20895 z: function(date, token, _localize) { 20896 const timezoneOffset = date.getTimezoneOffset(); 20897 switch (token) { 20898 // Short 20899 case "z": 20900 case "zz": 20901 case "zzz": 20902 return "GMT" + formatTimezoneShort(timezoneOffset, ":"); 20903 // Long 20904 case "zzzz": 20905 default: 20906 return "GMT" + formatTimezone(timezoneOffset, ":"); 20907 } 20908 }, 20909 // Seconds timestamp 20910 t: function(date, token, _localize) { 20911 const timestamp = Math.trunc(+date / 1e3); 20912 return addLeadingZeros(timestamp, token.length); 20913 }, 20914 // Milliseconds timestamp 20915 T: function(date, token, _localize) { 20916 return addLeadingZeros(+date, token.length); 20917 } 20918 }; 20919 function formatTimezoneShort(offset4, delimiter = "") { 20920 const sign = offset4 > 0 ? "-" : "+"; 20921 const absOffset = Math.abs(offset4); 20922 const hours = Math.trunc(absOffset / 60); 20923 const minutes = absOffset % 60; 20924 if (minutes === 0) { 20925 return sign + String(hours); 20926 } 20927 return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2); 20928 } 20929 function formatTimezoneWithOptionalMinutes(offset4, delimiter) { 20930 if (offset4 % 60 === 0) { 20931 const sign = offset4 > 0 ? "-" : "+"; 20932 return sign + addLeadingZeros(Math.abs(offset4) / 60, 2); 20933 } 20934 return formatTimezone(offset4, delimiter); 20935 } 20936 function formatTimezone(offset4, delimiter = "") { 20937 const sign = offset4 > 0 ? "-" : "+"; 20938 const absOffset = Math.abs(offset4); 20939 const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2); 20940 const minutes = addLeadingZeros(absOffset % 60, 2); 20941 return sign + hours + delimiter + minutes; 20942 } 20943 20944 // node_modules/date-fns/_lib/format/longFormatters.js 20945 var dateLongFormatter = (pattern, formatLong2) => { 20946 switch (pattern) { 20947 case "P": 20948 return formatLong2.date({ width: "short" }); 20949 case "PP": 20950 return formatLong2.date({ width: "medium" }); 20951 case "PPP": 20952 return formatLong2.date({ width: "long" }); 20953 case "PPPP": 20954 default: 20955 return formatLong2.date({ width: "full" }); 20956 } 20957 }; 20958 var timeLongFormatter = (pattern, formatLong2) => { 20959 switch (pattern) { 20960 case "p": 20961 return formatLong2.time({ width: "short" }); 20962 case "pp": 20963 return formatLong2.time({ width: "medium" }); 20964 case "ppp": 20965 return formatLong2.time({ width: "long" }); 20966 case "pppp": 20967 default: 20968 return formatLong2.time({ width: "full" }); 20969 } 20970 }; 20971 var dateTimeLongFormatter = (pattern, formatLong2) => { 20972 const matchResult = pattern.match(/(P+)(p+)?/) || []; 20973 const datePattern = matchResult[1]; 20974 const timePattern = matchResult[2]; 20975 if (!timePattern) { 20976 return dateLongFormatter(pattern, formatLong2); 20977 } 20978 let dateTimeFormat; 20979 switch (datePattern) { 20980 case "P": 20981 dateTimeFormat = formatLong2.dateTime({ width: "short" }); 20982 break; 20983 case "PP": 20984 dateTimeFormat = formatLong2.dateTime({ width: "medium" }); 20985 break; 20986 case "PPP": 20987 dateTimeFormat = formatLong2.dateTime({ width: "long" }); 20988 break; 20989 case "PPPP": 20990 default: 20991 dateTimeFormat = formatLong2.dateTime({ width: "full" }); 20992 break; 20993 } 20994 return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2)); 20995 }; 20996 var longFormatters = { 20997 p: timeLongFormatter, 20998 P: dateTimeLongFormatter 20999 }; 21000 21001 // node_modules/date-fns/_lib/protectedTokens.js 21002 var dayOfYearTokenRE = /^D+$/; 21003 var weekYearTokenRE = /^Y+$/; 21004 var throwTokens = ["D", "DD", "YY", "YYYY"]; 21005 function isProtectedDayOfYearToken(token) { 21006 return dayOfYearTokenRE.test(token); 21007 } 21008 function isProtectedWeekYearToken(token) { 21009 return weekYearTokenRE.test(token); 21010 } 21011 function warnOrThrowProtectedError(token, format6, input) { 21012 const _message = message(token, format6, input); 21013 console.warn(_message); 21014 if (throwTokens.includes(token)) throw new RangeError(_message); 21015 } 21016 function message(token, format6, input) { 21017 const subject = token[0] === "Y" ? "years" : "days of the month"; 21018 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`; 21019 } 21020 21021 // node_modules/date-fns/format.js 21022 var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g; 21023 var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g; 21024 var escapedStringRegExp = /^'([^]*?)'?$/; 21025 var doubleQuoteRegExp = /''/g; 21026 var unescapedLatinCharacterRegExp = /[a-zA-Z]/; 21027 function format(date, formatStr, options) { 21028 const defaultOptions2 = getDefaultOptions(); 21029 const locale = options?.locale ?? defaultOptions2.locale ?? enUS; 21030 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1; 21031 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0; 21032 const originalDate = toDate(date, options?.in); 21033 if (!isValid(originalDate)) { 21034 throw new RangeError("Invalid time value"); 21035 } 21036 let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => { 21037 const firstCharacter = substring[0]; 21038 if (firstCharacter === "p" || firstCharacter === "P") { 21039 const longFormatter = longFormatters[firstCharacter]; 21040 return longFormatter(substring, locale.formatLong); 21041 } 21042 return substring; 21043 }).join("").match(formattingTokensRegExp).map((substring) => { 21044 if (substring === "''") { 21045 return { isToken: false, value: "'" }; 21046 } 21047 const firstCharacter = substring[0]; 21048 if (firstCharacter === "'") { 21049 return { isToken: false, value: cleanEscapedString(substring) }; 21050 } 21051 if (formatters[firstCharacter]) { 21052 return { isToken: true, value: substring }; 21053 } 21054 if (firstCharacter.match(unescapedLatinCharacterRegExp)) { 21055 throw new RangeError( 21056 "Format string contains an unescaped latin alphabet character `" + firstCharacter + "`" 21057 ); 21058 } 21059 return { isToken: false, value: substring }; 21060 }); 21061 if (locale.localize.preprocessor) { 21062 parts = locale.localize.preprocessor(originalDate, parts); 21063 } 21064 const formatterOptions = { 21065 firstWeekContainsDate, 21066 weekStartsOn, 21067 locale 21068 }; 21069 return parts.map((part) => { 21070 if (!part.isToken) return part.value; 21071 const token = part.value; 21072 if (!options?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token) || !options?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) { 21073 warnOrThrowProtectedError(token, formatStr, String(date)); 21074 } 21075 const formatter = formatters[token[0]]; 21076 return formatter(originalDate, token, locale.localize, formatterOptions); 21077 }).join(""); 21078 } 21079 function cleanEscapedString(input) { 21080 const matched = input.match(escapedStringRegExp); 21081 if (!matched) { 21082 return input; 21083 } 21084 return matched[1].replace(doubleQuoteRegExp, "'"); 21085 } 21086 21087 // node_modules/date-fns/subDays.js 21088 function subDays(date, amount, options) { 21089 return addDays(date, -amount, options); 21090 } 21091 21092 // node_modules/date-fns/subMonths.js 21093 function subMonths(date, amount, options) { 21094 return addMonths(date, -amount, options); 21095 } 21096 21097 // node_modules/date-fns/subWeeks.js 21098 function subWeeks(date, amount, options) { 21099 return addWeeks(date, -amount, options); 21100 } 21101 21102 // node_modules/date-fns/subYears.js 21103 function subYears(date, amount, options) { 21104 return addYears(date, -amount, options); 21105 } 21106 21107 // packages/dataviews/build-module/utils/operators.mjs 21108 var import_i18n30 = __toESM(require_i18n(), 1); 21109 var import_element44 = __toESM(require_element(), 1); 21110 var import_date = __toESM(require_date(), 1); 21111 var import_jsx_runtime81 = __toESM(require_jsx_runtime(), 1); 21112 var filterTextWrappers = { 21113 Name: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("span", { className: "dataviews-filters__summary-filter-text-name" }), 21114 Value: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("span", { className: "dataviews-filters__summary-filter-text-value" }) 21115 }; 21116 function getRelativeDate(value, unit) { 21117 switch (unit) { 21118 case "days": 21119 return subDays(/* @__PURE__ */ new Date(), value); 21120 case "weeks": 21121 return subWeeks(/* @__PURE__ */ new Date(), value); 21122 case "months": 21123 return subMonths(/* @__PURE__ */ new Date(), value); 21124 case "years": 21125 return subYears(/* @__PURE__ */ new Date(), value); 21126 default: 21127 return /* @__PURE__ */ new Date(); 21128 } 21129 } 21130 var isNoneOperatorDefinition = { 21131 /* translators: DataViews operator name */ 21132 label: (0, import_i18n30.__)("Is none of"), 21133 filterText: (filter, activeElements) => (0, import_element44.createInterpolateElement)( 21134 (0, import_i18n30.sprintf)( 21135 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */ 21136 (0, import_i18n30.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"), 21137 filter.name, 21138 activeElements.map((element) => element.label).join(", ") 21139 ), 21140 filterTextWrappers 21141 ), 21142 filter: ((item, field, filterValue) => { 21143 if (!filterValue?.length) { 21144 return true; 21145 } 21146 const fieldValue = field.getValue({ item }); 21147 if (Array.isArray(fieldValue)) { 21148 return !filterValue.some( 21149 (fv) => fieldValue.includes(fv) 21150 ); 21151 } else if (typeof fieldValue === "string") { 21152 return !filterValue.includes(fieldValue); 21153 } 21154 return false; 21155 }), 21156 selection: "multi" 21157 }; 21158 var OPERATORS = [ 21159 { 21160 name: OPERATOR_IS_ANY, 21161 /* translators: DataViews operator name */ 21162 label: (0, import_i18n30.__)("Includes"), 21163 filterText: (filter, activeElements) => (0, import_element44.createInterpolateElement)( 21164 (0, import_i18n30.sprintf)( 21165 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is any: Admin, Editor". */ 21166 (0, import_i18n30.__)("<Name>%1$s includes: </Name><Value>%2$s</Value>"), 21167 filter.name, 21168 activeElements.map((element) => element.label).join(", ") 21169 ), 21170 filterTextWrappers 21171 ), 21172 filter(item, field, filterValue) { 21173 if (!filterValue?.length) { 21174 return true; 21175 } 21176 const fieldValue = field.getValue({ item }); 21177 if (Array.isArray(fieldValue)) { 21178 return filterValue.some( 21179 (fv) => fieldValue.includes(fv) 21180 ); 21181 } else if (typeof fieldValue === "string") { 21182 return filterValue.includes(fieldValue); 21183 } 21184 return false; 21185 }, 21186 selection: "multi" 21187 }, 21188 { 21189 name: OPERATOR_IS_NONE, 21190 ...isNoneOperatorDefinition 21191 }, 21192 { 21193 name: OPERATOR_IS_ALL, 21194 /* translators: DataViews operator name */ 21195 label: (0, import_i18n30.__)("Includes all"), 21196 filterText: (filter, activeElements) => (0, import_element44.createInterpolateElement)( 21197 (0, import_i18n30.sprintf)( 21198 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author includes all: Admin, Editor". */ 21199 (0, import_i18n30.__)("<Name>%1$s includes all: </Name><Value>%2$s</Value>"), 21200 filter.name, 21201 activeElements.map((element) => element.label).join(", ") 21202 ), 21203 filterTextWrappers 21204 ), 21205 filter(item, field, filterValue) { 21206 if (!filterValue?.length) { 21207 return true; 21208 } 21209 return filterValue.every((value) => { 21210 return field.getValue({ item })?.includes(value); 21211 }); 21212 }, 21213 selection: "multi" 21214 }, 21215 { 21216 name: OPERATOR_IS_NOT_ALL, 21217 ...isNoneOperatorDefinition 21218 }, 21219 { 21220 name: OPERATOR_BETWEEN, 21221 /* translators: DataViews operator name */ 21222 label: (0, import_i18n30.__)("Between (inc)"), 21223 filterText: (filter, activeElements) => (0, import_element44.createInterpolateElement)( 21224 (0, import_i18n30.sprintf)( 21225 /* 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". */ 21226 (0, import_i18n30.__)( 21227 "<Name>%1$s between (inc): </Name><Value>%2$s and %3$s</Value>" 21228 ), 21229 filter.name, 21230 activeElements[0].label[0], 21231 activeElements[0].label[1] 21232 ), 21233 filterTextWrappers 21234 ), 21235 filter(item, field, filterValue) { 21236 if (!Array.isArray(filterValue) || filterValue.length !== 2 || filterValue[0] === void 0 || filterValue[1] === void 0) { 21237 return true; 21238 } 21239 const fieldValue = field.getValue({ item }); 21240 if (typeof fieldValue === "number" || fieldValue instanceof Date || typeof fieldValue === "string") { 21241 return fieldValue >= filterValue[0] && fieldValue <= filterValue[1]; 21242 } 21243 return false; 21244 }, 21245 selection: "custom" 21246 }, 21247 { 21248 name: OPERATOR_IN_THE_PAST, 21249 /* translators: DataViews operator name */ 21250 label: (0, import_i18n30.__)("In the past"), 21251 filterText: (filter, activeElements) => (0, import_element44.createInterpolateElement)( 21252 (0, import_i18n30.sprintf)( 21253 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is in the past: 7 days". */ 21254 (0, import_i18n30.__)( 21255 "<Name>%1$s is in the past: </Name><Value>%2$s</Value>" 21256 ), 21257 filter.name, 21258 `$activeElements[0].value.value} $activeElements[0].value.unit}` 21259 ), 21260 filterTextWrappers 21261 ), 21262 filter(item, field, filterValue) { 21263 if (filterValue?.value === void 0 || filterValue?.unit === void 0) { 21264 return true; 21265 } 21266 const targetDate = getRelativeDate( 21267 filterValue.value, 21268 filterValue.unit 21269 ); 21270 const fieldValue = (0, import_date.getDate)(field.getValue({ item })); 21271 return fieldValue >= targetDate && fieldValue <= /* @__PURE__ */ new Date(); 21272 }, 21273 selection: "custom" 21274 }, 21275 { 21276 name: OPERATOR_OVER, 21277 /* translators: DataViews operator name */ 21278 label: (0, import_i18n30.__)("Over"), 21279 filterText: (filter, activeElements) => (0, import_element44.createInterpolateElement)( 21280 (0, import_i18n30.sprintf)( 21281 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is over: 7 days". */ 21282 (0, import_i18n30.__)("<Name>%1$s is over: </Name><Value>%2$s</Value>"), 21283 filter.name, 21284 `$activeElements[0].value.value} $activeElements[0].value.unit}` 21285 ), 21286 filterTextWrappers 21287 ), 21288 filter(item, field, filterValue) { 21289 if (filterValue?.value === void 0 || filterValue?.unit === void 0) { 21290 return true; 21291 } 21292 const targetDate = getRelativeDate( 21293 filterValue.value, 21294 filterValue.unit 21295 ); 21296 const fieldValue = (0, import_date.getDate)(field.getValue({ item })); 21297 return fieldValue < targetDate; 21298 }, 21299 selection: "custom" 21300 }, 21301 { 21302 name: OPERATOR_IS, 21303 /* translators: DataViews operator name */ 21304 label: (0, import_i18n30.__)("Is"), 21305 filterText: (filter, activeElements) => (0, import_element44.createInterpolateElement)( 21306 (0, import_i18n30.sprintf)( 21307 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is: Admin". */ 21308 (0, import_i18n30.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"), 21309 filter.name, 21310 activeElements[0].label 21311 ), 21312 filterTextWrappers 21313 ), 21314 filter(item, field, filterValue) { 21315 return filterValue === field.getValue({ item }) || filterValue === void 0; 21316 }, 21317 selection: "single" 21318 }, 21319 { 21320 name: OPERATOR_IS_NOT, 21321 /* translators: DataViews operator name */ 21322 label: (0, import_i18n30.__)("Is not"), 21323 filterText: (filter, activeElements) => (0, import_element44.createInterpolateElement)( 21324 (0, import_i18n30.sprintf)( 21325 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is not: Admin". */ 21326 (0, import_i18n30.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"), 21327 filter.name, 21328 activeElements[0].label 21329 ), 21330 filterTextWrappers 21331 ), 21332 filter(item, field, filterValue) { 21333 return filterValue !== field.getValue({ item }); 21334 }, 21335 selection: "single" 21336 }, 21337 { 21338 name: OPERATOR_LESS_THAN, 21339 /* translators: DataViews operator name */ 21340 label: (0, import_i18n30.__)("Less than"), 21341 filterText: (filter, activeElements) => (0, import_element44.createInterpolateElement)( 21342 (0, import_i18n30.sprintf)( 21343 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than: 10". */ 21344 (0, import_i18n30.__)("<Name>%1$s is less than: </Name><Value>%2$s</Value>"), 21345 filter.name, 21346 activeElements[0].label 21347 ), 21348 filterTextWrappers 21349 ), 21350 filter(item, field, filterValue) { 21351 if (filterValue === void 0) { 21352 return true; 21353 } 21354 const fieldValue = field.getValue({ item }); 21355 return fieldValue < filterValue; 21356 }, 21357 selection: "single" 21358 }, 21359 { 21360 name: OPERATOR_GREATER_THAN, 21361 /* translators: DataViews operator name */ 21362 label: (0, import_i18n30.__)("Greater than"), 21363 filterText: (filter, activeElements) => (0, import_element44.createInterpolateElement)( 21364 (0, import_i18n30.sprintf)( 21365 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than: 10". */ 21366 (0, import_i18n30.__)( 21367 "<Name>%1$s is greater than: </Name><Value>%2$s</Value>" 21368 ), 21369 filter.name, 21370 activeElements[0].label 21371 ), 21372 filterTextWrappers 21373 ), 21374 filter(item, field, filterValue) { 21375 if (filterValue === void 0) { 21376 return true; 21377 } 21378 const fieldValue = field.getValue({ item }); 21379 return fieldValue > filterValue; 21380 }, 21381 selection: "single" 21382 }, 21383 { 21384 name: OPERATOR_LESS_THAN_OR_EQUAL, 21385 /* translators: DataViews operator name */ 21386 label: (0, import_i18n30.__)("Less than or equal"), 21387 filterText: (filter, activeElements) => (0, import_element44.createInterpolateElement)( 21388 (0, import_i18n30.sprintf)( 21389 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than or equal to: 10". */ 21390 (0, import_i18n30.__)( 21391 "<Name>%1$s is less than or equal to: </Name><Value>%2$s</Value>" 21392 ), 21393 filter.name, 21394 activeElements[0].label 21395 ), 21396 filterTextWrappers 21397 ), 21398 filter(item, field, filterValue) { 21399 if (filterValue === void 0) { 21400 return true; 21401 } 21402 const fieldValue = field.getValue({ item }); 21403 return fieldValue <= filterValue; 21404 }, 21405 selection: "single" 21406 }, 21407 { 21408 name: OPERATOR_GREATER_THAN_OR_EQUAL, 21409 /* translators: DataViews operator name */ 21410 label: (0, import_i18n30.__)("Greater than or equal"), 21411 filterText: (filter, activeElements) => (0, import_element44.createInterpolateElement)( 21412 (0, import_i18n30.sprintf)( 21413 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than or equal to: 10". */ 21414 (0, import_i18n30.__)( 21415 "<Name>%1$s is greater than or equal to: </Name><Value>%2$s</Value>" 21416 ), 21417 filter.name, 21418 activeElements[0].label 21419 ), 21420 filterTextWrappers 21421 ), 21422 filter(item, field, filterValue) { 21423 if (filterValue === void 0) { 21424 return true; 21425 } 21426 const fieldValue = field.getValue({ item }); 21427 return fieldValue >= filterValue; 21428 }, 21429 selection: "single" 21430 }, 21431 { 21432 name: OPERATOR_BEFORE, 21433 /* translators: DataViews operator name */ 21434 label: (0, import_i18n30.__)("Before"), 21435 filterText: (filter, activeElements) => (0, import_element44.createInterpolateElement)( 21436 (0, import_i18n30.sprintf)( 21437 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is before: 2024-01-01". */ 21438 (0, import_i18n30.__)("<Name>%1$s is before: </Name><Value>%2$s</Value>"), 21439 filter.name, 21440 activeElements[0].label 21441 ), 21442 filterTextWrappers 21443 ), 21444 filter(item, field, filterValue) { 21445 if (filterValue === void 0) { 21446 return true; 21447 } 21448 const filterDate = (0, import_date.getDate)(filterValue); 21449 const fieldDate = (0, import_date.getDate)(field.getValue({ item })); 21450 return fieldDate < filterDate; 21451 }, 21452 selection: "single" 21453 }, 21454 { 21455 name: OPERATOR_AFTER, 21456 /* translators: DataViews operator name */ 21457 label: (0, import_i18n30.__)("After"), 21458 filterText: (filter, activeElements) => (0, import_element44.createInterpolateElement)( 21459 (0, import_i18n30.sprintf)( 21460 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is after: 2024-01-01". */ 21461 (0, import_i18n30.__)("<Name>%1$s is after: </Name><Value>%2$s</Value>"), 21462 filter.name, 21463 activeElements[0].label 21464 ), 21465 filterTextWrappers 21466 ), 21467 filter(item, field, filterValue) { 21468 if (filterValue === void 0) { 21469 return true; 21470 } 21471 const filterDate = (0, import_date.getDate)(filterValue); 21472 const fieldDate = (0, import_date.getDate)(field.getValue({ item })); 21473 return fieldDate > filterDate; 21474 }, 21475 selection: "single" 21476 }, 21477 { 21478 name: OPERATOR_BEFORE_INC, 21479 /* translators: DataViews operator name */ 21480 label: (0, import_i18n30.__)("Before (inc)"), 21481 filterText: (filter, activeElements) => (0, import_element44.createInterpolateElement)( 21482 (0, import_i18n30.sprintf)( 21483 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or before: 2024-01-01". */ 21484 (0, import_i18n30.__)( 21485 "<Name>%1$s is on or before: </Name><Value>%2$s</Value>" 21486 ), 21487 filter.name, 21488 activeElements[0].label 21489 ), 21490 filterTextWrappers 21491 ), 21492 filter(item, field, filterValue) { 21493 if (filterValue === void 0) { 21494 return true; 21495 } 21496 const filterDate = (0, import_date.getDate)(filterValue); 21497 const fieldDate = (0, import_date.getDate)(field.getValue({ item })); 21498 return fieldDate <= filterDate; 21499 }, 21500 selection: "single" 21501 }, 21502 { 21503 name: OPERATOR_AFTER_INC, 21504 /* translators: DataViews operator name */ 21505 label: (0, import_i18n30.__)("After (inc)"), 21506 filterText: (filter, activeElements) => (0, import_element44.createInterpolateElement)( 21507 (0, import_i18n30.sprintf)( 21508 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or after: 2024-01-01". */ 21509 (0, import_i18n30.__)( 21510 "<Name>%1$s is on or after: </Name><Value>%2$s</Value>" 21511 ), 21512 filter.name, 21513 activeElements[0].label 21514 ), 21515 filterTextWrappers 21516 ), 21517 filter(item, field, filterValue) { 21518 if (filterValue === void 0) { 21519 return true; 21520 } 21521 const filterDate = (0, import_date.getDate)(filterValue); 21522 const fieldDate = (0, import_date.getDate)(field.getValue({ item })); 21523 return fieldDate >= filterDate; 21524 }, 21525 selection: "single" 21526 }, 21527 { 21528 name: OPERATOR_CONTAINS, 21529 /* translators: DataViews operator name */ 21530 label: (0, import_i18n30.__)("Contains"), 21531 filterText: (filter, activeElements) => (0, import_element44.createInterpolateElement)( 21532 (0, import_i18n30.sprintf)( 21533 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title contains: Hello". */ 21534 (0, import_i18n30.__)("<Name>%1$s contains: </Name><Value>%2$s</Value>"), 21535 filter.name, 21536 activeElements[0].label 21537 ), 21538 filterTextWrappers 21539 ), 21540 filter(item, field, filterValue) { 21541 if (filterValue === void 0) { 21542 return true; 21543 } 21544 const fieldValue = field.getValue({ item }); 21545 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().includes(String(filterValue).toLowerCase()); 21546 }, 21547 selection: "single" 21548 }, 21549 { 21550 name: OPERATOR_NOT_CONTAINS, 21551 /* translators: DataViews operator name */ 21552 label: (0, import_i18n30.__)("Doesn't contain"), 21553 filterText: (filter, activeElements) => (0, import_element44.createInterpolateElement)( 21554 (0, import_i18n30.sprintf)( 21555 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title doesn't contain: Hello". */ 21556 (0, import_i18n30.__)( 21557 "<Name>%1$s doesn't contain: </Name><Value>%2$s</Value>" 21558 ), 21559 filter.name, 21560 activeElements[0].label 21561 ), 21562 filterTextWrappers 21563 ), 21564 filter(item, field, filterValue) { 21565 if (filterValue === void 0) { 21566 return true; 21567 } 21568 const fieldValue = field.getValue({ item }); 21569 return typeof fieldValue === "string" && filterValue && !fieldValue.toLowerCase().includes(String(filterValue).toLowerCase()); 21570 }, 21571 selection: "single" 21572 }, 21573 { 21574 name: OPERATOR_STARTS_WITH, 21575 /* translators: DataViews operator name */ 21576 label: (0, import_i18n30.__)("Starts with"), 21577 filterText: (filter, activeElements) => (0, import_element44.createInterpolateElement)( 21578 (0, import_i18n30.sprintf)( 21579 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title starts with: Hello". */ 21580 (0, import_i18n30.__)("<Name>%1$s starts with: </Name><Value>%2$s</Value>"), 21581 filter.name, 21582 activeElements[0].label 21583 ), 21584 filterTextWrappers 21585 ), 21586 filter(item, field, filterValue) { 21587 if (filterValue === void 0) { 21588 return true; 21589 } 21590 const fieldValue = field.getValue({ item }); 21591 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().startsWith(String(filterValue).toLowerCase()); 21592 }, 21593 selection: "single" 21594 }, 21595 { 21596 name: OPERATOR_ON, 21597 /* translators: DataViews operator name */ 21598 label: (0, import_i18n30.__)("On"), 21599 filterText: (filter, activeElements) => (0, import_element44.createInterpolateElement)( 21600 (0, import_i18n30.sprintf)( 21601 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is: 2024-01-01". */ 21602 (0, import_i18n30.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"), 21603 filter.name, 21604 activeElements[0].label 21605 ), 21606 filterTextWrappers 21607 ), 21608 filter(item, field, filterValue) { 21609 if (filterValue === void 0) { 21610 return true; 21611 } 21612 const filterDate = (0, import_date.getDate)(filterValue); 21613 const fieldDate = (0, import_date.getDate)(field.getValue({ item })); 21614 return filterDate.getTime() === fieldDate.getTime(); 21615 }, 21616 selection: "single" 21617 }, 21618 { 21619 name: OPERATOR_NOT_ON, 21620 /* translators: DataViews operator name */ 21621 label: (0, import_i18n30.__)("Not on"), 21622 filterText: (filter, activeElements) => (0, import_element44.createInterpolateElement)( 21623 (0, import_i18n30.sprintf)( 21624 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is not: 2024-01-01". */ 21625 (0, import_i18n30.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"), 21626 filter.name, 21627 activeElements[0].label 21628 ), 21629 filterTextWrappers 21630 ), 21631 filter(item, field, filterValue) { 21632 if (filterValue === void 0) { 21633 return true; 21634 } 21635 const filterDate = (0, import_date.getDate)(filterValue); 21636 const fieldDate = (0, import_date.getDate)(field.getValue({ item })); 21637 return filterDate.getTime() !== fieldDate.getTime(); 21638 }, 21639 selection: "single" 21640 } 21641 ]; 21642 var getOperatorByName = (name) => OPERATORS.find((op) => op.name === name); 21643 var getAllOperatorNames = () => OPERATORS.map((op) => op.name); 21644 var isSingleSelectionOperator = (name) => OPERATORS.filter((op) => op.selection === "single").some( 21645 (op) => op.name === name 21646 ); 21647 var isRegisteredOperator = (name) => OPERATORS.some((op) => op.name === name); 21648 21649 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs 21650 var import_jsx_runtime82 = __toESM(require_jsx_runtime(), 1); 21651 var ENTER = "Enter"; 21652 var SPACE = " "; 21653 var FilterText = ({ 21654 activeElements, 21655 filterInView, 21656 filter 21657 }) => { 21658 if (activeElements === void 0 || activeElements.length === 0) { 21659 return filter.name; 21660 } 21661 const operator = getOperatorByName(filterInView?.operator); 21662 if (operator !== void 0) { 21663 return operator.filterText(filter, activeElements); 21664 } 21665 return (0, import_i18n31.sprintf)( 21666 /* translators: 1: Filter name e.g.: "Unknown status for Author". */ 21667 (0, import_i18n31.__)("Unknown status for %1$s"), 21668 filter.name 21669 ); 21670 }; 21671 function OperatorSelector({ 21672 filter, 21673 view, 21674 onChangeView 21675 }) { 21676 const operatorOptions = filter.operators?.map((operator) => ({ 21677 value: operator, 21678 label: getOperatorByName(operator)?.label || operator 21679 })); 21680 const currentFilter = view.filters?.find( 21681 (_filter) => _filter.field === filter.field 21682 ); 21683 const value = currentFilter?.operator || filter.operators[0]; 21684 return operatorOptions.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)( 21685 Stack, 21686 { 21687 direction: "row", 21688 gap: "sm", 21689 justify: "flex-start", 21690 className: "dataviews-filters__summary-operators-container", 21691 align: "center", 21692 children: [ 21693 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_components21.FlexItem, { className: "dataviews-filters__summary-operators-filter-name", children: filter.name }), 21694 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)( 21695 import_components21.SelectControl, 21696 { 21697 className: "dataviews-filters__summary-operators-filter-select", 21698 label: (0, import_i18n31.__)("Conditions"), 21699 value, 21700 options: operatorOptions, 21701 onChange: (newValue) => { 21702 const newOperator = newValue; 21703 const currentOperator = currentFilter?.operator; 21704 const newFilters = currentFilter ? [ 21705 ...(view.filters ?? []).map( 21706 (_filter) => { 21707 if (_filter.field === filter.field) { 21708 const currentOpSelectionModel = getOperatorByName( 21709 currentOperator 21710 )?.selection; 21711 const newOpSelectionModel = getOperatorByName( 21712 newOperator 21713 )?.selection; 21714 const shouldResetValue = currentOpSelectionModel !== newOpSelectionModel || [ 21715 currentOpSelectionModel, 21716 newOpSelectionModel 21717 ].includes("custom"); 21718 return { 21719 ..._filter, 21720 value: shouldResetValue ? void 0 : _filter.value, 21721 operator: newOperator 21722 }; 21723 } 21724 return _filter; 21725 } 21726 ) 21727 ] : [ 21728 ...view.filters ?? [], 21729 { 21730 field: filter.field, 21731 operator: newOperator, 21732 value: void 0 21733 } 21734 ]; 21735 onChangeView({ 21736 ...view, 21737 page: 1, 21738 filters: newFilters 21739 }); 21740 }, 21741 size: "small", 21742 variant: "minimal", 21743 hideLabelFromVision: true 21744 } 21745 ) 21746 ] 21747 } 21748 ); 21749 } 21750 function Filter({ 21751 addFilterRef, 21752 openedFilter, 21753 fields, 21754 ...commonProps 21755 }) { 21756 const toggleRef = (0, import_element45.useRef)(null); 21757 const { filter, view, onChangeView } = commonProps; 21758 const filterInView = view.filters?.find( 21759 (f2) => f2.field === filter.field 21760 ); 21761 let activeElements = []; 21762 const field = (0, import_element45.useMemo)(() => { 21763 const currentField = fields.find((f2) => f2.id === filter.field); 21764 if (currentField) { 21765 return { 21766 ...currentField, 21767 // Configure getValue as if Item was a plain object. 21768 // See related input-widget.tsx 21769 getValue: ({ item }) => item[currentField.id] 21770 }; 21771 } 21772 return currentField; 21773 }, [fields, filter.field]); 21774 const { elements } = useElements({ 21775 elements: filter.elements, 21776 getElements: filter.getElements 21777 }); 21778 if (elements.length > 0) { 21779 activeElements = elements.filter((element) => { 21780 if (filter.singleSelection) { 21781 return element.value === filterInView?.value; 21782 } 21783 return filterInView?.value?.includes(element.value); 21784 }); 21785 } else if (Array.isArray(filterInView?.value)) { 21786 const label = filterInView.value.map((v2) => { 21787 const formattedValue = field?.getValueFormatted({ 21788 item: { [field.id]: v2 }, 21789 field 21790 }); 21791 return formattedValue || String(v2); 21792 }); 21793 activeElements = [ 21794 { 21795 value: filterInView.value, 21796 // @ts-ignore 21797 label 21798 } 21799 ]; 21800 } else if (typeof filterInView?.value === "object") { 21801 activeElements = [ 21802 { value: filterInView.value, label: filterInView.value } 21803 ]; 21804 } else if (filterInView?.value !== void 0) { 21805 const label = field !== void 0 ? field.getValueFormatted({ 21806 item: { [field.id]: filterInView.value }, 21807 field 21808 }) : String(filterInView.value); 21809 activeElements = [ 21810 { 21811 value: filterInView.value, 21812 label 21813 } 21814 ]; 21815 } 21816 const isPrimary = filter.isPrimary; 21817 const isLocked = filterInView?.isLocked; 21818 const hasValues = !isLocked && filterInView?.value !== void 0; 21819 const canResetOrRemove = !isLocked && (!isPrimary || hasValues); 21820 const resetOrRemoveLabel = isPrimary ? (0, import_i18n31.__)("Reset") : (0, import_i18n31.__)("Remove"); 21821 return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)( 21822 import_components21.Dropdown, 21823 { 21824 defaultOpen: openedFilter === filter.field, 21825 contentClassName: "dataviews-filters__summary-popover", 21826 popoverProps: { placement: "bottom-start", role: "dialog" }, 21827 onClose: () => { 21828 toggleRef.current?.focus(); 21829 }, 21830 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)("div", { className: "dataviews-filters__summary-chip-container", children: [ 21831 /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)(tooltip_exports.Root, { children: [ 21832 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)( 21833 tooltip_exports.Trigger, 21834 { 21835 render: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)( 21836 "div", 21837 { 21838 className: clsx_default( 21839 "dataviews-filters__summary-chip", 21840 { 21841 "has-reset": canResetOrRemove, 21842 "has-values": hasValues, 21843 "is-not-clickable": isLocked 21844 } 21845 ), 21846 role: "button", 21847 tabIndex: isLocked ? -1 : 0, 21848 onClick: () => { 21849 if (!isLocked) { 21850 onToggle(); 21851 } 21852 }, 21853 onKeyDown: (event) => { 21854 if (!isLocked && [ENTER, SPACE].includes( 21855 event.key 21856 )) { 21857 onToggle(); 21858 event.preventDefault(); 21859 } 21860 }, 21861 "aria-disabled": isLocked, 21862 "aria-pressed": isOpen, 21863 "aria-expanded": isOpen, 21864 ref: toggleRef, 21865 children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)( 21866 FilterText, 21867 { 21868 activeElements, 21869 filterInView, 21870 filter 21871 } 21872 ) 21873 } 21874 ) 21875 } 21876 ), 21877 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(tooltip_exports.Popup, { children: (0, import_i18n31.sprintf)( 21878 /* translators: 1: Filter name. */ 21879 (0, import_i18n31.__)("Filter by: %1$s"), 21880 filter.name.toLowerCase() 21881 ) }) 21882 ] }), 21883 canResetOrRemove && /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)(tooltip_exports.Root, { children: [ 21884 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)( 21885 tooltip_exports.Trigger, 21886 { 21887 render: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)( 21888 "button", 21889 { 21890 className: clsx_default( 21891 "dataviews-filters__summary-chip-remove", 21892 { "has-values": hasValues } 21893 ), 21894 "aria-label": resetOrRemoveLabel, 21895 onClick: () => { 21896 onChangeView({ 21897 ...view, 21898 page: 1, 21899 filters: view.filters?.filter( 21900 (_filter) => _filter.field !== filter.field 21901 ) 21902 }); 21903 if (!isPrimary) { 21904 addFilterRef.current?.focus(); 21905 } else { 21906 toggleRef.current?.focus(); 21907 } 21908 }, 21909 children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_components21.Icon, { icon: close_small_default }) 21910 } 21911 ) 21912 } 21913 ), 21914 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(tooltip_exports.Popup, { children: resetOrRemoveLabel }) 21915 ] }) 21916 ] }), 21917 renderContent: () => { 21918 return /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)(Stack, { direction: "column", justify: "flex-start", children: [ 21919 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(OperatorSelector, { ...commonProps }), 21920 commonProps.filter.hasElements ? /* @__PURE__ */ (0, import_jsx_runtime82.jsx)( 21921 SearchWidget, 21922 { 21923 ...commonProps, 21924 filter: { 21925 ...commonProps.filter, 21926 elements 21927 } 21928 } 21929 ) : /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(InputWidget, { ...commonProps, fields }) 21930 ] }); 21931 } 21932 } 21933 ); 21934 } 21935 21936 // packages/dataviews/build-module/components/dataviews-filters/add-filter.mjs 21937 var import_components22 = __toESM(require_components(), 1); 21938 var import_i18n32 = __toESM(require_i18n(), 1); 21939 var import_element46 = __toESM(require_element(), 1); 21940 var import_jsx_runtime83 = __toESM(require_jsx_runtime(), 1); 21941 var { Menu: Menu4 } = unlock2(import_components22.privateApis); 21942 function AddFilterMenu({ 21943 filters, 21944 view, 21945 onChangeView, 21946 setOpenedFilter, 21947 triggerProps 21948 }) { 21949 const inactiveFilters = filters.filter((filter) => !filter.isVisible); 21950 return /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(Menu4, { children: [ 21951 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(Menu4.TriggerButton, { ...triggerProps }), 21952 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(Menu4.Popover, { children: inactiveFilters.map((filter) => { 21953 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)( 21954 Menu4.Item, 21955 { 21956 onClick: () => { 21957 setOpenedFilter(filter.field); 21958 onChangeView({ 21959 ...view, 21960 page: 1, 21961 filters: [ 21962 ...view.filters || [], 21963 { 21964 field: filter.field, 21965 value: void 0, 21966 operator: filter.operators[0] 21967 } 21968 ] 21969 }); 21970 }, 21971 children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(Menu4.ItemLabel, { children: filter.name }) 21972 }, 21973 filter.field 21974 ); 21975 }) }) 21976 ] }); 21977 } 21978 function AddFilter({ filters, view, onChangeView, setOpenedFilter }, ref) { 21979 if (!filters.length || filters.every(({ isPrimary }) => isPrimary)) { 21980 return null; 21981 } 21982 const inactiveFilters = filters.filter((filter) => !filter.isVisible); 21983 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)( 21984 AddFilterMenu, 21985 { 21986 triggerProps: { 21987 render: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)( 21988 import_components22.Button, 21989 { 21990 accessibleWhenDisabled: true, 21991 size: "compact", 21992 className: "dataviews-filters-button", 21993 variant: "tertiary", 21994 disabled: !inactiveFilters.length, 21995 ref 21996 } 21997 ), 21998 children: (0, import_i18n32.__)("Add filter") 21999 }, 22000 ...{ filters, view, onChangeView, setOpenedFilter } 22001 } 22002 ); 22003 } 22004 var add_filter_default = (0, import_element46.forwardRef)(AddFilter); 22005 22006 // packages/dataviews/build-module/components/dataviews-filters/reset-filters.mjs 22007 var import_components23 = __toESM(require_components(), 1); 22008 var import_i18n33 = __toESM(require_i18n(), 1); 22009 var import_jsx_runtime84 = __toESM(require_jsx_runtime(), 1); 22010 function ResetFilter({ 22011 filters, 22012 view, 22013 onChangeView 22014 }) { 22015 const isPrimary = (field) => filters.some( 22016 (_filter) => _filter.field === field && _filter.isPrimary 22017 ); 22018 const isDisabled = !view.search && !view.filters?.some( 22019 (_filter) => !_filter.isLocked && (_filter.value !== void 0 || !isPrimary(_filter.field)) 22020 ); 22021 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)( 22022 import_components23.Button, 22023 { 22024 disabled: isDisabled, 22025 accessibleWhenDisabled: true, 22026 size: "compact", 22027 variant: "tertiary", 22028 className: "dataviews-filters__reset-button", 22029 onClick: () => { 22030 onChangeView({ 22031 ...view, 22032 page: 1, 22033 search: "", 22034 filters: view.filters?.filter((f2) => !!f2.isLocked) || [] 22035 }); 22036 }, 22037 children: (0, import_i18n33.__)("Reset") 22038 } 22039 ); 22040 } 22041 22042 // packages/dataviews/build-module/components/dataviews-filters/use-filters.mjs 22043 var import_element47 = __toESM(require_element(), 1); 22044 function useFilters(fields, view) { 22045 return (0, import_element47.useMemo)(() => { 22046 const filters = []; 22047 fields.forEach((field) => { 22048 if (field.filterBy === false || !field.hasElements && !field.Edit) { 22049 return; 22050 } 22051 const operators = field.filterBy.operators; 22052 const isPrimary = !!field.filterBy?.isPrimary; 22053 const isLocked = view.filters?.some( 22054 (f2) => f2.field === field.id && !!f2.isLocked 22055 ) ?? false; 22056 filters.push({ 22057 field: field.id, 22058 name: field.label, 22059 elements: field.elements, 22060 getElements: field.getElements, 22061 hasElements: field.hasElements, 22062 singleSelection: operators.some( 22063 (op) => isSingleSelectionOperator(op) 22064 ), 22065 operators, 22066 isVisible: isLocked || isPrimary || !!view.filters?.some( 22067 (f2) => f2.field === field.id && isRegisteredOperator(f2.operator) 22068 ), 22069 isPrimary, 22070 isLocked 22071 }); 22072 }); 22073 filters.sort((a2, b2) => { 22074 if (a2.isLocked && !b2.isLocked) { 22075 return -1; 22076 } 22077 if (!a2.isLocked && b2.isLocked) { 22078 return 1; 22079 } 22080 if (a2.isPrimary && !b2.isPrimary) { 22081 return -1; 22082 } 22083 if (!a2.isPrimary && b2.isPrimary) { 22084 return 1; 22085 } 22086 return a2.name.localeCompare(b2.name); 22087 }); 22088 return filters; 22089 }, [fields, view]); 22090 } 22091 var use_filters_default = useFilters; 22092 22093 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs 22094 var import_jsx_runtime85 = __toESM(require_jsx_runtime(), 1); 22095 function Filters({ className }) { 22096 const { fields, view, onChangeView, openedFilter, setOpenedFilter } = (0, import_element48.useContext)(dataviews_context_default); 22097 const addFilterRef = (0, import_element48.useRef)(null); 22098 const filters = use_filters_default(fields, view); 22099 const addFilter = /* @__PURE__ */ (0, import_jsx_runtime85.jsx)( 22100 add_filter_default, 22101 { 22102 filters, 22103 view, 22104 onChangeView, 22105 ref: addFilterRef, 22106 setOpenedFilter 22107 }, 22108 "add-filter" 22109 ); 22110 const visibleFilters = filters.filter((filter) => filter.isVisible); 22111 if (visibleFilters.length === 0) { 22112 return null; 22113 } 22114 const filterComponents = [ 22115 ...visibleFilters.map((filter) => { 22116 return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)( 22117 Filter, 22118 { 22119 filter, 22120 view, 22121 fields, 22122 onChangeView, 22123 addFilterRef, 22124 openedFilter 22125 }, 22126 filter.field 22127 ); 22128 }), 22129 addFilter 22130 ]; 22131 filterComponents.push( 22132 /* @__PURE__ */ (0, import_jsx_runtime85.jsx)( 22133 ResetFilter, 22134 { 22135 filters, 22136 view, 22137 onChangeView 22138 }, 22139 "reset-filters" 22140 ) 22141 ); 22142 return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)( 22143 Stack, 22144 { 22145 direction: "row", 22146 justify: "flex-start", 22147 gap: "sm", 22148 style: { width: "fit-content" }, 22149 wrap: "wrap", 22150 className, 22151 children: filterComponents 22152 } 22153 ); 22154 } 22155 var filters_default = (0, import_element48.memo)(Filters); 22156 22157 // packages/dataviews/build-module/components/dataviews-filters/toggle.mjs 22158 var import_element49 = __toESM(require_element(), 1); 22159 var import_components24 = __toESM(require_components(), 1); 22160 var import_i18n34 = __toESM(require_i18n(), 1); 22161 var import_jsx_runtime86 = __toESM(require_jsx_runtime(), 1); 22162 function FiltersToggle() { 22163 const { 22164 filters, 22165 view, 22166 onChangeView, 22167 setOpenedFilter, 22168 isShowingFilter, 22169 setIsShowingFilter 22170 } = (0, import_element49.useContext)(dataviews_context_default); 22171 const buttonRef = (0, import_element49.useRef)(null); 22172 const onChangeViewWithFilterVisibility = (0, import_element49.useCallback)( 22173 (_view) => { 22174 onChangeView(_view); 22175 setIsShowingFilter(true); 22176 }, 22177 [onChangeView, setIsShowingFilter] 22178 ); 22179 if (filters.length === 0) { 22180 return null; 22181 } 22182 const hasVisibleFilters = filters.some((filter) => filter.isVisible); 22183 const addFilterButtonProps = { 22184 label: (0, import_i18n34.__)("Add filter"), 22185 "aria-expanded": false, 22186 isPressed: false 22187 }; 22188 const toggleFiltersButtonProps = { 22189 label: (0, import_i18n34._x)("Filter", "verb"), 22190 "aria-expanded": isShowingFilter, 22191 isPressed: isShowingFilter, 22192 onClick: () => { 22193 if (!isShowingFilter) { 22194 setOpenedFilter(null); 22195 } 22196 setIsShowingFilter(!isShowingFilter); 22197 } 22198 }; 22199 const hasPrimaryOrLockedFilters = filters.some( 22200 (filter) => filter.isPrimary || filter.isLocked 22201 ); 22202 const buttonComponent = /* @__PURE__ */ (0, import_jsx_runtime86.jsx)( 22203 import_components24.Button, 22204 { 22205 ref: buttonRef, 22206 className: "dataviews-filters__visibility-toggle", 22207 size: "compact", 22208 icon: funnel_default, 22209 disabled: hasPrimaryOrLockedFilters, 22210 accessibleWhenDisabled: true, 22211 ...hasVisibleFilters ? toggleFiltersButtonProps : addFilterButtonProps 22212 } 22213 ); 22214 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)("div", { className: "dataviews-filters__container-visibility-toggle", children: !hasVisibleFilters ? /* @__PURE__ */ (0, import_jsx_runtime86.jsx)( 22215 AddFilterMenu, 22216 { 22217 filters, 22218 view, 22219 onChangeView: onChangeViewWithFilterVisibility, 22220 setOpenedFilter, 22221 triggerProps: { render: buttonComponent } 22222 } 22223 ) : /* @__PURE__ */ (0, import_jsx_runtime86.jsx)( 22224 FilterVisibilityToggle, 22225 { 22226 buttonRef, 22227 filtersCount: view.filters?.length, 22228 children: buttonComponent 22229 } 22230 ) }); 22231 } 22232 function FilterVisibilityToggle({ 22233 buttonRef, 22234 filtersCount, 22235 children 22236 }) { 22237 (0, import_element49.useEffect)( 22238 () => () => { 22239 buttonRef.current?.focus(); 22240 }, 22241 [buttonRef] 22242 ); 22243 return /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)(import_jsx_runtime86.Fragment, { children: [ 22244 children, 22245 !!filtersCount && /* @__PURE__ */ (0, import_jsx_runtime86.jsx)("span", { className: "dataviews-filters-toggle__count", children: filtersCount }) 22246 ] }); 22247 } 22248 var toggle_default = FiltersToggle; 22249 22250 // packages/dataviews/build-module/components/dataviews-filters/filters-toggled.mjs 22251 var import_element50 = __toESM(require_element(), 1); 22252 var import_jsx_runtime87 = __toESM(require_jsx_runtime(), 1); 22253 function FiltersToggled(props) { 22254 const { isShowingFilter } = (0, import_element50.useContext)(dataviews_context_default); 22255 if (!isShowingFilter) { 22256 return null; 22257 } 22258 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(filters_default, { ...props }); 22259 } 22260 var filters_toggled_default = FiltersToggled; 22261 22262 // packages/dataviews/build-module/components/dataviews-layout/index.mjs 22263 var import_element51 = __toESM(require_element(), 1); 22264 var import_components25 = __toESM(require_components(), 1); 22265 var import_i18n35 = __toESM(require_i18n(), 1); 22266 var import_jsx_runtime88 = __toESM(require_jsx_runtime(), 1); 22267 function DataViewsLayout({ className }) { 22268 const { 22269 actions = [], 22270 data, 22271 fields, 22272 getItemId, 22273 getItemLevel, 22274 hasInitiallyLoaded, 22275 isLoading, 22276 view, 22277 onChangeView, 22278 selection, 22279 onChangeSelection, 22280 setOpenedFilter, 22281 onClickItem, 22282 isItemClickable: isItemClickable2, 22283 renderItemLink, 22284 defaultLayouts: defaultLayouts2, 22285 containerRef, 22286 empty = /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("p", { children: (0, import_i18n35.__)("No results") }) 22287 } = (0, import_element51.useContext)(dataviews_context_default); 22288 const isDelayedInitialLoading = useDelayedLoading(!hasInitiallyLoaded, { 22289 delay: 200 22290 }); 22291 if (!hasInitiallyLoaded) { 22292 if (!isDelayedInitialLoading) { 22293 return null; 22294 } 22295 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("div", { className: "dataviews-loading", children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(import_components25.Spinner, {}) }) }); 22296 } 22297 const ViewComponent = VIEW_LAYOUTS.find( 22298 (v2) => v2.type === view.type && defaultLayouts2[v2.type] 22299 )?.component; 22300 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("div", { className: "dataviews-layout__container", ref: containerRef, children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)( 22301 ViewComponent, 22302 { 22303 className, 22304 actions, 22305 data, 22306 fields, 22307 getItemId, 22308 getItemLevel, 22309 isLoading, 22310 onChangeView, 22311 onChangeSelection, 22312 selection, 22313 setOpenedFilter, 22314 onClickItem, 22315 renderItemLink, 22316 isItemClickable: isItemClickable2, 22317 view, 22318 empty 22319 } 22320 ) }); 22321 } 22322 22323 // packages/dataviews/build-module/components/dataviews-search/index.mjs 22324 var import_i18n36 = __toESM(require_i18n(), 1); 22325 var import_element52 = __toESM(require_element(), 1); 22326 var import_components26 = __toESM(require_components(), 1); 22327 var import_compose10 = __toESM(require_compose(), 1); 22328 var import_jsx_runtime89 = __toESM(require_jsx_runtime(), 1); 22329 var DataViewsSearch = (0, import_element52.memo)(function Search({ label }) { 22330 const { view, onChangeView } = (0, import_element52.useContext)(dataviews_context_default); 22331 const [search, setSearch, debouncedSearch] = (0, import_compose10.useDebouncedInput)( 22332 view.search 22333 ); 22334 (0, import_element52.useEffect)(() => { 22335 if (view.search !== debouncedSearch) { 22336 setSearch(view.search ?? ""); 22337 } 22338 }, [view.search, setSearch]); 22339 const onChangeViewRef = (0, import_element52.useRef)(onChangeView); 22340 const viewRef = (0, import_element52.useRef)(view); 22341 (0, import_element52.useEffect)(() => { 22342 onChangeViewRef.current = onChangeView; 22343 viewRef.current = view; 22344 }, [onChangeView, view]); 22345 (0, import_element52.useEffect)(() => { 22346 if (debouncedSearch !== viewRef.current?.search) { 22347 onChangeViewRef.current({ 22348 ...viewRef.current, 22349 page: view.page ? 1 : void 0, 22350 startPosition: view.startPosition ? 1 : void 0, 22351 search: debouncedSearch 22352 }); 22353 } 22354 }, [debouncedSearch]); 22355 const searchLabel = label || (0, import_i18n36.__)("Search"); 22356 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)( 22357 import_components26.SearchControl, 22358 { 22359 className: "dataviews-search", 22360 onChange: setSearch, 22361 value: search, 22362 label: searchLabel, 22363 placeholder: searchLabel, 22364 size: "compact" 22365 } 22366 ); 22367 }); 22368 var dataviews_search_default = DataViewsSearch; 22369 22370 // packages/dataviews/build-module/components/dataviews-view-config/index.mjs 22371 var import_components27 = __toESM(require_components(), 1); 22372 var import_i18n37 = __toESM(require_i18n(), 1); 22373 var import_element53 = __toESM(require_element(), 1); 22374 var import_warning = __toESM(require_warning(), 1); 22375 var import_compose11 = __toESM(require_compose(), 1); 22376 var import_jsx_runtime90 = __toESM(require_jsx_runtime(), 1); 22377 var { Menu: Menu5 } = unlock2(import_components27.privateApis); 22378 var DATAVIEWS_CONFIG_POPOVER_PROPS = { 22379 className: "dataviews-config__popover", 22380 placement: "bottom-end", 22381 offset: 9 22382 }; 22383 function ViewTypeMenu() { 22384 const { view, onChangeView, defaultLayouts: defaultLayouts2 } = (0, import_element53.useContext)(dataviews_context_default); 22385 const availableLayouts = Object.keys(defaultLayouts2); 22386 if (availableLayouts.length <= 1) { 22387 return null; 22388 } 22389 const activeView = VIEW_LAYOUTS.find((v2) => view.type === v2.type); 22390 return /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(Menu5, { children: [ 22391 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)( 22392 Menu5.TriggerButton, 22393 { 22394 render: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)( 22395 import_components27.Button, 22396 { 22397 size: "compact", 22398 icon: activeView?.icon, 22399 label: (0, import_i18n37.__)("Layout") 22400 } 22401 ) 22402 } 22403 ), 22404 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(Menu5.Popover, { children: availableLayouts.map((layout) => { 22405 const config = VIEW_LAYOUTS.find( 22406 (v2) => v2.type === layout 22407 ); 22408 if (!config) { 22409 return null; 22410 } 22411 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)( 22412 Menu5.RadioItem, 22413 { 22414 value: layout, 22415 name: "view-actions-available-view", 22416 checked: layout === view.type, 22417 hideOnClick: true, 22418 onChange: (e2) => { 22419 switch (e2.target.value) { 22420 case "list": 22421 case "grid": 22422 case "table": 22423 case "pickerGrid": 22424 case "pickerTable": 22425 case "pickerActivity": 22426 case "activity": 22427 const viewWithoutLayout = { ...view }; 22428 if ("layout" in viewWithoutLayout) { 22429 delete viewWithoutLayout.layout; 22430 } 22431 return onChangeView({ 22432 ...viewWithoutLayout, 22433 type: e2.target.value, 22434 ...defaultLayouts2[e2.target.value] 22435 }); 22436 } 22437 (0, import_warning.default)("Invalid dataview"); 22438 }, 22439 children: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(Menu5.ItemLabel, { children: config.label }) 22440 }, 22441 layout 22442 ); 22443 }) }) 22444 ] }); 22445 } 22446 function SortFieldControl() { 22447 const { view, fields, onChangeView } = (0, import_element53.useContext)(dataviews_context_default); 22448 const orderOptions = (0, import_element53.useMemo)(() => { 22449 const sortableFields = fields.filter( 22450 (field) => field.enableSorting !== false 22451 ); 22452 return sortableFields.map((field) => { 22453 return { 22454 label: field.label, 22455 value: field.id 22456 }; 22457 }); 22458 }, [fields]); 22459 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)( 22460 import_components27.SelectControl, 22461 { 22462 __next40pxDefaultSize: true, 22463 label: (0, import_i18n37.__)("Sort by"), 22464 value: view.sort?.field, 22465 options: orderOptions, 22466 onChange: (value) => { 22467 onChangeView({ 22468 ...view, 22469 sort: { 22470 direction: view?.sort?.direction || "desc", 22471 field: value 22472 }, 22473 showLevels: false 22474 }); 22475 } 22476 } 22477 ); 22478 } 22479 function SortDirectionControl() { 22480 const { view, fields, onChangeView } = (0, import_element53.useContext)(dataviews_context_default); 22481 const sortableFields = fields.filter( 22482 (field) => field.enableSorting !== false 22483 ); 22484 if (sortableFields.length === 0) { 22485 return null; 22486 } 22487 let value = view.sort?.direction; 22488 if (!value && view.sort?.field) { 22489 value = "desc"; 22490 } 22491 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)( 22492 import_components27.__experimentalToggleGroupControl, 22493 { 22494 className: "dataviews-view-config__sort-direction", 22495 __next40pxDefaultSize: true, 22496 isBlock: true, 22497 label: (0, import_i18n37.__)("Order"), 22498 value, 22499 onChange: (newDirection) => { 22500 if (newDirection === "asc" || newDirection === "desc") { 22501 onChangeView({ 22502 ...view, 22503 sort: { 22504 direction: newDirection, 22505 field: view.sort?.field || // If there is no field assigned as the sorting field assign the first sortable field. 22506 fields.find( 22507 (field) => field.enableSorting !== false 22508 )?.id || "" 22509 }, 22510 showLevels: false 22511 }); 22512 return; 22513 } 22514 (0, import_warning.default)("Invalid direction"); 22515 }, 22516 children: SORTING_DIRECTIONS.map((direction) => { 22517 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)( 22518 import_components27.__experimentalToggleGroupControlOptionIcon, 22519 { 22520 value: direction, 22521 icon: sortIcons[direction], 22522 label: sortLabels[direction] 22523 }, 22524 direction 22525 ); 22526 }) 22527 } 22528 ); 22529 } 22530 function ItemsPerPageControl() { 22531 const { view, config, onChangeView } = (0, import_element53.useContext)(dataviews_context_default); 22532 const { infiniteScrollEnabled } = view; 22533 if (!config || !config.perPageSizes || config.perPageSizes.length < 2 || config.perPageSizes.length > 6 || infiniteScrollEnabled) { 22534 return null; 22535 } 22536 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)( 22537 import_components27.__experimentalToggleGroupControl, 22538 { 22539 __next40pxDefaultSize: true, 22540 isBlock: true, 22541 label: (0, import_i18n37.__)("Items per page"), 22542 value: view.perPage || 10, 22543 disabled: !view?.sort?.field, 22544 onChange: (newItemsPerPage) => { 22545 const newItemsPerPageNumber = typeof newItemsPerPage === "number" || newItemsPerPage === void 0 ? newItemsPerPage : parseInt(newItemsPerPage, 10); 22546 onChangeView({ 22547 ...view, 22548 perPage: newItemsPerPageNumber, 22549 page: 1 22550 }); 22551 }, 22552 children: config.perPageSizes.map((value) => { 22553 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)( 22554 import_components27.__experimentalToggleGroupControlOption, 22555 { 22556 value, 22557 label: value.toString() 22558 }, 22559 value 22560 ); 22561 }) 22562 } 22563 ); 22564 } 22565 function ResetViewButton() { 22566 const { onReset } = (0, import_element53.useContext)(dataviews_context_default); 22567 if (onReset === void 0) { 22568 return null; 22569 } 22570 const isDisabled = onReset === false; 22571 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)( 22572 import_components27.Button, 22573 { 22574 variant: "tertiary", 22575 size: "compact", 22576 disabled: isDisabled, 22577 accessibleWhenDisabled: true, 22578 className: "dataviews-view-config__reset-button", 22579 onClick: () => { 22580 if (typeof onReset === "function") { 22581 onReset(); 22582 } 22583 }, 22584 children: (0, import_i18n37.__)("Reset view") 22585 } 22586 ); 22587 } 22588 function DataviewsViewConfigDropdown() { 22589 const { view, onReset } = (0, import_element53.useContext)(dataviews_context_default); 22590 const popoverId = (0, import_compose11.useInstanceId)( 22591 _DataViewsViewConfig, 22592 "dataviews-view-config-dropdown" 22593 ); 22594 const activeLayout = VIEW_LAYOUTS.find( 22595 (layout) => layout.type === view.type 22596 ); 22597 const isModified = typeof onReset === "function"; 22598 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)( 22599 import_components27.Dropdown, 22600 { 22601 expandOnMobile: true, 22602 popoverProps: { 22603 ...DATAVIEWS_CONFIG_POPOVER_PROPS, 22604 id: popoverId 22605 }, 22606 renderToggle: ({ onToggle, isOpen }) => { 22607 return /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)("div", { className: "dataviews-view-config__toggle-wrapper", children: [ 22608 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)( 22609 import_components27.Button, 22610 { 22611 size: "compact", 22612 icon: cog_default, 22613 label: (0, import_i18n37._x)( 22614 "View options", 22615 "View is used as a noun" 22616 ), 22617 onClick: onToggle, 22618 "aria-expanded": isOpen ? "true" : "false", 22619 "aria-controls": popoverId 22620 } 22621 ), 22622 isModified && /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("span", { className: "dataviews-view-config__modified-indicator" }) 22623 ] }); 22624 }, 22625 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime90.jsx)( 22626 import_components27.__experimentalDropdownContentWrapper, 22627 { 22628 paddingSize: "medium", 22629 className: "dataviews-config__popover-content-wrapper", 22630 children: /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)( 22631 Stack, 22632 { 22633 direction: "column", 22634 className: "dataviews-view-config", 22635 gap: "xl", 22636 children: [ 22637 /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)( 22638 Stack, 22639 { 22640 direction: "row", 22641 justify: "space-between", 22642 align: "center", 22643 className: "dataviews-view-config__header", 22644 children: [ 22645 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)( 22646 import_components27.__experimentalHeading, 22647 { 22648 level: 2, 22649 className: "dataviews-settings-section__title", 22650 children: (0, import_i18n37.__)("Appearance") 22651 } 22652 ), 22653 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(ResetViewButton, {}) 22654 ] 22655 } 22656 ), 22657 /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(Stack, { direction: "column", gap: "lg", children: [ 22658 /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)( 22659 Stack, 22660 { 22661 direction: "row", 22662 gap: "sm", 22663 className: "dataviews-view-config__sort-controls", 22664 children: [ 22665 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(SortFieldControl, {}), 22666 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(SortDirectionControl, {}) 22667 ] 22668 } 22669 ), 22670 !!activeLayout?.viewConfigOptions && /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(activeLayout.viewConfigOptions, {}), 22671 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(ItemsPerPageControl, {}), 22672 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(PropertiesSection, {}) 22673 ] }) 22674 ] 22675 } 22676 ) 22677 } 22678 ) 22679 } 22680 ); 22681 } 22682 function _DataViewsViewConfig() { 22683 return /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(import_jsx_runtime90.Fragment, { children: [ 22684 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(ViewTypeMenu, {}), 22685 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(DataviewsViewConfigDropdown, {}) 22686 ] }); 22687 } 22688 var DataViewsViewConfig = (0, import_element53.memo)(_DataViewsViewConfig); 22689 var dataviews_view_config_default = DataViewsViewConfig; 22690 22691 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs 22692 var import_components28 = __toESM(require_components(), 1); 22693 var import_element54 = __toESM(require_element(), 1); 22694 22695 // packages/dataviews/build-module/components/dataform-controls/utils/get-custom-validity.mjs 22696 function getCustomValidity(isValid2, validity) { 22697 let customValidity; 22698 if (isValid2?.required && validity?.required) { 22699 customValidity = validity?.required?.message ? validity.required : void 0; 22700 } else if (isValid2?.pattern && validity?.pattern) { 22701 customValidity = validity.pattern; 22702 } else if (isValid2?.min && validity?.min) { 22703 customValidity = validity.min; 22704 } else if (isValid2?.max && validity?.max) { 22705 customValidity = validity.max; 22706 } else if (isValid2?.minLength && validity?.minLength) { 22707 customValidity = validity.minLength; 22708 } else if (isValid2?.maxLength && validity?.maxLength) { 22709 customValidity = validity.maxLength; 22710 } else if (isValid2?.elements && validity?.elements) { 22711 customValidity = validity.elements; 22712 } else if (validity?.custom) { 22713 customValidity = validity.custom; 22714 } 22715 return customValidity; 22716 } 22717 22718 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs 22719 var import_jsx_runtime91 = __toESM(require_jsx_runtime(), 1); 22720 var { ValidatedCheckboxControl } = unlock2(import_components28.privateApis); 22721 function Checkbox({ 22722 field, 22723 onChange, 22724 data, 22725 hideLabelFromVision, 22726 markWhenOptional, 22727 validity 22728 }) { 22729 const { getValue, setValue, label, description, isValid: isValid2 } = field; 22730 const disabled2 = field.isDisabled({ item: data, field }); 22731 const onChangeControl = (0, import_element54.useCallback)(() => { 22732 onChange( 22733 setValue({ item: data, value: !getValue({ item: data }) }) 22734 ); 22735 }, [data, getValue, onChange, setValue]); 22736 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)( 22737 ValidatedCheckboxControl, 22738 { 22739 required: !!field.isValid?.required, 22740 markWhenOptional, 22741 customValidity: getCustomValidity(isValid2, validity), 22742 hidden: hideLabelFromVision, 22743 label, 22744 help: description, 22745 checked: getValue({ item: data }), 22746 onChange: onChangeControl, 22747 disabled: disabled2 22748 } 22749 ); 22750 } 22751 22752 // packages/dataviews/build-module/components/dataform-controls/combobox.mjs 22753 var import_components29 = __toESM(require_components(), 1); 22754 var import_element55 = __toESM(require_element(), 1); 22755 var import_jsx_runtime92 = __toESM(require_jsx_runtime(), 1); 22756 var { ValidatedComboboxControl } = unlock2(import_components29.privateApis); 22757 function Combobox3({ 22758 data, 22759 field, 22760 onChange, 22761 hideLabelFromVision, 22762 validity 22763 }) { 22764 const { label, description, placeholder, getValue, setValue, isValid: isValid2 } = field; 22765 const value = getValue({ item: data }) ?? ""; 22766 const onChangeControl = (0, import_element55.useCallback)( 22767 (newValue) => onChange(setValue({ item: data, value: newValue ?? "" })), 22768 [data, onChange, setValue] 22769 ); 22770 const { elements, isLoading } = useElements({ 22771 elements: field.elements, 22772 getElements: field.getElements 22773 }); 22774 if (isLoading) { 22775 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(import_components29.Spinner, {}); 22776 } 22777 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)( 22778 ValidatedComboboxControl, 22779 { 22780 required: !!field.isValid?.required, 22781 customValidity: getCustomValidity(isValid2, validity), 22782 label, 22783 value, 22784 help: description, 22785 placeholder, 22786 options: elements, 22787 onChange: onChangeControl, 22788 hideLabelFromVision, 22789 allowReset: true, 22790 expandOnFocus: true 22791 } 22792 ); 22793 } 22794 22795 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs 22796 var import_components31 = __toESM(require_components(), 1); 22797 var import_element58 = __toESM(require_element(), 1); 22798 var import_i18n39 = __toESM(require_i18n(), 1); 22799 var import_date3 = __toESM(require_date(), 1); 22800 22801 // packages/dataviews/build-module/components/dataform-controls/utils/relative-date-control.mjs 22802 var import_components30 = __toESM(require_components(), 1); 22803 var import_element56 = __toESM(require_element(), 1); 22804 var import_i18n38 = __toESM(require_i18n(), 1); 22805 var import_jsx_runtime93 = __toESM(require_jsx_runtime(), 1); 22806 var TIME_UNITS_OPTIONS = { 22807 [OPERATOR_IN_THE_PAST]: [ 22808 { value: "days", label: (0, import_i18n38.__)("Days") }, 22809 { value: "weeks", label: (0, import_i18n38.__)("Weeks") }, 22810 { value: "months", label: (0, import_i18n38.__)("Months") }, 22811 { value: "years", label: (0, import_i18n38.__)("Years") } 22812 ], 22813 [OPERATOR_OVER]: [ 22814 { value: "days", label: (0, import_i18n38.__)("Days ago") }, 22815 { value: "weeks", label: (0, import_i18n38.__)("Weeks ago") }, 22816 { value: "months", label: (0, import_i18n38.__)("Months ago") }, 22817 { value: "years", label: (0, import_i18n38.__)("Years ago") } 22818 ] 22819 }; 22820 function RelativeDateControl({ 22821 className, 22822 data, 22823 field, 22824 onChange, 22825 hideLabelFromVision, 22826 operator 22827 }) { 22828 const options = TIME_UNITS_OPTIONS[operator === OPERATOR_IN_THE_PAST ? "inThePast" : "over"]; 22829 const { id, label, description, getValue, setValue } = field; 22830 const disabled2 = field.isDisabled({ item: data, field }); 22831 const fieldValue = getValue({ item: data }); 22832 const { value: relValue = "", unit = options[0].value } = fieldValue && typeof fieldValue === "object" ? fieldValue : {}; 22833 const onChangeValue = (0, import_element56.useCallback)( 22834 (newValue) => onChange( 22835 setValue({ 22836 item: data, 22837 value: { value: Number(newValue), unit } 22838 }) 22839 ), 22840 [onChange, setValue, data, unit] 22841 ); 22842 const onChangeUnit = (0, import_element56.useCallback)( 22843 (newUnit) => onChange( 22844 setValue({ 22845 item: data, 22846 value: { value: relValue, unit: newUnit } 22847 }) 22848 ), 22849 [onChange, setValue, data, relValue] 22850 ); 22851 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)( 22852 import_components30.BaseControl, 22853 { 22854 id, 22855 className: clsx_default(className, "dataviews-controls__relative-date"), 22856 label, 22857 hideLabelFromVision, 22858 help: description, 22859 children: /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(Stack, { direction: "row", gap: "sm", children: [ 22860 /* @__PURE__ */ (0, import_jsx_runtime93.jsx)( 22861 import_components30.__experimentalNumberControl, 22862 { 22863 __next40pxDefaultSize: true, 22864 className: "dataviews-controls__relative-date-number", 22865 spinControls: "none", 22866 min: 1, 22867 step: 1, 22868 value: relValue, 22869 onChange: onChangeValue, 22870 disabled: disabled2 22871 } 22872 ), 22873 /* @__PURE__ */ (0, import_jsx_runtime93.jsx)( 22874 import_components30.SelectControl, 22875 { 22876 className: "dataviews-controls__relative-date-unit", 22877 __next40pxDefaultSize: true, 22878 label: (0, import_i18n38.__)("Unit"), 22879 value: unit, 22880 options, 22881 onChange: onChangeUnit, 22882 hideLabelFromVision: true, 22883 disabled: disabled2 22884 } 22885 ) 22886 ] }) 22887 } 22888 ); 22889 } 22890 22891 // packages/dataviews/build-module/components/dataform-controls/utils/use-disabled-date-matchers.mjs 22892 var import_element57 = __toESM(require_element(), 1); 22893 function useDisabledDateMatchers(isValid2, parseDateFn) { 22894 const minConstraint = typeof isValid2.min?.constraint === "string" ? isValid2.min.constraint : void 0; 22895 const maxConstraint = typeof isValid2.max?.constraint === "string" ? isValid2.max.constraint : void 0; 22896 const disabledMatchers = (0, import_element57.useMemo)(() => { 22897 const matchers = []; 22898 if (minConstraint) { 22899 const minDate = parseDateFn(minConstraint); 22900 if (minDate) { 22901 matchers.push({ before: minDate }); 22902 } 22903 } 22904 if (maxConstraint) { 22905 const maxDate = parseDateFn(maxConstraint); 22906 if (maxDate) { 22907 matchers.push({ after: maxDate }); 22908 } 22909 } 22910 return matchers.length > 0 ? matchers : void 0; 22911 }, [minConstraint, maxConstraint, parseDateFn]); 22912 return { minConstraint, maxConstraint, disabledMatchers }; 22913 } 22914 22915 // packages/dataviews/build-module/field-types/utils/parse-date-time.mjs 22916 var import_date2 = __toESM(require_date(), 1); 22917 function parseDateTime(dateTimeString) { 22918 if (!dateTimeString) { 22919 return null; 22920 } 22921 const parsed = (0, import_date2.getDate)(dateTimeString); 22922 return parsed && isValid(parsed) ? parsed : null; 22923 } 22924 22925 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs 22926 var import_jsx_runtime94 = __toESM(require_jsx_runtime(), 1); 22927 var { DateCalendar, ValidatedInputControl } = unlock2(import_components31.privateApis); 22928 var formatDateTime = (value) => { 22929 if (!value) { 22930 return ""; 22931 } 22932 return (0, import_date3.dateI18n)("Y-m-d\\TH:i", (0, import_date3.getDate)(value)); 22933 }; 22934 function CalendarDateTimeControl({ 22935 data, 22936 field, 22937 onChange, 22938 hideLabelFromVision, 22939 markWhenOptional, 22940 validity, 22941 config 22942 }) { 22943 const { compact } = config || {}; 22944 const { id, label, description, setValue, getValue, isValid: isValid2 } = field; 22945 const disabled2 = field.isDisabled({ item: data, field }); 22946 const fieldValue = getValue({ item: data }); 22947 const value = typeof fieldValue === "string" ? fieldValue : void 0; 22948 const [calendarMonth, setCalendarMonth] = (0, import_element58.useState)(() => { 22949 const parsedDate = parseDateTime(value); 22950 return parsedDate || /* @__PURE__ */ new Date(); 22951 }); 22952 const inputControlRef = (0, import_element58.useRef)(null); 22953 const validationTimeoutRef = (0, import_element58.useRef)(void 0); 22954 const previousFocusRef = (0, import_element58.useRef)(null); 22955 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDateTime); 22956 const onChangeCallback = (0, import_element58.useCallback)( 22957 (newValue) => onChange(setValue({ item: data, value: newValue })), 22958 [data, onChange, setValue] 22959 ); 22960 (0, import_element58.useEffect)(() => { 22961 return () => { 22962 if (validationTimeoutRef.current) { 22963 clearTimeout(validationTimeoutRef.current); 22964 } 22965 }; 22966 }, []); 22967 const onSelectDate = (0, import_element58.useCallback)( 22968 (newDate) => { 22969 let dateTimeValue; 22970 if (newDate) { 22971 const wpDate = (0, import_date3.dateI18n)("Y-m-d", newDate); 22972 let wpTime; 22973 if (value) { 22974 wpTime = (0, import_date3.dateI18n)("H:i", (0, import_date3.getDate)(value)); 22975 } else { 22976 wpTime = (0, import_date3.dateI18n)("H:i", newDate); 22977 } 22978 const finalDateTime = (0, import_date3.getDate)(`$wpDate}T$wpTime}`); 22979 dateTimeValue = finalDateTime.toISOString(); 22980 onChangeCallback(dateTimeValue); 22981 if (validationTimeoutRef.current) { 22982 clearTimeout(validationTimeoutRef.current); 22983 } 22984 } else { 22985 onChangeCallback(void 0); 22986 } 22987 previousFocusRef.current = inputControlRef.current && inputControlRef.current.ownerDocument.activeElement; 22988 validationTimeoutRef.current = setTimeout(() => { 22989 if (inputControlRef.current) { 22990 inputControlRef.current.focus(); 22991 inputControlRef.current.blur(); 22992 onChangeCallback(dateTimeValue); 22993 if (previousFocusRef.current && previousFocusRef.current instanceof HTMLElement) { 22994 previousFocusRef.current.focus(); 22995 } 22996 } 22997 }, 0); 22998 }, 22999 [onChangeCallback, value] 23000 ); 23001 const handleManualDateTimeChange = (0, import_element58.useCallback)( 23002 (newValue) => { 23003 if (newValue) { 23004 const dateTime = (0, import_date3.getDate)(newValue); 23005 onChangeCallback(dateTime.toISOString()); 23006 const parsedDate = parseDateTime(dateTime.toISOString()); 23007 if (parsedDate) { 23008 setCalendarMonth(parsedDate); 23009 } 23010 } else { 23011 onChangeCallback(void 0); 23012 } 23013 }, 23014 [onChangeCallback] 23015 ); 23016 const { format: fieldFormat } = field; 23017 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date3.getSettings)().l10n.startOfWeek; 23018 const { 23019 timezone: { string: timezoneString } 23020 } = (0, import_date3.getSettings)(); 23021 let displayLabel = label; 23022 if (isValid2?.required && !markWhenOptional && !hideLabelFromVision) { 23023 displayLabel = `$label} (${(0, import_i18n39.__)("Required")})`; 23024 } else if (!isValid2?.required && markWhenOptional && !hideLabelFromVision) { 23025 displayLabel = `$label} (${(0, import_i18n39.__)("Optional")})`; 23026 } 23027 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)( 23028 import_components31.BaseControl, 23029 { 23030 id, 23031 label: displayLabel, 23032 help: description, 23033 hideLabelFromVision, 23034 children: /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(Stack, { direction: "column", gap: "lg", children: [ 23035 /* @__PURE__ */ (0, import_jsx_runtime94.jsx)( 23036 ValidatedInputControl, 23037 { 23038 ref: inputControlRef, 23039 __next40pxDefaultSize: true, 23040 required: !!isValid2?.required, 23041 customValidity: getCustomValidity(isValid2, validity), 23042 type: "datetime-local", 23043 label: (0, import_i18n39.__)("Date time"), 23044 hideLabelFromVision: true, 23045 value: formatDateTime(value), 23046 onChange: handleManualDateTimeChange, 23047 disabled: disabled2, 23048 min: minConstraint ? formatDateTime(minConstraint) : void 0, 23049 max: maxConstraint ? formatDateTime(maxConstraint) : void 0 23050 } 23051 ), 23052 !compact && /* @__PURE__ */ (0, import_jsx_runtime94.jsx)( 23053 DateCalendar, 23054 { 23055 style: { width: "100%" }, 23056 selected: value ? parseDateTime(value) || void 0 : void 0, 23057 onSelect: onSelectDate, 23058 month: calendarMonth, 23059 onMonthChange: setCalendarMonth, 23060 timeZone: timezoneString || void 0, 23061 weekStartsOn, 23062 disabled: disabled2 || disabledMatchers 23063 } 23064 ) 23065 ] }) 23066 } 23067 ); 23068 } 23069 function DateTime({ 23070 data, 23071 field, 23072 onChange, 23073 hideLabelFromVision, 23074 markWhenOptional, 23075 operator, 23076 validity, 23077 config 23078 }) { 23079 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) { 23080 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)( 23081 RelativeDateControl, 23082 { 23083 className: "dataviews-controls__datetime", 23084 data, 23085 field, 23086 onChange, 23087 hideLabelFromVision, 23088 operator 23089 } 23090 ); 23091 } 23092 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)( 23093 CalendarDateTimeControl, 23094 { 23095 data, 23096 field, 23097 onChange, 23098 hideLabelFromVision, 23099 markWhenOptional, 23100 validity, 23101 config 23102 } 23103 ); 23104 } 23105 23106 // packages/dataviews/build-module/components/dataform-controls/date.mjs 23107 var import_components32 = __toESM(require_components(), 1); 23108 var import_element59 = __toESM(require_element(), 1); 23109 var import_i18n40 = __toESM(require_i18n(), 1); 23110 var import_date4 = __toESM(require_date(), 1); 23111 var import_jsx_runtime95 = __toESM(require_jsx_runtime(), 1); 23112 var { DateCalendar: DateCalendar2, DateRangeCalendar } = unlock2(import_components32.privateApis); 23113 var DATE_PRESETS = [ 23114 { 23115 id: "today", 23116 label: (0, import_i18n40.__)("Today"), 23117 getValue: () => (0, import_date4.getDate)(null) 23118 }, 23119 { 23120 id: "yesterday", 23121 label: (0, import_i18n40.__)("Yesterday"), 23122 getValue: () => { 23123 const today = (0, import_date4.getDate)(null); 23124 return subDays(today, 1); 23125 } 23126 }, 23127 { 23128 id: "past-week", 23129 label: (0, import_i18n40.__)("Past week"), 23130 getValue: () => { 23131 const today = (0, import_date4.getDate)(null); 23132 return subDays(today, 7); 23133 } 23134 }, 23135 { 23136 id: "past-month", 23137 label: (0, import_i18n40.__)("Past month"), 23138 getValue: () => { 23139 const today = (0, import_date4.getDate)(null); 23140 return subMonths(today, 1); 23141 } 23142 } 23143 ]; 23144 var DATE_RANGE_PRESETS = [ 23145 { 23146 id: "last-7-days", 23147 label: (0, import_i18n40.__)("Last 7 days"), 23148 getValue: () => { 23149 const today = (0, import_date4.getDate)(null); 23150 return [subDays(today, 7), today]; 23151 } 23152 }, 23153 { 23154 id: "last-30-days", 23155 label: (0, import_i18n40.__)("Last 30 days"), 23156 getValue: () => { 23157 const today = (0, import_date4.getDate)(null); 23158 return [subDays(today, 30), today]; 23159 } 23160 }, 23161 { 23162 id: "month-to-date", 23163 label: (0, import_i18n40.__)("Month to date"), 23164 getValue: () => { 23165 const today = (0, import_date4.getDate)(null); 23166 return [startOfMonth(today), today]; 23167 } 23168 }, 23169 { 23170 id: "last-year", 23171 label: (0, import_i18n40.__)("Last year"), 23172 getValue: () => { 23173 const today = (0, import_date4.getDate)(null); 23174 return [subYears(today, 1), today]; 23175 } 23176 }, 23177 { 23178 id: "year-to-date", 23179 label: (0, import_i18n40.__)("Year to date"), 23180 getValue: () => { 23181 const today = (0, import_date4.getDate)(null); 23182 return [startOfYear(today), today]; 23183 } 23184 } 23185 ]; 23186 var parseDate = (dateString) => { 23187 if (!dateString) { 23188 return null; 23189 } 23190 const parsed = (0, import_date4.getDate)(dateString); 23191 return parsed && isValid(parsed) ? parsed : null; 23192 }; 23193 var formatDate = (date) => { 23194 if (!date) { 23195 return ""; 23196 } 23197 return typeof date === "string" ? date : format(date, "yyyy-MM-dd"); 23198 }; 23199 function ValidatedDateControl({ 23200 field, 23201 validity, 23202 inputRefs, 23203 isTouched, 23204 setIsTouched, 23205 children 23206 }) { 23207 const { isValid: isValid2 } = field; 23208 const [customValidity, setCustomValidity] = (0, import_element59.useState)(void 0); 23209 const validateRefs = (0, import_element59.useCallback)(() => { 23210 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs]; 23211 for (const ref of refs) { 23212 const input = ref.current; 23213 if (input && !input.validity.valid) { 23214 setCustomValidity({ 23215 type: "invalid", 23216 message: input.validationMessage 23217 }); 23218 return; 23219 } 23220 } 23221 setCustomValidity(void 0); 23222 }, [inputRefs]); 23223 (0, import_element59.useEffect)(() => { 23224 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs]; 23225 const result = validity ? getCustomValidity(isValid2, validity) : void 0; 23226 for (const ref of refs) { 23227 const input = ref.current; 23228 if (input) { 23229 input.setCustomValidity( 23230 result?.type === "invalid" && result.message ? result.message : "" 23231 ); 23232 } 23233 } 23234 }, [inputRefs, isValid2, validity]); 23235 (0, import_element59.useEffect)(() => { 23236 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs]; 23237 const handleInvalid = (event) => { 23238 event.preventDefault(); 23239 setIsTouched(true); 23240 }; 23241 for (const ref of refs) { 23242 ref.current?.addEventListener("invalid", handleInvalid); 23243 } 23244 return () => { 23245 for (const ref of refs) { 23246 ref.current?.removeEventListener("invalid", handleInvalid); 23247 } 23248 }; 23249 }, [inputRefs, setIsTouched]); 23250 (0, import_element59.useEffect)(() => { 23251 if (!isTouched) { 23252 return; 23253 } 23254 const result = validity ? getCustomValidity(isValid2, validity) : void 0; 23255 if (result) { 23256 setCustomValidity(result); 23257 } else { 23258 validateRefs(); 23259 } 23260 }, [isTouched, isValid2, validity, validateRefs]); 23261 const onBlur = (event) => { 23262 if (isTouched) { 23263 return; 23264 } 23265 if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) { 23266 setIsTouched(true); 23267 } 23268 }; 23269 return /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)("div", { onBlur, children: [ 23270 children, 23271 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)("div", { "aria-live": "polite", children: customValidity && /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)( 23272 "p", 23273 { 23274 className: clsx_default( 23275 "components-validated-control__indicator", 23276 customValidity.type === "invalid" ? "is-invalid" : void 0 23277 ), 23278 children: [ 23279 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)( 23280 import_components32.Icon, 23281 { 23282 className: "components-validated-control__indicator-icon", 23283 icon: error_default, 23284 size: 16, 23285 fill: "currentColor" 23286 } 23287 ), 23288 customValidity.message 23289 ] 23290 } 23291 ) }) 23292 ] }); 23293 } 23294 function CalendarDateControl({ 23295 data, 23296 field, 23297 onChange, 23298 hideLabelFromVision, 23299 markWhenOptional, 23300 validity 23301 }) { 23302 const { 23303 id, 23304 label, 23305 description, 23306 setValue, 23307 getValue, 23308 isValid: isValid2, 23309 format: fieldFormat 23310 } = field; 23311 const disabled2 = field.isDisabled({ item: data, field }); 23312 const [selectedPresetId, setSelectedPresetId] = (0, import_element59.useState)( 23313 null 23314 ); 23315 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek; 23316 const fieldValue = getValue({ item: data }); 23317 const value = typeof fieldValue === "string" ? fieldValue : void 0; 23318 const [calendarMonth, setCalendarMonth] = (0, import_element59.useState)(() => { 23319 const parsedDate = parseDate(value); 23320 return parsedDate || /* @__PURE__ */ new Date(); 23321 }); 23322 const [isTouched, setIsTouched] = (0, import_element59.useState)(false); 23323 const validityTargetRef = (0, import_element59.useRef)(null); 23324 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate); 23325 const onChangeCallback = (0, import_element59.useCallback)( 23326 (newValue) => onChange(setValue({ item: data, value: newValue })), 23327 [data, onChange, setValue] 23328 ); 23329 const onSelectDate = (0, import_element59.useCallback)( 23330 (newDate) => { 23331 const dateValue = newDate ? format(newDate, "yyyy-MM-dd") : void 0; 23332 onChangeCallback(dateValue); 23333 setSelectedPresetId(null); 23334 setIsTouched(true); 23335 }, 23336 [onChangeCallback] 23337 ); 23338 const handlePresetClick = (0, import_element59.useCallback)( 23339 (preset) => { 23340 const presetDate = preset.getValue(); 23341 const dateValue = formatDate(presetDate); 23342 setCalendarMonth(presetDate); 23343 onChangeCallback(dateValue); 23344 setSelectedPresetId(preset.id); 23345 setIsTouched(true); 23346 }, 23347 [onChangeCallback] 23348 ); 23349 const handleManualDateChange = (0, import_element59.useCallback)( 23350 (newValue) => { 23351 onChangeCallback(newValue); 23352 if (newValue) { 23353 const parsedDate = parseDate(newValue); 23354 if (parsedDate) { 23355 setCalendarMonth(parsedDate); 23356 } 23357 } 23358 setSelectedPresetId(null); 23359 setIsTouched(true); 23360 }, 23361 [onChangeCallback] 23362 ); 23363 const { 23364 timezone: { string: timezoneString } 23365 } = (0, import_date4.getSettings)(); 23366 let displayLabel = label; 23367 if (isValid2?.required && !markWhenOptional) { 23368 displayLabel = `$label} (${(0, import_i18n40.__)("Required")})`; 23369 } else if (!isValid2?.required && markWhenOptional) { 23370 displayLabel = `$label} (${(0, import_i18n40.__)("Optional")})`; 23371 } 23372 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)( 23373 ValidatedDateControl, 23374 { 23375 field, 23376 validity, 23377 inputRefs: validityTargetRef, 23378 isTouched, 23379 setIsTouched, 23380 children: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)( 23381 import_components32.BaseControl, 23382 { 23383 id, 23384 className: "dataviews-controls__date", 23385 label: displayLabel, 23386 help: description, 23387 hideLabelFromVision, 23388 children: /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(Stack, { direction: "column", gap: "lg", children: [ 23389 /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)( 23390 Stack, 23391 { 23392 direction: "row", 23393 gap: "sm", 23394 wrap: "wrap", 23395 justify: "flex-start", 23396 children: [ 23397 DATE_PRESETS.map((preset) => { 23398 const isSelected2 = selectedPresetId === preset.id; 23399 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)( 23400 import_components32.Button, 23401 { 23402 className: "dataviews-controls__date-preset", 23403 variant: "tertiary", 23404 isPressed: isSelected2, 23405 size: "small", 23406 disabled: disabled2, 23407 accessibleWhenDisabled: true, 23408 onClick: () => handlePresetClick(preset), 23409 children: preset.label 23410 }, 23411 preset.id 23412 ); 23413 }), 23414 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)( 23415 import_components32.Button, 23416 { 23417 className: "dataviews-controls__date-preset", 23418 variant: "tertiary", 23419 isPressed: !selectedPresetId, 23420 size: "small", 23421 disabled: !!selectedPresetId || disabled2, 23422 accessibleWhenDisabled: true, 23423 children: (0, import_i18n40.__)("Custom") 23424 } 23425 ) 23426 ] 23427 } 23428 ), 23429 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)( 23430 import_components32.__experimentalInputControl, 23431 { 23432 __next40pxDefaultSize: true, 23433 ref: validityTargetRef, 23434 type: "date", 23435 label: (0, import_i18n40.__)("Date"), 23436 hideLabelFromVision: true, 23437 value, 23438 onChange: handleManualDateChange, 23439 required: !!field.isValid?.required, 23440 disabled: disabled2, 23441 min: minConstraint, 23442 max: maxConstraint 23443 } 23444 ), 23445 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)( 23446 DateCalendar2, 23447 { 23448 style: { width: "100%" }, 23449 selected: value ? parseDate(value) || void 0 : void 0, 23450 onSelect: onSelectDate, 23451 month: calendarMonth, 23452 onMonthChange: setCalendarMonth, 23453 timeZone: timezoneString || void 0, 23454 weekStartsOn, 23455 disabled: disabled2 || disabledMatchers, 23456 disableNavigation: disabled2 23457 } 23458 ) 23459 ] }) 23460 } 23461 ) 23462 } 23463 ); 23464 } 23465 function CalendarDateRangeControl({ 23466 data, 23467 field, 23468 onChange, 23469 hideLabelFromVision, 23470 markWhenOptional, 23471 validity 23472 }) { 23473 const { 23474 id, 23475 label, 23476 description, 23477 getValue, 23478 setValue, 23479 isValid: isValid2, 23480 format: fieldFormat 23481 } = field; 23482 const disabled2 = field.isDisabled({ item: data, field }); 23483 let value; 23484 const fieldValue = getValue({ item: data }); 23485 if (Array.isArray(fieldValue) && fieldValue.length === 2 && fieldValue.every((date) => typeof date === "string")) { 23486 value = fieldValue; 23487 } 23488 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek; 23489 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate); 23490 const onChangeCallback = (0, import_element59.useCallback)( 23491 (newValue) => { 23492 onChange( 23493 setValue({ 23494 item: data, 23495 value: newValue 23496 }) 23497 ); 23498 }, 23499 [data, onChange, setValue] 23500 ); 23501 const [selectedPresetId, setSelectedPresetId] = (0, import_element59.useState)( 23502 null 23503 ); 23504 const selectedRange = (0, import_element59.useMemo)(() => { 23505 if (!value) { 23506 return { from: void 0, to: void 0 }; 23507 } 23508 const [from, to] = value; 23509 return { 23510 from: parseDate(from) || void 0, 23511 to: parseDate(to) || void 0 23512 }; 23513 }, [value]); 23514 const [calendarMonth, setCalendarMonth] = (0, import_element59.useState)(() => { 23515 return selectedRange.from || /* @__PURE__ */ new Date(); 23516 }); 23517 const [isTouched, setIsTouched] = (0, import_element59.useState)(false); 23518 const fromInputRef = (0, import_element59.useRef)(null); 23519 const toInputRef = (0, import_element59.useRef)(null); 23520 const updateDateRange = (0, import_element59.useCallback)( 23521 (fromDate, toDate2) => { 23522 if (fromDate && toDate2) { 23523 onChangeCallback([ 23524 formatDate(fromDate), 23525 formatDate(toDate2) 23526 ]); 23527 } else if (!fromDate && !toDate2) { 23528 onChangeCallback(void 0); 23529 } 23530 }, 23531 [onChangeCallback] 23532 ); 23533 const onSelectCalendarRange = (0, import_element59.useCallback)( 23534 (newRange) => { 23535 updateDateRange(newRange?.from, newRange?.to); 23536 setSelectedPresetId(null); 23537 setIsTouched(true); 23538 }, 23539 [updateDateRange] 23540 ); 23541 const handlePresetClick = (0, import_element59.useCallback)( 23542 (preset) => { 23543 const [startDate, endDate] = preset.getValue(); 23544 setCalendarMonth(startDate); 23545 updateDateRange(startDate, endDate); 23546 setSelectedPresetId(preset.id); 23547 setIsTouched(true); 23548 }, 23549 [updateDateRange] 23550 ); 23551 const handleManualDateChange = (0, import_element59.useCallback)( 23552 (fromOrTo, newValue) => { 23553 const [currentFrom, currentTo] = value || [ 23554 void 0, 23555 void 0 23556 ]; 23557 const updatedFrom = fromOrTo === "from" ? newValue : currentFrom; 23558 const updatedTo = fromOrTo === "to" ? newValue : currentTo; 23559 updateDateRange(updatedFrom, updatedTo); 23560 if (newValue) { 23561 const parsedDate = parseDate(newValue); 23562 if (parsedDate) { 23563 setCalendarMonth(parsedDate); 23564 } 23565 } 23566 setSelectedPresetId(null); 23567 setIsTouched(true); 23568 }, 23569 [value, updateDateRange] 23570 ); 23571 const { timezone } = (0, import_date4.getSettings)(); 23572 let displayLabel = label; 23573 if (field.isValid?.required && !markWhenOptional) { 23574 displayLabel = `$label} (${(0, import_i18n40.__)("Required")})`; 23575 } else if (!field.isValid?.required && markWhenOptional) { 23576 displayLabel = `$label} (${(0, import_i18n40.__)("Optional")})`; 23577 } 23578 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)( 23579 ValidatedDateControl, 23580 { 23581 field, 23582 validity, 23583 inputRefs: [fromInputRef, toInputRef], 23584 isTouched, 23585 setIsTouched, 23586 children: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)( 23587 import_components32.BaseControl, 23588 { 23589 id, 23590 className: "dataviews-controls__date", 23591 label: displayLabel, 23592 help: description, 23593 hideLabelFromVision, 23594 children: /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(Stack, { direction: "column", gap: "lg", children: [ 23595 /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)( 23596 Stack, 23597 { 23598 direction: "row", 23599 gap: "sm", 23600 wrap: "wrap", 23601 justify: "flex-start", 23602 children: [ 23603 DATE_RANGE_PRESETS.map((preset) => { 23604 const isSelected2 = selectedPresetId === preset.id; 23605 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)( 23606 import_components32.Button, 23607 { 23608 className: "dataviews-controls__date-preset", 23609 variant: "tertiary", 23610 isPressed: isSelected2, 23611 size: "small", 23612 disabled: disabled2, 23613 accessibleWhenDisabled: true, 23614 onClick: () => handlePresetClick(preset), 23615 children: preset.label 23616 }, 23617 preset.id 23618 ); 23619 }), 23620 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)( 23621 import_components32.Button, 23622 { 23623 className: "dataviews-controls__date-preset", 23624 variant: "tertiary", 23625 isPressed: !selectedPresetId, 23626 size: "small", 23627 accessibleWhenDisabled: true, 23628 disabled: !!selectedPresetId || disabled2, 23629 children: (0, import_i18n40.__)("Custom") 23630 } 23631 ) 23632 ] 23633 } 23634 ), 23635 /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)( 23636 Stack, 23637 { 23638 direction: "row", 23639 gap: "sm", 23640 justify: "space-between", 23641 className: "dataviews-controls__date-range-inputs", 23642 children: [ 23643 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)( 23644 import_components32.__experimentalInputControl, 23645 { 23646 __next40pxDefaultSize: true, 23647 ref: fromInputRef, 23648 type: "date", 23649 label: (0, import_i18n40.__)("From"), 23650 hideLabelFromVision: true, 23651 value: value?.[0], 23652 onChange: (newValue) => handleManualDateChange("from", newValue), 23653 required: !!field.isValid?.required, 23654 disabled: disabled2, 23655 min: minConstraint, 23656 max: maxConstraint 23657 } 23658 ), 23659 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)( 23660 import_components32.__experimentalInputControl, 23661 { 23662 __next40pxDefaultSize: true, 23663 ref: toInputRef, 23664 type: "date", 23665 label: (0, import_i18n40.__)("To"), 23666 hideLabelFromVision: true, 23667 value: value?.[1], 23668 onChange: (newValue) => handleManualDateChange("to", newValue), 23669 required: !!field.isValid?.required, 23670 disabled: disabled2, 23671 min: minConstraint, 23672 max: maxConstraint 23673 } 23674 ) 23675 ] 23676 } 23677 ), 23678 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)( 23679 DateRangeCalendar, 23680 { 23681 style: { width: "100%" }, 23682 selected: selectedRange, 23683 onSelect: onSelectCalendarRange, 23684 month: calendarMonth, 23685 onMonthChange: setCalendarMonth, 23686 timeZone: timezone.string || void 0, 23687 weekStartsOn, 23688 disabled: disabled2 || disabledMatchers 23689 } 23690 ) 23691 ] }) 23692 } 23693 ) 23694 } 23695 ); 23696 } 23697 function DateControl({ 23698 data, 23699 field, 23700 onChange, 23701 hideLabelFromVision, 23702 markWhenOptional, 23703 operator, 23704 validity 23705 }) { 23706 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) { 23707 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)( 23708 RelativeDateControl, 23709 { 23710 className: "dataviews-controls__date", 23711 data, 23712 field, 23713 onChange, 23714 hideLabelFromVision, 23715 operator 23716 } 23717 ); 23718 } 23719 if (operator === OPERATOR_BETWEEN) { 23720 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)( 23721 CalendarDateRangeControl, 23722 { 23723 data, 23724 field, 23725 onChange, 23726 hideLabelFromVision, 23727 markWhenOptional, 23728 validity 23729 } 23730 ); 23731 } 23732 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)( 23733 CalendarDateControl, 23734 { 23735 data, 23736 field, 23737 onChange, 23738 hideLabelFromVision, 23739 markWhenOptional, 23740 validity 23741 } 23742 ); 23743 } 23744 23745 // packages/dataviews/build-module/components/dataform-controls/select.mjs 23746 var import_components33 = __toESM(require_components(), 1); 23747 var import_element60 = __toESM(require_element(), 1); 23748 var import_jsx_runtime96 = __toESM(require_jsx_runtime(), 1); 23749 var { ValidatedSelectControl } = unlock2(import_components33.privateApis); 23750 function Select({ 23751 data, 23752 field, 23753 onChange, 23754 hideLabelFromVision, 23755 markWhenOptional, 23756 validity 23757 }) { 23758 const { type, label, description, getValue, setValue, isValid: isValid2 } = field; 23759 const disabled2 = field.isDisabled({ item: data, field }); 23760 const isMultiple = type === "array"; 23761 const value = getValue({ item: data }) ?? (isMultiple ? [] : ""); 23762 const onChangeControl = (0, import_element60.useCallback)( 23763 (newValue) => onChange(setValue({ item: data, value: newValue })), 23764 [data, onChange, setValue] 23765 ); 23766 const { elements, isLoading } = useElements({ 23767 elements: field.elements, 23768 getElements: field.getElements 23769 }); 23770 if (isLoading) { 23771 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(import_components33.Spinner, {}); 23772 } 23773 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)( 23774 ValidatedSelectControl, 23775 { 23776 required: !!field.isValid?.required, 23777 markWhenOptional, 23778 customValidity: getCustomValidity(isValid2, validity), 23779 label, 23780 value, 23781 help: description, 23782 options: elements, 23783 onChange: onChangeControl, 23784 __next40pxDefaultSize: true, 23785 hideLabelFromVision, 23786 multiple: isMultiple, 23787 disabled: disabled2 23788 } 23789 ); 23790 } 23791 23792 // packages/dataviews/build-module/components/dataform-controls/adaptive-select.mjs 23793 var import_jsx_runtime97 = __toESM(require_jsx_runtime(), 1); 23794 var ELEMENTS_THRESHOLD = 10; 23795 function AdaptiveSelect(props) { 23796 const { field } = props; 23797 const { elements } = useElements({ 23798 elements: field.elements, 23799 getElements: field.getElements 23800 }); 23801 if (elements.length >= ELEMENTS_THRESHOLD) { 23802 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(Combobox3, { ...props }); 23803 } 23804 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(Select, { ...props }); 23805 } 23806 23807 // packages/dataviews/build-module/components/dataform-controls/email.mjs 23808 var import_components35 = __toESM(require_components(), 1); 23809 23810 // packages/dataviews/build-module/components/dataform-controls/utils/validated-input.mjs 23811 var import_components34 = __toESM(require_components(), 1); 23812 var import_element61 = __toESM(require_element(), 1); 23813 var import_jsx_runtime98 = __toESM(require_jsx_runtime(), 1); 23814 var { ValidatedInputControl: ValidatedInputControl2 } = unlock2(import_components34.privateApis); 23815 function ValidatedText({ 23816 data, 23817 field, 23818 onChange, 23819 hideLabelFromVision, 23820 markWhenOptional, 23821 type, 23822 prefix, 23823 suffix, 23824 validity 23825 }) { 23826 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field; 23827 const value = getValue({ item: data }); 23828 const disabled2 = field.isDisabled({ item: data, field }); 23829 const onChangeControl = (0, import_element61.useCallback)( 23830 (newValue) => onChange( 23831 setValue({ 23832 item: data, 23833 value: newValue 23834 }) 23835 ), 23836 [data, setValue, onChange] 23837 ); 23838 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)( 23839 ValidatedInputControl2, 23840 { 23841 required: !!isValid2.required, 23842 markWhenOptional, 23843 customValidity: getCustomValidity(isValid2, validity), 23844 label, 23845 placeholder, 23846 value: value ?? "", 23847 help: description, 23848 onChange: onChangeControl, 23849 hideLabelFromVision, 23850 type, 23851 prefix, 23852 suffix, 23853 disabled: disabled2, 23854 pattern: isValid2.pattern ? isValid2.pattern.constraint : void 0, 23855 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0, 23856 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0, 23857 __next40pxDefaultSize: true 23858 } 23859 ); 23860 } 23861 23862 // packages/dataviews/build-module/components/dataform-controls/email.mjs 23863 var import_jsx_runtime99 = __toESM(require_jsx_runtime(), 1); 23864 function Email({ 23865 data, 23866 field, 23867 onChange, 23868 hideLabelFromVision, 23869 markWhenOptional, 23870 validity 23871 }) { 23872 return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)( 23873 ValidatedText, 23874 { 23875 ...{ 23876 data, 23877 field, 23878 onChange, 23879 hideLabelFromVision, 23880 markWhenOptional, 23881 validity, 23882 type: "email", 23883 prefix: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(import_components35.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(import_components35.Icon, { icon: envelope_default }) }) 23884 } 23885 } 23886 ); 23887 } 23888 23889 // packages/dataviews/build-module/components/dataform-controls/telephone.mjs 23890 var import_components36 = __toESM(require_components(), 1); 23891 var import_jsx_runtime100 = __toESM(require_jsx_runtime(), 1); 23892 function Telephone({ 23893 data, 23894 field, 23895 onChange, 23896 hideLabelFromVision, 23897 markWhenOptional, 23898 validity 23899 }) { 23900 return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)( 23901 ValidatedText, 23902 { 23903 ...{ 23904 data, 23905 field, 23906 onChange, 23907 hideLabelFromVision, 23908 markWhenOptional, 23909 validity, 23910 type: "tel", 23911 prefix: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(import_components36.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(import_components36.Icon, { icon: mobile_default }) }) 23912 } 23913 } 23914 ); 23915 } 23916 23917 // packages/dataviews/build-module/components/dataform-controls/url.mjs 23918 var import_components37 = __toESM(require_components(), 1); 23919 var import_jsx_runtime101 = __toESM(require_jsx_runtime(), 1); 23920 function Url({ 23921 data, 23922 field, 23923 onChange, 23924 hideLabelFromVision, 23925 markWhenOptional, 23926 validity 23927 }) { 23928 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)( 23929 ValidatedText, 23930 { 23931 ...{ 23932 data, 23933 field, 23934 onChange, 23935 hideLabelFromVision, 23936 markWhenOptional, 23937 validity, 23938 type: "url", 23939 prefix: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_components37.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_components37.Icon, { icon: link_default }) }) 23940 } 23941 } 23942 ); 23943 } 23944 23945 // packages/dataviews/build-module/components/dataform-controls/utils/validated-number.mjs 23946 var import_components38 = __toESM(require_components(), 1); 23947 var import_element62 = __toESM(require_element(), 1); 23948 var import_i18n41 = __toESM(require_i18n(), 1); 23949 var import_jsx_runtime102 = __toESM(require_jsx_runtime(), 1); 23950 var { ValidatedNumberControl } = unlock2(import_components38.privateApis); 23951 function toNumberOrEmpty(value) { 23952 if (value === "" || value === void 0) { 23953 return ""; 23954 } 23955 const number = Number(value); 23956 return Number.isFinite(number) ? number : ""; 23957 } 23958 function BetweenControls({ 23959 value, 23960 onChange, 23961 hideLabelFromVision, 23962 step 23963 }) { 23964 const [min2 = "", max2 = ""] = value; 23965 const onChangeMin = (0, import_element62.useCallback)( 23966 (newValue) => onChange([toNumberOrEmpty(newValue), max2]), 23967 [onChange, max2] 23968 ); 23969 const onChangeMax = (0, import_element62.useCallback)( 23970 (newValue) => onChange([min2, toNumberOrEmpty(newValue)]), 23971 [onChange, min2] 23972 ); 23973 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)( 23974 import_components38.BaseControl, 23975 { 23976 help: (0, import_i18n41.__)("The max. value must be greater than the min. value."), 23977 children: /* @__PURE__ */ (0, import_jsx_runtime102.jsxs)(import_components38.Flex, { direction: "row", gap: 4, children: [ 23978 /* @__PURE__ */ (0, import_jsx_runtime102.jsx)( 23979 import_components38.__experimentalNumberControl, 23980 { 23981 label: (0, import_i18n41.__)("Min."), 23982 value: min2, 23983 max: max2 ? Number(max2) - step : void 0, 23984 onChange: onChangeMin, 23985 __next40pxDefaultSize: true, 23986 hideLabelFromVision, 23987 step 23988 } 23989 ), 23990 /* @__PURE__ */ (0, import_jsx_runtime102.jsx)( 23991 import_components38.__experimentalNumberControl, 23992 { 23993 label: (0, import_i18n41.__)("Max."), 23994 value: max2, 23995 min: min2 ? Number(min2) + step : void 0, 23996 onChange: onChangeMax, 23997 __next40pxDefaultSize: true, 23998 hideLabelFromVision, 23999 step 24000 } 24001 ) 24002 ] }) 24003 } 24004 ); 24005 } 24006 function ValidatedNumber({ 24007 data, 24008 field, 24009 onChange, 24010 hideLabelFromVision, 24011 markWhenOptional, 24012 operator, 24013 validity 24014 }) { 24015 const decimals = field.format?.decimals ?? 0; 24016 const step = Math.pow(10, Math.abs(decimals) * -1); 24017 const { label, description, getValue, setValue, isValid: isValid2 } = field; 24018 const value = getValue({ item: data }) ?? ""; 24019 const disabled2 = field.isDisabled({ item: data, field }); 24020 const onChangeControl = (0, import_element62.useCallback)( 24021 (newValue) => { 24022 onChange( 24023 setValue({ 24024 item: data, 24025 // Do not convert an empty string or undefined to a number, 24026 // otherwise there's a mismatch between the UI control (empty) 24027 // and the data relied by onChange (0). 24028 value: ["", void 0].includes(newValue) ? void 0 : Number(newValue) 24029 }) 24030 ); 24031 }, 24032 [data, onChange, setValue] 24033 ); 24034 const onChangeBetweenControls = (0, import_element62.useCallback)( 24035 (newValue) => { 24036 onChange( 24037 setValue({ 24038 item: data, 24039 value: newValue 24040 }) 24041 ); 24042 }, 24043 [data, onChange, setValue] 24044 ); 24045 if (operator === OPERATOR_BETWEEN) { 24046 let valueBetween = ["", ""]; 24047 if (Array.isArray(value) && value.length === 2 && value.every( 24048 (element) => typeof element === "number" || element === "" 24049 )) { 24050 valueBetween = value; 24051 } 24052 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)( 24053 BetweenControls, 24054 { 24055 value: valueBetween, 24056 onChange: onChangeBetweenControls, 24057 hideLabelFromVision, 24058 step 24059 } 24060 ); 24061 } 24062 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)( 24063 ValidatedNumberControl, 24064 { 24065 required: !!isValid2.required, 24066 markWhenOptional, 24067 customValidity: getCustomValidity(isValid2, validity), 24068 label, 24069 help: description, 24070 value, 24071 onChange: onChangeControl, 24072 __next40pxDefaultSize: true, 24073 hideLabelFromVision, 24074 step, 24075 min: isValid2.min ? isValid2.min.constraint : void 0, 24076 max: isValid2.max ? isValid2.max.constraint : void 0, 24077 disabled: disabled2 24078 } 24079 ); 24080 } 24081 24082 // packages/dataviews/build-module/components/dataform-controls/integer.mjs 24083 var import_jsx_runtime103 = __toESM(require_jsx_runtime(), 1); 24084 function Integer(props) { 24085 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(ValidatedNumber, { ...props }); 24086 } 24087 24088 // packages/dataviews/build-module/components/dataform-controls/number.mjs 24089 var import_jsx_runtime104 = __toESM(require_jsx_runtime(), 1); 24090 function Number2(props) { 24091 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(ValidatedNumber, { ...props }); 24092 } 24093 24094 // packages/dataviews/build-module/components/dataform-controls/radio.mjs 24095 var import_components39 = __toESM(require_components(), 1); 24096 var import_element63 = __toESM(require_element(), 1); 24097 var import_jsx_runtime105 = __toESM(require_jsx_runtime(), 1); 24098 var { ValidatedRadioControl } = unlock2(import_components39.privateApis); 24099 function Radio({ 24100 data, 24101 field, 24102 onChange, 24103 hideLabelFromVision, 24104 markWhenOptional, 24105 validity 24106 }) { 24107 const { label, description, getValue, setValue, isValid: isValid2 } = field; 24108 const disabled2 = field.isDisabled({ item: data, field }); 24109 const { elements, isLoading } = useElements({ 24110 elements: field.elements, 24111 getElements: field.getElements 24112 }); 24113 const value = getValue({ item: data }); 24114 const onChangeControl = (0, import_element63.useCallback)( 24115 (newValue) => onChange(setValue({ item: data, value: newValue })), 24116 [data, onChange, setValue] 24117 ); 24118 if (isLoading) { 24119 return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(import_components39.Spinner, {}); 24120 } 24121 return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)( 24122 ValidatedRadioControl, 24123 { 24124 required: !!field.isValid?.required, 24125 markWhenOptional, 24126 customValidity: getCustomValidity(isValid2, validity), 24127 label, 24128 help: description, 24129 onChange: onChangeControl, 24130 options: elements, 24131 selected: value, 24132 hideLabelFromVision, 24133 disabled: disabled2 24134 } 24135 ); 24136 } 24137 24138 // packages/dataviews/build-module/components/dataform-controls/text.mjs 24139 var import_element64 = __toESM(require_element(), 1); 24140 var import_jsx_runtime106 = __toESM(require_jsx_runtime(), 1); 24141 function Text({ 24142 data, 24143 field, 24144 onChange, 24145 hideLabelFromVision, 24146 markWhenOptional, 24147 config, 24148 validity 24149 }) { 24150 const { prefix, suffix } = config || {}; 24151 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)( 24152 ValidatedText, 24153 { 24154 ...{ 24155 data, 24156 field, 24157 onChange, 24158 hideLabelFromVision, 24159 markWhenOptional, 24160 validity, 24161 prefix: prefix ? (0, import_element64.createElement)(prefix) : void 0, 24162 suffix: suffix ? (0, import_element64.createElement)(suffix) : void 0 24163 } 24164 } 24165 ); 24166 } 24167 24168 // packages/dataviews/build-module/components/dataform-controls/toggle.mjs 24169 var import_components40 = __toESM(require_components(), 1); 24170 var import_element65 = __toESM(require_element(), 1); 24171 var import_jsx_runtime107 = __toESM(require_jsx_runtime(), 1); 24172 var { ValidatedToggleControl } = unlock2(import_components40.privateApis); 24173 function Toggle({ 24174 field, 24175 onChange, 24176 data, 24177 hideLabelFromVision, 24178 markWhenOptional, 24179 validity 24180 }) { 24181 const { label, description, getValue, setValue, isValid: isValid2 } = field; 24182 const disabled2 = field.isDisabled({ item: data, field }); 24183 const onChangeControl = (0, import_element65.useCallback)(() => { 24184 onChange( 24185 setValue({ item: data, value: !getValue({ item: data }) }) 24186 ); 24187 }, [onChange, setValue, data, getValue]); 24188 return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)( 24189 ValidatedToggleControl, 24190 { 24191 required: !!isValid2.required, 24192 markWhenOptional, 24193 customValidity: getCustomValidity(isValid2, validity), 24194 hidden: hideLabelFromVision, 24195 label, 24196 help: description, 24197 checked: getValue({ item: data }), 24198 onChange: onChangeControl, 24199 disabled: disabled2 24200 } 24201 ); 24202 } 24203 24204 // packages/dataviews/build-module/components/dataform-controls/textarea.mjs 24205 var import_components41 = __toESM(require_components(), 1); 24206 var import_element66 = __toESM(require_element(), 1); 24207 var import_jsx_runtime108 = __toESM(require_jsx_runtime(), 1); 24208 var { ValidatedTextareaControl } = unlock2(import_components41.privateApis); 24209 function Textarea({ 24210 data, 24211 field, 24212 onChange, 24213 hideLabelFromVision, 24214 markWhenOptional, 24215 config, 24216 validity 24217 }) { 24218 const { rows = 4 } = config || {}; 24219 const disabled2 = field.isDisabled({ item: data, field }); 24220 const { label, placeholder, description, setValue, isValid: isValid2 } = field; 24221 const value = field.getValue({ item: data }); 24222 const onChangeControl = (0, import_element66.useCallback)( 24223 (newValue) => onChange(setValue({ item: data, value: newValue })), 24224 [data, onChange, setValue] 24225 ); 24226 return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)( 24227 ValidatedTextareaControl, 24228 { 24229 required: !!isValid2.required, 24230 markWhenOptional, 24231 customValidity: getCustomValidity(isValid2, validity), 24232 label, 24233 placeholder, 24234 value: value ?? "", 24235 help: description, 24236 onChange: onChangeControl, 24237 rows, 24238 disabled: disabled2, 24239 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0, 24240 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0, 24241 __next40pxDefaultSize: true, 24242 hideLabelFromVision 24243 } 24244 ); 24245 } 24246 24247 // packages/dataviews/build-module/components/dataform-controls/toggle-group.mjs 24248 var import_components42 = __toESM(require_components(), 1); 24249 var import_element67 = __toESM(require_element(), 1); 24250 var import_jsx_runtime109 = __toESM(require_jsx_runtime(), 1); 24251 var { ValidatedToggleGroupControl } = unlock2(import_components42.privateApis); 24252 function ToggleGroup({ 24253 data, 24254 field, 24255 onChange, 24256 hideLabelFromVision, 24257 markWhenOptional, 24258 validity 24259 }) { 24260 const { getValue, setValue, isValid: isValid2 } = field; 24261 const disabled2 = field.isDisabled({ item: data, field }); 24262 const value = getValue({ item: data }); 24263 const onChangeControl = (0, import_element67.useCallback)( 24264 (newValue) => onChange(setValue({ item: data, value: newValue })), 24265 [data, onChange, setValue] 24266 ); 24267 const { elements, isLoading } = useElements({ 24268 elements: field.elements, 24269 getElements: field.getElements 24270 }); 24271 if (isLoading) { 24272 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(import_components42.Spinner, {}); 24273 } 24274 if (elements.length === 0) { 24275 return null; 24276 } 24277 const selectedOption = elements.find((el) => el.value === value); 24278 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)( 24279 ValidatedToggleGroupControl, 24280 { 24281 required: !!field.isValid?.required, 24282 markWhenOptional, 24283 customValidity: getCustomValidity(isValid2, validity), 24284 __next40pxDefaultSize: true, 24285 isBlock: true, 24286 label: field.label, 24287 help: selectedOption?.description || field.description, 24288 onChange: onChangeControl, 24289 value, 24290 hideLabelFromVision, 24291 children: elements.map((el) => /* @__PURE__ */ (0, import_jsx_runtime109.jsx)( 24292 import_components42.__experimentalToggleGroupControlOption, 24293 { 24294 label: el.label, 24295 value: el.value, 24296 disabled: disabled2 24297 }, 24298 el.value 24299 )) 24300 } 24301 ); 24302 } 24303 24304 // packages/dataviews/build-module/components/dataform-controls/array.mjs 24305 var import_components43 = __toESM(require_components(), 1); 24306 var import_element68 = __toESM(require_element(), 1); 24307 var import_jsx_runtime110 = __toESM(require_jsx_runtime(), 1); 24308 var { ValidatedFormTokenField } = unlock2(import_components43.privateApis); 24309 function ArrayControl({ 24310 data, 24311 field, 24312 onChange, 24313 hideLabelFromVision, 24314 markWhenOptional, 24315 validity 24316 }) { 24317 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field; 24318 const value = getValue({ item: data }); 24319 const disabled2 = field.isDisabled({ item: data, field }); 24320 const { elements, isLoading } = useElements({ 24321 elements: field.elements, 24322 getElements: field.getElements 24323 }); 24324 const arrayValueAsElements = (0, import_element68.useMemo)( 24325 () => Array.isArray(value) ? value.map((token) => { 24326 const element = elements?.find( 24327 (suggestion) => suggestion.value === token 24328 ); 24329 return element || { value: token, label: token }; 24330 }) : [], 24331 [value, elements] 24332 ); 24333 const onChangeControl = (0, import_element68.useCallback)( 24334 (tokens) => { 24335 const valueTokens = tokens.map((token) => { 24336 if (typeof token === "object" && "value" in token) { 24337 return token.value; 24338 } 24339 return token; 24340 }); 24341 onChange(setValue({ item: data, value: valueTokens })); 24342 }, 24343 [onChange, setValue, data] 24344 ); 24345 if (isLoading) { 24346 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(import_components43.Spinner, {}); 24347 } 24348 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)( 24349 ValidatedFormTokenField, 24350 { 24351 required: !!isValid2?.required, 24352 markWhenOptional, 24353 customValidity: getCustomValidity(isValid2, validity), 24354 label: hideLabelFromVision ? void 0 : label, 24355 value: arrayValueAsElements, 24356 onChange: onChangeControl, 24357 placeholder, 24358 suggestions: elements?.map((element) => element.value), 24359 disabled: disabled2, 24360 __experimentalValidateInput: (token) => { 24361 if (field.isValid?.elements && elements) { 24362 return elements.some( 24363 (element) => element.value === token || element.label === token 24364 ); 24365 } 24366 return true; 24367 }, 24368 __experimentalExpandOnFocus: elements && elements.length > 0, 24369 help: description ?? (field.isValid?.elements ? "" : void 0), 24370 displayTransform: (token) => { 24371 if (typeof token === "object" && "label" in token) { 24372 return token.label; 24373 } 24374 if (typeof token === "string" && elements) { 24375 const element = elements.find( 24376 (el) => el.value === token 24377 ); 24378 return element?.label || token; 24379 } 24380 return token; 24381 }, 24382 __experimentalRenderItem: ({ item }) => { 24383 if (typeof item === "string" && elements) { 24384 const element = elements.find( 24385 (el) => el.value === item 24386 ); 24387 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("span", { children: element?.label || item }); 24388 } 24389 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("span", { children: item }); 24390 } 24391 } 24392 ); 24393 } 24394 24395 // node_modules/colord/index.mjs 24396 var r2 = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }; 24397 var t = function(r3) { 24398 return "string" == typeof r3 ? r3.length > 0 : "number" == typeof r3; 24399 }; 24400 var n = function(r3, t2, n2) { 24401 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = Math.pow(10, t2)), Math.round(n2 * r3) / n2 + 0; 24402 }; 24403 var e = function(r3, t2, n2) { 24404 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = 1), r3 > n2 ? n2 : r3 > t2 ? r3 : t2; 24405 }; 24406 var u = function(r3) { 24407 return (r3 = isFinite(r3) ? r3 % 360 : 0) > 0 ? r3 : r3 + 360; 24408 }; 24409 var a = function(r3) { 24410 return { r: e(r3.r, 0, 255), g: e(r3.g, 0, 255), b: e(r3.b, 0, 255), a: e(r3.a) }; 24411 }; 24412 var o = function(r3) { 24413 return { r: n(r3.r), g: n(r3.g), b: n(r3.b), a: n(r3.a, 3) }; 24414 }; 24415 var i = /^#([0-9a-f]{3,8})$/i; 24416 var s = function(r3) { 24417 var t2 = r3.toString(16); 24418 return t2.length < 2 ? "0" + t2 : t2; 24419 }; 24420 var h = function(r3) { 24421 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; 24422 return { h: 60 * (i2 < 0 ? i2 + 6 : i2), s: a2 ? o2 / a2 * 100 : 0, v: a2 / 255 * 100, a: u2 }; 24423 }; 24424 var b = function(r3) { 24425 var t2 = r3.h, n2 = r3.s, e2 = r3.v, u2 = r3.a; 24426 t2 = t2 / 360 * 6, n2 /= 100, e2 /= 100; 24427 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; 24428 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 }; 24429 }; 24430 var g = function(r3) { 24431 return { h: u(r3.h), s: e(r3.s, 0, 100), l: e(r3.l, 0, 100), a: e(r3.a) }; 24432 }; 24433 var d = function(r3) { 24434 return { h: n(r3.h), s: n(r3.s), l: n(r3.l), a: n(r3.a, 3) }; 24435 }; 24436 var f = function(r3) { 24437 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 })); 24438 var t2, n2, e2; 24439 }; 24440 var c = function(r3) { 24441 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 }; 24442 var t2, n2, e2, u2; 24443 }; 24444 var l = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; 24445 var p = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; 24446 var v = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; 24447 var m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; 24448 var y = { string: [[function(r3) { 24449 var t2 = i.exec(r3); 24450 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; 24451 }, "hex"], [function(r3) { 24452 var t2 = v.exec(r3) || m.exec(r3); 24453 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; 24454 }, "rgb"], [function(t2) { 24455 var n2 = l.exec(t2) || p.exec(t2); 24456 if (!n2) return null; 24457 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) }); 24458 return f(a2); 24459 }, "hsl"]], object: [[function(r3) { 24460 var n2 = r3.r, e2 = r3.g, u2 = r3.b, o2 = r3.a, i2 = void 0 === o2 ? 1 : o2; 24461 return t(n2) && t(e2) && t(u2) ? a({ r: Number(n2), g: Number(e2), b: Number(u2), a: Number(i2) }) : null; 24462 }, "rgb"], [function(r3) { 24463 var n2 = r3.h, e2 = r3.s, u2 = r3.l, a2 = r3.a, o2 = void 0 === a2 ? 1 : a2; 24464 if (!t(n2) || !t(e2) || !t(u2)) return null; 24465 var i2 = g({ h: Number(n2), s: Number(e2), l: Number(u2), a: Number(o2) }); 24466 return f(i2); 24467 }, "hsl"], [function(r3) { 24468 var n2 = r3.h, a2 = r3.s, o2 = r3.v, i2 = r3.a, s2 = void 0 === i2 ? 1 : i2; 24469 if (!t(n2) || !t(a2) || !t(o2)) return null; 24470 var h2 = (function(r4) { 24471 return { h: u(r4.h), s: e(r4.s, 0, 100), v: e(r4.v, 0, 100), a: e(r4.a) }; 24472 })({ h: Number(n2), s: Number(a2), v: Number(o2), a: Number(s2) }); 24473 return b(h2); 24474 }, "hsv"]] }; 24475 var N = function(r3, t2) { 24476 for (var n2 = 0; n2 < t2.length; n2++) { 24477 var e2 = t2[n2][0](r3); 24478 if (e2) return [e2, t2[n2][1]]; 24479 } 24480 return [null, void 0]; 24481 }; 24482 var x = function(r3) { 24483 return "string" == typeof r3 ? N(r3.trim(), y.string) : "object" == typeof r3 && null !== r3 ? N(r3, y.object) : [null, void 0]; 24484 }; 24485 var M = function(r3, t2) { 24486 var n2 = c(r3); 24487 return { h: n2.h, s: e(n2.s + 100 * t2, 0, 100), l: n2.l, a: n2.a }; 24488 }; 24489 var H = function(r3) { 24490 return (299 * r3.r + 587 * r3.g + 114 * r3.b) / 1e3 / 255; 24491 }; 24492 var $ = function(r3, t2) { 24493 var n2 = c(r3); 24494 return { h: n2.h, s: n2.s, l: e(n2.l + 100 * t2, 0, 100), a: n2.a }; 24495 }; 24496 var j = (function() { 24497 function r3(r4) { 24498 this.parsed = x(r4)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 }; 24499 } 24500 return r3.prototype.isValid = function() { 24501 return null !== this.parsed; 24502 }, r3.prototype.brightness = function() { 24503 return n(H(this.rgba), 2); 24504 }, r3.prototype.isDark = function() { 24505 return H(this.rgba) < 0.5; 24506 }, r3.prototype.isLight = function() { 24507 return H(this.rgba) >= 0.5; 24508 }, r3.prototype.toHex = function() { 24509 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; 24510 var r4, t2, e2, u2, a2, i2; 24511 }, r3.prototype.toRgb = function() { 24512 return o(this.rgba); 24513 }, r3.prototype.toRgbString = function() { 24514 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 + ")"; 24515 var r4, t2, n2, e2, u2; 24516 }, r3.prototype.toHsl = function() { 24517 return d(c(this.rgba)); 24518 }, r3.prototype.toHslString = function() { 24519 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 + "%)"; 24520 var r4, t2, n2, e2, u2; 24521 }, r3.prototype.toHsv = function() { 24522 return r4 = h(this.rgba), { h: n(r4.h), s: n(r4.s), v: n(r4.v), a: n(r4.a, 3) }; 24523 var r4; 24524 }, r3.prototype.invert = function() { 24525 return w({ r: 255 - (r4 = this.rgba).r, g: 255 - r4.g, b: 255 - r4.b, a: r4.a }); 24526 var r4; 24527 }, r3.prototype.saturate = function(r4) { 24528 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, r4)); 24529 }, r3.prototype.desaturate = function(r4) { 24530 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, -r4)); 24531 }, r3.prototype.grayscale = function() { 24532 return w(M(this.rgba, -1)); 24533 }, r3.prototype.lighten = function(r4) { 24534 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, r4)); 24535 }, r3.prototype.darken = function(r4) { 24536 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, -r4)); 24537 }, r3.prototype.rotate = function(r4) { 24538 return void 0 === r4 && (r4 = 15), this.hue(this.hue() + r4); 24539 }, r3.prototype.alpha = function(r4) { 24540 return "number" == typeof r4 ? w({ r: (t2 = this.rgba).r, g: t2.g, b: t2.b, a: r4 }) : n(this.rgba.a, 3); 24541 var t2; 24542 }, r3.prototype.hue = function(r4) { 24543 var t2 = c(this.rgba); 24544 return "number" == typeof r4 ? w({ h: r4, s: t2.s, l: t2.l, a: t2.a }) : n(t2.h); 24545 }, r3.prototype.isEqual = function(r4) { 24546 return this.toHex() === w(r4).toHex(); 24547 }, r3; 24548 })(); 24549 var w = function(r3) { 24550 return r3 instanceof j ? r3 : new j(r3); 24551 }; 24552 24553 // packages/dataviews/build-module/components/dataform-controls/color.mjs 24554 var import_components44 = __toESM(require_components(), 1); 24555 var import_element69 = __toESM(require_element(), 1); 24556 var import_i18n42 = __toESM(require_i18n(), 1); 24557 var import_jsx_runtime111 = __toESM(require_jsx_runtime(), 1); 24558 var { ValidatedInputControl: ValidatedInputControl3 } = unlock2(import_components44.privateApis); 24559 var ColorPickerDropdown = ({ 24560 color, 24561 onColorChange, 24562 disabled: disabled2 24563 }) => { 24564 const validColor = color && w(color).isValid() ? color : "#ffffff"; 24565 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)( 24566 import_components44.Dropdown, 24567 { 24568 className: "dataviews-controls__color-picker-dropdown", 24569 popoverProps: { resize: false }, 24570 renderToggle: ({ onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime111.jsx)( 24571 import_components44.Button, 24572 { 24573 onClick: onToggle, 24574 "aria-label": (0, import_i18n42.__)("Open color picker"), 24575 size: "small", 24576 disabled: disabled2, 24577 accessibleWhenDisabled: true, 24578 icon: () => /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(import_components44.ColorIndicator, { colorValue: validColor }) 24579 } 24580 ), 24581 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(import_components44.__experimentalDropdownContentWrapper, { paddingSize: "none", children: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)( 24582 import_components44.ColorPicker, 24583 { 24584 color: validColor, 24585 onChange: onColorChange, 24586 enableAlpha: true 24587 } 24588 ) }) 24589 } 24590 ); 24591 }; 24592 function Color({ 24593 data, 24594 field, 24595 onChange, 24596 hideLabelFromVision, 24597 markWhenOptional, 24598 validity 24599 }) { 24600 const { label, placeholder, description, setValue, isValid: isValid2 } = field; 24601 const disabled2 = field.isDisabled({ item: data, field }); 24602 const value = field.getValue({ item: data }) || ""; 24603 const handleColorChange = (0, import_element69.useCallback)( 24604 (newColor) => { 24605 onChange(setValue({ item: data, value: newColor })); 24606 }, 24607 [data, onChange, setValue] 24608 ); 24609 const handleInputChange = (0, import_element69.useCallback)( 24610 (newValue) => { 24611 onChange(setValue({ item: data, value: newValue || "" })); 24612 }, 24613 [data, onChange, setValue] 24614 ); 24615 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)( 24616 ValidatedInputControl3, 24617 { 24618 required: !!field.isValid?.required, 24619 markWhenOptional, 24620 customValidity: getCustomValidity(isValid2, validity), 24621 label, 24622 placeholder, 24623 value, 24624 help: description, 24625 onChange: handleInputChange, 24626 hideLabelFromVision, 24627 type: "text", 24628 disabled: disabled2, 24629 prefix: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(import_components44.__experimentalInputControlPrefixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)( 24630 ColorPickerDropdown, 24631 { 24632 color: value, 24633 onColorChange: handleColorChange, 24634 disabled: disabled2 24635 } 24636 ) }) 24637 } 24638 ); 24639 } 24640 24641 // packages/dataviews/build-module/components/dataform-controls/password.mjs 24642 var import_components45 = __toESM(require_components(), 1); 24643 var import_element70 = __toESM(require_element(), 1); 24644 var import_i18n43 = __toESM(require_i18n(), 1); 24645 var import_jsx_runtime112 = __toESM(require_jsx_runtime(), 1); 24646 function Password({ 24647 data, 24648 field, 24649 onChange, 24650 hideLabelFromVision, 24651 markWhenOptional, 24652 validity 24653 }) { 24654 const [isVisible2, setIsVisible] = (0, import_element70.useState)(false); 24655 const disabled2 = field.isDisabled({ item: data, field }); 24656 const toggleVisibility = (0, import_element70.useCallback)(() => { 24657 setIsVisible((prev) => !prev); 24658 }, []); 24659 return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)( 24660 ValidatedText, 24661 { 24662 ...{ 24663 data, 24664 field, 24665 onChange, 24666 hideLabelFromVision, 24667 markWhenOptional, 24668 validity, 24669 type: isVisible2 ? "text" : "password", 24670 suffix: /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(import_components45.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime112.jsx)( 24671 import_components45.Button, 24672 { 24673 icon: isVisible2 ? unseen_default : seen_default, 24674 onClick: toggleVisibility, 24675 size: "small", 24676 label: isVisible2 ? (0, import_i18n43.__)("Hide password") : (0, import_i18n43.__)("Show password"), 24677 disabled: disabled2, 24678 accessibleWhenDisabled: true 24679 } 24680 ) }) 24681 } 24682 } 24683 ); 24684 } 24685 24686 // packages/dataviews/build-module/field-types/utils/has-elements.mjs 24687 function hasElements(field) { 24688 return Array.isArray(field.elements) && field.elements.length > 0 || typeof field.getElements === "function"; 24689 } 24690 24691 // packages/dataviews/build-module/components/dataform-controls/index.mjs 24692 var import_jsx_runtime113 = __toESM(require_jsx_runtime(), 1); 24693 var FORM_CONTROLS = { 24694 adaptiveSelect: AdaptiveSelect, 24695 array: ArrayControl, 24696 checkbox: Checkbox, 24697 color: Color, 24698 combobox: Combobox3, 24699 datetime: DateTime, 24700 date: DateControl, 24701 email: Email, 24702 telephone: Telephone, 24703 url: Url, 24704 integer: Integer, 24705 number: Number2, 24706 password: Password, 24707 radio: Radio, 24708 select: Select, 24709 text: Text, 24710 toggle: Toggle, 24711 textarea: Textarea, 24712 toggleGroup: ToggleGroup 24713 }; 24714 function isEditConfig(value) { 24715 return value && typeof value === "object" && typeof value.control === "string"; 24716 } 24717 function createConfiguredControl(config) { 24718 const { control, ...controlConfig } = config; 24719 const BaseControlType = getControlByType(control); 24720 if (BaseControlType === null) { 24721 return null; 24722 } 24723 return function ConfiguredControl(props) { 24724 return /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(BaseControlType, { ...props, config: controlConfig }); 24725 }; 24726 } 24727 function getControl(field, fallback) { 24728 if (typeof field.Edit === "function") { 24729 return field.Edit; 24730 } 24731 if (typeof field.Edit === "string") { 24732 return getControlByType(field.Edit); 24733 } 24734 if (isEditConfig(field.Edit)) { 24735 return createConfiguredControl(field.Edit); 24736 } 24737 if (hasElements(field) && field.type !== "array") { 24738 return getControlByType("adaptiveSelect"); 24739 } 24740 if (fallback === null) { 24741 return null; 24742 } 24743 return getControlByType(fallback); 24744 } 24745 function getControlByType(type) { 24746 if (Object.keys(FORM_CONTROLS).includes(type)) { 24747 return FORM_CONTROLS[type]; 24748 } 24749 return null; 24750 } 24751 24752 // packages/dataviews/build-module/field-types/utils/get-filter-by.mjs 24753 function getFilterBy(field, defaultOperators, validOperators) { 24754 if (field.filterBy === false) { 24755 return false; 24756 } 24757 const operators = field.filterBy?.operators?.filter( 24758 (op) => validOperators.includes(op) 24759 ) ?? defaultOperators; 24760 if (operators.length === 0) { 24761 return false; 24762 } 24763 return { 24764 isPrimary: !!field.filterBy?.isPrimary, 24765 operators 24766 }; 24767 } 24768 var get_filter_by_default = getFilterBy; 24769 24770 // packages/dataviews/build-module/field-types/utils/get-value-from-id.mjs 24771 var getValueFromId = (id) => ({ item }) => { 24772 const path = id.split("."); 24773 let value = item; 24774 for (const segment of path) { 24775 if (value.hasOwnProperty(segment)) { 24776 value = value[segment]; 24777 } else { 24778 value = void 0; 24779 } 24780 } 24781 return value; 24782 }; 24783 var get_value_from_id_default = getValueFromId; 24784 24785 // packages/dataviews/build-module/field-types/utils/set-value-from-id.mjs 24786 var setValueFromId = (id) => ({ value }) => { 24787 const path = id.split("."); 24788 const result = {}; 24789 let current = result; 24790 for (const segment of path.slice(0, -1)) { 24791 current[segment] = {}; 24792 current = current[segment]; 24793 } 24794 current[path.at(-1)] = value; 24795 return result; 24796 }; 24797 var set_value_from_id_default = setValueFromId; 24798 24799 // packages/dataviews/build-module/field-types/email.mjs 24800 var import_i18n44 = __toESM(require_i18n(), 1); 24801 24802 // packages/dataviews/build-module/field-types/utils/render-from-elements.mjs 24803 function RenderFromElements({ 24804 item, 24805 field 24806 }) { 24807 const { elements, isLoading } = useElements({ 24808 elements: field.elements, 24809 getElements: field.getElements 24810 }); 24811 const value = field.getValue({ item }); 24812 if (isLoading) { 24813 return value; 24814 } 24815 if (elements.length === 0) { 24816 return value; 24817 } 24818 return elements?.find((element) => element.value === value)?.label || field.getValue({ item }); 24819 } 24820 24821 // packages/dataviews/build-module/field-types/utils/render-default.mjs 24822 var import_jsx_runtime114 = __toESM(require_jsx_runtime(), 1); 24823 function render({ 24824 item, 24825 field 24826 }) { 24827 if (field.hasElements) { 24828 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(RenderFromElements, { item, field }); 24829 } 24830 return field.getValueFormatted({ item, field }); 24831 } 24832 24833 // packages/dataviews/build-module/field-types/utils/sort-text.mjs 24834 var sort_text_default = (a2, b2, direction) => { 24835 return direction === "asc" ? a2.localeCompare(b2) : b2.localeCompare(a2); 24836 }; 24837 24838 // packages/dataviews/build-module/field-types/utils/is-valid-required.mjs 24839 function isValidRequired(item, field) { 24840 const value = field.getValue({ item }); 24841 return ![void 0, "", null].includes(value); 24842 } 24843 24844 // packages/dataviews/build-module/field-types/utils/is-valid-min-length.mjs 24845 function isValidMinLength(item, field) { 24846 if (typeof field.isValid.minLength?.constraint !== "number") { 24847 return false; 24848 } 24849 const value = field.getValue({ item }); 24850 if ([void 0, "", null].includes(value)) { 24851 return true; 24852 } 24853 return String(value).length >= field.isValid.minLength.constraint; 24854 } 24855 24856 // packages/dataviews/build-module/field-types/utils/is-valid-max-length.mjs 24857 function isValidMaxLength(item, field) { 24858 if (typeof field.isValid.maxLength?.constraint !== "number") { 24859 return false; 24860 } 24861 const value = field.getValue({ item }); 24862 if ([void 0, "", null].includes(value)) { 24863 return true; 24864 } 24865 return String(value).length <= field.isValid.maxLength.constraint; 24866 } 24867 24868 // packages/dataviews/build-module/field-types/utils/is-valid-pattern.mjs 24869 function isValidPattern(item, field) { 24870 if (field.isValid.pattern?.constraint === void 0) { 24871 return true; 24872 } 24873 try { 24874 const regexp = new RegExp(field.isValid.pattern.constraint); 24875 const value = field.getValue({ item }); 24876 if ([void 0, "", null].includes(value)) { 24877 return true; 24878 } 24879 return regexp.test(String(value)); 24880 } catch { 24881 return false; 24882 } 24883 } 24884 24885 // packages/dataviews/build-module/field-types/utils/is-valid-elements.mjs 24886 function isValidElements(item, field) { 24887 const elements = field.elements ?? []; 24888 const validValues = elements.map((el) => el.value); 24889 if (validValues.length === 0) { 24890 return true; 24891 } 24892 const value = field.getValue({ item }); 24893 return [].concat(value).every((v2) => validValues.includes(v2)); 24894 } 24895 24896 // packages/dataviews/build-module/field-types/utils/get-value-formatted-default.mjs 24897 function getValueFormatted({ 24898 item, 24899 field 24900 }) { 24901 return field.getValue({ item }); 24902 } 24903 var get_value_formatted_default_default = getValueFormatted; 24904 24905 // packages/dataviews/build-module/field-types/email.mjs 24906 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])?)*$/; 24907 function isValidCustom(item, field) { 24908 const value = field.getValue({ item }); 24909 if (![void 0, "", null].includes(value) && !emailRegex.test(value)) { 24910 return (0, import_i18n44.__)("Value must be a valid email address."); 24911 } 24912 return null; 24913 } 24914 var email_default = { 24915 type: "email", 24916 render, 24917 Edit: "email", 24918 sort: sort_text_default, 24919 enableSorting: true, 24920 enableGlobalSearch: false, 24921 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE], 24922 validOperators: [ 24923 OPERATOR_IS, 24924 OPERATOR_IS_NOT, 24925 OPERATOR_CONTAINS, 24926 OPERATOR_NOT_CONTAINS, 24927 OPERATOR_STARTS_WITH, 24928 // Multiple selection 24929 OPERATOR_IS_ANY, 24930 OPERATOR_IS_NONE, 24931 OPERATOR_IS_ALL, 24932 OPERATOR_IS_NOT_ALL 24933 ], 24934 format: {}, 24935 getValueFormatted: get_value_formatted_default_default, 24936 validate: { 24937 required: isValidRequired, 24938 pattern: isValidPattern, 24939 minLength: isValidMinLength, 24940 maxLength: isValidMaxLength, 24941 elements: isValidElements, 24942 custom: isValidCustom 24943 } 24944 }; 24945 24946 // packages/dataviews/build-module/field-types/integer.mjs 24947 var import_i18n45 = __toESM(require_i18n(), 1); 24948 24949 // packages/dataviews/build-module/field-types/utils/sort-number.mjs 24950 var sort_number_default = (a2, b2, direction) => { 24951 return direction === "asc" ? a2 - b2 : b2 - a2; 24952 }; 24953 24954 // packages/dataviews/build-module/field-types/utils/is-valid-min.mjs 24955 function isValidMin(item, field) { 24956 if (typeof field.isValid.min?.constraint !== "number") { 24957 return false; 24958 } 24959 const value = field.getValue({ item }); 24960 if ([void 0, "", null].includes(value)) { 24961 return true; 24962 } 24963 return Number(value) >= field.isValid.min.constraint; 24964 } 24965 24966 // packages/dataviews/build-module/field-types/utils/is-valid-max.mjs 24967 function isValidMax(item, field) { 24968 if (typeof field.isValid.max?.constraint !== "number") { 24969 return false; 24970 } 24971 const value = field.getValue({ item }); 24972 if ([void 0, "", null].includes(value)) { 24973 return true; 24974 } 24975 return Number(value) <= field.isValid.max.constraint; 24976 } 24977 24978 // packages/dataviews/build-module/field-types/integer.mjs 24979 var format2 = { 24980 separatorThousand: "," 24981 }; 24982 function getValueFormatted2({ 24983 item, 24984 field 24985 }) { 24986 let value = field.getValue({ item }); 24987 if (value === null || value === void 0) { 24988 return ""; 24989 } 24990 value = Number(value); 24991 if (!Number.isFinite(value)) { 24992 return String(value); 24993 } 24994 let formatInteger; 24995 if (field.type !== "integer") { 24996 formatInteger = format2; 24997 } else { 24998 formatInteger = field.format; 24999 } 25000 const { separatorThousand } = formatInteger; 25001 const integerValue = Math.trunc(value); 25002 if (!separatorThousand) { 25003 return String(integerValue); 25004 } 25005 return String(integerValue).replace( 25006 /\B(?=(\d{3})+(?!\d))/g, 25007 separatorThousand 25008 ); 25009 } 25010 function isValidCustom2(item, field) { 25011 const value = field.getValue({ item }); 25012 if (![void 0, "", null].includes(value) && !Number.isInteger(value)) { 25013 return (0, import_i18n45.__)("Value must be an integer."); 25014 } 25015 return null; 25016 } 25017 var integer_default = { 25018 type: "integer", 25019 render, 25020 Edit: "integer", 25021 sort: sort_number_default, 25022 enableSorting: true, 25023 enableGlobalSearch: false, 25024 defaultOperators: [ 25025 OPERATOR_IS, 25026 OPERATOR_IS_NOT, 25027 OPERATOR_LESS_THAN, 25028 OPERATOR_GREATER_THAN, 25029 OPERATOR_LESS_THAN_OR_EQUAL, 25030 OPERATOR_GREATER_THAN_OR_EQUAL, 25031 OPERATOR_BETWEEN 25032 ], 25033 validOperators: [ 25034 // Single-selection 25035 OPERATOR_IS, 25036 OPERATOR_IS_NOT, 25037 OPERATOR_LESS_THAN, 25038 OPERATOR_GREATER_THAN, 25039 OPERATOR_LESS_THAN_OR_EQUAL, 25040 OPERATOR_GREATER_THAN_OR_EQUAL, 25041 OPERATOR_BETWEEN, 25042 // Multiple-selection 25043 OPERATOR_IS_ANY, 25044 OPERATOR_IS_NONE, 25045 OPERATOR_IS_ALL, 25046 OPERATOR_IS_NOT_ALL 25047 ], 25048 format: format2, 25049 getValueFormatted: getValueFormatted2, 25050 validate: { 25051 required: isValidRequired, 25052 min: isValidMin, 25053 max: isValidMax, 25054 elements: isValidElements, 25055 custom: isValidCustom2 25056 } 25057 }; 25058 25059 // packages/dataviews/build-module/field-types/number.mjs 25060 var import_i18n46 = __toESM(require_i18n(), 1); 25061 var format3 = { 25062 separatorThousand: ",", 25063 separatorDecimal: ".", 25064 decimals: 2 25065 }; 25066 function getValueFormatted3({ 25067 item, 25068 field 25069 }) { 25070 let value = field.getValue({ item }); 25071 if (value === null || value === void 0) { 25072 return ""; 25073 } 25074 value = Number(value); 25075 if (!Number.isFinite(value)) { 25076 return String(value); 25077 } 25078 let formatNumber; 25079 if (field.type !== "number") { 25080 formatNumber = format3; 25081 } else { 25082 formatNumber = field.format; 25083 } 25084 const { separatorThousand, separatorDecimal, decimals } = formatNumber; 25085 const fixedValue = value.toFixed(decimals); 25086 const [integerPart, decimalPart] = fixedValue.split("."); 25087 const formattedInteger = separatorThousand ? integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, separatorThousand) : integerPart; 25088 return decimals === 0 ? formattedInteger : formattedInteger + separatorDecimal + decimalPart; 25089 } 25090 function isEmpty2(value) { 25091 return value === "" || value === void 0 || value === null; 25092 } 25093 function isValidCustom3(item, field) { 25094 const value = field.getValue({ item }); 25095 if (!isEmpty2(value) && !Number.isFinite(value)) { 25096 return (0, import_i18n46.__)("Value must be a number."); 25097 } 25098 return null; 25099 } 25100 var number_default = { 25101 type: "number", 25102 render, 25103 Edit: "number", 25104 sort: sort_number_default, 25105 enableSorting: true, 25106 enableGlobalSearch: false, 25107 defaultOperators: [ 25108 OPERATOR_IS, 25109 OPERATOR_IS_NOT, 25110 OPERATOR_LESS_THAN, 25111 OPERATOR_GREATER_THAN, 25112 OPERATOR_LESS_THAN_OR_EQUAL, 25113 OPERATOR_GREATER_THAN_OR_EQUAL, 25114 OPERATOR_BETWEEN 25115 ], 25116 validOperators: [ 25117 // Single-selection 25118 OPERATOR_IS, 25119 OPERATOR_IS_NOT, 25120 OPERATOR_LESS_THAN, 25121 OPERATOR_GREATER_THAN, 25122 OPERATOR_LESS_THAN_OR_EQUAL, 25123 OPERATOR_GREATER_THAN_OR_EQUAL, 25124 OPERATOR_BETWEEN, 25125 // Multiple-selection 25126 OPERATOR_IS_ANY, 25127 OPERATOR_IS_NONE, 25128 OPERATOR_IS_ALL, 25129 OPERATOR_IS_NOT_ALL 25130 ], 25131 format: format3, 25132 getValueFormatted: getValueFormatted3, 25133 validate: { 25134 required: isValidRequired, 25135 min: isValidMin, 25136 max: isValidMax, 25137 elements: isValidElements, 25138 custom: isValidCustom3 25139 } 25140 }; 25141 25142 // packages/dataviews/build-module/field-types/text.mjs 25143 var text_default = { 25144 type: "text", 25145 render, 25146 Edit: "text", 25147 sort: sort_text_default, 25148 enableSorting: true, 25149 enableGlobalSearch: false, 25150 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE], 25151 validOperators: [ 25152 // Single selection 25153 OPERATOR_IS, 25154 OPERATOR_IS_NOT, 25155 OPERATOR_CONTAINS, 25156 OPERATOR_NOT_CONTAINS, 25157 OPERATOR_STARTS_WITH, 25158 // Multiple selection 25159 OPERATOR_IS_ANY, 25160 OPERATOR_IS_NONE, 25161 OPERATOR_IS_ALL, 25162 OPERATOR_IS_NOT_ALL 25163 ], 25164 format: {}, 25165 getValueFormatted: get_value_formatted_default_default, 25166 validate: { 25167 required: isValidRequired, 25168 pattern: isValidPattern, 25169 minLength: isValidMinLength, 25170 maxLength: isValidMaxLength, 25171 elements: isValidElements 25172 } 25173 }; 25174 25175 // packages/dataviews/build-module/field-types/datetime.mjs 25176 var import_date7 = __toESM(require_date(), 1); 25177 25178 // packages/dataviews/build-module/field-types/utils/is-valid-date-boundary.mjs 25179 var import_date6 = __toESM(require_date(), 1); 25180 function parseDateLike(value) { 25181 if (!value) { 25182 return null; 25183 } 25184 if (!isValid(new Date(value))) { 25185 return null; 25186 } 25187 const parsed = (0, import_date6.getDate)(value); 25188 return parsed && isValid(parsed) ? parsed : null; 25189 } 25190 function validateDateLikeBoundary(item, field, boundary) { 25191 const constraint = field.isValid[boundary]?.constraint; 25192 if (typeof constraint !== "string") { 25193 return false; 25194 } 25195 const value = field.getValue({ item }); 25196 const boundaryValue = Array.isArray(value) ? value[boundary === "min" ? 0 : value.length - 1] : value; 25197 if (boundaryValue === void 0 || boundaryValue === null || boundaryValue === "") { 25198 return true; 25199 } 25200 const parsedConstraint = parseDateLike(constraint); 25201 const parsedValue = parseDateLike(String(boundaryValue)); 25202 return !!parsedConstraint && !!parsedValue && (boundary === "min" ? parsedValue.getTime() >= parsedConstraint.getTime() : parsedValue.getTime() <= parsedConstraint.getTime()); 25203 } 25204 function isValidMinDate(item, field) { 25205 return validateDateLikeBoundary(item, field, "min"); 25206 } 25207 function isValidMaxDate(item, field) { 25208 return validateDateLikeBoundary(item, field, "max"); 25209 } 25210 25211 // packages/dataviews/build-module/field-types/datetime.mjs 25212 var format4 = { 25213 datetime: (0, import_date7.getSettings)().formats.datetime, 25214 weekStartsOn: (0, import_date7.getSettings)().l10n.startOfWeek 25215 }; 25216 function getValueFormatted4({ 25217 item, 25218 field 25219 }) { 25220 const value = field.getValue({ item }); 25221 if (["", void 0, null].includes(value)) { 25222 return ""; 25223 } 25224 let formatDatetime; 25225 if (field.type !== "datetime") { 25226 formatDatetime = format4; 25227 } else { 25228 formatDatetime = field.format; 25229 } 25230 return (0, import_date7.dateI18n)(formatDatetime.datetime, (0, import_date7.getDate)(value)); 25231 } 25232 var sort = (a2, b2, direction) => { 25233 const timeA = new Date(a2).getTime(); 25234 const timeB = new Date(b2).getTime(); 25235 return direction === "asc" ? timeA - timeB : timeB - timeA; 25236 }; 25237 var datetime_default = { 25238 type: "datetime", 25239 render, 25240 Edit: "datetime", 25241 sort, 25242 enableSorting: true, 25243 enableGlobalSearch: false, 25244 defaultOperators: [ 25245 OPERATOR_ON, 25246 OPERATOR_NOT_ON, 25247 OPERATOR_BEFORE, 25248 OPERATOR_AFTER, 25249 OPERATOR_BEFORE_INC, 25250 OPERATOR_AFTER_INC, 25251 OPERATOR_IN_THE_PAST, 25252 OPERATOR_OVER 25253 ], 25254 validOperators: [ 25255 OPERATOR_ON, 25256 OPERATOR_NOT_ON, 25257 OPERATOR_BEFORE, 25258 OPERATOR_AFTER, 25259 OPERATOR_BEFORE_INC, 25260 OPERATOR_AFTER_INC, 25261 OPERATOR_IN_THE_PAST, 25262 OPERATOR_OVER 25263 ], 25264 format: format4, 25265 getValueFormatted: getValueFormatted4, 25266 validate: { 25267 required: isValidRequired, 25268 elements: isValidElements, 25269 min: isValidMinDate, 25270 max: isValidMaxDate 25271 } 25272 }; 25273 25274 // packages/dataviews/build-module/field-types/date.mjs 25275 var import_date8 = __toESM(require_date(), 1); 25276 var format5 = { 25277 date: (0, import_date8.getSettings)().formats.date, 25278 weekStartsOn: (0, import_date8.getSettings)().l10n.startOfWeek 25279 }; 25280 function getValueFormatted5({ 25281 item, 25282 field 25283 }) { 25284 const value = field.getValue({ item }); 25285 if (["", void 0, null].includes(value)) { 25286 return ""; 25287 } 25288 let formatDate2; 25289 if (field.type !== "date") { 25290 formatDate2 = format5; 25291 } else { 25292 formatDate2 = field.format; 25293 } 25294 return (0, import_date8.dateI18n)(formatDate2.date, (0, import_date8.getDate)(value)); 25295 } 25296 var sort2 = (a2, b2, direction) => { 25297 const timeA = new Date(a2).getTime(); 25298 const timeB = new Date(b2).getTime(); 25299 return direction === "asc" ? timeA - timeB : timeB - timeA; 25300 }; 25301 var date_default = { 25302 type: "date", 25303 render, 25304 Edit: "date", 25305 sort: sort2, 25306 enableSorting: true, 25307 enableGlobalSearch: false, 25308 defaultOperators: [ 25309 OPERATOR_ON, 25310 OPERATOR_NOT_ON, 25311 OPERATOR_BEFORE, 25312 OPERATOR_AFTER, 25313 OPERATOR_BEFORE_INC, 25314 OPERATOR_AFTER_INC, 25315 OPERATOR_IN_THE_PAST, 25316 OPERATOR_OVER, 25317 OPERATOR_BETWEEN 25318 ], 25319 validOperators: [ 25320 OPERATOR_ON, 25321 OPERATOR_NOT_ON, 25322 OPERATOR_BEFORE, 25323 OPERATOR_AFTER, 25324 OPERATOR_BEFORE_INC, 25325 OPERATOR_AFTER_INC, 25326 OPERATOR_IN_THE_PAST, 25327 OPERATOR_OVER, 25328 OPERATOR_BETWEEN 25329 ], 25330 format: format5, 25331 getValueFormatted: getValueFormatted5, 25332 validate: { 25333 required: isValidRequired, 25334 elements: isValidElements, 25335 min: isValidMinDate, 25336 max: isValidMaxDate 25337 } 25338 }; 25339 25340 // packages/dataviews/build-module/field-types/boolean.mjs 25341 var import_i18n47 = __toESM(require_i18n(), 1); 25342 25343 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-bool.mjs 25344 function isValidRequiredForBool(item, field) { 25345 const value = field.getValue({ item }); 25346 return value === true; 25347 } 25348 25349 // packages/dataviews/build-module/field-types/boolean.mjs 25350 function getValueFormatted6({ 25351 item, 25352 field 25353 }) { 25354 const value = field.getValue({ item }); 25355 if (value === true) { 25356 return (0, import_i18n47.__)("True"); 25357 } 25358 if (value === false) { 25359 return (0, import_i18n47.__)("False"); 25360 } 25361 return ""; 25362 } 25363 function isValidCustom4(item, field) { 25364 const value = field.getValue({ item }); 25365 if (![void 0, "", null].includes(value) && ![true, false].includes(value)) { 25366 return (0, import_i18n47.__)("Value must be true, false, or undefined"); 25367 } 25368 return null; 25369 } 25370 var sort3 = (a2, b2, direction) => { 25371 const boolA = Boolean(a2); 25372 const boolB = Boolean(b2); 25373 if (boolA === boolB) { 25374 return 0; 25375 } 25376 if (direction === "asc") { 25377 return boolA ? 1 : -1; 25378 } 25379 return boolA ? -1 : 1; 25380 }; 25381 var boolean_default = { 25382 type: "boolean", 25383 render, 25384 Edit: "checkbox", 25385 sort: sort3, 25386 validate: { 25387 required: isValidRequiredForBool, 25388 elements: isValidElements, 25389 custom: isValidCustom4 25390 }, 25391 enableSorting: true, 25392 enableGlobalSearch: false, 25393 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT], 25394 validOperators: [OPERATOR_IS, OPERATOR_IS_NOT], 25395 format: {}, 25396 getValueFormatted: getValueFormatted6 25397 }; 25398 25399 // packages/dataviews/build-module/field-types/media.mjs 25400 var media_default = { 25401 type: "media", 25402 render: () => null, 25403 Edit: null, 25404 sort: () => 0, 25405 enableSorting: false, 25406 enableGlobalSearch: false, 25407 defaultOperators: [], 25408 validOperators: [], 25409 format: {}, 25410 getValueFormatted: get_value_formatted_default_default, 25411 // cannot validate any constraint, so 25412 // the only available validation for the field author 25413 // would be providing a custom validator. 25414 validate: {} 25415 }; 25416 25417 // packages/dataviews/build-module/field-types/array.mjs 25418 var import_i18n48 = __toESM(require_i18n(), 1); 25419 25420 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-array.mjs 25421 function isValidRequiredForArray(item, field) { 25422 const value = field.getValue({ item }); 25423 return Array.isArray(value) && value.length > 0 && value.every( 25424 (element) => ![void 0, "", null].includes(element) 25425 ); 25426 } 25427 25428 // packages/dataviews/build-module/field-types/array.mjs 25429 function getValueFormatted7({ 25430 item, 25431 field 25432 }) { 25433 const value = field.getValue({ item }); 25434 const arr = Array.isArray(value) ? value : []; 25435 return arr.join(", "); 25436 } 25437 function render2({ item, field }) { 25438 return getValueFormatted7({ item, field }); 25439 } 25440 function isValidCustom5(item, field) { 25441 const value = field.getValue({ item }); 25442 if (![void 0, "", null].includes(value) && !Array.isArray(value)) { 25443 return (0, import_i18n48.__)("Value must be an array."); 25444 } 25445 if (!value.every((v2) => typeof v2 === "string")) { 25446 return (0, import_i18n48.__)("Every value must be a string."); 25447 } 25448 return null; 25449 } 25450 var sort4 = (a2, b2, direction) => { 25451 const arrA = Array.isArray(a2) ? a2 : []; 25452 const arrB = Array.isArray(b2) ? b2 : []; 25453 if (arrA.length !== arrB.length) { 25454 return direction === "asc" ? arrA.length - arrB.length : arrB.length - arrA.length; 25455 } 25456 const joinedA = arrA.join(","); 25457 const joinedB = arrB.join(","); 25458 return direction === "asc" ? joinedA.localeCompare(joinedB) : joinedB.localeCompare(joinedA); 25459 }; 25460 var array_default = { 25461 type: "array", 25462 render: render2, 25463 Edit: "array", 25464 sort: sort4, 25465 enableSorting: true, 25466 enableGlobalSearch: false, 25467 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE], 25468 validOperators: [ 25469 OPERATOR_IS_ANY, 25470 OPERATOR_IS_NONE, 25471 OPERATOR_IS_ALL, 25472 OPERATOR_IS_NOT_ALL 25473 ], 25474 format: {}, 25475 getValueFormatted: getValueFormatted7, 25476 validate: { 25477 required: isValidRequiredForArray, 25478 elements: isValidElements, 25479 custom: isValidCustom5 25480 } 25481 }; 25482 25483 // packages/dataviews/build-module/field-types/password.mjs 25484 function getValueFormatted8({ 25485 item, 25486 field 25487 }) { 25488 return field.getValue({ item }) ? "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" : ""; 25489 } 25490 var password_default = { 25491 type: "password", 25492 render, 25493 Edit: "password", 25494 sort: () => 0, 25495 // Passwords should not be sortable for security reasons 25496 enableSorting: false, 25497 enableGlobalSearch: false, 25498 defaultOperators: [], 25499 validOperators: [], 25500 format: {}, 25501 getValueFormatted: getValueFormatted8, 25502 validate: { 25503 required: isValidRequired, 25504 pattern: isValidPattern, 25505 minLength: isValidMinLength, 25506 maxLength: isValidMaxLength, 25507 elements: isValidElements 25508 } 25509 }; 25510 25511 // packages/dataviews/build-module/field-types/telephone.mjs 25512 var telephone_default = { 25513 type: "telephone", 25514 render, 25515 Edit: "telephone", 25516 sort: sort_text_default, 25517 enableSorting: true, 25518 enableGlobalSearch: false, 25519 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE], 25520 validOperators: [ 25521 OPERATOR_IS, 25522 OPERATOR_IS_NOT, 25523 OPERATOR_CONTAINS, 25524 OPERATOR_NOT_CONTAINS, 25525 OPERATOR_STARTS_WITH, 25526 // Multiple selection 25527 OPERATOR_IS_ANY, 25528 OPERATOR_IS_NONE, 25529 OPERATOR_IS_ALL, 25530 OPERATOR_IS_NOT_ALL 25531 ], 25532 format: {}, 25533 getValueFormatted: get_value_formatted_default_default, 25534 validate: { 25535 required: isValidRequired, 25536 pattern: isValidPattern, 25537 minLength: isValidMinLength, 25538 maxLength: isValidMaxLength, 25539 elements: isValidElements 25540 } 25541 }; 25542 25543 // packages/dataviews/build-module/field-types/color.mjs 25544 var import_i18n49 = __toESM(require_i18n(), 1); 25545 var import_jsx_runtime115 = __toESM(require_jsx_runtime(), 1); 25546 function render3({ item, field }) { 25547 if (field.hasElements) { 25548 return /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(RenderFromElements, { item, field }); 25549 } 25550 const value = get_value_formatted_default_default({ item, field }); 25551 if (!value || !w(value).isValid()) { 25552 return value; 25553 } 25554 return /* @__PURE__ */ (0, import_jsx_runtime115.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [ 25555 /* @__PURE__ */ (0, import_jsx_runtime115.jsx)( 25556 "div", 25557 { 25558 style: { 25559 width: "16px", 25560 height: "16px", 25561 borderRadius: "50%", 25562 backgroundColor: value, 25563 border: "1px solid #ddd", 25564 flexShrink: 0 25565 } 25566 } 25567 ), 25568 /* @__PURE__ */ (0, import_jsx_runtime115.jsx)("span", { children: value }) 25569 ] }); 25570 } 25571 function isValidCustom6(item, field) { 25572 const value = field.getValue({ item }); 25573 if (![void 0, "", null].includes(value) && !w(value).isValid()) { 25574 return (0, import_i18n49.__)("Value must be a valid color."); 25575 } 25576 return null; 25577 } 25578 var sort5 = (a2, b2, direction) => { 25579 const colorA = w(a2); 25580 const colorB = w(b2); 25581 if (!colorA.isValid() && !colorB.isValid()) { 25582 return 0; 25583 } 25584 if (!colorA.isValid()) { 25585 return direction === "asc" ? 1 : -1; 25586 } 25587 if (!colorB.isValid()) { 25588 return direction === "asc" ? -1 : 1; 25589 } 25590 const hslA = colorA.toHsl(); 25591 const hslB = colorB.toHsl(); 25592 if (hslA.h !== hslB.h) { 25593 return direction === "asc" ? hslA.h - hslB.h : hslB.h - hslA.h; 25594 } 25595 if (hslA.s !== hslB.s) { 25596 return direction === "asc" ? hslA.s - hslB.s : hslB.s - hslA.s; 25597 } 25598 return direction === "asc" ? hslA.l - hslB.l : hslB.l - hslA.l; 25599 }; 25600 var color_default = { 25601 type: "color", 25602 render: render3, 25603 Edit: "color", 25604 sort: sort5, 25605 enableSorting: true, 25606 enableGlobalSearch: false, 25607 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE], 25608 validOperators: [ 25609 OPERATOR_IS, 25610 OPERATOR_IS_NOT, 25611 OPERATOR_IS_ANY, 25612 OPERATOR_IS_NONE 25613 ], 25614 format: {}, 25615 getValueFormatted: get_value_formatted_default_default, 25616 validate: { 25617 required: isValidRequired, 25618 elements: isValidElements, 25619 custom: isValidCustom6 25620 } 25621 }; 25622 25623 // packages/dataviews/build-module/field-types/url.mjs 25624 var url_default = { 25625 type: "url", 25626 render, 25627 Edit: "url", 25628 sort: sort_text_default, 25629 enableSorting: true, 25630 enableGlobalSearch: false, 25631 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE], 25632 validOperators: [ 25633 OPERATOR_IS, 25634 OPERATOR_IS_NOT, 25635 OPERATOR_CONTAINS, 25636 OPERATOR_NOT_CONTAINS, 25637 OPERATOR_STARTS_WITH, 25638 // Multiple selection 25639 OPERATOR_IS_ANY, 25640 OPERATOR_IS_NONE, 25641 OPERATOR_IS_ALL, 25642 OPERATOR_IS_NOT_ALL 25643 ], 25644 format: {}, 25645 getValueFormatted: get_value_formatted_default_default, 25646 validate: { 25647 required: isValidRequired, 25648 pattern: isValidPattern, 25649 minLength: isValidMinLength, 25650 maxLength: isValidMaxLength, 25651 elements: isValidElements 25652 } 25653 }; 25654 25655 // packages/dataviews/build-module/field-types/no-type.mjs 25656 var sort6 = (a2, b2, direction) => { 25657 if (typeof a2 === "number" && typeof b2 === "number") { 25658 return sort_number_default(a2, b2, direction); 25659 } 25660 return sort_text_default(a2, b2, direction); 25661 }; 25662 var no_type_default = { 25663 // type: no type for this one 25664 render, 25665 Edit: null, 25666 sort: sort6, 25667 enableSorting: true, 25668 enableGlobalSearch: false, 25669 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT], 25670 validOperators: getAllOperatorNames(), 25671 format: {}, 25672 getValueFormatted: get_value_formatted_default_default, 25673 validate: { 25674 required: isValidRequired, 25675 elements: isValidElements 25676 } 25677 }; 25678 25679 // packages/dataviews/build-module/field-types/utils/get-is-valid.mjs 25680 function supportsNumericRangeConstraint(type) { 25681 return type === "integer" || type === "number"; 25682 } 25683 function supportsDateRangeConstraint(type) { 25684 return type === "date" || type === "datetime"; 25685 } 25686 function normalizeRangeRule(value, fieldType, key) { 25687 const validator = fieldType.validate[key]; 25688 if (validator && (typeof value === "number" && supportsNumericRangeConstraint(fieldType.type) || typeof value === "string" && supportsDateRangeConstraint(fieldType.type))) { 25689 return { constraint: value, validate: validator }; 25690 } 25691 return void 0; 25692 } 25693 function getIsValid(field, fieldType) { 25694 const rules = field.isValid; 25695 let required; 25696 if (rules?.required === true && fieldType.validate.required !== void 0) { 25697 required = { 25698 constraint: true, 25699 validate: fieldType.validate.required 25700 }; 25701 } 25702 let elements; 25703 if ((rules?.elements === true || // elements is enabled unless the field opts-out 25704 rules?.elements === void 0 && (!!field.elements || !!field.getElements)) && fieldType.validate.elements !== void 0) { 25705 elements = { 25706 constraint: true, 25707 validate: fieldType.validate.elements 25708 }; 25709 } 25710 const min2 = normalizeRangeRule(rules?.min, fieldType, "min"); 25711 const max2 = normalizeRangeRule(rules?.max, fieldType, "max"); 25712 const minLengthValue = rules?.minLength; 25713 let minLength; 25714 if (typeof minLengthValue === "number" && fieldType.validate.minLength !== void 0) { 25715 minLength = { 25716 constraint: minLengthValue, 25717 validate: fieldType.validate.minLength 25718 }; 25719 } 25720 const maxLengthValue = rules?.maxLength; 25721 let maxLength; 25722 if (typeof maxLengthValue === "number" && fieldType.validate.maxLength !== void 0) { 25723 maxLength = { 25724 constraint: maxLengthValue, 25725 validate: fieldType.validate.maxLength 25726 }; 25727 } 25728 const patternValue = rules?.pattern; 25729 let pattern; 25730 if (patternValue !== void 0 && fieldType.validate.pattern !== void 0) { 25731 pattern = { 25732 constraint: patternValue, 25733 validate: fieldType.validate.pattern 25734 }; 25735 } 25736 const custom = rules?.custom ?? fieldType.validate.custom; 25737 return { 25738 required, 25739 elements, 25740 min: min2, 25741 max: max2, 25742 minLength, 25743 maxLength, 25744 pattern, 25745 custom 25746 }; 25747 } 25748 25749 // packages/dataviews/build-module/field-types/utils/get-filter.mjs 25750 function getFilter(fieldType) { 25751 return fieldType.validOperators.reduce((accumulator, operator) => { 25752 const operatorObj = getOperatorByName(operator); 25753 if (operatorObj?.filter) { 25754 accumulator[operator] = operatorObj.filter; 25755 } 25756 return accumulator; 25757 }, {}); 25758 } 25759 25760 // packages/dataviews/build-module/field-types/utils/get-format.mjs 25761 function getFormat(field, fieldType) { 25762 return { 25763 ...fieldType.format, 25764 ...field.format 25765 }; 25766 } 25767 var get_format_default = getFormat; 25768 25769 // packages/dataviews/build-module/field-types/index.mjs 25770 function getFieldTypeByName(type) { 25771 const found = [ 25772 email_default, 25773 integer_default, 25774 number_default, 25775 text_default, 25776 datetime_default, 25777 date_default, 25778 boolean_default, 25779 media_default, 25780 array_default, 25781 password_default, 25782 telephone_default, 25783 color_default, 25784 url_default 25785 ].find((fieldType) => fieldType?.type === type); 25786 if (!!found) { 25787 return found; 25788 } 25789 return no_type_default; 25790 } 25791 function normalizeFields(fields) { 25792 return fields.map((field) => { 25793 const fieldType = getFieldTypeByName(field.type); 25794 const getValue = field.getValue || get_value_from_id_default(field.id); 25795 const sort7 = function(a2, b2, direction) { 25796 const aValue = getValue({ item: a2 }); 25797 const bValue = getValue({ item: b2 }); 25798 return field.sort ? field.sort(aValue, bValue, direction) : fieldType.sort(aValue, bValue, direction); 25799 }; 25800 return { 25801 id: field.id, 25802 label: field.label || field.id, 25803 header: field.header || field.label || field.id, 25804 description: field.description, 25805 placeholder: field.placeholder, 25806 getValue, 25807 setValue: field.setValue || set_value_from_id_default(field.id), 25808 elements: field.elements, 25809 getElements: field.getElements, 25810 hasElements: hasElements(field), 25811 isVisible: field.isVisible, 25812 isDisabled: typeof field.isDisabled === "function" ? field.isDisabled : () => !!field.isDisabled, 25813 enableHiding: field.enableHiding ?? true, 25814 readOnly: field.readOnly ?? false, 25815 // The type provides defaults for the following props 25816 type: fieldType.type, 25817 render: field.render ?? fieldType.render, 25818 Edit: getControl(field, fieldType.Edit), 25819 sort: sort7, 25820 enableSorting: field.enableSorting ?? fieldType.enableSorting, 25821 enableGlobalSearch: field.enableGlobalSearch ?? fieldType.enableGlobalSearch, 25822 isValid: getIsValid(field, fieldType), 25823 filterBy: get_filter_by_default( 25824 field, 25825 fieldType.defaultOperators, 25826 fieldType.validOperators 25827 ), 25828 filter: getFilter(fieldType), 25829 format: get_format_default(field, fieldType), 25830 getValueFormatted: field.getValueFormatted ?? fieldType.getValueFormatted 25831 }; 25832 }); 25833 } 25834 25835 // packages/dataviews/build-module/hooks/use-data.mjs 25836 var import_element71 = __toESM(require_element(), 1); 25837 function useData({ 25838 view, 25839 data: shownData, 25840 getItemId, 25841 isLoading, 25842 paginationInfo, 25843 selection 25844 }) { 25845 const isInfiniteScrollEnabled = view.infiniteScrollEnabled; 25846 const [hasInitiallyLoaded, setHasInitiallyLoaded] = (0, import_element71.useState)( 25847 !isLoading 25848 ); 25849 (0, import_element71.useEffect)(() => { 25850 if (!isLoading) { 25851 setHasInitiallyLoaded(true); 25852 } 25853 }, [isLoading]); 25854 const previousDataRef = (0, import_element71.useRef)(shownData); 25855 const previousPaginationInfoRef = (0, import_element71.useRef)(paginationInfo); 25856 (0, import_element71.useEffect)(() => { 25857 if (!isLoading) { 25858 previousDataRef.current = shownData; 25859 previousPaginationInfoRef.current = paginationInfo; 25860 } 25861 }, [shownData, isLoading, paginationInfo]); 25862 const [visibleEntries, setVisibleEntries] = (0, import_element71.useState)([]); 25863 const positionMapRef = (0, import_element71.useRef)(/* @__PURE__ */ new Map()); 25864 const allLoadedRecordsRef = (0, import_element71.useRef)([]); 25865 const prevViewParamsRef = (0, import_element71.useRef)({ 25866 search: void 0, 25867 filters: void 0, 25868 perPage: void 0 25869 }); 25870 const scrollDirectionRef = (0, import_element71.useRef)(void 0); 25871 const prevStartPositionRef = (0, import_element71.useRef)(void 0); 25872 const hasInitializedRef = (0, import_element71.useRef)(false); 25873 const allLoadedRecords = (0, import_element71.useMemo)(() => { 25874 if (view.startPosition !== void 0 && prevStartPositionRef.current !== void 0) { 25875 if (view.startPosition < prevStartPositionRef.current) { 25876 scrollDirectionRef.current = "up"; 25877 } else if (view.startPosition > prevStartPositionRef.current) { 25878 scrollDirectionRef.current = "down"; 25879 } 25880 } 25881 prevStartPositionRef.current = view.startPosition; 25882 const currentFiltersKey = JSON.stringify(view.filters ?? []); 25883 const prevFiltersKey = prevViewParamsRef.current.filters; 25884 const shouldReset = !hasInitializedRef.current || !view.infiniteScrollEnabled || view.search !== prevViewParamsRef.current.search || currentFiltersKey !== prevFiltersKey || view.perPage !== prevViewParamsRef.current.perPage; 25885 hasInitializedRef.current = true; 25886 prevViewParamsRef.current = { 25887 search: view.search, 25888 filters: currentFiltersKey, 25889 perPage: view.perPage 25890 }; 25891 if (shouldReset) { 25892 positionMapRef.current.clear(); 25893 scrollDirectionRef.current = void 0; 25894 const startPosition = view.search ? 1 : view.startPosition ?? 1; 25895 const records = shownData.map((record, index2) => { 25896 const position = startPosition + index2; 25897 positionMapRef.current.set(getItemId(record), position); 25898 return { 25899 ...record, 25900 position 25901 }; 25902 }); 25903 allLoadedRecordsRef.current = records; 25904 return records; 25905 } 25906 const prev = allLoadedRecordsRef.current; 25907 const shownDataIds = new Set(shownData.map(getItemId)); 25908 const scrollDirection = scrollDirectionRef.current; 25909 const basePosition = view.search ? 1 : view.startPosition ?? 1; 25910 const newRecords = shownData.map((record, index2) => { 25911 const itemId = getItemId(record); 25912 const position = view.infiniteScrollEnabled ? basePosition + index2 : void 0; 25913 if (position !== void 0) { 25914 positionMapRef.current.set(itemId, position); 25915 } 25916 return { 25917 ...record, 25918 position 25919 }; 25920 }); 25921 if (newRecords.length === 0) { 25922 return prev; 25923 } 25924 const prevWithoutDuplicates = prev.filter( 25925 (record) => !shownDataIds.has(getItemId(record)) 25926 ); 25927 const allRecords = scrollDirection === "up" ? [...newRecords, ...prevWithoutDuplicates] : [...prevWithoutDuplicates, ...newRecords]; 25928 allRecords.sort((a2, b2) => { 25929 const posA = a2.position; 25930 const posB = b2.position; 25931 return posA - posB; 25932 }); 25933 let result = allRecords; 25934 if (visibleEntries.length > 0) { 25935 const visibleMin = Math.min(...visibleEntries); 25936 const visibleMax = Math.max(...visibleEntries); 25937 const buffer = 20; 25938 const recordPositions = allRecords.map( 25939 (r3) => r3.position 25940 ); 25941 const minRecordPos = Math.min(...recordPositions); 25942 const maxRecordPos = Math.max(...recordPositions); 25943 const hasOverlap = !(maxRecordPos < visibleMin - buffer || minRecordPos > visibleMax + buffer); 25944 if (hasOverlap) { 25945 result = allRecords.filter((record) => { 25946 const itemId = getItemId(record); 25947 const isSelected2 = selection?.includes(itemId); 25948 if (isSelected2) { 25949 return true; 25950 } 25951 const itemPosition = record.position; 25952 if (scrollDirection === "up") { 25953 return itemPosition <= visibleMax + buffer; 25954 } else if (scrollDirection === "down") { 25955 return itemPosition >= visibleMin - buffer; 25956 } 25957 return itemPosition >= visibleMin - buffer && itemPosition <= visibleMax + buffer; 25958 }); 25959 } 25960 } 25961 allLoadedRecordsRef.current = result; 25962 return result; 25963 }, [ 25964 shownData, 25965 view.search, 25966 view.filters, 25967 view.perPage, 25968 view.startPosition, 25969 view.infiniteScrollEnabled, 25970 visibleEntries, 25971 selection, 25972 getItemId 25973 ]); 25974 if (!isInfiniteScrollEnabled) { 25975 const dataToReturn = isLoading && previousDataRef.current?.length ? previousDataRef.current : shownData; 25976 return { 25977 data: dataToReturn.map((item) => ({ 25978 ...item, 25979 position: void 0 25980 })), 25981 paginationInfo: isLoading && previousDataRef.current?.length ? previousPaginationInfoRef.current : paginationInfo, 25982 hasInitiallyLoaded, 25983 setVisibleEntries: void 0 25984 }; 25985 } 25986 return { 25987 data: allLoadedRecords, 25988 paginationInfo, 25989 hasInitiallyLoaded, 25990 setVisibleEntries 25991 }; 25992 } 25993 25994 // packages/dataviews/build-module/hooks/use-infinite-scroll.mjs 25995 var import_element72 = __toESM(require_element(), 1); 25996 var import_compose12 = __toESM(require_compose(), 1); 25997 function captureAnchorElement(container, anchorElementRef, direction) { 25998 const containerRect = container.getBoundingClientRect(); 25999 const centerY = containerRect.top + containerRect.height / 2; 26000 const items = Array.from(container.querySelectorAll("[aria-posinset]")); 26001 if (items.length === 0) { 26002 return false; 26003 } 26004 const bestAnchor = items.reduce((best, item) => { 26005 const itemRect = item.getBoundingClientRect(); 26006 const itemCenterY = itemRect.top + itemRect.height / 2; 26007 const distance = Math.abs(itemCenterY - centerY); 26008 const bestRect = best.getBoundingClientRect(); 26009 const bestCenterY = bestRect.top + bestRect.height / 2; 26010 const bestDistance = Math.abs(bestCenterY - centerY); 26011 return distance < bestDistance ? item : best; 26012 }); 26013 const posinset = Number(bestAnchor.getAttribute("aria-posinset")); 26014 const anchorRect = bestAnchor.getBoundingClientRect(); 26015 anchorElementRef.current = { 26016 posinset, 26017 viewportOffset: anchorRect.top - containerRect.top, 26018 direction 26019 }; 26020 return true; 26021 } 26022 function useInfiniteScroll({ 26023 view, 26024 onChangeView, 26025 isLoading, 26026 paginationInfo, 26027 containerRef, 26028 setVisibleEntries 26029 }) { 26030 const anchorElementRef = (0, import_element72.useRef)(null); 26031 const viewRef = (0, import_element72.useRef)(view); 26032 const isLoadingRef = (0, import_element72.useRef)(isLoading); 26033 const onChangeViewRef = (0, import_element72.useRef)(onChangeView); 26034 const totalItemsRef = (0, import_element72.useRef)(paginationInfo.totalItems); 26035 (0, import_element72.useLayoutEffect)(() => { 26036 viewRef.current = view; 26037 isLoadingRef.current = isLoading; 26038 onChangeViewRef.current = onChangeView; 26039 totalItemsRef.current = paginationInfo.totalItems; 26040 }, [view, isLoading, onChangeView, paginationInfo.totalItems]); 26041 const intersectionObserverCallback = (0, import_element72.useCallback)( 26042 (entries) => { 26043 if (!setVisibleEntries) { 26044 return; 26045 } 26046 setVisibleEntries((prev) => { 26047 const newVisibleEntries = new Set(prev); 26048 let hasChanged = false; 26049 entries.forEach((entry) => { 26050 const posInSet = Number( 26051 entry.target?.attributes?.getNamedItem( 26052 "aria-posinset" 26053 )?.value 26054 ); 26055 if (isNaN(posInSet)) { 26056 return; 26057 } 26058 if (entry.isIntersecting) { 26059 if (!newVisibleEntries.has(posInSet)) { 26060 newVisibleEntries.add(posInSet); 26061 hasChanged = true; 26062 } 26063 } else if (newVisibleEntries.has(posInSet)) { 26064 newVisibleEntries.delete(posInSet); 26065 hasChanged = true; 26066 } 26067 }); 26068 return hasChanged ? Array.from(newVisibleEntries).sort() : prev; 26069 }); 26070 }, 26071 [setVisibleEntries] 26072 ); 26073 (0, import_element72.useLayoutEffect)(() => { 26074 const container = containerRef.current; 26075 const anchor = anchorElementRef.current; 26076 if (!container || !view.infiniteScrollEnabled || !anchor || isLoading) { 26077 return; 26078 } 26079 const anchorElement = container.querySelector( 26080 `[aria-posinset="$anchor.posinset}"]` 26081 ); 26082 if (anchorElement) { 26083 const containerRect = container.getBoundingClientRect(); 26084 const anchorRect = anchorElement.getBoundingClientRect(); 26085 const currentOffset = anchorRect.top - containerRect.top; 26086 const scrollAdjustment = currentOffset - anchor.viewportOffset; 26087 if (Math.abs(scrollAdjustment) > 1) { 26088 container.scrollTop += scrollAdjustment; 26089 } 26090 } 26091 anchorElementRef.current = null; 26092 }, [containerRef, isLoading, view.infiniteScrollEnabled]); 26093 const intersectionObserverRef = (0, import_element72.useRef)( 26094 null 26095 ); 26096 (0, import_element72.useEffect)(() => { 26097 if (!view.infiniteScrollEnabled || !intersectionObserverCallback) { 26098 if (intersectionObserverRef.current) { 26099 intersectionObserverRef.current.disconnect(); 26100 intersectionObserverRef.current = null; 26101 } 26102 return; 26103 } 26104 intersectionObserverRef.current = new IntersectionObserver( 26105 intersectionObserverCallback, 26106 { root: null, rootMargin: "0px", threshold: 0.1 } 26107 ); 26108 return () => { 26109 if (intersectionObserverRef.current) { 26110 intersectionObserverRef.current.disconnect(); 26111 intersectionObserverRef.current = null; 26112 } 26113 }; 26114 }, [view.infiniteScrollEnabled, intersectionObserverCallback]); 26115 (0, import_element72.useEffect)(() => { 26116 if (!view.infiniteScrollEnabled || !containerRef.current) { 26117 return; 26118 } 26119 let lastScrollTop = 0; 26120 const BOTTOM_THRESHOLD = 600; 26121 const TOP_THRESHOLD = 800; 26122 const handleScroll = (0, import_compose12.throttle)((event) => { 26123 const currentView = viewRef.current; 26124 const totalItems = totalItemsRef.current; 26125 const target = event.target; 26126 const scrollTop = target.scrollTop; 26127 const scrollHeight = target.scrollHeight; 26128 const clientHeight = target.clientHeight; 26129 const scrollDirection = scrollTop > lastScrollTop ? "down" : "up"; 26130 lastScrollTop = scrollTop; 26131 if (isLoadingRef.current) { 26132 return; 26133 } 26134 const currentStartPosition = currentView.startPosition || 1; 26135 const batchSize = currentView.perPage || 10; 26136 const currentEndPosition = Math.min( 26137 currentStartPosition + batchSize, 26138 totalItems 26139 ); 26140 if (scrollDirection === "down" && scrollTop + clientHeight >= scrollHeight - BOTTOM_THRESHOLD) { 26141 if (currentEndPosition < totalItems) { 26142 const newStartPosition = currentEndPosition; 26143 captureAnchorElement(target, anchorElementRef, "down"); 26144 onChangeViewRef.current({ 26145 ...currentView, 26146 startPosition: newStartPosition 26147 }); 26148 } 26149 } 26150 if (scrollDirection === "up" && scrollTop <= TOP_THRESHOLD) { 26151 if (currentStartPosition > 1) { 26152 const calculatedStartPosition = currentStartPosition - batchSize; 26153 const newStartPosition = calculatedStartPosition < 6 ? 1 : calculatedStartPosition; 26154 captureAnchorElement(target, anchorElementRef, "up"); 26155 onChangeViewRef.current({ 26156 ...currentView, 26157 startPosition: newStartPosition 26158 }); 26159 } 26160 } 26161 }, 50); 26162 const container = containerRef.current; 26163 container.addEventListener("scroll", handleScroll); 26164 return () => { 26165 container.removeEventListener("scroll", handleScroll); 26166 handleScroll.cancel(); 26167 }; 26168 }, [containerRef, view.infiniteScrollEnabled]); 26169 return { 26170 intersectionObserver: intersectionObserverRef.current 26171 }; 26172 } 26173 26174 // packages/dataviews/build-module/dataviews-picker/index.mjs 26175 var import_element73 = __toESM(require_element(), 1); 26176 var import_compose13 = __toESM(require_compose(), 1); 26177 var import_jsx_runtime116 = __toESM(require_jsx_runtime(), 1); 26178 var isItemClickable = () => false; 26179 var dataViewsPickerLayouts = VIEW_LAYOUTS.filter( 26180 (viewLayout) => viewLayout.isPicker 26181 ); 26182 var defaultGetItemId = (item) => item.id; 26183 var EMPTY_ARRAY5 = []; 26184 var DEFAULT_PICKER_LAYOUTS = { 26185 pickerGrid: true, 26186 pickerTable: true 26187 }; 26188 function DefaultUI({ 26189 search = true, 26190 searchLabel = void 0 26191 }) { 26192 const { view } = (0, import_element73.useContext)(dataviews_context_default); 26193 const isInfiniteScroll = view.infiniteScrollEnabled; 26194 return /* @__PURE__ */ (0, import_jsx_runtime116.jsxs)(import_jsx_runtime116.Fragment, { children: [ 26195 /* @__PURE__ */ (0, import_jsx_runtime116.jsxs)( 26196 Stack, 26197 { 26198 direction: "row", 26199 align: "top", 26200 justify: "space-between", 26201 className: clsx_default("dataviews__view-actions", { 26202 "dataviews__view-actions--infinite-scroll": isInfiniteScroll 26203 }), 26204 gap: "xs", 26205 children: [ 26206 /* @__PURE__ */ (0, import_jsx_runtime116.jsxs)( 26207 Stack, 26208 { 26209 direction: "row", 26210 gap: "sm", 26211 justify: "start", 26212 className: "dataviews__search", 26213 children: [ 26214 search && /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(dataviews_search_default, { label: searchLabel }), 26215 /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(toggle_default, {}) 26216 ] 26217 } 26218 ), 26219 /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(Stack, { direction: "row", gap: "xs", style: { flexShrink: 0 }, children: /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(dataviews_view_config_default, {}) }) 26220 ] 26221 } 26222 ), 26223 /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(filters_toggled_default, { className: "dataviews-filters__container" }), 26224 /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(DataViewsLayout, {}), 26225 /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(DataViewsPickerFooter, {}) 26226 ] }); 26227 } 26228 function DataViewsPicker({ 26229 view, 26230 onChangeView, 26231 fields, 26232 search = true, 26233 searchLabel = void 0, 26234 actions = EMPTY_ARRAY5, 26235 data, 26236 getItemId = defaultGetItemId, 26237 isLoading = false, 26238 paginationInfo, 26239 defaultLayouts: defaultLayoutsProperty = DEFAULT_PICKER_LAYOUTS, 26240 selection, 26241 onChangeSelection, 26242 children, 26243 config = { perPageSizes: [10, 20, 50, 100] }, 26244 itemListLabel, 26245 empty, 26246 onReset 26247 }) { 26248 const { data: displayData, setVisibleEntries } = useData({ 26249 view, 26250 data, 26251 getItemId, 26252 selection, 26253 paginationInfo 26254 }); 26255 const containerRef = (0, import_element73.useRef)(null); 26256 const [containerWidth, setContainerWidth] = (0, import_element73.useState)(0); 26257 const resizeObserverRef = (0, import_compose13.useResizeObserver)( 26258 (resizeObserverEntries) => { 26259 setContainerWidth( 26260 resizeObserverEntries[0].borderBoxSize[0].inlineSize 26261 ); 26262 }, 26263 { box: "border-box" } 26264 ); 26265 const [openedFilter, setOpenedFilter] = (0, import_element73.useState)(null); 26266 function setSelectionWithChange(value) { 26267 const newValue = typeof value === "function" ? value(selection) : value; 26268 if (onChangeSelection) { 26269 onChangeSelection(newValue); 26270 } 26271 } 26272 const _fields = (0, import_element73.useMemo)(() => normalizeFields(fields), [fields]); 26273 const filters = use_filters_default(_fields, view); 26274 const hasPrimaryOrLockedFilters = (0, import_element73.useMemo)( 26275 () => (filters || []).some( 26276 (filter) => filter.isPrimary || filter.isLocked 26277 ), 26278 [filters] 26279 ); 26280 const [isShowingFilter, setIsShowingFilter] = (0, import_element73.useState)( 26281 hasPrimaryOrLockedFilters 26282 ); 26283 const { intersectionObserver } = useInfiniteScroll({ 26284 view, 26285 onChangeView, 26286 isLoading, 26287 paginationInfo, 26288 containerRef, 26289 setVisibleEntries 26290 }); 26291 (0, import_element73.useEffect)(() => { 26292 if (hasPrimaryOrLockedFilters && !isShowingFilter) { 26293 setIsShowingFilter(true); 26294 } 26295 }, [hasPrimaryOrLockedFilters, isShowingFilter]); 26296 const defaultLayouts2 = (0, import_element73.useMemo)( 26297 () => Object.fromEntries( 26298 Object.entries(defaultLayoutsProperty).filter(([layoutType]) => { 26299 return dataViewsPickerLayouts.some( 26300 (viewLayout) => viewLayout.type === layoutType 26301 ); 26302 }).map(([key, value]) => [ 26303 key, 26304 value === true ? {} : value 26305 ]) 26306 ), 26307 [defaultLayoutsProperty] 26308 ); 26309 if (!defaultLayouts2[view.type]) { 26310 return null; 26311 } 26312 return /* @__PURE__ */ (0, import_jsx_runtime116.jsx)( 26313 dataviews_context_default.Provider, 26314 { 26315 value: { 26316 view, 26317 onChangeView, 26318 fields: _fields, 26319 actions, 26320 data: displayData, 26321 isLoading, 26322 paginationInfo, 26323 isItemClickable, 26324 selection, 26325 onChangeSelection: setSelectionWithChange, 26326 openedFilter, 26327 setOpenedFilter, 26328 getItemId, 26329 containerWidth, 26330 containerRef, 26331 resizeObserverRef, 26332 defaultLayouts: defaultLayouts2, 26333 filters, 26334 isShowingFilter, 26335 setIsShowingFilter, 26336 config, 26337 itemListLabel, 26338 empty, 26339 onReset, 26340 hasInitiallyLoaded: true, 26341 intersectionObserver 26342 }, 26343 children: /* @__PURE__ */ (0, import_jsx_runtime116.jsx)("div", { className: "dataviews-picker-wrapper", children: children ?? /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(DefaultUI, { search, searchLabel }) }) 26344 } 26345 ); 26346 } 26347 var DataViewsPickerSubComponents = DataViewsPicker; 26348 DataViewsPickerSubComponents.BulkActionToolbar = DataViewsPickerFooter; 26349 DataViewsPickerSubComponents.Filters = filters_default; 26350 DataViewsPickerSubComponents.FiltersToggled = filters_toggled_default; 26351 DataViewsPickerSubComponents.FiltersToggle = toggle_default; 26352 DataViewsPickerSubComponents.Layout = DataViewsLayout; 26353 DataViewsPickerSubComponents.LayoutSwitcher = ViewTypeMenu; 26354 DataViewsPickerSubComponents.Pagination = DataViewsPagination; 26355 DataViewsPickerSubComponents.Search = dataviews_search_default; 26356 DataViewsPickerSubComponents.ViewConfig = DataviewsViewConfigDropdown; 26357 var dataviews_picker_default = DataViewsPickerSubComponents; 26358 26359 // node_modules/dequal/dist/index.mjs 26360 var has = Object.prototype.hasOwnProperty; 26361 function find(iter, tar, key) { 26362 for (key of iter.keys()) { 26363 if (dequal(key, tar)) return key; 26364 } 26365 } 26366 function dequal(foo, bar) { 26367 var ctor, len, tmp; 26368 if (foo === bar) return true; 26369 if (foo && bar && (ctor = foo.constructor) === bar.constructor) { 26370 if (ctor === Date) return foo.getTime() === bar.getTime(); 26371 if (ctor === RegExp) return foo.toString() === bar.toString(); 26372 if (ctor === Array) { 26373 if ((len = foo.length) === bar.length) { 26374 while (len-- && dequal(foo[len], bar[len])) ; 26375 } 26376 return len === -1; 26377 } 26378 if (ctor === Set) { 26379 if (foo.size !== bar.size) { 26380 return false; 26381 } 26382 for (len of foo) { 26383 tmp = len; 26384 if (tmp && typeof tmp === "object") { 26385 tmp = find(bar, tmp); 26386 if (!tmp) return false; 26387 } 26388 if (!bar.has(tmp)) return false; 26389 } 26390 return true; 26391 } 26392 if (ctor === Map) { 26393 if (foo.size !== bar.size) { 26394 return false; 26395 } 26396 for (len of foo) { 26397 tmp = len[0]; 26398 if (tmp && typeof tmp === "object") { 26399 tmp = find(bar, tmp); 26400 if (!tmp) return false; 26401 } 26402 if (!dequal(len[1], bar.get(tmp))) { 26403 return false; 26404 } 26405 } 26406 return true; 26407 } 26408 if (ctor === ArrayBuffer) { 26409 foo = new Uint8Array(foo); 26410 bar = new Uint8Array(bar); 26411 } else if (ctor === DataView) { 26412 if ((len = foo.byteLength) === bar.byteLength) { 26413 while (len-- && foo.getInt8(len) === bar.getInt8(len)) ; 26414 } 26415 return len === -1; 26416 } 26417 if (ArrayBuffer.isView(foo)) { 26418 if ((len = foo.byteLength) === bar.byteLength) { 26419 while (len-- && foo[len] === bar[len]) ; 26420 } 26421 return len === -1; 26422 } 26423 if (!ctor || typeof foo === "object") { 26424 len = 0; 26425 for (ctor in foo) { 26426 if (has.call(foo, ctor) && ++len && !has.call(bar, ctor)) return false; 26427 if (!(ctor in bar) || !dequal(foo[ctor], bar[ctor])) return false; 26428 } 26429 return Object.keys(bar).length === len; 26430 } 26431 } 26432 return foo !== foo && bar !== bar; 26433 } 26434 26435 // packages/views/build-module/use-view.mjs 26436 var import_element74 = __toESM(require_element(), 1); 26437 var import_data6 = __toESM(require_data(), 1); 26438 var import_preferences = __toESM(require_preferences(), 1); 26439 26440 // packages/views/build-module/preference-keys.mjs 26441 function generatePreferenceKey(kind, name, slug) { 26442 return `dataviews-$kind}-$name}-$slug}`; 26443 } 26444 26445 // packages/views/build-module/filter-utils.mjs 26446 var SCALAR_VALUES = [ 26447 "titleField", 26448 "mediaField", 26449 "descriptionField", 26450 "showTitle", 26451 "showMedia", 26452 "showDescription", 26453 "showLevels", 26454 "infiniteScrollEnabled" 26455 ]; 26456 function mergeActiveViewOverrides(view, activeViewOverrides, defaultView2) { 26457 if (!activeViewOverrides) { 26458 return view; 26459 } 26460 let result = view; 26461 for (const key of SCALAR_VALUES) { 26462 if (key in activeViewOverrides) { 26463 result = { ...result, [key]: activeViewOverrides[key] }; 26464 } 26465 } 26466 if (activeViewOverrides.filters && activeViewOverrides.filters.length > 0) { 26467 const activeFields = new Set( 26468 activeViewOverrides.filters.map((f2) => f2.field) 26469 ); 26470 const preserved = (view.filters ?? []).filter( 26471 (f2) => !activeFields.has(f2.field) 26472 ); 26473 result = { 26474 ...result, 26475 filters: [...preserved, ...activeViewOverrides.filters] 26476 }; 26477 } 26478 if (activeViewOverrides.sort) { 26479 const isDefaultSort = defaultView2 && view.sort?.field === defaultView2.sort?.field && view.sort?.direction === defaultView2.sort?.direction; 26480 if (isDefaultSort) { 26481 result = { 26482 ...result, 26483 sort: activeViewOverrides.sort 26484 }; 26485 } 26486 } 26487 if (activeViewOverrides.layout) { 26488 result = { 26489 ...result, 26490 layout: { 26491 ...result.layout, 26492 ...activeViewOverrides.layout 26493 } 26494 }; 26495 } 26496 if (activeViewOverrides.groupBy) { 26497 result = { 26498 ...result, 26499 groupBy: activeViewOverrides.groupBy 26500 }; 26501 } 26502 return result; 26503 } 26504 function stripActiveViewOverrides(view, activeViewOverrides, defaultView2) { 26505 if (!activeViewOverrides) { 26506 return view; 26507 } 26508 let result = view; 26509 for (const key of SCALAR_VALUES) { 26510 if (key in activeViewOverrides) { 26511 const { [key]: _, ...rest } = result; 26512 result = rest; 26513 } 26514 } 26515 if (activeViewOverrides.filters && activeViewOverrides.filters.length > 0) { 26516 const activeFields = new Set( 26517 activeViewOverrides.filters.map((f2) => f2.field) 26518 ); 26519 result = { 26520 ...result, 26521 filters: (view.filters ?? []).filter( 26522 (f2) => !activeFields.has(f2.field) 26523 ) 26524 }; 26525 } 26526 if (activeViewOverrides.sort && view.sort?.field === activeViewOverrides.sort.field && view.sort?.direction === activeViewOverrides.sort.direction) { 26527 result = { 26528 ...result, 26529 sort: defaultView2?.sort 26530 }; 26531 } 26532 if (activeViewOverrides.layout && "layout" in result && result.layout) { 26533 const layout = { ...result.layout }; 26534 for (const key of Object.keys(activeViewOverrides.layout)) { 26535 delete layout[key]; 26536 } 26537 result = { 26538 ...result, 26539 layout: Object.keys(layout).length > 0 ? layout : void 0 26540 }; 26541 } 26542 if (activeViewOverrides.groupBy && "groupBy" in result) { 26543 const { groupBy: _, ...rest } = result; 26544 result = rest; 26545 } 26546 return result; 26547 } 26548 26549 // packages/views/build-module/use-view.mjs 26550 function omit3(obj, keys) { 26551 const result = { ...obj }; 26552 for (const key of keys) { 26553 delete result[key]; 26554 } 26555 return result; 26556 } 26557 function useView(config) { 26558 const { 26559 kind, 26560 name, 26561 slug, 26562 defaultView: defaultView2, 26563 activeViewOverrides, 26564 queryParams, 26565 onChangeQueryParams 26566 } = config; 26567 const preferenceKey = generatePreferenceKey(kind, name, slug); 26568 const persistedView = (0, import_data6.useSelect)( 26569 (select2) => { 26570 return select2(import_preferences.store).get( 26571 "core/views", 26572 preferenceKey 26573 ); 26574 }, 26575 [preferenceKey] 26576 ); 26577 const { set: set2 } = (0, import_data6.useDispatch)(import_preferences.store); 26578 const baseView = (0, import_element74.useMemo)( 26579 () => persistedView ?? defaultView2 ?? {}, 26580 [persistedView, defaultView2] 26581 ); 26582 const page = Number(queryParams?.page ?? baseView.page ?? 1); 26583 const search = queryParams?.search ?? baseView.search ?? ""; 26584 const combinedOverrides = (0, import_element74.useMemo)(() => { 26585 const rawDefaults = config.defaultLayouts?.[baseView.type]; 26586 const layoutTypeDefaults = !rawDefaults || rawDefaults === true ? {} : rawDefaults; 26587 return { ...layoutTypeDefaults, ...activeViewOverrides }; 26588 }, [config.defaultLayouts, baseView.type, activeViewOverrides]); 26589 const view = (0, import_element74.useMemo)(() => { 26590 return mergeActiveViewOverrides( 26591 { 26592 ...baseView, 26593 page, 26594 search 26595 }, 26596 combinedOverrides, 26597 defaultView2 26598 ); 26599 }, [baseView, page, search, combinedOverrides, defaultView2]); 26600 const isModified = !!persistedView; 26601 const updateView = (0, import_element74.useCallback)( 26602 (newView) => { 26603 const urlParams = { 26604 page: newView?.page, 26605 search: newView?.search 26606 }; 26607 const preferenceView = stripActiveViewOverrides( 26608 omit3(newView, ["page", "search"]), 26609 combinedOverrides, 26610 defaultView2 26611 ); 26612 if (onChangeQueryParams && !dequal(urlParams, { page, search })) { 26613 onChangeQueryParams(urlParams); 26614 } 26615 const comparableBaseView = stripActiveViewOverrides( 26616 baseView, 26617 combinedOverrides, 26618 defaultView2 26619 ); 26620 const comparableDefaultView = stripActiveViewOverrides( 26621 defaultView2, 26622 combinedOverrides, 26623 defaultView2 26624 ); 26625 if (!dequal(comparableBaseView, preferenceView)) { 26626 if (dequal(preferenceView, comparableDefaultView)) { 26627 set2("core/views", preferenceKey, void 0); 26628 } else { 26629 set2("core/views", preferenceKey, preferenceView); 26630 } 26631 } 26632 }, 26633 [ 26634 onChangeQueryParams, 26635 page, 26636 search, 26637 baseView, 26638 defaultView2, 26639 combinedOverrides, 26640 set2, 26641 preferenceKey 26642 ] 26643 ); 26644 const resetToDefault = (0, import_element74.useCallback)(() => { 26645 set2("core/views", preferenceKey, void 0); 26646 }, [preferenceKey, set2]); 26647 return { 26648 view, 26649 isModified, 26650 updateView, 26651 resetToDefault 26652 }; 26653 } 26654 26655 // packages/views/build-module/load-view.mjs 26656 var import_data7 = __toESM(require_data(), 1); 26657 var import_preferences2 = __toESM(require_preferences(), 1); 26658 26659 // packages/views/build-module/use-view-config.mjs 26660 var import_data8 = __toESM(require_data(), 1); 26661 var import_core_data = __toESM(require_core_data(), 1); 26662 26663 // packages/views/build-module/lock-unlock.mjs 26664 var import_private_apis3 = __toESM(require_private_apis(), 1); 26665 var { lock: lock3, unlock: unlock3 } = (0, import_private_apis3.__dangerousOptInToUnstableAPIsOnlyForCoreModules)( 26666 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.", 26667 "@wordpress/views" 26668 ); 26669 26670 // packages/media-fields/build-module/alt_text/index.mjs 26671 var import_i18n50 = __toESM(require_i18n(), 1); 26672 var import_components46 = __toESM(require_components(), 1); 26673 var import_jsx_runtime117 = __toESM(require_jsx_runtime(), 1); 26674 var altTextField = { 26675 id: "alt_text", 26676 type: "text", 26677 label: (0, import_i18n50.__)("Alt text"), 26678 isVisible: (item) => item?.media_type === "image", 26679 render: ({ item }) => item?.alt_text || "-", 26680 Edit: ({ field, onChange, data }) => { 26681 return /* @__PURE__ */ (0, import_jsx_runtime117.jsx)( 26682 import_components46.TextareaControl, 26683 { 26684 label: field.label, 26685 value: data.alt_text || "", 26686 onChange: (value) => onChange({ alt_text: value }), 26687 rows: 2 26688 } 26689 ); 26690 }, 26691 enableSorting: false, 26692 filterBy: false 26693 }; 26694 var alt_text_default = altTextField; 26695 26696 // packages/media-fields/build-module/attached_to/index.mjs 26697 var import_i18n53 = __toESM(require_i18n(), 1); 26698 26699 // packages/media-fields/build-module/attached_to/view.mjs 26700 var import_element75 = __toESM(require_element(), 1); 26701 var import_i18n51 = __toESM(require_i18n(), 1); 26702 26703 // packages/media-fields/build-module/utils/get-rendered-content.mjs 26704 function getRenderedContent(content) { 26705 if (!content) { 26706 return ""; 26707 } 26708 if (typeof content === "string") { 26709 return content; 26710 } 26711 if (typeof content === "object") { 26712 return content.rendered || content.raw || ""; 26713 } 26714 return ""; 26715 } 26716 26717 // packages/media-fields/build-module/attached_to/view.mjs 26718 var import_jsx_runtime118 = __toESM(require_jsx_runtime(), 1); 26719 function MediaAttachedToView({ 26720 item 26721 }) { 26722 const [attachedPostTitle, setAttachedPostTitle] = (0, import_element75.useState)(null); 26723 const parentId = item.post; 26724 const embeddedPostId = item._embedded?.["wp:attached-to"]?.[0]?.id; 26725 const embeddedPostTitle = item._embedded?.["wp:attached-to"]?.[0]?.title; 26726 (0, import_element75.useEffect)(() => { 26727 if (!!parentId && parentId === embeddedPostId) { 26728 setAttachedPostTitle( 26729 getRenderedContent(embeddedPostTitle) || (0, import_i18n51.__)("(no title)") 26730 ); 26731 } 26732 if (!parentId) { 26733 setAttachedPostTitle((0, import_i18n51.__)("(Unattached)")); 26734 } 26735 }, [parentId, embeddedPostId, embeddedPostTitle]); 26736 return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(import_jsx_runtime118.Fragment, { children: attachedPostTitle }); 26737 } 26738 26739 // packages/media-fields/build-module/attached_to/edit.mjs 26740 var import_core_data2 = __toESM(require_core_data(), 1); 26741 var import_components47 = __toESM(require_components(), 1); 26742 var import_i18n52 = __toESM(require_i18n(), 1); 26743 var import_element76 = __toESM(require_element(), 1); 26744 var import_compose14 = __toESM(require_compose(), 1); 26745 var import_data9 = __toESM(require_data(), 1); 26746 var import_jsx_runtime119 = __toESM(require_jsx_runtime(), 1); 26747 function MediaAttachedToEdit({ 26748 data, 26749 onChange 26750 }) { 26751 const defaultPost = !!data.post && !!data?._embedded?.["wp:attached-to"]?.[0] ? [ 26752 { 26753 label: getRenderedContent( 26754 data._embedded?.["wp:attached-to"]?.[0]?.title 26755 ), 26756 value: data.post.toString() 26757 } 26758 ] : []; 26759 const [options, setOptions] = (0, import_element76.useState)(defaultPost); 26760 const [searchResults, setSearchResults] = (0, import_element76.useState)( 26761 [] 26762 ); 26763 const [isLoading, setIsLoading] = (0, import_element76.useState)(false); 26764 const [value, setValue] = (0, import_element76.useState)( 26765 data?.post?.toString() ?? null 26766 ); 26767 const postTypes = (0, import_data9.useSelect)( 26768 (select2) => select2(import_core_data2.store).getPostTypes(), 26769 [] 26770 ); 26771 const handleDetach = () => { 26772 onChange({ 26773 post: 0, 26774 _embedded: { ...data?._embedded, "wp:attached-to": void 0 } 26775 }); 26776 setOptions([]); 26777 }; 26778 const onValueChange = async (filterValue) => { 26779 setIsLoading(true); 26780 const results = await (0, import_core_data2.__experimentalFetchLinkSuggestions)( 26781 filterValue, 26782 /* 26783 * @TODO `fetchLinkSuggestions()` should accept `perPage` as an option argument. 26784 * `isInitialSuggestions` limits the result to 3, otherwise it's hardcoded to 20. 26785 */ 26786 { type: "post", isInitialSuggestions: true }, 26787 {} 26788 ); 26789 setSearchResults(results); 26790 const mappedSuggestions = results.map((result) => { 26791 return { 26792 label: result.title, 26793 value: result.id.toString() 26794 }; 26795 }); 26796 setOptions(mappedSuggestions); 26797 setIsLoading(false); 26798 }; 26799 const handleSelectOption = (selectedPostId) => { 26800 if (!selectedPostId) { 26801 handleDetach(); 26802 return; 26803 } 26804 setValue(selectedPostId); 26805 if (selectedPostId) { 26806 const selectedPost = searchResults.find( 26807 (result) => result.id === Number(selectedPostId) 26808 ); 26809 if (selectedPost && postTypes) { 26810 const postType = postTypes.find( 26811 (_postType) => _postType.slug === selectedPost?.type 26812 ); 26813 const attachedTo = { 26814 ...postType && { type: postType.slug }, 26815 id: Number(selectedPostId), 26816 title: { 26817 raw: selectedPost.title, 26818 rendered: selectedPost.title 26819 } 26820 }; 26821 onChange({ 26822 post: Number(selectedPostId), 26823 _embedded: { 26824 ...data?._embedded, 26825 "wp:attached-to": [attachedTo] 26826 } 26827 }); 26828 } 26829 } 26830 }; 26831 const help = !!data.post ? (0, import_element76.createInterpolateElement)( 26832 (0, import_i18n52.__)( 26833 "Search for a post or page to attach this media to or <button>detach current</button>." 26834 ), 26835 { 26836 button: /* @__PURE__ */ (0, import_jsx_runtime119.jsx)( 26837 import_components47.Button, 26838 { 26839 __next40pxDefaultSize: true, 26840 onClick: handleDetach, 26841 variant: "link", 26842 accessibleWhenDisabled: true 26843 } 26844 ) 26845 } 26846 ) : (0, import_i18n52.__)("Search for a post or page to attach this media to."); 26847 return /* @__PURE__ */ (0, import_jsx_runtime119.jsx)( 26848 import_components47.ComboboxControl, 26849 { 26850 className: "dataviews-media-field__attached-to", 26851 __next40pxDefaultSize: true, 26852 isLoading, 26853 label: (0, import_i18n52.__)("Attached to"), 26854 help, 26855 value, 26856 options, 26857 onFilterValueChange: (0, import_compose14.debounce)( 26858 (filterValue) => onValueChange(filterValue), 26859 300 26860 ), 26861 onChange: handleSelectOption, 26862 hideLabelFromVision: true 26863 } 26864 ); 26865 } 26866 26867 // packages/media-fields/build-module/attached_to/index.mjs 26868 var attachedToField = { 26869 id: "attached_to", 26870 type: "text", 26871 label: (0, import_i18n53.__)("Attached to"), 26872 Edit: MediaAttachedToEdit, 26873 render: MediaAttachedToView, 26874 enableSorting: false, 26875 filterBy: false 26876 }; 26877 var attached_to_default = attachedToField; 26878 26879 // packages/media-fields/build-module/author/index.mjs 26880 var import_i18n55 = __toESM(require_i18n(), 1); 26881 var import_data10 = __toESM(require_data(), 1); 26882 var import_core_data3 = __toESM(require_core_data(), 1); 26883 26884 // packages/media-fields/build-module/author/view.mjs 26885 var import_i18n54 = __toESM(require_i18n(), 1); 26886 var import_element77 = __toESM(require_element(), 1); 26887 var import_components48 = __toESM(require_components(), 1); 26888 var import_jsx_runtime120 = __toESM(require_jsx_runtime(), 1); 26889 function AuthorView({ 26890 item 26891 }) { 26892 const author = item?._embedded?.author?.[0]; 26893 const text = author?.name; 26894 const imageUrl = author?.avatar_urls?.[48]; 26895 const [loadingState, setLoadingState] = (0, import_element77.useState)("loading"); 26896 (0, import_element77.useEffect)(() => { 26897 setLoadingState("loading"); 26898 }, [imageUrl]); 26899 const imgRef = (0, import_element77.useCallback)((img) => { 26900 if (img?.complete) { 26901 setLoadingState("instant"); 26902 } 26903 }, []); 26904 const handleLoad = () => { 26905 if (loadingState === "loading") { 26906 setLoadingState("loaded"); 26907 } 26908 }; 26909 return /* @__PURE__ */ (0, import_jsx_runtime120.jsxs)(import_components48.__experimentalHStack, { alignment: "left", spacing: 0, children: [ 26910 !!imageUrl && /* @__PURE__ */ (0, import_jsx_runtime120.jsx)( 26911 "div", 26912 { 26913 className: clsx_default("media-author-field__avatar", { 26914 "is-loading": loadingState === "loading", 26915 "is-loaded": loadingState === "loaded" 26916 }), 26917 children: /* @__PURE__ */ (0, import_jsx_runtime120.jsx)( 26918 "img", 26919 { 26920 ref: imgRef, 26921 onLoad: handleLoad, 26922 alt: (0, import_i18n54.__)("Author avatar"), 26923 src: imageUrl 26924 } 26925 ) 26926 } 26927 ), 26928 !imageUrl && /* @__PURE__ */ (0, import_jsx_runtime120.jsx)("div", { className: "media-author-field__icon", children: /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(import_components48.Icon, { icon: comment_author_avatar_default }) }), 26929 /* @__PURE__ */ (0, import_jsx_runtime120.jsx)("span", { className: "media-author-field__name", children: text }) 26930 ] }); 26931 } 26932 26933 // packages/media-fields/build-module/author/index.mjs 26934 var authorField = { 26935 label: (0, import_i18n55.__)("Author"), 26936 id: "author", 26937 type: "integer", 26938 getElements: async () => { 26939 const authors = await (0, import_data10.resolveSelect)(import_core_data3.store).getEntityRecords( 26940 "root", 26941 "user", 26942 { 26943 per_page: -1, 26944 who: "authors", 26945 _fields: "id,name", 26946 context: "view" 26947 } 26948 ) ?? []; 26949 return authors.map(({ id, name }) => ({ 26950 value: id, 26951 label: name 26952 })); 26953 }, 26954 render: AuthorView, 26955 sort: (a2, b2, direction) => { 26956 const nameA = a2._embedded?.author?.[0]?.name || ""; 26957 const nameB = b2._embedded?.author?.[0]?.name || ""; 26958 return direction === "asc" ? nameA.localeCompare(nameB) : nameB.localeCompare(nameA); 26959 }, 26960 filterBy: { 26961 operators: ["isAny", "isNone"] 26962 }, 26963 readOnly: true 26964 }; 26965 var author_default = authorField; 26966 26967 // packages/media-fields/build-module/caption/index.mjs 26968 var import_i18n56 = __toESM(require_i18n(), 1); 26969 var import_components49 = __toESM(require_components(), 1); 26970 26971 // packages/media-fields/build-module/utils/get-raw-content.mjs 26972 function getRawContent(content) { 26973 if (!content) { 26974 return ""; 26975 } 26976 if (typeof content === "string") { 26977 return content; 26978 } 26979 if (typeof content === "object" && "raw" in content) { 26980 return content.raw || ""; 26981 } 26982 return ""; 26983 } 26984 26985 // packages/media-fields/build-module/caption/index.mjs 26986 var import_jsx_runtime121 = __toESM(require_jsx_runtime(), 1); 26987 var captionField = { 26988 id: "caption", 26989 type: "text", 26990 label: (0, import_i18n56.__)("Caption"), 26991 getValue: ({ item }) => getRawContent(item?.caption), 26992 render: ({ item }) => getRawContent(item?.caption) || "-", 26993 Edit: ({ field, onChange, data }) => { 26994 return /* @__PURE__ */ (0, import_jsx_runtime121.jsx)( 26995 import_components49.TextareaControl, 26996 { 26997 label: field.label, 26998 value: getRawContent(data.caption) || "", 26999 onChange: (value) => onChange({ caption: value }), 27000 rows: 2 27001 } 27002 ); 27003 }, 27004 enableSorting: false, 27005 filterBy: false 27006 }; 27007 var caption_default = captionField; 27008 27009 // packages/media-fields/build-module/date_added/index.mjs 27010 var import_i18n57 = __toESM(require_i18n(), 1); 27011 var dateAddedField = { 27012 id: "date", 27013 type: "datetime", 27014 label: (0, import_i18n57.__)("Date added"), 27015 filterBy: { 27016 operators: ["before", "after"] 27017 }, 27018 readOnly: true 27019 }; 27020 var date_added_default = dateAddedField; 27021 27022 // packages/media-fields/build-module/date_modified/index.mjs 27023 var import_i18n58 = __toESM(require_i18n(), 1); 27024 var dateModifiedField = { 27025 id: "modified", 27026 type: "datetime", 27027 label: (0, import_i18n58.__)("Date modified"), 27028 filterBy: { 27029 operators: ["before", "after"] 27030 }, 27031 readOnly: true 27032 }; 27033 var date_modified_default = dateModifiedField; 27034 27035 // packages/media-fields/build-module/description/index.mjs 27036 var import_i18n59 = __toESM(require_i18n(), 1); 27037 var import_components50 = __toESM(require_components(), 1); 27038 var import_jsx_runtime122 = __toESM(require_jsx_runtime(), 1); 27039 var descriptionField = { 27040 id: "description", 27041 type: "text", 27042 label: (0, import_i18n59.__)("Description"), 27043 getValue: ({ item }) => getRawContent(item?.description), 27044 render: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime122.jsx)("div", { children: getRawContent(item?.description) || "-" }), 27045 Edit: ({ field, onChange, data }) => { 27046 return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)( 27047 import_components50.TextareaControl, 27048 { 27049 label: field.label, 27050 value: getRawContent(data.description) || "", 27051 onChange: (value) => onChange({ description: value }), 27052 rows: 5 27053 } 27054 ); 27055 }, 27056 enableSorting: false, 27057 filterBy: false 27058 }; 27059 var description_default = descriptionField; 27060 27061 // packages/media-fields/build-module/filename/index.mjs 27062 var import_i18n60 = __toESM(require_i18n(), 1); 27063 var import_url4 = __toESM(require_url(), 1); 27064 27065 // packages/media-fields/build-module/filename/view.mjs 27066 var import_element78 = __toESM(require_element(), 1); 27067 var import_url3 = __toESM(require_url(), 1); 27068 var import_jsx_runtime123 = __toESM(require_jsx_runtime(), 1); 27069 var TRUNCATE_LENGTH = 15; 27070 function FileNameView({ 27071 item 27072 }) { 27073 const fileName = (0, import_element78.useMemo)( 27074 () => item?.source_url ? (0, import_url3.getFilename)(item.source_url) : null, 27075 [item?.source_url] 27076 ); 27077 if (!fileName) { 27078 return ""; 27079 } 27080 if (fileName.length <= TRUNCATE_LENGTH) { 27081 return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)("span", { className: "dataviews-media-field__filename", children: fileName }); 27082 } 27083 return /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)(tooltip_exports.Root, { children: [ 27084 /* @__PURE__ */ (0, import_jsx_runtime123.jsx)( 27085 tooltip_exports.Trigger, 27086 { 27087 render: /* @__PURE__ */ (0, import_jsx_runtime123.jsx)("span", { className: "dataviews-media-field__filename", children: fileName }) 27088 } 27089 ), 27090 /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(tooltip_exports.Popup, { children: fileName }) 27091 ] }); 27092 } 27093 27094 // packages/media-fields/build-module/filename/index.mjs 27095 var filenameField = { 27096 id: "filename", 27097 type: "text", 27098 label: (0, import_i18n60.__)("File name"), 27099 getValue: ({ item }) => (0, import_url4.getFilename)(item?.source_url || ""), 27100 render: FileNameView, 27101 enableSorting: false, 27102 filterBy: false, 27103 readOnly: true 27104 }; 27105 var filename_default = filenameField; 27106 27107 // packages/media-fields/build-module/filesize/index.mjs 27108 var import_i18n61 = __toESM(require_i18n(), 1); 27109 var KB_IN_BYTES = 1024; 27110 var MB_IN_BYTES = 1024 * KB_IN_BYTES; 27111 var GB_IN_BYTES = 1024 * MB_IN_BYTES; 27112 var TB_IN_BYTES = 1024 * GB_IN_BYTES; 27113 var PB_IN_BYTES = 1024 * TB_IN_BYTES; 27114 var EB_IN_BYTES = 1024 * PB_IN_BYTES; 27115 var ZB_IN_BYTES = 1024 * EB_IN_BYTES; 27116 var YB_IN_BYTES = 1024 * ZB_IN_BYTES; 27117 function getBytesString(bytes, unitSymbol, decimals = 2) { 27118 return (0, import_i18n61.sprintf)( 27119 // translators: 1: Actual bytes of a file. 2: The unit symbol (e.g. MB). 27120 (0, import_i18n61._x)("%1$s %2$s", "file size"), 27121 bytes.toLocaleString(void 0, { 27122 minimumFractionDigits: 0, 27123 maximumFractionDigits: decimals 27124 }), 27125 unitSymbol 27126 ); 27127 } 27128 function formatFileSize(bytes, decimals = 2) { 27129 if (bytes === 0) { 27130 return getBytesString(0, (0, import_i18n61._x)("B", "unit symbol"), decimals); 27131 } 27132 const quant = { 27133 /* translators: Unit symbol for yottabyte. */ 27134 [(0, import_i18n61._x)("YB", "unit symbol")]: YB_IN_BYTES, 27135 /* translators: Unit symbol for zettabyte. */ 27136 [(0, import_i18n61._x)("ZB", "unit symbol")]: ZB_IN_BYTES, 27137 /* translators: Unit symbol for exabyte. */ 27138 [(0, import_i18n61._x)("EB", "unit symbol")]: EB_IN_BYTES, 27139 /* translators: Unit symbol for petabyte. */ 27140 [(0, import_i18n61._x)("PB", "unit symbol")]: PB_IN_BYTES, 27141 /* translators: Unit symbol for terabyte. */ 27142 [(0, import_i18n61._x)("TB", "unit symbol")]: TB_IN_BYTES, 27143 /* translators: Unit symbol for gigabyte. */ 27144 [(0, import_i18n61._x)("GB", "unit symbol")]: GB_IN_BYTES, 27145 /* translators: Unit symbol for megabyte. */ 27146 [(0, import_i18n61._x)("MB", "unit symbol")]: MB_IN_BYTES, 27147 /* translators: Unit symbol for kilobyte. */ 27148 [(0, import_i18n61._x)("KB", "unit symbol")]: KB_IN_BYTES, 27149 /* translators: Unit symbol for byte. */ 27150 [(0, import_i18n61._x)("B", "unit symbol")]: 1 27151 }; 27152 for (const [unit, mag] of Object.entries(quant)) { 27153 if (bytes >= mag) { 27154 return getBytesString(bytes / mag, unit, decimals); 27155 } 27156 } 27157 return ""; 27158 } 27159 var filesizeField = { 27160 id: "filesize", 27161 type: "text", 27162 label: (0, import_i18n61.__)("File size"), 27163 getValue: ({ item }) => item?.media_details?.filesize ? formatFileSize(item?.media_details?.filesize) : "", 27164 isVisible: (item) => { 27165 return !!item?.media_details?.filesize; 27166 }, 27167 enableSorting: false, 27168 filterBy: false, 27169 readOnly: true 27170 }; 27171 var filesize_default = filesizeField; 27172 27173 // packages/media-fields/build-module/media_dimensions/index.mjs 27174 var import_i18n62 = __toESM(require_i18n(), 1); 27175 var mediaDimensionsField = { 27176 id: "media_dimensions", 27177 type: "text", 27178 label: (0, import_i18n62.__)("Dimensions"), 27179 getValue: ({ item }) => item?.media_details?.width && item?.media_details?.height ? (0, import_i18n62.sprintf)( 27180 // translators: 1: Width. 2: Height. 27181 (0, import_i18n62._x)("%1$s \xD7 %2$s", "image dimensions"), 27182 item?.media_details?.width?.toString(), 27183 item?.media_details?.height?.toString() 27184 ) : "", 27185 isVisible: (item) => { 27186 return !!(item?.media_details?.width && item?.media_details?.height); 27187 }, 27188 enableSorting: false, 27189 filterBy: false, 27190 readOnly: true 27191 }; 27192 var media_dimensions_default = mediaDimensionsField; 27193 27194 // packages/media-fields/build-module/media_thumbnail/index.mjs 27195 var import_i18n64 = __toESM(require_i18n(), 1); 27196 27197 // packages/media-fields/build-module/media_thumbnail/view.mjs 27198 var import_data11 = __toESM(require_data(), 1); 27199 var import_core_data4 = __toESM(require_core_data(), 1); 27200 var import_components51 = __toESM(require_components(), 1); 27201 var import_element79 = __toESM(require_element(), 1); 27202 var import_url5 = __toESM(require_url(), 1); 27203 27204 // packages/media-fields/build-module/utils/get-media-type-from-mime-type.mjs 27205 var import_i18n63 = __toESM(require_i18n(), 1); 27206 function getMediaTypeFromMimeType(mimeType) { 27207 if (mimeType.startsWith("image/")) { 27208 return { 27209 type: "image", 27210 label: (0, import_i18n63.__)("Image"), 27211 icon: image_default 27212 }; 27213 } 27214 if (mimeType.startsWith("video/")) { 27215 return { 27216 type: "video", 27217 label: (0, import_i18n63.__)("Video"), 27218 icon: video_default 27219 }; 27220 } 27221 if (mimeType.startsWith("audio/")) { 27222 return { 27223 type: "audio", 27224 label: (0, import_i18n63.__)("Audio"), 27225 icon: audio_default 27226 }; 27227 } 27228 return { 27229 type: "application", 27230 label: (0, import_i18n63.__)("Application"), 27231 icon: file_default 27232 }; 27233 } 27234 27235 // packages/media-fields/build-module/media_thumbnail/view.mjs 27236 var import_jsx_runtime124 = __toESM(require_jsx_runtime(), 1); 27237 function getBestImageUrl(featuredMedia, configSizes) { 27238 const sizes = featuredMedia?.media_details?.sizes; 27239 if (!sizes) { 27240 return featuredMedia.source_url; 27241 } 27242 const sizeEntries = Object.values(sizes); 27243 if (!sizeEntries.length) { 27244 return featuredMedia.source_url; 27245 } 27246 const targetWidth = configSizes ? parseInt(configSizes, 10) : NaN; 27247 if (!Number.isNaN(targetWidth)) { 27248 const validEntries = sizeEntries.filter( 27249 (s2) => typeof s2.width === "number" && !Number.isNaN(s2.width) 27250 ); 27251 if (!validEntries.length) { 27252 return featuredMedia.source_url; 27253 } 27254 const sorted = [...validEntries].sort( 27255 (a2, b2) => a2.width - b2.width 27256 ); 27257 const match2 = sorted.find((s2) => s2.width >= targetWidth); 27258 if (match2) { 27259 return match2.source_url; 27260 } 27261 return sorted[sorted.length - 1].source_url; 27262 } 27263 return featuredMedia.source_url; 27264 } 27265 function FallbackView({ 27266 item, 27267 filename 27268 }) { 27269 return /* @__PURE__ */ (0, import_jsx_runtime124.jsx)("div", { className: "dataviews-media-field__media-thumbnail", children: /* @__PURE__ */ (0, import_jsx_runtime124.jsxs)( 27270 import_components51.__experimentalVStack, 27271 { 27272 justify: "center", 27273 alignment: "center", 27274 className: "dataviews-media-field__media-thumbnail__stack", 27275 spacing: 0, 27276 children: [ 27277 /* @__PURE__ */ (0, import_jsx_runtime124.jsx)( 27278 import_components51.Icon, 27279 { 27280 className: "dataviews-media-field__media-thumbnail--icon", 27281 icon: getMediaTypeFromMimeType(item.mime_type).icon, 27282 size: 24 27283 } 27284 ), 27285 !!filename && /* @__PURE__ */ (0, import_jsx_runtime124.jsx)("div", { className: "dataviews-media-field__media-thumbnail__filename", children: /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(import_components51.__experimentalTruncate, { className: "dataviews-media-field__media-thumbnail__filename__truncate", children: filename }) }) 27286 ] 27287 } 27288 ) }); 27289 } 27290 function ImageView({ 27291 item, 27292 configSizes, 27293 onError 27294 }) { 27295 const imageUrl = getBestImageUrl(item, configSizes); 27296 const imgRef = (0, import_element79.useRef)(null); 27297 const [loadingState, setLoadingState] = (0, import_element79.useState)("loading"); 27298 (0, import_element79.useLayoutEffect)(() => { 27299 if (imgRef.current?.complete) { 27300 setLoadingState("instant"); 27301 } else { 27302 setLoadingState("loading"); 27303 } 27304 }, [imageUrl]); 27305 const handleLoad = () => { 27306 if (loadingState === "loading") { 27307 setLoadingState("loaded"); 27308 } 27309 }; 27310 return /* @__PURE__ */ (0, import_jsx_runtime124.jsx)( 27311 "div", 27312 { 27313 className: clsx_default("dataviews-media-field__media-thumbnail", { 27314 "is-loading": loadingState === "loading", 27315 "is-loaded": loadingState === "loaded" 27316 }), 27317 children: /* @__PURE__ */ (0, import_jsx_runtime124.jsx)( 27318 "img", 27319 { 27320 ref: imgRef, 27321 className: "dataviews-media-field__media-thumbnail--image", 27322 src: imageUrl, 27323 alt: item.alt_text || item.title.raw, 27324 onLoad: handleLoad, 27325 onError, 27326 loading: "lazy" 27327 } 27328 ) 27329 } 27330 ); 27331 } 27332 function MediaThumbnailView({ 27333 item, 27334 config 27335 }) { 27336 const [imageError, setImageError] = (0, import_element79.useState)(false); 27337 const _featuredMedia = (0, import_data11.useSelect)( 27338 (select2) => { 27339 if (!item.featured_media) { 27340 return; 27341 } 27342 return select2(import_core_data4.store).getEntityRecord( 27343 "postType", 27344 "attachment", 27345 item.featured_media 27346 ); 27347 }, 27348 [item.featured_media] 27349 ); 27350 const featuredMedia = item.featured_media ? _featuredMedia : item; 27351 if (!featuredMedia) { 27352 return null; 27353 } 27354 const filename = (0, import_url5.getFilename)(featuredMedia.source_url || ""); 27355 if (imageError || getMediaTypeFromMimeType(featuredMedia.mime_type).type !== "image") { 27356 return /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(FallbackView, { item: featuredMedia, filename: filename || "" }); 27357 } 27358 return /* @__PURE__ */ (0, import_jsx_runtime124.jsx)( 27359 ImageView, 27360 { 27361 item: featuredMedia, 27362 configSizes: config?.sizes, 27363 onError: () => setImageError(true) 27364 } 27365 ); 27366 } 27367 27368 // packages/media-fields/build-module/media_thumbnail/index.mjs 27369 var mediaThumbnailField = { 27370 id: "media_thumbnail", 27371 type: "media", 27372 label: (0, import_i18n64.__)("Thumbnail"), 27373 render: MediaThumbnailView, 27374 enableSorting: false, 27375 filterBy: false 27376 }; 27377 var media_thumbnail_default = mediaThumbnailField; 27378 27379 // packages/media-fields/build-module/mime_type/index.mjs 27380 var import_i18n65 = __toESM(require_i18n(), 1); 27381 var mimeTypeField = { 27382 id: "mime_type", 27383 type: "text", 27384 label: (0, import_i18n65.__)("File type"), 27385 getValue: ({ item }) => item?.mime_type || "", 27386 render: ({ item }) => item?.mime_type || "-", 27387 // Disable sorting until REST API support for ordering my `mime_type` is added. 27388 // See: https://core.trac.wordpress.org/ticket/64073 27389 enableSorting: false, 27390 filterBy: false, 27391 readOnly: true 27392 }; 27393 var mime_type_default = mimeTypeField; 27394 27395 // packages/media-utils/build-module/components/media-upload-modal/index.mjs 27396 var import_notices = __toESM(require_notices(), 1); 27397 27398 // packages/media-utils/build-module/lock-unlock.mjs 27399 var import_private_apis4 = __toESM(require_private_apis(), 1); 27400 var { lock: lock4, unlock: unlock4 } = (0, import_private_apis4.__dangerousOptInToUnstableAPIsOnlyForCoreModules)( 27401 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.", 27402 "@wordpress/media-utils" 27403 ); 27404 27405 // packages/media-utils/build-module/components/media-upload-modal/upload-status-popover.mjs 27406 var import_element80 = __toESM(require_element(), 1); 27407 var import_i18n66 = __toESM(require_i18n(), 1); 27408 var import_components52 = __toESM(require_components(), 1); 27409 var import_jsx_runtime125 = __toESM(require_jsx_runtime(), 1); 27410 function UploadStatusPopover({ 27411 uploadingFiles, 27412 onDismissError, 27413 onOpenChange 27414 }) { 27415 const [isOpen, setIsOpen] = (0, import_element80.useState)(false); 27416 const [prevHadErrors, setPrevHadErrors] = (0, import_element80.useState)(false); 27417 const triggerRef = (0, import_element80.useRef)(null); 27418 const updateIsOpen = (0, import_element80.useCallback)( 27419 (open) => { 27420 setIsOpen(open); 27421 onOpenChange?.(open); 27422 }, 27423 [onOpenChange] 27424 ); 27425 const activeFiles = uploadingFiles.filter( 27426 (file) => file.status === "uploading" 27427 ); 27428 const errorFiles = uploadingFiles.filter( 27429 (file) => file.status === "error" 27430 ); 27431 const hasErrors = errorFiles.length > 0; 27432 const isUploading = activeFiles.length > 0; 27433 (0, import_element80.useEffect)(() => { 27434 if (hasErrors && !prevHadErrors) { 27435 updateIsOpen(true); 27436 } 27437 setPrevHadErrors(hasErrors); 27438 }, [hasErrors, prevHadErrors, updateIsOpen]); 27439 if (uploadingFiles.length === 0) { 27440 return null; 27441 } 27442 let buttonLabel, popoverHeading; 27443 if (isUploading) { 27444 buttonLabel = (0, import_i18n66.sprintf)( 27445 // translators: %s: number of files being uploaded 27446 (0, import_i18n66._n)("Uploading %s file", "Uploading %s files", activeFiles.length), 27447 activeFiles.length.toLocaleString() 27448 ); 27449 popoverHeading = (0, import_i18n66.__)("Uploading"); 27450 } else if (hasErrors) { 27451 buttonLabel = (0, import_i18n66.sprintf)( 27452 // translators: %s: number of upload errors 27453 (0, import_i18n66._n)("%s upload error", "%s upload errors", errorFiles.length), 27454 errorFiles.length.toLocaleString() 27455 ); 27456 popoverHeading = (0, import_i18n66.__)("Upload errors"); 27457 } else { 27458 buttonLabel = (0, import_i18n66.__)("Upload complete"); 27459 popoverHeading = (0, import_i18n66.__)("Upload complete"); 27460 } 27461 return /* @__PURE__ */ (0, import_jsx_runtime125.jsxs)("div", { className: "media-upload-modal__upload-status", children: [ 27462 isUploading && /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(import_components52.Spinner, {}), 27463 /* @__PURE__ */ (0, import_jsx_runtime125.jsx)( 27464 import_components52.Button, 27465 { 27466 className: "media-upload-modal__upload-status__trigger", 27467 size: "compact", 27468 icon: chevron_down_default, 27469 iconPosition: "right", 27470 onClick: () => updateIsOpen(!isOpen), 27471 "aria-expanded": isOpen, 27472 ref: triggerRef, 27473 children: buttonLabel 27474 } 27475 ), 27476 isOpen && /* @__PURE__ */ (0, import_jsx_runtime125.jsxs)( 27477 import_components52.Popover, 27478 { 27479 className: "media-upload-modal__upload-status__popover", 27480 placement: "top-start", 27481 offset: 8, 27482 anchor: triggerRef.current, 27483 focusOnMount: true, 27484 onClose: () => { 27485 if (triggerRef.current?.contains( 27486 triggerRef.current.ownerDocument.activeElement 27487 )) { 27488 return; 27489 } 27490 updateIsOpen(false); 27491 }, 27492 children: [ 27493 /* @__PURE__ */ (0, import_jsx_runtime125.jsx)("div", { className: "media-upload-modal__upload-status__header", children: /* @__PURE__ */ (0, import_jsx_runtime125.jsx)("h3", { children: popoverHeading }) }), 27494 /* @__PURE__ */ (0, import_jsx_runtime125.jsx)("ul", { className: "media-upload-modal__upload-status__list", children: uploadingFiles.map((file) => /* @__PURE__ */ (0, import_jsx_runtime125.jsxs)( 27495 "li", 27496 { 27497 className: "media-upload-modal__upload-status__item", 27498 children: [ 27499 file.status === "uploading" && /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(import_components52.Spinner, {}), 27500 file.status === "uploaded" && /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(import_components52.Icon, { icon: check_default, size: 16 }), 27501 (file.status === "uploading" || file.status === "uploaded") && /* @__PURE__ */ (0, import_jsx_runtime125.jsx)( 27502 "span", 27503 { 27504 className: "media-upload-modal__upload-status__filename", 27505 title: file.name, 27506 children: file.name 27507 } 27508 ), 27509 file.status === "error" && /* @__PURE__ */ (0, import_jsx_runtime125.jsxs)( 27510 import_components52.Notice, 27511 { 27512 status: "error", 27513 isDismissible: !!onDismissError, 27514 onRemove: () => onDismissError?.(file.id), 27515 children: [ 27516 file.name, 27517 ": ", 27518 file.error 27519 ] 27520 } 27521 ) 27522 ] 27523 }, 27524 file.id 27525 )) }) 27526 ] 27527 } 27528 ) 27529 ] }); 27530 } 27531 27532 // packages/media-utils/build-module/components/media-upload-modal/use-invalidate-attachment-resolutions.mjs 27533 var import_element81 = __toESM(require_element(), 1); 27534 var import_core_data5 = __toESM(require_core_data(), 1); 27535 var import_data12 = __toESM(require_data(), 1); 27536 function useInvalidateAttachmentResolutions() { 27537 const registry = (0, import_data12.useRegistry)(); 27538 return (0, import_element81.useCallback)(() => { 27539 const resolvers = registry.select(import_core_data5.store).getCachedResolvers(); 27540 const entityRecordResolutions = resolvers.getEntityRecords; 27541 entityRecordResolutions?.forEach((_value, args) => { 27542 if (args[0] === "postType" && args[1] === "attachment") { 27543 registry.dispatch(import_core_data5.store).invalidateResolution("getEntityRecords", args); 27544 } 27545 }); 27546 }, [registry]); 27547 } 27548 27549 // packages/media-utils/build-module/components/media-upload-modal/use-upload-status.mjs 27550 var import_element82 = __toESM(require_element(), 1); 27551 var import_blob2 = __toESM(require_blob(), 1); 27552 var idCounter = 0; 27553 var batchIdCounter = 0; 27554 function useUploadStatus({ 27555 onBatchComplete 27556 } = {}) { 27557 const [uploadingFiles, setUploadingFiles] = (0, import_element82.useState)( 27558 [] 27559 ); 27560 const clearCompleted = (0, import_element82.useCallback)(() => { 27561 setUploadingFiles( 27562 (prev) => prev.filter((item) => item.status !== "uploaded") 27563 ); 27564 }, []); 27565 const dismissError = (0, import_element82.useCallback)((fileId) => { 27566 setUploadingFiles( 27567 (prev) => prev.filter((item) => item.id !== fileId) 27568 ); 27569 }, []); 27570 const registerBatch = (0, import_element82.useCallback)( 27571 (files) => { 27572 const batchId = String(++batchIdCounter); 27573 const batchSize = files.length; 27574 const newEntries = files.map((file) => ({ 27575 id: String(++idCounter), 27576 batchId, 27577 name: file.name, 27578 status: "uploading" 27579 })); 27580 setUploadingFiles((prev) => [...prev, ...newEntries]); 27581 let successCount = 0; 27582 let errorCount = 0; 27583 let batchDone = false; 27584 let successAttachments = []; 27585 const completeBatchIfDone = () => { 27586 if (batchDone || successCount + errorCount < batchSize) { 27587 return; 27588 } 27589 batchDone = true; 27590 setUploadingFiles( 27591 (prev) => prev.map( 27592 (item) => item.batchId === batchId && item.status === "uploading" ? { 27593 ...item, 27594 status: "uploaded" 27595 } : item 27596 ) 27597 ); 27598 onBatchComplete?.(successAttachments); 27599 }; 27600 const onFileChange = (attachments) => { 27601 if (batchDone) { 27602 return; 27603 } 27604 const allReal = attachments.every( 27605 (attachment) => attachment.id && attachment.url && !(0, import_blob2.isBlobURL)(attachment.url) 27606 ); 27607 if (!allReal) { 27608 return; 27609 } 27610 successCount = attachments.length; 27611 successAttachments = attachments; 27612 completeBatchIfDone(); 27613 }; 27614 const onError = (error) => { 27615 const fileName = error instanceof UploadError ? error.file.name : void 0; 27616 setUploadingFiles((prev) => { 27617 let matched = false; 27618 return prev.map((item) => { 27619 if (!matched && item.batchId === batchId && item.status === "uploading" && (!fileName || item.name === fileName)) { 27620 matched = true; 27621 return { 27622 ...item, 27623 status: "error", 27624 error: error.message 27625 }; 27626 } 27627 return item; 27628 }); 27629 }); 27630 errorCount++; 27631 completeBatchIfDone(); 27632 }; 27633 return { onFileChange, onError }; 27634 }, 27635 [onBatchComplete] 27636 ); 27637 const allComplete = uploadingFiles.length > 0 && uploadingFiles.every((item) => item.status !== "uploading"); 27638 return { 27639 uploadingFiles, 27640 registerBatch, 27641 dismissError, 27642 clearCompleted, 27643 allComplete 27644 }; 27645 } 27646 27647 // packages/media-utils/build-module/components/media-upload-modal/index.mjs 27648 var import_jsx_runtime126 = __toESM(require_jsx_runtime(), 1); 27649 var { useEntityRecordsWithPermissions } = unlock4(import_core_data6.privateApis); 27650 var LAYOUT_PICKER_GRID2 = "pickerGrid"; 27651 var LAYOUT_PICKER_TABLE2 = "pickerTable"; 27652 var NOTICES_CONTEXT = "media-modal"; 27653 var NOTICE_ID_UPLOAD_PROGRESS = "media-modal-upload-progress"; 27654 var defaultQueryParams = { 27655 page: 1, 27656 search: "" 27657 }; 27658 var defaultView = { 27659 type: LAYOUT_PICKER_GRID2, 27660 fields: [], 27661 showTitle: false, 27662 titleField: "title", 27663 mediaField: "media_thumbnail", 27664 perPage: 50, 27665 filters: [], 27666 layout: { 27667 previewSize: 170, 27668 density: "compact" 27669 } 27670 }; 27671 var defaultLayouts = { 27672 [LAYOUT_PICKER_GRID2]: { 27673 fields: [], 27674 showTitle: false, 27675 layout: { 27676 previewSize: 170, 27677 density: "compact" 27678 } 27679 }, 27680 [LAYOUT_PICKER_TABLE2]: { 27681 fields: [ 27682 "filename", 27683 "filesize", 27684 "media_dimensions", 27685 "author", 27686 "date" 27687 ], 27688 showTitle: true 27689 } 27690 }; 27691 function MediaUploadModal({ 27692 allowedTypes, 27693 multiple = false, 27694 value, 27695 onSelect, 27696 onClose, 27697 onUpload, 27698 title = (0, import_i18n67.__)("Select Media"), 27699 isOpen, 27700 isDismissible = true, 27701 modalClass, 27702 search = true, 27703 searchLabel = (0, import_i18n67.__)("Search media") 27704 }) { 27705 const [selection, setSelection] = (0, import_element83.useState)(() => { 27706 if (!value) { 27707 return []; 27708 } 27709 return Array.isArray(value) ? value.map(String) : [String(value)]; 27710 }); 27711 const { createSuccessNotice, removeAllNotices } = (0, import_data13.useDispatch)(import_notices.store); 27712 const invalidateAttachmentResolutions = useInvalidateAttachmentResolutions(); 27713 const [queryParams, setQueryParams] = (0, import_element83.useState)( 27714 () => defaultQueryParams 27715 ); 27716 const { view, updateView, isModified, resetToDefault } = useView({ 27717 kind: "postType", 27718 name: "attachment", 27719 slug: "media-modal", 27720 defaultView, 27721 queryParams, 27722 onChangeQueryParams: setQueryParams 27723 }); 27724 const handleChangeView = (0, import_element83.useCallback)( 27725 (nextView) => { 27726 const normalizedView = { ...nextView }; 27727 if (normalizedView.startPosition === void 0) { 27728 delete normalizedView.startPosition; 27729 } 27730 updateView(normalizedView); 27731 }, 27732 [updateView] 27733 ); 27734 const queryArgs = (0, import_element83.useMemo)(() => { 27735 const filters = {}; 27736 view.filters?.forEach((filter) => { 27737 if (filter.field === "media_type") { 27738 filters.media_type = filter.value; 27739 } 27740 if (filter.field === "author") { 27741 if (filter.operator === "isAny") { 27742 filters.author = filter.value; 27743 } else if (filter.operator === "isNone") { 27744 filters.author_exclude = filter.value; 27745 } 27746 } 27747 if (filter.field === "date" || filter.field === "modified") { 27748 if (filter.operator === "before") { 27749 filters.before = filter.value; 27750 } else if (filter.operator === "after") { 27751 filters.after = filter.value; 27752 } 27753 } 27754 if (filter.field === "mime_type") { 27755 filters.mime_type = filter.value; 27756 } 27757 }); 27758 if (!filters.media_type && !filters.mime_type && allowedTypes && !allowedTypes.includes("*")) { 27759 const { mediaTypes, mimeTypes } = allowedTypes.reduce( 27760 (acc, type) => { 27761 if (type.endsWith("/*")) { 27762 acc.mediaTypes.push(type.replace("/*", "")); 27763 } else if (type.includes("/")) { 27764 acc.mimeTypes.push(type); 27765 } else { 27766 acc.mediaTypes.push(type); 27767 } 27768 return acc; 27769 }, 27770 { mediaTypes: [], mimeTypes: [] } 27771 ); 27772 if (mediaTypes.length) { 27773 filters.media_type = mediaTypes; 27774 } 27775 if (mimeTypes.length) { 27776 filters.mime_type = mimeTypes; 27777 } 27778 } 27779 return { 27780 per_page: view.perPage || 20, 27781 page: view.page || 1, 27782 status: "inherit", 27783 order: view.sort?.direction, 27784 orderby: view.sort?.field, 27785 search: view.search, 27786 _embed: "author,wp:attached-to", 27787 ...filters 27788 }; 27789 }, [view, allowedTypes]); 27790 const handleBatchComplete = (0, import_element83.useCallback)( 27791 (attachments) => { 27792 const uploadedIds = attachments.map((attachment) => String(attachment.id)).filter(Boolean); 27793 if (multiple) { 27794 setSelection((prev) => { 27795 const existing = new Set(prev); 27796 const newIds = uploadedIds.filter( 27797 (id) => !existing.has(id) 27798 ); 27799 return [...prev, ...newIds]; 27800 }); 27801 } else { 27802 setSelection(uploadedIds.slice(0, 1)); 27803 } 27804 invalidateAttachmentResolutions(); 27805 }, 27806 [multiple, invalidateAttachmentResolutions] 27807 ); 27808 const { 27809 uploadingFiles, 27810 registerBatch, 27811 dismissError, 27812 clearCompleted, 27813 allComplete 27814 } = useUploadStatus({ onBatchComplete: handleBatchComplete }); 27815 const isPopoverOpenRef = (0, import_element83.useRef)(false); 27816 const handlePopoverOpenChange = (0, import_element83.useCallback)( 27817 (open) => { 27818 isPopoverOpenRef.current = open; 27819 if (!open) { 27820 clearCompleted(); 27821 } 27822 }, 27823 [clearCompleted] 27824 ); 27825 const { 27826 records: mediaRecords, 27827 isResolving: isLoading, 27828 totalItems, 27829 totalPages 27830 } = useEntityRecordsWithPermissions("postType", "attachment", queryArgs); 27831 const fields = (0, import_element83.useMemo)( 27832 () => [ 27833 // Media field definitions from @wordpress/media-fields 27834 // Cast is safe because RestAttachment has the same properties as Attachment 27835 { 27836 ...media_thumbnail_default, 27837 enableHiding: false 27838 // Within the modal, the thumbnail should always be shown. 27839 }, 27840 { 27841 id: "title", 27842 type: "text", 27843 label: (0, import_i18n67.__)("Title"), 27844 getValue: ({ item }) => { 27845 const titleValue = item.title.raw || item.title.rendered; 27846 return titleValue || (0, import_i18n67.__)("(no title)"); 27847 } 27848 }, 27849 alt_text_default, 27850 caption_default, 27851 description_default, 27852 date_added_default, 27853 date_modified_default, 27854 author_default, 27855 filename_default, 27856 filesize_default, 27857 media_dimensions_default, 27858 mime_type_default, 27859 attached_to_default 27860 ], 27861 [] 27862 ); 27863 const actions = (0, import_element83.useMemo)( 27864 () => [ 27865 { 27866 id: "select", 27867 label: (0, import_i18n67.__)("Select"), 27868 isPrimary: true, 27869 supportsBulk: multiple, 27870 async callback() { 27871 if (selection.length === 0) { 27872 return; 27873 } 27874 const selectedPostsQuery = { 27875 include: selection, 27876 per_page: -1 27877 }; 27878 const selectedPosts = await (0, import_data13.resolveSelect)( 27879 import_core_data6.store 27880 ).getEntityRecords( 27881 "postType", 27882 "attachment", 27883 selectedPostsQuery 27884 ); 27885 const transformedPosts = (selectedPosts ?? []).map(transformAttachment).filter(Boolean); 27886 const selectedItems = multiple ? transformedPosts : transformedPosts?.[0]; 27887 removeAllNotices("snackbar", NOTICES_CONTEXT); 27888 onSelect(selectedItems); 27889 } 27890 } 27891 ], 27892 [multiple, onSelect, selection, removeAllNotices] 27893 ); 27894 const handleModalClose = (0, import_element83.useCallback)(() => { 27895 removeAllNotices("snackbar", NOTICES_CONTEXT); 27896 onClose?.(); 27897 }, [removeAllNotices, onClose]); 27898 (0, import_element83.useEffect)(() => { 27899 if (!isOpen) { 27900 setQueryParams(defaultQueryParams); 27901 } 27902 }, [isOpen]); 27903 const handleUpload = onUpload || uploadMedia; 27904 const prevAllCompleteRef = (0, import_element83.useRef)(false); 27905 (0, import_element83.useEffect)(() => { 27906 if (allComplete && !prevAllCompleteRef.current) { 27907 const completeCount = uploadingFiles.filter( 27908 (file) => file.status === "uploaded" 27909 ).length; 27910 if (completeCount > 0) { 27911 createSuccessNotice( 27912 (0, import_i18n67.sprintf)( 27913 // translators: %s: number of files 27914 (0, import_i18n67._n)( 27915 "Uploaded %s file", 27916 "Uploaded %s files", 27917 completeCount 27918 ), 27919 completeCount.toLocaleString() 27920 ), 27921 { 27922 type: "snackbar", 27923 context: NOTICES_CONTEXT, 27924 id: NOTICE_ID_UPLOAD_PROGRESS 27925 } 27926 ); 27927 } 27928 if (!isPopoverOpenRef.current) { 27929 clearCompleted(); 27930 } 27931 } 27932 prevAllCompleteRef.current = allComplete; 27933 }, [allComplete, uploadingFiles, createSuccessNotice, clearCompleted]); 27934 const handleFileSelect = (0, import_element83.useCallback)( 27935 (event) => { 27936 const files = event.target.files; 27937 if (files && files.length > 0) { 27938 const filesArray = Array.from(files); 27939 const { onFileChange, onError } = registerBatch(filesArray); 27940 handleUpload({ 27941 allowedTypes, 27942 filesList: filesArray, 27943 onFileChange, 27944 onError 27945 }); 27946 } 27947 }, 27948 [allowedTypes, handleUpload, registerBatch] 27949 ); 27950 const paginationInfo = (0, import_element83.useMemo)( 27951 () => ({ 27952 totalItems, 27953 totalPages 27954 }), 27955 [totalItems, totalPages] 27956 ); 27957 const acceptTypes = (0, import_element83.useMemo)(() => { 27958 if (allowedTypes?.includes("*")) { 27959 return void 0; 27960 } 27961 return allowedTypes?.join(","); 27962 }, [allowedTypes]); 27963 if (!isOpen) { 27964 return null; 27965 } 27966 return /* @__PURE__ */ (0, import_jsx_runtime126.jsxs)( 27967 import_components53.Modal, 27968 { 27969 title, 27970 onRequestClose: handleModalClose, 27971 isDismissible, 27972 className: modalClass, 27973 overlayClassName: "media-upload-modal", 27974 size: "fill", 27975 headerActions: /* @__PURE__ */ (0, import_jsx_runtime126.jsx)( 27976 import_components53.FormFileUpload, 27977 { 27978 accept: acceptTypes, 27979 multiple: true, 27980 onChange: handleFileSelect, 27981 __next40pxDefaultSize: true, 27982 render: ({ openFileDialog }) => /* @__PURE__ */ (0, import_jsx_runtime126.jsx)( 27983 import_components53.Button, 27984 { 27985 onClick: openFileDialog, 27986 icon: upload_default, 27987 __next40pxDefaultSize: true, 27988 children: (0, import_i18n67.__)("Upload media") 27989 } 27990 ) 27991 } 27992 ), 27993 children: [ 27994 /* @__PURE__ */ (0, import_jsx_runtime126.jsx)( 27995 import_components53.DropZone, 27996 { 27997 onFilesDrop: (files) => { 27998 let filteredFiles = files; 27999 if (allowedTypes && !allowedTypes.includes("*")) { 28000 filteredFiles = files.filter( 28001 (file) => allowedTypes.some((allowedType) => { 28002 return file.type === allowedType || file.type.startsWith( 28003 allowedType.replace("*", "") 28004 ); 28005 }) 28006 ); 28007 } 28008 if (filteredFiles.length > 0) { 28009 const { onFileChange, onError } = registerBatch(filteredFiles); 28010 handleUpload({ 28011 allowedTypes, 28012 filesList: filteredFiles, 28013 onFileChange, 28014 onError 28015 }); 28016 } 28017 }, 28018 label: (0, import_i18n67.__)("Drop files to upload") 28019 } 28020 ), 28021 /* @__PURE__ */ (0, import_jsx_runtime126.jsxs)( 28022 dataviews_picker_default, 28023 { 28024 data: mediaRecords || [], 28025 fields, 28026 view, 28027 onChangeView: handleChangeView, 28028 actions, 28029 selection, 28030 onChangeSelection: setSelection, 28031 isLoading, 28032 paginationInfo, 28033 defaultLayouts, 28034 getItemId: (item) => String(item.id), 28035 itemListLabel: (0, import_i18n67.__)("Media items"), 28036 onReset: isModified ? resetToDefault : false, 28037 children: [ 28038 /* @__PURE__ */ (0, import_jsx_runtime126.jsxs)( 28039 Stack, 28040 { 28041 direction: "row", 28042 align: "top", 28043 justify: "space-between", 28044 className: "dataviews__view-actions", 28045 gap: "xs", 28046 children: [ 28047 /* @__PURE__ */ (0, import_jsx_runtime126.jsxs)( 28048 Stack, 28049 { 28050 direction: "row", 28051 gap: "sm", 28052 justify: "start", 28053 className: "dataviews__search", 28054 children: [ 28055 search && /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(dataviews_picker_default.Search, { label: searchLabel }), 28056 /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(dataviews_picker_default.FiltersToggle, {}) 28057 ] 28058 } 28059 ), 28060 /* @__PURE__ */ (0, import_jsx_runtime126.jsxs)(Stack, { direction: "row", gap: "xs", style: { flexShrink: 0 }, children: [ 28061 /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(dataviews_picker_default.LayoutSwitcher, {}), 28062 /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(dataviews_picker_default.ViewConfig, {}) 28063 ] }) 28064 ] 28065 } 28066 ), 28067 /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(dataviews_picker_default.FiltersToggled, { className: "dataviews-filters__container" }), 28068 /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(dataviews_picker_default.Layout, {}), 28069 /* @__PURE__ */ (0, import_jsx_runtime126.jsxs)( 28070 "div", 28071 { 28072 className: clsx_default("media-upload-modal__footer", { 28073 "is-uploading": uploadingFiles.length > 0 28074 }), 28075 children: [ 28076 /* @__PURE__ */ (0, import_jsx_runtime126.jsx)( 28077 UploadStatusPopover, 28078 { 28079 uploadingFiles, 28080 onDismissError: dismissError, 28081 onOpenChange: handlePopoverOpenChange 28082 } 28083 ), 28084 /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(dataviews_picker_default.BulkActionToolbar, {}) 28085 ] 28086 } 28087 ) 28088 ] 28089 } 28090 ), 28091 (0, import_element83.createPortal)( 28092 /* @__PURE__ */ (0, import_jsx_runtime126.jsx)( 28093 import_notices.SnackbarNotices, 28094 { 28095 className: "media-upload-modal__snackbar", 28096 context: NOTICES_CONTEXT 28097 } 28098 ), 28099 document.body 28100 ) 28101 ] 28102 } 28103 ); 28104 } 28105 28106 // packages/media-utils/build-module/private-apis.mjs 28107 var privateApis12 = {}; 28108 lock4(privateApis12, { 28109 sideloadMedia, 28110 MediaUploadModal 28111 }); 28112 return __toCommonJS(index_exports); 28113 })(); 28114 /*! Bundled license information: 28115 28116 use-sync-external-store/cjs/use-sync-external-store-shim.development.js: 28117 (** 28118 * @license React 28119 * use-sync-external-store-shim.development.js 28120 * 28121 * Copyright (c) Meta Platforms, Inc. and affiliates. 28122 * 28123 * This source code is licensed under the MIT license found in the 28124 * LICENSE file in the root directory of this source tree. 28125 *) 28126 28127 use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js: 28128 (** 28129 * @license React 28130 * use-sync-external-store-shim/with-selector.development.js 28131 * 28132 * Copyright (c) Meta Platforms, Inc. and affiliates. 28133 * 28134 * This source code is licensed under the MIT license found in the 28135 * LICENSE file in the root directory of this source tree. 28136 *) 28137 */
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Thu Jul 2 08:20:12 2026 | Cross-referenced by PHPXref |