| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 (function() { 2 var wp; 3 (wp ||= {}).blockDirectory = (() => { 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/plugins 36 var require_plugins = __commonJS({ 37 "package-external:@wordpress/plugins"(exports, module) { 38 module.exports = window.wp.plugins; 39 } 40 }); 41 42 // package-external:@wordpress/hooks 43 var require_hooks = __commonJS({ 44 "package-external:@wordpress/hooks"(exports, module) { 45 module.exports = window.wp.hooks; 46 } 47 }); 48 49 // package-external:@wordpress/blocks 50 var require_blocks = __commonJS({ 51 "package-external:@wordpress/blocks"(exports, module) { 52 module.exports = window.wp.blocks; 53 } 54 }); 55 56 // package-external:@wordpress/data 57 var require_data = __commonJS({ 58 "package-external:@wordpress/data"(exports, module) { 59 module.exports = window.wp.data; 60 } 61 }); 62 63 // package-external:@wordpress/element 64 var require_element = __commonJS({ 65 "package-external:@wordpress/element"(exports, module) { 66 module.exports = window.wp.element; 67 } 68 }); 69 70 // package-external:@wordpress/editor 71 var require_editor = __commonJS({ 72 "package-external:@wordpress/editor"(exports, module) { 73 module.exports = window.wp.editor; 74 } 75 }); 76 77 // package-external:@wordpress/block-editor 78 var require_block_editor = __commonJS({ 79 "package-external:@wordpress/block-editor"(exports, module) { 80 module.exports = window.wp.blockEditor; 81 } 82 }); 83 84 // package-external:@wordpress/i18n 85 var require_i18n = __commonJS({ 86 "package-external:@wordpress/i18n"(exports, module) { 87 module.exports = window.wp.i18n; 88 } 89 }); 90 91 // package-external:@wordpress/api-fetch 92 var require_api_fetch = __commonJS({ 93 "package-external:@wordpress/api-fetch"(exports, module) { 94 module.exports = window.wp.apiFetch; 95 } 96 }); 97 98 // package-external:@wordpress/notices 99 var require_notices = __commonJS({ 100 "package-external:@wordpress/notices"(exports, module) { 101 module.exports = window.wp.notices; 102 } 103 }); 104 105 // package-external:@wordpress/url 106 var require_url = __commonJS({ 107 "package-external:@wordpress/url"(exports, module) { 108 module.exports = window.wp.url; 109 } 110 }); 111 112 // package-external:@wordpress/compose 113 var require_compose = __commonJS({ 114 "package-external:@wordpress/compose"(exports, module) { 115 module.exports = window.wp.compose; 116 } 117 }); 118 119 // package-external:@wordpress/components 120 var require_components = __commonJS({ 121 "package-external:@wordpress/components"(exports, module) { 122 module.exports = window.wp.components; 123 } 124 }); 125 126 // package-external:@wordpress/core-data 127 var require_core_data = __commonJS({ 128 "package-external:@wordpress/core-data"(exports, module) { 129 module.exports = window.wp.coreData; 130 } 131 }); 132 133 // package-external:@wordpress/html-entities 134 var require_html_entities = __commonJS({ 135 "package-external:@wordpress/html-entities"(exports, module) { 136 module.exports = window.wp.htmlEntities; 137 } 138 }); 139 140 // vendor-external:react 141 var require_react = __commonJS({ 142 "vendor-external:react"(exports, module) { 143 module.exports = window.React; 144 } 145 }); 146 147 // vendor-external:react/jsx-runtime 148 var require_jsx_runtime = __commonJS({ 149 "vendor-external:react/jsx-runtime"(exports, module) { 150 module.exports = window.ReactJSXRuntime; 151 } 152 }); 153 154 // vendor-external:react-dom 155 var require_react_dom = __commonJS({ 156 "vendor-external:react-dom"(exports, module) { 157 module.exports = window.ReactDOM; 158 } 159 }); 160 161 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js 162 var require_use_sync_external_store_shim_development = __commonJS({ 163 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports) { 164 "use strict"; 165 (function() { 166 function is(x, y) { 167 return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y; 168 } 169 function useSyncExternalStore$2(subscribe, getSnapshot) { 170 didWarnOld18Alpha || void 0 === React47.startTransition || (didWarnOld18Alpha = true, console.error( 171 "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." 172 )); 173 var value = getSnapshot(); 174 if (!didWarnUncachedGetSnapshot) { 175 var cachedValue = getSnapshot(); 176 objectIs(value, cachedValue) || (console.error( 177 "The result of getSnapshot should be cached to avoid an infinite loop" 178 ), didWarnUncachedGetSnapshot = true); 179 } 180 cachedValue = useState13({ 181 inst: { value, getSnapshot } 182 }); 183 var inst = cachedValue[0].inst, forceUpdate = cachedValue[1]; 184 useLayoutEffect3( 185 function() { 186 inst.value = value; 187 inst.getSnapshot = getSnapshot; 188 checkIfSnapshotChanged(inst) && forceUpdate({ inst }); 189 }, 190 [subscribe, value, getSnapshot] 191 ); 192 useEffect13( 193 function() { 194 checkIfSnapshotChanged(inst) && forceUpdate({ inst }); 195 return subscribe(function() { 196 checkIfSnapshotChanged(inst) && forceUpdate({ inst }); 197 }); 198 }, 199 [subscribe] 200 ); 201 useDebugValue2(value); 202 return value; 203 } 204 function checkIfSnapshotChanged(inst) { 205 var latestGetSnapshot = inst.getSnapshot; 206 inst = inst.value; 207 try { 208 var nextValue = latestGetSnapshot(); 209 return !objectIs(inst, nextValue); 210 } catch (error) { 211 return true; 212 } 213 } 214 function useSyncExternalStore$1(subscribe, getSnapshot) { 215 return getSnapshot(); 216 } 217 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error()); 218 var React47 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is, useState13 = React47.useState, useEffect13 = React47.useEffect, useLayoutEffect3 = React47.useLayoutEffect, useDebugValue2 = React47.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2; 219 exports.useSyncExternalStore = void 0 !== React47.useSyncExternalStore ? React47.useSyncExternalStore : shim; 220 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error()); 221 })(); 222 } 223 }); 224 225 // node_modules/use-sync-external-store/shim/index.js 226 var require_shim = __commonJS({ 227 "node_modules/use-sync-external-store/shim/index.js"(exports, module) { 228 "use strict"; 229 if (false) { 230 module.exports = null; 231 } else { 232 module.exports = require_use_sync_external_store_shim_development(); 233 } 234 } 235 }); 236 237 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js 238 var require_with_selector_development = __commonJS({ 239 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js"(exports) { 240 "use strict"; 241 (function() { 242 function is(x, y) { 243 return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y; 244 } 245 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error()); 246 var React47 = require_react(), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore2 = shim.useSyncExternalStore, useRef19 = React47.useRef, useEffect13 = React47.useEffect, useMemo15 = React47.useMemo, useDebugValue2 = React47.useDebugValue; 247 exports.useSyncExternalStoreWithSelector = function(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) { 248 var instRef = useRef19(null); 249 if (null === instRef.current) { 250 var inst = { hasValue: false, value: null }; 251 instRef.current = inst; 252 } else inst = instRef.current; 253 instRef = useMemo15( 254 function() { 255 function memoizedSelector(nextSnapshot) { 256 if (!hasMemo) { 257 hasMemo = true; 258 memoizedSnapshot = nextSnapshot; 259 nextSnapshot = selector(nextSnapshot); 260 if (void 0 !== isEqual && inst.hasValue) { 261 var currentSelection = inst.value; 262 if (isEqual(currentSelection, nextSnapshot)) 263 return memoizedSelection = currentSelection; 264 } 265 return memoizedSelection = nextSnapshot; 266 } 267 currentSelection = memoizedSelection; 268 if (objectIs(memoizedSnapshot, nextSnapshot)) 269 return currentSelection; 270 var nextSelection = selector(nextSnapshot); 271 if (void 0 !== isEqual && isEqual(currentSelection, nextSelection)) 272 return memoizedSnapshot = nextSnapshot, currentSelection; 273 memoizedSnapshot = nextSnapshot; 274 return memoizedSelection = nextSelection; 275 } 276 var hasMemo = false, memoizedSnapshot, memoizedSelection, maybeGetServerSnapshot = void 0 === getServerSnapshot ? null : getServerSnapshot; 277 return [ 278 function() { 279 return memoizedSelector(getSnapshot()); 280 }, 281 null === maybeGetServerSnapshot ? void 0 : function() { 282 return memoizedSelector(maybeGetServerSnapshot()); 283 } 284 ]; 285 }, 286 [getSnapshot, getServerSnapshot, selector, isEqual] 287 ); 288 var value = useSyncExternalStore2(subscribe, instRef[0], instRef[1]); 289 useEffect13( 290 function() { 291 inst.hasValue = true; 292 inst.value = value; 293 }, 294 [value] 295 ); 296 useDebugValue2(value); 297 return value; 298 }; 299 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error()); 300 })(); 301 } 302 }); 303 304 // node_modules/use-sync-external-store/shim/with-selector.js 305 var require_with_selector = __commonJS({ 306 "node_modules/use-sync-external-store/shim/with-selector.js"(exports, module) { 307 "use strict"; 308 if (false) { 309 module.exports = null; 310 } else { 311 module.exports = require_with_selector_development(); 312 } 313 } 314 }); 315 316 // package-external:@wordpress/a11y 317 var require_a11y = __commonJS({ 318 "package-external:@wordpress/a11y"(exports, module) { 319 module.exports = window.wp.a11y; 320 } 321 }); 322 323 // package-external:@wordpress/primitives 324 var require_primitives = __commonJS({ 325 "package-external:@wordpress/primitives"(exports, module) { 326 module.exports = window.wp.primitives; 327 } 328 }); 329 330 // package-external:@wordpress/theme 331 var require_theme = __commonJS({ 332 "package-external:@wordpress/theme"(exports, module) { 333 module.exports = window.wp.theme; 334 } 335 }); 336 337 // package-external:@wordpress/private-apis 338 var require_private_apis = __commonJS({ 339 "package-external:@wordpress/private-apis"(exports, module) { 340 module.exports = window.wp.privateApis; 341 } 342 }); 343 344 // packages/block-directory/build-module/index.mjs 345 var index_exports = {}; 346 __export(index_exports, { 347 store: () => store 348 }); 349 350 // packages/block-directory/build-module/plugins/index.mjs 351 var import_plugins = __toESM(require_plugins(), 1); 352 var import_hooks = __toESM(require_hooks(), 1); 353 354 // packages/block-directory/build-module/components/auto-block-uninstaller/index.mjs 355 var import_blocks2 = __toESM(require_blocks(), 1); 356 var import_data4 = __toESM(require_data(), 1); 357 var import_element = __toESM(require_element(), 1); 358 var import_editor = __toESM(require_editor(), 1); 359 360 // packages/block-directory/build-module/store/index.mjs 361 var import_data3 = __toESM(require_data(), 1); 362 363 // packages/block-directory/build-module/store/reducer.mjs 364 var import_data = __toESM(require_data(), 1); 365 var downloadableBlocks = (state = {}, action) => { 366 switch (action.type) { 367 case "FETCH_DOWNLOADABLE_BLOCKS": 368 return { 369 ...state, 370 [action.filterValue]: { 371 isRequesting: true 372 } 373 }; 374 case "RECEIVE_DOWNLOADABLE_BLOCKS": 375 return { 376 ...state, 377 [action.filterValue]: { 378 results: action.downloadableBlocks, 379 isRequesting: false 380 } 381 }; 382 } 383 return state; 384 }; 385 var blockManagement = (state = { 386 installedBlockTypes: [], 387 isInstalling: {} 388 }, action) => { 389 switch (action.type) { 390 case "ADD_INSTALLED_BLOCK_TYPE": 391 return { 392 ...state, 393 installedBlockTypes: [ 394 ...state.installedBlockTypes, 395 action.item 396 ] 397 }; 398 case "REMOVE_INSTALLED_BLOCK_TYPE": 399 return { 400 ...state, 401 installedBlockTypes: state.installedBlockTypes.filter( 402 (blockType) => blockType.name !== action.item.name 403 ) 404 }; 405 case "SET_INSTALLING_BLOCK": 406 return { 407 ...state, 408 isInstalling: { 409 ...state.isInstalling, 410 [action.blockId]: action.isInstalling 411 } 412 }; 413 } 414 return state; 415 }; 416 var errorNotices = (state = {}, action) => { 417 switch (action.type) { 418 case "SET_ERROR_NOTICE": 419 return { 420 ...state, 421 [action.blockId]: { 422 message: action.message, 423 isFatal: action.isFatal 424 } 425 }; 426 case "CLEAR_ERROR_NOTICE": 427 const { [action.blockId]: blockId, ...restState } = state; 428 return restState; 429 } 430 return state; 431 }; 432 var reducer_default = (0, import_data.combineReducers)({ 433 downloadableBlocks, 434 blockManagement, 435 errorNotices 436 }); 437 438 // packages/block-directory/build-module/store/selectors.mjs 439 var selectors_exports = {}; 440 __export(selectors_exports, { 441 getDownloadableBlocks: () => getDownloadableBlocks, 442 getErrorNoticeForBlock: () => getErrorNoticeForBlock, 443 getErrorNotices: () => getErrorNotices, 444 getInstalledBlockTypes: () => getInstalledBlockTypes, 445 getNewBlockTypes: () => getNewBlockTypes, 446 getUnusedBlockTypes: () => getUnusedBlockTypes, 447 isInstalling: () => isInstalling, 448 isRequestingDownloadableBlocks: () => isRequestingDownloadableBlocks 449 }); 450 var import_data2 = __toESM(require_data(), 1); 451 var import_block_editor = __toESM(require_block_editor(), 1); 452 var EMPTY_ARRAY = []; 453 function isRequestingDownloadableBlocks(state, filterValue) { 454 return state.downloadableBlocks[filterValue]?.isRequesting ?? false; 455 } 456 function getDownloadableBlocks(state, filterValue) { 457 return state.downloadableBlocks[filterValue]?.results ?? EMPTY_ARRAY; 458 } 459 function getInstalledBlockTypes(state) { 460 return state.blockManagement.installedBlockTypes; 461 } 462 var getNewBlockTypes = (0, import_data2.createRegistrySelector)( 463 (select) => (0, import_data2.createSelector)( 464 (state) => { 465 const installedBlockTypes = getInstalledBlockTypes(state); 466 if (!installedBlockTypes.length) { 467 return EMPTY_ARRAY; 468 } 469 const { getBlockName, getClientIdsWithDescendants } = select(import_block_editor.store); 470 const installedBlockNames = installedBlockTypes.map( 471 (blockType) => blockType.name 472 ); 473 const foundBlockNames = getClientIdsWithDescendants().flatMap( 474 (clientId) => { 475 const blockName = getBlockName(clientId); 476 return installedBlockNames.includes(blockName) ? blockName : []; 477 } 478 ); 479 const newBlockTypes = installedBlockTypes.filter( 480 (blockType) => foundBlockNames.includes(blockType.name) 481 ); 482 return newBlockTypes.length > 0 ? newBlockTypes : EMPTY_ARRAY; 483 }, 484 (state) => [ 485 getInstalledBlockTypes(state), 486 select(import_block_editor.store).getClientIdsWithDescendants() 487 ] 488 ) 489 ); 490 var getUnusedBlockTypes = (0, import_data2.createRegistrySelector)( 491 (select) => (0, import_data2.createSelector)( 492 (state) => { 493 const installedBlockTypes = getInstalledBlockTypes(state); 494 if (!installedBlockTypes.length) { 495 return EMPTY_ARRAY; 496 } 497 const { getBlockName, getClientIdsWithDescendants } = select(import_block_editor.store); 498 const installedBlockNames = installedBlockTypes.map( 499 (blockType) => blockType.name 500 ); 501 const foundBlockNames = getClientIdsWithDescendants().flatMap( 502 (clientId) => { 503 const blockName = getBlockName(clientId); 504 return installedBlockNames.includes(blockName) ? blockName : []; 505 } 506 ); 507 const unusedBlockTypes = installedBlockTypes.filter( 508 (blockType) => !foundBlockNames.includes(blockType.name) 509 ); 510 return unusedBlockTypes.length > 0 ? unusedBlockTypes : EMPTY_ARRAY; 511 }, 512 (state) => [ 513 getInstalledBlockTypes(state), 514 select(import_block_editor.store).getClientIdsWithDescendants() 515 ] 516 ) 517 ); 518 function isInstalling(state, blockId) { 519 return state.blockManagement.isInstalling[blockId] || false; 520 } 521 function getErrorNotices(state) { 522 return state.errorNotices; 523 } 524 function getErrorNoticeForBlock(state, blockId) { 525 return state.errorNotices[blockId]; 526 } 527 528 // packages/block-directory/build-module/store/actions.mjs 529 var actions_exports = {}; 530 __export(actions_exports, { 531 addInstalledBlockType: () => addInstalledBlockType, 532 clearErrorNotice: () => clearErrorNotice, 533 fetchDownloadableBlocks: () => fetchDownloadableBlocks, 534 installBlockType: () => installBlockType, 535 receiveDownloadableBlocks: () => receiveDownloadableBlocks, 536 removeInstalledBlockType: () => removeInstalledBlockType, 537 setErrorNotice: () => setErrorNotice, 538 setIsInstalling: () => setIsInstalling, 539 uninstallBlockType: () => uninstallBlockType 540 }); 541 var import_blocks = __toESM(require_blocks(), 1); 542 var import_i18n = __toESM(require_i18n(), 1); 543 var import_api_fetch2 = __toESM(require_api_fetch(), 1); 544 var import_notices = __toESM(require_notices(), 1); 545 var import_url = __toESM(require_url(), 1); 546 547 // packages/block-directory/build-module/store/load-assets.mjs 548 var import_api_fetch = __toESM(require_api_fetch(), 1); 549 var loadAsset = (el) => { 550 return new Promise((resolve, reject) => { 551 const newNode = document.createElement(el.nodeName); 552 ["id", "rel", "src", "href", "type"].forEach((attr2) => { 553 if (el[attr2]) { 554 newNode[attr2] = el[attr2]; 555 } 556 }); 557 if (el.innerHTML) { 558 newNode.appendChild(document.createTextNode(el.innerHTML)); 559 } 560 newNode.onload = () => resolve(true); 561 newNode.onerror = () => reject(new Error("Error loading asset.")); 562 document.body.appendChild(newNode); 563 if ("link" === newNode.nodeName.toLowerCase() || "script" === newNode.nodeName.toLowerCase() && !newNode.src) { 564 resolve(); 565 } 566 }); 567 }; 568 async function loadAssets() { 569 const response = await (0, import_api_fetch.default)({ 570 url: document.location.href, 571 parse: false 572 }); 573 const data = await response.text(); 574 const doc = new window.DOMParser().parseFromString(data, "text/html"); 575 const newAssets = Array.from( 576 doc.querySelectorAll('link[rel="stylesheet"],script') 577 ).filter((asset) => asset.id && !document.getElementById(asset.id)); 578 for (const newAsset of newAssets) { 579 await loadAsset(newAsset); 580 } 581 } 582 583 // packages/block-directory/build-module/store/utils/get-plugin-url.mjs 584 function getPluginUrl(block) { 585 if (!block) { 586 return false; 587 } 588 const link = block.links["wp:plugin"] || block.links.self; 589 if (link && link.length) { 590 return link[0].href; 591 } 592 return false; 593 } 594 595 // packages/block-directory/build-module/store/actions.mjs 596 function fetchDownloadableBlocks(filterValue) { 597 return { type: "FETCH_DOWNLOADABLE_BLOCKS", filterValue }; 598 } 599 function receiveDownloadableBlocks(downloadableBlocks2, filterValue) { 600 return { 601 type: "RECEIVE_DOWNLOADABLE_BLOCKS", 602 downloadableBlocks: downloadableBlocks2, 603 filterValue 604 }; 605 } 606 var installBlockType = (block) => async ({ registry, dispatch }) => { 607 const { id, name } = block; 608 let success = false; 609 dispatch.clearErrorNotice(id); 610 try { 611 dispatch.setIsInstalling(id, true); 612 const url = getPluginUrl(block); 613 let links = {}; 614 if (url) { 615 await (0, import_api_fetch2.default)({ 616 method: "PUT", 617 url, 618 data: { status: "active" } 619 }); 620 } else { 621 const response = await (0, import_api_fetch2.default)({ 622 method: "POST", 623 path: "wp/v2/plugins", 624 data: { slug: id, status: "active" } 625 }); 626 links = response._links; 627 } 628 dispatch.addInstalledBlockType({ 629 ...block, 630 links: { ...block.links, ...links } 631 }); 632 const metadataFields = [ 633 "api_version", 634 "title", 635 "category", 636 "parent", 637 "ancestor", 638 "icon", 639 "description", 640 "keywords", 641 "attributes", 642 "provides_context", 643 "uses_context", 644 "selectors", 645 "supports", 646 "styles", 647 "example", 648 "variations", 649 "allowed_blocks", 650 "block_hooks" 651 ]; 652 await (0, import_api_fetch2.default)({ 653 path: (0, import_url.addQueryArgs)(`/wp/v2/block-types/$name}`, { 654 _fields: metadataFields 655 }) 656 }).catch(() => { 657 }).then((response) => { 658 if (!response) { 659 return; 660 } 661 (0, import_blocks.unstable__bootstrapServerSideBlockDefinitions)({ 662 [name]: Object.fromEntries( 663 Object.entries(response).filter( 664 ([key]) => metadataFields.includes(key) 665 ) 666 ) 667 }); 668 }); 669 await loadAssets(); 670 const registeredBlocks = registry.select(import_blocks.store).getBlockTypes(); 671 if (!registeredBlocks.some((i) => i.name === name)) { 672 throw new Error( 673 (0, import_i18n.__)("Error registering block. Try reloading the page.") 674 ); 675 } 676 registry.dispatch(import_notices.store).createInfoNotice( 677 (0, import_i18n.sprintf)( 678 // translators: %s is the block title. 679 (0, import_i18n.__)("Block %s installed and added."), 680 block.title 681 ), 682 { 683 speak: true, 684 type: "snackbar" 685 } 686 ); 687 success = true; 688 } catch (error) { 689 let message = error.message || (0, import_i18n.__)("An error occurred."); 690 let isFatal = error instanceof Error; 691 const fatalAPIErrors = { 692 folder_exists: (0, import_i18n.__)( 693 "This block is already installed. Try reloading the page." 694 ), 695 unable_to_connect_to_filesystem: (0, import_i18n.__)( 696 "Error installing block. You can reload the page and try again." 697 ) 698 }; 699 if (fatalAPIErrors[error.code]) { 700 isFatal = true; 701 message = fatalAPIErrors[error.code]; 702 } 703 dispatch.setErrorNotice(id, message, isFatal); 704 registry.dispatch(import_notices.store).createErrorNotice(message, { 705 speak: true, 706 isDismissible: true 707 }); 708 } 709 dispatch.setIsInstalling(id, false); 710 return success; 711 }; 712 var uninstallBlockType = (block) => async ({ registry, dispatch }) => { 713 try { 714 const url = getPluginUrl(block); 715 await (0, import_api_fetch2.default)({ 716 method: "PUT", 717 url, 718 data: { status: "inactive" } 719 }); 720 await (0, import_api_fetch2.default)({ 721 method: "DELETE", 722 url 723 }); 724 dispatch.removeInstalledBlockType(block); 725 } catch (error) { 726 registry.dispatch(import_notices.store).createErrorNotice( 727 error.message || (0, import_i18n.__)("An error occurred.") 728 ); 729 } 730 }; 731 function addInstalledBlockType(item) { 732 return { 733 type: "ADD_INSTALLED_BLOCK_TYPE", 734 item 735 }; 736 } 737 function removeInstalledBlockType(item) { 738 return { 739 type: "REMOVE_INSTALLED_BLOCK_TYPE", 740 item 741 }; 742 } 743 function setIsInstalling(blockId, isInstalling2) { 744 return { 745 type: "SET_INSTALLING_BLOCK", 746 blockId, 747 isInstalling: isInstalling2 748 }; 749 } 750 function setErrorNotice(blockId, message, isFatal = false) { 751 return { 752 type: "SET_ERROR_NOTICE", 753 blockId, 754 message, 755 isFatal 756 }; 757 } 758 function clearErrorNotice(blockId) { 759 return { 760 type: "CLEAR_ERROR_NOTICE", 761 blockId 762 }; 763 } 764 765 // packages/block-directory/build-module/store/resolvers.mjs 766 var resolvers_exports = {}; 767 __export(resolvers_exports, { 768 getDownloadableBlocks: () => getDownloadableBlocks2 769 }); 770 771 // node_modules/tslib/tslib.es6.mjs 772 var __assign = function() { 773 __assign = Object.assign || function __assign2(t) { 774 for (var s, i = 1, n = arguments.length; i < n; i++) { 775 s = arguments[i]; 776 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; 777 } 778 return t; 779 }; 780 return __assign.apply(this, arguments); 781 }; 782 783 // node_modules/lower-case/dist.es2015/index.js 784 function lowerCase(str) { 785 return str.toLowerCase(); 786 } 787 788 // node_modules/no-case/dist.es2015/index.js 789 var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g]; 790 var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi; 791 function noCase(input, options) { 792 if (options === void 0) { 793 options = {}; 794 } 795 var _a = options.splitRegexp, splitRegexp = _a === void 0 ? DEFAULT_SPLIT_REGEXP : _a, _b = options.stripRegexp, stripRegexp = _b === void 0 ? DEFAULT_STRIP_REGEXP : _b, _c = options.transform, transform = _c === void 0 ? lowerCase : _c, _d = options.delimiter, delimiter = _d === void 0 ? " " : _d; 796 var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0"); 797 var start = 0; 798 var end = result.length; 799 while (result.charAt(start) === "\0") 800 start++; 801 while (result.charAt(end - 1) === "\0") 802 end--; 803 return result.slice(start, end).split("\0").map(transform).join(delimiter); 804 } 805 function replace(input, re, value) { 806 if (re instanceof RegExp) 807 return input.replace(re, value); 808 return re.reduce(function(input2, re2) { 809 return input2.replace(re2, value); 810 }, input); 811 } 812 813 // node_modules/pascal-case/dist.es2015/index.js 814 function pascalCaseTransform(input, index2) { 815 var firstChar = input.charAt(0); 816 var lowerChars = input.substr(1).toLowerCase(); 817 if (index2 > 0 && firstChar >= "0" && firstChar <= "9") { 818 return "_" + firstChar + lowerChars; 819 } 820 return "" + firstChar.toUpperCase() + lowerChars; 821 } 822 function pascalCase(input, options) { 823 if (options === void 0) { 824 options = {}; 825 } 826 return noCase(input, __assign({ delimiter: "", transform: pascalCaseTransform }, options)); 827 } 828 829 // node_modules/camel-case/dist.es2015/index.js 830 function camelCaseTransform(input, index2) { 831 if (index2 === 0) 832 return input.toLowerCase(); 833 return pascalCaseTransform(input, index2); 834 } 835 function camelCase(input, options) { 836 if (options === void 0) { 837 options = {}; 838 } 839 return pascalCase(input, __assign({ transform: camelCaseTransform }, options)); 840 } 841 842 // packages/block-directory/build-module/store/resolvers.mjs 843 var import_api_fetch3 = __toESM(require_api_fetch(), 1); 844 var getDownloadableBlocks2 = (filterValue) => async ({ dispatch }) => { 845 if (!filterValue) { 846 return; 847 } 848 try { 849 dispatch(fetchDownloadableBlocks(filterValue)); 850 const results = await (0, import_api_fetch3.default)({ 851 path: `wp/v2/block-directory/search?term=$filterValue}` 852 }); 853 const blocks = results.map( 854 (result) => Object.fromEntries( 855 Object.entries(result).map(([key, value]) => [ 856 camelCase(key), 857 value 858 ]) 859 ) 860 ); 861 dispatch(receiveDownloadableBlocks(blocks, filterValue)); 862 } catch { 863 dispatch(receiveDownloadableBlocks([], filterValue)); 864 } 865 }; 866 867 // packages/block-directory/build-module/store/index.mjs 868 var STORE_NAME = "core/block-directory"; 869 var storeConfig = { 870 reducer: reducer_default, 871 selectors: selectors_exports, 872 actions: actions_exports, 873 resolvers: resolvers_exports 874 }; 875 var store = (0, import_data3.createReduxStore)(STORE_NAME, storeConfig); 876 (0, import_data3.register)(store); 877 878 // packages/block-directory/build-module/components/auto-block-uninstaller/index.mjs 879 function AutoBlockUninstaller() { 880 const { uninstallBlockType: uninstallBlockType2 } = (0, import_data4.useDispatch)(store); 881 const shouldRemoveBlockTypes = (0, import_data4.useSelect)((select) => { 882 const { isAutosavingPost, isSavingPost } = select(import_editor.store); 883 return isSavingPost() && !isAutosavingPost(); 884 }, []); 885 const unusedBlockTypes = (0, import_data4.useSelect)( 886 (select) => select(store).getUnusedBlockTypes(), 887 [] 888 ); 889 (0, import_element.useEffect)(() => { 890 if (shouldRemoveBlockTypes && unusedBlockTypes.length) { 891 unusedBlockTypes.forEach((blockType) => { 892 uninstallBlockType2(blockType); 893 (0, import_blocks2.unregisterBlockType)(blockType.name); 894 }); 895 } 896 }, [shouldRemoveBlockTypes]); 897 return null; 898 } 899 900 // packages/block-directory/build-module/plugins/inserter-menu-downloadable-blocks-panel/index.mjs 901 var import_block_editor3 = __toESM(require_block_editor(), 1); 902 var import_compose = __toESM(require_compose(), 1); 903 var import_element20 = __toESM(require_element(), 1); 904 905 // packages/block-directory/build-module/components/downloadable-blocks-panel/index.mjs 906 var import_i18n8 = __toESM(require_i18n(), 1); 907 var import_components4 = __toESM(require_components(), 1); 908 var import_core_data = __toESM(require_core_data(), 1); 909 var import_data8 = __toESM(require_data(), 1); 910 var import_blocks5 = __toESM(require_blocks(), 1); 911 912 // packages/block-directory/build-module/components/downloadable-blocks-list/index.mjs 913 var import_i18n5 = __toESM(require_i18n(), 1); 914 var import_components2 = __toESM(require_components(), 1); 915 var import_blocks4 = __toESM(require_blocks(), 1); 916 var import_data7 = __toESM(require_data(), 1); 917 918 // node_modules/clsx/dist/clsx.mjs 919 function r(e) { 920 var t, f, n = ""; 921 if ("string" == typeof e || "number" == typeof e) n += e; 922 else if ("object" == typeof e) if (Array.isArray(e)) { 923 var o = e.length; 924 for (t = 0; t < o; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f); 925 } else for (f in e) e[f] && (n && (n += " "), n += f); 926 return n; 927 } 928 function clsx() { 929 for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t); 930 return n; 931 } 932 var clsx_default = clsx; 933 934 // packages/block-directory/build-module/components/downloadable-block-list-item/index.mjs 935 var import_i18n4 = __toESM(require_i18n(), 1); 936 var import_components = __toESM(require_components(), 1); 937 var import_element18 = __toESM(require_element(), 1); 938 var import_html_entities = __toESM(require_html_entities(), 1); 939 var import_blocks3 = __toESM(require_blocks(), 1); 940 var import_data6 = __toESM(require_data(), 1); 941 942 // node_modules/@base-ui/utils/safeReact.mjs 943 var React = __toESM(require_react(), 1); 944 var SafeReact = { 945 ...React 946 }; 947 948 // node_modules/@base-ui/utils/useRefWithInit.mjs 949 var React2 = __toESM(require_react(), 1); 950 var UNINITIALIZED = {}; 951 function useRefWithInit(init, initArg) { 952 const ref = React2.useRef(UNINITIALIZED); 953 if (ref.current === UNINITIALIZED) { 954 ref.current = init(initArg); 955 } 956 return ref; 957 } 958 959 // node_modules/@base-ui/utils/useStableCallback.mjs 960 var useInsertionEffect = SafeReact.useInsertionEffect; 961 var useSafeInsertionEffect = ( 962 // React 17 doesn't have useInsertionEffect. 963 useInsertionEffect && // Preact replaces useInsertionEffect with useLayoutEffect and fires too late. 964 useInsertionEffect !== SafeReact.useLayoutEffect ? useInsertionEffect : (fn) => fn() 965 ); 966 function useStableCallback(callback) { 967 const stable = useRefWithInit(createStableCallback).current; 968 stable.next = callback; 969 useSafeInsertionEffect(stable.effect); 970 return stable.trampoline; 971 } 972 function createStableCallback() { 973 const stable = { 974 next: void 0, 975 callback: assertNotCalled, 976 trampoline: (...args) => stable.callback?.(...args), 977 effect: () => { 978 stable.callback = stable.next; 979 } 980 }; 981 return stable; 982 } 983 function assertNotCalled() { 984 if (true) { 985 throw ( 986 /* minify-error-disabled */ 987 new Error("Base UI: Cannot call an event handler while rendering.") 988 ); 989 } 990 } 991 992 // node_modules/@base-ui/utils/useIsoLayoutEffect.mjs 993 var React3 = __toESM(require_react(), 1); 994 var noop = () => { 995 }; 996 var useIsoLayoutEffect = typeof document !== "undefined" ? React3.useLayoutEffect : noop; 997 998 // node_modules/@base-ui/utils/warn.mjs 999 var set; 1000 if (true) { 1001 set = /* @__PURE__ */ new Set(); 1002 } 1003 function warn(...messages) { 1004 if (true) { 1005 const messageKey = messages.join(" "); 1006 if (!set.has(messageKey)) { 1007 set.add(messageKey); 1008 console.warn(`Base UI: $messageKey}`); 1009 } 1010 } 1011 } 1012 1013 // node_modules/@base-ui/react/internals/direction-context/DirectionContext.mjs 1014 var React4 = __toESM(require_react(), 1); 1015 var DirectionContext = /* @__PURE__ */ React4.createContext(void 0); 1016 if (true) DirectionContext.displayName = "DirectionContext"; 1017 function useDirection() { 1018 const context = React4.useContext(DirectionContext); 1019 return context?.direction ?? "ltr"; 1020 } 1021 1022 // node_modules/@base-ui/react/internals/useRenderElement.mjs 1023 var React7 = __toESM(require_react(), 1); 1024 1025 // node_modules/@base-ui/utils/useMergedRefs.mjs 1026 function useMergedRefs(a, b, c, d) { 1027 const forkRef = useRefWithInit(createForkRef).current; 1028 if (didChange(forkRef, a, b, c, d)) { 1029 update(forkRef, [a, b, c, d]); 1030 } 1031 return forkRef.callback; 1032 } 1033 function useMergedRefsN(refs) { 1034 const forkRef = useRefWithInit(createForkRef).current; 1035 if (didChangeN(forkRef, refs)) { 1036 update(forkRef, refs); 1037 } 1038 return forkRef.callback; 1039 } 1040 function createForkRef() { 1041 return { 1042 callback: null, 1043 cleanup: null, 1044 refs: [] 1045 }; 1046 } 1047 function didChange(forkRef, a, b, c, d) { 1048 return forkRef.refs[0] !== a || forkRef.refs[1] !== b || forkRef.refs[2] !== c || forkRef.refs[3] !== d; 1049 } 1050 function didChangeN(forkRef, newRefs) { 1051 return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index2) => ref !== newRefs[index2]); 1052 } 1053 function update(forkRef, refs) { 1054 forkRef.refs = refs; 1055 if (refs.every((ref) => ref == null)) { 1056 forkRef.callback = null; 1057 return; 1058 } 1059 forkRef.callback = (instance) => { 1060 if (forkRef.cleanup) { 1061 forkRef.cleanup(); 1062 forkRef.cleanup = null; 1063 } 1064 if (instance != null) { 1065 const cleanupCallbacks = Array(refs.length).fill(null); 1066 for (let i = 0; i < refs.length; i += 1) { 1067 const ref = refs[i]; 1068 if (ref == null) { 1069 continue; 1070 } 1071 switch (typeof ref) { 1072 case "function": { 1073 const refCleanup = ref(instance); 1074 if (typeof refCleanup === "function") { 1075 cleanupCallbacks[i] = refCleanup; 1076 } 1077 break; 1078 } 1079 case "object": { 1080 ref.current = instance; 1081 break; 1082 } 1083 default: 1084 } 1085 } 1086 forkRef.cleanup = () => { 1087 for (let i = 0; i < refs.length; i += 1) { 1088 const ref = refs[i]; 1089 if (ref == null) { 1090 continue; 1091 } 1092 switch (typeof ref) { 1093 case "function": { 1094 const cleanupCallback = cleanupCallbacks[i]; 1095 if (typeof cleanupCallback === "function") { 1096 cleanupCallback(); 1097 } else { 1098 ref(null); 1099 } 1100 break; 1101 } 1102 case "object": { 1103 ref.current = null; 1104 break; 1105 } 1106 default: 1107 } 1108 } 1109 }; 1110 } 1111 }; 1112 } 1113 1114 // node_modules/@base-ui/utils/getReactElementRef.mjs 1115 var React6 = __toESM(require_react(), 1); 1116 1117 // node_modules/@base-ui/utils/reactVersion.mjs 1118 var React5 = __toESM(require_react(), 1); 1119 var majorVersion = parseInt(React5.version, 10); 1120 function isReactVersionAtLeast(reactVersionToCheck) { 1121 return majorVersion >= reactVersionToCheck; 1122 } 1123 1124 // node_modules/@base-ui/utils/getReactElementRef.mjs 1125 function getReactElementRef(element) { 1126 if (!/* @__PURE__ */ React6.isValidElement(element)) { 1127 return null; 1128 } 1129 const reactElement = element; 1130 const propsWithRef = reactElement.props; 1131 return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null; 1132 } 1133 1134 // node_modules/@base-ui/utils/mergeObjects.mjs 1135 function mergeObjects(a, b) { 1136 if (a && !b) { 1137 return a; 1138 } 1139 if (!a && b) { 1140 return b; 1141 } 1142 if (a || b) { 1143 return { 1144 ...a, 1145 ...b 1146 }; 1147 } 1148 return void 0; 1149 } 1150 1151 // node_modules/@base-ui/utils/empty.mjs 1152 function NOOP() { 1153 } 1154 var EMPTY_ARRAY2 = Object.freeze([]); 1155 var EMPTY_OBJECT = Object.freeze({}); 1156 1157 // node_modules/@base-ui/react/internals/getStateAttributesProps.mjs 1158 function getStateAttributesProps(state, customMapping) { 1159 const props = {}; 1160 for (const key in state) { 1161 const value = state[key]; 1162 if (customMapping?.hasOwnProperty(key)) { 1163 const customProps = customMapping[key](value); 1164 if (customProps != null) { 1165 Object.assign(props, customProps); 1166 } 1167 continue; 1168 } 1169 if (value === true) { 1170 props[`data-$key.toLowerCase()}`] = ""; 1171 } else if (value) { 1172 props[`data-$key.toLowerCase()}`] = value.toString(); 1173 } 1174 } 1175 return props; 1176 } 1177 1178 // node_modules/@base-ui/react/utils/resolveClassName.mjs 1179 function resolveClassName(className, state) { 1180 return typeof className === "function" ? className(state) : className; 1181 } 1182 1183 // node_modules/@base-ui/react/utils/resolveStyle.mjs 1184 function resolveStyle(style, state) { 1185 return typeof style === "function" ? style(state) : style; 1186 } 1187 1188 // node_modules/@base-ui/react/merge-props/mergeProps.mjs 1189 var EMPTY_PROPS = {}; 1190 function mergeProps(a, b, c, d, e) { 1191 if (!c && !d && !e && !a) { 1192 return createInitialMergedProps(b); 1193 } 1194 let merged = createInitialMergedProps(a); 1195 if (b) { 1196 merged = mergeInto(merged, b); 1197 } 1198 if (c) { 1199 merged = mergeInto(merged, c); 1200 } 1201 if (d) { 1202 merged = mergeInto(merged, d); 1203 } 1204 if (e) { 1205 merged = mergeInto(merged, e); 1206 } 1207 return merged; 1208 } 1209 function mergePropsN(props) { 1210 if (props.length === 0) { 1211 return EMPTY_PROPS; 1212 } 1213 if (props.length === 1) { 1214 return createInitialMergedProps(props[0]); 1215 } 1216 let merged = createInitialMergedProps(props[0]); 1217 for (let i = 1; i < props.length; i += 1) { 1218 merged = mergeInto(merged, props[i]); 1219 } 1220 return merged; 1221 } 1222 function createInitialMergedProps(inputProps) { 1223 if (isPropsGetter(inputProps)) { 1224 return { 1225 ...resolvePropsGetter(inputProps, EMPTY_PROPS) 1226 }; 1227 } 1228 return copyInitialProps(inputProps); 1229 } 1230 function mergeInto(merged, inputProps) { 1231 if (isPropsGetter(inputProps)) { 1232 return resolvePropsGetter(inputProps, merged); 1233 } 1234 return mutablyMergeInto(merged, inputProps); 1235 } 1236 function copyInitialProps(inputProps) { 1237 const copiedProps = { 1238 ...inputProps 1239 }; 1240 for (const propName in copiedProps) { 1241 const propValue = copiedProps[propName]; 1242 if (isEventHandler(propName, propValue)) { 1243 copiedProps[propName] = wrapEventHandler(propValue); 1244 } 1245 } 1246 return copiedProps; 1247 } 1248 function mutablyMergeInto(mergedProps, externalProps) { 1249 if (!externalProps) { 1250 return mergedProps; 1251 } 1252 for (const propName in externalProps) { 1253 const externalPropValue = externalProps[propName]; 1254 switch (propName) { 1255 case "style": { 1256 mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue); 1257 break; 1258 } 1259 case "className": { 1260 mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue); 1261 break; 1262 } 1263 default: { 1264 if (isEventHandler(propName, externalPropValue)) { 1265 mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue); 1266 } else { 1267 mergedProps[propName] = externalPropValue; 1268 } 1269 } 1270 } 1271 } 1272 return mergedProps; 1273 } 1274 function isEventHandler(key, value) { 1275 const code0 = key.charCodeAt(0); 1276 const code1 = key.charCodeAt(1); 1277 const code2 = key.charCodeAt(2); 1278 return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined"); 1279 } 1280 function isPropsGetter(inputProps) { 1281 return typeof inputProps === "function"; 1282 } 1283 function resolvePropsGetter(inputProps, previousProps) { 1284 if (isPropsGetter(inputProps)) { 1285 return inputProps(previousProps); 1286 } 1287 return inputProps ?? EMPTY_PROPS; 1288 } 1289 function mergeEventHandlers(ourHandler, theirHandler) { 1290 if (!theirHandler) { 1291 return ourHandler; 1292 } 1293 if (!ourHandler) { 1294 return wrapEventHandler(theirHandler); 1295 } 1296 return (...args) => { 1297 const event = args[0]; 1298 if (isSyntheticEvent(event)) { 1299 const baseUIEvent = event; 1300 makeEventPreventable(baseUIEvent); 1301 const result2 = theirHandler(...args); 1302 if (!baseUIEvent.baseUIHandlerPrevented) { 1303 ourHandler?.(...args); 1304 } 1305 return result2; 1306 } 1307 const result = theirHandler(...args); 1308 ourHandler?.(...args); 1309 return result; 1310 }; 1311 } 1312 function wrapEventHandler(handler) { 1313 if (!handler) { 1314 return handler; 1315 } 1316 return (...args) => { 1317 const event = args[0]; 1318 if (isSyntheticEvent(event)) { 1319 makeEventPreventable(event); 1320 } 1321 return handler(...args); 1322 }; 1323 } 1324 function makeEventPreventable(event) { 1325 event.preventBaseUIHandler = () => { 1326 event.baseUIHandlerPrevented = true; 1327 }; 1328 return event; 1329 } 1330 function mergeClassNames(ourClassName, theirClassName) { 1331 if (theirClassName) { 1332 if (ourClassName) { 1333 return theirClassName + " " + ourClassName; 1334 } 1335 return theirClassName; 1336 } 1337 return ourClassName; 1338 } 1339 function isSyntheticEvent(event) { 1340 return event != null && typeof event === "object" && "nativeEvent" in event; 1341 } 1342 1343 // node_modules/@base-ui/react/internals/useRenderElement.mjs 1344 var import_react = __toESM(require_react(), 1); 1345 function useRenderElement(element, componentProps, params = {}) { 1346 const renderProp = componentProps.render; 1347 const outProps = useRenderElementProps(componentProps, params); 1348 if (params.enabled === false) { 1349 return null; 1350 } 1351 const state = params.state ?? EMPTY_OBJECT; 1352 return evaluateRenderProp(element, renderProp, outProps, state); 1353 } 1354 function useRenderElementProps(componentProps, params = {}) { 1355 const { 1356 className: classNameProp, 1357 style: styleProp, 1358 render: renderProp 1359 } = componentProps; 1360 const { 1361 state = EMPTY_OBJECT, 1362 ref, 1363 props, 1364 stateAttributesMapping: stateAttributesMapping3, 1365 enabled = true 1366 } = params; 1367 const className = enabled ? resolveClassName(classNameProp, state) : void 0; 1368 const style = enabled ? resolveStyle(styleProp, state) : void 0; 1369 const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping3) : EMPTY_OBJECT; 1370 const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0; 1371 const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT; 1372 if (typeof document !== "undefined") { 1373 if (!enabled) { 1374 useMergedRefs(null, null); 1375 } else if (Array.isArray(ref)) { 1376 outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]); 1377 } else { 1378 outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref); 1379 } 1380 } 1381 if (!enabled) { 1382 return EMPTY_OBJECT; 1383 } 1384 if (className !== void 0) { 1385 outProps.className = mergeClassNames(outProps.className, className); 1386 } 1387 if (style !== void 0) { 1388 outProps.style = mergeObjects(outProps.style, style); 1389 } 1390 return outProps; 1391 } 1392 function resolveRenderFunctionProps(props) { 1393 if (Array.isArray(props)) { 1394 return mergePropsN(props); 1395 } 1396 return mergeProps(void 0, props); 1397 } 1398 var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy"); 1399 var COMPONENT_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9$]*$/; 1400 var LOWERCASE_CHARACTER_PATTERN = /[a-z]/; 1401 function evaluateRenderProp(element, render, props, state) { 1402 if (render) { 1403 if (typeof render === "function") { 1404 if (true) { 1405 warnIfRenderPropLooksLikeComponent(render); 1406 } 1407 return render(props, state); 1408 } 1409 const mergedProps = mergeProps(props, render.props); 1410 mergedProps.ref = props.ref; 1411 let newElement = render; 1412 if (newElement?.$$typeof === REACT_LAZY_TYPE) { 1413 const children = React7.Children.toArray(render); 1414 newElement = children[0]; 1415 } 1416 if (true) { 1417 if (!/* @__PURE__ */ React7.isValidElement(newElement)) { 1418 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")); 1419 } 1420 } 1421 return /* @__PURE__ */ React7.cloneElement(newElement, mergedProps); 1422 } 1423 if (element) { 1424 if (typeof element === "string") { 1425 return renderTag(element, props); 1426 } 1427 } 1428 throw new Error(true ? "Base UI: Render element or function are not defined." : formatErrorMessage_default(8)); 1429 } 1430 function warnIfRenderPropLooksLikeComponent(renderFn) { 1431 const functionName = renderFn.name; 1432 if (functionName.length === 0) { 1433 return; 1434 } 1435 if (!COMPONENT_IDENTIFIER_PATTERN.test(functionName)) { 1436 return; 1437 } 1438 if (!LOWERCASE_CHARACTER_PATTERN.test(functionName)) { 1439 return; 1440 } 1441 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"); 1442 } 1443 function renderTag(Tag, props) { 1444 if (Tag === "button") { 1445 return /* @__PURE__ */ (0, import_react.createElement)("button", { 1446 type: "button", 1447 ...props, 1448 key: props.key 1449 }); 1450 } 1451 if (Tag === "img") { 1452 return /* @__PURE__ */ (0, import_react.createElement)("img", { 1453 alt: "", 1454 ...props, 1455 key: props.key 1456 }); 1457 } 1458 return /* @__PURE__ */ React7.createElement(Tag, props); 1459 } 1460 1461 // node_modules/@base-ui/utils/useId.mjs 1462 var React8 = __toESM(require_react(), 1); 1463 var globalId = 0; 1464 function useGlobalId(idOverride, prefix = "mui") { 1465 const [defaultId, setDefaultId] = React8.useState(idOverride); 1466 const id = idOverride || defaultId; 1467 React8.useEffect(() => { 1468 if (defaultId == null) { 1469 globalId += 1; 1470 setDefaultId(`$prefix}-$globalId}`); 1471 } 1472 }, [defaultId, prefix]); 1473 return id; 1474 } 1475 var maybeReactUseId = SafeReact.useId; 1476 function useId(idOverride, prefix) { 1477 if (maybeReactUseId !== void 0) { 1478 const reactId = maybeReactUseId(); 1479 return idOverride ?? (prefix ? `$prefix}-$reactId}` : reactId); 1480 } 1481 return useGlobalId(idOverride, prefix); 1482 } 1483 1484 // node_modules/@base-ui/react/internals/useBaseUiId.mjs 1485 function useBaseUiId(idOverride) { 1486 return useId(idOverride, "base-ui"); 1487 } 1488 1489 // node_modules/@base-ui/react/internals/reason-parts.mjs 1490 var reason_parts_exports = {}; 1491 __export(reason_parts_exports, { 1492 cancelOpen: () => cancelOpen, 1493 chipRemovePress: () => chipRemovePress, 1494 clearPress: () => clearPress, 1495 closePress: () => closePress, 1496 closeWatcher: () => closeWatcher, 1497 decrementPress: () => decrementPress, 1498 disabled: () => disabled, 1499 drag: () => drag, 1500 escapeKey: () => escapeKey, 1501 focusOut: () => focusOut, 1502 imperativeAction: () => imperativeAction, 1503 incrementPress: () => incrementPress, 1504 initial: () => initial, 1505 inputBlur: () => inputBlur, 1506 inputChange: () => inputChange, 1507 inputClear: () => inputClear, 1508 inputPaste: () => inputPaste, 1509 inputPress: () => inputPress, 1510 itemPress: () => itemPress, 1511 keyboard: () => keyboard, 1512 linkPress: () => linkPress, 1513 listNavigation: () => listNavigation, 1514 missing: () => missing, 1515 none: () => none, 1516 outsidePress: () => outsidePress, 1517 pointer: () => pointer, 1518 scrub: () => scrub, 1519 siblingOpen: () => siblingOpen, 1520 swipe: () => swipe, 1521 trackPress: () => trackPress, 1522 triggerFocus: () => triggerFocus, 1523 triggerHover: () => triggerHover, 1524 triggerPress: () => triggerPress, 1525 wheel: () => wheel, 1526 windowResize: () => windowResize 1527 }); 1528 var none = "none"; 1529 var triggerPress = "trigger-press"; 1530 var triggerHover = "trigger-hover"; 1531 var triggerFocus = "trigger-focus"; 1532 var outsidePress = "outside-press"; 1533 var itemPress = "item-press"; 1534 var closePress = "close-press"; 1535 var linkPress = "link-press"; 1536 var clearPress = "clear-press"; 1537 var chipRemovePress = "chip-remove-press"; 1538 var trackPress = "track-press"; 1539 var incrementPress = "increment-press"; 1540 var decrementPress = "decrement-press"; 1541 var inputChange = "input-change"; 1542 var inputClear = "input-clear"; 1543 var inputBlur = "input-blur"; 1544 var inputPaste = "input-paste"; 1545 var inputPress = "input-press"; 1546 var focusOut = "focus-out"; 1547 var escapeKey = "escape-key"; 1548 var closeWatcher = "close-watcher"; 1549 var listNavigation = "list-navigation"; 1550 var keyboard = "keyboard"; 1551 var pointer = "pointer"; 1552 var drag = "drag"; 1553 var wheel = "wheel"; 1554 var scrub = "scrub"; 1555 var cancelOpen = "cancel-open"; 1556 var siblingOpen = "sibling-open"; 1557 var disabled = "disabled"; 1558 var missing = "missing"; 1559 var initial = "initial"; 1560 var imperativeAction = "imperative-action"; 1561 var swipe = "swipe"; 1562 var windowResize = "window-resize"; 1563 1564 // node_modules/@base-ui/react/internals/createBaseUIEventDetails.mjs 1565 function createChangeEventDetails(reason, event, trigger, customProperties) { 1566 let canceled = false; 1567 let allowPropagation = false; 1568 const custom = customProperties ?? EMPTY_OBJECT; 1569 const details = { 1570 reason, 1571 event: event ?? new Event("base-ui"), 1572 cancel() { 1573 canceled = true; 1574 }, 1575 allowPropagation() { 1576 allowPropagation = true; 1577 }, 1578 get isCanceled() { 1579 return canceled; 1580 }, 1581 get isPropagationAllowed() { 1582 return allowPropagation; 1583 }, 1584 trigger, 1585 ...custom 1586 }; 1587 return details; 1588 } 1589 1590 // node_modules/@base-ui/react/internals/useTransitionStatus.mjs 1591 var React10 = __toESM(require_react(), 1); 1592 1593 // node_modules/@base-ui/utils/useOnMount.mjs 1594 var React9 = __toESM(require_react(), 1); 1595 var EMPTY = []; 1596 function useOnMount(fn) { 1597 React9.useEffect(fn, EMPTY); 1598 } 1599 1600 // node_modules/@base-ui/utils/useAnimationFrame.mjs 1601 var EMPTY2 = null; 1602 var LAST_RAF = globalThis.requestAnimationFrame; 1603 var Scheduler = class { 1604 /* This implementation uses an array as a backing data-structure for frame callbacks. 1605 * It allows `O(1)` callback cancelling by inserting a `null` in the array, though it 1606 * never calls the native `cancelAnimationFrame` if there are no frames left. This can 1607 * be much more efficient if there is a call pattern that alterns as 1608 * "request-cancel-request-cancel-…". 1609 * But in the case of "request-request-…-cancel-cancel-…", it leaves the final animation 1610 * frame to run anyway. We turn that frame into a `O(1)` no-op via `callbacksCount`. */ 1611 callbacks = []; 1612 callbacksCount = 0; 1613 nextId = 1; 1614 startId = 1; 1615 isScheduled = false; 1616 tick = (timestamp) => { 1617 this.isScheduled = false; 1618 const currentCallbacks = this.callbacks; 1619 const currentCallbacksCount = this.callbacksCount; 1620 this.callbacks = []; 1621 this.callbacksCount = 0; 1622 this.startId = this.nextId; 1623 if (currentCallbacksCount > 0) { 1624 for (let i = 0; i < currentCallbacks.length; i += 1) { 1625 currentCallbacks[i]?.(timestamp); 1626 } 1627 } 1628 }; 1629 request(fn) { 1630 const id = this.nextId; 1631 this.nextId += 1; 1632 this.callbacks.push(fn); 1633 this.callbacksCount += 1; 1634 const didRAFChange = LAST_RAF !== requestAnimationFrame && (LAST_RAF = requestAnimationFrame, true); 1635 if (!this.isScheduled || didRAFChange) { 1636 requestAnimationFrame(this.tick); 1637 this.isScheduled = true; 1638 } 1639 return id; 1640 } 1641 cancel(id) { 1642 const index2 = id - this.startId; 1643 if (index2 < 0 || index2 >= this.callbacks.length) { 1644 return; 1645 } 1646 this.callbacks[index2] = null; 1647 this.callbacksCount -= 1; 1648 } 1649 }; 1650 var scheduler = new Scheduler(); 1651 var AnimationFrame = class _AnimationFrame { 1652 static create() { 1653 return new _AnimationFrame(); 1654 } 1655 static request(fn) { 1656 return scheduler.request(fn); 1657 } 1658 static cancel(id) { 1659 return scheduler.cancel(id); 1660 } 1661 currentId = EMPTY2; 1662 /** 1663 * Executes `fn` after `delay`, clearing any previously scheduled call. 1664 */ 1665 request(fn) { 1666 this.cancel(); 1667 this.currentId = scheduler.request(() => { 1668 this.currentId = EMPTY2; 1669 fn(); 1670 }); 1671 } 1672 cancel = () => { 1673 if (this.currentId !== EMPTY2) { 1674 scheduler.cancel(this.currentId); 1675 this.currentId = EMPTY2; 1676 } 1677 }; 1678 disposeEffect = () => { 1679 return this.cancel; 1680 }; 1681 }; 1682 function useAnimationFrame() { 1683 const timeout = useRefWithInit(AnimationFrame.create).current; 1684 useOnMount(timeout.disposeEffect); 1685 return timeout; 1686 } 1687 1688 // node_modules/@base-ui/react/internals/useTransitionStatus.mjs 1689 function useTransitionStatus(open, enableIdleState = false, deferEndingState = false) { 1690 const [transitionStatus, setTransitionStatus] = React10.useState(open && enableIdleState ? "idle" : void 0); 1691 const [mounted, setMounted] = React10.useState(open); 1692 if (open && !mounted) { 1693 setMounted(true); 1694 setTransitionStatus("starting"); 1695 } 1696 if (!open && mounted && transitionStatus !== "ending" && !deferEndingState) { 1697 setTransitionStatus("ending"); 1698 } 1699 if (!open && !mounted && transitionStatus === "ending") { 1700 setTransitionStatus(void 0); 1701 } 1702 useIsoLayoutEffect(() => { 1703 if (!open && mounted && transitionStatus !== "ending" && deferEndingState) { 1704 const frame = AnimationFrame.request(() => { 1705 setTransitionStatus("ending"); 1706 }); 1707 return () => { 1708 AnimationFrame.cancel(frame); 1709 }; 1710 } 1711 return void 0; 1712 }, [open, mounted, transitionStatus, deferEndingState]); 1713 useIsoLayoutEffect(() => { 1714 if (!open || enableIdleState) { 1715 return void 0; 1716 } 1717 const frame = AnimationFrame.request(() => { 1718 setTransitionStatus(void 0); 1719 }); 1720 return () => { 1721 AnimationFrame.cancel(frame); 1722 }; 1723 }, [enableIdleState, open]); 1724 useIsoLayoutEffect(() => { 1725 if (!open || !enableIdleState) { 1726 return void 0; 1727 } 1728 if (open && mounted && transitionStatus !== "idle") { 1729 setTransitionStatus("starting"); 1730 } 1731 const frame = AnimationFrame.request(() => { 1732 setTransitionStatus("idle"); 1733 }); 1734 return () => { 1735 AnimationFrame.cancel(frame); 1736 }; 1737 }, [enableIdleState, open, mounted, transitionStatus]); 1738 return { 1739 mounted, 1740 setMounted, 1741 transitionStatus 1742 }; 1743 } 1744 1745 // node_modules/@base-ui/react/internals/stateAttributesMapping.mjs 1746 var TransitionStatusDataAttributes = /* @__PURE__ */ (function(TransitionStatusDataAttributes2) { 1747 TransitionStatusDataAttributes2["startingStyle"] = "data-starting-style"; 1748 TransitionStatusDataAttributes2["endingStyle"] = "data-ending-style"; 1749 return TransitionStatusDataAttributes2; 1750 })({}); 1751 var STARTING_HOOK = { 1752 [TransitionStatusDataAttributes.startingStyle]: "" 1753 }; 1754 var ENDING_HOOK = { 1755 [TransitionStatusDataAttributes.endingStyle]: "" 1756 }; 1757 var transitionStatusMapping = { 1758 transitionStatus(value) { 1759 if (value === "starting") { 1760 return STARTING_HOOK; 1761 } 1762 if (value === "ending") { 1763 return ENDING_HOOK; 1764 } 1765 return null; 1766 } 1767 }; 1768 1769 // node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs 1770 function hasWindow() { 1771 return typeof window !== "undefined"; 1772 } 1773 function getNodeName(node) { 1774 if (isNode(node)) { 1775 return (node.nodeName || "").toLowerCase(); 1776 } 1777 return "#document"; 1778 } 1779 function getWindow(node) { 1780 var _node$ownerDocument; 1781 return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window; 1782 } 1783 function getDocumentElement(node) { 1784 var _ref; 1785 return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement; 1786 } 1787 function isNode(value) { 1788 if (!hasWindow()) { 1789 return false; 1790 } 1791 return value instanceof Node || value instanceof getWindow(value).Node; 1792 } 1793 function isElement(value) { 1794 if (!hasWindow()) { 1795 return false; 1796 } 1797 return value instanceof Element || value instanceof getWindow(value).Element; 1798 } 1799 function isHTMLElement(value) { 1800 if (!hasWindow()) { 1801 return false; 1802 } 1803 return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement; 1804 } 1805 function isShadowRoot(value) { 1806 if (!hasWindow() || typeof ShadowRoot === "undefined") { 1807 return false; 1808 } 1809 return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot; 1810 } 1811 function isOverflowElement(element) { 1812 const { 1813 overflow, 1814 overflowX, 1815 overflowY, 1816 display 1817 } = getComputedStyle2(element); 1818 return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== "inline" && display !== "contents"; 1819 } 1820 function isTableElement(element) { 1821 return /^(table|td|th)$/.test(getNodeName(element)); 1822 } 1823 function isTopLayer(element) { 1824 try { 1825 if (element.matches(":popover-open")) { 1826 return true; 1827 } 1828 } catch (_e) { 1829 } 1830 try { 1831 return element.matches(":modal"); 1832 } catch (_e) { 1833 return false; 1834 } 1835 } 1836 var willChangeRe = /transform|translate|scale|rotate|perspective|filter/; 1837 var containRe = /paint|layout|strict|content/; 1838 var isNotNone = (value) => !!value && value !== "none"; 1839 var isWebKitValue; 1840 function isContainingBlock(elementOrCss) { 1841 const css = isElement(elementOrCss) ? getComputedStyle2(elementOrCss) : elementOrCss; 1842 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 || ""); 1843 } 1844 function getContainingBlock(element) { 1845 let currentNode = getParentNode(element); 1846 while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) { 1847 if (isContainingBlock(currentNode)) { 1848 return currentNode; 1849 } else if (isTopLayer(currentNode)) { 1850 return null; 1851 } 1852 currentNode = getParentNode(currentNode); 1853 } 1854 return null; 1855 } 1856 function isWebKit() { 1857 if (isWebKitValue == null) { 1858 isWebKitValue = typeof CSS !== "undefined" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none"); 1859 } 1860 return isWebKitValue; 1861 } 1862 function isLastTraversableNode(node) { 1863 return /^(html|body|#document)$/.test(getNodeName(node)); 1864 } 1865 function getComputedStyle2(element) { 1866 return getWindow(element).getComputedStyle(element); 1867 } 1868 function getNodeScroll(element) { 1869 if (isElement(element)) { 1870 return { 1871 scrollLeft: element.scrollLeft, 1872 scrollTop: element.scrollTop 1873 }; 1874 } 1875 return { 1876 scrollLeft: element.scrollX, 1877 scrollTop: element.scrollY 1878 }; 1879 } 1880 function getParentNode(node) { 1881 if (getNodeName(node) === "html") { 1882 return node; 1883 } 1884 const result = ( 1885 // Step into the shadow DOM of the parent of a slotted node. 1886 node.assignedSlot || // DOM Element detected. 1887 node.parentNode || // ShadowRoot detected. 1888 isShadowRoot(node) && node.host || // Fallback. 1889 getDocumentElement(node) 1890 ); 1891 return isShadowRoot(result) ? result.host : result; 1892 } 1893 function getNearestOverflowAncestor(node) { 1894 const parentNode = getParentNode(node); 1895 if (isLastTraversableNode(parentNode)) { 1896 return node.ownerDocument ? node.ownerDocument.body : node.body; 1897 } 1898 if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) { 1899 return parentNode; 1900 } 1901 return getNearestOverflowAncestor(parentNode); 1902 } 1903 function getOverflowAncestors(node, list, traverseIframes) { 1904 var _node$ownerDocument2; 1905 if (list === void 0) { 1906 list = []; 1907 } 1908 if (traverseIframes === void 0) { 1909 traverseIframes = true; 1910 } 1911 const scrollableAncestor = getNearestOverflowAncestor(node); 1912 const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body); 1913 const win = getWindow(scrollableAncestor); 1914 if (isBody) { 1915 const frameElement = getFrameElement(win); 1916 return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []); 1917 } else { 1918 return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes)); 1919 } 1920 } 1921 function getFrameElement(win) { 1922 return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null; 1923 } 1924 1925 // node_modules/@base-ui/utils/addEventListener.mjs 1926 function addEventListener(target, type, listener, options) { 1927 target.addEventListener(type, listener, options); 1928 return () => { 1929 target.removeEventListener(type, listener, options); 1930 }; 1931 } 1932 1933 // node_modules/@base-ui/utils/useValueAsRef.mjs 1934 function useValueAsRef(value) { 1935 const latest = useRefWithInit(createLatestRef, value).current; 1936 latest.next = value; 1937 useIsoLayoutEffect(latest.effect); 1938 return latest; 1939 } 1940 function createLatestRef(value) { 1941 const latest = { 1942 current: value, 1943 next: value, 1944 effect: () => { 1945 latest.current = latest.next; 1946 } 1947 }; 1948 return latest; 1949 } 1950 1951 // node_modules/@base-ui/utils/owner.mjs 1952 function ownerDocument(node) { 1953 return node?.ownerDocument || document; 1954 } 1955 1956 // node_modules/@base-ui/react/internals/useOpenChangeComplete.mjs 1957 var React11 = __toESM(require_react(), 1); 1958 1959 // node_modules/@base-ui/react/internals/useAnimationsFinished.mjs 1960 var ReactDOM = __toESM(require_react_dom(), 1); 1961 1962 // node_modules/@base-ui/react/utils/resolveRef.mjs 1963 function resolveRef(maybeRef) { 1964 if (maybeRef == null) { 1965 return maybeRef; 1966 } 1967 return "current" in maybeRef ? maybeRef.current : maybeRef; 1968 } 1969 1970 // node_modules/@base-ui/react/internals/useAnimationsFinished.mjs 1971 function useAnimationsFinished(elementOrRef, waitForStartingStyleRemoved = false, treatAbortedAsFinished = true) { 1972 const frame = useAnimationFrame(); 1973 return useStableCallback((fnToExecute, signal = null) => { 1974 frame.cancel(); 1975 const element = resolveRef(elementOrRef); 1976 if (element == null) { 1977 return; 1978 } 1979 const resolvedElement = element; 1980 const done = () => { 1981 ReactDOM.flushSync(fnToExecute); 1982 }; 1983 if (typeof resolvedElement.getAnimations !== "function" || globalThis.BASE_UI_ANIMATIONS_DISABLED) { 1984 fnToExecute(); 1985 return; 1986 } 1987 function exec() { 1988 Promise.all(resolvedElement.getAnimations().map((animation) => animation.finished)).then(() => { 1989 if (!signal?.aborted) { 1990 done(); 1991 } 1992 }).catch(() => { 1993 if (treatAbortedAsFinished) { 1994 if (!signal?.aborted) { 1995 done(); 1996 } 1997 return; 1998 } 1999 const currentAnimations = resolvedElement.getAnimations(); 2000 if (!signal?.aborted && currentAnimations.length > 0 && currentAnimations.some((animation) => animation.pending || animation.playState !== "finished")) { 2001 exec(); 2002 } 2003 }); 2004 } 2005 if (waitForStartingStyleRemoved) { 2006 const startingStyleAttribute = TransitionStatusDataAttributes.startingStyle; 2007 if (!resolvedElement.hasAttribute(startingStyleAttribute)) { 2008 frame.request(exec); 2009 return; 2010 } 2011 const attributeObserver = new MutationObserver(() => { 2012 if (!resolvedElement.hasAttribute(startingStyleAttribute)) { 2013 attributeObserver.disconnect(); 2014 exec(); 2015 } 2016 }); 2017 attributeObserver.observe(resolvedElement, { 2018 attributes: true, 2019 attributeFilter: [startingStyleAttribute] 2020 }); 2021 signal?.addEventListener("abort", () => attributeObserver.disconnect(), { 2022 once: true 2023 }); 2024 return; 2025 } 2026 frame.request(exec); 2027 }); 2028 } 2029 2030 // node_modules/@base-ui/react/internals/useOpenChangeComplete.mjs 2031 function useOpenChangeComplete(parameters) { 2032 const { 2033 enabled = true, 2034 open, 2035 ref, 2036 onComplete: onCompleteParam 2037 } = parameters; 2038 const onComplete = useStableCallback(onCompleteParam); 2039 const runOnceAnimationsFinish = useAnimationsFinished(ref, open, false); 2040 React11.useEffect(() => { 2041 if (!enabled) { 2042 return void 0; 2043 } 2044 const abortController = new AbortController(); 2045 runOnceAnimationsFinish(onComplete, abortController.signal); 2046 return () => { 2047 abortController.abort(); 2048 }; 2049 }, [enabled, open, onComplete, runOnceAnimationsFinish]); 2050 } 2051 2052 // node_modules/@base-ui/utils/useOnFirstRender.mjs 2053 var React12 = __toESM(require_react(), 1); 2054 function useOnFirstRender(fn) { 2055 const ref = React12.useRef(true); 2056 if (ref.current) { 2057 ref.current = false; 2058 fn(); 2059 } 2060 } 2061 2062 // node_modules/@base-ui/utils/platform/parts.mjs 2063 var parts_exports = {}; 2064 __export(parts_exports, { 2065 engine: () => engine_exports, 2066 env: () => env_exports, 2067 os: () => os_exports, 2068 screenReader: () => screen_reader_exports 2069 }); 2070 2071 // node_modules/@base-ui/utils/platform/os.mjs 2072 var os_exports = {}; 2073 __export(os_exports, { 2074 android: () => android, 2075 apple: () => apple, 2076 ios: () => ios, 2077 linux: () => linux, 2078 mac: () => mac, 2079 windows: () => windows 2080 }); 2081 2082 // node_modules/@base-ui/utils/platform/shared.mjs 2083 function readRawData() { 2084 if (typeof navigator === "undefined") { 2085 return { 2086 userAgent: "", 2087 platform: "", 2088 maxTouchPoints: 0 2089 }; 2090 } 2091 if (true) { 2092 const uaData = navigator.userAgentData; 2093 if (uaData && Array.isArray(uaData.brands)) { 2094 return { 2095 userAgent: uaData.brands.map(({ 2096 brand, 2097 version: version2 2098 }) => `$brand}/$version2}`).join(" "), 2099 platform: uaData.platform ?? navigator.platform ?? "", 2100 maxTouchPoints: navigator.maxTouchPoints ?? 0 2101 }; 2102 } 2103 } 2104 return { 2105 userAgent: navigator.userAgent, 2106 platform: navigator.platform ?? "", 2107 maxTouchPoints: navigator.maxTouchPoints ?? 0 2108 }; 2109 } 2110 var { 2111 userAgent, 2112 platform, 2113 maxTouchPoints 2114 } = readRawData(); 2115 var lowerUserAgent = userAgent.toLowerCase(); 2116 var lowerPlatform = platform.toLowerCase(); 2117 2118 // node_modules/@base-ui/utils/platform/os.mjs 2119 var ios = /^i(os$|p)/.test(lowerPlatform) || lowerPlatform === "macintel" && maxTouchPoints > 1; 2120 var ANDROID_STRING = "android"; 2121 var android = lowerPlatform === ANDROID_STRING || lowerUserAgent.includes(ANDROID_STRING); 2122 var mac = !ios && lowerPlatform.startsWith("mac"); 2123 var windows = lowerPlatform.startsWith("win"); 2124 var linux = !android && /^(linux|chrome os)/.test(lowerPlatform); 2125 var apple = mac || ios; 2126 2127 // node_modules/@base-ui/utils/platform/engine.mjs 2128 var engine_exports = {}; 2129 __export(engine_exports, { 2130 blink: () => blink, 2131 gecko: () => gecko, 2132 webkit: () => webkit 2133 }); 2134 var webkit = typeof CSS !== "undefined" && !!CSS.supports?.("-webkit-backdrop-filter:none"); 2135 var gecko = !webkit && lowerUserAgent.includes("firefox"); 2136 var blink = !webkit && lowerUserAgent.includes("chrom"); 2137 2138 // node_modules/@base-ui/utils/platform/screen-reader.mjs 2139 var screen_reader_exports = {}; 2140 __export(screen_reader_exports, { 2141 voiceOver: () => voiceOver 2142 }); 2143 var voiceOver = apple; 2144 2145 // node_modules/@base-ui/utils/platform/env.mjs 2146 var env_exports = {}; 2147 __export(env_exports, { 2148 jsdom: () => jsdom 2149 }); 2150 var jsdom = /jsdom|happydom/.test(lowerUserAgent); 2151 2152 // node_modules/@base-ui/utils/useTimeout.mjs 2153 var EMPTY3 = 0; 2154 var Timeout = class _Timeout { 2155 static create() { 2156 return new _Timeout(); 2157 } 2158 currentId = EMPTY3; 2159 /** 2160 * Executes `fn` after `delay`, clearing any previously scheduled call. 2161 */ 2162 start(delay, fn) { 2163 this.clear(); 2164 this.currentId = setTimeout(() => { 2165 this.currentId = EMPTY3; 2166 fn(); 2167 }, delay); 2168 } 2169 isStarted() { 2170 return this.currentId !== EMPTY3; 2171 } 2172 clear = () => { 2173 if (this.currentId !== EMPTY3) { 2174 clearTimeout(this.currentId); 2175 this.currentId = EMPTY3; 2176 } 2177 }; 2178 disposeEffect = () => { 2179 return this.clear; 2180 }; 2181 }; 2182 function useTimeout() { 2183 const timeout = useRefWithInit(Timeout.create).current; 2184 useOnMount(timeout.disposeEffect); 2185 return timeout; 2186 } 2187 2188 // node_modules/@base-ui/react/floating-ui-react/components/FloatingDelayGroup.mjs 2189 var React13 = __toESM(require_react(), 1); 2190 2191 // node_modules/@base-ui/react/floating-ui-react/utils/event.mjs 2192 function isReactEvent(event) { 2193 return "nativeEvent" in event; 2194 } 2195 function isMouseLikePointerType(pointerType, strict) { 2196 const values = ["mouse", "pen"]; 2197 if (!strict) { 2198 values.push("", void 0); 2199 } 2200 return values.includes(pointerType); 2201 } 2202 function isClickLikeEvent(event) { 2203 const type = event.type; 2204 return type === "click" || type === "mousedown" || type === "keydown" || type === "keyup"; 2205 } 2206 2207 // node_modules/@base-ui/react/floating-ui-react/utils/constants.mjs 2208 var FOCUSABLE_ATTRIBUTE = "data-base-ui-focusable"; 2209 var TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])"; 2210 2211 // node_modules/@base-ui/react/internals/shadowDom.mjs 2212 function activeElement(doc) { 2213 let element = doc.activeElement; 2214 while (element?.shadowRoot?.activeElement != null) { 2215 element = element.shadowRoot.activeElement; 2216 } 2217 return element; 2218 } 2219 function contains(parent, child) { 2220 if (!parent || !child) { 2221 return false; 2222 } 2223 const rootNode = child.getRootNode?.(); 2224 if (parent.contains(child)) { 2225 return true; 2226 } 2227 if (rootNode && isShadowRoot(rootNode)) { 2228 let next = child; 2229 while (next) { 2230 if (parent === next) { 2231 return true; 2232 } 2233 next = next.parentNode || next.host; 2234 } 2235 } 2236 return false; 2237 } 2238 function getTarget(event) { 2239 if ("composedPath" in event) { 2240 return event.composedPath()[0]; 2241 } 2242 return event.target; 2243 } 2244 2245 // node_modules/@base-ui/react/floating-ui-react/utils/element.mjs 2246 function isTargetInsideEnabledTrigger(target, triggerElements) { 2247 if (!isElement(target)) { 2248 return false; 2249 } 2250 const targetElement = target; 2251 if (triggerElements.hasElement(targetElement)) { 2252 return !targetElement.hasAttribute("data-trigger-disabled"); 2253 } 2254 for (const [, trigger] of triggerElements.entries()) { 2255 if (contains(trigger, targetElement)) { 2256 return !trigger.hasAttribute("data-trigger-disabled"); 2257 } 2258 } 2259 return false; 2260 } 2261 function isEventTargetWithin(event, node) { 2262 if (node == null) { 2263 return false; 2264 } 2265 if ("composedPath" in event) { 2266 return event.composedPath().includes(node); 2267 } 2268 const eventAgain = event; 2269 return eventAgain.target != null && node.contains(eventAgain.target); 2270 } 2271 function isRootElement(element) { 2272 return element.matches("html,body"); 2273 } 2274 function isTypeableElement(element) { 2275 return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR); 2276 } 2277 function isInteractiveElement(element) { 2278 return element?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),$TYPEABLE_SELECTOR}`) != null; 2279 } 2280 function matchesFocusVisible(element) { 2281 if (!element || parts_exports.env.jsdom) { 2282 return true; 2283 } 2284 try { 2285 return element.matches(":focus-visible"); 2286 } catch (_e) { 2287 return true; 2288 } 2289 } 2290 2291 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverShared.mjs 2292 function resolveValue(value, pointerType) { 2293 if (pointerType != null && !isMouseLikePointerType(pointerType)) { 2294 return 0; 2295 } 2296 if (typeof value === "function") { 2297 return value(); 2298 } 2299 return value; 2300 } 2301 function getDelay(value, prop, pointerType) { 2302 const result = resolveValue(value, pointerType); 2303 if (typeof result === "number") { 2304 return result; 2305 } 2306 return result?.[prop]; 2307 } 2308 function getRestMs(value) { 2309 if (typeof value === "function") { 2310 return value(); 2311 } 2312 return value; 2313 } 2314 function isClickLikeOpenEvent(openEventType, interactedInside) { 2315 return interactedInside || openEventType === "click" || openEventType === "mousedown"; 2316 } 2317 function isHoverOpenEvent(openEventType) { 2318 return openEventType?.includes("mouse") && openEventType !== "mousedown"; 2319 } 2320 2321 // node_modules/@base-ui/react/floating-ui-react/components/FloatingDelayGroup.mjs 2322 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1); 2323 var FloatingDelayGroupContext = /* @__PURE__ */ React13.createContext({ 2324 hasProvider: false, 2325 timeoutMs: 0, 2326 delayRef: { 2327 current: 0 2328 }, 2329 initialDelayRef: { 2330 current: 0 2331 }, 2332 timeout: new Timeout(), 2333 currentIdRef: { 2334 current: null 2335 }, 2336 currentContextRef: { 2337 current: null 2338 } 2339 }); 2340 if (true) FloatingDelayGroupContext.displayName = "FloatingDelayGroupContext"; 2341 function resetDelayRef(delayRef, initialDelayRef) { 2342 delayRef.current = initialDelayRef.current; 2343 } 2344 function FloatingDelayGroup(props) { 2345 const { 2346 children, 2347 delay, 2348 timeoutMs = 0 2349 } = props; 2350 const delayRef = React13.useRef(delay); 2351 const initialDelayRef = React13.useRef(delay); 2352 const currentIdRef = React13.useRef(null); 2353 const currentContextRef = React13.useRef(null); 2354 const timeout = useTimeout(); 2355 useIsoLayoutEffect(() => { 2356 initialDelayRef.current = delay; 2357 if (!currentIdRef.current) { 2358 delayRef.current = delay; 2359 return; 2360 } 2361 delayRef.current = { 2362 open: getDelay(delayRef.current, "open"), 2363 close: getDelay(delay, "close") 2364 }; 2365 }, [delay, currentIdRef, delayRef, initialDelayRef]); 2366 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FloatingDelayGroupContext.Provider, { 2367 value: React13.useMemo(() => ({ 2368 hasProvider: true, 2369 delayRef, 2370 initialDelayRef, 2371 currentIdRef, 2372 timeoutMs, 2373 currentContextRef, 2374 timeout 2375 }), [timeoutMs, timeout]), 2376 children 2377 }); 2378 } 2379 function useDelayGroup(context, options = { 2380 open: false 2381 }) { 2382 const { 2383 open 2384 } = options; 2385 const store2 = "rootStore" in context ? context.rootStore : context; 2386 const floatingId = store2.useState("floatingId"); 2387 const groupContext = React13.useContext(FloatingDelayGroupContext); 2388 const { 2389 currentIdRef, 2390 delayRef, 2391 timeoutMs, 2392 initialDelayRef, 2393 currentContextRef, 2394 hasProvider, 2395 timeout 2396 } = groupContext; 2397 const [isInstantPhase, setIsInstantPhase] = React13.useState(false); 2398 const openRef = React13.useRef(open); 2399 const isUnmountedRef = React13.useRef(false); 2400 useIsoLayoutEffect(() => { 2401 openRef.current = open; 2402 }, [open]); 2403 useIsoLayoutEffect(() => { 2404 return () => { 2405 isUnmountedRef.current = true; 2406 }; 2407 }, []); 2408 useIsoLayoutEffect(() => { 2409 function unset() { 2410 if (!isUnmountedRef.current) { 2411 setIsInstantPhase(false); 2412 } 2413 currentContextRef.current?.setIsInstantPhase(false); 2414 currentIdRef.current = null; 2415 currentContextRef.current = null; 2416 delayRef.current = initialDelayRef.current; 2417 timeout.clear(); 2418 } 2419 if (!currentIdRef.current) { 2420 return void 0; 2421 } 2422 if (!open && currentIdRef.current === floatingId) { 2423 setIsInstantPhase(false); 2424 if (timeoutMs) { 2425 const closingId = floatingId; 2426 timeout.start(timeoutMs, () => { 2427 if (store2.select("open") || currentIdRef.current && currentIdRef.current !== closingId) { 2428 return; 2429 } 2430 unset(); 2431 }); 2432 return () => { 2433 if (openRef.current || currentIdRef.current !== closingId) { 2434 timeout.clear(); 2435 } 2436 }; 2437 } 2438 unset(); 2439 } 2440 return void 0; 2441 }, [open, floatingId, currentIdRef, delayRef, timeoutMs, initialDelayRef, currentContextRef, timeout, store2]); 2442 useIsoLayoutEffect(() => { 2443 if (!open) { 2444 return; 2445 } 2446 const prevContext = currentContextRef.current; 2447 const prevId = currentIdRef.current; 2448 timeout.clear(); 2449 currentContextRef.current = { 2450 onOpenChange: store2.setOpen, 2451 setIsInstantPhase 2452 }; 2453 currentIdRef.current = floatingId; 2454 delayRef.current = { 2455 open: 0, 2456 close: getDelay(initialDelayRef.current, "close") 2457 }; 2458 if (prevId !== null && prevId !== floatingId) { 2459 setIsInstantPhase(true); 2460 prevContext?.setIsInstantPhase(true); 2461 prevContext?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.none)); 2462 } else { 2463 setIsInstantPhase(false); 2464 prevContext?.setIsInstantPhase(false); 2465 } 2466 }, [open, floatingId, store2, currentIdRef, delayRef, initialDelayRef, currentContextRef, timeout]); 2467 useIsoLayoutEffect(() => { 2468 return () => { 2469 if (currentIdRef.current === floatingId) { 2470 currentContextRef.current = null; 2471 if (!openRef.current) { 2472 return; 2473 } 2474 currentIdRef.current = null; 2475 resetDelayRef(delayRef, initialDelayRef); 2476 timeout.clear(); 2477 } 2478 }; 2479 }, [currentContextRef, currentIdRef, delayRef, floatingId, initialDelayRef, timeout]); 2480 return React13.useMemo(() => ({ 2481 hasProvider, 2482 delayRef, 2483 isInstantPhase 2484 }), [hasProvider, delayRef, isInstantPhase]); 2485 } 2486 2487 // node_modules/@base-ui/utils/mergeCleanups.mjs 2488 function mergeCleanups(...cleanups) { 2489 return () => { 2490 for (let i = 0; i < cleanups.length; i += 1) { 2491 const cleanup = cleanups[i]; 2492 if (cleanup) { 2493 cleanup(); 2494 } 2495 } 2496 }; 2497 } 2498 2499 // node_modules/@base-ui/react/utils/FocusGuard.mjs 2500 var React14 = __toESM(require_react(), 1); 2501 2502 // node_modules/@base-ui/utils/visuallyHidden.mjs 2503 var visuallyHiddenBase = { 2504 clipPath: "inset(50%)", 2505 overflow: "hidden", 2506 whiteSpace: "nowrap", 2507 border: 0, 2508 padding: 0, 2509 width: 1, 2510 height: 1, 2511 margin: -1 2512 }; 2513 var visuallyHidden = { 2514 ...visuallyHiddenBase, 2515 position: "fixed", 2516 top: 0, 2517 left: 0 2518 }; 2519 var visuallyHiddenInput = { 2520 ...visuallyHiddenBase, 2521 position: "absolute" 2522 }; 2523 2524 // node_modules/@base-ui/react/utils/FocusGuard.mjs 2525 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1); 2526 var FocusGuard = /* @__PURE__ */ React14.forwardRef(function FocusGuard2(props, ref) { 2527 const [role, setRole] = React14.useState(); 2528 useIsoLayoutEffect(() => { 2529 if (parts_exports.screenReader.voiceOver && parts_exports.engine.webkit) { 2530 setRole("button"); 2531 } 2532 }, []); 2533 const restProps = { 2534 tabIndex: 0, 2535 // Role is only for VoiceOver 2536 role 2537 }; 2538 return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { 2539 ...props, 2540 ref, 2541 style: visuallyHidden, 2542 "aria-hidden": role ? void 0 : true, 2543 ...restProps, 2544 "data-base-ui-focus-guard": "" 2545 }); 2546 }); 2547 if (true) FocusGuard.displayName = "FocusGuard"; 2548 2549 // node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs 2550 var sides = ["top", "right", "bottom", "left"]; 2551 var min = Math.min; 2552 var max = Math.max; 2553 var round = Math.round; 2554 var floor = Math.floor; 2555 var createCoords = (v) => ({ 2556 x: v, 2557 y: v 2558 }); 2559 var oppositeSideMap = { 2560 left: "right", 2561 right: "left", 2562 bottom: "top", 2563 top: "bottom" 2564 }; 2565 function clamp(start, value, end) { 2566 return max(start, min(value, end)); 2567 } 2568 function evaluate(value, param) { 2569 return typeof value === "function" ? value(param) : value; 2570 } 2571 function getSide(placement) { 2572 return placement.split("-")[0]; 2573 } 2574 function getAlignment(placement) { 2575 return placement.split("-")[1]; 2576 } 2577 function getOppositeAxis(axis) { 2578 return axis === "x" ? "y" : "x"; 2579 } 2580 function getAxisLength(axis) { 2581 return axis === "y" ? "height" : "width"; 2582 } 2583 function getSideAxis(placement) { 2584 const firstChar = placement[0]; 2585 return firstChar === "t" || firstChar === "b" ? "y" : "x"; 2586 } 2587 function getAlignmentAxis(placement) { 2588 return getOppositeAxis(getSideAxis(placement)); 2589 } 2590 function getAlignmentSides(placement, rects, rtl) { 2591 if (rtl === void 0) { 2592 rtl = false; 2593 } 2594 const alignment = getAlignment(placement); 2595 const alignmentAxis = getAlignmentAxis(placement); 2596 const length = getAxisLength(alignmentAxis); 2597 let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top"; 2598 if (rects.reference[length] > rects.floating[length]) { 2599 mainAlignmentSide = getOppositePlacement(mainAlignmentSide); 2600 } 2601 return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)]; 2602 } 2603 function getExpandedPlacements(placement) { 2604 const oppositePlacement = getOppositePlacement(placement); 2605 return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)]; 2606 } 2607 function getOppositeAlignmentPlacement(placement) { 2608 return placement.includes("start") ? placement.replace("start", "end") : placement.replace("end", "start"); 2609 } 2610 var lrPlacement = ["left", "right"]; 2611 var rlPlacement = ["right", "left"]; 2612 var tbPlacement = ["top", "bottom"]; 2613 var btPlacement = ["bottom", "top"]; 2614 function getSideList(side, isStart, rtl) { 2615 switch (side) { 2616 case "top": 2617 case "bottom": 2618 if (rtl) return isStart ? rlPlacement : lrPlacement; 2619 return isStart ? lrPlacement : rlPlacement; 2620 case "left": 2621 case "right": 2622 return isStart ? tbPlacement : btPlacement; 2623 default: 2624 return []; 2625 } 2626 } 2627 function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) { 2628 const alignment = getAlignment(placement); 2629 let list = getSideList(getSide(placement), direction === "start", rtl); 2630 if (alignment) { 2631 list = list.map((side) => side + "-" + alignment); 2632 if (flipAlignment) { 2633 list = list.concat(list.map(getOppositeAlignmentPlacement)); 2634 } 2635 } 2636 return list; 2637 } 2638 function getOppositePlacement(placement) { 2639 const side = getSide(placement); 2640 return oppositeSideMap[side] + placement.slice(side.length); 2641 } 2642 function expandPaddingObject(padding) { 2643 return { 2644 top: 0, 2645 right: 0, 2646 bottom: 0, 2647 left: 0, 2648 ...padding 2649 }; 2650 } 2651 function getPaddingObject(padding) { 2652 return typeof padding !== "number" ? expandPaddingObject(padding) : { 2653 top: padding, 2654 right: padding, 2655 bottom: padding, 2656 left: padding 2657 }; 2658 } 2659 function rectToClientRect(rect) { 2660 const { 2661 x, 2662 y, 2663 width, 2664 height 2665 } = rect; 2666 return { 2667 width, 2668 height, 2669 top: y, 2670 left: x, 2671 right: x + width, 2672 bottom: y + height, 2673 x, 2674 y 2675 }; 2676 } 2677 2678 // node_modules/@base-ui/react/floating-ui-react/utils/composite.mjs 2679 function isHiddenByStyles(styles) { 2680 return styles.visibility === "hidden" || styles.visibility === "collapse"; 2681 } 2682 function isElementVisible(element, styles = element ? getComputedStyle2(element) : null) { 2683 if (!element || !element.isConnected || !styles || isHiddenByStyles(styles)) { 2684 return false; 2685 } 2686 if (typeof element.checkVisibility === "function") { 2687 return element.checkVisibility(); 2688 } 2689 return styles.display !== "none" && styles.display !== "contents"; 2690 } 2691 2692 // node_modules/@base-ui/react/floating-ui-react/utils/tabbable.mjs 2693 var CANDIDATE_SELECTOR = 'a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]'; 2694 function getParentElement(element) { 2695 const assignedSlot = element.assignedSlot; 2696 if (assignedSlot) { 2697 return assignedSlot; 2698 } 2699 if (element.parentElement) { 2700 return element.parentElement; 2701 } 2702 const rootNode = element.getRootNode(); 2703 return isShadowRoot(rootNode) ? rootNode.host : null; 2704 } 2705 function getDetailsSummary(details) { 2706 for (const child of Array.from(details.children)) { 2707 if (getNodeName(child) === "summary") { 2708 return child; 2709 } 2710 } 2711 return null; 2712 } 2713 function isWithinOpenDetailsSummary(element, details) { 2714 const summary = getDetailsSummary(details); 2715 return !!summary && (element === summary || contains(summary, element)); 2716 } 2717 function isFocusableCandidate(element) { 2718 const nodeName = element ? getNodeName(element) : ""; 2719 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"); 2720 } 2721 function isFocusableElement(element) { 2722 if (!isFocusableCandidate(element) || !element.isConnected || element.matches(":disabled")) { 2723 return false; 2724 } 2725 for (let current = element; current; current = getParentElement(current)) { 2726 const isAncestor = current !== element; 2727 const isSlot = getNodeName(current) === "slot"; 2728 if (current.hasAttribute("inert")) { 2729 return false; 2730 } 2731 if (isAncestor && getNodeName(current) === "details" && !current.open && !isWithinOpenDetailsSummary(element, current) || current.hasAttribute("hidden") || !isSlot && !isVisibleInTabbableTree(current, isAncestor)) { 2732 return false; 2733 } 2734 } 2735 return true; 2736 } 2737 function isVisibleInTabbableTree(element, isAncestor) { 2738 const styles = getComputedStyle2(element); 2739 if (!isAncestor) { 2740 return isElementVisible(element, styles); 2741 } 2742 return styles.display !== "none"; 2743 } 2744 function getTabIndex(element) { 2745 const tabIndex = element.tabIndex; 2746 if (tabIndex < 0) { 2747 const nodeName = getNodeName(element); 2748 if (nodeName === "details" || nodeName === "audio" || nodeName === "video" || isHTMLElement(element) && element.isContentEditable) { 2749 return 0; 2750 } 2751 } 2752 return tabIndex; 2753 } 2754 function getNamedRadioInput(element) { 2755 if (getNodeName(element) !== "input") { 2756 return null; 2757 } 2758 const input = element; 2759 return input.type === "radio" && input.name !== "" ? input : null; 2760 } 2761 function isTabbableRadio(element, candidates) { 2762 const input = getNamedRadioInput(element); 2763 if (!input) { 2764 return true; 2765 } 2766 const checkedRadio = candidates.find((candidate) => { 2767 const radio = getNamedRadioInput(candidate); 2768 return radio?.name === input.name && radio.form === input.form && radio.checked; 2769 }); 2770 if (checkedRadio) { 2771 return checkedRadio === input; 2772 } 2773 return candidates.find((candidate) => { 2774 const radio = getNamedRadioInput(candidate); 2775 return radio?.name === input.name && radio.form === input.form; 2776 }) === input; 2777 } 2778 function getComposedChildren(container) { 2779 if (isHTMLElement(container) && getNodeName(container) === "slot") { 2780 const assignedElements = container.assignedElements({ 2781 flatten: true 2782 }); 2783 if (assignedElements.length > 0) { 2784 return assignedElements; 2785 } 2786 } 2787 if (isHTMLElement(container) && container.shadowRoot) { 2788 return Array.from(container.shadowRoot.children); 2789 } 2790 return Array.from(container.children); 2791 } 2792 function appendCandidates(container, list) { 2793 getComposedChildren(container).forEach((child) => { 2794 if (isFocusableCandidate(child)) { 2795 list.push(child); 2796 } 2797 appendCandidates(child, list); 2798 }); 2799 } 2800 function appendMatchingElements(container, selector, list) { 2801 getComposedChildren(container).forEach((child) => { 2802 if (isHTMLElement(child) && child.matches(selector)) { 2803 list.push(child); 2804 } 2805 appendMatchingElements(child, selector, list); 2806 }); 2807 } 2808 function focusable(container) { 2809 const candidates = []; 2810 appendCandidates(container, candidates); 2811 return candidates.filter(isFocusableElement); 2812 } 2813 function tabbable(container) { 2814 const candidates = focusable(container); 2815 return candidates.filter((element) => getTabIndex(element) >= 0 && isTabbableRadio(element, candidates)); 2816 } 2817 function getTabbableIn(container, dir) { 2818 const list = tabbable(container); 2819 const len = list.length; 2820 if (len === 0) { 2821 return void 0; 2822 } 2823 const active = activeElement(ownerDocument(container)); 2824 const index2 = list.indexOf(active); 2825 const nextIndex = index2 === -1 ? dir === 1 ? 0 : len - 1 : index2 + dir; 2826 return list[nextIndex]; 2827 } 2828 function getNextTabbable(referenceElement) { 2829 return getTabbableIn(ownerDocument(referenceElement).body, 1) || referenceElement; 2830 } 2831 function getPreviousTabbable(referenceElement) { 2832 return getTabbableIn(ownerDocument(referenceElement).body, -1) || referenceElement; 2833 } 2834 function isOutsideEvent(event, container) { 2835 const containerElement = container || event.currentTarget; 2836 const relatedTarget = event.relatedTarget; 2837 return !relatedTarget || !contains(containerElement, relatedTarget); 2838 } 2839 function disableFocusInside(container) { 2840 const tabbableElements = tabbable(container); 2841 tabbableElements.forEach((element) => { 2842 element.dataset.tabindex = element.getAttribute("tabindex") || ""; 2843 element.setAttribute("tabindex", "-1"); 2844 }); 2845 } 2846 function enableFocusInside(container) { 2847 const elements = []; 2848 appendMatchingElements(container, "[data-tabindex]", elements); 2849 elements.forEach((element) => { 2850 const tabindex = element.dataset.tabindex; 2851 delete element.dataset.tabindex; 2852 if (tabindex) { 2853 element.setAttribute("tabindex", tabindex); 2854 } else { 2855 element.removeAttribute("tabindex"); 2856 } 2857 }); 2858 } 2859 2860 // node_modules/@base-ui/react/floating-ui-react/utils/nodes.mjs 2861 function getNodeChildren(nodes, id, onlyOpenChildren = true) { 2862 const directChildren = nodes.filter((node) => node.parentId === id); 2863 return directChildren.flatMap((child) => [...!onlyOpenChildren || child.context?.open ? [child] : [], ...getNodeChildren(nodes, child.id, onlyOpenChildren)]); 2864 } 2865 2866 // node_modules/@base-ui/react/floating-ui-react/utils/createAttribute.mjs 2867 function createAttribute(name) { 2868 return `data-base-ui-$name}`; 2869 } 2870 2871 // node_modules/@base-ui/react/floating-ui-react/components/FloatingPortal.mjs 2872 var React15 = __toESM(require_react(), 1); 2873 var ReactDOM2 = __toESM(require_react_dom(), 1); 2874 2875 // node_modules/@base-ui/react/internals/constants.mjs 2876 var DISABLED_TRANSITIONS_STYLE = { 2877 style: { 2878 transition: "none" 2879 } 2880 }; 2881 var BASE_UI_SWIPE_IGNORE_ATTRIBUTE = "data-base-ui-swipe-ignore"; 2882 var LEGACY_SWIPE_IGNORE_ATTRIBUTE = "data-swipe-ignore"; 2883 var BASE_UI_SWIPE_IGNORE_SELECTOR = `[$BASE_UI_SWIPE_IGNORE_ATTRIBUTE}]`; 2884 var LEGACY_SWIPE_IGNORE_SELECTOR = `[$LEGACY_SWIPE_IGNORE_ATTRIBUTE}]`; 2885 var POPUP_COLLISION_AVOIDANCE = { 2886 fallbackAxisSide: "end" 2887 }; 2888 var ownerVisuallyHidden = { 2889 clipPath: "inset(50%)", 2890 position: "fixed", 2891 top: 0, 2892 left: 0 2893 }; 2894 2895 // node_modules/@base-ui/react/floating-ui-react/components/FloatingPortal.mjs 2896 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1); 2897 var PortalContext = /* @__PURE__ */ React15.createContext(null); 2898 if (true) PortalContext.displayName = "PortalContext"; 2899 var usePortalContext = () => React15.useContext(PortalContext); 2900 var attr = createAttribute("portal"); 2901 function useFloatingPortalNode(props = {}) { 2902 const { 2903 ref, 2904 container: containerProp, 2905 componentProps = EMPTY_OBJECT, 2906 elementProps 2907 } = props; 2908 const uniqueId = useId(); 2909 const portalContext = usePortalContext(); 2910 const parentPortalNode = portalContext?.portalNode; 2911 const [containerElement, setContainerElement] = React15.useState(null); 2912 const [portalNode, setPortalNode] = React15.useState(null); 2913 const setPortalNodeRef = useStableCallback((node) => { 2914 if (node !== null) { 2915 setPortalNode(node); 2916 } 2917 }); 2918 const containerRef = React15.useRef(null); 2919 useIsoLayoutEffect(() => { 2920 if (containerProp === null) { 2921 if (containerRef.current) { 2922 containerRef.current = null; 2923 setPortalNode(null); 2924 setContainerElement(null); 2925 } 2926 return; 2927 } 2928 if (uniqueId == null) { 2929 return; 2930 } 2931 const resolvedContainer = (containerProp && (isNode(containerProp) ? containerProp : containerProp.current)) ?? parentPortalNode ?? document.body; 2932 if (resolvedContainer == null) { 2933 if (containerRef.current) { 2934 containerRef.current = null; 2935 setPortalNode(null); 2936 setContainerElement(null); 2937 } 2938 return; 2939 } 2940 if (containerRef.current !== resolvedContainer) { 2941 containerRef.current = resolvedContainer; 2942 setPortalNode(null); 2943 setContainerElement(resolvedContainer); 2944 } 2945 }, [containerProp, parentPortalNode, uniqueId]); 2946 const portalElement = useRenderElement("div", componentProps, { 2947 ref: [ref, setPortalNodeRef], 2948 props: [{ 2949 id: uniqueId, 2950 [attr]: "" 2951 }, elementProps] 2952 }); 2953 const portalSubtree = containerElement && portalElement ? /* @__PURE__ */ ReactDOM2.createPortal(portalElement, containerElement) : null; 2954 return { 2955 portalNode, 2956 portalSubtree 2957 }; 2958 } 2959 var FloatingPortal = /* @__PURE__ */ React15.forwardRef(function FloatingPortal2(componentProps, forwardedRef) { 2960 const { 2961 render, 2962 className, 2963 style, 2964 children, 2965 container, 2966 renderGuards, 2967 ...elementProps 2968 } = componentProps; 2969 const { 2970 portalNode, 2971 portalSubtree 2972 } = useFloatingPortalNode({ 2973 container, 2974 ref: forwardedRef, 2975 componentProps, 2976 elementProps 2977 }); 2978 const beforeOutsideRef = React15.useRef(null); 2979 const afterOutsideRef = React15.useRef(null); 2980 const beforeInsideRef = React15.useRef(null); 2981 const afterInsideRef = React15.useRef(null); 2982 const [focusManagerState, setFocusManagerState] = React15.useState(null); 2983 const focusInsideDisabledRef = React15.useRef(false); 2984 const modal = focusManagerState?.modal; 2985 const open = focusManagerState?.open; 2986 const shouldRenderGuards = typeof renderGuards === "boolean" ? renderGuards : !!focusManagerState && !focusManagerState.modal && focusManagerState.open && !!portalNode; 2987 React15.useEffect(() => { 2988 if (!portalNode || modal) { 2989 return void 0; 2990 } 2991 function onFocus(event) { 2992 if (portalNode && event.relatedTarget && isOutsideEvent(event)) { 2993 if (event.type === "focusin") { 2994 if (focusInsideDisabledRef.current) { 2995 enableFocusInside(portalNode); 2996 focusInsideDisabledRef.current = false; 2997 } 2998 } else { 2999 disableFocusInside(portalNode); 3000 focusInsideDisabledRef.current = true; 3001 } 3002 } 3003 } 3004 return mergeCleanups(addEventListener(portalNode, "focusin", onFocus, true), addEventListener(portalNode, "focusout", onFocus, true)); 3005 }, [portalNode, modal]); 3006 useIsoLayoutEffect(() => { 3007 if (!portalNode || open !== true || !focusInsideDisabledRef.current) { 3008 return; 3009 } 3010 enableFocusInside(portalNode); 3011 focusInsideDisabledRef.current = false; 3012 }, [open, portalNode]); 3013 const portalContextValue = React15.useMemo(() => ({ 3014 beforeOutsideRef, 3015 afterOutsideRef, 3016 beforeInsideRef, 3017 afterInsideRef, 3018 portalNode, 3019 setFocusManagerState 3020 }), [portalNode]); 3021 return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(React15.Fragment, { 3022 children: [portalSubtree, /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(PortalContext.Provider, { 3023 value: portalContextValue, 3024 children: [shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, { 3025 "data-type": "outside", 3026 ref: beforeOutsideRef, 3027 onFocus: (event) => { 3028 if (isOutsideEvent(event, portalNode)) { 3029 beforeInsideRef.current?.focus(); 3030 } else { 3031 const domReference = focusManagerState ? focusManagerState.domReference : null; 3032 const prevTabbable = getPreviousTabbable(domReference); 3033 prevTabbable?.focus(); 3034 } 3035 } 3036 }), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { 3037 "aria-owns": portalNode.id, 3038 style: ownerVisuallyHidden 3039 }), portalNode && /* @__PURE__ */ ReactDOM2.createPortal(children, portalNode), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, { 3040 "data-type": "outside", 3041 ref: afterOutsideRef, 3042 onFocus: (event) => { 3043 if (isOutsideEvent(event, portalNode)) { 3044 afterInsideRef.current?.focus(); 3045 } else { 3046 const domReference = focusManagerState ? focusManagerState.domReference : null; 3047 const nextTabbable = getNextTabbable(domReference); 3048 nextTabbable?.focus(); 3049 if (focusManagerState?.closeOnFocusOut) { 3050 focusManagerState?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.focusOut, event.nativeEvent)); 3051 } 3052 } 3053 } 3054 })] 3055 })] 3056 }); 3057 }); 3058 if (true) FloatingPortal.displayName = "FloatingPortal"; 3059 3060 // node_modules/@base-ui/react/floating-ui-react/components/FloatingTree.mjs 3061 var React16 = __toESM(require_react(), 1); 3062 3063 // node_modules/@base-ui/react/floating-ui-react/utils/createEventEmitter.mjs 3064 function createEventEmitter() { 3065 const map = /* @__PURE__ */ new Map(); 3066 return { 3067 emit(event, data) { 3068 map.get(event)?.forEach((listener) => listener(data)); 3069 }, 3070 on(event, listener) { 3071 if (!map.has(event)) { 3072 map.set(event, /* @__PURE__ */ new Set()); 3073 } 3074 map.get(event).add(listener); 3075 }, 3076 off(event, listener) { 3077 map.get(event)?.delete(listener); 3078 } 3079 }; 3080 } 3081 3082 // node_modules/@base-ui/react/floating-ui-react/components/FloatingTree.mjs 3083 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1); 3084 var FloatingNodeContext = /* @__PURE__ */ React16.createContext(null); 3085 if (true) FloatingNodeContext.displayName = "FloatingNodeContext"; 3086 var FloatingTreeContext = /* @__PURE__ */ React16.createContext(null); 3087 if (true) FloatingTreeContext.displayName = "FloatingTreeContext"; 3088 var useFloatingParentNodeId = () => React16.useContext(FloatingNodeContext)?.id || null; 3089 var useFloatingTree = (externalTree) => { 3090 const contextTree = React16.useContext(FloatingTreeContext); 3091 return externalTree ?? contextTree; 3092 }; 3093 3094 // node_modules/@base-ui/react/floating-ui-react/hooks/useClientPoint.mjs 3095 var React17 = __toESM(require_react(), 1); 3096 function createVirtualElement(domElement, data) { 3097 let offsetX = null; 3098 let offsetY = null; 3099 let isAutoUpdateEvent = false; 3100 return { 3101 contextElement: domElement || void 0, 3102 getBoundingClientRect() { 3103 const domRect = domElement?.getBoundingClientRect() || { 3104 width: 0, 3105 height: 0, 3106 x: 0, 3107 y: 0 3108 }; 3109 const isXAxis = data.axis === "x" || data.axis === "both"; 3110 const isYAxis = data.axis === "y" || data.axis === "both"; 3111 const canTrackCursorOnAutoUpdate = ["mouseenter", "mousemove"].includes(data.dataRef.current.openEvent?.type || "") && data.pointerType !== "touch"; 3112 let width = domRect.width; 3113 let height = domRect.height; 3114 let x = domRect.x; 3115 let y = domRect.y; 3116 if (offsetX == null && data.x && isXAxis) { 3117 offsetX = domRect.x - data.x; 3118 } 3119 if (offsetY == null && data.y && isYAxis) { 3120 offsetY = domRect.y - data.y; 3121 } 3122 x -= offsetX || 0; 3123 y -= offsetY || 0; 3124 width = 0; 3125 height = 0; 3126 if (!isAutoUpdateEvent || canTrackCursorOnAutoUpdate) { 3127 width = data.axis === "y" ? domRect.width : 0; 3128 height = data.axis === "x" ? domRect.height : 0; 3129 x = isXAxis && data.x != null ? data.x : x; 3130 y = isYAxis && data.y != null ? data.y : y; 3131 } else if (isAutoUpdateEvent && !canTrackCursorOnAutoUpdate) { 3132 height = data.axis === "x" ? domRect.height : height; 3133 width = data.axis === "y" ? domRect.width : width; 3134 } 3135 isAutoUpdateEvent = true; 3136 return { 3137 width, 3138 height, 3139 x, 3140 y, 3141 top: y, 3142 right: x + width, 3143 bottom: y + height, 3144 left: x 3145 }; 3146 } 3147 }; 3148 } 3149 function isMouseBasedEvent(event) { 3150 return event != null && event.clientX != null; 3151 } 3152 function useClientPoint(context, props = {}) { 3153 const { 3154 enabled = true, 3155 axis = "both" 3156 } = props; 3157 const store2 = "rootStore" in context ? context.rootStore : context; 3158 const open = store2.useState("open"); 3159 const floating = store2.useState("floatingElement"); 3160 const domReference = store2.useState("domReferenceElement"); 3161 const dataRef = store2.context.dataRef; 3162 const initialRef = React17.useRef(false); 3163 const cleanupListenerRef = React17.useRef(null); 3164 const [pointerType, setPointerType] = React17.useState(); 3165 const [reactive, setReactive] = React17.useState([]); 3166 const resetReference = useStableCallback((reference2) => { 3167 store2.set("positionReference", reference2); 3168 }); 3169 const setReference = useStableCallback((newX, newY, referenceElement) => { 3170 if (initialRef.current) { 3171 return; 3172 } 3173 if (dataRef.current.openEvent && !isMouseBasedEvent(dataRef.current.openEvent)) { 3174 return; 3175 } 3176 store2.set("positionReference", createVirtualElement(referenceElement ?? domReference, { 3177 x: newX, 3178 y: newY, 3179 axis, 3180 dataRef, 3181 pointerType 3182 })); 3183 }); 3184 const handleReferenceEnterOrMove = useStableCallback((event) => { 3185 if (!open) { 3186 setReference(event.clientX, event.clientY, event.currentTarget); 3187 } else if (!cleanupListenerRef.current) { 3188 setReference(event.clientX, event.clientY, event.currentTarget); 3189 setReactive([]); 3190 } 3191 }); 3192 const openCheck = isMouseLikePointerType(pointerType) ? floating : open; 3193 React17.useEffect(() => { 3194 if (!enabled) { 3195 resetReference(domReference); 3196 return void 0; 3197 } 3198 if (!openCheck) { 3199 return void 0; 3200 } 3201 function cleanupListener() { 3202 cleanupListenerRef.current?.(); 3203 cleanupListenerRef.current = null; 3204 } 3205 const win = getWindow(floating); 3206 function handleMouseMove(event) { 3207 const target = getTarget(event); 3208 if (!contains(floating, target)) { 3209 setReference(event.clientX, event.clientY); 3210 } else { 3211 cleanupListener(); 3212 } 3213 } 3214 if (!dataRef.current.openEvent || isMouseBasedEvent(dataRef.current.openEvent)) { 3215 cleanupListenerRef.current = addEventListener(win, "mousemove", handleMouseMove); 3216 } else { 3217 resetReference(domReference); 3218 } 3219 return cleanupListener; 3220 }, [openCheck, enabled, floating, dataRef, domReference, store2, setReference, resetReference, reactive]); 3221 React17.useEffect(() => () => { 3222 store2.set("positionReference", null); 3223 }, [store2]); 3224 React17.useEffect(() => { 3225 if (enabled && !floating) { 3226 initialRef.current = false; 3227 } 3228 }, [enabled, floating]); 3229 React17.useEffect(() => { 3230 if (!enabled && open) { 3231 initialRef.current = true; 3232 } 3233 }, [enabled, open]); 3234 const reference = React17.useMemo(() => { 3235 function setPointerTypeRef(event) { 3236 setPointerType(event.pointerType); 3237 } 3238 return { 3239 onPointerDown: setPointerTypeRef, 3240 onPointerEnter: setPointerTypeRef, 3241 onMouseMove: handleReferenceEnterOrMove, 3242 onMouseEnter: handleReferenceEnterOrMove 3243 }; 3244 }, [handleReferenceEnterOrMove]); 3245 return React17.useMemo(() => enabled ? { 3246 reference, 3247 trigger: reference 3248 } : {}, [enabled, reference]); 3249 } 3250 3251 // node_modules/@base-ui/react/floating-ui-react/hooks/useDismiss.mjs 3252 var React18 = __toESM(require_react(), 1); 3253 function alwaysFalse() { 3254 return false; 3255 } 3256 function normalizeProp(normalizable) { 3257 return { 3258 escapeKey: typeof normalizable === "boolean" ? normalizable : normalizable?.escapeKey ?? false, 3259 outsidePress: typeof normalizable === "boolean" ? normalizable : normalizable?.outsidePress ?? true 3260 }; 3261 } 3262 function useDismiss(context, props = {}) { 3263 const { 3264 enabled = true, 3265 escapeKey: escapeKey2 = true, 3266 outsidePress: outsidePressProp = true, 3267 outsidePressEvent = "sloppy", 3268 referencePress = alwaysFalse, 3269 bubbles, 3270 externalTree 3271 } = props; 3272 const store2 = "rootStore" in context ? context.rootStore : context; 3273 const open = store2.useState("open"); 3274 const floatingElement = store2.useState("floatingElement"); 3275 const { 3276 dataRef 3277 } = store2.context; 3278 const tree = useFloatingTree(externalTree); 3279 const outsidePressFn = useStableCallback(typeof outsidePressProp === "function" ? outsidePressProp : () => false); 3280 const outsidePress2 = typeof outsidePressProp === "function" ? outsidePressFn : outsidePressProp; 3281 const outsidePressEnabled = outsidePress2 !== false; 3282 const getOutsidePressEventProp = useStableCallback(() => outsidePressEvent); 3283 const { 3284 escapeKey: escapeKeyBubbles, 3285 outsidePress: outsidePressBubbles 3286 } = normalizeProp(bubbles); 3287 const pressStartedInsideRef = React18.useRef(false); 3288 const pressStartPreventedRef = React18.useRef(false); 3289 const suppressNextOutsideClickRef = React18.useRef(false); 3290 const isComposingRef = React18.useRef(false); 3291 const currentPointerTypeRef = React18.useRef(""); 3292 const touchStateRef = React18.useRef(null); 3293 const cancelDismissOnEndTimeout = useTimeout(); 3294 const clearInsideReactTreeTimeout = useTimeout(); 3295 const clearInsideReactTree = useStableCallback(() => { 3296 clearInsideReactTreeTimeout.clear(); 3297 dataRef.current.insideReactTree = false; 3298 }); 3299 const hasBlockingChild = useStableCallback((bubbleKey) => { 3300 const nodeId = dataRef.current.floatingContext?.nodeId; 3301 const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : []; 3302 return children.some((child) => child.context?.open && !child.context.dataRef.current[bubbleKey]); 3303 }); 3304 const isEventWithinOwnElements = useStableCallback((event) => { 3305 return isEventTargetWithin(event, store2.select("floatingElement")) || isEventTargetWithin(event, store2.select("domReferenceElement")); 3306 }); 3307 const closeOnReferencePress = useStableCallback((event) => { 3308 if (!referencePress()) { 3309 return; 3310 } 3311 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent)); 3312 }); 3313 const closeOnEscapeKeyDown = useStableCallback((event) => { 3314 if (!open || !enabled || !escapeKey2 || event.key !== "Escape") { 3315 return; 3316 } 3317 if (isComposingRef.current) { 3318 return; 3319 } 3320 if (!escapeKeyBubbles && hasBlockingChild("__escapeKeyBubbles")) { 3321 return; 3322 } 3323 const native = isReactEvent(event) ? event.nativeEvent : event; 3324 const eventDetails = createChangeEventDetails(reason_parts_exports.escapeKey, native); 3325 store2.setOpen(false, eventDetails); 3326 if (!eventDetails.isCanceled) { 3327 event.preventDefault(); 3328 } 3329 if (!escapeKeyBubbles && !eventDetails.isPropagationAllowed) { 3330 event.stopPropagation(); 3331 } 3332 }); 3333 const markInsideReactTree = useStableCallback(() => { 3334 dataRef.current.insideReactTree = true; 3335 clearInsideReactTreeTimeout.start(0, clearInsideReactTree); 3336 }); 3337 const markPressStartedInsideReactTree = useStableCallback((event) => { 3338 if (!open || !enabled || event.button !== 0) { 3339 return; 3340 } 3341 const target = getTarget(event.nativeEvent); 3342 if (!contains(store2.select("floatingElement"), target)) { 3343 return; 3344 } 3345 if (!pressStartedInsideRef.current) { 3346 pressStartedInsideRef.current = true; 3347 pressStartPreventedRef.current = false; 3348 } 3349 }); 3350 const markInsidePressStartPrevented = useStableCallback((event) => { 3351 if (!open || !enabled) { 3352 return; 3353 } 3354 if (!(event.defaultPrevented || event.nativeEvent.defaultPrevented)) { 3355 return; 3356 } 3357 if (pressStartedInsideRef.current) { 3358 pressStartPreventedRef.current = true; 3359 } 3360 }); 3361 React18.useEffect(() => { 3362 if (!open || !enabled) { 3363 return void 0; 3364 } 3365 dataRef.current.__escapeKeyBubbles = escapeKeyBubbles; 3366 dataRef.current.__outsidePressBubbles = outsidePressBubbles; 3367 const compositionTimeout = new Timeout(); 3368 const preventedPressSuppressionTimeout = new Timeout(); 3369 function handleCompositionStart() { 3370 compositionTimeout.clear(); 3371 isComposingRef.current = true; 3372 } 3373 function handleCompositionEnd() { 3374 compositionTimeout.start( 3375 // 0ms or 1ms don't work in Safari. 5ms appears to consistently work. 3376 // Only apply to WebKit for the test to remain 0ms. 3377 parts_exports.engine.webkit ? 5 : 0, 3378 () => { 3379 isComposingRef.current = false; 3380 } 3381 ); 3382 } 3383 function suppressImmediateOutsideClickAfterPreventedStart() { 3384 suppressNextOutsideClickRef.current = true; 3385 preventedPressSuppressionTimeout.start(0, () => { 3386 suppressNextOutsideClickRef.current = false; 3387 }); 3388 } 3389 function resetPressStartState() { 3390 pressStartedInsideRef.current = false; 3391 pressStartPreventedRef.current = false; 3392 } 3393 function getOutsidePressEvent() { 3394 const type = currentPointerTypeRef.current; 3395 const computedType = type === "pen" || !type ? "mouse" : type; 3396 const outsidePressEventValue = getOutsidePressEventProp(); 3397 const resolved = typeof outsidePressEventValue === "function" ? outsidePressEventValue() : outsidePressEventValue; 3398 if (typeof resolved === "string") { 3399 return resolved; 3400 } 3401 return resolved[computedType]; 3402 } 3403 function shouldIgnoreEvent(event) { 3404 const computedOutsidePressEvent = getOutsidePressEvent(); 3405 return computedOutsidePressEvent === "intentional" && event.type !== "click" || computedOutsidePressEvent === "sloppy" && event.type === "click"; 3406 } 3407 function isEventWithinFloatingTree(event) { 3408 const nodeId = dataRef.current.floatingContext?.nodeId; 3409 const targetIsInsideChildren = tree && getNodeChildren(tree.nodesRef.current, nodeId).some((node) => isEventTargetWithin(event, node.context?.elements.floating)); 3410 return isEventWithinOwnElements(event) || targetIsInsideChildren; 3411 } 3412 function closeOnPressOutside(event) { 3413 if (shouldIgnoreEvent(event)) { 3414 if (event.type !== "click" && !isEventWithinOwnElements(event)) { 3415 preventedPressSuppressionTimeout.clear(); 3416 suppressNextOutsideClickRef.current = false; 3417 } 3418 clearInsideReactTree(); 3419 return; 3420 } 3421 if (dataRef.current.insideReactTree) { 3422 clearInsideReactTree(); 3423 return; 3424 } 3425 const target = getTarget(event); 3426 const inertSelector = `[$createAttribute("inert")}]`; 3427 const targetRoot = isElement(target) ? target.getRootNode() : null; 3428 const markers = Array.from((isShadowRoot(targetRoot) ? targetRoot : ownerDocument(store2.select("floatingElement"))).querySelectorAll(inertSelector)); 3429 const triggers = store2.context.triggerElements; 3430 if (target && (triggers.hasElement(target) || triggers.hasMatchingElement((trigger) => contains(trigger, target)))) { 3431 return; 3432 } 3433 let targetRootAncestor = isElement(target) ? target : null; 3434 while (targetRootAncestor && !isLastTraversableNode(targetRootAncestor)) { 3435 const nextParent = getParentNode(targetRootAncestor); 3436 if (isLastTraversableNode(nextParent) || !isElement(nextParent)) { 3437 break; 3438 } 3439 targetRootAncestor = nextParent; 3440 } 3441 if (markers.length && isElement(target) && !isRootElement(target) && // Clicked on a direct ancestor (e.g. FloatingOverlay). 3442 !contains(target, store2.select("floatingElement")) && // If the target root element contains none of the markers, then the 3443 // element was injected after the floating element rendered. 3444 markers.every((marker) => !contains(targetRootAncestor, marker))) { 3445 return; 3446 } 3447 if (isHTMLElement(target) && !("touches" in event)) { 3448 const lastTraversableNode = isLastTraversableNode(target); 3449 const style = getComputedStyle2(target); 3450 const scrollRe = /auto|scroll/; 3451 const isScrollableX = lastTraversableNode || scrollRe.test(style.overflowX); 3452 const isScrollableY = lastTraversableNode || scrollRe.test(style.overflowY); 3453 const canScrollX = isScrollableX && target.clientWidth > 0 && target.scrollWidth > target.clientWidth; 3454 const canScrollY = isScrollableY && target.clientHeight > 0 && target.scrollHeight > target.clientHeight; 3455 const isRTL2 = style.direction === "rtl"; 3456 const pressedVerticalScrollbar = canScrollY && (isRTL2 ? event.offsetX <= target.offsetWidth - target.clientWidth : event.offsetX > target.clientWidth); 3457 const pressedHorizontalScrollbar = canScrollX && event.offsetY > target.clientHeight; 3458 if (pressedVerticalScrollbar || pressedHorizontalScrollbar) { 3459 return; 3460 } 3461 } 3462 if (isEventWithinFloatingTree(event)) { 3463 return; 3464 } 3465 if (getOutsidePressEvent() === "intentional" && suppressNextOutsideClickRef.current) { 3466 preventedPressSuppressionTimeout.clear(); 3467 suppressNextOutsideClickRef.current = false; 3468 return; 3469 } 3470 if (typeof outsidePress2 === "function" && !outsidePress2(event)) { 3471 return; 3472 } 3473 if (hasBlockingChild("__outsidePressBubbles")) { 3474 return; 3475 } 3476 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.outsidePress, event)); 3477 clearInsideReactTree(); 3478 } 3479 function handlePointerDown(event) { 3480 if (getOutsidePressEvent() !== "sloppy" || event.pointerType === "touch" || !store2.select("open") || !enabled || isEventWithinOwnElements(event)) { 3481 return; 3482 } 3483 closeOnPressOutside(event); 3484 } 3485 function handleTouchStart(event) { 3486 if (getOutsidePressEvent() !== "sloppy" || !store2.select("open") || !enabled || isEventWithinOwnElements(event)) { 3487 return; 3488 } 3489 const touch = event.touches[0]; 3490 if (touch) { 3491 touchStateRef.current = { 3492 startTime: Date.now(), 3493 startX: touch.clientX, 3494 startY: touch.clientY, 3495 dismissOnTouchEnd: false, 3496 dismissOnMouseDown: true 3497 }; 3498 cancelDismissOnEndTimeout.start(1e3, () => { 3499 if (touchStateRef.current) { 3500 touchStateRef.current.dismissOnTouchEnd = false; 3501 touchStateRef.current.dismissOnMouseDown = false; 3502 } 3503 }); 3504 } 3505 } 3506 function addTargetEventListenerOnce(event, listener) { 3507 const target = getTarget(event); 3508 if (!target) { 3509 return; 3510 } 3511 const unsubscribe2 = addEventListener(target, event.type, () => { 3512 listener(event); 3513 unsubscribe2(); 3514 }); 3515 } 3516 function handleTouchStartCapture(event) { 3517 currentPointerTypeRef.current = "touch"; 3518 addTargetEventListenerOnce(event, handleTouchStart); 3519 } 3520 function closeOnPressOutsideCapture(event) { 3521 cancelDismissOnEndTimeout.clear(); 3522 if (event.type === "pointerdown") { 3523 currentPointerTypeRef.current = event.pointerType; 3524 } 3525 if (event.type === "mousedown" && touchStateRef.current && !touchStateRef.current.dismissOnMouseDown) { 3526 return; 3527 } 3528 addTargetEventListenerOnce(event, (targetEvent) => { 3529 if (targetEvent.type === "pointerdown") { 3530 handlePointerDown(targetEvent); 3531 } else { 3532 closeOnPressOutside(targetEvent); 3533 } 3534 }); 3535 } 3536 function handlePressEndCapture(event) { 3537 if (!pressStartedInsideRef.current) { 3538 return; 3539 } 3540 const pressStartedInsideDefaultPrevented = pressStartPreventedRef.current; 3541 resetPressStartState(); 3542 if (getOutsidePressEvent() !== "intentional") { 3543 return; 3544 } 3545 if (event.type === "pointercancel") { 3546 if (pressStartedInsideDefaultPrevented) { 3547 suppressImmediateOutsideClickAfterPreventedStart(); 3548 } 3549 return; 3550 } 3551 if (isEventWithinFloatingTree(event)) { 3552 return; 3553 } 3554 if (pressStartedInsideDefaultPrevented) { 3555 suppressImmediateOutsideClickAfterPreventedStart(); 3556 return; 3557 } 3558 if (typeof outsidePress2 === "function" && !outsidePress2(event)) { 3559 return; 3560 } 3561 preventedPressSuppressionTimeout.clear(); 3562 suppressNextOutsideClickRef.current = true; 3563 clearInsideReactTree(); 3564 } 3565 function handleTouchMove(event) { 3566 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) { 3567 return; 3568 } 3569 const touch = event.touches[0]; 3570 if (!touch) { 3571 return; 3572 } 3573 const deltaX = Math.abs(touch.clientX - touchStateRef.current.startX); 3574 const deltaY = Math.abs(touch.clientY - touchStateRef.current.startY); 3575 const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY); 3576 if (distance > 5) { 3577 touchStateRef.current.dismissOnTouchEnd = true; 3578 } 3579 if (distance > 10) { 3580 closeOnPressOutside(event); 3581 cancelDismissOnEndTimeout.clear(); 3582 touchStateRef.current = null; 3583 } 3584 } 3585 function handleTouchMoveCapture(event) { 3586 addTargetEventListenerOnce(event, handleTouchMove); 3587 } 3588 function handleTouchEnd(event) { 3589 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) { 3590 return; 3591 } 3592 if (touchStateRef.current.dismissOnTouchEnd) { 3593 closeOnPressOutside(event); 3594 } 3595 cancelDismissOnEndTimeout.clear(); 3596 touchStateRef.current = null; 3597 } 3598 function handleTouchEndCapture(event) { 3599 addTargetEventListenerOnce(event, handleTouchEnd); 3600 } 3601 const doc = ownerDocument(floatingElement); 3602 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))); 3603 return () => { 3604 unsubscribe(); 3605 compositionTimeout.clear(); 3606 preventedPressSuppressionTimeout.clear(); 3607 resetPressStartState(); 3608 suppressNextOutsideClickRef.current = false; 3609 }; 3610 }, [dataRef, floatingElement, escapeKey2, outsidePressEnabled, outsidePress2, open, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, clearInsideReactTree, getOutsidePressEventProp, hasBlockingChild, isEventWithinOwnElements, tree, store2, cancelDismissOnEndTimeout]); 3611 React18.useEffect(clearInsideReactTree, [outsidePress2, clearInsideReactTree]); 3612 const reference = React18.useMemo(() => ({ 3613 onKeyDown: closeOnEscapeKeyDown, 3614 onPointerDown: closeOnReferencePress, 3615 onClick: closeOnReferencePress 3616 }), [closeOnEscapeKeyDown, closeOnReferencePress]); 3617 const floating = React18.useMemo(() => ({ 3618 onKeyDown: closeOnEscapeKeyDown, 3619 // `onMouseDown` may be blocked if `event.preventDefault()` is called in 3620 // `onPointerDown`, such as with <NumberField.ScrubArea>. 3621 // See https://github.com/mui/base-ui/pull/3379 3622 onPointerDown: markInsidePressStartPrevented, 3623 onMouseDown: markInsidePressStartPrevented, 3624 onClickCapture: markInsideReactTree, 3625 onMouseDownCapture(event) { 3626 markInsideReactTree(); 3627 markPressStartedInsideReactTree(event); 3628 }, 3629 onPointerDownCapture(event) { 3630 markInsideReactTree(); 3631 markPressStartedInsideReactTree(event); 3632 }, 3633 onMouseUpCapture: markInsideReactTree, 3634 onTouchEndCapture: markInsideReactTree, 3635 onTouchMoveCapture: markInsideReactTree 3636 }), [closeOnEscapeKeyDown, markInsideReactTree, markPressStartedInsideReactTree, markInsidePressStartPrevented]); 3637 return React18.useMemo(() => enabled ? { 3638 reference, 3639 floating, 3640 trigger: reference 3641 } : {}, [enabled, reference, floating]); 3642 } 3643 3644 // node_modules/@base-ui/react/floating-ui-react/hooks/useFloating.mjs 3645 var React25 = __toESM(require_react(), 1); 3646 3647 // node_modules/@floating-ui/core/dist/floating-ui.core.mjs 3648 function computeCoordsFromPlacement(_ref, placement, rtl) { 3649 let { 3650 reference, 3651 floating 3652 } = _ref; 3653 const sideAxis = getSideAxis(placement); 3654 const alignmentAxis = getAlignmentAxis(placement); 3655 const alignLength = getAxisLength(alignmentAxis); 3656 const side = getSide(placement); 3657 const isVertical = sideAxis === "y"; 3658 const commonX = reference.x + reference.width / 2 - floating.width / 2; 3659 const commonY = reference.y + reference.height / 2 - floating.height / 2; 3660 const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2; 3661 let coords; 3662 switch (side) { 3663 case "top": 3664 coords = { 3665 x: commonX, 3666 y: reference.y - floating.height 3667 }; 3668 break; 3669 case "bottom": 3670 coords = { 3671 x: commonX, 3672 y: reference.y + reference.height 3673 }; 3674 break; 3675 case "right": 3676 coords = { 3677 x: reference.x + reference.width, 3678 y: commonY 3679 }; 3680 break; 3681 case "left": 3682 coords = { 3683 x: reference.x - floating.width, 3684 y: commonY 3685 }; 3686 break; 3687 default: 3688 coords = { 3689 x: reference.x, 3690 y: reference.y 3691 }; 3692 } 3693 switch (getAlignment(placement)) { 3694 case "start": 3695 coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1); 3696 break; 3697 case "end": 3698 coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1); 3699 break; 3700 } 3701 return coords; 3702 } 3703 async function detectOverflow(state, options) { 3704 var _await$platform$isEle; 3705 if (options === void 0) { 3706 options = {}; 3707 } 3708 const { 3709 x, 3710 y, 3711 platform: platform3, 3712 rects, 3713 elements, 3714 strategy 3715 } = state; 3716 const { 3717 boundary = "clippingAncestors", 3718 rootBoundary = "viewport", 3719 elementContext = "floating", 3720 altBoundary = false, 3721 padding = 0 3722 } = evaluate(options, state); 3723 const paddingObject = getPaddingObject(padding); 3724 const altContext = elementContext === "floating" ? "reference" : "floating"; 3725 const element = elements[altBoundary ? altContext : elementContext]; 3726 const clippingClientRect = rectToClientRect(await platform3.getClippingRect({ 3727 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)), 3728 boundary, 3729 rootBoundary, 3730 strategy 3731 })); 3732 const rect = elementContext === "floating" ? { 3733 x, 3734 y, 3735 width: rects.floating.width, 3736 height: rects.floating.height 3737 } : rects.reference; 3738 const offsetParent = await (platform3.getOffsetParent == null ? void 0 : platform3.getOffsetParent(elements.floating)); 3739 const offsetScale = await (platform3.isElement == null ? void 0 : platform3.isElement(offsetParent)) ? await (platform3.getScale == null ? void 0 : platform3.getScale(offsetParent)) || { 3740 x: 1, 3741 y: 1 3742 } : { 3743 x: 1, 3744 y: 1 3745 }; 3746 const elementClientRect = rectToClientRect(platform3.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform3.convertOffsetParentRelativeRectToViewportRelativeRect({ 3747 elements, 3748 rect, 3749 offsetParent, 3750 strategy 3751 }) : rect); 3752 return { 3753 top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y, 3754 bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y, 3755 left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x, 3756 right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x 3757 }; 3758 } 3759 var MAX_RESET_COUNT = 50; 3760 var computePosition = async (reference, floating, config) => { 3761 const { 3762 placement = "bottom", 3763 strategy = "absolute", 3764 middleware = [], 3765 platform: platform3 3766 } = config; 3767 const platformWithDetectOverflow = platform3.detectOverflow ? platform3 : { 3768 ...platform3, 3769 detectOverflow 3770 }; 3771 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(floating)); 3772 let rects = await platform3.getElementRects({ 3773 reference, 3774 floating, 3775 strategy 3776 }); 3777 let { 3778 x, 3779 y 3780 } = computeCoordsFromPlacement(rects, placement, rtl); 3781 let statefulPlacement = placement; 3782 let resetCount = 0; 3783 const middlewareData = {}; 3784 for (let i = 0; i < middleware.length; i++) { 3785 const currentMiddleware = middleware[i]; 3786 if (!currentMiddleware) { 3787 continue; 3788 } 3789 const { 3790 name, 3791 fn 3792 } = currentMiddleware; 3793 const { 3794 x: nextX, 3795 y: nextY, 3796 data, 3797 reset 3798 } = await fn({ 3799 x, 3800 y, 3801 initialPlacement: placement, 3802 placement: statefulPlacement, 3803 strategy, 3804 middlewareData, 3805 rects, 3806 platform: platformWithDetectOverflow, 3807 elements: { 3808 reference, 3809 floating 3810 } 3811 }); 3812 x = nextX != null ? nextX : x; 3813 y = nextY != null ? nextY : y; 3814 middlewareData[name] = { 3815 ...middlewareData[name], 3816 ...data 3817 }; 3818 if (reset && resetCount < MAX_RESET_COUNT) { 3819 resetCount++; 3820 if (typeof reset === "object") { 3821 if (reset.placement) { 3822 statefulPlacement = reset.placement; 3823 } 3824 if (reset.rects) { 3825 rects = reset.rects === true ? await platform3.getElementRects({ 3826 reference, 3827 floating, 3828 strategy 3829 }) : reset.rects; 3830 } 3831 ({ 3832 x, 3833 y 3834 } = computeCoordsFromPlacement(rects, statefulPlacement, rtl)); 3835 } 3836 i = -1; 3837 } 3838 } 3839 return { 3840 x, 3841 y, 3842 placement: statefulPlacement, 3843 strategy, 3844 middlewareData 3845 }; 3846 }; 3847 var flip = function(options) { 3848 if (options === void 0) { 3849 options = {}; 3850 } 3851 return { 3852 name: "flip", 3853 options, 3854 async fn(state) { 3855 var _middlewareData$arrow, _middlewareData$flip; 3856 const { 3857 placement, 3858 middlewareData, 3859 rects, 3860 initialPlacement, 3861 platform: platform3, 3862 elements 3863 } = state; 3864 const { 3865 mainAxis: checkMainAxis = true, 3866 crossAxis: checkCrossAxis = true, 3867 fallbackPlacements: specifiedFallbackPlacements, 3868 fallbackStrategy = "bestFit", 3869 fallbackAxisSideDirection = "none", 3870 flipAlignment = true, 3871 ...detectOverflowOptions 3872 } = evaluate(options, state); 3873 if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) { 3874 return {}; 3875 } 3876 const side = getSide(placement); 3877 const initialSideAxis = getSideAxis(initialPlacement); 3878 const isBasePlacement = getSide(initialPlacement) === initialPlacement; 3879 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating)); 3880 const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement)); 3881 const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none"; 3882 if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) { 3883 fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl)); 3884 } 3885 const placements2 = [initialPlacement, ...fallbackPlacements]; 3886 const overflow = await platform3.detectOverflow(state, detectOverflowOptions); 3887 const overflows = []; 3888 let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || []; 3889 if (checkMainAxis) { 3890 overflows.push(overflow[side]); 3891 } 3892 if (checkCrossAxis) { 3893 const sides2 = getAlignmentSides(placement, rects, rtl); 3894 overflows.push(overflow[sides2[0]], overflow[sides2[1]]); 3895 } 3896 overflowsData = [...overflowsData, { 3897 placement, 3898 overflows 3899 }]; 3900 if (!overflows.every((side2) => side2 <= 0)) { 3901 var _middlewareData$flip2, _overflowsData$filter; 3902 const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1; 3903 const nextPlacement = placements2[nextIndex]; 3904 if (nextPlacement) { 3905 const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false; 3906 if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis 3907 // overflows the main axis. 3908 overflowsData.every((d) => getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) { 3909 return { 3910 data: { 3911 index: nextIndex, 3912 overflows: overflowsData 3913 }, 3914 reset: { 3915 placement: nextPlacement 3916 } 3917 }; 3918 } 3919 } 3920 let resetPlacement = (_overflowsData$filter = overflowsData.filter((d) => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement; 3921 if (!resetPlacement) { 3922 switch (fallbackStrategy) { 3923 case "bestFit": { 3924 var _overflowsData$filter2; 3925 const placement2 = (_overflowsData$filter2 = overflowsData.filter((d) => { 3926 if (hasFallbackAxisSideDirection) { 3927 const currentSideAxis = getSideAxis(d.placement); 3928 return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal 3929 // reading directions favoring greater width. 3930 currentSideAxis === "y"; 3931 } 3932 return true; 3933 }).map((d) => [d.placement, d.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0]; 3934 if (placement2) { 3935 resetPlacement = placement2; 3936 } 3937 break; 3938 } 3939 case "initialPlacement": 3940 resetPlacement = initialPlacement; 3941 break; 3942 } 3943 } 3944 if (placement !== resetPlacement) { 3945 return { 3946 reset: { 3947 placement: resetPlacement 3948 } 3949 }; 3950 } 3951 } 3952 return {}; 3953 } 3954 }; 3955 }; 3956 function getSideOffsets(overflow, rect) { 3957 return { 3958 top: overflow.top - rect.height, 3959 right: overflow.right - rect.width, 3960 bottom: overflow.bottom - rect.height, 3961 left: overflow.left - rect.width 3962 }; 3963 } 3964 function isAnySideFullyClipped(overflow) { 3965 return sides.some((side) => overflow[side] >= 0); 3966 } 3967 var hide = function(options) { 3968 if (options === void 0) { 3969 options = {}; 3970 } 3971 return { 3972 name: "hide", 3973 options, 3974 async fn(state) { 3975 const { 3976 rects, 3977 platform: platform3 3978 } = state; 3979 const { 3980 strategy = "referenceHidden", 3981 ...detectOverflowOptions 3982 } = evaluate(options, state); 3983 switch (strategy) { 3984 case "referenceHidden": { 3985 const overflow = await platform3.detectOverflow(state, { 3986 ...detectOverflowOptions, 3987 elementContext: "reference" 3988 }); 3989 const offsets = getSideOffsets(overflow, rects.reference); 3990 return { 3991 data: { 3992 referenceHiddenOffsets: offsets, 3993 referenceHidden: isAnySideFullyClipped(offsets) 3994 } 3995 }; 3996 } 3997 case "escaped": { 3998 const overflow = await platform3.detectOverflow(state, { 3999 ...detectOverflowOptions, 4000 altBoundary: true 4001 }); 4002 const offsets = getSideOffsets(overflow, rects.floating); 4003 return { 4004 data: { 4005 escapedOffsets: offsets, 4006 escaped: isAnySideFullyClipped(offsets) 4007 } 4008 }; 4009 } 4010 default: { 4011 return {}; 4012 } 4013 } 4014 } 4015 }; 4016 }; 4017 var originSides = /* @__PURE__ */ new Set(["left", "top"]); 4018 async function convertValueToCoords(state, options) { 4019 const { 4020 placement, 4021 platform: platform3, 4022 elements 4023 } = state; 4024 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating)); 4025 const side = getSide(placement); 4026 const alignment = getAlignment(placement); 4027 const isVertical = getSideAxis(placement) === "y"; 4028 const mainAxisMulti = originSides.has(side) ? -1 : 1; 4029 const crossAxisMulti = rtl && isVertical ? -1 : 1; 4030 const rawValue = evaluate(options, state); 4031 let { 4032 mainAxis, 4033 crossAxis, 4034 alignmentAxis 4035 } = typeof rawValue === "number" ? { 4036 mainAxis: rawValue, 4037 crossAxis: 0, 4038 alignmentAxis: null 4039 } : { 4040 mainAxis: rawValue.mainAxis || 0, 4041 crossAxis: rawValue.crossAxis || 0, 4042 alignmentAxis: rawValue.alignmentAxis 4043 }; 4044 if (alignment && typeof alignmentAxis === "number") { 4045 crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis; 4046 } 4047 return isVertical ? { 4048 x: crossAxis * crossAxisMulti, 4049 y: mainAxis * mainAxisMulti 4050 } : { 4051 x: mainAxis * mainAxisMulti, 4052 y: crossAxis * crossAxisMulti 4053 }; 4054 } 4055 var offset = function(options) { 4056 if (options === void 0) { 4057 options = 0; 4058 } 4059 return { 4060 name: "offset", 4061 options, 4062 async fn(state) { 4063 var _middlewareData$offse, _middlewareData$arrow; 4064 const { 4065 x, 4066 y, 4067 placement, 4068 middlewareData 4069 } = state; 4070 const diffCoords = await convertValueToCoords(state, options); 4071 if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) { 4072 return {}; 4073 } 4074 return { 4075 x: x + diffCoords.x, 4076 y: y + diffCoords.y, 4077 data: { 4078 ...diffCoords, 4079 placement 4080 } 4081 }; 4082 } 4083 }; 4084 }; 4085 var shift = function(options) { 4086 if (options === void 0) { 4087 options = {}; 4088 } 4089 return { 4090 name: "shift", 4091 options, 4092 async fn(state) { 4093 const { 4094 x, 4095 y, 4096 placement, 4097 platform: platform3 4098 } = state; 4099 const { 4100 mainAxis: checkMainAxis = true, 4101 crossAxis: checkCrossAxis = false, 4102 limiter = { 4103 fn: (_ref) => { 4104 let { 4105 x: x2, 4106 y: y2 4107 } = _ref; 4108 return { 4109 x: x2, 4110 y: y2 4111 }; 4112 } 4113 }, 4114 ...detectOverflowOptions 4115 } = evaluate(options, state); 4116 const coords = { 4117 x, 4118 y 4119 }; 4120 const overflow = await platform3.detectOverflow(state, detectOverflowOptions); 4121 const crossAxis = getSideAxis(getSide(placement)); 4122 const mainAxis = getOppositeAxis(crossAxis); 4123 let mainAxisCoord = coords[mainAxis]; 4124 let crossAxisCoord = coords[crossAxis]; 4125 if (checkMainAxis) { 4126 const minSide = mainAxis === "y" ? "top" : "left"; 4127 const maxSide = mainAxis === "y" ? "bottom" : "right"; 4128 const min2 = mainAxisCoord + overflow[minSide]; 4129 const max2 = mainAxisCoord - overflow[maxSide]; 4130 mainAxisCoord = clamp(min2, mainAxisCoord, max2); 4131 } 4132 if (checkCrossAxis) { 4133 const minSide = crossAxis === "y" ? "top" : "left"; 4134 const maxSide = crossAxis === "y" ? "bottom" : "right"; 4135 const min2 = crossAxisCoord + overflow[minSide]; 4136 const max2 = crossAxisCoord - overflow[maxSide]; 4137 crossAxisCoord = clamp(min2, crossAxisCoord, max2); 4138 } 4139 const limitedCoords = limiter.fn({ 4140 ...state, 4141 [mainAxis]: mainAxisCoord, 4142 [crossAxis]: crossAxisCoord 4143 }); 4144 return { 4145 ...limitedCoords, 4146 data: { 4147 x: limitedCoords.x - x, 4148 y: limitedCoords.y - y, 4149 enabled: { 4150 [mainAxis]: checkMainAxis, 4151 [crossAxis]: checkCrossAxis 4152 } 4153 } 4154 }; 4155 } 4156 }; 4157 }; 4158 var limitShift = function(options) { 4159 if (options === void 0) { 4160 options = {}; 4161 } 4162 return { 4163 options, 4164 fn(state) { 4165 const { 4166 x, 4167 y, 4168 placement, 4169 rects, 4170 middlewareData 4171 } = state; 4172 const { 4173 offset: offset4 = 0, 4174 mainAxis: checkMainAxis = true, 4175 crossAxis: checkCrossAxis = true 4176 } = evaluate(options, state); 4177 const coords = { 4178 x, 4179 y 4180 }; 4181 const crossAxis = getSideAxis(placement); 4182 const mainAxis = getOppositeAxis(crossAxis); 4183 let mainAxisCoord = coords[mainAxis]; 4184 let crossAxisCoord = coords[crossAxis]; 4185 const rawOffset = evaluate(offset4, state); 4186 const computedOffset = typeof rawOffset === "number" ? { 4187 mainAxis: rawOffset, 4188 crossAxis: 0 4189 } : { 4190 mainAxis: 0, 4191 crossAxis: 0, 4192 ...rawOffset 4193 }; 4194 if (checkMainAxis) { 4195 const len = mainAxis === "y" ? "height" : "width"; 4196 const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis; 4197 const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis; 4198 if (mainAxisCoord < limitMin) { 4199 mainAxisCoord = limitMin; 4200 } else if (mainAxisCoord > limitMax) { 4201 mainAxisCoord = limitMax; 4202 } 4203 } 4204 if (checkCrossAxis) { 4205 var _middlewareData$offse, _middlewareData$offse2; 4206 const len = mainAxis === "y" ? "width" : "height"; 4207 const isOriginSide = originSides.has(getSide(placement)); 4208 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); 4209 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); 4210 if (crossAxisCoord < limitMin) { 4211 crossAxisCoord = limitMin; 4212 } else if (crossAxisCoord > limitMax) { 4213 crossAxisCoord = limitMax; 4214 } 4215 } 4216 return { 4217 [mainAxis]: mainAxisCoord, 4218 [crossAxis]: crossAxisCoord 4219 }; 4220 } 4221 }; 4222 }; 4223 var size = function(options) { 4224 if (options === void 0) { 4225 options = {}; 4226 } 4227 return { 4228 name: "size", 4229 options, 4230 async fn(state) { 4231 var _state$middlewareData, _state$middlewareData2; 4232 const { 4233 placement, 4234 rects, 4235 platform: platform3, 4236 elements 4237 } = state; 4238 const { 4239 apply = () => { 4240 }, 4241 ...detectOverflowOptions 4242 } = evaluate(options, state); 4243 const overflow = await platform3.detectOverflow(state, detectOverflowOptions); 4244 const side = getSide(placement); 4245 const alignment = getAlignment(placement); 4246 const isYAxis = getSideAxis(placement) === "y"; 4247 const { 4248 width, 4249 height 4250 } = rects.floating; 4251 let heightSide; 4252 let widthSide; 4253 if (side === "top" || side === "bottom") { 4254 heightSide = side; 4255 widthSide = alignment === (await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right"; 4256 } else { 4257 widthSide = side; 4258 heightSide = alignment === "end" ? "top" : "bottom"; 4259 } 4260 const maximumClippingHeight = height - overflow.top - overflow.bottom; 4261 const maximumClippingWidth = width - overflow.left - overflow.right; 4262 const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight); 4263 const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth); 4264 const noShift = !state.middlewareData.shift; 4265 let availableHeight = overflowAvailableHeight; 4266 let availableWidth = overflowAvailableWidth; 4267 if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) { 4268 availableWidth = maximumClippingWidth; 4269 } 4270 if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) { 4271 availableHeight = maximumClippingHeight; 4272 } 4273 if (noShift && !alignment) { 4274 const xMin = max(overflow.left, 0); 4275 const xMax = max(overflow.right, 0); 4276 const yMin = max(overflow.top, 0); 4277 const yMax = max(overflow.bottom, 0); 4278 if (isYAxis) { 4279 availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right)); 4280 } else { 4281 availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom)); 4282 } 4283 } 4284 await apply({ 4285 ...state, 4286 availableWidth, 4287 availableHeight 4288 }); 4289 const nextDimensions = await platform3.getDimensions(elements.floating); 4290 if (width !== nextDimensions.width || height !== nextDimensions.height) { 4291 return { 4292 reset: { 4293 rects: true 4294 } 4295 }; 4296 } 4297 return {}; 4298 } 4299 }; 4300 }; 4301 4302 // node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs 4303 function getCssDimensions(element) { 4304 const css = getComputedStyle2(element); 4305 let width = parseFloat(css.width) || 0; 4306 let height = parseFloat(css.height) || 0; 4307 const hasOffset = isHTMLElement(element); 4308 const offsetWidth = hasOffset ? element.offsetWidth : width; 4309 const offsetHeight = hasOffset ? element.offsetHeight : height; 4310 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight; 4311 if (shouldFallback) { 4312 width = offsetWidth; 4313 height = offsetHeight; 4314 } 4315 return { 4316 width, 4317 height, 4318 $: shouldFallback 4319 }; 4320 } 4321 function unwrapElement(element) { 4322 return !isElement(element) ? element.contextElement : element; 4323 } 4324 function getScale(element) { 4325 const domElement = unwrapElement(element); 4326 if (!isHTMLElement(domElement)) { 4327 return createCoords(1); 4328 } 4329 const rect = domElement.getBoundingClientRect(); 4330 const { 4331 width, 4332 height, 4333 $ 4334 } = getCssDimensions(domElement); 4335 let x = ($ ? round(rect.width) : rect.width) / width; 4336 let y = ($ ? round(rect.height) : rect.height) / height; 4337 if (!x || !Number.isFinite(x)) { 4338 x = 1; 4339 } 4340 if (!y || !Number.isFinite(y)) { 4341 y = 1; 4342 } 4343 return { 4344 x, 4345 y 4346 }; 4347 } 4348 var noOffsets = /* @__PURE__ */ createCoords(0); 4349 function getVisualOffsets(element) { 4350 const win = getWindow(element); 4351 if (!isWebKit() || !win.visualViewport) { 4352 return noOffsets; 4353 } 4354 return { 4355 x: win.visualViewport.offsetLeft, 4356 y: win.visualViewport.offsetTop 4357 }; 4358 } 4359 function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) { 4360 if (isFixed === void 0) { 4361 isFixed = false; 4362 } 4363 if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) { 4364 return false; 4365 } 4366 return isFixed; 4367 } 4368 function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) { 4369 if (includeScale === void 0) { 4370 includeScale = false; 4371 } 4372 if (isFixedStrategy === void 0) { 4373 isFixedStrategy = false; 4374 } 4375 const clientRect = element.getBoundingClientRect(); 4376 const domElement = unwrapElement(element); 4377 let scale = createCoords(1); 4378 if (includeScale) { 4379 if (offsetParent) { 4380 if (isElement(offsetParent)) { 4381 scale = getScale(offsetParent); 4382 } 4383 } else { 4384 scale = getScale(element); 4385 } 4386 } 4387 const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0); 4388 let x = (clientRect.left + visualOffsets.x) / scale.x; 4389 let y = (clientRect.top + visualOffsets.y) / scale.y; 4390 let width = clientRect.width / scale.x; 4391 let height = clientRect.height / scale.y; 4392 if (domElement) { 4393 const win = getWindow(domElement); 4394 const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent; 4395 let currentWin = win; 4396 let currentIFrame = getFrameElement(currentWin); 4397 while (currentIFrame && offsetParent && offsetWin !== currentWin) { 4398 const iframeScale = getScale(currentIFrame); 4399 const iframeRect = currentIFrame.getBoundingClientRect(); 4400 const css = getComputedStyle2(currentIFrame); 4401 const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x; 4402 const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y; 4403 x *= iframeScale.x; 4404 y *= iframeScale.y; 4405 width *= iframeScale.x; 4406 height *= iframeScale.y; 4407 x += left; 4408 y += top; 4409 currentWin = getWindow(currentIFrame); 4410 currentIFrame = getFrameElement(currentWin); 4411 } 4412 } 4413 return rectToClientRect({ 4414 width, 4415 height, 4416 x, 4417 y 4418 }); 4419 } 4420 function getWindowScrollBarX(element, rect) { 4421 const leftScroll = getNodeScroll(element).scrollLeft; 4422 if (!rect) { 4423 return getBoundingClientRect(getDocumentElement(element)).left + leftScroll; 4424 } 4425 return rect.left + leftScroll; 4426 } 4427 function getHTMLOffset(documentElement, scroll) { 4428 const htmlRect = documentElement.getBoundingClientRect(); 4429 const x = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect); 4430 const y = htmlRect.top + scroll.scrollTop; 4431 return { 4432 x, 4433 y 4434 }; 4435 } 4436 function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) { 4437 let { 4438 elements, 4439 rect, 4440 offsetParent, 4441 strategy 4442 } = _ref; 4443 const isFixed = strategy === "fixed"; 4444 const documentElement = getDocumentElement(offsetParent); 4445 const topLayer = elements ? isTopLayer(elements.floating) : false; 4446 if (offsetParent === documentElement || topLayer && isFixed) { 4447 return rect; 4448 } 4449 let scroll = { 4450 scrollLeft: 0, 4451 scrollTop: 0 4452 }; 4453 let scale = createCoords(1); 4454 const offsets = createCoords(0); 4455 const isOffsetParentAnElement = isHTMLElement(offsetParent); 4456 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) { 4457 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) { 4458 scroll = getNodeScroll(offsetParent); 4459 } 4460 if (isOffsetParentAnElement) { 4461 const offsetRect = getBoundingClientRect(offsetParent); 4462 scale = getScale(offsetParent); 4463 offsets.x = offsetRect.x + offsetParent.clientLeft; 4464 offsets.y = offsetRect.y + offsetParent.clientTop; 4465 } 4466 } 4467 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0); 4468 return { 4469 width: rect.width * scale.x, 4470 height: rect.height * scale.y, 4471 x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x, 4472 y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y 4473 }; 4474 } 4475 function getClientRects(element) { 4476 return Array.from(element.getClientRects()); 4477 } 4478 function getDocumentRect(element) { 4479 const html = getDocumentElement(element); 4480 const scroll = getNodeScroll(element); 4481 const body = element.ownerDocument.body; 4482 const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth); 4483 const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight); 4484 let x = -scroll.scrollLeft + getWindowScrollBarX(element); 4485 const y = -scroll.scrollTop; 4486 if (getComputedStyle2(body).direction === "rtl") { 4487 x += max(html.clientWidth, body.clientWidth) - width; 4488 } 4489 return { 4490 width, 4491 height, 4492 x, 4493 y 4494 }; 4495 } 4496 var SCROLLBAR_MAX = 25; 4497 function getViewportRect(element, strategy) { 4498 const win = getWindow(element); 4499 const html = getDocumentElement(element); 4500 const visualViewport = win.visualViewport; 4501 let width = html.clientWidth; 4502 let height = html.clientHeight; 4503 let x = 0; 4504 let y = 0; 4505 if (visualViewport) { 4506 width = visualViewport.width; 4507 height = visualViewport.height; 4508 const visualViewportBased = isWebKit(); 4509 if (!visualViewportBased || visualViewportBased && strategy === "fixed") { 4510 x = visualViewport.offsetLeft; 4511 y = visualViewport.offsetTop; 4512 } 4513 } 4514 const windowScrollbarX = getWindowScrollBarX(html); 4515 if (windowScrollbarX <= 0) { 4516 const doc = html.ownerDocument; 4517 const body = doc.body; 4518 const bodyStyles = getComputedStyle(body); 4519 const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0; 4520 const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline); 4521 if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) { 4522 width -= clippingStableScrollbarWidth; 4523 } 4524 } else if (windowScrollbarX <= SCROLLBAR_MAX) { 4525 width += windowScrollbarX; 4526 } 4527 return { 4528 width, 4529 height, 4530 x, 4531 y 4532 }; 4533 } 4534 function getInnerBoundingClientRect(element, strategy) { 4535 const clientRect = getBoundingClientRect(element, true, strategy === "fixed"); 4536 const top = clientRect.top + element.clientTop; 4537 const left = clientRect.left + element.clientLeft; 4538 const scale = isHTMLElement(element) ? getScale(element) : createCoords(1); 4539 const width = element.clientWidth * scale.x; 4540 const height = element.clientHeight * scale.y; 4541 const x = left * scale.x; 4542 const y = top * scale.y; 4543 return { 4544 width, 4545 height, 4546 x, 4547 y 4548 }; 4549 } 4550 function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) { 4551 let rect; 4552 if (clippingAncestor === "viewport") { 4553 rect = getViewportRect(element, strategy); 4554 } else if (clippingAncestor === "document") { 4555 rect = getDocumentRect(getDocumentElement(element)); 4556 } else if (isElement(clippingAncestor)) { 4557 rect = getInnerBoundingClientRect(clippingAncestor, strategy); 4558 } else { 4559 const visualOffsets = getVisualOffsets(element); 4560 rect = { 4561 x: clippingAncestor.x - visualOffsets.x, 4562 y: clippingAncestor.y - visualOffsets.y, 4563 width: clippingAncestor.width, 4564 height: clippingAncestor.height 4565 }; 4566 } 4567 return rectToClientRect(rect); 4568 } 4569 function hasFixedPositionAncestor(element, stopNode) { 4570 const parentNode = getParentNode(element); 4571 if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) { 4572 return false; 4573 } 4574 return getComputedStyle2(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode); 4575 } 4576 function getClippingElementAncestors(element, cache) { 4577 const cachedResult = cache.get(element); 4578 if (cachedResult) { 4579 return cachedResult; 4580 } 4581 let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body"); 4582 let currentContainingBlockComputedStyle = null; 4583 const elementIsFixed = getComputedStyle2(element).position === "fixed"; 4584 let currentNode = elementIsFixed ? getParentNode(element) : element; 4585 while (isElement(currentNode) && !isLastTraversableNode(currentNode)) { 4586 const computedStyle = getComputedStyle2(currentNode); 4587 const currentNodeIsContaining = isContainingBlock(currentNode); 4588 if (!currentNodeIsContaining && computedStyle.position === "fixed") { 4589 currentContainingBlockComputedStyle = null; 4590 } 4591 const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && (currentContainingBlockComputedStyle.position === "absolute" || currentContainingBlockComputedStyle.position === "fixed") || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode); 4592 if (shouldDropCurrentNode) { 4593 result = result.filter((ancestor) => ancestor !== currentNode); 4594 } else { 4595 currentContainingBlockComputedStyle = computedStyle; 4596 } 4597 currentNode = getParentNode(currentNode); 4598 } 4599 cache.set(element, result); 4600 return result; 4601 } 4602 function getClippingRect(_ref) { 4603 let { 4604 element, 4605 boundary, 4606 rootBoundary, 4607 strategy 4608 } = _ref; 4609 const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary); 4610 const clippingAncestors = [...elementClippingAncestors, rootBoundary]; 4611 const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy); 4612 let top = firstRect.top; 4613 let right = firstRect.right; 4614 let bottom = firstRect.bottom; 4615 let left = firstRect.left; 4616 for (let i = 1; i < clippingAncestors.length; i++) { 4617 const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i], strategy); 4618 top = max(rect.top, top); 4619 right = min(rect.right, right); 4620 bottom = min(rect.bottom, bottom); 4621 left = max(rect.left, left); 4622 } 4623 return { 4624 width: right - left, 4625 height: bottom - top, 4626 x: left, 4627 y: top 4628 }; 4629 } 4630 function getDimensions(element) { 4631 const { 4632 width, 4633 height 4634 } = getCssDimensions(element); 4635 return { 4636 width, 4637 height 4638 }; 4639 } 4640 function getRectRelativeToOffsetParent(element, offsetParent, strategy) { 4641 const isOffsetParentAnElement = isHTMLElement(offsetParent); 4642 const documentElement = getDocumentElement(offsetParent); 4643 const isFixed = strategy === "fixed"; 4644 const rect = getBoundingClientRect(element, true, isFixed, offsetParent); 4645 let scroll = { 4646 scrollLeft: 0, 4647 scrollTop: 0 4648 }; 4649 const offsets = createCoords(0); 4650 function setLeftRTLScrollbarOffset() { 4651 offsets.x = getWindowScrollBarX(documentElement); 4652 } 4653 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) { 4654 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) { 4655 scroll = getNodeScroll(offsetParent); 4656 } 4657 if (isOffsetParentAnElement) { 4658 const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent); 4659 offsets.x = offsetRect.x + offsetParent.clientLeft; 4660 offsets.y = offsetRect.y + offsetParent.clientTop; 4661 } else if (documentElement) { 4662 setLeftRTLScrollbarOffset(); 4663 } 4664 } 4665 if (isFixed && !isOffsetParentAnElement && documentElement) { 4666 setLeftRTLScrollbarOffset(); 4667 } 4668 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0); 4669 const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x; 4670 const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y; 4671 return { 4672 x, 4673 y, 4674 width: rect.width, 4675 height: rect.height 4676 }; 4677 } 4678 function isStaticPositioned(element) { 4679 return getComputedStyle2(element).position === "static"; 4680 } 4681 function getTrueOffsetParent(element, polyfill) { 4682 if (!isHTMLElement(element) || getComputedStyle2(element).position === "fixed") { 4683 return null; 4684 } 4685 if (polyfill) { 4686 return polyfill(element); 4687 } 4688 let rawOffsetParent = element.offsetParent; 4689 if (getDocumentElement(element) === rawOffsetParent) { 4690 rawOffsetParent = rawOffsetParent.ownerDocument.body; 4691 } 4692 return rawOffsetParent; 4693 } 4694 function getOffsetParent(element, polyfill) { 4695 const win = getWindow(element); 4696 if (isTopLayer(element)) { 4697 return win; 4698 } 4699 if (!isHTMLElement(element)) { 4700 let svgOffsetParent = getParentNode(element); 4701 while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) { 4702 if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) { 4703 return svgOffsetParent; 4704 } 4705 svgOffsetParent = getParentNode(svgOffsetParent); 4706 } 4707 return win; 4708 } 4709 let offsetParent = getTrueOffsetParent(element, polyfill); 4710 while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) { 4711 offsetParent = getTrueOffsetParent(offsetParent, polyfill); 4712 } 4713 if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) { 4714 return win; 4715 } 4716 return offsetParent || getContainingBlock(element) || win; 4717 } 4718 var getElementRects = async function(data) { 4719 const getOffsetParentFn = this.getOffsetParent || getOffsetParent; 4720 const getDimensionsFn = this.getDimensions; 4721 const floatingDimensions = await getDimensionsFn(data.floating); 4722 return { 4723 reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy), 4724 floating: { 4725 x: 0, 4726 y: 0, 4727 width: floatingDimensions.width, 4728 height: floatingDimensions.height 4729 } 4730 }; 4731 }; 4732 function isRTL(element) { 4733 return getComputedStyle2(element).direction === "rtl"; 4734 } 4735 var platform2 = { 4736 convertOffsetParentRelativeRectToViewportRelativeRect, 4737 getDocumentElement, 4738 getClippingRect, 4739 getOffsetParent, 4740 getElementRects, 4741 getClientRects, 4742 getDimensions, 4743 getScale, 4744 isElement, 4745 isRTL 4746 }; 4747 function rectsAreEqual(a, b) { 4748 return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height; 4749 } 4750 function observeMove(element, onMove) { 4751 let io = null; 4752 let timeoutId; 4753 const root = getDocumentElement(element); 4754 function cleanup() { 4755 var _io; 4756 clearTimeout(timeoutId); 4757 (_io = io) == null || _io.disconnect(); 4758 io = null; 4759 } 4760 function refresh(skip, threshold) { 4761 if (skip === void 0) { 4762 skip = false; 4763 } 4764 if (threshold === void 0) { 4765 threshold = 1; 4766 } 4767 cleanup(); 4768 const elementRectForRootMargin = element.getBoundingClientRect(); 4769 const { 4770 left, 4771 top, 4772 width, 4773 height 4774 } = elementRectForRootMargin; 4775 if (!skip) { 4776 onMove(); 4777 } 4778 if (!width || !height) { 4779 return; 4780 } 4781 const insetTop = floor(top); 4782 const insetRight = floor(root.clientWidth - (left + width)); 4783 const insetBottom = floor(root.clientHeight - (top + height)); 4784 const insetLeft = floor(left); 4785 const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px"; 4786 const options = { 4787 rootMargin, 4788 threshold: max(0, min(1, threshold)) || 1 4789 }; 4790 let isFirstUpdate = true; 4791 function handleObserve(entries) { 4792 const ratio = entries[0].intersectionRatio; 4793 if (ratio !== threshold) { 4794 if (!isFirstUpdate) { 4795 return refresh(); 4796 } 4797 if (!ratio) { 4798 timeoutId = setTimeout(() => { 4799 refresh(false, 1e-7); 4800 }, 1e3); 4801 } else { 4802 refresh(false, ratio); 4803 } 4804 } 4805 if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) { 4806 refresh(); 4807 } 4808 isFirstUpdate = false; 4809 } 4810 try { 4811 io = new IntersectionObserver(handleObserve, { 4812 ...options, 4813 // Handle <iframe>s 4814 root: root.ownerDocument 4815 }); 4816 } catch (_e) { 4817 io = new IntersectionObserver(handleObserve, options); 4818 } 4819 io.observe(element); 4820 } 4821 refresh(true); 4822 return cleanup; 4823 } 4824 function autoUpdate(reference, floating, update2, options) { 4825 if (options === void 0) { 4826 options = {}; 4827 } 4828 const { 4829 ancestorScroll = true, 4830 ancestorResize = true, 4831 elementResize = typeof ResizeObserver === "function", 4832 layoutShift = typeof IntersectionObserver === "function", 4833 animationFrame = false 4834 } = options; 4835 const referenceEl = unwrapElement(reference); 4836 const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...floating ? getOverflowAncestors(floating) : []] : []; 4837 ancestors.forEach((ancestor) => { 4838 ancestorScroll && ancestor.addEventListener("scroll", update2, { 4839 passive: true 4840 }); 4841 ancestorResize && ancestor.addEventListener("resize", update2); 4842 }); 4843 const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update2) : null; 4844 let reobserveFrame = -1; 4845 let resizeObserver = null; 4846 if (elementResize) { 4847 resizeObserver = new ResizeObserver((_ref) => { 4848 let [firstEntry] = _ref; 4849 if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) { 4850 resizeObserver.unobserve(floating); 4851 cancelAnimationFrame(reobserveFrame); 4852 reobserveFrame = requestAnimationFrame(() => { 4853 var _resizeObserver; 4854 (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating); 4855 }); 4856 } 4857 update2(); 4858 }); 4859 if (referenceEl && !animationFrame) { 4860 resizeObserver.observe(referenceEl); 4861 } 4862 if (floating) { 4863 resizeObserver.observe(floating); 4864 } 4865 } 4866 let frameId; 4867 let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null; 4868 if (animationFrame) { 4869 frameLoop(); 4870 } 4871 function frameLoop() { 4872 const nextRefRect = getBoundingClientRect(reference); 4873 if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) { 4874 update2(); 4875 } 4876 prevRefRect = nextRefRect; 4877 frameId = requestAnimationFrame(frameLoop); 4878 } 4879 update2(); 4880 return () => { 4881 var _resizeObserver2; 4882 ancestors.forEach((ancestor) => { 4883 ancestorScroll && ancestor.removeEventListener("scroll", update2); 4884 ancestorResize && ancestor.removeEventListener("resize", update2); 4885 }); 4886 cleanupIo == null || cleanupIo(); 4887 (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect(); 4888 resizeObserver = null; 4889 if (animationFrame) { 4890 cancelAnimationFrame(frameId); 4891 } 4892 }; 4893 } 4894 var offset2 = offset; 4895 var shift2 = shift; 4896 var flip2 = flip; 4897 var size2 = size; 4898 var hide2 = hide; 4899 var limitShift2 = limitShift; 4900 var computePosition2 = (reference, floating, options) => { 4901 const cache = /* @__PURE__ */ new Map(); 4902 const mergedOptions = { 4903 platform: platform2, 4904 ...options 4905 }; 4906 const platformWithCache = { 4907 ...mergedOptions.platform, 4908 _c: cache 4909 }; 4910 return computePosition(reference, floating, { 4911 ...mergedOptions, 4912 platform: platformWithCache 4913 }); 4914 }; 4915 4916 // node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.mjs 4917 var React19 = __toESM(require_react(), 1); 4918 var import_react2 = __toESM(require_react(), 1); 4919 var ReactDOM3 = __toESM(require_react_dom(), 1); 4920 var isClient = typeof document !== "undefined"; 4921 var noop2 = function noop3() { 4922 }; 4923 var index = isClient ? import_react2.useLayoutEffect : noop2; 4924 function deepEqual(a, b) { 4925 if (a === b) { 4926 return true; 4927 } 4928 if (typeof a !== typeof b) { 4929 return false; 4930 } 4931 if (typeof a === "function" && a.toString() === b.toString()) { 4932 return true; 4933 } 4934 let length; 4935 let i; 4936 let keys; 4937 if (a && b && typeof a === "object") { 4938 if (Array.isArray(a)) { 4939 length = a.length; 4940 if (length !== b.length) return false; 4941 for (i = length; i-- !== 0; ) { 4942 if (!deepEqual(a[i], b[i])) { 4943 return false; 4944 } 4945 } 4946 return true; 4947 } 4948 keys = Object.keys(a); 4949 length = keys.length; 4950 if (length !== Object.keys(b).length) { 4951 return false; 4952 } 4953 for (i = length; i-- !== 0; ) { 4954 if (!{}.hasOwnProperty.call(b, keys[i])) { 4955 return false; 4956 } 4957 } 4958 for (i = length; i-- !== 0; ) { 4959 const key = keys[i]; 4960 if (key === "_owner" && a.$$typeof) { 4961 continue; 4962 } 4963 if (!deepEqual(a[key], b[key])) { 4964 return false; 4965 } 4966 } 4967 return true; 4968 } 4969 return a !== a && b !== b; 4970 } 4971 function getDPR(element) { 4972 if (typeof window === "undefined") { 4973 return 1; 4974 } 4975 const win = element.ownerDocument.defaultView || window; 4976 return win.devicePixelRatio || 1; 4977 } 4978 function roundByDPR(element, value) { 4979 const dpr = getDPR(element); 4980 return Math.round(value * dpr) / dpr; 4981 } 4982 function useLatestRef(value) { 4983 const ref = React19.useRef(value); 4984 index(() => { 4985 ref.current = value; 4986 }); 4987 return ref; 4988 } 4989 function useFloating(options) { 4990 if (options === void 0) { 4991 options = {}; 4992 } 4993 const { 4994 placement = "bottom", 4995 strategy = "absolute", 4996 middleware = [], 4997 platform: platform3, 4998 elements: { 4999 reference: externalReference, 5000 floating: externalFloating 5001 } = {}, 5002 transform = true, 5003 whileElementsMounted, 5004 open 5005 } = options; 5006 const [data, setData] = React19.useState({ 5007 x: 0, 5008 y: 0, 5009 strategy, 5010 placement, 5011 middlewareData: {}, 5012 isPositioned: false 5013 }); 5014 const [latestMiddleware, setLatestMiddleware] = React19.useState(middleware); 5015 if (!deepEqual(latestMiddleware, middleware)) { 5016 setLatestMiddleware(middleware); 5017 } 5018 const [_reference, _setReference] = React19.useState(null); 5019 const [_floating, _setFloating] = React19.useState(null); 5020 const setReference = React19.useCallback((node) => { 5021 if (node !== referenceRef.current) { 5022 referenceRef.current = node; 5023 _setReference(node); 5024 } 5025 }, []); 5026 const setFloating = React19.useCallback((node) => { 5027 if (node !== floatingRef.current) { 5028 floatingRef.current = node; 5029 _setFloating(node); 5030 } 5031 }, []); 5032 const referenceEl = externalReference || _reference; 5033 const floatingEl = externalFloating || _floating; 5034 const referenceRef = React19.useRef(null); 5035 const floatingRef = React19.useRef(null); 5036 const dataRef = React19.useRef(data); 5037 const hasWhileElementsMounted = whileElementsMounted != null; 5038 const whileElementsMountedRef = useLatestRef(whileElementsMounted); 5039 const platformRef = useLatestRef(platform3); 5040 const openRef = useLatestRef(open); 5041 const update2 = React19.useCallback(() => { 5042 if (!referenceRef.current || !floatingRef.current) { 5043 return; 5044 } 5045 const config = { 5046 placement, 5047 strategy, 5048 middleware: latestMiddleware 5049 }; 5050 if (platformRef.current) { 5051 config.platform = platformRef.current; 5052 } 5053 computePosition2(referenceRef.current, floatingRef.current, config).then((data2) => { 5054 const fullData = { 5055 ...data2, 5056 // The floating element's position may be recomputed while it's closed 5057 // but still mounted (such as when transitioning out). To ensure 5058 // `isPositioned` will be `false` initially on the next open, avoid 5059 // setting it to `true` when `open === false` (must be specified). 5060 isPositioned: openRef.current !== false 5061 }; 5062 if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) { 5063 dataRef.current = fullData; 5064 ReactDOM3.flushSync(() => { 5065 setData(fullData); 5066 }); 5067 } 5068 }); 5069 }, [latestMiddleware, placement, strategy, platformRef, openRef]); 5070 index(() => { 5071 if (open === false && dataRef.current.isPositioned) { 5072 dataRef.current.isPositioned = false; 5073 setData((data2) => ({ 5074 ...data2, 5075 isPositioned: false 5076 })); 5077 } 5078 }, [open]); 5079 const isMountedRef = React19.useRef(false); 5080 index(() => { 5081 isMountedRef.current = true; 5082 return () => { 5083 isMountedRef.current = false; 5084 }; 5085 }, []); 5086 index(() => { 5087 if (referenceEl) referenceRef.current = referenceEl; 5088 if (floatingEl) floatingRef.current = floatingEl; 5089 if (referenceEl && floatingEl) { 5090 if (whileElementsMountedRef.current) { 5091 return whileElementsMountedRef.current(referenceEl, floatingEl, update2); 5092 } 5093 update2(); 5094 } 5095 }, [referenceEl, floatingEl, update2, whileElementsMountedRef, hasWhileElementsMounted]); 5096 const refs = React19.useMemo(() => ({ 5097 reference: referenceRef, 5098 floating: floatingRef, 5099 setReference, 5100 setFloating 5101 }), [setReference, setFloating]); 5102 const elements = React19.useMemo(() => ({ 5103 reference: referenceEl, 5104 floating: floatingEl 5105 }), [referenceEl, floatingEl]); 5106 const floatingStyles = React19.useMemo(() => { 5107 const initialStyles = { 5108 position: strategy, 5109 left: 0, 5110 top: 0 5111 }; 5112 if (!elements.floating) { 5113 return initialStyles; 5114 } 5115 const x = roundByDPR(elements.floating, data.x); 5116 const y = roundByDPR(elements.floating, data.y); 5117 if (transform) { 5118 return { 5119 ...initialStyles, 5120 transform: "translate(" + x + "px, " + y + "px)", 5121 ...getDPR(elements.floating) >= 1.5 && { 5122 willChange: "transform" 5123 } 5124 }; 5125 } 5126 return { 5127 position: strategy, 5128 left: x, 5129 top: y 5130 }; 5131 }, [strategy, transform, elements.floating, data.x, data.y]); 5132 return React19.useMemo(() => ({ 5133 ...data, 5134 update: update2, 5135 refs, 5136 elements, 5137 floatingStyles 5138 }), [data, update2, refs, elements, floatingStyles]); 5139 } 5140 var offset3 = (options, deps) => { 5141 const result = offset2(options); 5142 return { 5143 name: result.name, 5144 fn: result.fn, 5145 options: [options, deps] 5146 }; 5147 }; 5148 var shift3 = (options, deps) => { 5149 const result = shift2(options); 5150 return { 5151 name: result.name, 5152 fn: result.fn, 5153 options: [options, deps] 5154 }; 5155 }; 5156 var limitShift3 = (options, deps) => { 5157 const result = limitShift2(options); 5158 return { 5159 fn: result.fn, 5160 options: [options, deps] 5161 }; 5162 }; 5163 var flip3 = (options, deps) => { 5164 const result = flip2(options); 5165 return { 5166 name: result.name, 5167 fn: result.fn, 5168 options: [options, deps] 5169 }; 5170 }; 5171 var size3 = (options, deps) => { 5172 const result = size2(options); 5173 return { 5174 name: result.name, 5175 fn: result.fn, 5176 options: [options, deps] 5177 }; 5178 }; 5179 var hide3 = (options, deps) => { 5180 const result = hide2(options); 5181 return { 5182 name: result.name, 5183 fn: result.fn, 5184 options: [options, deps] 5185 }; 5186 }; 5187 5188 // node_modules/@base-ui/react/utils/popups/popupStoreUtils.mjs 5189 var React24 = __toESM(require_react(), 1); 5190 var ReactDOM4 = __toESM(require_react_dom(), 1); 5191 5192 // node_modules/@base-ui/react/floating-ui-react/hooks/useSyncedFloatingRootContext.mjs 5193 var React23 = __toESM(require_react(), 1); 5194 5195 // node_modules/@base-ui/utils/store/createSelector.mjs 5196 var createSelector2 = (a, b, c, d, e, f, ...other) => { 5197 if (other.length > 0) { 5198 throw new Error(true ? "Unsupported number of selectors" : formatErrorMessage_default(1)); 5199 } 5200 let selector; 5201 if (a && b && c && d && e && f) { 5202 selector = (state, a1, a2, a3) => { 5203 const va = a(state, a1, a2, a3); 5204 const vb = b(state, a1, a2, a3); 5205 const vc = c(state, a1, a2, a3); 5206 const vd = d(state, a1, a2, a3); 5207 const ve = e(state, a1, a2, a3); 5208 return f(va, vb, vc, vd, ve, a1, a2, a3); 5209 }; 5210 } else if (a && b && c && d && e) { 5211 selector = (state, a1, a2, a3) => { 5212 const va = a(state, a1, a2, a3); 5213 const vb = b(state, a1, a2, a3); 5214 const vc = c(state, a1, a2, a3); 5215 const vd = d(state, a1, a2, a3); 5216 return e(va, vb, vc, vd, a1, a2, a3); 5217 }; 5218 } else if (a && b && c && d) { 5219 selector = (state, a1, a2, a3) => { 5220 const va = a(state, a1, a2, a3); 5221 const vb = b(state, a1, a2, a3); 5222 const vc = c(state, a1, a2, a3); 5223 return d(va, vb, vc, a1, a2, a3); 5224 }; 5225 } else if (a && b && c) { 5226 selector = (state, a1, a2, a3) => { 5227 const va = a(state, a1, a2, a3); 5228 const vb = b(state, a1, a2, a3); 5229 return c(va, vb, a1, a2, a3); 5230 }; 5231 } else if (a && b) { 5232 selector = (state, a1, a2, a3) => { 5233 const va = a(state, a1, a2, a3); 5234 return b(va, a1, a2, a3); 5235 }; 5236 } else if (a) { 5237 selector = a; 5238 } else { 5239 throw ( 5240 /* minify-error-disabled */ 5241 new Error("Missing arguments") 5242 ); 5243 } 5244 return selector; 5245 }; 5246 5247 // node_modules/@base-ui/utils/store/useStore.mjs 5248 var React21 = __toESM(require_react(), 1); 5249 var import_shim = __toESM(require_shim(), 1); 5250 var import_with_selector = __toESM(require_with_selector(), 1); 5251 5252 // node_modules/@base-ui/utils/fastHooks.mjs 5253 var React20 = __toESM(require_react(), 1); 5254 var hooks = []; 5255 var currentInstance = void 0; 5256 function getInstance() { 5257 return currentInstance; 5258 } 5259 function register2(hook) { 5260 hooks.push(hook); 5261 } 5262 function fastComponent(fn) { 5263 const FastComponent = (props, forwardedRef) => { 5264 const instance = useRefWithInit(createInstance).current; 5265 let result; 5266 try { 5267 currentInstance = instance; 5268 for (const hook of hooks) { 5269 hook.before(instance); 5270 } 5271 result = fn(props, forwardedRef); 5272 for (const hook of hooks) { 5273 hook.after(instance); 5274 } 5275 instance.didInitialize = true; 5276 } finally { 5277 currentInstance = void 0; 5278 } 5279 return result; 5280 }; 5281 FastComponent.displayName = fn.displayName || fn.name; 5282 return FastComponent; 5283 } 5284 function fastComponentRef(fn) { 5285 return /* @__PURE__ */ React20.forwardRef(fastComponent(fn)); 5286 } 5287 function createInstance() { 5288 return { 5289 didInitialize: false 5290 }; 5291 } 5292 5293 // node_modules/@base-ui/utils/store/useStore.mjs 5294 var canUseRawUseSyncExternalStore = isReactVersionAtLeast(19); 5295 var useStoreImplementation = canUseRawUseSyncExternalStore ? useStoreFast : useStoreLegacy; 5296 function useStore(store2, selector, a1, a2, a3) { 5297 return useStoreImplementation(store2, selector, a1, a2, a3); 5298 } 5299 function useStoreR19(store2, selector, a1, a2, a3) { 5300 const getSelection = React21.useCallback(() => selector(store2.getSnapshot(), a1, a2, a3), [store2, selector, a1, a2, a3]); 5301 return (0, import_shim.useSyncExternalStore)(store2.subscribe, getSelection, getSelection); 5302 } 5303 register2({ 5304 before(instance) { 5305 instance.syncIndex = 0; 5306 if (!instance.didInitialize) { 5307 instance.syncTick = 1; 5308 instance.syncHooks = []; 5309 instance.didChangeStore = true; 5310 instance.getSnapshot = () => { 5311 let didChange2 = false; 5312 for (let i = 0; i < instance.syncHooks.length; i += 1) { 5313 const hook = instance.syncHooks[i]; 5314 const value = hook.selector(hook.store.state, hook.a1, hook.a2, hook.a3); 5315 if (!Object.is(hook.value, value)) { 5316 didChange2 = true; 5317 hook.value = value; 5318 } 5319 } 5320 if (didChange2) { 5321 instance.syncTick += 1; 5322 } 5323 return instance.syncTick; 5324 }; 5325 } 5326 }, 5327 after(instance) { 5328 if (instance.syncHooks.length > 0) { 5329 if (instance.didChangeStore) { 5330 instance.didChangeStore = false; 5331 instance.subscribe = (onStoreChange) => { 5332 const stores = /* @__PURE__ */ new Set(); 5333 for (const hook of instance.syncHooks) { 5334 stores.add(hook.store); 5335 } 5336 const unsubscribes = []; 5337 for (const store2 of stores) { 5338 unsubscribes.push(store2.subscribe(onStoreChange)); 5339 } 5340 return () => { 5341 for (const unsubscribe of unsubscribes) { 5342 unsubscribe(); 5343 } 5344 }; 5345 }; 5346 } 5347 (0, import_shim.useSyncExternalStore)(instance.subscribe, instance.getSnapshot, instance.getSnapshot); 5348 } 5349 } 5350 }); 5351 function useStoreFast(store2, selector, a1, a2, a3) { 5352 const instance = getInstance(); 5353 if (!instance) { 5354 return useStoreR19(store2, selector, a1, a2, a3); 5355 } 5356 const index2 = instance.syncIndex; 5357 instance.syncIndex += 1; 5358 let hook; 5359 if (!instance.didInitialize) { 5360 hook = { 5361 store: store2, 5362 selector, 5363 a1, 5364 a2, 5365 a3, 5366 value: selector(store2.getSnapshot(), a1, a2, a3) 5367 }; 5368 instance.syncHooks.push(hook); 5369 } else { 5370 hook = instance.syncHooks[index2]; 5371 if (hook.store !== store2 || hook.selector !== selector || !Object.is(hook.a1, a1) || !Object.is(hook.a2, a2) || !Object.is(hook.a3, a3)) { 5372 if (hook.store !== store2) { 5373 instance.didChangeStore = true; 5374 } 5375 hook.store = store2; 5376 hook.selector = selector; 5377 hook.a1 = a1; 5378 hook.a2 = a2; 5379 hook.a3 = a3; 5380 hook.value = selector(store2.getSnapshot(), a1, a2, a3); 5381 } 5382 } 5383 return hook.value; 5384 } 5385 function useStoreLegacy(store2, selector, a1, a2, a3) { 5386 return (0, import_with_selector.useSyncExternalStoreWithSelector)(store2.subscribe, store2.getSnapshot, store2.getSnapshot, (state) => selector(state, a1, a2, a3)); 5387 } 5388 5389 // node_modules/@base-ui/utils/store/Store.mjs 5390 var Store = class { 5391 /** 5392 * The current state of the store. 5393 * This property is updated immediately when the state changes as a result of calling {@link setState}, {@link update}, or {@link set}. 5394 * 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). 5395 * The values can be used directly (to avoid subscribing to the store) in effects or event handlers. 5396 * 5397 * Do not modify properties in state directly. Instead, use the provided methods to ensure proper state management and listener notification. 5398 */ 5399 // Internal state to handle recursive `setState()` calls 5400 constructor(state) { 5401 this.state = state; 5402 this.listeners = /* @__PURE__ */ new Set(); 5403 this.updateTick = 0; 5404 } 5405 /** 5406 * Registers a listener that will be called whenever the store's state changes. 5407 * 5408 * @param fn The listener function to be called on state changes. 5409 * @returns A function to unsubscribe the listener. 5410 */ 5411 subscribe = (fn) => { 5412 this.listeners.add(fn); 5413 return () => { 5414 this.listeners.delete(fn); 5415 }; 5416 }; 5417 /** 5418 * Returns the current state of the store. 5419 */ 5420 getSnapshot = () => { 5421 return this.state; 5422 }; 5423 /** 5424 * Updates the entire store's state and notifies all registered listeners. 5425 * 5426 * @param newState The new state to set for the store. 5427 */ 5428 setState(newState) { 5429 if (this.state === newState) { 5430 return; 5431 } 5432 this.state = newState; 5433 this.updateTick += 1; 5434 const currentTick = this.updateTick; 5435 for (const listener of this.listeners) { 5436 if (currentTick !== this.updateTick) { 5437 return; 5438 } 5439 listener(newState); 5440 } 5441 } 5442 /** 5443 * Merges the provided changes into the current state and notifies listeners if there are changes. 5444 * 5445 * @param changes An object containing the changes to apply to the current state. 5446 */ 5447 update(changes) { 5448 for (const key in changes) { 5449 if (!Object.is(this.state[key], changes[key])) { 5450 this.setState({ 5451 ...this.state, 5452 ...changes 5453 }); 5454 return; 5455 } 5456 } 5457 } 5458 /** 5459 * Sets a specific key in the store's state to a new value and notifies listeners if the value has changed. 5460 * 5461 * @param key The key in the store's state to update. 5462 * @param value The new value to set for the specified key. 5463 */ 5464 set(key, value) { 5465 if (!Object.is(this.state[key], value)) { 5466 this.setState({ 5467 ...this.state, 5468 [key]: value 5469 }); 5470 } 5471 } 5472 /** 5473 * Gives the state a new reference and updates all registered listeners. 5474 */ 5475 notifyAll() { 5476 const newState = { 5477 ...this.state 5478 }; 5479 this.setState(newState); 5480 } 5481 use(selector, a1, a2, a3) { 5482 return useStore(this, selector, a1, a2, a3); 5483 } 5484 }; 5485 5486 // node_modules/@base-ui/utils/store/ReactStore.mjs 5487 var React22 = __toESM(require_react(), 1); 5488 var ReactStore = class extends Store { 5489 /** 5490 * Creates a new ReactStore instance. 5491 * 5492 * @param state Initial state of the store. 5493 * @param context Non-reactive context values. 5494 * @param selectors Optional selectors for use with `useState`. 5495 */ 5496 constructor(state, context = {}, selectors3) { 5497 super(state); 5498 this.context = context; 5499 this.selectors = selectors3; 5500 } 5501 /** 5502 * Non-reactive values such as refs, callbacks, etc. 5503 */ 5504 /** 5505 * Synchronizes a single external value into the store. 5506 * 5507 * Note that the while the value in `state` is updated immediately, the value returned 5508 * by `useState` is updated before the next render (similarly to React's `useState`). 5509 */ 5510 useSyncedValue(key, value) { 5511 React22.useDebugValue(key); 5512 const store2 = this; 5513 useIsoLayoutEffect(() => { 5514 if (store2.state[key] !== value) { 5515 store2.set(key, value); 5516 } 5517 }, [store2, key, value]); 5518 } 5519 /** 5520 * Synchronizes a single external value into the store and 5521 * cleans it up (sets to `undefined`) on unmount. 5522 * 5523 * Note that the while the value in `state` is updated immediately, the value returned 5524 * by `useState` is updated before the next render (similarly to React's `useState`). 5525 */ 5526 useSyncedValueWithCleanup(key, value) { 5527 const store2 = this; 5528 useIsoLayoutEffect(() => { 5529 if (store2.state[key] !== value) { 5530 store2.set(key, value); 5531 } 5532 return () => { 5533 store2.set(key, void 0); 5534 }; 5535 }, [store2, key, value]); 5536 } 5537 /** 5538 * Synchronizes multiple external values into the store. 5539 * 5540 * Note that the while the values in `state` are updated immediately, the values returned 5541 * by `useState` are updated before the next render (similarly to React's `useState`). 5542 */ 5543 useSyncedValues(statePart) { 5544 const store2 = this; 5545 if (true) { 5546 React22.useDebugValue(statePart, (p) => Object.keys(p)); 5547 const keys = React22.useRef(Object.keys(statePart)).current; 5548 const nextKeys = Object.keys(statePart); 5549 if (keys.length !== nextKeys.length || keys.some((key, index2) => key !== nextKeys[index2])) { 5550 console.error("ReactStore.useSyncedValues expects the same prop keys on every render. Keys should be stable."); 5551 } 5552 } 5553 const dependencies = Object.values(statePart); 5554 useIsoLayoutEffect(() => { 5555 store2.update(statePart); 5556 }, [store2, ...dependencies]); 5557 } 5558 /** 5559 * Registers a controllable prop pair (`controlled`, `defaultValue`) for a specific key. If `controlled` 5560 * is non-undefined, the store's state at `key` is updated to match `controlled`. 5561 */ 5562 useControlledProp(key, controlled) { 5563 React22.useDebugValue(key); 5564 const store2 = this; 5565 const isControlled = controlled !== void 0; 5566 useIsoLayoutEffect(() => { 5567 if (isControlled && !Object.is(store2.state[key], controlled)) { 5568 store2.setState({ 5569 ...store2.state, 5570 [key]: controlled 5571 }); 5572 } 5573 }, [store2, key, controlled, isControlled]); 5574 if (true) { 5575 const cache = this.controlledValues ??= /* @__PURE__ */ new Map(); 5576 if (!cache.has(key)) { 5577 cache.set(key, isControlled); 5578 } 5579 const previouslyControlled = cache.get(key); 5580 if (previouslyControlled !== void 0 && previouslyControlled !== isControlled) { 5581 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).`); 5582 } 5583 } 5584 } 5585 /** Gets the current value from the store using a selector with the provided key. 5586 * 5587 * @param key Key of the selector to use. 5588 */ 5589 select(key, a1, a2, a3) { 5590 const selector = this.selectors[key]; 5591 return selector(this.state, a1, a2, a3); 5592 } 5593 /** 5594 * Returns a value from the store's state using a selector function. 5595 * Used to subscribe to specific parts of the state. 5596 * This methods causes a rerender whenever the selected state changes. 5597 * 5598 * @param key Key of the selector to use. 5599 */ 5600 useState(key, a1, a2, a3) { 5601 React22.useDebugValue(key); 5602 return useStore(this, this.selectors[key], a1, a2, a3); 5603 } 5604 /** 5605 * Wraps a function with `useStableCallback` to ensure it has a stable reference 5606 * and assigns it to the context. 5607 * 5608 * @param key Key of the event callback. Must be a function in the context. 5609 * @param fn Function to assign. 5610 */ 5611 useContextCallback(key, fn) { 5612 React22.useDebugValue(key); 5613 const stableFunction = useStableCallback(fn ?? NOOP); 5614 this.context[key] = stableFunction; 5615 } 5616 /** 5617 * Returns a stable setter function for a specific key in the store's state. 5618 * It's commonly used to pass as a ref callback to React elements. 5619 * 5620 * @param key Key of the state to set. 5621 */ 5622 useStateSetter(key) { 5623 const ref = React22.useRef(void 0); 5624 if (ref.current === void 0) { 5625 ref.current = (value) => { 5626 this.set(key, value); 5627 }; 5628 } 5629 return ref.current; 5630 } 5631 /** 5632 * Observes changes derived from the store's selectors and calls the listener when the selected value changes. 5633 * 5634 * @param key Key of the selector to observe. 5635 * @param listener Listener function called when the selector result changes. 5636 */ 5637 observe(selector, listener) { 5638 let selectFn; 5639 if (typeof selector === "function") { 5640 selectFn = selector; 5641 } else { 5642 selectFn = this.selectors[selector]; 5643 } 5644 let prevValue = selectFn(this.state); 5645 listener(prevValue, prevValue, this); 5646 return this.subscribe((nextState) => { 5647 const nextValue = selectFn(nextState); 5648 if (!Object.is(prevValue, nextValue)) { 5649 const oldValue = prevValue; 5650 prevValue = nextValue; 5651 listener(nextValue, oldValue, this); 5652 } 5653 }); 5654 } 5655 }; 5656 5657 // node_modules/@base-ui/react/floating-ui-react/components/FloatingRootStore.mjs 5658 var selectors = { 5659 open: createSelector2((state) => state.open), 5660 transitionStatus: createSelector2((state) => state.transitionStatus), 5661 domReferenceElement: createSelector2((state) => state.domReferenceElement), 5662 referenceElement: createSelector2((state) => state.positionReference ?? state.referenceElement), 5663 floatingElement: createSelector2((state) => state.floatingElement), 5664 floatingId: createSelector2((state) => state.floatingId) 5665 }; 5666 var FloatingRootStore = class extends ReactStore { 5667 constructor(options) { 5668 const { 5669 syncOnly, 5670 nested, 5671 onOpenChange, 5672 triggerElements, 5673 ...initialState 5674 } = options; 5675 super({ 5676 ...initialState, 5677 positionReference: initialState.referenceElement, 5678 domReferenceElement: initialState.referenceElement 5679 }, { 5680 onOpenChange, 5681 dataRef: { 5682 current: {} 5683 }, 5684 events: createEventEmitter(), 5685 nested, 5686 triggerElements 5687 }, selectors); 5688 this.syncOnly = syncOnly; 5689 } 5690 /** 5691 * Syncs the event used by hover logic to distinguish hover-open from click-like interaction. 5692 */ 5693 syncOpenEvent = (newOpen, event) => { 5694 if (!newOpen || !this.state.open || // Prevent a pending hover-open from overwriting a click-open event, while allowing 5695 // click events to upgrade a hover-open. 5696 event != null && isClickLikeEvent(event)) { 5697 this.context.dataRef.current.openEvent = newOpen ? event : void 0; 5698 } 5699 }; 5700 /** 5701 * Runs the root-owned side effects for an open state change. 5702 */ 5703 dispatchOpenChange = (newOpen, eventDetails) => { 5704 this.syncOpenEvent(newOpen, eventDetails.event); 5705 const details = { 5706 open: newOpen, 5707 reason: eventDetails.reason, 5708 nativeEvent: eventDetails.event, 5709 nested: this.context.nested, 5710 triggerElement: eventDetails.trigger 5711 }; 5712 this.context.events.emit("openchange", details); 5713 }; 5714 /** 5715 * Emits the `openchange` event through the internal event emitter and calls the `onOpenChange` handler with the provided arguments. 5716 * 5717 * @param newOpen The new open state. 5718 * @param eventDetails Details about the event that triggered the open state change. 5719 */ 5720 setOpen = (newOpen, eventDetails) => { 5721 if (this.syncOnly) { 5722 this.context.onOpenChange?.(newOpen, eventDetails); 5723 return; 5724 } 5725 this.dispatchOpenChange(newOpen, eventDetails); 5726 this.context.onOpenChange?.(newOpen, eventDetails); 5727 }; 5728 }; 5729 5730 // node_modules/@base-ui/react/floating-ui-react/hooks/useSyncedFloatingRootContext.mjs 5731 function useSyncedFloatingRootContext(options) { 5732 const { 5733 popupStore, 5734 treatPopupAsFloatingElement = false, 5735 floatingRootContext: floatingRootContextProp, 5736 floatingId, 5737 nested, 5738 onOpenChange 5739 } = options; 5740 const open = popupStore.useState("open"); 5741 const referenceElement = popupStore.useState("activeTriggerElement"); 5742 const floatingElement = popupStore.useState(treatPopupAsFloatingElement ? "popupElement" : "positionerElement"); 5743 const triggerElements = popupStore.context.triggerElements; 5744 const handleOpenChange = onOpenChange; 5745 const internalStoreRef = React23.useRef(null); 5746 if (floatingRootContextProp === void 0 && internalStoreRef.current === null) { 5747 internalStoreRef.current = new FloatingRootStore({ 5748 open, 5749 transitionStatus: void 0, 5750 referenceElement, 5751 floatingElement, 5752 triggerElements, 5753 onOpenChange: handleOpenChange, 5754 floatingId, 5755 syncOnly: true, 5756 nested 5757 }); 5758 } 5759 const store2 = floatingRootContextProp ?? internalStoreRef.current; 5760 popupStore.useSyncedValue("floatingId", floatingId); 5761 useIsoLayoutEffect(() => { 5762 const valuesToSync = { 5763 open, 5764 floatingId, 5765 referenceElement, 5766 floatingElement 5767 }; 5768 if (isElement(referenceElement)) { 5769 valuesToSync.domReferenceElement = referenceElement; 5770 } 5771 if (store2.state.positionReference === store2.state.referenceElement) { 5772 valuesToSync.positionReference = referenceElement; 5773 } 5774 store2.update(valuesToSync); 5775 }, [open, floatingId, referenceElement, floatingElement, store2]); 5776 store2.context.onOpenChange = handleOpenChange; 5777 store2.context.nested = nested; 5778 return store2; 5779 } 5780 5781 // node_modules/@base-ui/react/utils/popups/popupStoreUtils.mjs 5782 var FOCUSABLE_POPUP_PROPS = { 5783 tabIndex: -1, 5784 [FOCUSABLE_ATTRIBUTE]: "" 5785 }; 5786 function usePopupStore(externalStore, createStore, treatPopupAsFloatingElement = false) { 5787 const floatingId = useId(); 5788 const nested = useFloatingParentNodeId() != null; 5789 const internalStoreRef = React24.useRef(null); 5790 if (externalStore === void 0 && internalStoreRef.current === null) { 5791 internalStoreRef.current = createStore(floatingId, nested); 5792 } 5793 const store2 = externalStore ?? internalStoreRef.current; 5794 useSyncedFloatingRootContext({ 5795 popupStore: store2, 5796 treatPopupAsFloatingElement, 5797 floatingRootContext: store2.state.floatingRootContext, 5798 floatingId, 5799 nested, 5800 onOpenChange: store2.setOpen 5801 }); 5802 return { 5803 store: store2, 5804 internalStore: internalStoreRef.current 5805 }; 5806 } 5807 function useTriggerRegistration(id, store2) { 5808 const registeredElementIdRef = React24.useRef(null); 5809 const registeredElementRef = React24.useRef(null); 5810 return React24.useCallback((element) => { 5811 if (id === void 0) { 5812 return; 5813 } 5814 let shouldSyncTriggerCount = false; 5815 if (registeredElementIdRef.current !== null) { 5816 const registeredId = registeredElementIdRef.current; 5817 const registeredElement = registeredElementRef.current; 5818 const currentElement = store2.context.triggerElements.getById(registeredId); 5819 if (registeredElement && currentElement === registeredElement) { 5820 store2.context.triggerElements.delete(registeredId); 5821 shouldSyncTriggerCount = true; 5822 } 5823 registeredElementIdRef.current = null; 5824 registeredElementRef.current = null; 5825 } 5826 if (element !== null) { 5827 registeredElementIdRef.current = id; 5828 registeredElementRef.current = element; 5829 store2.context.triggerElements.add(id, element); 5830 shouldSyncTriggerCount = true; 5831 } 5832 if (shouldSyncTriggerCount) { 5833 const triggerCount = store2.context.triggerElements.size; 5834 if (store2.select("open") && store2.state.triggerCount !== triggerCount) { 5835 store2.set("triggerCount", triggerCount); 5836 } 5837 } 5838 }, [store2, id]); 5839 } 5840 function setPopupOpenState(state, open, trigger, preventUnmountOnClose = false) { 5841 if (open) { 5842 state.preventUnmountingOnClose = false; 5843 } else if (preventUnmountOnClose) { 5844 state.preventUnmountingOnClose = true; 5845 } 5846 const triggerId = trigger?.id ?? null; 5847 if (triggerId || open) { 5848 state.activeTriggerId = triggerId; 5849 state.activeTriggerElement = trigger ?? null; 5850 } 5851 } 5852 function attachPreventUnmountOnClose(eventDetails) { 5853 let preventUnmountOnClose = false; 5854 eventDetails.preventUnmountOnClose = () => { 5855 preventUnmountOnClose = true; 5856 }; 5857 return () => preventUnmountOnClose; 5858 } 5859 function applyPopupOpenChange(store2, nextOpen, eventDetails, options = {}) { 5860 const reason = eventDetails.reason; 5861 const isHover = reason === reason_parts_exports.triggerHover; 5862 const isFocusOpen = nextOpen && reason === reason_parts_exports.triggerFocus; 5863 const isDismissClose = !nextOpen && (reason === reason_parts_exports.triggerPress || reason === reason_parts_exports.escapeKey); 5864 const shouldPreventUnmountOnClose = attachPreventUnmountOnClose(eventDetails); 5865 store2.context.onOpenChange?.(nextOpen, eventDetails); 5866 if (eventDetails.isCanceled) { 5867 return; 5868 } 5869 options.onBeforeDispatch?.(); 5870 store2.state.floatingRootContext.dispatchOpenChange(nextOpen, eventDetails); 5871 const changeState = () => { 5872 const updatedState = { 5873 ...options.extraState, 5874 open: nextOpen 5875 }; 5876 if (isFocusOpen) { 5877 updatedState.instantType = "focus"; 5878 } else if (isDismissClose) { 5879 updatedState.instantType = "dismiss"; 5880 } else if (isHover) { 5881 updatedState.instantType = void 0; 5882 } 5883 setPopupOpenState(updatedState, nextOpen, eventDetails.trigger, shouldPreventUnmountOnClose()); 5884 store2.update(updatedState); 5885 }; 5886 if (isHover) { 5887 ReactDOM4.flushSync(changeState); 5888 } else { 5889 changeState(); 5890 } 5891 } 5892 function useInitialOpenSync(store2, openProp, defaultOpen, defaultTriggerId) { 5893 useOnFirstRender(() => { 5894 if (openProp === void 0 && store2.state.open === false && defaultOpen) { 5895 store2.state = { 5896 ...store2.state, 5897 open: true, 5898 activeTriggerId: defaultTriggerId, 5899 preventUnmountingOnClose: false 5900 }; 5901 } 5902 }); 5903 } 5904 function useTriggerDataForwarding(triggerId, triggerElementRef, store2, stateUpdates) { 5905 const isMountedByThisTrigger = store2.useState("isMountedByTrigger", triggerId); 5906 const baseRegisterTrigger = useTriggerRegistration(triggerId, store2); 5907 const registerTrigger = useStableCallback((element) => { 5908 baseRegisterTrigger(element); 5909 if (!element) { 5910 return; 5911 } 5912 const open = store2.select("open"); 5913 const activeTriggerId = store2.select("activeTriggerId"); 5914 if (activeTriggerId === triggerId) { 5915 store2.update({ 5916 activeTriggerElement: element, 5917 ...open ? stateUpdates : null 5918 }); 5919 return; 5920 } 5921 if (activeTriggerId == null && open) { 5922 store2.update({ 5923 activeTriggerId: triggerId, 5924 activeTriggerElement: element, 5925 ...stateUpdates 5926 }); 5927 } 5928 }); 5929 useIsoLayoutEffect(() => { 5930 if (isMountedByThisTrigger) { 5931 store2.update({ 5932 activeTriggerElement: triggerElementRef.current, 5933 ...stateUpdates 5934 }); 5935 } 5936 }, [isMountedByThisTrigger, store2, triggerElementRef, ...Object.values(stateUpdates)]); 5937 return { 5938 registerTrigger, 5939 isMountedByThisTrigger 5940 }; 5941 } 5942 function useImplicitActiveTrigger(store2, options = {}) { 5943 const { 5944 closeOnActiveTriggerUnmount = false 5945 } = options; 5946 const open = store2.useState("open"); 5947 const reactiveTriggerCount = store2.useState("triggerCount"); 5948 useIsoLayoutEffect(() => { 5949 if (!open) { 5950 if (store2.state.triggerCount !== 0) { 5951 store2.set("triggerCount", 0); 5952 } 5953 return; 5954 } 5955 const triggerCount = store2.context.triggerElements.size; 5956 const stateUpdates = {}; 5957 if (store2.state.triggerCount !== triggerCount) { 5958 stateUpdates.triggerCount = triggerCount; 5959 } 5960 const activeTriggerId = store2.select("activeTriggerId"); 5961 let lostActiveTriggerId = null; 5962 if (activeTriggerId) { 5963 const activeTriggerElement = store2.context.triggerElements.getById(activeTriggerId); 5964 if (!activeTriggerElement) { 5965 lostActiveTriggerId = activeTriggerId; 5966 } else if (activeTriggerElement !== store2.state.activeTriggerElement) { 5967 stateUpdates.activeTriggerElement = activeTriggerElement; 5968 } 5969 } 5970 if (!lostActiveTriggerId && !activeTriggerId && triggerCount === 1) { 5971 const iteratorResult = store2.context.triggerElements.entries().next(); 5972 if (!iteratorResult.done) { 5973 const [implicitTriggerId, implicitTriggerElement] = iteratorResult.value; 5974 stateUpdates.activeTriggerId = implicitTriggerId; 5975 stateUpdates.activeTriggerElement = implicitTriggerElement; 5976 } 5977 } 5978 if (stateUpdates.triggerCount !== void 0 || stateUpdates.activeTriggerId !== void 0 || stateUpdates.activeTriggerElement !== void 0) { 5979 store2.update(stateUpdates); 5980 } 5981 if (lostActiveTriggerId) { 5982 if (closeOnActiveTriggerUnmount) { 5983 queueMicrotask(() => { 5984 if (store2.select("open") && store2.select("activeTriggerId") === lostActiveTriggerId && !store2.context.triggerElements.getById(lostActiveTriggerId)) { 5985 const eventDetails = createChangeEventDetails(reason_parts_exports.none); 5986 store2.setOpen(false, eventDetails); 5987 if (!eventDetails.isCanceled) { 5988 store2.update({ 5989 activeTriggerId: null, 5990 activeTriggerElement: null 5991 }); 5992 } 5993 } 5994 }); 5995 } 5996 } 5997 }, [open, store2, reactiveTriggerCount, closeOnActiveTriggerUnmount]); 5998 } 5999 function useOpenStateTransitions(open, store2, onUnmount) { 6000 const { 6001 mounted, 6002 setMounted, 6003 transitionStatus 6004 } = useTransitionStatus(open); 6005 const preventUnmountingOnClose = store2.useState("preventUnmountingOnClose"); 6006 const syncedPreventUnmountingOnClose = open ? false : preventUnmountingOnClose; 6007 store2.useSyncedValues({ 6008 mounted, 6009 transitionStatus, 6010 preventUnmountingOnClose: syncedPreventUnmountingOnClose 6011 }); 6012 const forceUnmount = useStableCallback(() => { 6013 setMounted(false); 6014 store2.update({ 6015 activeTriggerId: null, 6016 activeTriggerElement: null, 6017 mounted: false, 6018 preventUnmountingOnClose: false 6019 }); 6020 onUnmount?.(); 6021 store2.context.onOpenChangeComplete?.(false); 6022 }); 6023 useOpenChangeComplete({ 6024 enabled: mounted && !open && !syncedPreventUnmountingOnClose, 6025 open, 6026 ref: store2.context.popupRef, 6027 onComplete() { 6028 if (!open) { 6029 forceUnmount(); 6030 } 6031 } 6032 }); 6033 return { 6034 forceUnmount, 6035 transitionStatus 6036 }; 6037 } 6038 function usePopupInteractionProps(store2, statePart) { 6039 store2.useSyncedValues(statePart); 6040 useIsoLayoutEffect(() => () => { 6041 store2.update({ 6042 activeTriggerProps: EMPTY_OBJECT, 6043 inactiveTriggerProps: EMPTY_OBJECT, 6044 popupProps: EMPTY_OBJECT 6045 }); 6046 }, [store2]); 6047 } 6048 6049 // node_modules/@base-ui/react/utils/popups/popupTriggerMap.mjs 6050 var PopupTriggerMap = class { 6051 constructor() { 6052 this.elementsSet = /* @__PURE__ */ new Set(); 6053 this.idMap = /* @__PURE__ */ new Map(); 6054 } 6055 /** 6056 * Adds a trigger element with the given ID. 6057 * 6058 * Note: The provided element is assumed to not be registered under multiple IDs. 6059 */ 6060 add(id, element) { 6061 const existingElement = this.idMap.get(id); 6062 if (existingElement === element) { 6063 return; 6064 } 6065 if (existingElement !== void 0) { 6066 this.elementsSet.delete(existingElement); 6067 } 6068 this.elementsSet.add(element); 6069 this.idMap.set(id, element); 6070 if (true) { 6071 if (this.elementsSet.size !== this.idMap.size) { 6072 throw new Error("Base UI: A trigger element cannot be registered under multiple IDs in PopupTriggerMap."); 6073 } 6074 } 6075 } 6076 /** 6077 * Removes the trigger element with the given ID. 6078 */ 6079 delete(id) { 6080 const element = this.idMap.get(id); 6081 if (element) { 6082 this.elementsSet.delete(element); 6083 this.idMap.delete(id); 6084 } 6085 } 6086 /** 6087 * Whether the given element is registered as a trigger. 6088 */ 6089 hasElement(element) { 6090 return this.elementsSet.has(element); 6091 } 6092 /** 6093 * Whether there is a registered trigger element matching the given predicate. 6094 */ 6095 hasMatchingElement(predicate) { 6096 for (const element of this.elementsSet) { 6097 if (predicate(element)) { 6098 return true; 6099 } 6100 } 6101 return false; 6102 } 6103 /** 6104 * Returns the trigger element associated with the given ID, or undefined if no such element exists. 6105 */ 6106 getById(id) { 6107 return this.idMap.get(id); 6108 } 6109 /** 6110 * Returns an iterable of all registered trigger entries, where each entry is a tuple of [id, element]. 6111 */ 6112 entries() { 6113 return this.idMap.entries(); 6114 } 6115 /** 6116 * Returns an iterable of all registered trigger elements. 6117 */ 6118 elements() { 6119 return this.elementsSet.values(); 6120 } 6121 /** 6122 * Returns the number of registered trigger elements. 6123 */ 6124 get size() { 6125 return this.idMap.size; 6126 } 6127 }; 6128 6129 // node_modules/@base-ui/react/floating-ui-react/utils/getEmptyRootContext.mjs 6130 function getEmptyRootContext() { 6131 return new FloatingRootStore({ 6132 open: false, 6133 transitionStatus: void 0, 6134 floatingElement: null, 6135 referenceElement: null, 6136 triggerElements: new PopupTriggerMap(), 6137 floatingId: void 0, 6138 syncOnly: false, 6139 nested: false, 6140 onOpenChange: void 0 6141 }); 6142 } 6143 6144 // node_modules/@base-ui/react/utils/popups/store.mjs 6145 function createInitialPopupStoreState() { 6146 return { 6147 open: false, 6148 openProp: void 0, 6149 mounted: false, 6150 transitionStatus: void 0, 6151 floatingRootContext: getEmptyRootContext(), 6152 floatingId: void 0, 6153 triggerCount: 0, 6154 preventUnmountingOnClose: false, 6155 payload: void 0, 6156 activeTriggerId: null, 6157 activeTriggerElement: null, 6158 triggerIdProp: void 0, 6159 popupElement: null, 6160 positionerElement: null, 6161 activeTriggerProps: EMPTY_OBJECT, 6162 inactiveTriggerProps: EMPTY_OBJECT, 6163 popupProps: EMPTY_OBJECT 6164 }; 6165 } 6166 function createPopupFloatingRootContext(triggerElements, floatingId, nested = false) { 6167 return new FloatingRootStore({ 6168 open: false, 6169 transitionStatus: void 0, 6170 floatingElement: null, 6171 referenceElement: null, 6172 triggerElements, 6173 floatingId, 6174 syncOnly: true, 6175 nested, 6176 onOpenChange: void 0 6177 }); 6178 } 6179 var activeTriggerIdSelector = createSelector2((state) => state.triggerIdProp ?? state.activeTriggerId); 6180 var openSelector = createSelector2((state) => state.openProp ?? state.open); 6181 var popupIdSelector = createSelector2((state) => { 6182 const popupId = state.popupElement?.id ?? state.floatingId; 6183 return popupId || void 0; 6184 }); 6185 function triggerOwnsOpenPopup(state, triggerId) { 6186 return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) === triggerId; 6187 } 6188 function triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) { 6189 if (triggerOwnsOpenPopup(state, triggerId)) { 6190 return true; 6191 } 6192 return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) == null && state.triggerCount === 1; 6193 } 6194 var popupStoreSelectors = { 6195 open: openSelector, 6196 mounted: createSelector2((state) => state.mounted), 6197 transitionStatus: createSelector2((state) => state.transitionStatus), 6198 floatingRootContext: createSelector2((state) => state.floatingRootContext), 6199 triggerCount: createSelector2((state) => state.triggerCount), 6200 preventUnmountingOnClose: createSelector2((state) => state.preventUnmountingOnClose), 6201 payload: createSelector2((state) => state.payload), 6202 activeTriggerId: activeTriggerIdSelector, 6203 activeTriggerElement: createSelector2((state) => state.mounted ? state.activeTriggerElement : null), 6204 popupId: popupIdSelector, 6205 /** 6206 * Whether the trigger with the given ID was used to open the popup. 6207 */ 6208 isTriggerActive: createSelector2((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId), 6209 /** 6210 * Whether the popup is open and was activated by a trigger with the given ID. 6211 */ 6212 isOpenedByTrigger: createSelector2((state, triggerId) => triggerOwnsOpenPopup(state, triggerId)), 6213 /** 6214 * Whether the popup is mounted and was activated by a trigger with the given ID. 6215 */ 6216 isMountedByTrigger: createSelector2((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId && state.mounted), 6217 triggerProps: createSelector2((state, isActive) => isActive ? state.activeTriggerProps : state.inactiveTriggerProps), 6218 /** 6219 * Popup id for the trigger that currently owns the open popup. 6220 */ 6221 triggerPopupId: createSelector2((state, triggerId) => triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) ? popupIdSelector(state) : void 0), 6222 popupProps: createSelector2((state) => state.popupProps), 6223 popupElement: createSelector2((state) => state.popupElement), 6224 positionerElement: createSelector2((state) => state.positionerElement) 6225 }; 6226 6227 // node_modules/@base-ui/react/floating-ui-react/hooks/useFloatingRootContext.mjs 6228 function useFloatingRootContext(options) { 6229 const { 6230 open = false, 6231 onOpenChange, 6232 elements = {} 6233 } = options; 6234 const floatingId = useId(); 6235 const nested = useFloatingParentNodeId() != null; 6236 if (true) { 6237 const optionDomReference = elements.reference; 6238 if (optionDomReference && !isElement(optionDomReference)) { 6239 console.error("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `context.setPositionReference()`", "instead."); 6240 } 6241 } 6242 const store2 = useRefWithInit(() => new FloatingRootStore({ 6243 open, 6244 transitionStatus: void 0, 6245 onOpenChange, 6246 referenceElement: elements.reference ?? null, 6247 floatingElement: elements.floating ?? null, 6248 triggerElements: new PopupTriggerMap(), 6249 floatingId, 6250 syncOnly: false, 6251 nested 6252 })).current; 6253 useIsoLayoutEffect(() => { 6254 const valuesToSync = { 6255 open, 6256 floatingId 6257 }; 6258 if (elements.reference !== void 0) { 6259 valuesToSync.referenceElement = elements.reference; 6260 valuesToSync.domReferenceElement = isElement(elements.reference) ? elements.reference : null; 6261 } 6262 if (elements.floating !== void 0) { 6263 valuesToSync.floatingElement = elements.floating; 6264 } 6265 store2.update(valuesToSync); 6266 }, [open, floatingId, elements.reference, elements.floating, store2]); 6267 store2.context.onOpenChange = onOpenChange; 6268 store2.context.nested = nested; 6269 return store2; 6270 } 6271 6272 // node_modules/@base-ui/react/floating-ui-react/hooks/useFloating.mjs 6273 function useFloating2(options = {}) { 6274 const { 6275 nodeId, 6276 externalTree 6277 } = options; 6278 const internalStore = useFloatingRootContext(options); 6279 const store2 = options.rootContext || internalStore; 6280 const referenceElement = store2.useState("referenceElement"); 6281 const floatingElement = store2.useState("floatingElement"); 6282 const domReferenceElement = store2.useState("domReferenceElement"); 6283 const open = store2.useState("open"); 6284 const floatingId = store2.useState("floatingId"); 6285 const [positionReference, setPositionReferenceRaw] = React25.useState(null); 6286 const [localDomReference, setLocalDomReference] = React25.useState(void 0); 6287 const [localFloatingElement, setLocalFloatingElement] = React25.useState(void 0); 6288 const domReferenceRef = React25.useRef(null); 6289 const tree = useFloatingTree(externalTree); 6290 const storeElements = React25.useMemo(() => ({ 6291 reference: referenceElement, 6292 floating: floatingElement, 6293 domReference: domReferenceElement 6294 }), [referenceElement, floatingElement, domReferenceElement]); 6295 const position = useFloating({ 6296 ...options, 6297 elements: { 6298 ...storeElements, 6299 ...positionReference && { 6300 reference: positionReference 6301 } 6302 } 6303 }); 6304 const localDomReferenceElement = isElement(localDomReference) ? localDomReference : null; 6305 const syncedFloatingElement = localFloatingElement === void 0 ? store2.state.floatingElement : localFloatingElement; 6306 store2.useSyncedValue("referenceElement", localDomReference ?? null); 6307 store2.useSyncedValue("domReferenceElement", localDomReference === void 0 ? domReferenceElement : localDomReferenceElement); 6308 store2.useSyncedValue("floatingElement", syncedFloatingElement); 6309 const setPositionReference = React25.useCallback((node) => { 6310 const computedPositionReference = isElement(node) ? { 6311 getBoundingClientRect: () => node.getBoundingClientRect(), 6312 getClientRects: () => node.getClientRects(), 6313 contextElement: node 6314 } : node; 6315 setPositionReferenceRaw(computedPositionReference); 6316 position.refs.setReference(computedPositionReference); 6317 }, [position.refs]); 6318 const setReference = React25.useCallback((node) => { 6319 if (isElement(node) || node === null) { 6320 domReferenceRef.current = node; 6321 setLocalDomReference(node); 6322 } 6323 if (isElement(position.refs.reference.current) || position.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to 6324 // `null` to support `positionReference` + an unstable `reference` 6325 // callback ref. 6326 node !== null && !isElement(node)) { 6327 position.refs.setReference(node); 6328 } 6329 }, [position.refs, setLocalDomReference]); 6330 const setFloating = React25.useCallback((node) => { 6331 setLocalFloatingElement(node); 6332 position.refs.setFloating(node); 6333 }, [position.refs]); 6334 const refs = React25.useMemo(() => ({ 6335 ...position.refs, 6336 setReference, 6337 setFloating, 6338 setPositionReference, 6339 domReference: domReferenceRef 6340 }), [position.refs, setReference, setFloating, setPositionReference]); 6341 const elements = React25.useMemo(() => ({ 6342 ...position.elements, 6343 domReference: domReferenceElement 6344 }), [position.elements, domReferenceElement]); 6345 const context = React25.useMemo(() => ({ 6346 ...position, 6347 dataRef: store2.context.dataRef, 6348 open, 6349 onOpenChange: store2.setOpen, 6350 events: store2.context.events, 6351 floatingId, 6352 refs, 6353 elements, 6354 nodeId, 6355 rootStore: store2 6356 }), [position, refs, elements, nodeId, store2, open, floatingId]); 6357 useIsoLayoutEffect(() => { 6358 if (domReferenceElement) { 6359 domReferenceRef.current = domReferenceElement; 6360 } 6361 }, [domReferenceElement]); 6362 useIsoLayoutEffect(() => { 6363 store2.context.dataRef.current.floatingContext = context; 6364 const node = tree?.nodesRef.current.find((n) => n.id === nodeId); 6365 if (node) { 6366 node.context = context; 6367 } 6368 }); 6369 return React25.useMemo(() => ({ 6370 ...position, 6371 context, 6372 refs, 6373 elements, 6374 rootStore: store2 6375 }), [position, refs, elements, context, store2]); 6376 } 6377 6378 // node_modules/@base-ui/react/floating-ui-react/hooks/useFocus.mjs 6379 var React26 = __toESM(require_react(), 1); 6380 var isMacSafari = parts_exports.os.mac && parts_exports.engine.webkit; 6381 function useFocus(context, props = {}) { 6382 const { 6383 enabled = true, 6384 delay 6385 } = props; 6386 const store2 = "rootStore" in context ? context.rootStore : context; 6387 const { 6388 events, 6389 dataRef 6390 } = store2.context; 6391 const blockFocusRef = React26.useRef(false); 6392 const blockedReferenceRef = React26.useRef(null); 6393 const keyboardModalityRef = React26.useRef(true); 6394 const timeout = useTimeout(); 6395 React26.useEffect(() => { 6396 const domReference = store2.select("domReferenceElement"); 6397 if (!enabled) { 6398 return void 0; 6399 } 6400 const win = getWindow(domReference); 6401 function onBlur() { 6402 const currentDomReference = store2.select("domReferenceElement"); 6403 if (!store2.select("open") && isHTMLElement(currentDomReference) && currentDomReference === activeElement(ownerDocument(currentDomReference))) { 6404 blockFocusRef.current = true; 6405 } 6406 } 6407 function onKeyDown() { 6408 keyboardModalityRef.current = true; 6409 } 6410 function onPointerDown() { 6411 keyboardModalityRef.current = false; 6412 } 6413 return mergeCleanups(addEventListener(win, "blur", onBlur), isMacSafari && addEventListener(win, "keydown", onKeyDown, true), isMacSafari && addEventListener(win, "pointerdown", onPointerDown, true)); 6414 }, [store2, enabled]); 6415 React26.useEffect(() => { 6416 if (!enabled) { 6417 return void 0; 6418 } 6419 function onOpenChangeLocal(details) { 6420 if (details.reason === reason_parts_exports.triggerPress || details.reason === reason_parts_exports.escapeKey) { 6421 const referenceElement = store2.select("domReferenceElement"); 6422 if (isElement(referenceElement)) { 6423 blockedReferenceRef.current = referenceElement; 6424 blockFocusRef.current = true; 6425 } 6426 } 6427 } 6428 events.on("openchange", onOpenChangeLocal); 6429 return () => { 6430 events.off("openchange", onOpenChangeLocal); 6431 }; 6432 }, [events, enabled, store2]); 6433 const reference = React26.useMemo(() => { 6434 function resetBlockedFocus() { 6435 blockFocusRef.current = false; 6436 blockedReferenceRef.current = null; 6437 } 6438 return { 6439 onMouseLeave() { 6440 resetBlockedFocus(); 6441 }, 6442 onFocus(event) { 6443 const focusTarget = event.currentTarget; 6444 if (blockFocusRef.current) { 6445 if (blockedReferenceRef.current === focusTarget) { 6446 return; 6447 } 6448 resetBlockedFocus(); 6449 } 6450 const target = getTarget(event.nativeEvent); 6451 if (isElement(target)) { 6452 if (isMacSafari && !event.relatedTarget) { 6453 if (!keyboardModalityRef.current && !isTypeableElement(target)) { 6454 return; 6455 } 6456 } else if (!matchesFocusVisible(target)) { 6457 return; 6458 } 6459 } 6460 const movedFromOtherEnabledTrigger = isTargetInsideEnabledTrigger(event.relatedTarget, store2.context.triggerElements); 6461 const { 6462 nativeEvent, 6463 currentTarget 6464 } = event; 6465 const delayValue = typeof delay === "function" ? delay() : delay; 6466 if (store2.select("open") && movedFromOtherEnabledTrigger || delayValue === 0 || delayValue === void 0) { 6467 store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget)); 6468 return; 6469 } 6470 timeout.start(delayValue, () => { 6471 if (blockFocusRef.current) { 6472 return; 6473 } 6474 store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget)); 6475 }); 6476 }, 6477 onBlur(event) { 6478 resetBlockedFocus(); 6479 const relatedTarget = event.relatedTarget; 6480 const nativeEvent = event.nativeEvent; 6481 const movedToFocusGuard = isElement(relatedTarget) && relatedTarget.hasAttribute(createAttribute("focus-guard")) && relatedTarget.getAttribute("data-type") === "outside"; 6482 timeout.start(0, () => { 6483 const domReference = store2.select("domReferenceElement"); 6484 const activeEl = activeElement(ownerDocument(domReference)); 6485 if (!relatedTarget && activeEl === domReference) { 6486 return; 6487 } 6488 if (contains(dataRef.current.floatingContext?.refs.floating.current, activeEl) || contains(domReference, activeEl) || movedToFocusGuard) { 6489 return; 6490 } 6491 const nextFocusedElement = relatedTarget ?? activeEl; 6492 if (isTargetInsideEnabledTrigger(nextFocusedElement, store2.context.triggerElements)) { 6493 return; 6494 } 6495 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent)); 6496 }); 6497 } 6498 }; 6499 }, [dataRef, delay, store2, timeout]); 6500 return React26.useMemo(() => enabled ? { 6501 reference, 6502 trigger: reference 6503 } : {}, [enabled, reference]); 6504 } 6505 6506 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverFloatingInteraction.mjs 6507 var React27 = __toESM(require_react(), 1); 6508 6509 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverInteractionSharedState.mjs 6510 var HoverInteraction = class _HoverInteraction { 6511 constructor() { 6512 this.pointerType = void 0; 6513 this.interactedInside = false; 6514 this.handler = void 0; 6515 this.blockMouseMove = true; 6516 this.performedPointerEventsMutation = false; 6517 this.pointerEventsScopeElement = null; 6518 this.pointerEventsReferenceElement = null; 6519 this.pointerEventsFloatingElement = null; 6520 this.restTimeoutPending = false; 6521 this.openChangeTimeout = new Timeout(); 6522 this.restTimeout = new Timeout(); 6523 this.handleCloseOptions = void 0; 6524 } 6525 static create() { 6526 return new _HoverInteraction(); 6527 } 6528 dispose = () => { 6529 this.openChangeTimeout.clear(); 6530 this.restTimeout.clear(); 6531 }; 6532 disposeEffect = () => { 6533 return this.dispose; 6534 }; 6535 }; 6536 var pointerEventsMutationOwnerByScopeElement = /* @__PURE__ */ new WeakMap(); 6537 function clearSafePolygonPointerEventsMutation(instance) { 6538 if (!instance.performedPointerEventsMutation) { 6539 return; 6540 } 6541 const scopeElement = instance.pointerEventsScopeElement; 6542 if (scopeElement && pointerEventsMutationOwnerByScopeElement.get(scopeElement) === instance) { 6543 instance.pointerEventsScopeElement?.style.removeProperty("pointer-events"); 6544 instance.pointerEventsReferenceElement?.style.removeProperty("pointer-events"); 6545 instance.pointerEventsFloatingElement?.style.removeProperty("pointer-events"); 6546 pointerEventsMutationOwnerByScopeElement.delete(scopeElement); 6547 } 6548 instance.performedPointerEventsMutation = false; 6549 instance.pointerEventsScopeElement = null; 6550 instance.pointerEventsReferenceElement = null; 6551 instance.pointerEventsFloatingElement = null; 6552 } 6553 function applySafePolygonPointerEventsMutation(instance, options) { 6554 const { 6555 scopeElement, 6556 referenceElement, 6557 floatingElement 6558 } = options; 6559 const existingOwner = pointerEventsMutationOwnerByScopeElement.get(scopeElement); 6560 if (existingOwner && existingOwner !== instance) { 6561 clearSafePolygonPointerEventsMutation(existingOwner); 6562 } 6563 clearSafePolygonPointerEventsMutation(instance); 6564 instance.performedPointerEventsMutation = true; 6565 instance.pointerEventsScopeElement = scopeElement; 6566 instance.pointerEventsReferenceElement = referenceElement; 6567 instance.pointerEventsFloatingElement = floatingElement; 6568 pointerEventsMutationOwnerByScopeElement.set(scopeElement, instance); 6569 scopeElement.style.pointerEvents = "none"; 6570 referenceElement.style.pointerEvents = "auto"; 6571 floatingElement.style.pointerEvents = "auto"; 6572 } 6573 function useHoverInteractionSharedState(store2) { 6574 const data = store2.context.dataRef.current; 6575 const instance = useRefWithInit(() => data.hoverInteractionState ?? HoverInteraction.create()).current; 6576 if (!data.hoverInteractionState) { 6577 data.hoverInteractionState = instance; 6578 } 6579 useOnMount(data.hoverInteractionState.disposeEffect); 6580 return data.hoverInteractionState; 6581 } 6582 6583 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverFloatingInteraction.mjs 6584 function useHoverFloatingInteraction(context, parameters = {}) { 6585 const { 6586 enabled = true, 6587 closeDelay: closeDelayProp = 0, 6588 nodeId: nodeIdProp 6589 } = parameters; 6590 const store2 = "rootStore" in context ? context.rootStore : context; 6591 const open = store2.useState("open"); 6592 const floatingElement = store2.useState("floatingElement"); 6593 const domReferenceElement = store2.useState("domReferenceElement"); 6594 const { 6595 dataRef 6596 } = store2.context; 6597 const tree = useFloatingTree(); 6598 const parentId = useFloatingParentNodeId(); 6599 const instance = useHoverInteractionSharedState(store2); 6600 const childClosedTimeout = useTimeout(); 6601 const isClickLikeOpenEvent2 = useStableCallback(() => { 6602 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside); 6603 }); 6604 const isHoverOpen = useStableCallback(() => { 6605 return isHoverOpenEvent(dataRef.current.openEvent?.type); 6606 }); 6607 const clearPointerEvents = useStableCallback(() => { 6608 clearSafePolygonPointerEventsMutation(instance); 6609 }); 6610 useIsoLayoutEffect(() => { 6611 if (!open) { 6612 instance.pointerType = void 0; 6613 instance.restTimeoutPending = false; 6614 instance.interactedInside = false; 6615 clearPointerEvents(); 6616 } 6617 }, [open, instance, clearPointerEvents]); 6618 React27.useEffect(() => { 6619 return clearPointerEvents; 6620 }, [clearPointerEvents]); 6621 useIsoLayoutEffect(() => { 6622 if (!enabled) { 6623 return void 0; 6624 } 6625 if (open && instance.handleCloseOptions?.blockPointerEvents && isHoverOpen() && isElement(domReferenceElement) && floatingElement) { 6626 const ref = domReferenceElement; 6627 const floatingEl = floatingElement; 6628 const doc = ownerDocument(floatingElement); 6629 const parentFloating = tree?.nodesRef.current.find((node) => node.id === parentId)?.context?.elements.floating; 6630 if (parentFloating) { 6631 parentFloating.style.pointerEvents = ""; 6632 } 6633 const cachedScopeElement = instance.pointerEventsScopeElement !== floatingEl ? instance.pointerEventsScopeElement : null; 6634 const parentScopeElement = parentFloating !== floatingEl ? parentFloating : null; 6635 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? cachedScopeElement ?? parentScopeElement ?? ref.closest("[data-rootownerid]") ?? doc.body; 6636 applySafePolygonPointerEventsMutation(instance, { 6637 scopeElement, 6638 referenceElement: ref, 6639 floatingElement: floatingEl 6640 }); 6641 return () => { 6642 clearPointerEvents(); 6643 }; 6644 } 6645 return void 0; 6646 }, [enabled, open, domReferenceElement, floatingElement, instance, isHoverOpen, tree, parentId, clearPointerEvents]); 6647 React27.useEffect(() => { 6648 if (!enabled) { 6649 return void 0; 6650 } 6651 function hasParentChildren() { 6652 return !!(tree && parentId && getNodeChildren(tree.nodesRef.current, parentId).length > 0); 6653 } 6654 function closeWithDelay(event) { 6655 const closeDelay = getDelay(closeDelayProp, "close", instance.pointerType); 6656 const close = () => { 6657 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event)); 6658 tree?.events.emit("floating.closed", event); 6659 }; 6660 if (closeDelay) { 6661 instance.openChangeTimeout.start(closeDelay, close); 6662 } else { 6663 instance.openChangeTimeout.clear(); 6664 close(); 6665 } 6666 } 6667 function handleInteractInside(event) { 6668 const target = getTarget(event); 6669 if (!isInteractiveElement(target)) { 6670 instance.interactedInside = false; 6671 return; 6672 } 6673 instance.interactedInside = target?.closest("[aria-haspopup]") != null; 6674 } 6675 function onFloatingMouseEnter() { 6676 instance.openChangeTimeout.clear(); 6677 childClosedTimeout.clear(); 6678 tree?.events.off("floating.closed", onNodeClosed); 6679 clearPointerEvents(); 6680 } 6681 function onFloatingMouseLeave(event) { 6682 if (hasParentChildren() && tree) { 6683 tree.events.on("floating.closed", onNodeClosed); 6684 return; 6685 } 6686 if (isTargetInsideEnabledTrigger(event.relatedTarget, store2.context.triggerElements)) { 6687 return; 6688 } 6689 const currentNodeId = dataRef.current.floatingContext?.nodeId ?? nodeIdProp; 6690 const relatedTarget = event.relatedTarget; 6691 const isMovingIntoDescendantFloating = tree && currentNodeId && isElement(relatedTarget) && getNodeChildren(tree.nodesRef.current, currentNodeId, false).some((node) => contains(node.context?.elements.floating, relatedTarget)); 6692 if (isMovingIntoDescendantFloating) { 6693 return; 6694 } 6695 if (instance.handler) { 6696 instance.handler(event); 6697 return; 6698 } 6699 clearPointerEvents(); 6700 if (isHoverOpen() && !isClickLikeOpenEvent2()) { 6701 closeWithDelay(event); 6702 } 6703 } 6704 function onNodeClosed(event) { 6705 if (!tree || !parentId || hasParentChildren()) { 6706 return; 6707 } 6708 childClosedTimeout.start(0, () => { 6709 tree.events.off("floating.closed", onNodeClosed); 6710 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event)); 6711 tree.events.emit("floating.closed", event); 6712 }); 6713 } 6714 const floating = floatingElement; 6715 return mergeCleanups(floating && addEventListener(floating, "mouseenter", onFloatingMouseEnter), floating && addEventListener(floating, "mouseleave", onFloatingMouseLeave), floating && addEventListener(floating, "pointerdown", handleInteractInside, true), () => { 6716 tree?.events.off("floating.closed", onNodeClosed); 6717 }); 6718 }, [enabled, floatingElement, store2, dataRef, closeDelayProp, nodeIdProp, isHoverOpen, isClickLikeOpenEvent2, clearPointerEvents, instance, tree, parentId, childClosedTimeout]); 6719 } 6720 6721 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverReferenceInteraction.mjs 6722 var React28 = __toESM(require_react(), 1); 6723 var ReactDOM5 = __toESM(require_react_dom(), 1); 6724 var EMPTY_REF = { 6725 current: null 6726 }; 6727 function useHoverReferenceInteraction(context, props = {}) { 6728 const { 6729 enabled = true, 6730 delay = 0, 6731 handleClose = null, 6732 mouseOnly = false, 6733 restMs = 0, 6734 move = true, 6735 triggerElementRef = EMPTY_REF, 6736 externalTree, 6737 isActiveTrigger = true, 6738 getHandleCloseContext, 6739 isClosing, 6740 shouldOpen: shouldOpenProp 6741 } = props; 6742 const store2 = "rootStore" in context ? context.rootStore : context; 6743 const { 6744 dataRef, 6745 events 6746 } = store2.context; 6747 const tree = useFloatingTree(externalTree); 6748 const instance = useHoverInteractionSharedState(store2); 6749 const isHoverCloseActiveRef = React28.useRef(false); 6750 const handleCloseRef = useValueAsRef(handleClose); 6751 const delayRef = useValueAsRef(delay); 6752 const restMsRef = useValueAsRef(restMs); 6753 const enabledRef = useValueAsRef(enabled); 6754 const shouldOpenRef = useValueAsRef(shouldOpenProp); 6755 const isClosingRef = useValueAsRef(isClosing); 6756 const isClickLikeOpenEvent2 = useStableCallback(() => { 6757 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside); 6758 }); 6759 const checkShouldOpen = useStableCallback(() => { 6760 return shouldOpenRef.current?.() !== false; 6761 }); 6762 const isOverInactiveTrigger = useStableCallback((currentDomReference, currentTarget, target) => { 6763 const allTriggers = store2.context.triggerElements; 6764 if (allTriggers.hasElement(currentTarget)) { 6765 return !currentDomReference || !contains(currentDomReference, currentTarget); 6766 } 6767 if (!isElement(target)) { 6768 return false; 6769 } 6770 const targetElement = target; 6771 return allTriggers.hasMatchingElement((trigger) => contains(trigger, targetElement)) && (!currentDomReference || !contains(currentDomReference, targetElement)); 6772 }); 6773 const cleanupMouseMoveHandler = useStableCallback(() => { 6774 if (!instance.handler) { 6775 return; 6776 } 6777 const doc = ownerDocument(store2.select("domReferenceElement")); 6778 doc.removeEventListener("mousemove", instance.handler); 6779 instance.handler = void 0; 6780 }); 6781 const clearPointerEvents = useStableCallback(() => { 6782 clearSafePolygonPointerEventsMutation(instance); 6783 }); 6784 if (isActiveTrigger) { 6785 instance.handleCloseOptions = handleCloseRef.current?.__options; 6786 } 6787 React28.useEffect(() => cleanupMouseMoveHandler, [cleanupMouseMoveHandler]); 6788 React28.useEffect(() => { 6789 if (!enabled) { 6790 return void 0; 6791 } 6792 function onOpenChangeLocal(details) { 6793 if (!details.open) { 6794 isHoverCloseActiveRef.current = details.reason === reason_parts_exports.triggerHover; 6795 cleanupMouseMoveHandler(); 6796 instance.openChangeTimeout.clear(); 6797 instance.restTimeout.clear(); 6798 instance.blockMouseMove = true; 6799 instance.restTimeoutPending = false; 6800 } else { 6801 isHoverCloseActiveRef.current = false; 6802 } 6803 } 6804 events.on("openchange", onOpenChangeLocal); 6805 return () => { 6806 events.off("openchange", onOpenChangeLocal); 6807 }; 6808 }, [enabled, events, instance, cleanupMouseMoveHandler]); 6809 React28.useEffect(() => { 6810 if (!enabled) { 6811 return void 0; 6812 } 6813 function closeWithDelay(event, runElseBranch = true) { 6814 const closeDelay = getDelay(delayRef.current, "close", instance.pointerType); 6815 if (closeDelay) { 6816 instance.openChangeTimeout.start(closeDelay, () => { 6817 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event)); 6818 tree?.events.emit("floating.closed", event); 6819 }); 6820 } else if (runElseBranch) { 6821 instance.openChangeTimeout.clear(); 6822 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event)); 6823 tree?.events.emit("floating.closed", event); 6824 } 6825 } 6826 const trigger = triggerElementRef.current ?? (isActiveTrigger ? store2.select("domReferenceElement") : null); 6827 if (!isElement(trigger)) { 6828 return void 0; 6829 } 6830 function onMouseEnter(event) { 6831 instance.openChangeTimeout.clear(); 6832 instance.blockMouseMove = false; 6833 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) { 6834 return; 6835 } 6836 const restMsValue = getRestMs(restMsRef.current); 6837 const openDelay = getDelay(delayRef.current, "open", instance.pointerType); 6838 const eventTarget = getTarget(event); 6839 const currentTarget = event.currentTarget ?? null; 6840 const currentDomReference = store2.select("domReferenceElement"); 6841 let triggerNode = currentTarget; 6842 if (isElement(eventTarget) && !store2.context.triggerElements.hasElement(eventTarget)) { 6843 for (const triggerElement of store2.context.triggerElements.elements()) { 6844 if (contains(triggerElement, eventTarget)) { 6845 triggerNode = triggerElement; 6846 break; 6847 } 6848 } 6849 } 6850 if (isElement(currentTarget) && isElement(currentDomReference) && !store2.context.triggerElements.hasElement(currentTarget) && contains(currentTarget, currentDomReference)) { 6851 triggerNode = currentDomReference; 6852 } 6853 const isOverInactive = triggerNode == null ? false : isOverInactiveTrigger(currentDomReference, triggerNode, eventTarget); 6854 const isOpen = store2.select("open"); 6855 const isInClosingTransition = isClosingRef.current?.() ?? store2.select("transitionStatus") === "ending"; 6856 const isHoverCloseTransition = !isOpen && isInClosingTransition && isHoverCloseActiveRef.current; 6857 const isReenteringSameTriggerDuringCloseTransition = !isOverInactive && isElement(triggerNode) && isElement(currentDomReference) && contains(currentDomReference, triggerNode) && isHoverCloseTransition; 6858 const isRestOnlyDelay = restMsValue > 0 && !openDelay; 6859 const shouldOpenImmediately = isOverInactive && (isOpen || isHoverCloseTransition) || isReenteringSameTriggerDuringCloseTransition; 6860 const shouldOpen = !isOpen || isOverInactive; 6861 if (shouldOpenImmediately) { 6862 if (checkShouldOpen()) { 6863 store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode)); 6864 } 6865 return; 6866 } 6867 if (isRestOnlyDelay) { 6868 return; 6869 } 6870 if (openDelay) { 6871 instance.openChangeTimeout.start(openDelay, () => { 6872 if (shouldOpen && checkShouldOpen()) { 6873 store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode)); 6874 } 6875 }); 6876 } else if (shouldOpen) { 6877 if (checkShouldOpen()) { 6878 store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode)); 6879 } 6880 } 6881 } 6882 function onMouseLeave(event) { 6883 if (isClickLikeOpenEvent2()) { 6884 clearPointerEvents(); 6885 return; 6886 } 6887 cleanupMouseMoveHandler(); 6888 const domReferenceElement = store2.select("domReferenceElement"); 6889 const doc = ownerDocument(domReferenceElement); 6890 instance.restTimeout.clear(); 6891 instance.restTimeoutPending = false; 6892 const handleCloseContextBase = dataRef.current.floatingContext ?? getHandleCloseContext?.(); 6893 if (isTargetInsideEnabledTrigger(event.relatedTarget, store2.context.triggerElements)) { 6894 return; 6895 } 6896 if (handleCloseRef.current && handleCloseContextBase) { 6897 if (!store2.select("open")) { 6898 instance.openChangeTimeout.clear(); 6899 } 6900 const currentTrigger = triggerElementRef.current; 6901 instance.handler = handleCloseRef.current({ 6902 ...handleCloseContextBase, 6903 tree, 6904 x: event.clientX, 6905 y: event.clientY, 6906 onClose() { 6907 clearPointerEvents(); 6908 cleanupMouseMoveHandler(); 6909 if (enabledRef.current && !isClickLikeOpenEvent2() && currentTrigger === store2.select("domReferenceElement")) { 6910 closeWithDelay(event, true); 6911 } 6912 } 6913 }); 6914 doc.addEventListener("mousemove", instance.handler); 6915 instance.handler(event); 6916 return; 6917 } 6918 const shouldClose = instance.pointerType === "touch" ? !contains(store2.select("floatingElement"), event.relatedTarget) : true; 6919 if (shouldClose) { 6920 closeWithDelay(event); 6921 } 6922 } 6923 if (move) { 6924 return mergeCleanups(addEventListener(trigger, "mousemove", onMouseEnter, { 6925 once: true 6926 }), addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave)); 6927 } 6928 return mergeCleanups(addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave)); 6929 }, [cleanupMouseMoveHandler, clearPointerEvents, dataRef, delayRef, store2, enabled, handleCloseRef, instance, isActiveTrigger, isOverInactiveTrigger, isClickLikeOpenEvent2, mouseOnly, move, restMsRef, triggerElementRef, tree, enabledRef, getHandleCloseContext, isClosingRef, checkShouldOpen]); 6930 return React28.useMemo(() => { 6931 if (!enabled) { 6932 return void 0; 6933 } 6934 function setPointerRef(event) { 6935 instance.pointerType = event.pointerType; 6936 } 6937 return { 6938 onPointerDown: setPointerRef, 6939 onPointerEnter: setPointerRef, 6940 onMouseMove(event) { 6941 const { 6942 nativeEvent 6943 } = event; 6944 const trigger = event.currentTarget; 6945 const currentDomReference = store2.select("domReferenceElement"); 6946 const currentOpen = store2.select("open"); 6947 const isOverInactive = isOverInactiveTrigger(currentDomReference, trigger, event.target); 6948 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) { 6949 return; 6950 } 6951 if (currentOpen && isOverInactive && instance.handleCloseOptions?.blockPointerEvents) { 6952 const floatingElement = store2.select("floatingElement"); 6953 if (floatingElement) { 6954 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? trigger.ownerDocument.body; 6955 applySafePolygonPointerEventsMutation(instance, { 6956 scopeElement, 6957 referenceElement: trigger, 6958 floatingElement 6959 }); 6960 } 6961 } 6962 const restMsValue = getRestMs(restMsRef.current); 6963 if (currentOpen && !isOverInactive || restMsValue === 0) { 6964 return; 6965 } 6966 if (!isOverInactive && instance.restTimeoutPending && event.movementX ** 2 + event.movementY ** 2 < 2) { 6967 return; 6968 } 6969 instance.restTimeout.clear(); 6970 function handleMouseMove() { 6971 instance.restTimeoutPending = false; 6972 if (isClickLikeOpenEvent2()) { 6973 return; 6974 } 6975 const latestOpen = store2.select("open"); 6976 if (!instance.blockMouseMove && (!latestOpen || isOverInactive) && checkShouldOpen()) { 6977 store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, nativeEvent, trigger)); 6978 } 6979 } 6980 if (instance.pointerType === "touch") { 6981 ReactDOM5.flushSync(() => { 6982 handleMouseMove(); 6983 }); 6984 } else if (isOverInactive && currentOpen) { 6985 handleMouseMove(); 6986 } else { 6987 instance.restTimeoutPending = true; 6988 instance.restTimeout.start(restMsValue, handleMouseMove); 6989 } 6990 } 6991 }; 6992 }, [enabled, instance, isClickLikeOpenEvent2, isOverInactiveTrigger, mouseOnly, store2, restMsRef, checkShouldOpen]); 6993 } 6994 6995 // node_modules/@base-ui/react/floating-ui-react/safePolygon.mjs 6996 var CURSOR_SPEED_THRESHOLD = 0.1; 6997 var CURSOR_SPEED_THRESHOLD_SQUARED = CURSOR_SPEED_THRESHOLD * CURSOR_SPEED_THRESHOLD; 6998 var POLYGON_BUFFER = 0.5; 6999 function hasIntersectingEdge(pointX, pointY, xi, yi, xj, yj) { 7000 return yi >= pointY !== yj >= pointY && pointX <= (xj - xi) * (pointY - yi) / (yj - yi) + xi; 7001 } 7002 function isPointInQuadrilateral(pointX, pointY, x1, y1, x2, y2, x3, y3, x4, y4) { 7003 let isInsideValue = false; 7004 if (hasIntersectingEdge(pointX, pointY, x1, y1, x2, y2)) { 7005 isInsideValue = !isInsideValue; 7006 } 7007 if (hasIntersectingEdge(pointX, pointY, x2, y2, x3, y3)) { 7008 isInsideValue = !isInsideValue; 7009 } 7010 if (hasIntersectingEdge(pointX, pointY, x3, y3, x4, y4)) { 7011 isInsideValue = !isInsideValue; 7012 } 7013 if (hasIntersectingEdge(pointX, pointY, x4, y4, x1, y1)) { 7014 isInsideValue = !isInsideValue; 7015 } 7016 return isInsideValue; 7017 } 7018 function isInsideRect(pointX, pointY, rect) { 7019 return pointX >= rect.x && pointX <= rect.x + rect.width && pointY >= rect.y && pointY <= rect.y + rect.height; 7020 } 7021 function isInsideAxisAlignedRect(pointX, pointY, x1, y1, x2, y2) { 7022 const minX = Math.min(x1, x2); 7023 const maxX = Math.max(x1, x2); 7024 const minY = Math.min(y1, y2); 7025 const maxY = Math.max(y1, y2); 7026 return pointX >= minX && pointX <= maxX && pointY >= minY && pointY <= maxY; 7027 } 7028 function safePolygon(options = {}) { 7029 const { 7030 blockPointerEvents = false 7031 } = options; 7032 const timeout = new Timeout(); 7033 const fn = ({ 7034 x, 7035 y, 7036 placement, 7037 elements, 7038 onClose, 7039 nodeId, 7040 tree 7041 }) => { 7042 const side = placement?.split("-")[0]; 7043 let hasLanded = false; 7044 let lastX = null; 7045 let lastY = null; 7046 let lastCursorTime = typeof performance !== "undefined" ? performance.now() : 0; 7047 function isCursorMovingSlowly(nextX, nextY) { 7048 const currentTime = performance.now(); 7049 const elapsedTime = currentTime - lastCursorTime; 7050 if (lastX === null || lastY === null || elapsedTime === 0) { 7051 lastX = nextX; 7052 lastY = nextY; 7053 lastCursorTime = currentTime; 7054 return false; 7055 } 7056 const deltaX = nextX - lastX; 7057 const deltaY = nextY - lastY; 7058 const distanceSquared = deltaX * deltaX + deltaY * deltaY; 7059 const thresholdSquared = elapsedTime * elapsedTime * CURSOR_SPEED_THRESHOLD_SQUARED; 7060 lastX = nextX; 7061 lastY = nextY; 7062 lastCursorTime = currentTime; 7063 return distanceSquared < thresholdSquared; 7064 } 7065 function close() { 7066 timeout.clear(); 7067 onClose(); 7068 } 7069 return function onMouseMove(event) { 7070 timeout.clear(); 7071 const domReference = elements.domReference; 7072 const floating = elements.floating; 7073 if (!domReference || !floating || side == null || x == null || y == null) { 7074 return void 0; 7075 } 7076 const { 7077 clientX, 7078 clientY 7079 } = event; 7080 const target = getTarget(event); 7081 const isLeave = event.type === "mouseleave"; 7082 const isOverFloatingEl = contains(floating, target); 7083 const isOverReferenceEl = contains(domReference, target); 7084 if (isOverFloatingEl) { 7085 hasLanded = true; 7086 if (!isLeave) { 7087 return void 0; 7088 } 7089 } 7090 if (isOverReferenceEl) { 7091 hasLanded = false; 7092 if (!isLeave) { 7093 hasLanded = true; 7094 return void 0; 7095 } 7096 } 7097 if (isLeave && isElement(event.relatedTarget) && contains(floating, event.relatedTarget)) { 7098 return void 0; 7099 } 7100 function hasOpenChildNode() { 7101 return Boolean(tree && getNodeChildren(tree.nodesRef.current, nodeId).length > 0); 7102 } 7103 function closeIfNoOpenChild() { 7104 if (!hasOpenChildNode()) { 7105 close(); 7106 } 7107 } 7108 if (hasOpenChildNode()) { 7109 return void 0; 7110 } 7111 const refRect = domReference.getBoundingClientRect(); 7112 const rect = floating.getBoundingClientRect(); 7113 const cursorLeaveFromRight = x > rect.right - rect.width / 2; 7114 const cursorLeaveFromBottom = y > rect.bottom - rect.height / 2; 7115 const isFloatingWider = rect.width > refRect.width; 7116 const isFloatingTaller = rect.height > refRect.height; 7117 const left = (isFloatingWider ? refRect : rect).left; 7118 const right = (isFloatingWider ? refRect : rect).right; 7119 const top = (isFloatingTaller ? refRect : rect).top; 7120 const bottom = (isFloatingTaller ? refRect : rect).bottom; 7121 if (side === "top" && y >= refRect.bottom - 1 || side === "bottom" && y <= refRect.top + 1 || side === "left" && x >= refRect.right - 1 || side === "right" && x <= refRect.left + 1) { 7122 closeIfNoOpenChild(); 7123 return void 0; 7124 } 7125 let isInsideTroughRect = false; 7126 switch (side) { 7127 case "top": 7128 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, refRect.top + 1, right, rect.bottom - 1); 7129 break; 7130 case "bottom": 7131 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, rect.top + 1, right, refRect.bottom - 1); 7132 break; 7133 case "left": 7134 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, rect.right - 1, bottom, refRect.left + 1, top); 7135 break; 7136 case "right": 7137 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, refRect.right - 1, bottom, rect.left + 1, top); 7138 break; 7139 default: 7140 } 7141 if (isInsideTroughRect) { 7142 return void 0; 7143 } 7144 if (hasLanded && !isInsideRect(clientX, clientY, refRect)) { 7145 closeIfNoOpenChild(); 7146 return void 0; 7147 } 7148 if (!isLeave && isCursorMovingSlowly(clientX, clientY)) { 7149 closeIfNoOpenChild(); 7150 return void 0; 7151 } 7152 let isInsidePolygon = false; 7153 switch (side) { 7154 case "top": { 7155 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4; 7156 const cursorPointOneX = isFloatingWider ? x + cursorXOffset : cursorLeaveFromRight ? x + cursorXOffset : x - cursorXOffset; 7157 const cursorPointTwoX = isFloatingWider ? x - cursorXOffset : cursorLeaveFromRight ? x + cursorXOffset : x - cursorXOffset; 7158 const cursorPointY = y + POLYGON_BUFFER + 1; 7159 const commonYLeft = cursorLeaveFromRight ? rect.bottom - POLYGON_BUFFER : isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top; 7160 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top : rect.bottom - POLYGON_BUFFER; 7161 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight); 7162 break; 7163 } 7164 case "bottom": { 7165 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4; 7166 const cursorPointOneX = isFloatingWider ? x + cursorXOffset : cursorLeaveFromRight ? x + cursorXOffset : x - cursorXOffset; 7167 const cursorPointTwoX = isFloatingWider ? x - cursorXOffset : cursorLeaveFromRight ? x + cursorXOffset : x - cursorXOffset; 7168 const cursorPointY = y - POLYGON_BUFFER; 7169 const commonYLeft = cursorLeaveFromRight ? rect.top + POLYGON_BUFFER : isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom; 7170 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom : rect.top + POLYGON_BUFFER; 7171 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight); 7172 break; 7173 } 7174 case "left": { 7175 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4; 7176 const cursorPointOneY = isFloatingTaller ? y + cursorYOffset : cursorLeaveFromBottom ? y + cursorYOffset : y - cursorYOffset; 7177 const cursorPointTwoY = isFloatingTaller ? y - cursorYOffset : cursorLeaveFromBottom ? y + cursorYOffset : y - cursorYOffset; 7178 const cursorPointX = x + POLYGON_BUFFER + 1; 7179 const commonXTop = cursorLeaveFromBottom ? rect.right - POLYGON_BUFFER : isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left; 7180 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left : rect.right - POLYGON_BUFFER; 7181 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, commonXTop, rect.top, commonXBottom, rect.bottom, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY); 7182 break; 7183 } 7184 case "right": { 7185 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4; 7186 const cursorPointOneY = isFloatingTaller ? y + cursorYOffset : cursorLeaveFromBottom ? y + cursorYOffset : y - cursorYOffset; 7187 const cursorPointTwoY = isFloatingTaller ? y - cursorYOffset : cursorLeaveFromBottom ? y + cursorYOffset : y - cursorYOffset; 7188 const cursorPointX = x - POLYGON_BUFFER; 7189 const commonXTop = cursorLeaveFromBottom ? rect.left + POLYGON_BUFFER : isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right; 7190 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right : rect.left + POLYGON_BUFFER; 7191 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY, commonXTop, rect.top, commonXBottom, rect.bottom); 7192 break; 7193 } 7194 default: 7195 } 7196 if (!isInsidePolygon) { 7197 closeIfNoOpenChild(); 7198 } else if (!hasLanded) { 7199 timeout.start(40, closeIfNoOpenChild); 7200 } 7201 return void 0; 7202 }; 7203 }; 7204 fn.__options = { 7205 ...options, 7206 blockPointerEvents 7207 }; 7208 return fn; 7209 } 7210 7211 // node_modules/@base-ui/react/utils/popupStateMapping.mjs 7212 var CommonPopupDataAttributes = (function(CommonPopupDataAttributes2) { 7213 CommonPopupDataAttributes2["open"] = "data-open"; 7214 CommonPopupDataAttributes2["closed"] = "data-closed"; 7215 CommonPopupDataAttributes2[CommonPopupDataAttributes2["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle"; 7216 CommonPopupDataAttributes2[CommonPopupDataAttributes2["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle"; 7217 CommonPopupDataAttributes2["anchorHidden"] = "data-anchor-hidden"; 7218 CommonPopupDataAttributes2["side"] = "data-side"; 7219 CommonPopupDataAttributes2["align"] = "data-align"; 7220 return CommonPopupDataAttributes2; 7221 })({}); 7222 var CommonTriggerDataAttributes = /* @__PURE__ */ (function(CommonTriggerDataAttributes2) { 7223 CommonTriggerDataAttributes2["popupOpen"] = "data-popup-open"; 7224 CommonTriggerDataAttributes2["pressed"] = "data-pressed"; 7225 return CommonTriggerDataAttributes2; 7226 })({}); 7227 var TRIGGER_HOOK = { 7228 [CommonTriggerDataAttributes.popupOpen]: "" 7229 }; 7230 var PRESSABLE_TRIGGER_HOOK = { 7231 [CommonTriggerDataAttributes.popupOpen]: "", 7232 [CommonTriggerDataAttributes.pressed]: "" 7233 }; 7234 var POPUP_OPEN_HOOK = { 7235 [CommonPopupDataAttributes.open]: "" 7236 }; 7237 var POPUP_CLOSED_HOOK = { 7238 [CommonPopupDataAttributes.closed]: "" 7239 }; 7240 var ANCHOR_HIDDEN_HOOK = { 7241 [CommonPopupDataAttributes.anchorHidden]: "" 7242 }; 7243 var triggerOpenStateMapping = { 7244 open(value) { 7245 if (value) { 7246 return TRIGGER_HOOK; 7247 } 7248 return null; 7249 } 7250 }; 7251 var popupStateMapping = { 7252 open(value) { 7253 if (value) { 7254 return POPUP_OPEN_HOOK; 7255 } 7256 return POPUP_CLOSED_HOOK; 7257 }, 7258 anchorHidden(value) { 7259 if (value) { 7260 return ANCHOR_HIDDEN_HOOK; 7261 } 7262 return null; 7263 } 7264 }; 7265 7266 // node_modules/@base-ui/utils/inertValue.mjs 7267 function inertValue(value) { 7268 if (isReactVersionAtLeast(19)) { 7269 return value; 7270 } 7271 return value ? "true" : void 0; 7272 } 7273 7274 // node_modules/@base-ui/react/utils/useAnchorPositioning.mjs 7275 var React29 = __toESM(require_react(), 1); 7276 7277 // node_modules/@base-ui/react/floating-ui-react/middleware/arrow.mjs 7278 var baseArrow = (options) => ({ 7279 name: "arrow", 7280 options, 7281 async fn(state) { 7282 const { 7283 x, 7284 y, 7285 placement, 7286 rects, 7287 platform: platform3, 7288 elements, 7289 middlewareData 7290 } = state; 7291 const { 7292 element, 7293 padding = 0, 7294 offsetParent = "real" 7295 } = evaluate(options, state) || {}; 7296 if (element == null) { 7297 return {}; 7298 } 7299 const paddingObject = getPaddingObject(padding); 7300 const coords = { 7301 x, 7302 y 7303 }; 7304 const axis = getAlignmentAxis(placement); 7305 const length = getAxisLength(axis); 7306 const arrowDimensions = await platform3.getDimensions(element); 7307 const isYAxis = axis === "y"; 7308 const minProp = isYAxis ? "top" : "left"; 7309 const maxProp = isYAxis ? "bottom" : "right"; 7310 const clientProp = isYAxis ? "clientHeight" : "clientWidth"; 7311 const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length]; 7312 const startDiff = coords[axis] - rects.reference[axis]; 7313 const arrowOffsetParent = offsetParent === "real" ? await platform3.getOffsetParent?.(element) : elements.floating; 7314 let clientSize = elements.floating[clientProp] || rects.floating[length]; 7315 if (!clientSize || !await platform3.isElement?.(arrowOffsetParent)) { 7316 clientSize = elements.floating[clientProp] || rects.floating[length]; 7317 } 7318 const centerToReference = endDiff / 2 - startDiff / 2; 7319 const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1; 7320 const minPadding = Math.min(paddingObject[minProp], largestPossiblePadding); 7321 const maxPadding = Math.min(paddingObject[maxProp], largestPossiblePadding); 7322 const min2 = minPadding; 7323 const max2 = clientSize - arrowDimensions[length] - maxPadding; 7324 const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference; 7325 const offset4 = clamp(min2, center, max2); 7326 const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset4 && rects.reference[length] / 2 - (center < min2 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0; 7327 const alignmentOffset = shouldAddOffset ? center < min2 ? center - min2 : center - max2 : 0; 7328 return { 7329 [axis]: coords[axis] + alignmentOffset, 7330 data: { 7331 [axis]: offset4, 7332 centerOffset: center - offset4 - alignmentOffset, 7333 ...shouldAddOffset && { 7334 alignmentOffset 7335 } 7336 }, 7337 reset: shouldAddOffset 7338 }; 7339 } 7340 }); 7341 var arrow4 = (options, deps) => ({ 7342 ...baseArrow(options), 7343 options: [options, deps] 7344 }); 7345 7346 // node_modules/@base-ui/react/utils/hideMiddleware.mjs 7347 var nativeHideFn = hide3().fn; 7348 var hide4 = { 7349 name: "hide", 7350 async fn(state) { 7351 const { 7352 width, 7353 height, 7354 x, 7355 y 7356 } = state.rects.reference; 7357 const anchorHidden = width === 0 && height === 0 && x === 0 && y === 0; 7358 const nativeHideResult = await nativeHideFn(state); 7359 return { 7360 data: { 7361 referenceHidden: nativeHideResult.data?.referenceHidden || anchorHidden 7362 } 7363 }; 7364 } 7365 }; 7366 7367 // node_modules/@base-ui/react/utils/adaptiveOriginMiddleware.mjs 7368 var DEFAULT_SIDES = { 7369 sideX: "left", 7370 sideY: "top" 7371 }; 7372 var adaptiveOrigin = { 7373 name: "adaptiveOrigin", 7374 async fn(state) { 7375 const { 7376 x: rawX, 7377 y: rawY, 7378 rects: { 7379 floating: floatRect 7380 }, 7381 elements: { 7382 floating 7383 }, 7384 platform: platform3, 7385 strategy, 7386 placement 7387 } = state; 7388 const win = getWindow(floating); 7389 const styles = win.getComputedStyle(floating); 7390 const hasTransition = styles.transitionDuration !== "0s" && styles.transitionDuration !== ""; 7391 if (!hasTransition) { 7392 return { 7393 x: rawX, 7394 y: rawY, 7395 data: DEFAULT_SIDES 7396 }; 7397 } 7398 const offsetParent = await platform3.getOffsetParent?.(floating); 7399 let offsetDimensions = { 7400 width: 0, 7401 height: 0 7402 }; 7403 if (strategy === "fixed" && win?.visualViewport) { 7404 offsetDimensions = { 7405 width: win.visualViewport.width, 7406 height: win.visualViewport.height 7407 }; 7408 } else if (offsetParent === win) { 7409 const doc = ownerDocument(floating); 7410 offsetDimensions = { 7411 width: doc.documentElement.clientWidth, 7412 height: doc.documentElement.clientHeight 7413 }; 7414 } else if (await platform3.isElement?.(offsetParent)) { 7415 offsetDimensions = await platform3.getDimensions(offsetParent); 7416 } 7417 const currentSide = getSide(placement); 7418 let x = rawX; 7419 let y = rawY; 7420 if (currentSide === "left") { 7421 x = offsetDimensions.width - (rawX + floatRect.width); 7422 } 7423 if (currentSide === "top") { 7424 y = offsetDimensions.height - (rawY + floatRect.height); 7425 } 7426 const sideX = currentSide === "left" ? "right" : DEFAULT_SIDES.sideX; 7427 const sideY = currentSide === "top" ? "bottom" : DEFAULT_SIDES.sideY; 7428 return { 7429 x, 7430 y, 7431 data: { 7432 sideX, 7433 sideY 7434 } 7435 }; 7436 } 7437 }; 7438 7439 // node_modules/@base-ui/react/utils/useAnchorPositioning.mjs 7440 function getLogicalSide(sideParam, renderedSide, isRtl) { 7441 const isLogicalSideParam = sideParam === "inline-start" || sideParam === "inline-end"; 7442 const logicalRight = isRtl ? "inline-start" : "inline-end"; 7443 const logicalLeft = isRtl ? "inline-end" : "inline-start"; 7444 return { 7445 top: "top", 7446 right: isLogicalSideParam ? logicalRight : "right", 7447 bottom: "bottom", 7448 left: isLogicalSideParam ? logicalLeft : "left" 7449 }[renderedSide]; 7450 } 7451 function getOffsetData(state, sideParam, isRtl) { 7452 const { 7453 rects, 7454 placement 7455 } = state; 7456 const data = { 7457 side: getLogicalSide(sideParam, getSide(placement), isRtl), 7458 align: getAlignment(placement) || "center", 7459 anchor: { 7460 width: rects.reference.width, 7461 height: rects.reference.height 7462 }, 7463 positioner: { 7464 width: rects.floating.width, 7465 height: rects.floating.height 7466 } 7467 }; 7468 return data; 7469 } 7470 function useAnchorPositioning(params) { 7471 const { 7472 // Public parameters 7473 anchor, 7474 positionMethod = "absolute", 7475 side: sideParam = "bottom", 7476 sideOffset = 0, 7477 align = "center", 7478 alignOffset = 0, 7479 collisionBoundary, 7480 collisionPadding: collisionPaddingParam = 5, 7481 sticky = false, 7482 arrowPadding = 5, 7483 disableAnchorTracking = false, 7484 inline: inlineMiddleware, 7485 // Private parameters 7486 keepMounted = false, 7487 floatingRootContext, 7488 mounted, 7489 collisionAvoidance, 7490 shiftCrossAxis = false, 7491 nodeId, 7492 adaptiveOrigin: adaptiveOrigin2, 7493 lazyFlip = false, 7494 externalTree 7495 } = params; 7496 const [mountSide, setMountSide] = React29.useState(null); 7497 if (!mounted && mountSide !== null) { 7498 setMountSide(null); 7499 } 7500 const collisionAvoidanceSide = collisionAvoidance.side || "flip"; 7501 const collisionAvoidanceAlign = collisionAvoidance.align || "flip"; 7502 const collisionAvoidanceFallbackAxisSide = collisionAvoidance.fallbackAxisSide || "end"; 7503 const anchorFn = typeof anchor === "function" ? anchor : void 0; 7504 const anchorFnCallback = useStableCallback(anchorFn); 7505 const anchorDep = anchorFn ? anchorFnCallback : anchor; 7506 const anchorValueRef = useValueAsRef(anchor); 7507 const mountedRef = useValueAsRef(mounted); 7508 const direction = useDirection(); 7509 const isRtl = direction === "rtl"; 7510 const side = mountSide || { 7511 top: "top", 7512 right: "right", 7513 bottom: "bottom", 7514 left: "left", 7515 "inline-end": isRtl ? "left" : "right", 7516 "inline-start": isRtl ? "right" : "left" 7517 }[sideParam]; 7518 const placement = align === "center" ? side : `$side}-$align}`; 7519 let collisionPadding = collisionPaddingParam; 7520 const bias = 1; 7521 const biasTop = sideParam === "bottom" ? bias : 0; 7522 const biasBottom = sideParam === "top" ? bias : 0; 7523 const biasLeft = sideParam === "right" ? bias : 0; 7524 const biasRight = sideParam === "left" ? bias : 0; 7525 if (typeof collisionPadding === "number") { 7526 collisionPadding = { 7527 top: collisionPadding + biasTop, 7528 right: collisionPadding + biasRight, 7529 bottom: collisionPadding + biasBottom, 7530 left: collisionPadding + biasLeft 7531 }; 7532 } else if (collisionPadding) { 7533 collisionPadding = { 7534 top: (collisionPadding.top || 0) + biasTop, 7535 right: (collisionPadding.right || 0) + biasRight, 7536 bottom: (collisionPadding.bottom || 0) + biasBottom, 7537 left: (collisionPadding.left || 0) + biasLeft 7538 }; 7539 } 7540 const commonCollisionProps = { 7541 boundary: collisionBoundary === "clipping-ancestors" ? "clippingAncestors" : collisionBoundary, 7542 padding: collisionPadding 7543 }; 7544 const arrowRef = React29.useRef(null); 7545 const sideOffsetRef = useValueAsRef(sideOffset); 7546 const alignOffsetRef = useValueAsRef(alignOffset); 7547 const sideOffsetDep = typeof sideOffset !== "function" ? sideOffset : 0; 7548 const alignOffsetDep = typeof alignOffset !== "function" ? alignOffset : 0; 7549 const middleware = []; 7550 if (inlineMiddleware) { 7551 middleware.push(inlineMiddleware); 7552 } 7553 middleware.push(offset3((state) => { 7554 const data = getOffsetData(state, sideParam, isRtl); 7555 const sideAxis = typeof sideOffsetRef.current === "function" ? sideOffsetRef.current(data) : sideOffsetRef.current; 7556 const alignAxis = typeof alignOffsetRef.current === "function" ? alignOffsetRef.current(data) : alignOffsetRef.current; 7557 return { 7558 mainAxis: sideAxis, 7559 crossAxis: alignAxis, 7560 alignmentAxis: alignAxis 7561 }; 7562 }, [sideOffsetDep, alignOffsetDep, isRtl, sideParam])); 7563 const shiftDisabled = collisionAvoidanceAlign === "none" && collisionAvoidanceSide !== "shift"; 7564 const crossAxisShiftEnabled = !shiftDisabled && (sticky || shiftCrossAxis || collisionAvoidanceSide === "shift"); 7565 const flipMiddleware = collisionAvoidanceSide === "none" ? null : flip3({ 7566 ...commonCollisionProps, 7567 // Ensure the popup flips if it's been limited by its --available-height and it resizes. 7568 // Since the size() padding is smaller than the flip() padding, flip() will take precedence. 7569 padding: { 7570 top: collisionPadding.top + bias, 7571 right: collisionPadding.right + bias, 7572 bottom: collisionPadding.bottom + bias, 7573 left: collisionPadding.left + bias 7574 }, 7575 mainAxis: !shiftCrossAxis && collisionAvoidanceSide === "flip", 7576 crossAxis: collisionAvoidanceAlign === "flip" ? "alignment" : false, 7577 fallbackAxisSideDirection: collisionAvoidanceFallbackAxisSide 7578 }); 7579 const shiftMiddleware = shiftDisabled ? null : shift3((data) => { 7580 const html = ownerDocument(data.elements.floating).documentElement; 7581 return { 7582 ...commonCollisionProps, 7583 // Use the Layout Viewport to avoid shifting around when pinch-zooming 7584 // for context menus. 7585 rootBoundary: shiftCrossAxis ? { 7586 x: 0, 7587 y: 0, 7588 width: html.clientWidth, 7589 height: html.clientHeight 7590 } : void 0, 7591 mainAxis: collisionAvoidanceAlign !== "none", 7592 crossAxis: crossAxisShiftEnabled, 7593 limiter: sticky || shiftCrossAxis ? void 0 : limitShift3((limitData) => { 7594 if (!arrowRef.current) { 7595 return {}; 7596 } 7597 const { 7598 width, 7599 height 7600 } = arrowRef.current.getBoundingClientRect(); 7601 const sideAxis = getSideAxis(getSide(limitData.placement)); 7602 const arrowSize = sideAxis === "y" ? width : height; 7603 const offsetAmount = sideAxis === "y" ? collisionPadding.left + collisionPadding.right : collisionPadding.top + collisionPadding.bottom; 7604 return { 7605 offset: arrowSize / 2 + offsetAmount / 2 7606 }; 7607 }) 7608 }; 7609 }, [commonCollisionProps, sticky, shiftCrossAxis, collisionPadding, collisionAvoidanceAlign]); 7610 if (collisionAvoidanceSide === "shift" || collisionAvoidanceAlign === "shift" || align === "center") { 7611 middleware.push(shiftMiddleware, flipMiddleware); 7612 } else { 7613 middleware.push(flipMiddleware, shiftMiddleware); 7614 } 7615 middleware.push(size3({ 7616 ...commonCollisionProps, 7617 apply({ 7618 elements: { 7619 floating 7620 }, 7621 availableWidth, 7622 availableHeight, 7623 rects 7624 }) { 7625 if (!mountedRef.current) { 7626 return; 7627 } 7628 const floatingStyle = floating.style; 7629 floatingStyle.setProperty("--available-width", `$availableWidth}px`); 7630 floatingStyle.setProperty("--available-height", `$availableHeight}px`); 7631 const dpr = getWindow(floating).devicePixelRatio || 1; 7632 const { 7633 x: x2, 7634 y: y2, 7635 width, 7636 height 7637 } = rects.reference; 7638 const anchorWidth = (Math.round((x2 + width) * dpr) - Math.round(x2 * dpr)) / dpr; 7639 const anchorHeight = (Math.round((y2 + height) * dpr) - Math.round(y2 * dpr)) / dpr; 7640 floatingStyle.setProperty("--anchor-width", `$anchorWidth}px`); 7641 floatingStyle.setProperty("--anchor-height", `$anchorHeight}px`); 7642 } 7643 }), arrow4((state) => ({ 7644 // `transform-origin` calculations rely on an element existing. If the arrow hasn't been set, 7645 // we'll create a fake element. 7646 element: arrowRef.current || ownerDocument(state.elements.floating).createElement("div"), 7647 padding: arrowPadding, 7648 offsetParent: "floating" 7649 }), [arrowPadding]), { 7650 name: "transformOrigin", 7651 fn(state) { 7652 const { 7653 elements: elements2, 7654 middlewareData: middlewareData2, 7655 placement: renderedPlacement2, 7656 rects, 7657 y: y2 7658 } = state; 7659 const currentRenderedSide = getSide(renderedPlacement2); 7660 const currentRenderedAxis = getSideAxis(currentRenderedSide); 7661 const arrowEl = arrowRef.current; 7662 const arrowX = middlewareData2.arrow?.x || 0; 7663 const arrowY = middlewareData2.arrow?.y || 0; 7664 const arrowWidth = arrowEl?.clientWidth || 0; 7665 const arrowHeight = arrowEl?.clientHeight || 0; 7666 const transformX = arrowX + arrowWidth / 2; 7667 const transformY = arrowY + arrowHeight / 2; 7668 const shiftY = Math.abs(middlewareData2.shift?.y || 0); 7669 const halfAnchorHeight = rects.reference.height / 2; 7670 const sideOffsetValue = typeof sideOffset === "function" ? sideOffset(getOffsetData(state, sideParam, isRtl)) : sideOffset; 7671 const isOverlappingAnchor = shiftY > sideOffsetValue; 7672 const adjacentTransformOrigin = { 7673 top: `$transformX}px calc(100% + $sideOffsetValue}px)`, 7674 bottom: `$transformX}px ${-sideOffsetValue}px`, 7675 left: `calc(100% + $sideOffsetValue}px) $transformY}px`, 7676 right: `${-sideOffsetValue}px $transformY}px` 7677 }[currentRenderedSide]; 7678 const overlapTransformOrigin = `$transformX}px $rects.reference.y + halfAnchorHeight - y2}px`; 7679 elements2.floating.style.setProperty("--transform-origin", crossAxisShiftEnabled && currentRenderedAxis === "y" && isOverlappingAnchor ? overlapTransformOrigin : adjacentTransformOrigin); 7680 return {}; 7681 } 7682 }, hide4, adaptiveOrigin2); 7683 useIsoLayoutEffect(() => { 7684 if (!mounted && floatingRootContext) { 7685 floatingRootContext.update({ 7686 referenceElement: null, 7687 floatingElement: null, 7688 domReferenceElement: null, 7689 positionReference: null 7690 }); 7691 } 7692 }, [mounted, floatingRootContext]); 7693 const autoUpdateOptions = React29.useMemo(() => ({ 7694 elementResize: !disableAnchorTracking && typeof ResizeObserver !== "undefined", 7695 layoutShift: !disableAnchorTracking && typeof IntersectionObserver !== "undefined" 7696 }), [disableAnchorTracking]); 7697 const { 7698 refs, 7699 elements, 7700 x, 7701 y, 7702 middlewareData, 7703 update: update2, 7704 placement: renderedPlacement, 7705 context, 7706 isPositioned, 7707 floatingStyles: originalFloatingStyles 7708 } = useFloating2({ 7709 rootContext: floatingRootContext, 7710 open: keepMounted ? mounted : void 0, 7711 placement, 7712 middleware, 7713 strategy: positionMethod, 7714 whileElementsMounted: keepMounted ? void 0 : (...args) => autoUpdate(...args, autoUpdateOptions), 7715 nodeId, 7716 externalTree 7717 }); 7718 const { 7719 sideX, 7720 sideY 7721 } = middlewareData.adaptiveOrigin || DEFAULT_SIDES; 7722 const resolvedPosition = isPositioned ? positionMethod : "fixed"; 7723 const floatingStyles = React29.useMemo(() => { 7724 const base = adaptiveOrigin2 ? { 7725 position: resolvedPosition, 7726 [sideX]: x, 7727 [sideY]: y 7728 } : { 7729 position: resolvedPosition, 7730 ...originalFloatingStyles 7731 }; 7732 if (!isPositioned) { 7733 base.opacity = 0; 7734 } 7735 return base; 7736 }, [adaptiveOrigin2, resolvedPosition, sideX, x, sideY, y, originalFloatingStyles, isPositioned]); 7737 const registeredPositionReferenceRef = React29.useRef(null); 7738 useIsoLayoutEffect(() => { 7739 if (!mounted) { 7740 return; 7741 } 7742 const anchorValue = anchorValueRef.current; 7743 const resolvedAnchor = typeof anchorValue === "function" ? anchorValue() : anchorValue; 7744 const unwrappedElement = (isRef(resolvedAnchor) ? resolvedAnchor.current : resolvedAnchor) || null; 7745 const finalAnchor = unwrappedElement || null; 7746 if (finalAnchor !== registeredPositionReferenceRef.current) { 7747 refs.setPositionReference(finalAnchor); 7748 registeredPositionReferenceRef.current = finalAnchor; 7749 } 7750 }, [mounted, refs, anchorDep, anchorValueRef]); 7751 React29.useEffect(() => { 7752 if (!mounted) { 7753 return; 7754 } 7755 const anchorValue = anchorValueRef.current; 7756 if (typeof anchorValue === "function") { 7757 return; 7758 } 7759 if (isRef(anchorValue) && anchorValue.current !== registeredPositionReferenceRef.current) { 7760 refs.setPositionReference(anchorValue.current); 7761 registeredPositionReferenceRef.current = anchorValue.current; 7762 } 7763 }, [mounted, refs, anchorDep, anchorValueRef]); 7764 React29.useEffect(() => { 7765 if (keepMounted && mounted && elements.reference && elements.floating) { 7766 return autoUpdate(elements.reference, elements.floating, update2, autoUpdateOptions); 7767 } 7768 return void 0; 7769 }, [keepMounted, mounted, elements, update2, autoUpdateOptions]); 7770 const renderedSide = getSide(renderedPlacement); 7771 const logicalRenderedSide = getLogicalSide(sideParam, renderedSide, isRtl); 7772 const renderedAlign = getAlignment(renderedPlacement) || "center"; 7773 const anchorHidden = Boolean(middlewareData.hide?.referenceHidden); 7774 useIsoLayoutEffect(() => { 7775 if (lazyFlip && mounted && isPositioned) { 7776 setMountSide(renderedSide); 7777 } 7778 }, [lazyFlip, mounted, isPositioned, renderedSide]); 7779 const arrowStyles = React29.useMemo(() => ({ 7780 position: "absolute", 7781 top: middlewareData.arrow?.y, 7782 left: middlewareData.arrow?.x 7783 }), [middlewareData.arrow]); 7784 const arrowUncentered = middlewareData.arrow?.centerOffset !== 0; 7785 return React29.useMemo(() => ({ 7786 positionerStyles: floatingStyles, 7787 arrowStyles, 7788 arrowRef, 7789 arrowUncentered, 7790 side: logicalRenderedSide, 7791 align: renderedAlign, 7792 physicalSide: renderedSide, 7793 anchorHidden, 7794 refs, 7795 context, 7796 isPositioned, 7797 update: update2 7798 }), [floatingStyles, arrowStyles, arrowRef, arrowUncentered, logicalRenderedSide, renderedAlign, renderedSide, anchorHidden, refs, context, isPositioned, update2]); 7799 } 7800 function isRef(param) { 7801 return param != null && "current" in param; 7802 } 7803 7804 // node_modules/@base-ui/react/utils/getDisabledMountTransitionStyles.mjs 7805 function getDisabledMountTransitionStyles(transitionStatus) { 7806 return transitionStatus === "starting" ? DISABLED_TRANSITIONS_STYLE : EMPTY_OBJECT; 7807 } 7808 7809 // node_modules/@base-ui/react/utils/usePositioner.mjs 7810 function usePositioner(componentProps, state, { 7811 styles, 7812 transitionStatus, 7813 props, 7814 refs, 7815 hidden, 7816 inert = false 7817 }) { 7818 const style = { 7819 ...styles 7820 }; 7821 if (inert) { 7822 style.pointerEvents = "none"; 7823 } 7824 return useRenderElement("div", componentProps, { 7825 state, 7826 ref: refs, 7827 props: [{ 7828 role: "presentation", 7829 hidden, 7830 style 7831 }, getDisabledMountTransitionStyles(transitionStatus), props], 7832 stateAttributesMapping: popupStateMapping 7833 }); 7834 } 7835 7836 // node_modules/@base-ui/react/utils/usePopupViewport.mjs 7837 var React32 = __toESM(require_react(), 1); 7838 var ReactDOM6 = __toESM(require_react_dom(), 1); 7839 7840 // node_modules/@base-ui/utils/usePreviousValue.mjs 7841 var React30 = __toESM(require_react(), 1); 7842 function usePreviousValue(value) { 7843 const [state, setState] = React30.useState({ 7844 current: value, 7845 previous: null 7846 }); 7847 if (value !== state.current) { 7848 setState({ 7849 current: value, 7850 previous: state.current 7851 }); 7852 } 7853 return state.previous; 7854 } 7855 7856 // node_modules/@base-ui/react/utils/usePopupAutoResize.mjs 7857 var React31 = __toESM(require_react(), 1); 7858 7859 // node_modules/@base-ui/react/utils/getCssDimensions.mjs 7860 function getCssDimensions2(element) { 7861 const css = getComputedStyle2(element); 7862 let width = parseFloat(css.width) || 0; 7863 let height = parseFloat(css.height) || 0; 7864 const hasOffset = isHTMLElement(element); 7865 const offsetWidth = hasOffset ? element.offsetWidth : width; 7866 const offsetHeight = hasOffset ? element.offsetHeight : height; 7867 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight; 7868 if (shouldFallback) { 7869 width = offsetWidth; 7870 height = offsetHeight; 7871 } 7872 return { 7873 width, 7874 height 7875 }; 7876 } 7877 7878 // node_modules/@base-ui/react/utils/usePopupAutoResize.mjs 7879 function usePopupAutoResize(parameters) { 7880 const { 7881 popupElement, 7882 positionerElement, 7883 content, 7884 mounted, 7885 onMeasureLayout: onMeasureLayoutParam, 7886 onMeasureLayoutComplete: onMeasureLayoutCompleteParam, 7887 side, 7888 direction 7889 } = parameters; 7890 const runOnceAnimationsFinish = useAnimationsFinished(popupElement, true, false); 7891 const animationFrame = useAnimationFrame(); 7892 const committedDimensionsRef = React31.useRef(null); 7893 const isInitialRenderRef = React31.useRef(true); 7894 const restoreAnchoringStylesRef = React31.useRef(NOOP); 7895 const onMeasureLayout = useStableCallback(onMeasureLayoutParam); 7896 const onMeasureLayoutComplete = useStableCallback(onMeasureLayoutCompleteParam); 7897 const anchoringStyles = React31.useMemo(() => { 7898 let isOriginSide = side === "top"; 7899 let isPhysicalLeft = side === "left"; 7900 if (direction === "rtl") { 7901 isOriginSide = isOriginSide || side === "inline-end"; 7902 isPhysicalLeft = isPhysicalLeft || side === "inline-end"; 7903 } else { 7904 isOriginSide = isOriginSide || side === "inline-start"; 7905 isPhysicalLeft = isPhysicalLeft || side === "inline-start"; 7906 } 7907 return isOriginSide ? { 7908 position: "absolute", 7909 [side === "top" ? "bottom" : "top"]: "0", 7910 [isPhysicalLeft ? "right" : "left"]: "0" 7911 } : EMPTY_OBJECT; 7912 }, [side, direction]); 7913 useIsoLayoutEffect(() => { 7914 if (!mounted) { 7915 restoreAnchoringStylesRef.current = NOOP; 7916 isInitialRenderRef.current = true; 7917 committedDimensionsRef.current = null; 7918 return void 0; 7919 } 7920 if (!popupElement || !positionerElement) { 7921 return void 0; 7922 } 7923 restoreAnchoringStylesRef.current = applyElementStyles(popupElement, anchoringStyles); 7924 setPopupCssSize(popupElement, "auto"); 7925 const restorePopupPosition = overrideElementStyle(popupElement, "position", "static"); 7926 const restorePopupTransform = overrideElementStyle(popupElement, "transform", "none"); 7927 const restorePopupScale = overrideElementStyle(popupElement, "scale", "1"); 7928 const restorePositionerAvailableSize = applyElementStyles(positionerElement, { 7929 "--available-width": "max-content", 7930 "--available-height": "max-content" 7931 }); 7932 function restoreMeasurementOverrides() { 7933 restorePopupPosition(); 7934 restorePopupTransform(); 7935 restorePositionerAvailableSize(); 7936 } 7937 function restoreMeasurementOverridesIncludingScale() { 7938 restoreMeasurementOverrides(); 7939 restorePopupScale(); 7940 } 7941 onMeasureLayout?.(); 7942 if (isInitialRenderRef.current || committedDimensionsRef.current === null) { 7943 setPositionerCssSize(positionerElement, "max-content"); 7944 const dimensions = getCssDimensions2(popupElement); 7945 committedDimensionsRef.current = dimensions; 7946 setPositionerCssSize(positionerElement, dimensions); 7947 restoreMeasurementOverridesIncludingScale(); 7948 onMeasureLayoutComplete?.(null, dimensions); 7949 isInitialRenderRef.current = false; 7950 return () => { 7951 restoreAnchoringStylesRef.current(); 7952 restoreAnchoringStylesRef.current = NOOP; 7953 }; 7954 } 7955 setPositionerCssSize(positionerElement, "max-content"); 7956 const previousDimensions = committedDimensionsRef.current; 7957 const newDimensions = getCssDimensions2(popupElement); 7958 committedDimensionsRef.current = newDimensions; 7959 setPopupCssSize(popupElement, previousDimensions); 7960 restoreMeasurementOverridesIncludingScale(); 7961 onMeasureLayoutComplete?.(previousDimensions, newDimensions); 7962 setPositionerCssSize(positionerElement, newDimensions); 7963 const abortController = new AbortController(); 7964 animationFrame.request(() => { 7965 setPopupCssSize(popupElement, newDimensions); 7966 runOnceAnimationsFinish(() => { 7967 popupElement.style.setProperty("--popup-width", "auto"); 7968 popupElement.style.setProperty("--popup-height", "auto"); 7969 }, abortController.signal); 7970 }); 7971 return () => { 7972 abortController.abort(); 7973 animationFrame.cancel(); 7974 restoreAnchoringStylesRef.current(); 7975 restoreAnchoringStylesRef.current = NOOP; 7976 }; 7977 }, [content, popupElement, positionerElement, runOnceAnimationsFinish, animationFrame, mounted, onMeasureLayout, onMeasureLayoutComplete, anchoringStyles]); 7978 } 7979 function overrideElementStyle(element, property, value) { 7980 const originalValue = element.style.getPropertyValue(property); 7981 element.style.setProperty(property, value); 7982 return () => { 7983 element.style.setProperty(property, originalValue); 7984 }; 7985 } 7986 function applyElementStyles(element, styles) { 7987 const restorers = []; 7988 for (const [key, value] of Object.entries(styles)) { 7989 restorers.push(overrideElementStyle(element, key, value)); 7990 } 7991 return restorers.length ? () => { 7992 restorers.forEach((restore) => restore()); 7993 } : NOOP; 7994 } 7995 function setPopupCssSize(popupElement, size4) { 7996 const width = size4 === "auto" ? "auto" : `$size4.width}px`; 7997 const height = size4 === "auto" ? "auto" : `$size4.height}px`; 7998 popupElement.style.setProperty("--popup-width", width); 7999 popupElement.style.setProperty("--popup-height", height); 8000 } 8001 function setPositionerCssSize(positionerElement, size4) { 8002 const width = size4 === "max-content" ? "max-content" : `$size4.width}px`; 8003 const height = size4 === "max-content" ? "max-content" : `$size4.height}px`; 8004 positionerElement.style.setProperty("--positioner-width", width); 8005 positionerElement.style.setProperty("--positioner-height", height); 8006 } 8007 8008 // node_modules/@base-ui/react/utils/usePopupViewport.mjs 8009 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1); 8010 function usePopupViewport(parameters) { 8011 const { 8012 store: store2, 8013 side, 8014 cssVars, 8015 children 8016 } = parameters; 8017 const direction = useDirection(); 8018 const activeTrigger = store2.useState("activeTriggerElement"); 8019 const activeTriggerId = store2.useState("activeTriggerId"); 8020 const open = store2.useState("open"); 8021 const payload = store2.useState("payload"); 8022 const mounted = store2.useState("mounted"); 8023 const popupElement = store2.useState("popupElement"); 8024 const positionerElement = store2.useState("positionerElement"); 8025 const previousActiveTrigger = usePreviousValue(open ? activeTrigger : null); 8026 const currentContentKey = usePopupContentKey(activeTriggerId, payload); 8027 const capturedNodeRef = React32.useRef(null); 8028 const [previousContentNode, setPreviousContentNode] = React32.useState(null); 8029 const [newTriggerOffset, setNewTriggerOffset] = React32.useState(null); 8030 const currentContainerRef = React32.useRef(null); 8031 const previousContainerRef = React32.useRef(null); 8032 const onAnimationsFinished = useAnimationsFinished(currentContainerRef, true, false); 8033 const cleanupFrame = useAnimationFrame(); 8034 const [previousContentDimensions, setPreviousContentDimensions] = React32.useState(null); 8035 const [showStartingStyleAttribute, setShowStartingStyleAttribute] = React32.useState(false); 8036 useIsoLayoutEffect(() => { 8037 store2.set("hasViewport", true); 8038 return () => { 8039 store2.set("hasViewport", false); 8040 }; 8041 }, [store2]); 8042 const handleMeasureLayout = useStableCallback(() => { 8043 currentContainerRef.current?.style.setProperty("animation", "none"); 8044 currentContainerRef.current?.style.setProperty("transition", "none"); 8045 previousContainerRef.current?.style.setProperty("display", "none"); 8046 }); 8047 const handleMeasureLayoutComplete = useStableCallback((previousDimensions) => { 8048 currentContainerRef.current?.style.removeProperty("animation"); 8049 currentContainerRef.current?.style.removeProperty("transition"); 8050 previousContainerRef.current?.style.removeProperty("display"); 8051 if (previousDimensions) { 8052 setPreviousContentDimensions(previousDimensions); 8053 } 8054 }); 8055 const lastHandledTriggerRef = React32.useRef(null); 8056 useIsoLayoutEffect(() => { 8057 if (!open || !mounted) { 8058 lastHandledTriggerRef.current = null; 8059 } 8060 }, [open, mounted]); 8061 useIsoLayoutEffect(() => { 8062 if (activeTrigger && previousActiveTrigger && activeTrigger !== previousActiveTrigger && lastHandledTriggerRef.current !== activeTrigger && capturedNodeRef.current) { 8063 setPreviousContentNode(capturedNodeRef.current); 8064 setShowStartingStyleAttribute(true); 8065 const offset4 = calculateRelativePosition(previousActiveTrigger, activeTrigger); 8066 setNewTriggerOffset(offset4); 8067 cleanupFrame.request(() => { 8068 ReactDOM6.flushSync(() => { 8069 setShowStartingStyleAttribute(false); 8070 }); 8071 onAnimationsFinished(() => { 8072 setPreviousContentNode(null); 8073 setPreviousContentDimensions(null); 8074 capturedNodeRef.current = null; 8075 }); 8076 }); 8077 lastHandledTriggerRef.current = activeTrigger; 8078 } 8079 }, [activeTrigger, previousActiveTrigger, previousContentNode, onAnimationsFinished, cleanupFrame]); 8080 useIsoLayoutEffect(() => { 8081 const source = currentContainerRef.current; 8082 if (!source) { 8083 return; 8084 } 8085 const wrapper = ownerDocument(source).createElement("div"); 8086 for (const child of Array.from(source.childNodes)) { 8087 wrapper.appendChild(child.cloneNode(true)); 8088 } 8089 capturedNodeRef.current = wrapper; 8090 }); 8091 const isTransitioning = previousContentNode != null; 8092 let childrenToRender; 8093 if (!isTransitioning) { 8094 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { 8095 "data-current": true, 8096 ref: currentContainerRef, 8097 children 8098 }, currentContentKey); 8099 } else { 8100 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(React32.Fragment, { 8101 children: [/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { 8102 "data-previous": true, 8103 inert: inertValue(true), 8104 ref: previousContainerRef, 8105 style: { 8106 ...previousContentDimensions ? { 8107 [cssVars.popupWidth]: `$previousContentDimensions.width}px`, 8108 [cssVars.popupHeight]: `$previousContentDimensions.height}px` 8109 } : null, 8110 position: "absolute" 8111 }, 8112 "data-ending-style": showStartingStyleAttribute ? void 0 : "" 8113 }, "previous"), /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { 8114 "data-current": true, 8115 ref: currentContainerRef, 8116 "data-starting-style": showStartingStyleAttribute ? "" : void 0, 8117 children 8118 }, currentContentKey)] 8119 }); 8120 } 8121 useIsoLayoutEffect(() => { 8122 const container = previousContainerRef.current; 8123 if (!container || !previousContentNode) { 8124 return; 8125 } 8126 container.replaceChildren(...Array.from(previousContentNode.childNodes)); 8127 }, [previousContentNode]); 8128 usePopupAutoResize({ 8129 popupElement, 8130 positionerElement, 8131 mounted, 8132 content: payload, 8133 onMeasureLayout: handleMeasureLayout, 8134 onMeasureLayoutComplete: handleMeasureLayoutComplete, 8135 side, 8136 direction 8137 }); 8138 const state = { 8139 activationDirection: getActivationDirection(newTriggerOffset), 8140 transitioning: isTransitioning 8141 }; 8142 return { 8143 children: childrenToRender, 8144 state 8145 }; 8146 } 8147 function getActivationDirection(offset4) { 8148 if (!offset4) { 8149 return void 0; 8150 } 8151 return `$getValueWithTolerance(offset4.horizontal, 5, "right", "left")} $getValueWithTolerance(offset4.vertical, 5, "down", "up")}`; 8152 } 8153 function getValueWithTolerance(value, tolerance, positiveLabel, negativeLabel) { 8154 if (value > tolerance) { 8155 return positiveLabel; 8156 } 8157 if (value < -tolerance) { 8158 return negativeLabel; 8159 } 8160 return ""; 8161 } 8162 function calculateRelativePosition(from, to) { 8163 const fromRect = from.getBoundingClientRect(); 8164 const toRect = to.getBoundingClientRect(); 8165 const fromCenter = { 8166 x: fromRect.left + fromRect.width / 2, 8167 y: fromRect.top + fromRect.height / 2 8168 }; 8169 const toCenter = { 8170 x: toRect.left + toRect.width / 2, 8171 y: toRect.top + toRect.height / 2 8172 }; 8173 return { 8174 horizontal: toCenter.x - fromCenter.x, 8175 vertical: toCenter.y - fromCenter.y 8176 }; 8177 } 8178 function usePopupContentKey(activeTriggerId, payload) { 8179 const [contentKey, setContentKey] = React32.useState(0); 8180 const previousActiveTriggerIdRef = React32.useRef(activeTriggerId); 8181 const previousPayloadRef = React32.useRef(payload); 8182 const pendingPayloadUpdateRef = React32.useRef(false); 8183 useIsoLayoutEffect(() => { 8184 const previousActiveTriggerId = previousActiveTriggerIdRef.current; 8185 const previousPayload = previousPayloadRef.current; 8186 const triggerIdChanged = activeTriggerId !== previousActiveTriggerId; 8187 const payloadChanged = payload !== previousPayload; 8188 if (triggerIdChanged) { 8189 setContentKey((value) => value + 1); 8190 pendingPayloadUpdateRef.current = !payloadChanged; 8191 } else if (pendingPayloadUpdateRef.current && payloadChanged) { 8192 setContentKey((value) => value + 1); 8193 pendingPayloadUpdateRef.current = false; 8194 } 8195 previousActiveTriggerIdRef.current = activeTriggerId; 8196 previousPayloadRef.current = payload; 8197 }, [activeTriggerId, payload]); 8198 return `$activeTriggerId ?? "current"}-$contentKey}`; 8199 } 8200 8201 // node_modules/@base-ui/react/utils/FloatingPortalLite.mjs 8202 var React33 = __toESM(require_react(), 1); 8203 var ReactDOM7 = __toESM(require_react_dom(), 1); 8204 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1); 8205 var FloatingPortalLite = /* @__PURE__ */ React33.forwardRef(function FloatingPortalLite2(componentProps, forwardedRef) { 8206 const { 8207 children, 8208 container, 8209 className, 8210 render, 8211 style, 8212 ...elementProps 8213 } = componentProps; 8214 const { 8215 portalNode, 8216 portalSubtree 8217 } = useFloatingPortalNode({ 8218 container, 8219 ref: forwardedRef, 8220 componentProps, 8221 elementProps 8222 }); 8223 if (!portalSubtree && !portalNode) { 8224 return null; 8225 } 8226 return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(React33.Fragment, { 8227 children: [portalSubtree, portalNode && /* @__PURE__ */ ReactDOM7.createPortal(children, portalNode)] 8228 }); 8229 }); 8230 if (true) FloatingPortalLite.displayName = "FloatingPortalLite"; 8231 8232 // node_modules/@base-ui/react/tooltip/index.parts.mjs 8233 var index_parts_exports = {}; 8234 __export(index_parts_exports, { 8235 Arrow: () => TooltipArrow, 8236 Handle: () => TooltipHandle, 8237 Popup: () => TooltipPopup, 8238 Portal: () => TooltipPortal, 8239 Positioner: () => TooltipPositioner, 8240 Provider: () => TooltipProvider, 8241 Root: () => TooltipRoot, 8242 Trigger: () => TooltipTrigger, 8243 Viewport: () => TooltipViewport, 8244 createHandle: () => createTooltipHandle 8245 }); 8246 8247 // node_modules/@base-ui/react/tooltip/root/TooltipRoot.mjs 8248 var React36 = __toESM(require_react(), 1); 8249 8250 // node_modules/@base-ui/react/tooltip/root/TooltipRootContext.mjs 8251 var React34 = __toESM(require_react(), 1); 8252 var TooltipRootContext = /* @__PURE__ */ React34.createContext(void 0); 8253 if (true) TooltipRootContext.displayName = "TooltipRootContext"; 8254 function useTooltipRootContext(optional) { 8255 const context = React34.useContext(TooltipRootContext); 8256 if (context === void 0 && !optional) { 8257 throw new Error(true ? "Base UI: TooltipRootContext is missing. Tooltip parts must be placed within <Tooltip.Root>." : formatErrorMessage_default(72)); 8258 } 8259 return context; 8260 } 8261 8262 // node_modules/@base-ui/react/tooltip/store/TooltipStore.mjs 8263 var React35 = __toESM(require_react(), 1); 8264 var selectors2 = { 8265 ...popupStoreSelectors, 8266 disabled: createSelector2((state) => state.disabled), 8267 instantType: createSelector2((state) => state.instantType), 8268 isInstantPhase: createSelector2((state) => state.isInstantPhase), 8269 trackCursorAxis: createSelector2((state) => state.trackCursorAxis), 8270 disableHoverablePopup: createSelector2((state) => state.disableHoverablePopup), 8271 lastOpenChangeReason: createSelector2((state) => state.openChangeReason), 8272 closeOnClick: createSelector2((state) => state.closeOnClick), 8273 closeDelay: createSelector2((state) => state.closeDelay), 8274 hasViewport: createSelector2((state) => state.hasViewport) 8275 }; 8276 var TooltipStore = class _TooltipStore extends ReactStore { 8277 constructor(initialState, floatingId, nested = false) { 8278 const triggerElements = new PopupTriggerMap(); 8279 const state = { 8280 ...createInitialState(), 8281 ...initialState 8282 }; 8283 state.floatingRootContext = createPopupFloatingRootContext(triggerElements, floatingId, nested); 8284 super(state, { 8285 popupRef: /* @__PURE__ */ React35.createRef(), 8286 onOpenChange: void 0, 8287 onOpenChangeComplete: void 0, 8288 triggerElements 8289 }, selectors2); 8290 } 8291 setOpen = (nextOpen, eventDetails) => { 8292 applyPopupOpenChange(this, nextOpen, eventDetails, { 8293 extraState: { 8294 openChangeReason: eventDetails.reason 8295 } 8296 }); 8297 }; 8298 // Used by trigger clicks to clear a delayed hover open without reporting a public open-state change. 8299 cancelPendingOpen(event) { 8300 this.state.floatingRootContext.dispatchOpenChange(false, createChangeEventDetails(reason_parts_exports.triggerPress, event)); 8301 } 8302 static useStore(externalStore, initialState) { 8303 const store2 = usePopupStore(externalStore, (floatingId, nested) => new _TooltipStore(initialState, floatingId, nested)).store; 8304 return store2; 8305 } 8306 }; 8307 function createInitialState() { 8308 return { 8309 ...createInitialPopupStoreState(), 8310 disabled: false, 8311 instantType: void 0, 8312 isInstantPhase: false, 8313 trackCursorAxis: "none", 8314 disableHoverablePopup: false, 8315 openChangeReason: null, 8316 closeOnClick: true, 8317 closeDelay: 0, 8318 hasViewport: false 8319 }; 8320 } 8321 8322 // node_modules/@base-ui/react/tooltip/root/TooltipRoot.mjs 8323 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1); 8324 var TooltipRoot = fastComponent(function TooltipRoot2(props) { 8325 const { 8326 disabled: disabled2 = false, 8327 defaultOpen = false, 8328 open: openProp, 8329 disableHoverablePopup = false, 8330 trackCursorAxis = "none", 8331 actionsRef, 8332 onOpenChange, 8333 onOpenChangeComplete, 8334 handle, 8335 triggerId: triggerIdProp, 8336 defaultTriggerId: defaultTriggerIdProp = null, 8337 children 8338 } = props; 8339 const store2 = TooltipStore.useStore(handle?.store, { 8340 open: defaultOpen, 8341 openProp, 8342 activeTriggerId: defaultTriggerIdProp, 8343 triggerIdProp 8344 }); 8345 useInitialOpenSync(store2, openProp, defaultOpen, defaultTriggerIdProp); 8346 store2.useControlledProp("openProp", openProp); 8347 store2.useControlledProp("triggerIdProp", triggerIdProp); 8348 store2.useContextCallback("onOpenChange", onOpenChange); 8349 store2.useContextCallback("onOpenChangeComplete", onOpenChangeComplete); 8350 const openState = store2.useState("open"); 8351 const open = !disabled2 && openState; 8352 const activeTriggerId = store2.useState("activeTriggerId"); 8353 const mounted = store2.useState("mounted"); 8354 const payload = store2.useState("payload"); 8355 store2.useSyncedValues({ 8356 trackCursorAxis, 8357 disableHoverablePopup 8358 }); 8359 store2.useSyncedValue("disabled", disabled2); 8360 useImplicitActiveTrigger(store2, { 8361 closeOnActiveTriggerUnmount: true 8362 }); 8363 const { 8364 forceUnmount, 8365 transitionStatus 8366 } = useOpenStateTransitions(open, store2); 8367 const isInstantPhase = store2.useState("isInstantPhase"); 8368 const instantType = store2.useState("instantType"); 8369 const lastOpenChangeReason = store2.useState("lastOpenChangeReason"); 8370 const previousInstantTypeRef = React36.useRef(null); 8371 useIsoLayoutEffect(() => { 8372 if (openState && disabled2) { 8373 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.disabled)); 8374 } 8375 }, [openState, disabled2, store2]); 8376 useIsoLayoutEffect(() => { 8377 if (transitionStatus === "ending" && lastOpenChangeReason === reason_parts_exports.none || transitionStatus !== "ending" && isInstantPhase) { 8378 if (instantType !== "delay") { 8379 previousInstantTypeRef.current = instantType; 8380 } 8381 store2.set("instantType", "delay"); 8382 } else if (previousInstantTypeRef.current !== null) { 8383 store2.set("instantType", previousInstantTypeRef.current); 8384 previousInstantTypeRef.current = null; 8385 } 8386 }, [transitionStatus, isInstantPhase, lastOpenChangeReason, instantType, store2]); 8387 useIsoLayoutEffect(() => { 8388 if (open) { 8389 if (activeTriggerId == null) { 8390 store2.set("payload", void 0); 8391 } 8392 } 8393 }, [store2, activeTriggerId, open]); 8394 const handleImperativeClose = React36.useCallback(() => { 8395 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction)); 8396 }, [store2]); 8397 React36.useImperativeHandle(actionsRef, () => ({ 8398 unmount: forceUnmount, 8399 close: handleImperativeClose 8400 }), [forceUnmount, handleImperativeClose]); 8401 const shouldRenderInteractions = open || mounted || !disabled2 && trackCursorAxis !== "none"; 8402 return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(TooltipRootContext.Provider, { 8403 value: store2, 8404 children: [shouldRenderInteractions && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(TooltipInteractions, { 8405 store: store2, 8406 disabled: disabled2, 8407 trackCursorAxis 8408 }), typeof children === "function" ? children({ 8409 payload 8410 }) : children] 8411 }); 8412 }); 8413 if (true) TooltipRoot.displayName = "TooltipRoot"; 8414 function TooltipInteractions({ 8415 store: store2, 8416 disabled: disabled2, 8417 trackCursorAxis 8418 }) { 8419 const floatingRootContext = store2.useState("floatingRootContext"); 8420 const dismiss = useDismiss(floatingRootContext, { 8421 enabled: !disabled2, 8422 referencePress: () => store2.select("closeOnClick") 8423 }); 8424 const clientPoint = useClientPoint(floatingRootContext, { 8425 enabled: !disabled2 && trackCursorAxis !== "none", 8426 axis: trackCursorAxis === "none" ? void 0 : trackCursorAxis 8427 }); 8428 const activeTriggerProps = React36.useMemo(() => mergeProps(clientPoint.reference, dismiss.reference), [clientPoint.reference, dismiss.reference]); 8429 const inactiveTriggerProps = React36.useMemo(() => mergeProps(clientPoint.trigger, dismiss.trigger), [clientPoint.trigger, dismiss.trigger]); 8430 const popupProps = React36.useMemo(() => mergeProps(FOCUSABLE_POPUP_PROPS, clientPoint.floating, dismiss.floating), [clientPoint.floating, dismiss.floating]); 8431 usePopupInteractionProps(store2, { 8432 activeTriggerProps, 8433 inactiveTriggerProps, 8434 popupProps 8435 }); 8436 return null; 8437 } 8438 8439 // node_modules/@base-ui/react/tooltip/trigger/TooltipTrigger.mjs 8440 var React38 = __toESM(require_react(), 1); 8441 8442 // node_modules/@base-ui/react/tooltip/provider/TooltipProviderContext.mjs 8443 var React37 = __toESM(require_react(), 1); 8444 var TooltipProviderContext = /* @__PURE__ */ React37.createContext(void 0); 8445 if (true) TooltipProviderContext.displayName = "TooltipProviderContext"; 8446 function useTooltipProviderContext() { 8447 return React37.useContext(TooltipProviderContext); 8448 } 8449 8450 // node_modules/@base-ui/react/tooltip/trigger/TooltipTriggerDataAttributes.mjs 8451 var TooltipTriggerDataAttributes = (function(TooltipTriggerDataAttributes2) { 8452 TooltipTriggerDataAttributes2[TooltipTriggerDataAttributes2["popupOpen"] = CommonTriggerDataAttributes.popupOpen] = "popupOpen"; 8453 TooltipTriggerDataAttributes2["triggerDisabled"] = "data-trigger-disabled"; 8454 return TooltipTriggerDataAttributes2; 8455 })({}); 8456 8457 // node_modules/@base-ui/react/tooltip/utils/constants.mjs 8458 var OPEN_DELAY = 600; 8459 8460 // node_modules/@base-ui/react/tooltip/trigger/TooltipTrigger.mjs 8461 var TOOLTIP_TRIGGER_IDENTIFIER = "data-base-ui-tooltip-trigger"; 8462 function getTargetElement(event) { 8463 if ("composedPath" in event) { 8464 const path = event.composedPath(); 8465 for (let i = 0; i < path.length; i += 1) { 8466 const element = path[i]; 8467 if (isElement(element)) { 8468 return element; 8469 } 8470 } 8471 } 8472 const target = event.target; 8473 if (isElement(target)) { 8474 return target; 8475 } 8476 return null; 8477 } 8478 function closestEnabledTooltipTrigger(element) { 8479 let current = element; 8480 while (current) { 8481 if (current.hasAttribute(TOOLTIP_TRIGGER_IDENTIFIER)) { 8482 return current; 8483 } 8484 const parentElement = current.parentElement; 8485 if (parentElement) { 8486 current = parentElement; 8487 continue; 8488 } 8489 const root = current.getRootNode(); 8490 current = "host" in root && isElement(root.host) ? root.host : null; 8491 } 8492 return null; 8493 } 8494 var TooltipTrigger = fastComponentRef(function TooltipTrigger2(componentProps, forwardedRef) { 8495 const { 8496 render, 8497 className, 8498 style, 8499 handle, 8500 payload, 8501 disabled: disabledProp, 8502 delay, 8503 closeOnClick = true, 8504 closeDelay, 8505 id: idProp, 8506 ...elementProps 8507 } = componentProps; 8508 const rootContext = useTooltipRootContext(true); 8509 const store2 = handle?.store ?? rootContext; 8510 if (!store2) { 8511 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)); 8512 } 8513 const thisTriggerId = useBaseUiId(idProp); 8514 const isTriggerActive = store2.useState("isTriggerActive", thisTriggerId); 8515 const isOpenedByThisTrigger = store2.useState("isOpenedByTrigger", thisTriggerId); 8516 const floatingRootContext = store2.useState("floatingRootContext"); 8517 const triggerElementRef = React38.useRef(null); 8518 const delayWithDefault = delay ?? OPEN_DELAY; 8519 const closeDelayWithDefault = closeDelay ?? 0; 8520 const { 8521 registerTrigger, 8522 isMountedByThisTrigger 8523 } = useTriggerDataForwarding(thisTriggerId, triggerElementRef, store2, { 8524 payload, 8525 closeOnClick, 8526 closeDelay: closeDelayWithDefault 8527 }); 8528 const providerContext = useTooltipProviderContext(); 8529 const { 8530 delayRef, 8531 isInstantPhase, 8532 hasProvider 8533 } = useDelayGroup(floatingRootContext, { 8534 open: isOpenedByThisTrigger 8535 }); 8536 const hoverInteraction = useHoverInteractionSharedState(floatingRootContext); 8537 store2.useSyncedValue("isInstantPhase", isInstantPhase); 8538 const rootDisabled = store2.useState("disabled"); 8539 const disabled2 = disabledProp ?? rootDisabled; 8540 const disabledRef = useValueAsRef(disabled2); 8541 const trackCursorAxis = store2.useState("trackCursorAxis"); 8542 const disableHoverablePopup = store2.useState("disableHoverablePopup"); 8543 const isNestedTriggerHoveredRef = React38.useRef(false); 8544 const nestedTriggerOpenTimeout = useTimeout(); 8545 const pointerTypeRef = React38.useRef(void 0); 8546 function getOpenDelay() { 8547 const providerDelay = providerContext?.delay; 8548 const groupOpenValue = typeof delayRef.current === "object" ? delayRef.current.open : void 0; 8549 let computedOpenDelay = delayWithDefault; 8550 if (hasProvider) { 8551 if (groupOpenValue !== 0) { 8552 computedOpenDelay = delay ?? providerDelay ?? delayWithDefault; 8553 } else { 8554 computedOpenDelay = 0; 8555 } 8556 } 8557 return computedOpenDelay; 8558 } 8559 function isEnabledNestedTriggerTarget(target) { 8560 const triggerEl = triggerElementRef.current; 8561 if (!triggerEl || !target) { 8562 return false; 8563 } 8564 const nearestTrigger = closestEnabledTooltipTrigger(target); 8565 return nearestTrigger !== null && nearestTrigger !== triggerEl && contains(triggerEl, nearestTrigger); 8566 } 8567 function detectNestedTriggerHover(target) { 8568 const nestedTriggerHovered = isEnabledNestedTriggerTarget(target); 8569 isNestedTriggerHoveredRef.current = nestedTriggerHovered; 8570 if (nestedTriggerHovered) { 8571 hoverInteraction.openChangeTimeout.clear(); 8572 hoverInteraction.restTimeout.clear(); 8573 hoverInteraction.restTimeoutPending = false; 8574 nestedTriggerOpenTimeout.clear(); 8575 } 8576 return nestedTriggerHovered; 8577 } 8578 const hoverProps = useHoverReferenceInteraction(floatingRootContext, { 8579 enabled: !disabled2, 8580 mouseOnly: true, 8581 move: false, 8582 handleClose: !disableHoverablePopup && trackCursorAxis !== "both" ? safePolygon() : null, 8583 restMs: getOpenDelay, 8584 delay() { 8585 const closeValue = typeof delayRef.current === "object" ? delayRef.current.close : void 0; 8586 let computedCloseDelay = closeDelayWithDefault; 8587 if (closeDelay == null && hasProvider) { 8588 computedCloseDelay = closeValue; 8589 } 8590 return { 8591 close: computedCloseDelay 8592 }; 8593 }, 8594 triggerElementRef, 8595 isActiveTrigger: isTriggerActive, 8596 isClosing: () => store2.select("transitionStatus") === "ending", 8597 shouldOpen() { 8598 return !isNestedTriggerHoveredRef.current; 8599 } 8600 }); 8601 const focusProps = useFocus(floatingRootContext, { 8602 enabled: !disabled2 8603 }).reference; 8604 const handleNestedTriggerHover = (event) => { 8605 const wasNestedTriggerHovered = isNestedTriggerHoveredRef.current; 8606 const target = getTargetElement(event); 8607 const nestedTriggerHovered = detectNestedTriggerHover(target); 8608 const triggerEl = triggerElementRef.current; 8609 const targetInsideTrigger = triggerEl && target && contains(triggerEl, target); 8610 if (nestedTriggerHovered && store2.select("open") && store2.select("lastOpenChangeReason") === reason_parts_exports.triggerHover) { 8611 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event)); 8612 return; 8613 } 8614 if (wasNestedTriggerHovered && !nestedTriggerHovered && targetInsideTrigger && !disabledRef.current && !store2.select("open") && triggerEl && // Match the hover hook's non-strict mouse fallback for mouse-only event sequences. 8615 isMouseLikePointerType(pointerTypeRef.current)) { 8616 const open = () => { 8617 if (!isNestedTriggerHoveredRef.current && !disabledRef.current && !store2.select("open")) { 8618 store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerEl)); 8619 } 8620 }; 8621 const openDelay = getOpenDelay(); 8622 if (openDelay === 0) { 8623 nestedTriggerOpenTimeout.clear(); 8624 open(); 8625 } else { 8626 nestedTriggerOpenTimeout.start(openDelay, open); 8627 } 8628 } 8629 }; 8630 const rootTriggerProps = store2.useState("triggerProps", isMountedByThisTrigger); 8631 const shouldApplyRootTriggerProps = isMountedByThisTrigger || trackCursorAxis !== "none"; 8632 const state = { 8633 open: isOpenedByThisTrigger 8634 }; 8635 const element = useRenderElement("button", componentProps, { 8636 state, 8637 ref: [forwardedRef, registerTrigger, triggerElementRef], 8638 props: [hoverProps, focusProps, shouldApplyRootTriggerProps ? rootTriggerProps : void 0, { 8639 onMouseOver(event) { 8640 handleNestedTriggerHover(event.nativeEvent); 8641 }, 8642 onFocus(event) { 8643 if (isEnabledNestedTriggerTarget(getTargetElement(event.nativeEvent))) { 8644 event.preventBaseUIHandler(); 8645 } 8646 }, 8647 onMouseLeave() { 8648 isNestedTriggerHoveredRef.current = false; 8649 nestedTriggerOpenTimeout.clear(); 8650 pointerTypeRef.current = void 0; 8651 }, 8652 onPointerEnter(event) { 8653 pointerTypeRef.current = event.pointerType; 8654 }, 8655 onPointerDown(event) { 8656 pointerTypeRef.current = event.pointerType; 8657 store2.set("closeOnClick", closeOnClick); 8658 if (closeOnClick && !store2.select("open")) { 8659 store2.cancelPendingOpen(event.nativeEvent); 8660 } 8661 }, 8662 onClick(event) { 8663 if (closeOnClick && !store2.select("open")) { 8664 store2.cancelPendingOpen(event.nativeEvent); 8665 } 8666 }, 8667 id: thisTriggerId, 8668 [TooltipTriggerDataAttributes.triggerDisabled]: disabled2 ? "" : void 0, 8669 [TOOLTIP_TRIGGER_IDENTIFIER]: disabled2 ? void 0 : "" 8670 }, elementProps], 8671 stateAttributesMapping: triggerOpenStateMapping 8672 }); 8673 return element; 8674 }); 8675 if (true) TooltipTrigger.displayName = "TooltipTrigger"; 8676 8677 // node_modules/@base-ui/react/tooltip/portal/TooltipPortal.mjs 8678 var React40 = __toESM(require_react(), 1); 8679 8680 // node_modules/@base-ui/react/tooltip/portal/TooltipPortalContext.mjs 8681 var React39 = __toESM(require_react(), 1); 8682 var TooltipPortalContext = /* @__PURE__ */ React39.createContext(void 0); 8683 if (true) TooltipPortalContext.displayName = "TooltipPortalContext"; 8684 function useTooltipPortalContext() { 8685 const value = React39.useContext(TooltipPortalContext); 8686 if (value === void 0) { 8687 throw new Error(true ? "Base UI: <Tooltip.Portal> is missing." : formatErrorMessage_default(70)); 8688 } 8689 return value; 8690 } 8691 8692 // node_modules/@base-ui/react/tooltip/portal/TooltipPortal.mjs 8693 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1); 8694 var TooltipPortal = /* @__PURE__ */ React40.forwardRef(function TooltipPortal2(props, forwardedRef) { 8695 const { 8696 keepMounted = false, 8697 ...portalProps 8698 } = props; 8699 const store2 = useTooltipRootContext(); 8700 const mounted = store2.useState("mounted"); 8701 const shouldRender = mounted || keepMounted; 8702 if (!shouldRender) { 8703 return null; 8704 } 8705 return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(TooltipPortalContext.Provider, { 8706 value: keepMounted, 8707 children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(FloatingPortalLite, { 8708 ref: forwardedRef, 8709 ...portalProps 8710 }) 8711 }); 8712 }); 8713 if (true) TooltipPortal.displayName = "TooltipPortal"; 8714 8715 // node_modules/@base-ui/react/tooltip/positioner/TooltipPositioner.mjs 8716 var React42 = __toESM(require_react(), 1); 8717 8718 // node_modules/@base-ui/react/tooltip/positioner/TooltipPositionerContext.mjs 8719 var React41 = __toESM(require_react(), 1); 8720 var TooltipPositionerContext = /* @__PURE__ */ React41.createContext(void 0); 8721 if (true) TooltipPositionerContext.displayName = "TooltipPositionerContext"; 8722 function useTooltipPositionerContext() { 8723 const context = React41.useContext(TooltipPositionerContext); 8724 if (context === void 0) { 8725 throw new Error(true ? "Base UI: TooltipPositionerContext is missing. TooltipPositioner parts must be placed within <Tooltip.Positioner>." : formatErrorMessage_default(71)); 8726 } 8727 return context; 8728 } 8729 8730 // node_modules/@base-ui/react/tooltip/positioner/TooltipPositioner.mjs 8731 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1); 8732 var TooltipPositioner = /* @__PURE__ */ React42.forwardRef(function TooltipPositioner2(componentProps, forwardedRef) { 8733 const { 8734 render, 8735 className, 8736 anchor, 8737 positionMethod = "absolute", 8738 side = "top", 8739 align = "center", 8740 sideOffset = 0, 8741 alignOffset = 0, 8742 collisionBoundary = "clipping-ancestors", 8743 collisionPadding = 5, 8744 arrowPadding = 5, 8745 sticky = false, 8746 disableAnchorTracking = false, 8747 collisionAvoidance = POPUP_COLLISION_AVOIDANCE, 8748 style, 8749 ...elementProps 8750 } = componentProps; 8751 const store2 = useTooltipRootContext(); 8752 const keepMounted = useTooltipPortalContext(); 8753 const open = store2.useState("open"); 8754 const mounted = store2.useState("mounted"); 8755 const trackCursorAxis = store2.useState("trackCursorAxis"); 8756 const disableHoverablePopup = store2.useState("disableHoverablePopup"); 8757 const floatingRootContext = store2.useState("floatingRootContext"); 8758 const instantType = store2.useState("instantType"); 8759 const transitionStatus = store2.useState("transitionStatus"); 8760 const hasViewport = store2.useState("hasViewport"); 8761 const positioning = useAnchorPositioning({ 8762 anchor, 8763 positionMethod, 8764 floatingRootContext, 8765 mounted, 8766 side, 8767 sideOffset, 8768 align, 8769 alignOffset, 8770 collisionBoundary, 8771 collisionPadding, 8772 sticky, 8773 arrowPadding, 8774 disableAnchorTracking, 8775 keepMounted, 8776 collisionAvoidance, 8777 adaptiveOrigin: hasViewport ? adaptiveOrigin : void 0 8778 }); 8779 const state = React42.useMemo(() => ({ 8780 open, 8781 side: positioning.side, 8782 align: positioning.align, 8783 anchorHidden: positioning.anchorHidden, 8784 instant: trackCursorAxis !== "none" ? "tracking-cursor" : instantType 8785 }), [open, positioning.side, positioning.align, positioning.anchorHidden, trackCursorAxis, instantType]); 8786 const element = usePositioner(componentProps, state, { 8787 styles: positioning.positionerStyles, 8788 transitionStatus, 8789 props: elementProps, 8790 refs: [forwardedRef, store2.useStateSetter("positionerElement")], 8791 hidden: !mounted, 8792 inert: !open || trackCursorAxis === "both" || disableHoverablePopup 8793 }); 8794 return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(TooltipPositionerContext.Provider, { 8795 value: positioning, 8796 children: element 8797 }); 8798 }); 8799 if (true) TooltipPositioner.displayName = "TooltipPositioner"; 8800 8801 // node_modules/@base-ui/react/tooltip/popup/TooltipPopup.mjs 8802 var React43 = __toESM(require_react(), 1); 8803 var stateAttributesMapping = { 8804 ...popupStateMapping, 8805 ...transitionStatusMapping 8806 }; 8807 var TooltipPopup = /* @__PURE__ */ React43.forwardRef(function TooltipPopup2(componentProps, forwardedRef) { 8808 const { 8809 render, 8810 className, 8811 style, 8812 ...elementProps 8813 } = componentProps; 8814 const store2 = useTooltipRootContext(); 8815 const { 8816 side, 8817 align 8818 } = useTooltipPositionerContext(); 8819 const open = store2.useState("open"); 8820 const instantType = store2.useState("instantType"); 8821 const transitionStatus = store2.useState("transitionStatus"); 8822 const popupProps = store2.useState("popupProps"); 8823 const floatingContext = store2.useState("floatingRootContext"); 8824 const disabled2 = store2.useState("disabled"); 8825 const closeDelay = store2.useState("closeDelay"); 8826 useOpenChangeComplete({ 8827 open, 8828 ref: store2.context.popupRef, 8829 onComplete() { 8830 if (open) { 8831 store2.context.onOpenChangeComplete?.(true); 8832 } 8833 } 8834 }); 8835 useHoverFloatingInteraction(floatingContext, { 8836 enabled: !disabled2, 8837 closeDelay 8838 }); 8839 const setPopupElement = store2.useStateSetter("popupElement"); 8840 const state = { 8841 open, 8842 side, 8843 align, 8844 instant: instantType, 8845 transitionStatus 8846 }; 8847 const element = useRenderElement("div", componentProps, { 8848 state, 8849 ref: [forwardedRef, store2.context.popupRef, setPopupElement], 8850 props: [popupProps, getDisabledMountTransitionStyles(transitionStatus), elementProps], 8851 stateAttributesMapping 8852 }); 8853 return element; 8854 }); 8855 if (true) TooltipPopup.displayName = "TooltipPopup"; 8856 8857 // node_modules/@base-ui/react/tooltip/arrow/TooltipArrow.mjs 8858 var React44 = __toESM(require_react(), 1); 8859 var TooltipArrow = /* @__PURE__ */ React44.forwardRef(function TooltipArrow2(componentProps, forwardedRef) { 8860 const { 8861 render, 8862 className, 8863 style, 8864 ...elementProps 8865 } = componentProps; 8866 const store2 = useTooltipRootContext(); 8867 const { 8868 arrowRef, 8869 side, 8870 align, 8871 arrowUncentered, 8872 arrowStyles 8873 } = useTooltipPositionerContext(); 8874 const open = store2.useState("open"); 8875 const instantType = store2.useState("instantType"); 8876 const state = { 8877 open, 8878 side, 8879 align, 8880 uncentered: arrowUncentered, 8881 instant: instantType 8882 }; 8883 const element = useRenderElement("div", componentProps, { 8884 state, 8885 ref: [forwardedRef, arrowRef], 8886 props: [{ 8887 style: arrowStyles, 8888 "aria-hidden": true 8889 }, elementProps], 8890 stateAttributesMapping: popupStateMapping 8891 }); 8892 return element; 8893 }); 8894 if (true) TooltipArrow.displayName = "TooltipArrow"; 8895 8896 // node_modules/@base-ui/react/tooltip/provider/TooltipProvider.mjs 8897 var React45 = __toESM(require_react(), 1); 8898 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1); 8899 var TooltipProvider = function TooltipProvider2(props) { 8900 const { 8901 delay, 8902 closeDelay, 8903 timeout = 400 8904 } = props; 8905 const contextValue = React45.useMemo(() => ({ 8906 delay, 8907 closeDelay 8908 }), [delay, closeDelay]); 8909 const delayValue = React45.useMemo(() => ({ 8910 open: delay, 8911 close: closeDelay 8912 }), [delay, closeDelay]); 8913 return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(TooltipProviderContext.Provider, { 8914 value: contextValue, 8915 children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(FloatingDelayGroup, { 8916 delay: delayValue, 8917 timeoutMs: timeout, 8918 children: props.children 8919 }) 8920 }); 8921 }; 8922 if (true) TooltipProvider.displayName = "TooltipProvider"; 8923 8924 // node_modules/@base-ui/react/tooltip/viewport/TooltipViewport.mjs 8925 var React46 = __toESM(require_react(), 1); 8926 8927 // node_modules/@base-ui/react/tooltip/viewport/TooltipViewportCssVars.mjs 8928 var TooltipViewportCssVars = /* @__PURE__ */ (function(TooltipViewportCssVars2) { 8929 TooltipViewportCssVars2["popupWidth"] = "--popup-width"; 8930 TooltipViewportCssVars2["popupHeight"] = "--popup-height"; 8931 return TooltipViewportCssVars2; 8932 })({}); 8933 8934 // node_modules/@base-ui/react/tooltip/viewport/TooltipViewport.mjs 8935 var stateAttributesMapping2 = { 8936 activationDirection: (value) => value ? { 8937 "data-activation-direction": value 8938 } : null 8939 }; 8940 var TooltipViewport = /* @__PURE__ */ React46.forwardRef(function TooltipViewport2(componentProps, forwardedRef) { 8941 const { 8942 render, 8943 className, 8944 style, 8945 children, 8946 ...elementProps 8947 } = componentProps; 8948 const store2 = useTooltipRootContext(); 8949 const positioner = useTooltipPositionerContext(); 8950 const instantType = store2.useState("instantType"); 8951 const { 8952 children: childrenToRender, 8953 state: viewportState 8954 } = usePopupViewport({ 8955 store: store2, 8956 side: positioner.side, 8957 cssVars: TooltipViewportCssVars, 8958 children 8959 }); 8960 const state = { 8961 activationDirection: viewportState.activationDirection, 8962 transitioning: viewportState.transitioning, 8963 instant: instantType 8964 }; 8965 return useRenderElement("div", componentProps, { 8966 state, 8967 ref: forwardedRef, 8968 props: [elementProps, { 8969 children: childrenToRender 8970 }], 8971 stateAttributesMapping: stateAttributesMapping2 8972 }); 8973 }); 8974 if (true) TooltipViewport.displayName = "TooltipViewport"; 8975 8976 // node_modules/@base-ui/react/tooltip/store/TooltipHandle.mjs 8977 var TooltipHandle = class { 8978 /** 8979 * Internal store holding the tooltip state. 8980 * @internal 8981 */ 8982 constructor() { 8983 this.store = new TooltipStore(); 8984 } 8985 /** 8986 * Opens the tooltip and associates it with the trigger with the given ID. 8987 * The trigger must be a Tooltip.Trigger component with this handle passed as a prop. 8988 * 8989 * This method should only be called in an event handler or an effect (not during rendering). 8990 * 8991 * @param triggerId ID of the trigger to associate with the tooltip. 8992 */ 8993 open(triggerId) { 8994 const triggerElement = triggerId ? this.store.context.triggerElements.getById(triggerId) : void 0; 8995 if (triggerId && !triggerElement) { 8996 throw new Error(true ? `Base UI: TooltipHandle.open: No trigger found with id "$triggerId}".` : formatErrorMessage_default(81, triggerId)); 8997 } 8998 this.store.setOpen(true, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, triggerElement)); 8999 } 9000 /** 9001 * Closes the tooltip. 9002 */ 9003 close() { 9004 this.store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, void 0)); 9005 } 9006 /** 9007 * Indicates whether the tooltip is currently open. 9008 */ 9009 get isOpen() { 9010 return this.store.select("open"); 9011 } 9012 }; 9013 function createTooltipHandle() { 9014 return new TooltipHandle(); 9015 } 9016 9017 // node_modules/@base-ui/react/use-render/useRender.mjs 9018 function useRender(params) { 9019 return useRenderElement(params.defaultTagName ?? "div", params, params); 9020 } 9021 9022 // packages/icons/build-module/icon/index.mjs 9023 var import_element11 = __toESM(require_element(), 1); 9024 var icon_default = (0, import_element11.forwardRef)( 9025 ({ icon, size: size4 = 24, ...props }, ref) => { 9026 return (0, import_element11.cloneElement)(icon, { 9027 width: size4, 9028 height: size4, 9029 ...props, 9030 ref 9031 }); 9032 } 9033 ); 9034 9035 // packages/icons/build-module/library/star-empty.mjs 9036 var import_primitives = __toESM(require_primitives(), 1); 9037 var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1); 9038 var star_empty_default = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M9.706 8.646a.25.25 0 01-.188.137l-4.626.672a.25.25 0 00-.139.427l3.348 3.262a.25.25 0 01.072.222l-.79 4.607a.25.25 0 00.362.264l4.138-2.176a.25.25 0 01.233 0l4.137 2.175a.25.25 0 00.363-.263l-.79-4.607a.25.25 0 01.072-.222l3.347-3.262a.25.25 0 00-.139-.427l-4.626-.672a.25.25 0 01-.188-.137l-2.069-4.192a.25.25 0 00-.448 0L9.706 8.646zM12 7.39l-.948 1.921a1.75 1.75 0 01-1.317.957l-2.12.308 1.534 1.495c.412.402.6.982.503 1.55l-.362 2.11 1.896-.997a1.75 1.75 0 011.629 0l1.895.997-.362-2.11a1.75 1.75 0 01.504-1.55l1.533-1.495-2.12-.308a1.75 1.75 0 01-1.317-.957L12 7.39z" }) }); 9039 9040 // packages/icons/build-module/library/star-filled.mjs 9041 var import_primitives2 = __toESM(require_primitives(), 1); 9042 var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1); 9043 var star_filled_default = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives2.Path, { d: "M11.776 4.454a.25.25 0 01.448 0l2.069 4.192a.25.25 0 00.188.137l4.626.672a.25.25 0 01.139.426l-3.348 3.263a.25.25 0 00-.072.222l.79 4.607a.25.25 0 01-.362.263l-4.138-2.175a.25.25 0 00-.232 0l-4.138 2.175a.25.25 0 01-.363-.263l.79-4.607a.25.25 0 00-.071-.222L4.754 9.881a.25.25 0 01.139-.426l4.626-.672a.25.25 0 00.188-.137l2.069-4.192z" }) }); 9044 9045 // packages/icons/build-module/library/star-half.mjs 9046 var import_primitives3 = __toESM(require_primitives(), 1); 9047 var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1); 9048 var star_half_default = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives3.Path, { d: "M9.518 8.783a.25.25 0 00.188-.137l2.069-4.192a.25.25 0 01.448 0l2.07 4.192a.25.25 0 00.187.137l4.626.672a.25.25 0 01.139.427l-3.347 3.262a.25.25 0 00-.072.222l.79 4.607a.25.25 0 01-.363.264l-4.137-2.176a.25.25 0 00-.233 0l-4.138 2.175a.25.25 0 01-.362-.263l.79-4.607a.25.25 0 00-.072-.222L4.753 9.882a.25.25 0 01.14-.427l4.625-.672zM12 14.533c.28 0 .559.067.814.2l1.895.997-.362-2.11a1.75 1.75 0 01.504-1.55l1.533-1.495-2.12-.308a1.75 1.75 0 01-1.317-.957L12 7.39v7.143z" }) }); 9049 9050 // packages/ui/build-module/utils/render-slot-with-children.mjs 9051 var import_element12 = __toESM(require_element(), 1); 9052 function renderSlotWithChildren(slot, defaultSlot, children) { 9053 return (0, import_element12.cloneElement)(slot ?? defaultSlot, { children }); 9054 } 9055 9056 // packages/ui/build-module/utils/theme-provider.mjs 9057 var theme = __toESM(require_theme(), 1); 9058 9059 // packages/ui/build-module/lock-unlock.mjs 9060 var import_private_apis = __toESM(require_private_apis(), 1); 9061 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)( 9062 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.", 9063 "@wordpress/ui" 9064 ); 9065 9066 // packages/ui/build-module/utils/theme-provider.mjs 9067 function getThemeProvider() { 9068 const themePackage = theme; 9069 if (themePackage.ThemeProvider) { 9070 return themePackage.ThemeProvider; 9071 } 9072 if (!themePackage.privateApis) { 9073 throw new Error( 9074 "@wordpress/ui: @wordpress/theme must expose `ThemeProvider` or `privateApis.ThemeProvider`." 9075 ); 9076 } 9077 return unlock( 9078 themePackage.privateApis 9079 ).ThemeProvider; 9080 } 9081 var ThemeProvider = getThemeProvider(); 9082 9083 // packages/ui/build-module/tooltip/index.mjs 9084 var tooltip_exports = {}; 9085 __export(tooltip_exports, { 9086 Popup: () => Popup, 9087 Portal: () => Portal, 9088 Positioner: () => Positioner, 9089 Provider: () => Provider, 9090 Root: () => Root, 9091 Trigger: () => Trigger 9092 }); 9093 9094 // packages/ui/build-module/tooltip/popup.mjs 9095 var import_element15 = __toESM(require_element(), 1); 9096 9097 // packages/ui/build-module/tooltip/portal.mjs 9098 var import_element13 = __toESM(require_element(), 1); 9099 9100 // packages/ui/build-module/utils/wp-compat-overlay-slot.mjs 9101 var STYLE_HASH_ATTRIBUTE = "data-wp-hash"; 9102 function getRuntime() { 9103 const globalScope = globalThis; 9104 if (globalScope.__wpStyleRuntime) { 9105 return globalScope.__wpStyleRuntime; 9106 } 9107 globalScope.__wpStyleRuntime = { 9108 documents: /* @__PURE__ */ new Map(), 9109 styles: /* @__PURE__ */ new Map(), 9110 injectedStyles: /* @__PURE__ */ new WeakMap() 9111 }; 9112 if (typeof document !== "undefined") { 9113 registerDocument(document); 9114 } 9115 return globalScope.__wpStyleRuntime; 9116 } 9117 function documentContainsStyleHash(targetDocument, hash) { 9118 if (!targetDocument.head) { 9119 return false; 9120 } 9121 for (const style of targetDocument.head.querySelectorAll( 9122 `style[$STYLE_HASH_ATTRIBUTE}]` 9123 )) { 9124 if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) { 9125 return true; 9126 } 9127 } 9128 return false; 9129 } 9130 function injectStyle(targetDocument, hash, css) { 9131 if (!targetDocument.head) { 9132 return; 9133 } 9134 const runtime = getRuntime(); 9135 let injectedStyles = runtime.injectedStyles.get(targetDocument); 9136 if (!injectedStyles) { 9137 injectedStyles = /* @__PURE__ */ new Set(); 9138 runtime.injectedStyles.set(targetDocument, injectedStyles); 9139 } 9140 if (injectedStyles.has(hash)) { 9141 return; 9142 } 9143 if (documentContainsStyleHash(targetDocument, hash)) { 9144 injectedStyles.add(hash); 9145 return; 9146 } 9147 const style = targetDocument.createElement("style"); 9148 style.setAttribute(STYLE_HASH_ATTRIBUTE, hash); 9149 style.appendChild(targetDocument.createTextNode(css)); 9150 targetDocument.head.appendChild(style); 9151 injectedStyles.add(hash); 9152 } 9153 function registerDocument(targetDocument) { 9154 const runtime = getRuntime(); 9155 runtime.documents.set( 9156 targetDocument, 9157 (runtime.documents.get(targetDocument) ?? 0) + 1 9158 ); 9159 for (const [hash, css] of runtime.styles) { 9160 injectStyle(targetDocument, hash, css); 9161 } 9162 return () => { 9163 const count = runtime.documents.get(targetDocument); 9164 if (count === void 0) { 9165 return; 9166 } 9167 if (count <= 1) { 9168 runtime.documents.delete(targetDocument); 9169 return; 9170 } 9171 runtime.documents.set(targetDocument, count - 1); 9172 }; 9173 } 9174 function registerStyle(hash, css) { 9175 const runtime = getRuntime(); 9176 runtime.styles.set(hash, css); 9177 for (const targetDocument of runtime.documents.keys()) { 9178 injectStyle(targetDocument, hash, css); 9179 } 9180 } 9181 if (typeof process === "undefined" || true) { 9182 registerStyle("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}}}"); 9183 } 9184 var wp_compat_overlay_slot_default = { "slot": "_11fc52b637ff8a7e__slot" }; 9185 var WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE = "data-wp-compat-overlay-slot"; 9186 function resolveOwnerDocument() { 9187 return typeof document === "undefined" ? null : document; 9188 } 9189 function isInWordPressEnvironment() { 9190 let topWp; 9191 try { 9192 topWp = window.top?.wp; 9193 } catch { 9194 } 9195 const wp = topWp ?? window.wp; 9196 return typeof wp?.components === "object" && wp.components !== null; 9197 } 9198 var cachedSlot = null; 9199 function ensureSlotIsAccessible(element) { 9200 element.setAttribute("aria-hidden", "false"); 9201 return element; 9202 } 9203 function createSlot(ownerDocument2) { 9204 const element = ownerDocument2.createElement("div"); 9205 element.setAttribute(WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE, ""); 9206 if (wp_compat_overlay_slot_default.slot) { 9207 element.classList.add(wp_compat_overlay_slot_default.slot); 9208 } 9209 ownerDocument2.body.appendChild(element); 9210 return element; 9211 } 9212 function getWpCompatOverlaySlot() { 9213 if (typeof window === "undefined") { 9214 return void 0; 9215 } 9216 if (!isInWordPressEnvironment() && window.__wpUiCompatOverlaySlotEnabled !== true) { 9217 return void 0; 9218 } 9219 const ownerDocument2 = resolveOwnerDocument(); 9220 if (!ownerDocument2 || !ownerDocument2.body) { 9221 return void 0; 9222 } 9223 if (cachedSlot && cachedSlot.ownerDocument === ownerDocument2 && cachedSlot.isConnected) { 9224 return ensureSlotIsAccessible(cachedSlot); 9225 } 9226 const existing = ownerDocument2.querySelector( 9227 `[$WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE}]` 9228 ); 9229 if (existing instanceof HTMLDivElement) { 9230 cachedSlot = ensureSlotIsAccessible(existing); 9231 return cachedSlot; 9232 } 9233 if (cachedSlot?.isConnected) { 9234 cachedSlot.remove(); 9235 } 9236 cachedSlot = ensureSlotIsAccessible(createSlot(ownerDocument2)); 9237 return cachedSlot; 9238 } 9239 9240 // packages/ui/build-module/tooltip/portal.mjs 9241 var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1); 9242 var Portal = (0, import_element13.forwardRef)( 9243 function TooltipPortal3({ container, ...restProps }, ref) { 9244 return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)( 9245 index_parts_exports.Portal, 9246 { 9247 container: container ?? getWpCompatOverlaySlot(), 9248 ...restProps, 9249 ref 9250 } 9251 ); 9252 } 9253 ); 9254 9255 // packages/ui/build-module/tooltip/positioner.mjs 9256 var import_element14 = __toESM(require_element(), 1); 9257 var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1); 9258 var STYLE_HASH_ATTRIBUTE2 = "data-wp-hash"; 9259 function getRuntime2() { 9260 const globalScope = globalThis; 9261 if (globalScope.__wpStyleRuntime) { 9262 return globalScope.__wpStyleRuntime; 9263 } 9264 globalScope.__wpStyleRuntime = { 9265 documents: /* @__PURE__ */ new Map(), 9266 styles: /* @__PURE__ */ new Map(), 9267 injectedStyles: /* @__PURE__ */ new WeakMap() 9268 }; 9269 if (typeof document !== "undefined") { 9270 registerDocument2(document); 9271 } 9272 return globalScope.__wpStyleRuntime; 9273 } 9274 function documentContainsStyleHash2(targetDocument, hash) { 9275 if (!targetDocument.head) { 9276 return false; 9277 } 9278 for (const style of targetDocument.head.querySelectorAll( 9279 `style[$STYLE_HASH_ATTRIBUTE2}]` 9280 )) { 9281 if (style.getAttribute(STYLE_HASH_ATTRIBUTE2) === hash) { 9282 return true; 9283 } 9284 } 9285 return false; 9286 } 9287 function injectStyle2(targetDocument, hash, css) { 9288 if (!targetDocument.head) { 9289 return; 9290 } 9291 const runtime = getRuntime2(); 9292 let injectedStyles = runtime.injectedStyles.get(targetDocument); 9293 if (!injectedStyles) { 9294 injectedStyles = /* @__PURE__ */ new Set(); 9295 runtime.injectedStyles.set(targetDocument, injectedStyles); 9296 } 9297 if (injectedStyles.has(hash)) { 9298 return; 9299 } 9300 if (documentContainsStyleHash2(targetDocument, hash)) { 9301 injectedStyles.add(hash); 9302 return; 9303 } 9304 const style = targetDocument.createElement("style"); 9305 style.setAttribute(STYLE_HASH_ATTRIBUTE2, hash); 9306 style.appendChild(targetDocument.createTextNode(css)); 9307 targetDocument.head.appendChild(style); 9308 injectedStyles.add(hash); 9309 } 9310 function registerDocument2(targetDocument) { 9311 const runtime = getRuntime2(); 9312 runtime.documents.set( 9313 targetDocument, 9314 (runtime.documents.get(targetDocument) ?? 0) + 1 9315 ); 9316 for (const [hash, css] of runtime.styles) { 9317 injectStyle2(targetDocument, hash, css); 9318 } 9319 return () => { 9320 const count = runtime.documents.get(targetDocument); 9321 if (count === void 0) { 9322 return; 9323 } 9324 if (count <= 1) { 9325 runtime.documents.delete(targetDocument); 9326 return; 9327 } 9328 runtime.documents.set(targetDocument, count - 1); 9329 }; 9330 } 9331 function registerStyle2(hash, css) { 9332 const runtime = getRuntime2(); 9333 runtime.styles.set(hash, css); 9334 for (const targetDocument of runtime.documents.keys()) { 9335 injectStyle2(targetDocument, hash, css); 9336 } 9337 } 9338 if (typeof process === "undefined" || true) { 9339 registerStyle2("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}"); 9340 } 9341 var resets_default = { "box-sizing": "_336cd3e4e743482f__box-sizing" }; 9342 if (typeof process === "undefined" || true) { 9343 registerStyle2("19fcc06039", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{--_wp-ui-elevation-sm:0 1px 2px rgba(0,0,0,.05),0 2px 3px rgba(0,0,0,.04),0 6px 6px rgba(0,0,0,.03),0 8px 8px rgba(0,0,0,.02);background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-md,4px);box-shadow:var(--_wp-ui-elevation-sm);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-sm,12px);line-height:1.4;padding:var(--wpds-dimension-padding-xs,4px) var(--wpds-dimension-padding-sm,8px);@media (forced-colors:active){border-bottom-color:CanvasText;border-bottom-style:solid;border-bottom-width:1px;border-left-color:CanvasText;border-left-style:solid;border-left-width:1px;border-right-color:CanvasText;border-right-style:solid;border-right-width:1px;border-top-color:CanvasText;border-top-style:solid;border-top-width:1px}}}}'); 9344 } 9345 var style_default = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" }; 9346 var Positioner = (0, import_element14.forwardRef)( 9347 function TooltipPositioner3({ align = "center", className, side = "top", sideOffset = 4, ...props }, ref) { 9348 return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)( 9349 index_parts_exports.Positioner, 9350 { 9351 ref, 9352 align, 9353 side, 9354 sideOffset, 9355 ...props, 9356 className: clsx_default( 9357 resets_default["box-sizing"], 9358 style_default.positioner, 9359 className 9360 ) 9361 } 9362 ); 9363 } 9364 ); 9365 9366 // packages/ui/build-module/tooltip/popup.mjs 9367 var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1); 9368 var STYLE_HASH_ATTRIBUTE3 = "data-wp-hash"; 9369 function getRuntime3() { 9370 const globalScope = globalThis; 9371 if (globalScope.__wpStyleRuntime) { 9372 return globalScope.__wpStyleRuntime; 9373 } 9374 globalScope.__wpStyleRuntime = { 9375 documents: /* @__PURE__ */ new Map(), 9376 styles: /* @__PURE__ */ new Map(), 9377 injectedStyles: /* @__PURE__ */ new WeakMap() 9378 }; 9379 if (typeof document !== "undefined") { 9380 registerDocument3(document); 9381 } 9382 return globalScope.__wpStyleRuntime; 9383 } 9384 function documentContainsStyleHash3(targetDocument, hash) { 9385 if (!targetDocument.head) { 9386 return false; 9387 } 9388 for (const style of targetDocument.head.querySelectorAll( 9389 `style[$STYLE_HASH_ATTRIBUTE3}]` 9390 )) { 9391 if (style.getAttribute(STYLE_HASH_ATTRIBUTE3) === hash) { 9392 return true; 9393 } 9394 } 9395 return false; 9396 } 9397 function injectStyle3(targetDocument, hash, css) { 9398 if (!targetDocument.head) { 9399 return; 9400 } 9401 const runtime = getRuntime3(); 9402 let injectedStyles = runtime.injectedStyles.get(targetDocument); 9403 if (!injectedStyles) { 9404 injectedStyles = /* @__PURE__ */ new Set(); 9405 runtime.injectedStyles.set(targetDocument, injectedStyles); 9406 } 9407 if (injectedStyles.has(hash)) { 9408 return; 9409 } 9410 if (documentContainsStyleHash3(targetDocument, hash)) { 9411 injectedStyles.add(hash); 9412 return; 9413 } 9414 const style = targetDocument.createElement("style"); 9415 style.setAttribute(STYLE_HASH_ATTRIBUTE3, hash); 9416 style.appendChild(targetDocument.createTextNode(css)); 9417 targetDocument.head.appendChild(style); 9418 injectedStyles.add(hash); 9419 } 9420 function registerDocument3(targetDocument) { 9421 const runtime = getRuntime3(); 9422 runtime.documents.set( 9423 targetDocument, 9424 (runtime.documents.get(targetDocument) ?? 0) + 1 9425 ); 9426 for (const [hash, css] of runtime.styles) { 9427 injectStyle3(targetDocument, hash, css); 9428 } 9429 return () => { 9430 const count = runtime.documents.get(targetDocument); 9431 if (count === void 0) { 9432 return; 9433 } 9434 if (count <= 1) { 9435 runtime.documents.delete(targetDocument); 9436 return; 9437 } 9438 runtime.documents.set(targetDocument, count - 1); 9439 }; 9440 } 9441 function registerStyle3(hash, css) { 9442 const runtime = getRuntime3(); 9443 runtime.styles.set(hash, css); 9444 for (const targetDocument of runtime.documents.keys()) { 9445 injectStyle3(targetDocument, hash, css); 9446 } 9447 } 9448 if (typeof process === "undefined" || true) { 9449 registerStyle3("19fcc06039", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{--_wp-ui-elevation-sm:0 1px 2px rgba(0,0,0,.05),0 2px 3px rgba(0,0,0,.04),0 6px 6px rgba(0,0,0,.03),0 8px 8px rgba(0,0,0,.02);background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-md,4px);box-shadow:var(--_wp-ui-elevation-sm);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-sm,12px);line-height:1.4;padding:var(--wpds-dimension-padding-xs,4px) var(--wpds-dimension-padding-sm,8px);@media (forced-colors:active){border-bottom-color:CanvasText;border-bottom-style:solid;border-bottom-width:1px;border-left-color:CanvasText;border-left-style:solid;border-left-width:1px;border-right-color:CanvasText;border-right-style:solid;border-right-width:1px;border-top-color:CanvasText;border-top-style:solid;border-top-width:1px}}}}'); 9450 } 9451 var style_default2 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" }; 9452 var POPUP_COLOR = { background: "#1e1e1e" }; 9453 var Popup = (0, import_element15.forwardRef)(function TooltipPopup3({ portal, positioner, children, className, ...props }, ref) { 9454 const popupContent = /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ThemeProvider, { color: POPUP_COLOR, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)( 9455 index_parts_exports.Popup, 9456 { 9457 ref, 9458 className: clsx_default(style_default2.popup, className), 9459 ...props, 9460 children 9461 } 9462 ) }); 9463 const positionedPopup = renderSlotWithChildren( 9464 positioner, 9465 /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Positioner, {}), 9466 popupContent 9467 ); 9468 return renderSlotWithChildren(portal, /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Portal, {}), positionedPopup); 9469 }); 9470 9471 // packages/ui/build-module/tooltip/trigger.mjs 9472 var import_element16 = __toESM(require_element(), 1); 9473 var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1); 9474 var Trigger = (0, import_element16.forwardRef)( 9475 function TooltipTrigger3(props, ref) { 9476 return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(index_parts_exports.Trigger, { ref, ...props }); 9477 } 9478 ); 9479 9480 // packages/ui/build-module/tooltip/root.mjs 9481 var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1); 9482 function Root(props) { 9483 return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(index_parts_exports.Root, { ...props }); 9484 } 9485 9486 // packages/ui/build-module/tooltip/provider.mjs 9487 var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1); 9488 function Provider({ ...props }) { 9489 return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(index_parts_exports.Provider, { ...props }); 9490 } 9491 9492 // packages/ui/build-module/visually-hidden/visually-hidden.mjs 9493 var import_element17 = __toESM(require_element(), 1); 9494 var STYLE_HASH_ATTRIBUTE4 = "data-wp-hash"; 9495 function getRuntime4() { 9496 const globalScope = globalThis; 9497 if (globalScope.__wpStyleRuntime) { 9498 return globalScope.__wpStyleRuntime; 9499 } 9500 globalScope.__wpStyleRuntime = { 9501 documents: /* @__PURE__ */ new Map(), 9502 styles: /* @__PURE__ */ new Map(), 9503 injectedStyles: /* @__PURE__ */ new WeakMap() 9504 }; 9505 if (typeof document !== "undefined") { 9506 registerDocument4(document); 9507 } 9508 return globalScope.__wpStyleRuntime; 9509 } 9510 function documentContainsStyleHash4(targetDocument, hash) { 9511 if (!targetDocument.head) { 9512 return false; 9513 } 9514 for (const style of targetDocument.head.querySelectorAll( 9515 `style[$STYLE_HASH_ATTRIBUTE4}]` 9516 )) { 9517 if (style.getAttribute(STYLE_HASH_ATTRIBUTE4) === hash) { 9518 return true; 9519 } 9520 } 9521 return false; 9522 } 9523 function injectStyle4(targetDocument, hash, css) { 9524 if (!targetDocument.head) { 9525 return; 9526 } 9527 const runtime = getRuntime4(); 9528 let injectedStyles = runtime.injectedStyles.get(targetDocument); 9529 if (!injectedStyles) { 9530 injectedStyles = /* @__PURE__ */ new Set(); 9531 runtime.injectedStyles.set(targetDocument, injectedStyles); 9532 } 9533 if (injectedStyles.has(hash)) { 9534 return; 9535 } 9536 if (documentContainsStyleHash4(targetDocument, hash)) { 9537 injectedStyles.add(hash); 9538 return; 9539 } 9540 const style = targetDocument.createElement("style"); 9541 style.setAttribute(STYLE_HASH_ATTRIBUTE4, hash); 9542 style.appendChild(targetDocument.createTextNode(css)); 9543 targetDocument.head.appendChild(style); 9544 injectedStyles.add(hash); 9545 } 9546 function registerDocument4(targetDocument) { 9547 const runtime = getRuntime4(); 9548 runtime.documents.set( 9549 targetDocument, 9550 (runtime.documents.get(targetDocument) ?? 0) + 1 9551 ); 9552 for (const [hash, css] of runtime.styles) { 9553 injectStyle4(targetDocument, hash, css); 9554 } 9555 return () => { 9556 const count = runtime.documents.get(targetDocument); 9557 if (count === void 0) { 9558 return; 9559 } 9560 if (count <= 1) { 9561 runtime.documents.delete(targetDocument); 9562 return; 9563 } 9564 runtime.documents.set(targetDocument, count - 1); 9565 }; 9566 } 9567 function registerStyle4(hash, css) { 9568 const runtime = getRuntime4(); 9569 runtime.styles.set(hash, css); 9570 for (const targetDocument of runtime.documents.keys()) { 9571 injectStyle4(targetDocument, hash, css); 9572 } 9573 } 9574 if (typeof process === "undefined" || true) { 9575 registerStyle4("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}}}"); 9576 } 9577 var style_default3 = { "visually-hidden": "f37b9e2e191ebd66__visually-hidden" }; 9578 var VisuallyHidden = (0, import_element17.forwardRef)( 9579 function VisuallyHidden2({ render, ...restProps }, ref) { 9580 const element = useRender({ 9581 render, 9582 ref, 9583 props: mergeProps( 9584 { className: style_default3["visually-hidden"] }, 9585 restProps, 9586 { 9587 // @ts-expect-error Arbitrary data-* attributes aren't indexable on the typed div props. Kept hardcoded so consumers can't change or remove it. 9588 "data-visually-hidden": "" 9589 } 9590 ) 9591 }); 9592 return element; 9593 } 9594 ); 9595 9596 // packages/block-directory/build-module/components/block-ratings/stars.mjs 9597 var import_i18n2 = __toESM(require_i18n(), 1); 9598 var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1); 9599 function Stars({ rating }) { 9600 const stars = Math.round(rating / 0.5) * 0.5; 9601 const fullStarCount = Math.floor(rating); 9602 const halfStarCount = Math.ceil(rating - fullStarCount); 9603 const emptyStarCount = 5 - (fullStarCount + halfStarCount); 9604 return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)( 9605 "span", 9606 { 9607 "aria-label": (0, import_i18n2.sprintf)( 9608 /* translators: %s: number of stars. */ 9609 (0, import_i18n2.__)("%s out of 5 stars"), 9610 stars 9611 ), 9612 children: [ 9613 Array.from({ length: fullStarCount }).map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)( 9614 icon_default, 9615 { 9616 className: "block-directory-block-ratings__star-full", 9617 icon: star_filled_default, 9618 size: 16 9619 }, 9620 `full_stars_$i}` 9621 )), 9622 Array.from({ length: halfStarCount }).map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)( 9623 icon_default, 9624 { 9625 className: "block-directory-block-ratings__star-half-full", 9626 icon: star_half_default, 9627 size: 16 9628 }, 9629 `half_stars_$i}` 9630 )), 9631 Array.from({ length: emptyStarCount }).map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)( 9632 icon_default, 9633 { 9634 className: "block-directory-block-ratings__star-empty", 9635 icon: star_empty_default, 9636 size: 16 9637 }, 9638 `empty_stars_$i}` 9639 )) 9640 ] 9641 } 9642 ); 9643 } 9644 var stars_default = Stars; 9645 9646 // packages/block-directory/build-module/components/block-ratings/index.mjs 9647 var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1); 9648 var BlockRatings = ({ rating }) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "block-directory-block-ratings", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(stars_default, { rating }) }); 9649 var block_ratings_default = BlockRatings; 9650 9651 // packages/block-directory/build-module/components/downloadable-block-icon/index.mjs 9652 var import_block_editor2 = __toESM(require_block_editor(), 1); 9653 var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1); 9654 function DownloadableBlockIcon({ icon }) { 9655 const className = "block-directory-downloadable-block-icon"; 9656 return icon.match(/\.(jpeg|jpg|gif|png|svg)(?:\?.*)?$/) !== null ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("img", { className, src: icon, alt: "" }) : /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_block_editor2.BlockIcon, { className, icon, showColors: true }); 9657 } 9658 var downloadable_block_icon_default = DownloadableBlockIcon; 9659 9660 // packages/block-directory/build-module/components/downloadable-block-notice/index.mjs 9661 var import_i18n3 = __toESM(require_i18n(), 1); 9662 var import_data5 = __toESM(require_data(), 1); 9663 var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1); 9664 var DownloadableBlockNotice = ({ block }) => { 9665 const errorNotice = (0, import_data5.useSelect)( 9666 (select) => select(store).getErrorNoticeForBlock(block.id), 9667 [block] 9668 ); 9669 if (!errorNotice) { 9670 return null; 9671 } 9672 return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "block-directory-downloadable-block-notice", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "block-directory-downloadable-block-notice__content", children: [ 9673 errorNotice.message, 9674 errorNotice.isFatal ? " " + (0, import_i18n3.__)("Try reloading the page.") : null 9675 ] }) }); 9676 }; 9677 var downloadable_block_notice_default = DownloadableBlockNotice; 9678 9679 // packages/block-directory/build-module/components/downloadable-block-list-item/index.mjs 9680 var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1); 9681 function getDownloadableBlockLabel({ title, rating, ratingCount }, { hasNotice, isInstalled, isInstalling: isInstalling2 }) { 9682 const stars = Math.round(rating / 0.5) * 0.5; 9683 if (!isInstalled && hasNotice) { 9684 return (0, import_i18n4.sprintf)("Retry installing %s.", (0, import_html_entities.decodeEntities)(title)); 9685 } 9686 if (isInstalled) { 9687 return (0, import_i18n4.sprintf)("Add %s.", (0, import_html_entities.decodeEntities)(title)); 9688 } 9689 if (isInstalling2) { 9690 return (0, import_i18n4.sprintf)("Installing %s.", (0, import_html_entities.decodeEntities)(title)); 9691 } 9692 if (ratingCount < 1) { 9693 return (0, import_i18n4.sprintf)("Install %s.", (0, import_html_entities.decodeEntities)(title)); 9694 } 9695 return (0, import_i18n4.sprintf)( 9696 /* translators: 1: block title, 2: average rating, 3: total ratings count. */ 9697 (0, import_i18n4._n)( 9698 "Install %1$s. %2$s stars with %3$s review.", 9699 "Install %1$s. %2$s stars with %3$s reviews.", 9700 ratingCount 9701 ), 9702 (0, import_html_entities.decodeEntities)(title), 9703 stars, 9704 ratingCount 9705 ); 9706 } 9707 function DownloadableBlockListItem({ item, onClick }) { 9708 const { author, description, icon, rating, title } = item; 9709 const isInstalled = !!(0, import_blocks3.getBlockType)(item.name); 9710 const { hasNotice, isInstalling: isInstalling2, isInstallable } = (0, import_data6.useSelect)( 9711 (select) => { 9712 const { getErrorNoticeForBlock: getErrorNoticeForBlock2, isInstalling: isBlockInstalling } = select(store); 9713 const notice = getErrorNoticeForBlock2(item.id); 9714 const hasFatal = notice && notice.isFatal; 9715 return { 9716 hasNotice: !!notice, 9717 isInstalling: isBlockInstalling(item.id), 9718 isInstallable: !hasFatal 9719 }; 9720 }, 9721 [item] 9722 ); 9723 let statusText = ""; 9724 if (isInstalled) { 9725 statusText = (0, import_i18n4.__)("Installed!"); 9726 } else if (isInstalling2) { 9727 statusText = (0, import_i18n4.__)("Installing\u2026"); 9728 } 9729 const itemLabel = getDownloadableBlockLabel(item, { 9730 hasNotice, 9731 isInstalled, 9732 isInstalling: isInstalling2 9733 }); 9734 return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(tooltip_exports.Root, { children: [ 9735 /* @__PURE__ */ (0, import_jsx_runtime24.jsx)( 9736 tooltip_exports.Trigger, 9737 { 9738 render: /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)( 9739 import_components.Composite.Item, 9740 { 9741 className: clsx_default( 9742 "block-directory-downloadable-block-list-item", 9743 isInstalling2 && "is-installing" 9744 ), 9745 accessibleWhenDisabled: true, 9746 disabled: isInstalling2 || !isInstallable, 9747 onClick: (event) => { 9748 event.preventDefault(); 9749 onClick(); 9750 }, 9751 "aria-label": itemLabel, 9752 type: "button", 9753 role: "option", 9754 children: [ 9755 /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "block-directory-downloadable-block-list-item__icon", children: [ 9756 /* @__PURE__ */ (0, import_jsx_runtime24.jsx)( 9757 downloadable_block_icon_default, 9758 { 9759 icon, 9760 title 9761 } 9762 ), 9763 isInstalling2 ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "block-directory-downloadable-block-list-item__spinner", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_components.Spinner, {}) }) : /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(block_ratings_default, { rating }) 9764 ] }), 9765 /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("span", { className: "block-directory-downloadable-block-list-item__details", children: [ 9766 /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "block-directory-downloadable-block-list-item__title", children: (0, import_element18.createInterpolateElement)( 9767 (0, import_i18n4.sprintf)( 9768 /* translators: 1: block title. 2: author name. */ 9769 (0, import_i18n4.__)("%1$s <span>by %2$s</span>"), 9770 (0, import_html_entities.decodeEntities)(title), 9771 author 9772 ), 9773 { 9774 span: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "block-directory-downloadable-block-list-item__author" }) 9775 } 9776 ) }), 9777 hasNotice ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(downloadable_block_notice_default, { block: item }) : /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_jsx_runtime24.Fragment, { children: [ 9778 /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "block-directory-downloadable-block-list-item__desc", children: !!statusText ? statusText : (0, import_html_entities.decodeEntities)(description) }), 9779 isInstallable && !(isInstalled || isInstalling2) && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(VisuallyHidden, { children: (0, import_i18n4.__)("Install block") }) 9780 ] }) 9781 ] }) 9782 ] 9783 } 9784 ) 9785 } 9786 ), 9787 /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(tooltip_exports.Popup, { children: itemLabel }) 9788 ] }); 9789 } 9790 var downloadable_block_list_item_default = DownloadableBlockListItem; 9791 9792 // packages/block-directory/build-module/components/downloadable-blocks-list/index.mjs 9793 var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1); 9794 var noop4 = () => { 9795 }; 9796 function DownloadableBlocksList({ items, onHover = noop4, onSelect }) { 9797 const { installBlockType: installBlockType2 } = (0, import_data7.useDispatch)(store); 9798 if (!items.length) { 9799 return null; 9800 } 9801 return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)( 9802 import_components2.Composite, 9803 { 9804 role: "listbox", 9805 className: "block-directory-downloadable-blocks-list", 9806 "aria-label": (0, import_i18n5.__)("Blocks available for install"), 9807 children: items.map((item) => { 9808 return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)( 9809 downloadable_block_list_item_default, 9810 { 9811 onClick: () => { 9812 if ((0, import_blocks4.getBlockType)(item.name)) { 9813 onSelect(item); 9814 } else { 9815 installBlockType2(item).then((success) => { 9816 if (success) { 9817 onSelect(item); 9818 } 9819 }); 9820 } 9821 onHover(null); 9822 }, 9823 onHover, 9824 item 9825 }, 9826 item.id 9827 ); 9828 }) 9829 } 9830 ); 9831 } 9832 var downloadable_blocks_list_default = DownloadableBlocksList; 9833 9834 // packages/block-directory/build-module/components/downloadable-blocks-panel/inserter-panel.mjs 9835 var import_i18n6 = __toESM(require_i18n(), 1); 9836 var import_element19 = __toESM(require_element(), 1); 9837 var import_a11y = __toESM(require_a11y(), 1); 9838 var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1); 9839 function DownloadableBlocksInserterPanel({ 9840 children, 9841 downloadableItems, 9842 hasLocalBlocks 9843 }) { 9844 const count = downloadableItems.length; 9845 (0, import_element19.useEffect)(() => { 9846 (0, import_a11y.speak)( 9847 (0, import_i18n6.sprintf)( 9848 /* translators: %d: number of available blocks. */ 9849 (0, import_i18n6._n)( 9850 "%d additional block is available to install.", 9851 "%d additional blocks are available to install.", 9852 count 9853 ), 9854 count 9855 ) 9856 ); 9857 }, [count]); 9858 return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [ 9859 !hasLocalBlocks && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("p", { className: "block-directory-downloadable-blocks-panel__no-local", children: (0, import_i18n6.__)("No results available from your installed blocks.") }), 9860 /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "block-editor-inserter__quick-inserter-separator" }), 9861 /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "block-directory-downloadable-blocks-panel", children: [ 9862 /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "block-directory-downloadable-blocks-panel__header", children: [ 9863 /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("h2", { className: "block-directory-downloadable-blocks-panel__title", children: (0, import_i18n6.__)("Available to install") }), 9864 /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("p", { className: "block-directory-downloadable-blocks-panel__description", children: (0, import_i18n6.__)( 9865 "Select a block to install and add it to your post." 9866 ) }) 9867 ] }), 9868 children 9869 ] }) 9870 ] }); 9871 } 9872 var inserter_panel_default = DownloadableBlocksInserterPanel; 9873 9874 // packages/block-directory/build-module/components/downloadable-blocks-panel/no-results.mjs 9875 var import_i18n7 = __toESM(require_i18n(), 1); 9876 var import_components3 = __toESM(require_components(), 1); 9877 var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1); 9878 function DownloadableBlocksNoResults() { 9879 return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_jsx_runtime27.Fragment, { children: [ 9880 /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "block-editor-inserter__no-results", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("p", { children: (0, import_i18n7.__)("No results found.") }) }), 9881 /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "block-editor-inserter__tips", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_components3.Tip, { children: [ 9882 (0, import_i18n7.__)("Interested in creating your own block?"), 9883 /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("br", {}), 9884 /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_components3.ExternalLink, { href: "https://developer.wordpress.org/block-editor/", children: [ 9885 (0, import_i18n7.__)("Get started here"), 9886 "." 9887 ] }) 9888 ] }) }) 9889 ] }); 9890 } 9891 var no_results_default = DownloadableBlocksNoResults; 9892 9893 // packages/block-directory/build-module/components/downloadable-blocks-panel/index.mjs 9894 var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1); 9895 var EMPTY_ARRAY3 = []; 9896 var useDownloadableBlocks = (filterValue) => (0, import_data8.useSelect)( 9897 (select) => { 9898 const { 9899 getDownloadableBlocks: getDownloadableBlocks3, 9900 isRequestingDownloadableBlocks: isRequestingDownloadableBlocks2, 9901 getInstalledBlockTypes: getInstalledBlockTypes2 9902 } = select(store); 9903 const hasPermission = select(import_core_data.store).canUser( 9904 "read", 9905 "block-directory/search" 9906 ); 9907 let downloadableBlocks2 = EMPTY_ARRAY3; 9908 if (hasPermission) { 9909 downloadableBlocks2 = getDownloadableBlocks3(filterValue); 9910 const installedBlockTypes = getInstalledBlockTypes2(); 9911 const installableBlocks = downloadableBlocks2.filter( 9912 ({ name }) => { 9913 const isJustInstalled = installedBlockTypes.some( 9914 (blockType) => blockType.name === name 9915 ); 9916 const isPreviouslyInstalled = (0, import_blocks5.getBlockType)(name); 9917 return isJustInstalled || !isPreviouslyInstalled; 9918 } 9919 ); 9920 if (installableBlocks.length !== downloadableBlocks2.length) { 9921 downloadableBlocks2 = installableBlocks; 9922 } 9923 if (downloadableBlocks2.length === 0) { 9924 downloadableBlocks2 = EMPTY_ARRAY3; 9925 } 9926 } 9927 return { 9928 hasPermission, 9929 downloadableBlocks: downloadableBlocks2, 9930 isLoading: isRequestingDownloadableBlocks2(filterValue) 9931 }; 9932 }, 9933 [filterValue] 9934 ); 9935 function DownloadableBlocksPanel({ 9936 onSelect, 9937 onHover, 9938 hasLocalBlocks, 9939 isTyping, 9940 filterValue 9941 }) { 9942 const { hasPermission, downloadableBlocks: downloadableBlocks2, isLoading } = useDownloadableBlocks(filterValue); 9943 if (hasPermission === void 0 || isLoading || isTyping) { 9944 return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_jsx_runtime28.Fragment, { children: [ 9945 hasPermission && !hasLocalBlocks && /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_jsx_runtime28.Fragment, { children: [ 9946 /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("p", { className: "block-directory-downloadable-blocks-panel__no-local", children: (0, import_i18n8.__)( 9947 "No results available from your installed blocks." 9948 ) }), 9949 /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "block-editor-inserter__quick-inserter-separator" }) 9950 ] }), 9951 /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "block-directory-downloadable-blocks-panel has-blocks-loading", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_components4.Spinner, {}) }) 9952 ] }); 9953 } 9954 if (false === hasPermission) { 9955 if (!hasLocalBlocks) { 9956 return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(no_results_default, {}); 9957 } 9958 return null; 9959 } 9960 if (downloadableBlocks2.length === 0) { 9961 return hasLocalBlocks ? null : /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(no_results_default, {}); 9962 } 9963 return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)( 9964 inserter_panel_default, 9965 { 9966 downloadableItems: downloadableBlocks2, 9967 hasLocalBlocks, 9968 children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)( 9969 downloadable_blocks_list_default, 9970 { 9971 items: downloadableBlocks2, 9972 onSelect, 9973 onHover 9974 } 9975 ) 9976 } 9977 ); 9978 } 9979 9980 // packages/block-directory/build-module/plugins/inserter-menu-downloadable-blocks-panel/index.mjs 9981 var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1); 9982 function InserterMenuDownloadableBlocksPanel() { 9983 const [debouncedFilterValue, setFilterValue] = (0, import_element20.useState)(""); 9984 const debouncedSetFilterValue = (0, import_compose.debounce)(setFilterValue, 400); 9985 return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_block_editor3.__unstableInserterMenuExtension, { children: ({ onSelect, onHover, filterValue, hasItems }) => { 9986 if (debouncedFilterValue !== filterValue) { 9987 debouncedSetFilterValue(filterValue); 9988 } 9989 if (!debouncedFilterValue) { 9990 return null; 9991 } 9992 return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)( 9993 DownloadableBlocksPanel, 9994 { 9995 onSelect, 9996 onHover, 9997 filterValue: debouncedFilterValue, 9998 hasLocalBlocks: hasItems, 9999 isTyping: filterValue !== debouncedFilterValue 10000 } 10001 ); 10002 } }); 10003 } 10004 var inserter_menu_downloadable_blocks_panel_default = InserterMenuDownloadableBlocksPanel; 10005 10006 // packages/block-directory/build-module/plugins/installed-blocks-pre-publish-panel/index.mjs 10007 var import_i18n10 = __toESM(require_i18n(), 1); 10008 var import_data9 = __toESM(require_data(), 1); 10009 var import_editor2 = __toESM(require_editor(), 1); 10010 10011 // packages/block-directory/build-module/components/compact-list/index.mjs 10012 var import_i18n9 = __toESM(require_i18n(), 1); 10013 var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1); 10014 function CompactList({ items }) { 10015 if (!items.length) { 10016 return null; 10017 } 10018 return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("ul", { className: "block-directory-compact-list", children: items.map(({ icon, id, title, author }) => /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("li", { className: "block-directory-compact-list__item", children: [ 10019 /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(downloadable_block_icon_default, { icon, title }), 10020 /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "block-directory-compact-list__item-details", children: [ 10021 /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: "block-directory-compact-list__item-title", children: title }), 10022 /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: "block-directory-compact-list__item-author", children: (0, import_i18n9.sprintf)( 10023 /* translators: %s: Name of the block author. */ 10024 (0, import_i18n9.__)("By %s"), 10025 author 10026 ) }) 10027 ] }) 10028 ] }, id)) }); 10029 } 10030 10031 // packages/block-directory/build-module/plugins/installed-blocks-pre-publish-panel/index.mjs 10032 var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1); 10033 function InstalledBlocksPrePublishPanel() { 10034 const newBlockTypes = (0, import_data9.useSelect)( 10035 (select) => select(store).getNewBlockTypes(), 10036 [] 10037 ); 10038 if (!newBlockTypes.length) { 10039 return null; 10040 } 10041 return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)( 10042 import_editor2.PluginPrePublishPanel, 10043 { 10044 title: (0, import_i18n10.sprintf)( 10045 // translators: %d: number of blocks (number). 10046 (0, import_i18n10._n)( 10047 "Added: %d block", 10048 "Added: %d blocks", 10049 newBlockTypes.length 10050 ), 10051 newBlockTypes.length 10052 ), 10053 initialOpen: true, 10054 children: [ 10055 /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("p", { className: "installed-blocks-pre-publish-panel__copy", children: (0, import_i18n10._n)( 10056 "The following block has been added to your site.", 10057 "The following blocks have been added to your site.", 10058 newBlockTypes.length 10059 ) }), 10060 /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(CompactList, { items: newBlockTypes }) 10061 ] 10062 } 10063 ); 10064 } 10065 10066 // packages/block-directory/build-module/plugins/get-install-missing/index.mjs 10067 var import_i18n12 = __toESM(require_i18n(), 1); 10068 var import_components6 = __toESM(require_components(), 1); 10069 var import_blocks7 = __toESM(require_blocks(), 1); 10070 var import_element21 = __toESM(require_element(), 1); 10071 var import_data11 = __toESM(require_data(), 1); 10072 var import_core_data2 = __toESM(require_core_data(), 1); 10073 var import_block_editor5 = __toESM(require_block_editor(), 1); 10074 10075 // packages/block-directory/build-module/plugins/get-install-missing/install-button.mjs 10076 var import_i18n11 = __toESM(require_i18n(), 1); 10077 var import_components5 = __toESM(require_components(), 1); 10078 var import_blocks6 = __toESM(require_blocks(), 1); 10079 var import_data10 = __toESM(require_data(), 1); 10080 var import_block_editor4 = __toESM(require_block_editor(), 1); 10081 var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1); 10082 function InstallButton({ attributes, block, clientId }) { 10083 const isInstallingBlock = (0, import_data10.useSelect)( 10084 (select) => select(store).isInstalling(block.id), 10085 [block.id] 10086 ); 10087 const { installBlockType: installBlockType2 } = (0, import_data10.useDispatch)(store); 10088 const { replaceBlock } = (0, import_data10.useDispatch)(import_block_editor4.store); 10089 return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)( 10090 import_components5.Button, 10091 { 10092 __next40pxDefaultSize: true, 10093 onClick: () => installBlockType2(block).then((success) => { 10094 if (success) { 10095 const blockType = (0, import_blocks6.getBlockType)(block.name); 10096 const [originalBlock] = (0, import_blocks6.parse)( 10097 attributes.originalContent 10098 ); 10099 if (originalBlock && blockType) { 10100 replaceBlock( 10101 clientId, 10102 (0, import_blocks6.createBlock)( 10103 blockType.name, 10104 originalBlock.attributes, 10105 originalBlock.innerBlocks 10106 ) 10107 ); 10108 } 10109 } 10110 }), 10111 accessibleWhenDisabled: true, 10112 disabled: isInstallingBlock, 10113 isBusy: isInstallingBlock, 10114 variant: "primary", 10115 children: (0, import_i18n11.sprintf)( 10116 /* translators: %s: block name */ 10117 (0, import_i18n11.__)("Install %s"), 10118 block.title 10119 ) 10120 } 10121 ); 10122 } 10123 10124 // packages/block-directory/build-module/plugins/get-install-missing/index.mjs 10125 var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1); 10126 var getInstallMissing = (OriginalComponent) => (props) => { 10127 const { originalName } = props.attributes; 10128 const { block, hasPermission } = (0, import_data11.useSelect)( 10129 (select) => { 10130 const { getDownloadableBlocks: getDownloadableBlocks3 } = select(store); 10131 const blocks = getDownloadableBlocks3( 10132 "block:" + originalName 10133 ).filter(({ name }) => originalName === name); 10134 return { 10135 hasPermission: select(import_core_data2.store).canUser( 10136 "read", 10137 "block-directory/search" 10138 ), 10139 block: blocks.length && blocks[0] 10140 }; 10141 }, 10142 [originalName] 10143 ); 10144 if (!hasPermission || !block) { 10145 return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(OriginalComponent, { ...props }); 10146 } 10147 return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(ModifiedWarning, { ...props, originalBlock: block }); 10148 }; 10149 var ModifiedWarning = ({ originalBlock, ...props }) => { 10150 const { originalName, originalUndelimitedContent, clientId } = props.attributes; 10151 const { replaceBlock } = (0, import_data11.useDispatch)(import_block_editor5.store); 10152 const convertToHTML = () => { 10153 replaceBlock( 10154 props.clientId, 10155 (0, import_blocks7.createBlock)("core/html", {}, [], [originalUndelimitedContent]) 10156 ); 10157 }; 10158 const hasContent = !!originalUndelimitedContent; 10159 const hasHTMLBlock = (0, import_data11.useSelect)( 10160 (select) => { 10161 const { canInsertBlockType, getBlockRootClientId } = select(import_block_editor5.store); 10162 return canInsertBlockType( 10163 "core/html", 10164 getBlockRootClientId(clientId) 10165 ); 10166 }, 10167 [clientId] 10168 ); 10169 let messageHTML = (0, import_i18n12.sprintf)( 10170 /* translators: %s: block name */ 10171 (0, import_i18n12.__)( 10172 "Your site doesn\u2019t include support for the %s block. You can try installing the block or remove it entirely." 10173 ), 10174 originalBlock.title || originalName 10175 ); 10176 const actions = [ 10177 /* @__PURE__ */ (0, import_jsx_runtime33.jsx)( 10178 InstallButton, 10179 { 10180 block: originalBlock, 10181 attributes: props.attributes, 10182 clientId: props.clientId 10183 }, 10184 "install" 10185 ) 10186 ]; 10187 if (hasContent && hasHTMLBlock) { 10188 messageHTML = (0, import_i18n12.sprintf)( 10189 /* translators: %s: block name */ 10190 (0, import_i18n12.__)( 10191 "Your site doesn\u2019t include support for the %s block. You can try installing the block, convert it to a Custom HTML block, or remove it entirely." 10192 ), 10193 originalBlock.title || originalName 10194 ); 10195 actions.push( 10196 /* @__PURE__ */ (0, import_jsx_runtime33.jsx)( 10197 import_components6.Button, 10198 { 10199 __next40pxDefaultSize: true, 10200 onClick: convertToHTML, 10201 variant: "tertiary", 10202 children: (0, import_i18n12.__)("Keep as HTML") 10203 }, 10204 "convert" 10205 ) 10206 ); 10207 } 10208 return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { ...(0, import_block_editor5.useBlockProps)(), children: [ 10209 /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_block_editor5.Warning, { actions, children: messageHTML }), 10210 /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_element21.RawHTML, { children: originalUndelimitedContent }) 10211 ] }); 10212 }; 10213 var get_install_missing_default = getInstallMissing; 10214 10215 // packages/block-directory/build-module/plugins/index.mjs 10216 var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1); 10217 (0, import_plugins.registerPlugin)("block-directory", { 10218 // The icon is explicitly set to undefined to prevent PluginPrePublishPanel 10219 // from rendering the fallback icon pluginIcon. 10220 icon: void 0, 10221 render() { 10222 return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [ 10223 /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(AutoBlockUninstaller, {}), 10224 /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(inserter_menu_downloadable_blocks_panel_default, {}), 10225 /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(InstalledBlocksPrePublishPanel, {}) 10226 ] }); 10227 } 10228 }); 10229 (0, import_hooks.addFilter)( 10230 "blocks.registerBlockType", 10231 "block-directory/fallback", 10232 (settings, name) => { 10233 if (name !== "core/missing") { 10234 return settings; 10235 } 10236 settings.edit = get_install_missing_default(settings.edit); 10237 return settings; 10238 } 10239 ); 10240 return __toCommonJS(index_exports); 10241 })(); 10242 /*! Bundled license information: 10243 10244 use-sync-external-store/cjs/use-sync-external-store-shim.development.js: 10245 (** 10246 * @license React 10247 * use-sync-external-store-shim.development.js 10248 * 10249 * Copyright (c) Meta Platforms, Inc. and affiliates. 10250 * 10251 * This source code is licensed under the MIT license found in the 10252 * LICENSE file in the root directory of this source tree. 10253 *) 10254 10255 use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js: 10256 (** 10257 * @license React 10258 * use-sync-external-store-shim/with-selector.development.js 10259 * 10260 * Copyright (c) Meta Platforms, Inc. and affiliates. 10261 * 10262 * This source code is licensed under the MIT license found in the 10263 * LICENSE file in the root directory of this source tree. 10264 *) 10265 */ 10266 (window.wp ||= {}).blockDirectory = wp.blockDirectory; 10267 })();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Sat Aug 8 08:20:21 2026 | Cross-referenced by PHPXref |