| 1 |
var wp; |
| 2 |
(wp ||= {}).blockDirectory = (() => { |
| 3 |
var __create = Object.create; |
| 4 |
var __defProp = Object.defineProperty; |
| 5 |
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
| 6 |
var __getOwnPropNames = Object.getOwnPropertyNames; |
| 7 |
var __getProtoOf = Object.getPrototypeOf; |
| 8 |
var __hasOwnProp = Object.prototype.hasOwnProperty; |
| 9 |
var __commonJS = (cb, mod) => function __require() { |
| 10 |
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; |
| 11 |
}; |
| 12 |
var __export = (target, all) => { |
| 13 |
for (var name in all) |
| 14 |
__defProp(target, name, { get: all[name], enumerable: true }); |
| 15 |
}; |
| 16 |
var __copyProps = (to, from, except, desc) => { |
| 17 |
if (from && typeof from === "object" || typeof from === "function") { |
| 18 |
for (let key of __getOwnPropNames(from)) |
| 19 |
if (!__hasOwnProp.call(to, key) && key !== except) |
| 20 |
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); |
| 21 |
} |
| 22 |
return to; |
| 23 |
}; |
| 24 |
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( |
| 25 |
// If the importer is in node compatibility mode or this is not an ESM |
| 26 |
// file that has been converted to a CommonJS file using a Babel- |
| 27 |
// compatible transform (i.e. "__esModule" has not been set), then set |
| 28 |
// "default" to the CommonJS "module.exports" for node compatibility. |
| 29 |
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, |
| 30 |
mod |
| 31 |
)); |
| 32 |
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); |
| 33 |
|
| 34 |
// package-external:@wordpress/plugins |
| 35 |
var require_plugins = __commonJS({ |
| 36 |
"package-external:@wordpress/plugins"(exports, module) { |
| 37 |
module.exports = window.wp.plugins; |
| 38 |
} |
| 39 |
}); |
| 40 |
|
| 41 |
// package-external:@wordpress/hooks |
| 42 |
var require_hooks = __commonJS({ |
| 43 |
"package-external:@wordpress/hooks"(exports, module) { |
| 44 |
module.exports = window.wp.hooks; |
| 45 |
} |
| 46 |
}); |
| 47 |
|
| 48 |
// package-external:@wordpress/blocks |
| 49 |
var require_blocks = __commonJS({ |
| 50 |
"package-external:@wordpress/blocks"(exports, module) { |
| 51 |
module.exports = window.wp.blocks; |
| 52 |
} |
| 53 |
}); |
| 54 |
|
| 55 |
// package-external:@wordpress/data |
| 56 |
var require_data = __commonJS({ |
| 57 |
"package-external:@wordpress/data"(exports, module) { |
| 58 |
module.exports = window.wp.data; |
| 59 |
} |
| 60 |
}); |
| 61 |
|
| 62 |
// package-external:@wordpress/element |
| 63 |
var require_element = __commonJS({ |
| 64 |
"package-external:@wordpress/element"(exports, module) { |
| 65 |
module.exports = window.wp.element; |
| 66 |
} |
| 67 |
}); |
| 68 |
|
| 69 |
// package-external:@wordpress/editor |
| 70 |
var require_editor = __commonJS({ |
| 71 |
"package-external:@wordpress/editor"(exports, module) { |
| 72 |
module.exports = window.wp.editor; |
| 73 |
} |
| 74 |
}); |
| 75 |
|
| 76 |
// package-external:@wordpress/block-editor |
| 77 |
var require_block_editor = __commonJS({ |
| 78 |
"package-external:@wordpress/block-editor"(exports, module) { |
| 79 |
module.exports = window.wp.blockEditor; |
| 80 |
} |
| 81 |
}); |
| 82 |
|
| 83 |
// package-external:@wordpress/i18n |
| 84 |
var require_i18n = __commonJS({ |
| 85 |
"package-external:@wordpress/i18n"(exports, module) { |
| 86 |
module.exports = window.wp.i18n; |
| 87 |
} |
| 88 |
}); |
| 89 |
|
| 90 |
// package-external:@wordpress/api-fetch |
| 91 |
var require_api_fetch = __commonJS({ |
| 92 |
"package-external:@wordpress/api-fetch"(exports, module) { |
| 93 |
module.exports = window.wp.apiFetch; |
| 94 |
} |
| 95 |
}); |
| 96 |
|
| 97 |
// package-external:@wordpress/notices |
| 98 |
var require_notices = __commonJS({ |
| 99 |
"package-external:@wordpress/notices"(exports, module) { |
| 100 |
module.exports = window.wp.notices; |
| 101 |
} |
| 102 |
}); |
| 103 |
|
| 104 |
// package-external:@wordpress/url |
| 105 |
var require_url = __commonJS({ |
| 106 |
"package-external:@wordpress/url"(exports, module) { |
| 107 |
module.exports = window.wp.url; |
| 108 |
} |
| 109 |
}); |
| 110 |
|
| 111 |
// package-external:@wordpress/compose |
| 112 |
var require_compose = __commonJS({ |
| 113 |
"package-external:@wordpress/compose"(exports, module) { |
| 114 |
module.exports = window.wp.compose; |
| 115 |
} |
| 116 |
}); |
| 117 |
|
| 118 |
// package-external:@wordpress/components |
| 119 |
var require_components = __commonJS({ |
| 120 |
"package-external:@wordpress/components"(exports, module) { |
| 121 |
module.exports = window.wp.components; |
| 122 |
} |
| 123 |
}); |
| 124 |
|
| 125 |
// package-external:@wordpress/core-data |
| 126 |
var require_core_data = __commonJS({ |
| 127 |
"package-external:@wordpress/core-data"(exports, module) { |
| 128 |
module.exports = window.wp.coreData; |
| 129 |
} |
| 130 |
}); |
| 131 |
|
| 132 |
// package-external:@wordpress/html-entities |
| 133 |
var require_html_entities = __commonJS({ |
| 134 |
"package-external:@wordpress/html-entities"(exports, module) { |
| 135 |
module.exports = window.wp.htmlEntities; |
| 136 |
} |
| 137 |
}); |
| 138 |
|
| 139 |
// vendor-external:react |
| 140 |
var require_react = __commonJS({ |
| 141 |
"vendor-external:react"(exports, module) { |
| 142 |
module.exports = window.React; |
| 143 |
} |
| 144 |
}); |
| 145 |
|
| 146 |
// vendor-external:react/jsx-runtime |
| 147 |
var require_jsx_runtime = __commonJS({ |
| 148 |
"vendor-external:react/jsx-runtime"(exports, module) { |
| 149 |
module.exports = window.ReactJSXRuntime; |
| 150 |
} |
| 151 |
}); |
| 152 |
|
| 153 |
// vendor-external:react-dom |
| 154 |
var require_react_dom = __commonJS({ |
| 155 |
"vendor-external:react-dom"(exports, module) { |
| 156 |
module.exports = window.ReactDOM; |
| 157 |
} |
| 158 |
}); |
| 159 |
|
| 160 |
// node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js |
| 161 |
var require_use_sync_external_store_shim_development = __commonJS({ |
| 162 |
"node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports) { |
| 163 |
"use strict"; |
| 164 |
(function() { |
| 165 |
function is(x, y) { |
| 166 |
return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y; |
| 167 |
} |
| 168 |
function useSyncExternalStore$2(subscribe, getSnapshot) { |
| 169 |
didWarnOld18Alpha || void 0 === React47.startTransition || (didWarnOld18Alpha = true, console.error( |
| 170 |
"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." |
| 171 |
)); |
| 172 |
var value = getSnapshot(); |
| 173 |
if (!didWarnUncachedGetSnapshot) { |
| 174 |
var cachedValue = getSnapshot(); |
| 175 |
objectIs(value, cachedValue) || (console.error( |
| 176 |
"The result of getSnapshot should be cached to avoid an infinite loop" |
| 177 |
), didWarnUncachedGetSnapshot = true); |
| 178 |
} |
| 179 |
cachedValue = useState13({ |
| 180 |
inst: { value, getSnapshot } |
| 181 |
}); |
| 182 |
var inst = cachedValue[0].inst, forceUpdate = cachedValue[1]; |
| 183 |
useLayoutEffect3( |
| 184 |
function() { |
| 185 |
inst.value = value; |
| 186 |
inst.getSnapshot = getSnapshot; |
| 187 |
checkIfSnapshotChanged(inst) && forceUpdate({ inst }); |
| 188 |
}, |
| 189 |
[subscribe, value, getSnapshot] |
| 190 |
); |
| 191 |
useEffect13( |
| 192 |
function() { |
| 193 |
checkIfSnapshotChanged(inst) && forceUpdate({ inst }); |
| 194 |
return subscribe(function() { |
| 195 |
checkIfSnapshotChanged(inst) && forceUpdate({ inst }); |
| 196 |
}); |
| 197 |
}, |
| 198 |
[subscribe] |
| 199 |
); |
| 200 |
useDebugValue2(value); |
| 201 |
return value; |
| 202 |
} |
| 203 |
function checkIfSnapshotChanged(inst) { |
| 204 |
var latestGetSnapshot = inst.getSnapshot; |
| 205 |
inst = inst.value; |
| 206 |
try { |
| 207 |
var nextValue = latestGetSnapshot(); |
| 208 |
return !objectIs(inst, nextValue); |
| 209 |
} catch (error) { |
| 210 |
return true; |
| 211 |
} |
| 212 |
} |
| 213 |
function useSyncExternalStore$1(subscribe, getSnapshot) { |
| 214 |
return getSnapshot(); |
| 215 |
} |
| 216 |
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error()); |
| 217 |
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; |
| 218 |
exports.useSyncExternalStore = void 0 !== React47.useSyncExternalStore ? React47.useSyncExternalStore : shim; |
| 219 |
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error()); |
| 220 |
})(); |
| 221 |
} |
| 222 |
}); |
| 223 |
|
| 224 |
// node_modules/use-sync-external-store/shim/index.js |
| 225 |
var require_shim = __commonJS({ |
| 226 |
"node_modules/use-sync-external-store/shim/index.js"(exports, module) { |
| 227 |
"use strict"; |
| 228 |
if (false) { |
| 229 |
module.exports = null; |
| 230 |
} else { |
| 231 |
module.exports = require_use_sync_external_store_shim_development(); |
| 232 |
} |
| 233 |
} |
| 234 |
}); |
| 235 |
|
| 236 |
// node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js |
| 237 |
var require_with_selector_development = __commonJS({ |
| 238 |
"node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js"(exports) { |
| 239 |
"use strict"; |
| 240 |
(function() { |
| 241 |
function is(x, y) { |
| 242 |
return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y; |
| 243 |
} |
| 244 |
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error()); |
| 245 |
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; |
| 246 |
exports.useSyncExternalStoreWithSelector = function(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) { |
| 247 |
var instRef = useRef19(null); |
| 248 |
if (null === instRef.current) { |
| 249 |
var inst = { hasValue: false, value: null }; |
| 250 |
instRef.current = inst; |
| 251 |
} else inst = instRef.current; |
| 252 |
instRef = useMemo15( |
| 253 |
function() { |
| 254 |
function memoizedSelector(nextSnapshot) { |
| 255 |
if (!hasMemo) { |
| 256 |
hasMemo = true; |
| 257 |
memoizedSnapshot = nextSnapshot; |
| 258 |
nextSnapshot = selector(nextSnapshot); |
| 259 |
if (void 0 !== isEqual && inst.hasValue) { |
| 260 |
var currentSelection = inst.value; |
| 261 |
if (isEqual(currentSelection, nextSnapshot)) |
| 262 |
return memoizedSelection = currentSelection; |
| 263 |
} |
| 264 |
return memoizedSelection = nextSnapshot; |
| 265 |
} |
| 266 |
currentSelection = memoizedSelection; |
| 267 |
if (objectIs(memoizedSnapshot, nextSnapshot)) |
| 268 |
return currentSelection; |
| 269 |
var nextSelection = selector(nextSnapshot); |
| 270 |
if (void 0 !== isEqual && isEqual(currentSelection, nextSelection)) |
| 271 |
return memoizedSnapshot = nextSnapshot, currentSelection; |
| 272 |
memoizedSnapshot = nextSnapshot; |
| 273 |
return memoizedSelection = nextSelection; |
| 274 |
} |
| 275 |
var hasMemo = false, memoizedSnapshot, memoizedSelection, maybeGetServerSnapshot = void 0 === getServerSnapshot ? null : getServerSnapshot; |
| 276 |
return [ |
| 277 |
function() { |
| 278 |
return memoizedSelector(getSnapshot()); |
| 279 |
}, |
| 280 |
null === maybeGetServerSnapshot ? void 0 : function() { |
| 281 |
return memoizedSelector(maybeGetServerSnapshot()); |
| 282 |
} |
| 283 |
]; |
| 284 |
}, |
| 285 |
[getSnapshot, getServerSnapshot, selector, isEqual] |
| 286 |
); |
| 287 |
var value = useSyncExternalStore2(subscribe, instRef[0], instRef[1]); |
| 288 |
useEffect13( |
| 289 |
function() { |
| 290 |
inst.hasValue = true; |
| 291 |
inst.value = value; |
| 292 |
}, |
| 293 |
[value] |
| 294 |
); |
| 295 |
useDebugValue2(value); |
| 296 |
return value; |
| 297 |
}; |
| 298 |
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error()); |
| 299 |
})(); |
| 300 |
} |
| 301 |
}); |
| 302 |
|
| 303 |
// node_modules/use-sync-external-store/shim/with-selector.js |
| 304 |
var require_with_selector = __commonJS({ |
| 305 |
"node_modules/use-sync-external-store/shim/with-selector.js"(exports, module) { |
| 306 |
"use strict"; |
| 307 |
if (false) { |
| 308 |
module.exports = null; |
| 309 |
} else { |
| 310 |
module.exports = require_with_selector_development(); |
| 311 |
} |
| 312 |
} |
| 313 |
}); |
| 314 |
|
| 315 |
// package-external:@wordpress/a11y |
| 316 |
var require_a11y = __commonJS({ |
| 317 |
"package-external:@wordpress/a11y"(exports, module) { |
| 318 |
module.exports = window.wp.a11y; |
| 319 |
} |
| 320 |
}); |
| 321 |
|
| 322 |
// package-external:@wordpress/primitives |
| 323 |
var require_primitives = __commonJS({ |
| 324 |
"package-external:@wordpress/primitives"(exports, module) { |
| 325 |
module.exports = window.wp.primitives; |
| 326 |
} |
| 327 |
}); |
| 328 |
|
| 329 |
// package-external:@wordpress/theme |
| 330 |
var require_theme = __commonJS({ |
| 331 |
"package-external:@wordpress/theme"(exports, module) { |
| 332 |
module.exports = window.wp.theme; |
| 333 |
} |
| 334 |
}); |
| 335 |
|
| 336 |
// package-external:@wordpress/private-apis |
| 337 |
var require_private_apis = __commonJS({ |
| 338 |
"package-external:@wordpress/private-apis"(exports, module) { |
| 339 |
module.exports = window.wp.privateApis; |
| 340 |
} |
| 341 |
}); |
| 342 |
|
| 343 |
// packages/block-directory/build-module/index.mjs |
| 344 |
var index_exports = {}; |
| 345 |
__export(index_exports, { |
| 346 |
store: () => store |
| 347 |
}); |
| 348 |
|
| 349 |
// packages/block-directory/build-module/plugins/index.mjs |
| 350 |
var import_plugins = __toESM(require_plugins(), 1); |
| 351 |
var import_hooks = __toESM(require_hooks(), 1); |
| 352 |
|
| 353 |
// packages/block-directory/build-module/components/auto-block-uninstaller/index.mjs |
| 354 |
var import_blocks2 = __toESM(require_blocks(), 1); |
| 355 |
var import_data4 = __toESM(require_data(), 1); |
| 356 |
var import_element = __toESM(require_element(), 1); |
| 357 |
var import_editor = __toESM(require_editor(), 1); |
| 358 |
|
| 359 |
// packages/block-directory/build-module/store/index.mjs |
| 360 |
var import_data3 = __toESM(require_data(), 1); |
| 361 |
|
| 362 |
// packages/block-directory/build-module/store/reducer.mjs |
| 363 |
var import_data = __toESM(require_data(), 1); |
| 364 |
var downloadableBlocks = (state = {}, action) => { |
| 365 |
switch (action.type) { |
| 366 |
case "FETCH_DOWNLOADABLE_BLOCKS": |
| 367 |
return { |
| 368 |
...state, |
| 369 |
[action.filterValue]: { |
| 370 |
isRequesting: true |
| 371 |
} |
| 372 |
}; |
| 373 |
case "RECEIVE_DOWNLOADABLE_BLOCKS": |
| 374 |
return { |
| 375 |
...state, |
| 376 |
[action.filterValue]: { |
| 377 |
results: action.downloadableBlocks, |
| 378 |
isRequesting: false |
| 379 |
} |
| 380 |
}; |
| 381 |
} |
| 382 |
return state; |
| 383 |
}; |
| 384 |
var blockManagement = (state = { |
| 385 |
installedBlockTypes: [], |
| 386 |
isInstalling: {} |
| 387 |
}, action) => { |
| 388 |
switch (action.type) { |
| 389 |
case "ADD_INSTALLED_BLOCK_TYPE": |
| 390 |
return { |
| 391 |
...state, |
| 392 |
installedBlockTypes: [ |
| 393 |
...state.installedBlockTypes, |
| 394 |
action.item |
| 395 |
] |
| 396 |
}; |
| 397 |
case "REMOVE_INSTALLED_BLOCK_TYPE": |
| 398 |
return { |
| 399 |
...state, |
| 400 |
installedBlockTypes: state.installedBlockTypes.filter( |
| 401 |
(blockType) => blockType.name !== action.item.name |
| 402 |
) |
| 403 |
}; |
| 404 |
case "SET_INSTALLING_BLOCK": |
| 405 |
return { |
| 406 |
...state, |
| 407 |
isInstalling: { |
| 408 |
...state.isInstalling, |
| 409 |
[action.blockId]: action.isInstalling |
| 410 |
} |
| 411 |
}; |
| 412 |
} |
| 413 |
return state; |
| 414 |
}; |
| 415 |
var errorNotices = (state = {}, action) => { |
| 416 |
switch (action.type) { |
| 417 |
case "SET_ERROR_NOTICE": |
| 418 |
return { |
| 419 |
...state, |
| 420 |
[action.blockId]: { |
| 421 |
message: action.message, |
| 422 |
isFatal: action.isFatal |
| 423 |
} |
| 424 |
}; |
| 425 |
case "CLEAR_ERROR_NOTICE": |
| 426 |
const { [action.blockId]: blockId, ...restState } = state; |
| 427 |
return restState; |
| 428 |
} |
| 429 |
return state; |
| 430 |
}; |
| 431 |
var reducer_default = (0, import_data.combineReducers)({ |
| 432 |
downloadableBlocks, |
| 433 |
blockManagement, |
| 434 |
errorNotices |
| 435 |
}); |
| 436 |
|
| 437 |
// packages/block-directory/build-module/store/selectors.mjs |
| 438 |
var selectors_exports = {}; |
| 439 |
__export(selectors_exports, { |
| 440 |
getDownloadableBlocks: () => getDownloadableBlocks, |
| 441 |
getErrorNoticeForBlock: () => getErrorNoticeForBlock, |
| 442 |
getErrorNotices: () => getErrorNotices, |
| 443 |
getInstalledBlockTypes: () => getInstalledBlockTypes, |
| 444 |
getNewBlockTypes: () => getNewBlockTypes, |
| 445 |
getUnusedBlockTypes: () => getUnusedBlockTypes, |
| 446 |
isInstalling: () => isInstalling, |
| 447 |
isRequestingDownloadableBlocks: () => isRequestingDownloadableBlocks |
| 448 |
}); |
| 449 |
var import_data2 = __toESM(require_data(), 1); |
| 450 |
var import_block_editor = __toESM(require_block_editor(), 1); |
| 451 |
var EMPTY_ARRAY = []; |
| 452 |
function isRequestingDownloadableBlocks(state, filterValue) { |
| 453 |
return state.downloadableBlocks[filterValue]?.isRequesting ?? false; |
| 454 |
} |
| 455 |
function getDownloadableBlocks(state, filterValue) { |
| 456 |
return state.downloadableBlocks[filterValue]?.results ?? EMPTY_ARRAY; |
| 457 |
} |
| 458 |
function getInstalledBlockTypes(state) { |
| 459 |
return state.blockManagement.installedBlockTypes; |
| 460 |
} |
| 461 |
var getNewBlockTypes = (0, import_data2.createRegistrySelector)( |
| 462 |
(select) => (0, import_data2.createSelector)( |
| 463 |
(state) => { |
| 464 |
const installedBlockTypes = getInstalledBlockTypes(state); |
| 465 |
if (!installedBlockTypes.length) { |
| 466 |
return EMPTY_ARRAY; |
| 467 |
} |
| 468 |
const { getBlockName, getClientIdsWithDescendants } = select(import_block_editor.store); |
| 469 |
const installedBlockNames = installedBlockTypes.map( |
| 470 |
(blockType) => blockType.name |
| 471 |
); |
| 472 |
const foundBlockNames = getClientIdsWithDescendants().flatMap( |
| 473 |
(clientId) => { |
| 474 |
const blockName = getBlockName(clientId); |
| 475 |
return installedBlockNames.includes(blockName) ? blockName : []; |
| 476 |
} |
| 477 |
); |
| 478 |
const newBlockTypes = installedBlockTypes.filter( |
| 479 |
(blockType) => foundBlockNames.includes(blockType.name) |
| 480 |
); |
| 481 |
return newBlockTypes.length > 0 ? newBlockTypes : EMPTY_ARRAY; |
| 482 |
}, |
| 483 |
(state) => [ |
| 484 |
getInstalledBlockTypes(state), |
| 485 |
select(import_block_editor.store).getClientIdsWithDescendants() |
| 486 |
] |
| 487 |
) |
| 488 |
); |
| 489 |
var getUnusedBlockTypes = (0, import_data2.createRegistrySelector)( |
| 490 |
(select) => (0, import_data2.createSelector)( |
| 491 |
(state) => { |
| 492 |
const installedBlockTypes = getInstalledBlockTypes(state); |
| 493 |
if (!installedBlockTypes.length) { |
| 494 |
return EMPTY_ARRAY; |
| 495 |
} |
| 496 |
const { getBlockName, getClientIdsWithDescendants } = select(import_block_editor.store); |
| 497 |
const installedBlockNames = installedBlockTypes.map( |
| 498 |
(blockType) => blockType.name |
| 499 |
); |
| 500 |
const foundBlockNames = getClientIdsWithDescendants().flatMap( |
| 501 |
(clientId) => { |
| 502 |
const blockName = getBlockName(clientId); |
| 503 |
return installedBlockNames.includes(blockName) ? blockName : []; |
| 504 |
} |
| 505 |
); |
| 506 |
const unusedBlockTypes = installedBlockTypes.filter( |
| 507 |
(blockType) => !foundBlockNames.includes(blockType.name) |
| 508 |
); |
| 509 |
return unusedBlockTypes.length > 0 ? unusedBlockTypes : EMPTY_ARRAY; |
| 510 |
}, |
| 511 |
(state) => [ |
| 512 |
getInstalledBlockTypes(state), |
| 513 |
select(import_block_editor.store).getClientIdsWithDescendants() |
| 514 |
] |
| 515 |
) |
| 516 |
); |
| 517 |
function isInstalling(state, blockId) { |
| 518 |
return state.blockManagement.isInstalling[blockId] || false; |
| 519 |
} |
| 520 |
function getErrorNotices(state) { |
| 521 |
return state.errorNotices; |
| 522 |
} |
| 523 |
function getErrorNoticeForBlock(state, blockId) { |
| 524 |
return state.errorNotices[blockId]; |
| 525 |
} |
| 526 |
|
| 527 |
// packages/block-directory/build-module/store/actions.mjs |
| 528 |
var actions_exports = {}; |
| 529 |
__export(actions_exports, { |
| 530 |
addInstalledBlockType: () => addInstalledBlockType, |
| 531 |
clearErrorNotice: () => clearErrorNotice, |
| 532 |
fetchDownloadableBlocks: () => fetchDownloadableBlocks, |
| 533 |
installBlockType: () => installBlockType, |
| 534 |
receiveDownloadableBlocks: () => receiveDownloadableBlocks, |
| 535 |
removeInstalledBlockType: () => removeInstalledBlockType, |
| 536 |
setErrorNotice: () => setErrorNotice, |
| 537 |
setIsInstalling: () => setIsInstalling, |
| 538 |
uninstallBlockType: () => uninstallBlockType |
| 539 |
}); |
| 540 |
var import_blocks = __toESM(require_blocks(), 1); |
| 541 |
var import_i18n = __toESM(require_i18n(), 1); |
| 542 |
var import_api_fetch2 = __toESM(require_api_fetch(), 1); |
| 543 |
var import_notices = __toESM(require_notices(), 1); |
| 544 |
var import_url = __toESM(require_url(), 1); |
| 545 |
|
| 546 |
// packages/block-directory/build-module/store/load-assets.mjs |
| 547 |
var import_api_fetch = __toESM(require_api_fetch(), 1); |
| 548 |
var loadAsset = (el) => { |
| 549 |
return new Promise((resolve, reject) => { |
| 550 |
const newNode = document.createElement(el.nodeName); |
| 551 |
["id", "rel", "src", "href", "type"].forEach((attr2) => { |
| 552 |
if (el[attr2]) { |
| 553 |
newNode[attr2] = el[attr2]; |
| 554 |
} |
| 555 |
}); |
| 556 |
if (el.innerHTML) { |
| 557 |
newNode.appendChild(document.createTextNode(el.innerHTML)); |
| 558 |
} |
| 559 |
newNode.onload = () => resolve(true); |
| 560 |
newNode.onerror = () => reject(new Error("Error loading asset.")); |
| 561 |
document.body.appendChild(newNode); |
| 562 |
if ("link" === newNode.nodeName.toLowerCase() || "script" === newNode.nodeName.toLowerCase() && !newNode.src) { |
| 563 |
resolve(); |
| 564 |
} |
| 565 |
}); |
| 566 |
}; |
| 567 |
async function loadAssets() { |
| 568 |
const response = await (0, import_api_fetch.default)({ |
| 569 |
url: document.location.href, |
| 570 |
parse: false |
| 571 |
}); |
| 572 |
const data = await response.text(); |
| 573 |
const doc = new window.DOMParser().parseFromString(data, "text/html"); |
| 574 |
const newAssets = Array.from( |
| 575 |
doc.querySelectorAll('link[rel="stylesheet"],script') |
| 576 |
).filter((asset) => asset.id && !document.getElementById(asset.id)); |
| 577 |
for (const newAsset of newAssets) { |
| 578 |
await loadAsset(newAsset); |
| 579 |
} |
| 580 |
} |
| 581 |
|
| 582 |
// packages/block-directory/build-module/store/utils/get-plugin-url.mjs |
| 583 |
function getPluginUrl(block) { |
| 584 |
if (!block) { |
| 585 |
return false; |
| 586 |
} |
| 587 |
const link = block.links["wp:plugin"] || block.links.self; |
| 588 |
if (link && link.length) { |
| 589 |
return link[0].href; |
| 590 |
} |
| 591 |
return false; |
| 592 |
} |
| 593 |
|
| 594 |
// packages/block-directory/build-module/store/actions.mjs |
| 595 |
function fetchDownloadableBlocks(filterValue) { |
| 596 |
return { type: "FETCH_DOWNLOADABLE_BLOCKS", filterValue }; |
| 597 |
} |
| 598 |
function receiveDownloadableBlocks(downloadableBlocks2, filterValue) { |
| 599 |
return { |
| 600 |
type: "RECEIVE_DOWNLOADABLE_BLOCKS", |
| 601 |
downloadableBlocks: downloadableBlocks2, |
| 602 |
filterValue |
| 603 |
}; |
| 604 |
} |
| 605 |
var installBlockType = (block) => async ({ registry, dispatch }) => { |
| 606 |
const { id, name } = block; |
| 607 |
let success = false; |
| 608 |
dispatch.clearErrorNotice(id); |
| 609 |
try { |
| 610 |
dispatch.setIsInstalling(id, true); |
| 611 |
const url = getPluginUrl(block); |
| 612 |
let links = {}; |
| 613 |
if (url) { |
| 614 |
await (0, import_api_fetch2.default)({ |
| 615 |
method: "PUT", |
| 616 |
url, |
| 617 |
data: { status: "active" } |
| 618 |
}); |
| 619 |
} else { |
| 620 |
const response = await (0, import_api_fetch2.default)({ |
| 621 |
method: "POST", |
| 622 |
path: "wp/v2/plugins", |
| 623 |
data: { slug: id, status: "active" } |
| 624 |
}); |
| 625 |
links = response._links; |
| 626 |
} |
| 627 |
dispatch.addInstalledBlockType({ |
| 628 |
...block, |
| 629 |
links: { ...block.links, ...links } |
| 630 |
}); |
| 631 |
const metadataFields = [ |
| 632 |
"api_version", |
| 633 |
"title", |
| 634 |
"category", |
| 635 |
"parent", |
| 636 |
"ancestor", |
| 637 |
"icon", |
| 638 |
"description", |
| 639 |
"keywords", |
| 640 |
"attributes", |
| 641 |
"provides_context", |
| 642 |
"uses_context", |
| 643 |
"selectors", |
| 644 |
"supports", |
| 645 |
"styles", |
| 646 |
"example", |
| 647 |
"variations", |
| 648 |
"allowed_blocks", |
| 649 |
"block_hooks" |
| 650 |
]; |
| 651 |
await (0, import_api_fetch2.default)({ |
| 652 |
path: (0, import_url.addQueryArgs)(`/wp/v2/block-types/${name}`, { |
| 653 |
_fields: metadataFields |
| 654 |
}) |
| 655 |
}).catch(() => { |
| 656 |
}).then((response) => { |
| 657 |
if (!response) { |
| 658 |
return; |
| 659 |
} |
| 660 |
(0, import_blocks.unstable__bootstrapServerSideBlockDefinitions)({ |
| 661 |
[name]: Object.fromEntries( |
| 662 |
Object.entries(response).filter( |
| 663 |
([key]) => metadataFields.includes(key) |
| 664 |
) |
| 665 |
) |
| 666 |
}); |
| 667 |
}); |
| 668 |
await loadAssets(); |
| 669 |
const registeredBlocks = registry.select(import_blocks.store).getBlockTypes(); |
| 670 |
if (!registeredBlocks.some((i) => i.name === name)) { |
| 671 |
throw new Error( |
| 672 |
(0, import_i18n.__)("Error registering block. Try reloading the page.") |
| 673 |
); |
| 674 |
} |
| 675 |
registry.dispatch(import_notices.store).createInfoNotice( |
| 676 |
(0, import_i18n.sprintf)( |
| 677 |
// translators: %s is the block title. |
| 678 |
(0, import_i18n.__)("Block %s installed and added."), |
| 679 |
block.title |
| 680 |
), |
| 681 |
{ |
| 682 |
speak: true, |
| 683 |
type: "snackbar" |
| 684 |
} |
| 685 |
); |
| 686 |
success = true; |
| 687 |
} catch (error) { |
| 688 |
let message = error.message || (0, import_i18n.__)("An error occurred."); |
| 689 |
let isFatal = error instanceof Error; |
| 690 |
const fatalAPIErrors = { |
| 691 |
folder_exists: (0, import_i18n.__)( |
| 692 |
"This block is already installed. Try reloading the page." |
| 693 |
), |
| 694 |
unable_to_connect_to_filesystem: (0, import_i18n.__)( |
| 695 |
"Error installing block. You can reload the page and try again." |
| 696 |
) |
| 697 |
}; |
| 698 |
if (fatalAPIErrors[error.code]) { |
| 699 |
isFatal = true; |
| 700 |
message = fatalAPIErrors[error.code]; |
| 701 |
} |
| 702 |
dispatch.setErrorNotice(id, message, isFatal); |
| 703 |
registry.dispatch(import_notices.store).createErrorNotice(message, { |
| 704 |
speak: true, |
| 705 |
isDismissible: true |
| 706 |
}); |
| 707 |
} |
| 708 |
dispatch.setIsInstalling(id, false); |
| 709 |
return success; |
| 710 |
}; |
| 711 |
var uninstallBlockType = (block) => async ({ registry, dispatch }) => { |
| 712 |
try { |
| 713 |
const url = getPluginUrl(block); |
| 714 |
await (0, import_api_fetch2.default)({ |
| 715 |
method: "PUT", |
| 716 |
url, |
| 717 |
data: { status: "inactive" } |
| 718 |
}); |
| 719 |
await (0, import_api_fetch2.default)({ |
| 720 |
method: "DELETE", |
| 721 |
url |
| 722 |
}); |
| 723 |
dispatch.removeInstalledBlockType(block); |
| 724 |
} catch (error) { |
| 725 |
registry.dispatch(import_notices.store).createErrorNotice( |
| 726 |
error.message || (0, import_i18n.__)("An error occurred.") |
| 727 |
); |
| 728 |
} |
| 729 |
}; |
| 730 |
function addInstalledBlockType(item) { |
| 731 |
return { |
| 732 |
type: "ADD_INSTALLED_BLOCK_TYPE", |
| 733 |
item |
| 734 |
}; |
| 735 |
} |
| 736 |
function removeInstalledBlockType(item) { |
| 737 |
return { |
| 738 |
type: "REMOVE_INSTALLED_BLOCK_TYPE", |
| 739 |
item |
| 740 |
}; |
| 741 |
} |
| 742 |
function setIsInstalling(blockId, isInstalling2) { |
| 743 |
return { |
| 744 |
type: "SET_INSTALLING_BLOCK", |
| 745 |
blockId, |
| 746 |
isInstalling: isInstalling2 |
| 747 |
}; |
| 748 |
} |
| 749 |
function setErrorNotice(blockId, message, isFatal = false) { |
| 750 |
return { |
| 751 |
type: "SET_ERROR_NOTICE", |
| 752 |
blockId, |
| 753 |
message, |
| 754 |
isFatal |
| 755 |
}; |
| 756 |
} |
| 757 |
function clearErrorNotice(blockId) { |
| 758 |
return { |
| 759 |
type: "CLEAR_ERROR_NOTICE", |
| 760 |
blockId |
| 761 |
}; |
| 762 |
} |
| 763 |
|
| 764 |
// packages/block-directory/build-module/store/resolvers.mjs |
| 765 |
var resolvers_exports = {}; |
| 766 |
__export(resolvers_exports, { |
| 767 |
getDownloadableBlocks: () => getDownloadableBlocks2 |
| 768 |
}); |
| 769 |
|
| 770 |
// node_modules/tslib/tslib.es6.mjs |
| 771 |
var __assign = function() { |
| 772 |
__assign = Object.assign || function __assign2(t) { |
| 773 |
for (var s, i = 1, n = arguments.length; i < n; i++) { |
| 774 |
s = arguments[i]; |
| 775 |
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; |
| 776 |
} |
| 777 |
return t; |
| 778 |
}; |
| 779 |
return __assign.apply(this, arguments); |
| 780 |
}; |
| 781 |
|
| 782 |
// node_modules/lower-case/dist.es2015/index.js |
| 783 |
function lowerCase(str) { |
| 784 |
return str.toLowerCase(); |
| 785 |
} |
| 786 |
|
| 787 |
// node_modules/no-case/dist.es2015/index.js |
| 788 |
var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g]; |
| 789 |
var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi; |
| 790 |
function noCase(input, options) { |
| 791 |
if (options === void 0) { |
| 792 |
options = {}; |
| 793 |
} |
| 794 |
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; |
| 795 |
var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0"); |
| 796 |
var start = 0; |
| 797 |
var end = result.length; |
| 798 |
while (result.charAt(start) === "\0") |
| 799 |
start++; |
| 800 |
while (result.charAt(end - 1) === "\0") |
| 801 |
end--; |
| 802 |
return result.slice(start, end).split("\0").map(transform).join(delimiter); |
| 803 |
} |
| 804 |
function replace(input, re, value) { |
| 805 |
if (re instanceof RegExp) |
| 806 |
return input.replace(re, value); |
| 807 |
return re.reduce(function(input2, re2) { |
| 808 |
return input2.replace(re2, value); |
| 809 |
}, input); |
| 810 |
} |
| 811 |
|
| 812 |
// node_modules/pascal-case/dist.es2015/index.js |
| 813 |
function pascalCaseTransform(input, index2) { |
| 814 |
var firstChar = input.charAt(0); |
| 815 |
var lowerChars = input.substr(1).toLowerCase(); |
| 816 |
if (index2 > 0 && firstChar >= "0" && firstChar <= "9") { |
| 817 |
return "_" + firstChar + lowerChars; |
| 818 |
} |
| 819 |
return "" + firstChar.toUpperCase() + lowerChars; |
| 820 |
} |
| 821 |
function pascalCase(input, options) { |
| 822 |
if (options === void 0) { |
| 823 |
options = {}; |
| 824 |
} |
| 825 |
return noCase(input, __assign({ delimiter: "", transform: pascalCaseTransform }, options)); |
| 826 |
} |
| 827 |
|
| 828 |
// node_modules/camel-case/dist.es2015/index.js |
| 829 |
function camelCaseTransform(input, index2) { |
| 830 |
if (index2 === 0) |
| 831 |
return input.toLowerCase(); |
| 832 |
return pascalCaseTransform(input, index2); |
| 833 |
} |
| 834 |
function camelCase(input, options) { |
| 835 |
if (options === void 0) { |
| 836 |
options = {}; |
| 837 |
} |
| 838 |
return pascalCase(input, __assign({ transform: camelCaseTransform }, options)); |
| 839 |
} |
| 840 |
|
| 841 |
// packages/block-directory/build-module/store/resolvers.mjs |
| 842 |
var import_api_fetch3 = __toESM(require_api_fetch(), 1); |
| 843 |
var getDownloadableBlocks2 = (filterValue) => async ({ dispatch }) => { |
| 844 |
if (!filterValue) { |
| 845 |
return; |
| 846 |
} |
| 847 |
try { |
| 848 |
dispatch(fetchDownloadableBlocks(filterValue)); |
| 849 |
const results = await (0, import_api_fetch3.default)({ |
| 850 |
path: `wp/v2/block-directory/search?term=${filterValue}` |
| 851 |
}); |
| 852 |
const blocks = results.map( |
| 853 |
(result) => Object.fromEntries( |
| 854 |
Object.entries(result).map(([key, value]) => [ |
| 855 |
camelCase(key), |
| 856 |
value |
| 857 |
]) |
| 858 |
) |
| 859 |
); |
| 860 |
dispatch(receiveDownloadableBlocks(blocks, filterValue)); |
| 861 |
} catch { |
| 862 |
dispatch(receiveDownloadableBlocks([], filterValue)); |
| 863 |
} |
| 864 |
}; |
| 865 |
|
| 866 |
// packages/block-directory/build-module/store/index.mjs |
| 867 |
var STORE_NAME = "core/block-directory"; |
| 868 |
var storeConfig = { |
| 869 |
reducer: reducer_default, |
| 870 |
selectors: selectors_exports, |
| 871 |
actions: actions_exports, |
| 872 |
resolvers: resolvers_exports |
| 873 |
}; |
| 874 |
var store = (0, import_data3.createReduxStore)(STORE_NAME, storeConfig); |
| 875 |
(0, import_data3.register)(store); |
| 876 |
|
| 877 |
// packages/block-directory/build-module/components/auto-block-uninstaller/index.mjs |
| 878 |
function AutoBlockUninstaller() { |
| 879 |
const { uninstallBlockType: uninstallBlockType2 } = (0, import_data4.useDispatch)(store); |
| 880 |
const shouldRemoveBlockTypes = (0, import_data4.useSelect)((select) => { |
| 881 |
const { isAutosavingPost, isSavingPost } = select(import_editor.store); |
| 882 |
return isSavingPost() && !isAutosavingPost(); |
| 883 |
}, []); |
| 884 |
const unusedBlockTypes = (0, import_data4.useSelect)( |
| 885 |
(select) => select(store).getUnusedBlockTypes(), |
| 886 |
[] |
| 887 |
); |
| 888 |
(0, import_element.useEffect)(() => { |
| 889 |
if (shouldRemoveBlockTypes && unusedBlockTypes.length) { |
| 890 |
unusedBlockTypes.forEach((blockType) => { |
| 891 |
uninstallBlockType2(blockType); |
| 892 |
(0, import_blocks2.unregisterBlockType)(blockType.name); |
| 893 |
}); |
| 894 |
} |
| 895 |
}, [shouldRemoveBlockTypes]); |
| 896 |
return null; |
| 897 |
} |
| 898 |
|
| 899 |
// packages/block-directory/build-module/plugins/inserter-menu-downloadable-blocks-panel/index.mjs |
| 900 |
var import_block_editor3 = __toESM(require_block_editor(), 1); |
| 901 |
var import_compose = __toESM(require_compose(), 1); |
| 902 |
var import_element20 = __toESM(require_element(), 1); |
| 903 |
|
| 904 |
// packages/block-directory/build-module/components/downloadable-blocks-panel/index.mjs |
| 905 |
var import_i18n8 = __toESM(require_i18n(), 1); |
| 906 |
var import_components4 = __toESM(require_components(), 1); |
| 907 |
var import_core_data = __toESM(require_core_data(), 1); |
| 908 |
var import_data8 = __toESM(require_data(), 1); |
| 909 |
var import_blocks5 = __toESM(require_blocks(), 1); |
| 910 |
|
| 911 |
// packages/block-directory/build-module/components/downloadable-blocks-list/index.mjs |
| 912 |
var import_i18n5 = __toESM(require_i18n(), 1); |
| 913 |
var import_components2 = __toESM(require_components(), 1); |
| 914 |
var import_blocks4 = __toESM(require_blocks(), 1); |
| 915 |
var import_data7 = __toESM(require_data(), 1); |
| 916 |
|
| 917 |
// node_modules/clsx/dist/clsx.mjs |
| 918 |
function r(e) { |
| 919 |
var t, f, n = ""; |
| 920 |
if ("string" == typeof e || "number" == typeof e) n += e; |
| 921 |
else if ("object" == typeof e) if (Array.isArray(e)) { |
| 922 |
var o = e.length; |
| 923 |
for (t = 0; t < o; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f); |
| 924 |
} else for (f in e) e[f] && (n && (n += " "), n += f); |
| 925 |
return n; |
| 926 |
} |
| 927 |
function clsx() { |
| 928 |
for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t); |
| 929 |
return n; |
| 930 |
} |
| 931 |
var clsx_default = clsx; |
| 932 |
|
| 933 |
// packages/block-directory/build-module/components/downloadable-block-list-item/index.mjs |
| 934 |
var import_i18n4 = __toESM(require_i18n(), 1); |
| 935 |
var import_components = __toESM(require_components(), 1); |
| 936 |
var import_element18 = __toESM(require_element(), 1); |
| 937 |
var import_html_entities = __toESM(require_html_entities(), 1); |
| 938 |
var import_blocks3 = __toESM(require_blocks(), 1); |
| 939 |
var import_data6 = __toESM(require_data(), 1); |
| 940 |
|
| 941 |
// node_modules/@base-ui/utils/safeReact.mjs |
| 942 |
var React = __toESM(require_react(), 1); |
| 943 |
var SafeReact = { |
| 944 |
...React |
| 945 |
}; |
| 946 |
|
| 947 |
// node_modules/@base-ui/utils/useRefWithInit.mjs |
| 948 |
var React2 = __toESM(require_react(), 1); |
| 949 |
var UNINITIALIZED = {}; |
| 950 |
function useRefWithInit(init, initArg) { |
| 951 |
const ref = React2.useRef(UNINITIALIZED); |
| 952 |
if (ref.current === UNINITIALIZED) { |
| 953 |
ref.current = init(initArg); |
| 954 |
} |
| 955 |
return ref; |
| 956 |
} |
| 957 |
|
| 958 |
// node_modules/@base-ui/utils/useStableCallback.mjs |
| 959 |
var useInsertionEffect = SafeReact.useInsertionEffect; |
| 960 |
var useSafeInsertionEffect = ( |
| 961 |
// React 17 doesn't have useInsertionEffect. |
| 962 |
useInsertionEffect && // Preact replaces useInsertionEffect with useLayoutEffect and fires too late. |
| 963 |
useInsertionEffect !== SafeReact.useLayoutEffect ? useInsertionEffect : (fn) => fn() |
| 964 |
); |
| 965 |
function useStableCallback(callback) { |
| 966 |
const stable = useRefWithInit(createStableCallback).current; |
| 967 |
stable.next = callback; |
| 968 |
useSafeInsertionEffect(stable.effect); |
| 969 |
return stable.trampoline; |
| 970 |
} |
| 971 |
function createStableCallback() { |
| 972 |
const stable = { |
| 973 |
next: void 0, |
| 974 |
callback: assertNotCalled, |
| 975 |
trampoline: (...args) => stable.callback?.(...args), |
| 976 |
effect: () => { |
| 977 |
stable.callback = stable.next; |
| 978 |
} |
| 979 |
}; |
| 980 |
return stable; |
| 981 |
} |
| 982 |
function assertNotCalled() { |
| 983 |
if (true) { |
| 984 |
throw ( |
| 985 |
/* minify-error-disabled */ |
| 986 |
new Error("Base UI: Cannot call an event handler while rendering.") |
| 987 |
); |
| 988 |
} |
| 989 |
} |
| 990 |
|
| 991 |
// node_modules/@base-ui/utils/useIsoLayoutEffect.mjs |
| 992 |
var React3 = __toESM(require_react(), 1); |
| 993 |
var noop = () => { |
| 994 |
}; |
| 995 |
var useIsoLayoutEffect = typeof document !== "undefined" ? React3.useLayoutEffect : noop; |
| 996 |
|
| 997 |
// node_modules/@base-ui/utils/warn.mjs |
| 998 |
var set; |
| 999 |
if (true) { |
| 1000 |
set = /* @__PURE__ */ new Set(); |
| 1001 |
} |
| 1002 |
function warn(...messages) { |
| 1003 |
if (true) { |
| 1004 |
const messageKey = messages.join(" "); |
| 1005 |
if (!set.has(messageKey)) { |
| 1006 |
set.add(messageKey); |
| 1007 |
console.warn(`Base UI: ${messageKey}`); |
| 1008 |
} |
| 1009 |
} |
| 1010 |
} |
| 1011 |
|
| 1012 |
// node_modules/@base-ui/react/internals/direction-context/DirectionContext.mjs |
| 1013 |
var React4 = __toESM(require_react(), 1); |
| 1014 |
var DirectionContext = /* @__PURE__ */ React4.createContext(void 0); |
| 1015 |
if (true) DirectionContext.displayName = "DirectionContext"; |
| 1016 |
function useDirection() { |
| 1017 |
const context = React4.useContext(DirectionContext); |
| 1018 |
return context?.direction ?? "ltr"; |
| 1019 |
} |
| 1020 |
|
| 1021 |
// node_modules/@base-ui/react/internals/useRenderElement.mjs |
| 1022 |
var React7 = __toESM(require_react(), 1); |
| 1023 |
|
| 1024 |
// node_modules/@base-ui/utils/useMergedRefs.mjs |
| 1025 |
function useMergedRefs(a, b, c, d) { |
| 1026 |
const forkRef = useRefWithInit(createForkRef).current; |
| 1027 |
if (didChange(forkRef, a, b, c, d)) { |
| 1028 |
update(forkRef, [a, b, c, d]); |
| 1029 |
} |
| 1030 |
return forkRef.callback; |
| 1031 |
} |
| 1032 |
function useMergedRefsN(refs) { |
| 1033 |
const forkRef = useRefWithInit(createForkRef).current; |
| 1034 |
if (didChangeN(forkRef, refs)) { |
| 1035 |
update(forkRef, refs); |
| 1036 |
} |
| 1037 |
return forkRef.callback; |
| 1038 |
} |
| 1039 |
function createForkRef() { |
| 1040 |
return { |
| 1041 |
callback: null, |
| 1042 |
cleanup: null, |
| 1043 |
refs: [] |
| 1044 |
}; |
| 1045 |
} |
| 1046 |
function didChange(forkRef, a, b, c, d) { |
| 1047 |
return forkRef.refs[0] !== a || forkRef.refs[1] !== b || forkRef.refs[2] !== c || forkRef.refs[3] !== d; |
| 1048 |
} |
| 1049 |
function didChangeN(forkRef, newRefs) { |
| 1050 |
return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index2) => ref !== newRefs[index2]); |
| 1051 |
} |
| 1052 |
function update(forkRef, refs) { |
| 1053 |
forkRef.refs = refs; |
| 1054 |
if (refs.every((ref) => ref == null)) { |
| 1055 |
forkRef.callback = null; |
| 1056 |
return; |
| 1057 |
} |
| 1058 |
forkRef.callback = (instance) => { |
| 1059 |
if (forkRef.cleanup) { |
| 1060 |
forkRef.cleanup(); |
| 1061 |
forkRef.cleanup = null; |
| 1062 |
} |
| 1063 |
if (instance != null) { |
| 1064 |
const cleanupCallbacks = Array(refs.length).fill(null); |
| 1065 |
for (let i = 0; i < refs.length; i += 1) { |
| 1066 |
const ref = refs[i]; |
| 1067 |
if (ref == null) { |
| 1068 |
continue; |
| 1069 |
} |
| 1070 |
switch (typeof ref) { |
| 1071 |
case "function": { |
| 1072 |
const refCleanup = ref(instance); |
| 1073 |
if (typeof refCleanup === "function") { |
| 1074 |
cleanupCallbacks[i] = refCleanup; |
| 1075 |
} |
| 1076 |
break; |
| 1077 |
} |
| 1078 |
case "object": { |
| 1079 |
ref.current = instance; |
| 1080 |
break; |
| 1081 |
} |
| 1082 |
default: |
| 1083 |
} |
| 1084 |
} |
| 1085 |
forkRef.cleanup = () => { |
| 1086 |
for (let i = 0; i < refs.length; i += 1) { |
| 1087 |
const ref = refs[i]; |
| 1088 |
if (ref == null) { |
| 1089 |
continue; |
| 1090 |
} |
| 1091 |
switch (typeof ref) { |
| 1092 |
case "function": { |
| 1093 |
const cleanupCallback = cleanupCallbacks[i]; |
| 1094 |
if (typeof cleanupCallback === "function") { |
| 1095 |
cleanupCallback(); |
| 1096 |
} else { |
| 1097 |
ref(null); |
| 1098 |
} |
| 1099 |
break; |
| 1100 |
} |
| 1101 |
case "object": { |
| 1102 |
ref.current = null; |
| 1103 |
break; |
| 1104 |
} |
| 1105 |
default: |
| 1106 |
} |
| 1107 |
} |
| 1108 |
}; |
| 1109 |
} |
| 1110 |
}; |
| 1111 |
} |
| 1112 |
|
| 1113 |
// node_modules/@base-ui/utils/getReactElementRef.mjs |
| 1114 |
var React6 = __toESM(require_react(), 1); |
| 1115 |
|
| 1116 |
// node_modules/@base-ui/utils/reactVersion.mjs |
| 1117 |
var React5 = __toESM(require_react(), 1); |
| 1118 |
var majorVersion = parseInt(React5.version, 10); |
| 1119 |
function isReactVersionAtLeast(reactVersionToCheck) { |
| 1120 |
return majorVersion >= reactVersionToCheck; |
| 1121 |
} |
| 1122 |
|
| 1123 |
// node_modules/@base-ui/utils/getReactElementRef.mjs |
| 1124 |
function getReactElementRef(element) { |
| 1125 |
if (!/* @__PURE__ */ React6.isValidElement(element)) { |
| 1126 |
return null; |
| 1127 |
} |
| 1128 |
const reactElement = element; |
| 1129 |
const propsWithRef = reactElement.props; |
| 1130 |
return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null; |
| 1131 |
} |
| 1132 |
|
| 1133 |
// node_modules/@base-ui/utils/mergeObjects.mjs |
| 1134 |
function mergeObjects(a, b) { |
| 1135 |
if (a && !b) { |
| 1136 |
return a; |
| 1137 |
} |
| 1138 |
if (!a && b) { |
| 1139 |
return b; |
| 1140 |
} |
| 1141 |
if (a || b) { |
| 1142 |
return { |
| 1143 |
...a, |
| 1144 |
...b |
| 1145 |
}; |
| 1146 |
} |
| 1147 |
return void 0; |
| 1148 |
} |
| 1149 |
|
| 1150 |
// node_modules/@base-ui/utils/empty.mjs |
| 1151 |
function NOOP() { |
| 1152 |
} |
| 1153 |
var EMPTY_ARRAY2 = Object.freeze([]); |
| 1154 |
var EMPTY_OBJECT = Object.freeze({}); |
| 1155 |
|
| 1156 |
// node_modules/@base-ui/react/internals/getStateAttributesProps.mjs |
| 1157 |
function getStateAttributesProps(state, customMapping) { |
| 1158 |
const props = {}; |
| 1159 |
for (const key in state) { |
| 1160 |
const value = state[key]; |
| 1161 |
if (customMapping?.hasOwnProperty(key)) { |
| 1162 |
const customProps = customMapping[key](value); |
| 1163 |
if (customProps != null) { |
| 1164 |
Object.assign(props, customProps); |
| 1165 |
} |
| 1166 |
continue; |
| 1167 |
} |
| 1168 |
if (value === true) { |
| 1169 |
props[`data-${key.toLowerCase()}`] = ""; |
| 1170 |
} else if (value) { |
| 1171 |
props[`data-${key.toLowerCase()}`] = value.toString(); |
| 1172 |
} |
| 1173 |
} |
| 1174 |
return props; |
| 1175 |
} |
| 1176 |
|
| 1177 |
// node_modules/@base-ui/react/utils/resolveClassName.mjs |
| 1178 |
function resolveClassName(className, state) { |
| 1179 |
return typeof className === "function" ? className(state) : className; |
| 1180 |
} |
| 1181 |
|
| 1182 |
// node_modules/@base-ui/react/utils/resolveStyle.mjs |
| 1183 |
function resolveStyle(style, state) { |
| 1184 |
return typeof style === "function" ? style(state) : style; |
| 1185 |
} |
| 1186 |
|
| 1187 |
// node_modules/@base-ui/react/merge-props/mergeProps.mjs |
| 1188 |
var EMPTY_PROPS = {}; |
| 1189 |
function mergeProps(a, b, c, d, e) { |
| 1190 |
if (!c && !d && !e && !a) { |
| 1191 |
return createInitialMergedProps(b); |
| 1192 |
} |
| 1193 |
let merged = createInitialMergedProps(a); |
| 1194 |
if (b) { |
| 1195 |
merged = mergeInto(merged, b); |
| 1196 |
} |
| 1197 |
if (c) { |
| 1198 |
merged = mergeInto(merged, c); |
| 1199 |
} |
| 1200 |
if (d) { |
| 1201 |
merged = mergeInto(merged, d); |
| 1202 |
} |
| 1203 |
if (e) { |
| 1204 |
merged = mergeInto(merged, e); |
| 1205 |
} |
| 1206 |
return merged; |
| 1207 |
} |
| 1208 |
function mergePropsN(props) { |
| 1209 |
if (props.length === 0) { |
| 1210 |
return EMPTY_PROPS; |
| 1211 |
} |
| 1212 |
if (props.length === 1) { |
| 1213 |
return createInitialMergedProps(props[0]); |
| 1214 |
} |
| 1215 |
let merged = createInitialMergedProps(props[0]); |
| 1216 |
for (let i = 1; i < props.length; i += 1) { |
| 1217 |
merged = mergeInto(merged, props[i]); |
| 1218 |
} |
| 1219 |
return merged; |
| 1220 |
} |
| 1221 |
function createInitialMergedProps(inputProps) { |
| 1222 |
if (isPropsGetter(inputProps)) { |
| 1223 |
return { |
| 1224 |
...resolvePropsGetter(inputProps, EMPTY_PROPS) |
| 1225 |
}; |
| 1226 |
} |
| 1227 |
return copyInitialProps(inputProps); |
| 1228 |
} |
| 1229 |
function mergeInto(merged, inputProps) { |
| 1230 |
if (isPropsGetter(inputProps)) { |
| 1231 |
return resolvePropsGetter(inputProps, merged); |
| 1232 |
} |
| 1233 |
return mutablyMergeInto(merged, inputProps); |
| 1234 |
} |
| 1235 |
function copyInitialProps(inputProps) { |
| 1236 |
const copiedProps = { |
| 1237 |
...inputProps |
| 1238 |
}; |
| 1239 |
for (const propName in copiedProps) { |
| 1240 |
const propValue = copiedProps[propName]; |
| 1241 |
if (isEventHandler(propName, propValue)) { |
| 1242 |
copiedProps[propName] = wrapEventHandler(propValue); |
| 1243 |
} |
| 1244 |
} |
| 1245 |
return copiedProps; |
| 1246 |
} |
| 1247 |
function mutablyMergeInto(mergedProps, externalProps) { |
| 1248 |
if (!externalProps) { |
| 1249 |
return mergedProps; |
| 1250 |
} |
| 1251 |
for (const propName in externalProps) { |
| 1252 |
const externalPropValue = externalProps[propName]; |
| 1253 |
switch (propName) { |
| 1254 |
case "style": { |
| 1255 |
mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue); |
| 1256 |
break; |
| 1257 |
} |
| 1258 |
case "className": { |
| 1259 |
mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue); |
| 1260 |
break; |
| 1261 |
} |
| 1262 |
default: { |
| 1263 |
if (isEventHandler(propName, externalPropValue)) { |
| 1264 |
mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue); |
| 1265 |
} else { |
| 1266 |
mergedProps[propName] = externalPropValue; |
| 1267 |
} |
| 1268 |
} |
| 1269 |
} |
| 1270 |
} |
| 1271 |
return mergedProps; |
| 1272 |
} |
| 1273 |
function isEventHandler(key, value) { |
| 1274 |
const code0 = key.charCodeAt(0); |
| 1275 |
const code1 = key.charCodeAt(1); |
| 1276 |
const code2 = key.charCodeAt(2); |
| 1277 |
return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined"); |
| 1278 |
} |
| 1279 |
function isPropsGetter(inputProps) { |
| 1280 |
return typeof inputProps === "function"; |
| 1281 |
} |
| 1282 |
function resolvePropsGetter(inputProps, previousProps) { |
| 1283 |
if (isPropsGetter(inputProps)) { |
| 1284 |
return inputProps(previousProps); |
| 1285 |
} |
| 1286 |
return inputProps ?? EMPTY_PROPS; |
| 1287 |
} |
| 1288 |
function mergeEventHandlers(ourHandler, theirHandler) { |
| 1289 |
if (!theirHandler) { |
| 1290 |
return ourHandler; |
| 1291 |
} |
| 1292 |
if (!ourHandler) { |
| 1293 |
return wrapEventHandler(theirHandler); |
| 1294 |
} |
| 1295 |
return (...args) => { |
| 1296 |
const event = args[0]; |
| 1297 |
if (isSyntheticEvent(event)) { |
| 1298 |
const baseUIEvent = event; |
| 1299 |
makeEventPreventable(baseUIEvent); |
| 1300 |
const result2 = theirHandler(...args); |
| 1301 |
if (!baseUIEvent.baseUIHandlerPrevented) { |
| 1302 |
ourHandler?.(...args); |
| 1303 |
} |
| 1304 |
return result2; |
| 1305 |
} |
| 1306 |
const result = theirHandler(...args); |
| 1307 |
ourHandler?.(...args); |
| 1308 |
return result; |
| 1309 |
}; |
| 1310 |
} |
| 1311 |
function wrapEventHandler(handler) { |
| 1312 |
if (!handler) { |
| 1313 |
return handler; |
| 1314 |
} |
| 1315 |
return (...args) => { |
| 1316 |
const event = args[0]; |
| 1317 |
if (isSyntheticEvent(event)) { |
| 1318 |
makeEventPreventable(event); |
| 1319 |
} |
| 1320 |
return handler(...args); |
| 1321 |
}; |
| 1322 |
} |
| 1323 |
function makeEventPreventable(event) { |
| 1324 |
event.preventBaseUIHandler = () => { |
| 1325 |
event.baseUIHandlerPrevented = true; |
| 1326 |
}; |
| 1327 |
return event; |
| 1328 |
} |
| 1329 |
function mergeClassNames(ourClassName, theirClassName) { |
| 1330 |
if (theirClassName) { |
| 1331 |
if (ourClassName) { |
| 1332 |
return theirClassName + " " + ourClassName; |
| 1333 |
} |
| 1334 |
return theirClassName; |
| 1335 |
} |
| 1336 |
return ourClassName; |
| 1337 |
} |
| 1338 |
function isSyntheticEvent(event) { |
| 1339 |
return event != null && typeof event === "object" && "nativeEvent" in event; |
| 1340 |
} |
| 1341 |
|
| 1342 |
// node_modules/@base-ui/react/internals/useRenderElement.mjs |
| 1343 |
var import_react = __toESM(require_react(), 1); |
| 1344 |
function useRenderElement(element, componentProps, params = {}) { |
| 1345 |
const renderProp = componentProps.render; |
| 1346 |
const outProps = useRenderElementProps(componentProps, params); |
| 1347 |
if (params.enabled === false) { |
| 1348 |
return null; |
| 1349 |
} |
| 1350 |
const state = params.state ?? EMPTY_OBJECT; |
| 1351 |
return evaluateRenderProp(element, renderProp, outProps, state); |
| 1352 |
} |
| 1353 |
function useRenderElementProps(componentProps, params = {}) { |
| 1354 |
const { |
| 1355 |
className: classNameProp, |
| 1356 |
style: styleProp, |
| 1357 |
render: renderProp |
| 1358 |
} = componentProps; |
| 1359 |
const { |
| 1360 |
state = EMPTY_OBJECT, |
| 1361 |
ref, |
| 1362 |
props, |
| 1363 |
stateAttributesMapping: stateAttributesMapping3, |
| 1364 |
enabled = true |
| 1365 |
} = params; |
| 1366 |
const className = enabled ? resolveClassName(classNameProp, state) : void 0; |
| 1367 |
const style = enabled ? resolveStyle(styleProp, state) : void 0; |
| 1368 |
const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping3) : EMPTY_OBJECT; |
| 1369 |
const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0; |
| 1370 |
const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT; |
| 1371 |
if (typeof document !== "undefined") { |
| 1372 |
if (!enabled) { |
| 1373 |
useMergedRefs(null, null); |
| 1374 |
} else if (Array.isArray(ref)) { |
| 1375 |
outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]); |
| 1376 |
} else { |
| 1377 |
outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref); |
| 1378 |
} |
| 1379 |
} |
| 1380 |
if (!enabled) { |
| 1381 |
return EMPTY_OBJECT; |
| 1382 |
} |
| 1383 |
if (className !== void 0) { |
| 1384 |
outProps.className = mergeClassNames(outProps.className, className); |
| 1385 |
} |
| 1386 |
if (style !== void 0) { |
| 1387 |
outProps.style = mergeObjects(outProps.style, style); |
| 1388 |
} |
| 1389 |
return outProps; |
| 1390 |
} |
| 1391 |
function resolveRenderFunctionProps(props) { |
| 1392 |
if (Array.isArray(props)) { |
| 1393 |
return mergePropsN(props); |
| 1394 |
} |
| 1395 |
return mergeProps(void 0, props); |
| 1396 |
} |
| 1397 |
var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy"); |
| 1398 |
var COMPONENT_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9$]*$/; |
| 1399 |
var LOWERCASE_CHARACTER_PATTERN = /[a-z]/; |
| 1400 |
function evaluateRenderProp(element, render, props, state) { |
| 1401 |
if (render) { |
| 1402 |
if (typeof render === "function") { |
| 1403 |
if (true) { |
| 1404 |
warnIfRenderPropLooksLikeComponent(render); |
| 1405 |
} |
| 1406 |
return render(props, state); |
| 1407 |
} |
| 1408 |
const mergedProps = mergeProps(props, render.props); |
| 1409 |
mergedProps.ref = props.ref; |
| 1410 |
let newElement = render; |
| 1411 |
if (newElement?.$$typeof === REACT_LAZY_TYPE) { |
| 1412 |
const children = React7.Children.toArray(render); |
| 1413 |
newElement = children[0]; |
| 1414 |
} |
| 1415 |
if (true) { |
| 1416 |
if (!/* @__PURE__ */ React7.isValidElement(newElement)) { |
| 1417 |
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")); |
| 1418 |
} |
| 1419 |
} |
| 1420 |
return /* @__PURE__ */ React7.cloneElement(newElement, mergedProps); |
| 1421 |
} |
| 1422 |
if (element) { |
| 1423 |
if (typeof element === "string") { |
| 1424 |
return renderTag(element, props); |
| 1425 |
} |
| 1426 |
} |
| 1427 |
throw new Error(true ? "Base UI: Render element or function are not defined." : formatErrorMessage_default(8)); |
| 1428 |
} |
| 1429 |
function warnIfRenderPropLooksLikeComponent(renderFn) { |
| 1430 |
const functionName = renderFn.name; |
| 1431 |
if (functionName.length === 0) { |
| 1432 |
return; |
| 1433 |
} |
| 1434 |
if (!COMPONENT_IDENTIFIER_PATTERN.test(functionName)) { |
| 1435 |
return; |
| 1436 |
} |
| 1437 |
if (!LOWERCASE_CHARACTER_PATTERN.test(functionName)) { |
| 1438 |
return; |
| 1439 |
} |
| 1440 |
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"); |
| 1441 |
} |
| 1442 |
function renderTag(Tag, props) { |
| 1443 |
if (Tag === "button") { |
| 1444 |
return /* @__PURE__ */ (0, import_react.createElement)("button", { |
| 1445 |
type: "button", |
| 1446 |
...props, |
| 1447 |
key: props.key |
| 1448 |
}); |
| 1449 |
} |
| 1450 |
if (Tag === "img") { |
| 1451 |
return /* @__PURE__ */ (0, import_react.createElement)("img", { |
| 1452 |
alt: "", |
| 1453 |
...props, |
| 1454 |
key: props.key |
| 1455 |
}); |
| 1456 |
} |
| 1457 |
return /* @__PURE__ */ React7.createElement(Tag, props); |
| 1458 |
} |
| 1459 |
|
| 1460 |
// node_modules/@base-ui/utils/useId.mjs |
| 1461 |
var React8 = __toESM(require_react(), 1); |
| 1462 |
var globalId = 0; |
| 1463 |
function useGlobalId(idOverride, prefix = "mui") { |
| 1464 |
const [defaultId, setDefaultId] = React8.useState(idOverride); |
| 1465 |
const id = idOverride || defaultId; |
| 1466 |
React8.useEffect(() => { |
| 1467 |
if (defaultId == null) { |
| 1468 |
globalId += 1; |
| 1469 |
setDefaultId(`${prefix}-${globalId}`); |
| 1470 |
} |
| 1471 |
}, [defaultId, prefix]); |
| 1472 |
return id; |
| 1473 |
} |
| 1474 |
var maybeReactUseId = SafeReact.useId; |
| 1475 |
function useId(idOverride, prefix) { |
| 1476 |
if (maybeReactUseId !== void 0) { |
| 1477 |
const reactId = maybeReactUseId(); |
| 1478 |
return idOverride ?? (prefix ? `${prefix}-${reactId}` : reactId); |
| 1479 |
} |
| 1480 |
return useGlobalId(idOverride, prefix); |
| 1481 |
} |
| 1482 |
|
| 1483 |
// node_modules/@base-ui/react/internals/useBaseUiId.mjs |
| 1484 |
function useBaseUiId(idOverride) { |
| 1485 |
return useId(idOverride, "base-ui"); |
| 1486 |
} |
| 1487 |
|
| 1488 |
// node_modules/@base-ui/react/internals/reason-parts.mjs |
| 1489 |
var reason_parts_exports = {}; |
| 1490 |
__export(reason_parts_exports, { |
| 1491 |
cancelOpen: () => cancelOpen, |
| 1492 |
chipRemovePress: () => chipRemovePress, |
| 1493 |
clearPress: () => clearPress, |
| 1494 |
closePress: () => closePress, |
| 1495 |
closeWatcher: () => closeWatcher, |
| 1496 |
decrementPress: () => decrementPress, |
| 1497 |
disabled: () => disabled, |
| 1498 |
drag: () => drag, |
| 1499 |
escapeKey: () => escapeKey, |
| 1500 |
focusOut: () => focusOut, |
| 1501 |
imperativeAction: () => imperativeAction, |
| 1502 |
incrementPress: () => incrementPress, |
| 1503 |
initial: () => initial, |
| 1504 |
inputBlur: () => inputBlur, |
| 1505 |
inputChange: () => inputChange, |
| 1506 |
inputClear: () => inputClear, |
| 1507 |
inputPaste: () => inputPaste, |
| 1508 |
inputPress: () => inputPress, |
| 1509 |
itemPress: () => itemPress, |
| 1510 |
keyboard: () => keyboard, |
| 1511 |
linkPress: () => linkPress, |
| 1512 |
listNavigation: () => listNavigation, |
| 1513 |
missing: () => missing, |
| 1514 |
none: () => none, |
| 1515 |
outsidePress: () => outsidePress, |
| 1516 |
pointer: () => pointer, |
| 1517 |
scrub: () => scrub, |
| 1518 |
siblingOpen: () => siblingOpen, |
| 1519 |
swipe: () => swipe, |
| 1520 |
trackPress: () => trackPress, |
| 1521 |
triggerFocus: () => triggerFocus, |
| 1522 |
triggerHover: () => triggerHover, |
| 1523 |
triggerPress: () => triggerPress, |
| 1524 |
wheel: () => wheel, |
| 1525 |
windowResize: () => windowResize |
| 1526 |
}); |
| 1527 |
var none = "none"; |
| 1528 |
var triggerPress = "trigger-press"; |
| 1529 |
var triggerHover = "trigger-hover"; |
| 1530 |
var triggerFocus = "trigger-focus"; |
| 1531 |
var outsidePress = "outside-press"; |
| 1532 |
var itemPress = "item-press"; |
| 1533 |
var closePress = "close-press"; |
| 1534 |
var linkPress = "link-press"; |
| 1535 |
var clearPress = "clear-press"; |
| 1536 |
var chipRemovePress = "chip-remove-press"; |
| 1537 |
var trackPress = "track-press"; |
| 1538 |
var incrementPress = "increment-press"; |
| 1539 |
var decrementPress = "decrement-press"; |
| 1540 |
var inputChange = "input-change"; |
| 1541 |
var inputClear = "input-clear"; |
| 1542 |
var inputBlur = "input-blur"; |
| 1543 |
var inputPaste = "input-paste"; |
| 1544 |
var inputPress = "input-press"; |
| 1545 |
var focusOut = "focus-out"; |
| 1546 |
var escapeKey = "escape-key"; |
| 1547 |
var closeWatcher = "close-watcher"; |
| 1548 |
var listNavigation = "list-navigation"; |
| 1549 |
var keyboard = "keyboard"; |
| 1550 |
var pointer = "pointer"; |
| 1551 |
var drag = "drag"; |
| 1552 |
var wheel = "wheel"; |
| 1553 |
var scrub = "scrub"; |
| 1554 |
var cancelOpen = "cancel-open"; |
| 1555 |
var siblingOpen = "sibling-open"; |
| 1556 |
var disabled = "disabled"; |
| 1557 |
var missing = "missing"; |
| 1558 |
var initial = "initial"; |
| 1559 |
var imperativeAction = "imperative-action"; |
| 1560 |
var swipe = "swipe"; |
| 1561 |
var windowResize = "window-resize"; |
| 1562 |
|
| 1563 |
// node_modules/@base-ui/react/internals/createBaseUIEventDetails.mjs |
| 1564 |
function createChangeEventDetails(reason, event, trigger, customProperties) { |
| 1565 |
let canceled = false; |
| 1566 |
let allowPropagation = false; |
| 1567 |
const custom = customProperties ?? EMPTY_OBJECT; |
| 1568 |
const details = { |
| 1569 |
reason, |
| 1570 |
event: event ?? new Event("base-ui"), |
| 1571 |
cancel() { |
| 1572 |
canceled = true; |
| 1573 |
}, |
| 1574 |
allowPropagation() { |
| 1575 |
allowPropagation = true; |
| 1576 |
}, |
| 1577 |
get isCanceled() { |
| 1578 |
return canceled; |
| 1579 |
}, |
| 1580 |
get isPropagationAllowed() { |
| 1581 |
return allowPropagation; |
| 1582 |
}, |
| 1583 |
trigger, |
| 1584 |
...custom |
| 1585 |
}; |
| 1586 |
return details; |
| 1587 |
} |
| 1588 |
|
| 1589 |
// node_modules/@base-ui/react/internals/useTransitionStatus.mjs |
| 1590 |
var React10 = __toESM(require_react(), 1); |
| 1591 |
|
| 1592 |
// node_modules/@base-ui/utils/useOnMount.mjs |
| 1593 |
var React9 = __toESM(require_react(), 1); |
| 1594 |
var EMPTY = []; |
| 1595 |
function useOnMount(fn) { |
| 1596 |
React9.useEffect(fn, EMPTY); |
| 1597 |
} |
| 1598 |
|
| 1599 |
// node_modules/@base-ui/utils/useAnimationFrame.mjs |
| 1600 |
var EMPTY2 = null; |
| 1601 |
var LAST_RAF = globalThis.requestAnimationFrame; |
| 1602 |
var Scheduler = class { |
| 1603 |
/* This implementation uses an array as a backing data-structure for frame callbacks. |
| 1604 |
* It allows `O(1)` callback cancelling by inserting a `null` in the array, though it |
| 1605 |
* never calls the native `cancelAnimationFrame` if there are no frames left. This can |
| 1606 |
* be much more efficient if there is a call pattern that alterns as |
| 1607 |
* "request-cancel-request-cancel-…". |
| 1608 |
* But in the case of "request-request-…-cancel-cancel-…", it leaves the final animation |
| 1609 |
* frame to run anyway. We turn that frame into a `O(1)` no-op via `callbacksCount`. */ |
| 1610 |
callbacks = []; |
| 1611 |
callbacksCount = 0; |
| 1612 |
nextId = 1; |
| 1613 |
startId = 1; |
| 1614 |
isScheduled = false; |
| 1615 |
tick = (timestamp) => { |
| 1616 |
this.isScheduled = false; |
| 1617 |
const currentCallbacks = this.callbacks; |
| 1618 |
const currentCallbacksCount = this.callbacksCount; |
| 1619 |
this.callbacks = []; |
| 1620 |
this.callbacksCount = 0; |
| 1621 |
this.startId = this.nextId; |
| 1622 |
if (currentCallbacksCount > 0) { |
| 1623 |
for (let i = 0; i < currentCallbacks.length; i += 1) { |
| 1624 |
currentCallbacks[i]?.(timestamp); |
| 1625 |
} |
| 1626 |
} |
| 1627 |
}; |
| 1628 |
request(fn) { |
| 1629 |
const id = this.nextId; |
| 1630 |
this.nextId += 1; |
| 1631 |
this.callbacks.push(fn); |
| 1632 |
this.callbacksCount += 1; |
| 1633 |
const didRAFChange = LAST_RAF !== requestAnimationFrame && (LAST_RAF = requestAnimationFrame, true); |
| 1634 |
if (!this.isScheduled || didRAFChange) { |
| 1635 |
requestAnimationFrame(this.tick); |
| 1636 |
this.isScheduled = true; |
| 1637 |
} |
| 1638 |
return id; |
| 1639 |
} |
| 1640 |
cancel(id) { |
| 1641 |
const index2 = id - this.startId; |
| 1642 |
if (index2 < 0 || index2 >= this.callbacks.length) { |
| 1643 |
return; |
| 1644 |
} |
| 1645 |
this.callbacks[index2] = null; |
| 1646 |
this.callbacksCount -= 1; |
| 1647 |
} |
| 1648 |
}; |
| 1649 |
var scheduler = new Scheduler(); |
| 1650 |
var AnimationFrame = class _AnimationFrame { |
| 1651 |
static create() { |
| 1652 |
return new _AnimationFrame(); |
| 1653 |
} |
| 1654 |
static request(fn) { |
| 1655 |
return scheduler.request(fn); |
| 1656 |
} |
| 1657 |
static cancel(id) { |
| 1658 |
return scheduler.cancel(id); |
| 1659 |
} |
| 1660 |
currentId = EMPTY2; |
| 1661 |
/** |
| 1662 |
* Executes `fn` after `delay`, clearing any previously scheduled call. |
| 1663 |
*/ |
| 1664 |
request(fn) { |
| 1665 |
this.cancel(); |
| 1666 |
this.currentId = scheduler.request(() => { |
| 1667 |
this.currentId = EMPTY2; |
| 1668 |
fn(); |
| 1669 |
}); |
| 1670 |
} |
| 1671 |
cancel = () => { |
| 1672 |
if (this.currentId !== EMPTY2) { |
| 1673 |
scheduler.cancel(this.currentId); |
| 1674 |
this.currentId = EMPTY2; |
| 1675 |
} |
| 1676 |
}; |
| 1677 |
disposeEffect = () => { |
| 1678 |
return this.cancel; |
| 1679 |
}; |
| 1680 |
}; |
| 1681 |
function useAnimationFrame() { |
| 1682 |
const timeout = useRefWithInit(AnimationFrame.create).current; |
| 1683 |
useOnMount(timeout.disposeEffect); |
| 1684 |
return timeout; |
| 1685 |
} |
| 1686 |
|
| 1687 |
// node_modules/@base-ui/react/internals/useTransitionStatus.mjs |
| 1688 |
function useTransitionStatus(open, enableIdleState = false, deferEndingState = false) { |
| 1689 |
const [transitionStatus, setTransitionStatus] = React10.useState(open && enableIdleState ? "idle" : void 0); |
| 1690 |
const [mounted, setMounted] = React10.useState(open); |
| 1691 |
if (open && !mounted) { |
| 1692 |
setMounted(true); |
| 1693 |
setTransitionStatus("starting"); |
| 1694 |
} |
| 1695 |
if (!open && mounted && transitionStatus !== "ending" && !deferEndingState) { |
| 1696 |
setTransitionStatus("ending"); |
| 1697 |
} |
| 1698 |
if (!open && !mounted && transitionStatus === "ending") { |
| 1699 |
setTransitionStatus(void 0); |
| 1700 |
} |
| 1701 |
useIsoLayoutEffect(() => { |
| 1702 |
if (!open && mounted && transitionStatus !== "ending" && deferEndingState) { |
| 1703 |
const frame = AnimationFrame.request(() => { |
| 1704 |
setTransitionStatus("ending"); |
| 1705 |
}); |
| 1706 |
return () => { |
| 1707 |
AnimationFrame.cancel(frame); |
| 1708 |
}; |
| 1709 |
} |
| 1710 |
return void 0; |
| 1711 |
}, [open, mounted, transitionStatus, deferEndingState]); |
| 1712 |
useIsoLayoutEffect(() => { |
| 1713 |
if (!open || enableIdleState) { |
| 1714 |
return void 0; |
| 1715 |
} |
| 1716 |
const frame = AnimationFrame.request(() => { |
| 1717 |
setTransitionStatus(void 0); |
| 1718 |
}); |
| 1719 |
return () => { |
| 1720 |
AnimationFrame.cancel(frame); |
| 1721 |
}; |
| 1722 |
}, [enableIdleState, open]); |
| 1723 |
useIsoLayoutEffect(() => { |
| 1724 |
if (!open || !enableIdleState) { |
| 1725 |
return void 0; |
| 1726 |
} |
| 1727 |
if (open && mounted && transitionStatus !== "idle") { |
| 1728 |
setTransitionStatus("starting"); |
| 1729 |
} |
| 1730 |
const frame = AnimationFrame.request(() => { |
| 1731 |
setTransitionStatus("idle"); |
| 1732 |
}); |
| 1733 |
return () => { |
| 1734 |
AnimationFrame.cancel(frame); |
| 1735 |
}; |
| 1736 |
}, [enableIdleState, open, mounted, transitionStatus]); |
| 1737 |
return { |
| 1738 |
mounted, |
| 1739 |
setMounted, |
| 1740 |
transitionStatus |
| 1741 |
}; |
| 1742 |
} |
| 1743 |
|
| 1744 |
// node_modules/@base-ui/react/internals/stateAttributesMapping.mjs |
| 1745 |
var TransitionStatusDataAttributes = /* @__PURE__ */ (function(TransitionStatusDataAttributes2) { |
| 1746 |
TransitionStatusDataAttributes2["startingStyle"] = "data-starting-style"; |
| 1747 |
TransitionStatusDataAttributes2["endingStyle"] = "data-ending-style"; |
| 1748 |
return TransitionStatusDataAttributes2; |
| 1749 |
})({}); |
| 1750 |
var STARTING_HOOK = { |
| 1751 |
[TransitionStatusDataAttributes.startingStyle]: "" |
| 1752 |
}; |
| 1753 |
var ENDING_HOOK = { |
| 1754 |
[TransitionStatusDataAttributes.endingStyle]: "" |
| 1755 |
}; |
| 1756 |
var transitionStatusMapping = { |
| 1757 |
transitionStatus(value) { |
| 1758 |
if (value === "starting") { |
| 1759 |
return STARTING_HOOK; |
| 1760 |
} |
| 1761 |
if (value === "ending") { |
| 1762 |
return ENDING_HOOK; |
| 1763 |
} |
| 1764 |
return null; |
| 1765 |
} |
| 1766 |
}; |
| 1767 |
|
| 1768 |
// node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs |
| 1769 |
function hasWindow() { |
| 1770 |
return typeof window !== "undefined"; |
| 1771 |
} |
| 1772 |
function getNodeName(node) { |
| 1773 |
if (isNode(node)) { |
| 1774 |
return (node.nodeName || "").toLowerCase(); |
| 1775 |
} |
| 1776 |
return "#document"; |
| 1777 |
} |
| 1778 |
function getWindow(node) { |
| 1779 |
var _node$ownerDocument; |
| 1780 |
return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window; |
| 1781 |
} |
| 1782 |
function getDocumentElement(node) { |
| 1783 |
var _ref; |
| 1784 |
return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement; |
| 1785 |
} |
| 1786 |
function isNode(value) { |
| 1787 |
if (!hasWindow()) { |
| 1788 |
return false; |
| 1789 |
} |
| 1790 |
return value instanceof Node || value instanceof getWindow(value).Node; |
| 1791 |
} |
| 1792 |
function isElement(value) { |
| 1793 |
if (!hasWindow()) { |
| 1794 |
return false; |
| 1795 |
} |
| 1796 |
return value instanceof Element || value instanceof getWindow(value).Element; |
| 1797 |
} |
| 1798 |
function isHTMLElement(value) { |
| 1799 |
if (!hasWindow()) { |
| 1800 |
return false; |
| 1801 |
} |
| 1802 |
return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement; |
| 1803 |
} |
| 1804 |
function isShadowRoot(value) { |
| 1805 |
if (!hasWindow() || typeof ShadowRoot === "undefined") { |
| 1806 |
return false; |
| 1807 |
} |
| 1808 |
return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot; |
| 1809 |
} |
| 1810 |
function isOverflowElement(element) { |
| 1811 |
const { |
| 1812 |
overflow, |
| 1813 |
overflowX, |
| 1814 |
overflowY, |
| 1815 |
display |
| 1816 |
} = getComputedStyle2(element); |
| 1817 |
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== "inline" && display !== "contents"; |
| 1818 |
} |
| 1819 |
function isTableElement(element) { |
| 1820 |
return /^(table|td|th)$/.test(getNodeName(element)); |
| 1821 |
} |
| 1822 |
function isTopLayer(element) { |
| 1823 |
try { |
| 1824 |
if (element.matches(":popover-open")) { |
| 1825 |
return true; |
| 1826 |
} |
| 1827 |
} catch (_e) { |
| 1828 |
} |
| 1829 |
try { |
| 1830 |
return element.matches(":modal"); |
| 1831 |
} catch (_e) { |
| 1832 |
return false; |
| 1833 |
} |
| 1834 |
} |
| 1835 |
var willChangeRe = /transform|translate|scale|rotate|perspective|filter/; |
| 1836 |
var containRe = /paint|layout|strict|content/; |
| 1837 |
var isNotNone = (value) => !!value && value !== "none"; |
| 1838 |
var isWebKitValue; |
| 1839 |
function isContainingBlock(elementOrCss) { |
| 1840 |
const css = isElement(elementOrCss) ? getComputedStyle2(elementOrCss) : elementOrCss; |
| 1841 |
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 || ""); |
| 1842 |
} |
| 1843 |
function getContainingBlock(element) { |
| 1844 |
let currentNode = getParentNode(element); |
| 1845 |
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) { |
| 1846 |
if (isContainingBlock(currentNode)) { |
| 1847 |
return currentNode; |
| 1848 |
} else if (isTopLayer(currentNode)) { |
| 1849 |
return null; |
| 1850 |
} |
| 1851 |
currentNode = getParentNode(currentNode); |
| 1852 |
} |
| 1853 |
return null; |
| 1854 |
} |
| 1855 |
function isWebKit() { |
| 1856 |
if (isWebKitValue == null) { |
| 1857 |
isWebKitValue = typeof CSS !== "undefined" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none"); |
| 1858 |
} |
| 1859 |
return isWebKitValue; |
| 1860 |
} |
| 1861 |
function isLastTraversableNode(node) { |
| 1862 |
return /^(html|body|#document)$/.test(getNodeName(node)); |
| 1863 |
} |
| 1864 |
function getComputedStyle2(element) { |
| 1865 |
return getWindow(element).getComputedStyle(element); |
| 1866 |
} |
| 1867 |
function getNodeScroll(element) { |
| 1868 |
if (isElement(element)) { |
| 1869 |
return { |
| 1870 |
scrollLeft: element.scrollLeft, |
| 1871 |
scrollTop: element.scrollTop |
| 1872 |
}; |
| 1873 |
} |
| 1874 |
return { |
| 1875 |
scrollLeft: element.scrollX, |
| 1876 |
scrollTop: element.scrollY |
| 1877 |
}; |
| 1878 |
} |
| 1879 |
function getParentNode(node) { |
| 1880 |
if (getNodeName(node) === "html") { |
| 1881 |
return node; |
| 1882 |
} |
| 1883 |
const result = ( |
| 1884 |
// Step into the shadow DOM of the parent of a slotted node. |
| 1885 |
node.assignedSlot || // DOM Element detected. |
| 1886 |
node.parentNode || // ShadowRoot detected. |
| 1887 |
isShadowRoot(node) && node.host || // Fallback. |
| 1888 |
getDocumentElement(node) |
| 1889 |
); |
| 1890 |
return isShadowRoot(result) ? result.host : result; |
| 1891 |
} |
| 1892 |
function getNearestOverflowAncestor(node) { |
| 1893 |
const parentNode = getParentNode(node); |
| 1894 |
if (isLastTraversableNode(parentNode)) { |
| 1895 |
return node.ownerDocument ? node.ownerDocument.body : node.body; |
| 1896 |
} |
| 1897 |
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) { |
| 1898 |
return parentNode; |
| 1899 |
} |
| 1900 |
return getNearestOverflowAncestor(parentNode); |
| 1901 |
} |
| 1902 |
function getOverflowAncestors(node, list, traverseIframes) { |
| 1903 |
var _node$ownerDocument2; |
| 1904 |
if (list === void 0) { |
| 1905 |
list = []; |
| 1906 |
} |
| 1907 |
if (traverseIframes === void 0) { |
| 1908 |
traverseIframes = true; |
| 1909 |
} |
| 1910 |
const scrollableAncestor = getNearestOverflowAncestor(node); |
| 1911 |
const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body); |
| 1912 |
const win = getWindow(scrollableAncestor); |
| 1913 |
if (isBody) { |
| 1914 |
const frameElement = getFrameElement(win); |
| 1915 |
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []); |
| 1916 |
} else { |
| 1917 |
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes)); |
| 1918 |
} |
| 1919 |
} |
| 1920 |
function getFrameElement(win) { |
| 1921 |
return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null; |
| 1922 |
} |
| 1923 |
|
| 1924 |
// node_modules/@base-ui/utils/addEventListener.mjs |
| 1925 |
function addEventListener(target, type, listener, options) { |
| 1926 |
target.addEventListener(type, listener, options); |
| 1927 |
return () => { |
| 1928 |
target.removeEventListener(type, listener, options); |
| 1929 |
}; |
| 1930 |
} |
| 1931 |
|
| 1932 |
// node_modules/@base-ui/utils/useValueAsRef.mjs |
| 1933 |
function useValueAsRef(value) { |
| 1934 |
const latest = useRefWithInit(createLatestRef, value).current; |
| 1935 |
latest.next = value; |
| 1936 |
useIsoLayoutEffect(latest.effect); |
| 1937 |
return latest; |
| 1938 |
} |
| 1939 |
function createLatestRef(value) { |
| 1940 |
const latest = { |
| 1941 |
current: value, |
| 1942 |
next: value, |
| 1943 |
effect: () => { |
| 1944 |
latest.current = latest.next; |
| 1945 |
} |
| 1946 |
}; |
| 1947 |
return latest; |
| 1948 |
} |
| 1949 |
|
| 1950 |
// node_modules/@base-ui/utils/owner.mjs |
| 1951 |
function ownerDocument(node) { |
| 1952 |
return node?.ownerDocument || document; |
| 1953 |
} |
| 1954 |
|
| 1955 |
// node_modules/@base-ui/react/internals/useOpenChangeComplete.mjs |
| 1956 |
var React11 = __toESM(require_react(), 1); |
| 1957 |
|
| 1958 |
// node_modules/@base-ui/react/internals/useAnimationsFinished.mjs |
| 1959 |
var ReactDOM = __toESM(require_react_dom(), 1); |
| 1960 |
|
| 1961 |
// node_modules/@base-ui/react/utils/resolveRef.mjs |
| 1962 |
function resolveRef(maybeRef) { |
| 1963 |
if (maybeRef == null) { |
| 1964 |
return maybeRef; |
| 1965 |
} |
| 1966 |
return "current" in maybeRef ? maybeRef.current : maybeRef; |
| 1967 |
} |
| 1968 |
|
| 1969 |
// node_modules/@base-ui/react/internals/useAnimationsFinished.mjs |
| 1970 |
function useAnimationsFinished(elementOrRef, waitForStartingStyleRemoved = false, treatAbortedAsFinished = true) { |
| 1971 |
const frame = useAnimationFrame(); |
| 1972 |
return useStableCallback((fnToExecute, signal = null) => { |
| 1973 |
frame.cancel(); |
| 1974 |
const element = resolveRef(elementOrRef); |
| 1975 |
if (element == null) { |
| 1976 |
return; |
| 1977 |
} |
| 1978 |
const resolvedElement = element; |
| 1979 |
const done = () => { |
| 1980 |
ReactDOM.flushSync(fnToExecute); |
| 1981 |
}; |
| 1982 |
if (typeof resolvedElement.getAnimations !== "function" || globalThis.BASE_UI_ANIMATIONS_DISABLED) { |
| 1983 |
fnToExecute(); |
| 1984 |
return; |
| 1985 |
} |
| 1986 |
function exec() { |
| 1987 |
Promise.all(resolvedElement.getAnimations().map((animation) => animation.finished)).then(() => { |
| 1988 |
if (!signal?.aborted) { |
| 1989 |
done(); |
| 1990 |
} |
| 1991 |
}).catch(() => { |
| 1992 |
if (treatAbortedAsFinished) { |
| 1993 |
if (!signal?.aborted) { |
| 1994 |
done(); |
| 1995 |
} |
| 1996 |
return; |
| 1997 |
} |
| 1998 |
const currentAnimations = resolvedElement.getAnimations(); |
| 1999 |
if (!signal?.aborted && currentAnimations.length > 0 && currentAnimations.some((animation) => animation.pending || animation.playState !== "finished")) { |
| 2000 |
exec(); |
| 2001 |
} |
| 2002 |
}); |
| 2003 |
} |
| 2004 |
if (waitForStartingStyleRemoved) { |
| 2005 |
const startingStyleAttribute = TransitionStatusDataAttributes.startingStyle; |
| 2006 |
if (!resolvedElement.hasAttribute(startingStyleAttribute)) { |
| 2007 |
frame.request(exec); |
| 2008 |
return; |
| 2009 |
} |
| 2010 |
const attributeObserver = new MutationObserver(() => { |
| 2011 |
if (!resolvedElement.hasAttribute(startingStyleAttribute)) { |
| 2012 |
attributeObserver.disconnect(); |
| 2013 |
exec(); |
| 2014 |
} |
| 2015 |
}); |
| 2016 |
attributeObserver.observe(resolvedElement, { |
| 2017 |
attributes: true, |
| 2018 |
attributeFilter: [startingStyleAttribute] |
| 2019 |
}); |
| 2020 |
signal?.addEventListener("abort", () => attributeObserver.disconnect(), { |
| 2021 |
once: true |
| 2022 |
}); |
| 2023 |
return; |
| 2024 |
} |
| 2025 |
frame.request(exec); |
| 2026 |
}); |
| 2027 |
} |
| 2028 |
|
| 2029 |
// node_modules/@base-ui/react/internals/useOpenChangeComplete.mjs |
| 2030 |
function useOpenChangeComplete(parameters) { |
| 2031 |
const { |
| 2032 |
enabled = true, |
| 2033 |
open, |
| 2034 |
ref, |
| 2035 |
onComplete: onCompleteParam |
| 2036 |
} = parameters; |
| 2037 |
const onComplete = useStableCallback(onCompleteParam); |
| 2038 |
const runOnceAnimationsFinish = useAnimationsFinished(ref, open, false); |
| 2039 |
React11.useEffect(() => { |
| 2040 |
if (!enabled) { |
| 2041 |
return void 0; |
| 2042 |
} |
| 2043 |
const abortController = new AbortController(); |
| 2044 |
runOnceAnimationsFinish(onComplete, abortController.signal); |
| 2045 |
return () => { |
| 2046 |
abortController.abort(); |
| 2047 |
}; |
| 2048 |
}, [enabled, open, onComplete, runOnceAnimationsFinish]); |
| 2049 |
} |
| 2050 |
|
| 2051 |
// node_modules/@base-ui/utils/useOnFirstRender.mjs |
| 2052 |
var React12 = __toESM(require_react(), 1); |
| 2053 |
function useOnFirstRender(fn) { |
| 2054 |
const ref = React12.useRef(true); |
| 2055 |
if (ref.current) { |
| 2056 |
ref.current = false; |
| 2057 |
fn(); |
| 2058 |
} |
| 2059 |
} |
| 2060 |
|
| 2061 |
// node_modules/@base-ui/utils/platform/parts.mjs |
| 2062 |
var parts_exports = {}; |
| 2063 |
__export(parts_exports, { |
| 2064 |
engine: () => engine_exports, |
| 2065 |
env: () => env_exports, |
| 2066 |
os: () => os_exports, |
| 2067 |
screenReader: () => screen_reader_exports |
| 2068 |
}); |
| 2069 |
|
| 2070 |
// node_modules/@base-ui/utils/platform/os.mjs |
| 2071 |
var os_exports = {}; |
| 2072 |
__export(os_exports, { |
| 2073 |
android: () => android, |
| 2074 |
apple: () => apple, |
| 2075 |
ios: () => ios, |
| 2076 |
linux: () => linux, |
| 2077 |
mac: () => mac, |
| 2078 |
windows: () => windows |
| 2079 |
}); |
| 2080 |
|
| 2081 |
// node_modules/@base-ui/utils/platform/shared.mjs |
| 2082 |
function readRawData() { |
| 2083 |
if (typeof navigator === "undefined") { |
| 2084 |
return { |
| 2085 |
userAgent: "", |
| 2086 |
platform: "", |
| 2087 |
maxTouchPoints: 0 |
| 2088 |
}; |
| 2089 |
} |
| 2090 |
if (true) { |
| 2091 |
const uaData = navigator.userAgentData; |
| 2092 |
if (uaData && Array.isArray(uaData.brands)) { |
| 2093 |
return { |
| 2094 |
userAgent: uaData.brands.map(({ |
| 2095 |
brand, |
| 2096 |
version: version2 |
| 2097 |
}) => `${brand}/${version2}`).join(" "), |
| 2098 |
platform: uaData.platform ?? navigator.platform ?? "", |
| 2099 |
maxTouchPoints: navigator.maxTouchPoints ?? 0 |
| 2100 |
}; |
| 2101 |
} |
| 2102 |
} |
| 2103 |
return { |
| 2104 |
userAgent: navigator.userAgent, |
| 2105 |
platform: navigator.platform ?? "", |
| 2106 |
maxTouchPoints: navigator.maxTouchPoints ?? 0 |
| 2107 |
}; |
| 2108 |
} |
| 2109 |
var { |
| 2110 |
userAgent, |
| 2111 |
platform, |
| 2112 |
maxTouchPoints |
| 2113 |
} = readRawData(); |
| 2114 |
var lowerUserAgent = userAgent.toLowerCase(); |
| 2115 |
var lowerPlatform = platform.toLowerCase(); |
| 2116 |
|
| 2117 |
// node_modules/@base-ui/utils/platform/os.mjs |
| 2118 |
var ios = /^i(os$|p)/.test(lowerPlatform) || lowerPlatform === "macintel" && maxTouchPoints > 1; |
| 2119 |
var ANDROID_STRING = "android"; |
| 2120 |
var android = lowerPlatform === ANDROID_STRING || lowerUserAgent.includes(ANDROID_STRING); |
| 2121 |
var mac = !ios && lowerPlatform.startsWith("mac"); |
| 2122 |
var windows = lowerPlatform.startsWith("win"); |
| 2123 |
var linux = !android && /^(linux|chrome os)/.test(lowerPlatform); |
| 2124 |
var apple = mac || ios; |
| 2125 |
|
| 2126 |
// node_modules/@base-ui/utils/platform/engine.mjs |
| 2127 |
var engine_exports = {}; |
| 2128 |
__export(engine_exports, { |
| 2129 |
blink: () => blink, |
| 2130 |
gecko: () => gecko, |
| 2131 |
webkit: () => webkit |
| 2132 |
}); |
| 2133 |
var webkit = typeof CSS !== "undefined" && !!CSS.supports?.("-webkit-backdrop-filter:none"); |
| 2134 |
var gecko = !webkit && lowerUserAgent.includes("firefox"); |
| 2135 |
var blink = !webkit && lowerUserAgent.includes("chrom"); |
| 2136 |
|
| 2137 |
// node_modules/@base-ui/utils/platform/screen-reader.mjs |
| 2138 |
var screen_reader_exports = {}; |
| 2139 |
__export(screen_reader_exports, { |
| 2140 |
voiceOver: () => voiceOver |
| 2141 |
}); |
| 2142 |
var voiceOver = apple; |
| 2143 |
|
| 2144 |
// node_modules/@base-ui/utils/platform/env.mjs |
| 2145 |
var env_exports = {}; |
| 2146 |
__export(env_exports, { |
| 2147 |
jsdom: () => jsdom |
| 2148 |
}); |
| 2149 |
var jsdom = /jsdom|happydom/.test(lowerUserAgent); |
| 2150 |
|
| 2151 |
// node_modules/@base-ui/utils/useTimeout.mjs |
| 2152 |
var EMPTY3 = 0; |
| 2153 |
var Timeout = class _Timeout { |
| 2154 |
static create() { |
| 2155 |
return new _Timeout(); |
| 2156 |
} |
| 2157 |
currentId = EMPTY3; |
| 2158 |
/** |
| 2159 |
* Executes `fn` after `delay`, clearing any previously scheduled call. |
| 2160 |
*/ |
| 2161 |
start(delay, fn) { |
| 2162 |
this.clear(); |
| 2163 |
this.currentId = setTimeout(() => { |
| 2164 |
this.currentId = EMPTY3; |
| 2165 |
fn(); |
| 2166 |
}, delay); |
| 2167 |
} |
| 2168 |
isStarted() { |
| 2169 |
return this.currentId !== EMPTY3; |
| 2170 |
} |
| 2171 |
clear = () => { |
| 2172 |
if (this.currentId !== EMPTY3) { |
| 2173 |
clearTimeout(this.currentId); |
| 2174 |
this.currentId = EMPTY3; |
| 2175 |
} |
| 2176 |
}; |
| 2177 |
disposeEffect = () => { |
| 2178 |
return this.clear; |
| 2179 |
}; |
| 2180 |
}; |
| 2181 |
function useTimeout() { |
| 2182 |
const timeout = useRefWithInit(Timeout.create).current; |
| 2183 |
useOnMount(timeout.disposeEffect); |
| 2184 |
return timeout; |
| 2185 |
} |
| 2186 |
|
| 2187 |
// node_modules/@base-ui/react/floating-ui-react/components/FloatingDelayGroup.mjs |
| 2188 |
var React13 = __toESM(require_react(), 1); |
| 2189 |
|
| 2190 |
// node_modules/@base-ui/react/floating-ui-react/utils/event.mjs |
| 2191 |
function isReactEvent(event) { |
| 2192 |
return "nativeEvent" in event; |
| 2193 |
} |
| 2194 |
function isMouseLikePointerType(pointerType, strict) { |
| 2195 |
const values = ["mouse", "pen"]; |
| 2196 |
if (!strict) { |
| 2197 |
values.push("", void 0); |
| 2198 |
} |
| 2199 |
return values.includes(pointerType); |
| 2200 |
} |
| 2201 |
function isClickLikeEvent(event) { |
| 2202 |
const type = event.type; |
| 2203 |
return type === "click" || type === "mousedown" || type === "keydown" || type === "keyup"; |
| 2204 |
} |
| 2205 |
|
| 2206 |
// node_modules/@base-ui/react/floating-ui-react/utils/constants.mjs |
| 2207 |
var FOCUSABLE_ATTRIBUTE = "data-base-ui-focusable"; |
| 2208 |
var TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])"; |
| 2209 |
|
| 2210 |
// node_modules/@base-ui/react/internals/shadowDom.mjs |
| 2211 |
function activeElement(doc) { |
| 2212 |
let element = doc.activeElement; |
| 2213 |
while (element?.shadowRoot?.activeElement != null) { |
| 2214 |
element = element.shadowRoot.activeElement; |
| 2215 |
} |
| 2216 |
return element; |
| 2217 |
} |
| 2218 |
function contains(parent, child) { |
| 2219 |
if (!parent || !child) { |
| 2220 |
return false; |
| 2221 |
} |
| 2222 |
const rootNode = child.getRootNode?.(); |
| 2223 |
if (parent.contains(child)) { |
| 2224 |
return true; |
| 2225 |
} |
| 2226 |
if (rootNode && isShadowRoot(rootNode)) { |
| 2227 |
let next = child; |
| 2228 |
while (next) { |
| 2229 |
if (parent === next) { |
| 2230 |
return true; |
| 2231 |
} |
| 2232 |
next = next.parentNode || next.host; |
| 2233 |
} |
| 2234 |
} |
| 2235 |
return false; |
| 2236 |
} |
| 2237 |
function getTarget(event) { |
| 2238 |
if ("composedPath" in event) { |
| 2239 |
return event.composedPath()[0]; |
| 2240 |
} |
| 2241 |
return event.target; |
| 2242 |
} |
| 2243 |
|
| 2244 |
// node_modules/@base-ui/react/floating-ui-react/utils/element.mjs |
| 2245 |
function isTargetInsideEnabledTrigger(target, triggerElements) { |
| 2246 |
if (!isElement(target)) { |
| 2247 |
return false; |
| 2248 |
} |
| 2249 |
const targetElement = target; |
| 2250 |
if (triggerElements.hasElement(targetElement)) { |
| 2251 |
return !targetElement.hasAttribute("data-trigger-disabled"); |
| 2252 |
} |
| 2253 |
for (const [, trigger] of triggerElements.entries()) { |
| 2254 |
if (contains(trigger, targetElement)) { |
| 2255 |
return !trigger.hasAttribute("data-trigger-disabled"); |
| 2256 |
} |
| 2257 |
} |
| 2258 |
return false; |
| 2259 |
} |
| 2260 |
function isEventTargetWithin(event, node) { |
| 2261 |
if (node == null) { |
| 2262 |
return false; |
| 2263 |
} |
| 2264 |
if ("composedPath" in event) { |
| 2265 |
return event.composedPath().includes(node); |
| 2266 |
} |
| 2267 |
const eventAgain = event; |
| 2268 |
return eventAgain.target != null && node.contains(eventAgain.target); |
| 2269 |
} |
| 2270 |
function isRootElement(element) { |
| 2271 |
return element.matches("html,body"); |
| 2272 |
} |
| 2273 |
function isTypeableElement(element) { |
| 2274 |
return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR); |
| 2275 |
} |
| 2276 |
function isInteractiveElement(element) { |
| 2277 |
return element?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${TYPEABLE_SELECTOR}`) != null; |
| 2278 |
} |
| 2279 |
function matchesFocusVisible(element) { |
| 2280 |
if (!element || parts_exports.env.jsdom) { |
| 2281 |
return true; |
| 2282 |
} |
| 2283 |
try { |
| 2284 |
return element.matches(":focus-visible"); |
| 2285 |
} catch (_e) { |
| 2286 |
return true; |
| 2287 |
} |
| 2288 |
} |
| 2289 |
|
| 2290 |
// node_modules/@base-ui/react/floating-ui-react/hooks/useHoverShared.mjs |
| 2291 |
function resolveValue(value, pointerType) { |
| 2292 |
if (pointerType != null && !isMouseLikePointerType(pointerType)) { |
| 2293 |
return 0; |
| 2294 |
} |
| 2295 |
if (typeof value === "function") { |
| 2296 |
return value(); |
| 2297 |
} |
| 2298 |
return value; |
| 2299 |
} |
| 2300 |
function getDelay(value, prop, pointerType) { |
| 2301 |
const result = resolveValue(value, pointerType); |
| 2302 |
if (typeof result === "number") { |
| 2303 |
return result; |
| 2304 |
} |
| 2305 |
return result?.[prop]; |
| 2306 |
} |
| 2307 |
function getRestMs(value) { |
| 2308 |
if (typeof value === "function") { |
| 2309 |
return value(); |
| 2310 |
} |
| 2311 |
return value; |
| 2312 |
} |
| 2313 |
function isClickLikeOpenEvent(openEventType, interactedInside) { |
| 2314 |
return interactedInside || openEventType === "click" || openEventType === "mousedown"; |
| 2315 |
} |
| 2316 |
function isHoverOpenEvent(openEventType) { |
| 2317 |
return openEventType?.includes("mouse") && openEventType !== "mousedown"; |
| 2318 |
} |
| 2319 |
|
| 2320 |
// node_modules/@base-ui/react/floating-ui-react/components/FloatingDelayGroup.mjs |
| 2321 |
var import_jsx_runtime = __toESM(require_jsx_runtime(), 1); |
| 2322 |
var FloatingDelayGroupContext = /* @__PURE__ */ React13.createContext({ |
| 2323 |
hasProvider: false, |
| 2324 |
timeoutMs: 0, |
| 2325 |
delayRef: { |
| 2326 |
current: 0 |
| 2327 |
}, |
| 2328 |
initialDelayRef: { |
| 2329 |
current: 0 |
| 2330 |
}, |
| 2331 |
timeout: new Timeout(), |
| 2332 |
currentIdRef: { |
| 2333 |
current: null |
| 2334 |
}, |
| 2335 |
currentContextRef: { |
| 2336 |
current: null |
| 2337 |
} |
| 2338 |
}); |
| 2339 |
if (true) FloatingDelayGroupContext.displayName = "FloatingDelayGroupContext"; |
| 2340 |
function resetDelayRef(delayRef, initialDelayRef) { |
| 2341 |
delayRef.current = initialDelayRef.current; |
| 2342 |
} |
| 2343 |
function FloatingDelayGroup(props) { |
| 2344 |
const { |
| 2345 |
children, |
| 2346 |
delay, |
| 2347 |
timeoutMs = 0 |
| 2348 |
} = props; |
| 2349 |
const delayRef = React13.useRef(delay); |
| 2350 |
const initialDelayRef = React13.useRef(delay); |
| 2351 |
const currentIdRef = React13.useRef(null); |
| 2352 |
const currentContextRef = React13.useRef(null); |
| 2353 |
const timeout = useTimeout(); |
| 2354 |
useIsoLayoutEffect(() => { |
| 2355 |
initialDelayRef.current = delay; |
| 2356 |
if (!currentIdRef.current) { |
| 2357 |
delayRef.current = delay; |
| 2358 |
return; |
| 2359 |
} |
| 2360 |
delayRef.current = { |
| 2361 |
open: getDelay(delayRef.current, "open"), |
| 2362 |
close: getDelay(delay, "close") |
| 2363 |
}; |
| 2364 |
}, [delay, currentIdRef, delayRef, initialDelayRef]); |
| 2365 |
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FloatingDelayGroupContext.Provider, { |
| 2366 |
value: React13.useMemo(() => ({ |
| 2367 |
hasProvider: true, |
| 2368 |
delayRef, |
| 2369 |
initialDelayRef, |
| 2370 |
currentIdRef, |
| 2371 |
timeoutMs, |
| 2372 |
currentContextRef, |
| 2373 |
timeout |
| 2374 |
}), [timeoutMs, timeout]), |
| 2375 |
children |
| 2376 |
}); |
| 2377 |
} |
| 2378 |
function useDelayGroup(context, options = { |
| 2379 |
open: false |
| 2380 |
}) { |
| 2381 |
const { |
| 2382 |
open |
| 2383 |
} = options; |
| 2384 |
const store2 = "rootStore" in context ? context.rootStore : context; |
| 2385 |
const floatingId = store2.useState("floatingId"); |
| 2386 |
const groupContext = React13.useContext(FloatingDelayGroupContext); |
| 2387 |
const { |
| 2388 |
currentIdRef, |
| 2389 |
delayRef, |
| 2390 |
timeoutMs, |
| 2391 |
initialDelayRef, |
| 2392 |
currentContextRef, |
| 2393 |
hasProvider, |
| 2394 |
timeout |
| 2395 |
} = groupContext; |
| 2396 |
const [isInstantPhase, setIsInstantPhase] = React13.useState(false); |
| 2397 |
const openRef = React13.useRef(open); |
| 2398 |
const isUnmountedRef = React13.useRef(false); |
| 2399 |
useIsoLayoutEffect(() => { |
| 2400 |
openRef.current = open; |
| 2401 |
}, [open]); |
| 2402 |
useIsoLayoutEffect(() => { |
| 2403 |
return () => { |
| 2404 |
isUnmountedRef.current = true; |
| 2405 |
}; |
| 2406 |
}, []); |
| 2407 |
useIsoLayoutEffect(() => { |
| 2408 |
function unset() { |
| 2409 |
if (!isUnmountedRef.current) { |
| 2410 |
setIsInstantPhase(false); |
| 2411 |
} |
| 2412 |
currentContextRef.current?.setIsInstantPhase(false); |
| 2413 |
currentIdRef.current = null; |
| 2414 |
currentContextRef.current = null; |
| 2415 |
delayRef.current = initialDelayRef.current; |
| 2416 |
timeout.clear(); |
| 2417 |
} |
| 2418 |
if (!currentIdRef.current) { |
| 2419 |
return void 0; |
| 2420 |
} |
| 2421 |
if (!open && currentIdRef.current === floatingId) { |
| 2422 |
setIsInstantPhase(false); |
| 2423 |
if (timeoutMs) { |
| 2424 |
const closingId = floatingId; |
| 2425 |
timeout.start(timeoutMs, () => { |
| 2426 |
if (store2.select("open") || currentIdRef.current && currentIdRef.current !== closingId) { |
| 2427 |
return; |
| 2428 |
} |
| 2429 |
unset(); |
| 2430 |
}); |
| 2431 |
return () => { |
| 2432 |
if (openRef.current || currentIdRef.current !== closingId) { |
| 2433 |
timeout.clear(); |
| 2434 |
} |
| 2435 |
}; |
| 2436 |
} |
| 2437 |
unset(); |
| 2438 |
} |
| 2439 |
return void 0; |
| 2440 |
}, [open, floatingId, currentIdRef, delayRef, timeoutMs, initialDelayRef, currentContextRef, timeout, store2]); |
| 2441 |
useIsoLayoutEffect(() => { |
| 2442 |
if (!open) { |
| 2443 |
return; |
| 2444 |
} |
| 2445 |
const prevContext = currentContextRef.current; |
| 2446 |
const prevId = currentIdRef.current; |
| 2447 |
timeout.clear(); |
| 2448 |
currentContextRef.current = { |
| 2449 |
onOpenChange: store2.setOpen, |
| 2450 |
setIsInstantPhase |
| 2451 |
}; |
| 2452 |
currentIdRef.current = floatingId; |
| 2453 |
delayRef.current = { |
| 2454 |
open: 0, |
| 2455 |
close: getDelay(initialDelayRef.current, "close") |
| 2456 |
}; |
| 2457 |
if (prevId !== null && prevId !== floatingId) { |
| 2458 |
setIsInstantPhase(true); |
| 2459 |
prevContext?.setIsInstantPhase(true); |
| 2460 |
prevContext?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.none)); |
| 2461 |
} else { |
| 2462 |
setIsInstantPhase(false); |
| 2463 |
prevContext?.setIsInstantPhase(false); |
| 2464 |
} |
| 2465 |
}, [open, floatingId, store2, currentIdRef, delayRef, initialDelayRef, currentContextRef, timeout]); |
| 2466 |
useIsoLayoutEffect(() => { |
| 2467 |
return () => { |
| 2468 |
if (currentIdRef.current === floatingId) { |
| 2469 |
currentContextRef.current = null; |
| 2470 |
if (!openRef.current) { |
| 2471 |
return; |
| 2472 |
} |
| 2473 |
currentIdRef.current = null; |
| 2474 |
resetDelayRef(delayRef, initialDelayRef); |
| 2475 |
timeout.clear(); |
| 2476 |
} |
| 2477 |
}; |
| 2478 |
}, [currentContextRef, currentIdRef, delayRef, floatingId, initialDelayRef, timeout]); |
| 2479 |
return React13.useMemo(() => ({ |
| 2480 |
hasProvider, |
| 2481 |
delayRef, |
| 2482 |
isInstantPhase |
| 2483 |
}), [hasProvider, delayRef, isInstantPhase]); |
| 2484 |
} |
| 2485 |
|
| 2486 |
// node_modules/@base-ui/utils/mergeCleanups.mjs |
| 2487 |
function mergeCleanups(...cleanups) { |
| 2488 |
return () => { |
| 2489 |
for (let i = 0; i < cleanups.length; i += 1) { |
| 2490 |
const cleanup = cleanups[i]; |
| 2491 |
if (cleanup) { |
| 2492 |
cleanup(); |
| 2493 |
} |
| 2494 |
} |
| 2495 |
}; |
| 2496 |
} |
| 2497 |
|
| 2498 |
// node_modules/@base-ui/react/utils/FocusGuard.mjs |
| 2499 |
var React14 = __toESM(require_react(), 1); |
| 2500 |
|
| 2501 |
// node_modules/@base-ui/utils/visuallyHidden.mjs |
| 2502 |
var visuallyHiddenBase = { |
| 2503 |
clipPath: "inset(50%)", |
| 2504 |
overflow: "hidden", |
| 2505 |
whiteSpace: "nowrap", |
| 2506 |
border: 0, |
| 2507 |
padding: 0, |
| 2508 |
width: 1, |
| 2509 |
height: 1, |
| 2510 |
margin: -1 |
| 2511 |
}; |
| 2512 |
var visuallyHidden = { |
| 2513 |
...visuallyHiddenBase, |
| 2514 |
position: "fixed", |
| 2515 |
top: 0, |
| 2516 |
left: 0 |
| 2517 |
}; |
| 2518 |
var visuallyHiddenInput = { |
| 2519 |
...visuallyHiddenBase, |
| 2520 |
position: "absolute" |
| 2521 |
}; |
| 2522 |
|
| 2523 |
// node_modules/@base-ui/react/utils/FocusGuard.mjs |
| 2524 |
var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1); |
| 2525 |
var FocusGuard = /* @__PURE__ */ React14.forwardRef(function FocusGuard2(props, ref) { |
| 2526 |
const [role, setRole] = React14.useState(); |
| 2527 |
useIsoLayoutEffect(() => { |
| 2528 |
if (parts_exports.screenReader.voiceOver && parts_exports.engine.webkit) { |
| 2529 |
setRole("button"); |
| 2530 |
} |
| 2531 |
}, []); |
| 2532 |
const restProps = { |
| 2533 |
tabIndex: 0, |
| 2534 |
// Role is only for VoiceOver |
| 2535 |
role |
| 2536 |
}; |
| 2537 |
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { |
| 2538 |
...props, |
| 2539 |
ref, |
| 2540 |
style: visuallyHidden, |
| 2541 |
"aria-hidden": role ? void 0 : true, |
| 2542 |
...restProps, |
| 2543 |
"data-base-ui-focus-guard": "" |
| 2544 |
}); |
| 2545 |
}); |
| 2546 |
if (true) FocusGuard.displayName = "FocusGuard"; |
| 2547 |
|
| 2548 |
// node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs |
| 2549 |
var sides = ["top", "right", "bottom", "left"]; |
| 2550 |
var min = Math.min; |
| 2551 |
var max = Math.max; |
| 2552 |
var round = Math.round; |
| 2553 |
var floor = Math.floor; |
| 2554 |
var createCoords = (v) => ({ |
| 2555 |
x: v, |
| 2556 |
y: v |
| 2557 |
}); |
| 2558 |
var oppositeSideMap = { |
| 2559 |
left: "right", |
| 2560 |
right: "left", |
| 2561 |
bottom: "top", |
| 2562 |
top: "bottom" |
| 2563 |
}; |
| 2564 |
function clamp(start, value, end) { |
| 2565 |
return max(start, min(value, end)); |
| 2566 |
} |
| 2567 |
function evaluate(value, param) { |
| 2568 |
return typeof value === "function" ? value(param) : value; |
| 2569 |
} |
| 2570 |
function getSide(placement) { |
| 2571 |
return placement.split("-")[0]; |
| 2572 |
} |
| 2573 |
function getAlignment(placement) { |
| 2574 |
return placement.split("-")[1]; |
| 2575 |
} |
| 2576 |
function getOppositeAxis(axis) { |
| 2577 |
return axis === "x" ? "y" : "x"; |
| 2578 |
} |
| 2579 |
function getAxisLength(axis) { |
| 2580 |
return axis === "y" ? "height" : "width"; |
| 2581 |
} |
| 2582 |
function getSideAxis(placement) { |
| 2583 |
const firstChar = placement[0]; |
| 2584 |
return firstChar === "t" || firstChar === "b" ? "y" : "x"; |
| 2585 |
} |
| 2586 |
function getAlignmentAxis(placement) { |
| 2587 |
return getOppositeAxis(getSideAxis(placement)); |
| 2588 |
} |
| 2589 |
function getAlignmentSides(placement, rects, rtl) { |
| 2590 |
if (rtl === void 0) { |
| 2591 |
rtl = false; |
| 2592 |
} |
| 2593 |
const alignment = getAlignment(placement); |
| 2594 |
const alignmentAxis = getAlignmentAxis(placement); |
| 2595 |
const length = getAxisLength(alignmentAxis); |
| 2596 |
let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top"; |
| 2597 |
if (rects.reference[length] > rects.floating[length]) { |
| 2598 |
mainAlignmentSide = getOppositePlacement(mainAlignmentSide); |
| 2599 |
} |
| 2600 |
return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)]; |
| 2601 |
} |
| 2602 |
function getExpandedPlacements(placement) { |
| 2603 |
const oppositePlacement = getOppositePlacement(placement); |
| 2604 |
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)]; |
| 2605 |
} |
| 2606 |
function getOppositeAlignmentPlacement(placement) { |
| 2607 |
return placement.includes("start") ? placement.replace("start", "end") : placement.replace("end", "start"); |
| 2608 |
} |
| 2609 |
var lrPlacement = ["left", "right"]; |
| 2610 |
var rlPlacement = ["right", "left"]; |
| 2611 |
var tbPlacement = ["top", "bottom"]; |
| 2612 |
var btPlacement = ["bottom", "top"]; |
| 2613 |
function getSideList(side, isStart, rtl) { |
| 2614 |
switch (side) { |
| 2615 |
case "top": |
| 2616 |
case "bottom": |
| 2617 |
if (rtl) return isStart ? rlPlacement : lrPlacement; |
| 2618 |
return isStart ? lrPlacement : rlPlacement; |
| 2619 |
case "left": |
| 2620 |
case "right": |
| 2621 |
return isStart ? tbPlacement : btPlacement; |
| 2622 |
default: |
| 2623 |
return []; |
| 2624 |
} |
| 2625 |
} |
| 2626 |
function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) { |
| 2627 |
const alignment = getAlignment(placement); |
| 2628 |
let list = getSideList(getSide(placement), direction === "start", rtl); |
| 2629 |
if (alignment) { |
| 2630 |
list = list.map((side) => side + "-" + alignment); |
| 2631 |
if (flipAlignment) { |
| 2632 |
list = list.concat(list.map(getOppositeAlignmentPlacement)); |
| 2633 |
} |
| 2634 |
} |
| 2635 |
return list; |
| 2636 |
} |
| 2637 |
function getOppositePlacement(placement) { |
| 2638 |
const side = getSide(placement); |
| 2639 |
return oppositeSideMap[side] + placement.slice(side.length); |
| 2640 |
} |
| 2641 |
function expandPaddingObject(padding) { |
| 2642 |
return { |
| 2643 |
top: 0, |
| 2644 |
right: 0, |
| 2645 |
bottom: 0, |
| 2646 |
left: 0, |
| 2647 |
...padding |
| 2648 |
}; |
| 2649 |
} |
| 2650 |
function getPaddingObject(padding) { |
| 2651 |
return typeof padding !== "number" ? expandPaddingObject(padding) : { |
| 2652 |
top: padding, |
| 2653 |
right: padding, |
| 2654 |
bottom: padding, |
| 2655 |
left: padding |
| 2656 |
}; |
| 2657 |
} |
| 2658 |
function rectToClientRect(rect) { |
| 2659 |
const { |
| 2660 |
x, |
| 2661 |
y, |
| 2662 |
width, |
| 2663 |
height |
| 2664 |
} = rect; |
| 2665 |
return { |
| 2666 |
width, |
| 2667 |
height, |
| 2668 |
top: y, |
| 2669 |
left: x, |
| 2670 |
right: x + width, |
| 2671 |
bottom: y + height, |
| 2672 |
x, |
| 2673 |
y |
| 2674 |
}; |
| 2675 |
} |
| 2676 |
|
| 2677 |
// node_modules/@base-ui/react/floating-ui-react/utils/composite.mjs |
| 2678 |
function isHiddenByStyles(styles) { |
| 2679 |
return styles.visibility === "hidden" || styles.visibility === "collapse"; |
| 2680 |
} |
| 2681 |
function isElementVisible(element, styles = element ? getComputedStyle2(element) : null) { |
| 2682 |
if (!element || !element.isConnected || !styles || isHiddenByStyles(styles)) { |
| 2683 |
return false; |
| 2684 |
} |
| 2685 |
if (typeof element.checkVisibility === "function") { |
| 2686 |
return element.checkVisibility(); |
| 2687 |
} |
| 2688 |
return styles.display !== "none" && styles.display !== "contents"; |
| 2689 |
} |
| 2690 |
|
| 2691 |
// node_modules/@base-ui/react/floating-ui-react/utils/tabbable.mjs |
| 2692 |
var CANDIDATE_SELECTOR = 'a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]'; |
| 2693 |
function getParentElement(element) { |
| 2694 |
const assignedSlot = element.assignedSlot; |
| 2695 |
if (assignedSlot) { |
| 2696 |
return assignedSlot; |
| 2697 |
} |
| 2698 |
if (element.parentElement) { |
| 2699 |
return element.parentElement; |
| 2700 |
} |
| 2701 |
const rootNode = element.getRootNode(); |
| 2702 |
return isShadowRoot(rootNode) ? rootNode.host : null; |
| 2703 |
} |
| 2704 |
function getDetailsSummary(details) { |
| 2705 |
for (const child of Array.from(details.children)) { |
| 2706 |
if (getNodeName(child) === "summary") { |
| 2707 |
return child; |
| 2708 |
} |
| 2709 |
} |
| 2710 |
return null; |
| 2711 |
} |
| 2712 |
function isWithinOpenDetailsSummary(element, details) { |
| 2713 |
const summary = getDetailsSummary(details); |
| 2714 |
return !!summary && (element === summary || contains(summary, element)); |
| 2715 |
} |
| 2716 |
function isFocusableCandidate(element) { |
| 2717 |
const nodeName = element ? getNodeName(element) : ""; |
| 2718 |
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"); |
| 2719 |
} |
| 2720 |
function isFocusableElement(element) { |
| 2721 |
if (!isFocusableCandidate(element) || !element.isConnected || element.matches(":disabled")) { |
| 2722 |
return false; |
| 2723 |
} |
| 2724 |
for (let current = element; current; current = getParentElement(current)) { |
| 2725 |
const isAncestor = current !== element; |
| 2726 |
const isSlot = getNodeName(current) === "slot"; |
| 2727 |
if (current.hasAttribute("inert")) { |
| 2728 |
return false; |
| 2729 |
} |
| 2730 |
if (isAncestor && getNodeName(current) === "details" && !current.open && !isWithinOpenDetailsSummary(element, current) || current.hasAttribute("hidden") || !isSlot && !isVisibleInTabbableTree(current, isAncestor)) { |
| 2731 |
return false; |
| 2732 |
} |
| 2733 |
} |
| 2734 |
return true; |
| 2735 |
} |
| 2736 |
function isVisibleInTabbableTree(element, isAncestor) { |
| 2737 |
const styles = getComputedStyle2(element); |
| 2738 |
if (!isAncestor) { |
| 2739 |
return isElementVisible(element, styles); |
| 2740 |
} |
| 2741 |
return styles.display !== "none"; |
| 2742 |
} |
| 2743 |
function getTabIndex(element) { |
| 2744 |
const tabIndex = element.tabIndex; |
| 2745 |
if (tabIndex < 0) { |
| 2746 |
const nodeName = getNodeName(element); |
| 2747 |
if (nodeName === "details" || nodeName === "audio" || nodeName === "video" || isHTMLElement(element) && element.isContentEditable) { |
| 2748 |
return 0; |
| 2749 |
} |
| 2750 |
} |
| 2751 |
return tabIndex; |
| 2752 |
} |
| 2753 |
function getNamedRadioInput(element) { |
| 2754 |
if (getNodeName(element) !== "input") { |
| 2755 |
return null; |
| 2756 |
} |
| 2757 |
const input = element; |
| 2758 |
return input.type === "radio" && input.name !== "" ? input : null; |
| 2759 |
} |
| 2760 |
function isTabbableRadio(element, candidates) { |
| 2761 |
const input = getNamedRadioInput(element); |
| 2762 |
if (!input) { |
| 2763 |
return true; |
| 2764 |
} |
| 2765 |
const checkedRadio = candidates.find((candidate) => { |
| 2766 |
const radio = getNamedRadioInput(candidate); |
| 2767 |
return radio?.name === input.name && radio.form === input.form && radio.checked; |
| 2768 |
}); |
| 2769 |
if (checkedRadio) { |
| 2770 |
return checkedRadio === input; |
| 2771 |
} |
| 2772 |
return candidates.find((candidate) => { |
| 2773 |
const radio = getNamedRadioInput(candidate); |
| 2774 |
return radio?.name === input.name && radio.form === input.form; |
| 2775 |
}) === input; |
| 2776 |
} |
| 2777 |
function getComposedChildren(container) { |
| 2778 |
if (isHTMLElement(container) && getNodeName(container) === "slot") { |
| 2779 |
const assignedElements = container.assignedElements({ |
| 2780 |
flatten: true |
| 2781 |
}); |
| 2782 |
if (assignedElements.length > 0) { |
| 2783 |
return assignedElements; |
| 2784 |
} |
| 2785 |
} |
| 2786 |
if (isHTMLElement(container) && container.shadowRoot) { |
| 2787 |
return Array.from(container.shadowRoot.children); |
| 2788 |
} |
| 2789 |
return Array.from(container.children); |
| 2790 |
} |
| 2791 |
function appendCandidates(container, list) { |
| 2792 |
getComposedChildren(container).forEach((child) => { |
| 2793 |
if (isFocusableCandidate(child)) { |
| 2794 |
list.push(child); |
| 2795 |
} |
| 2796 |
appendCandidates(child, list); |
| 2797 |
}); |
| 2798 |
} |
| 2799 |
function appendMatchingElements(container, selector, list) { |
| 2800 |
getComposedChildren(container).forEach((child) => { |
| 2801 |
if (isHTMLElement(child) && child.matches(selector)) { |
| 2802 |
list.push(child); |
| 2803 |
} |
| 2804 |
appendMatchingElements(child, selector, list); |
| 2805 |
}); |
| 2806 |
} |
| 2807 |
function focusable(container) { |
| 2808 |
const candidates = []; |
| 2809 |
appendCandidates(container, candidates); |
| 2810 |
return candidates.filter(isFocusableElement); |
| 2811 |
} |
| 2812 |
function tabbable(container) { |
| 2813 |
const candidates = focusable(container); |
| 2814 |
return candidates.filter((element) => getTabIndex(element) >= 0 && isTabbableRadio(element, candidates)); |
| 2815 |
} |
| 2816 |
function getTabbableIn(container, dir) { |
| 2817 |
const list = tabbable(container); |
| 2818 |
const len = list.length; |
| 2819 |
if (len === 0) { |
| 2820 |
return void 0; |
| 2821 |
} |
| 2822 |
const active = activeElement(ownerDocument(container)); |
| 2823 |
const index2 = list.indexOf(active); |
| 2824 |
const nextIndex = index2 === -1 ? dir === 1 ? 0 : len - 1 : index2 + dir; |
| 2825 |
return list[nextIndex]; |
| 2826 |
} |
| 2827 |
function getNextTabbable(referenceElement) { |
| 2828 |
return getTabbableIn(ownerDocument(referenceElement).body, 1) || referenceElement; |
| 2829 |
} |
| 2830 |
function getPreviousTabbable(referenceElement) { |
| 2831 |
return getTabbableIn(ownerDocument(referenceElement).body, -1) || referenceElement; |
| 2832 |
} |
| 2833 |
function isOutsideEvent(event, container) { |
| 2834 |
const containerElement = container || event.currentTarget; |
| 2835 |
const relatedTarget = event.relatedTarget; |
| 2836 |
return !relatedTarget || !contains(containerElement, relatedTarget); |
| 2837 |
} |
| 2838 |
function disableFocusInside(container) { |
| 2839 |
const tabbableElements = tabbable(container); |
| 2840 |
tabbableElements.forEach((element) => { |
| 2841 |
element.dataset.tabindex = element.getAttribute("tabindex") || ""; |
| 2842 |
element.setAttribute("tabindex", "-1"); |
| 2843 |
}); |
| 2844 |
} |
| 2845 |
function enableFocusInside(container) { |
| 2846 |
const elements = []; |
| 2847 |
appendMatchingElements(container, "[data-tabindex]", elements); |
| 2848 |
elements.forEach((element) => { |
| 2849 |
const tabindex = element.dataset.tabindex; |
| 2850 |
delete element.dataset.tabindex; |
| 2851 |
if (tabindex) { |
| 2852 |
element.setAttribute("tabindex", tabindex); |
| 2853 |
} else { |
| 2854 |
element.removeAttribute("tabindex"); |
| 2855 |
} |
| 2856 |
}); |
| 2857 |
} |
| 2858 |
|
| 2859 |
// node_modules/@base-ui/react/floating-ui-react/utils/nodes.mjs |
| 2860 |
function getNodeChildren(nodes, id, onlyOpenChildren = true) { |
| 2861 |
const directChildren = nodes.filter((node) => node.parentId === id); |
| 2862 |
return directChildren.flatMap((child) => [...!onlyOpenChildren || child.context?.open ? [child] : [], ...getNodeChildren(nodes, child.id, onlyOpenChildren)]); |
| 2863 |
} |
| 2864 |
|
| 2865 |
// node_modules/@base-ui/react/floating-ui-react/utils/createAttribute.mjs |
| 2866 |
function createAttribute(name) { |
| 2867 |
return `data-base-ui-${name}`; |
| 2868 |
} |
| 2869 |
|
| 2870 |
// node_modules/@base-ui/react/floating-ui-react/components/FloatingPortal.mjs |
| 2871 |
var React15 = __toESM(require_react(), 1); |
| 2872 |
var ReactDOM2 = __toESM(require_react_dom(), 1); |
| 2873 |
|
| 2874 |
// node_modules/@base-ui/react/internals/constants.mjs |
| 2875 |
var DISABLED_TRANSITIONS_STYLE = { |
| 2876 |
style: { |
| 2877 |
transition: "none" |
| 2878 |
} |
| 2879 |
}; |
| 2880 |
var BASE_UI_SWIPE_IGNORE_ATTRIBUTE = "data-base-ui-swipe-ignore"; |
| 2881 |
var LEGACY_SWIPE_IGNORE_ATTRIBUTE = "data-swipe-ignore"; |
| 2882 |
var BASE_UI_SWIPE_IGNORE_SELECTOR = `[${BASE_UI_SWIPE_IGNORE_ATTRIBUTE}]`; |
| 2883 |
var LEGACY_SWIPE_IGNORE_SELECTOR = `[${LEGACY_SWIPE_IGNORE_ATTRIBUTE}]`; |
| 2884 |
var POPUP_COLLISION_AVOIDANCE = { |
| 2885 |
fallbackAxisSide: "end" |
| 2886 |
}; |
| 2887 |
var ownerVisuallyHidden = { |
| 2888 |
clipPath: "inset(50%)", |
| 2889 |
position: "fixed", |
| 2890 |
top: 0, |
| 2891 |
left: 0 |
| 2892 |
}; |
| 2893 |
|
| 2894 |
// node_modules/@base-ui/react/floating-ui-react/components/FloatingPortal.mjs |
| 2895 |
var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1); |
| 2896 |
var PortalContext = /* @__PURE__ */ React15.createContext(null); |
| 2897 |
if (true) PortalContext.displayName = "PortalContext"; |
| 2898 |
var usePortalContext = () => React15.useContext(PortalContext); |
| 2899 |
var attr = createAttribute("portal"); |
| 2900 |
function useFloatingPortalNode(props = {}) { |
| 2901 |
const { |
| 2902 |
ref, |
| 2903 |
container: containerProp, |
| 2904 |
componentProps = EMPTY_OBJECT, |
| 2905 |
elementProps |
| 2906 |
} = props; |
| 2907 |
const uniqueId = useId(); |
| 2908 |
const portalContext = usePortalContext(); |
| 2909 |
const parentPortalNode = portalContext?.portalNode; |
| 2910 |
const [containerElement, setContainerElement] = React15.useState(null); |
| 2911 |
const [portalNode, setPortalNode] = React15.useState(null); |
| 2912 |
const setPortalNodeRef = useStableCallback((node) => { |
| 2913 |
if (node !== null) { |
| 2914 |
setPortalNode(node); |
| 2915 |
} |
| 2916 |
}); |
| 2917 |
const containerRef = React15.useRef(null); |
| 2918 |
useIsoLayoutEffect(() => { |
| 2919 |
if (containerProp === null) { |
| 2920 |
if (containerRef.current) { |
| 2921 |
containerRef.current = null; |
| 2922 |
setPortalNode(null); |
| 2923 |
setContainerElement(null); |
| 2924 |
} |
| 2925 |
return; |
| 2926 |
} |
| 2927 |
if (uniqueId == null) { |
| 2928 |
return; |
| 2929 |
} |
| 2930 |
const resolvedContainer = (containerProp && (isNode(containerProp) ? containerProp : containerProp.current)) ?? parentPortalNode ?? document.body; |
| 2931 |
if (resolvedContainer == null) { |
| 2932 |
if (containerRef.current) { |
| 2933 |
containerRef.current = null; |
| 2934 |
setPortalNode(null); |
| 2935 |
setContainerElement(null); |
| 2936 |
} |
| 2937 |
return; |
| 2938 |
} |
| 2939 |
if (containerRef.current !== resolvedContainer) { |
| 2940 |
containerRef.current = resolvedContainer; |
| 2941 |
setPortalNode(null); |
| 2942 |
setContainerElement(resolvedContainer); |
| 2943 |
} |
| 2944 |
}, [containerProp, parentPortalNode, uniqueId]); |
| 2945 |
const portalElement = useRenderElement("div", componentProps, { |
| 2946 |
ref: [ref, setPortalNodeRef], |
| 2947 |
props: [{ |
| 2948 |
id: uniqueId, |
| 2949 |
[attr]: "" |
| 2950 |
}, elementProps] |
| 2951 |
}); |
| 2952 |
const portalSubtree = containerElement && portalElement ? /* @__PURE__ */ ReactDOM2.createPortal(portalElement, containerElement) : null; |
| 2953 |
return { |
| 2954 |
portalNode, |
| 2955 |
portalSubtree |
| 2956 |
}; |
| 2957 |
} |
| 2958 |
var FloatingPortal = /* @__PURE__ */ React15.forwardRef(function FloatingPortal2(componentProps, forwardedRef) { |
| 2959 |
const { |
| 2960 |
render, |
| 2961 |
className, |
| 2962 |
style, |
| 2963 |
children, |
| 2964 |
container, |
| 2965 |
renderGuards, |
| 2966 |
...elementProps |
| 2967 |
} = componentProps; |
| 2968 |
const { |
| 2969 |
portalNode, |
| 2970 |
portalSubtree |
| 2971 |
} = useFloatingPortalNode({ |
| 2972 |
container, |
| 2973 |
ref: forwardedRef, |
| 2974 |
componentProps, |
| 2975 |
elementProps |
| 2976 |
}); |
| 2977 |
const beforeOutsideRef = React15.useRef(null); |
| 2978 |
const afterOutsideRef = React15.useRef(null); |
| 2979 |
const beforeInsideRef = React15.useRef(null); |
| 2980 |
const afterInsideRef = React15.useRef(null); |
| 2981 |
const [focusManagerState, setFocusManagerState] = React15.useState(null); |
| 2982 |
const focusInsideDisabledRef = React15.useRef(false); |
| 2983 |
const modal = focusManagerState?.modal; |
| 2984 |
const open = focusManagerState?.open; |
| 2985 |
const shouldRenderGuards = typeof renderGuards === "boolean" ? renderGuards : !!focusManagerState && !focusManagerState.modal && focusManagerState.open && !!portalNode; |
| 2986 |
React15.useEffect(() => { |
| 2987 |
if (!portalNode || modal) { |
| 2988 |
return void 0; |
| 2989 |
} |
| 2990 |
function onFocus(event) { |
| 2991 |
if (portalNode && event.relatedTarget && isOutsideEvent(event)) { |
| 2992 |
if (event.type === "focusin") { |
| 2993 |
if (focusInsideDisabledRef.current) { |
| 2994 |
enableFocusInside(portalNode); |
| 2995 |
focusInsideDisabledRef.current = false; |
| 2996 |
} |
| 2997 |
} else { |
| 2998 |
disableFocusInside(portalNode); |
| 2999 |
focusInsideDisabledRef.current = true; |
| 3000 |
} |
| 3001 |
} |
| 3002 |
} |
| 3003 |
return mergeCleanups(addEventListener(portalNode, "focusin", onFocus, true), addEventListener(portalNode, "focusout", onFocus, true)); |
| 3004 |
}, [portalNode, modal]); |
| 3005 |
useIsoLayoutEffect(() => { |
| 3006 |
if (!portalNode || open !== true || !focusInsideDisabledRef.current) { |
| 3007 |
return; |
| 3008 |
} |
| 3009 |
enableFocusInside(portalNode); |
| 3010 |
focusInsideDisabledRef.current = false; |
| 3011 |
}, [open, portalNode]); |
| 3012 |
const portalContextValue = React15.useMemo(() => ({ |
| 3013 |
beforeOutsideRef, |
| 3014 |
afterOutsideRef, |
| 3015 |
beforeInsideRef, |
| 3016 |
afterInsideRef, |
| 3017 |
portalNode, |
| 3018 |
setFocusManagerState |
| 3019 |
}), [portalNode]); |
| 3020 |
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(React15.Fragment, { |
| 3021 |
children: [portalSubtree, /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(PortalContext.Provider, { |
| 3022 |
value: portalContextValue, |
| 3023 |
children: [shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, { |
| 3024 |
"data-type": "outside", |
| 3025 |
ref: beforeOutsideRef, |
| 3026 |
onFocus: (event) => { |
| 3027 |
if (isOutsideEvent(event, portalNode)) { |
| 3028 |
beforeInsideRef.current?.focus(); |
| 3029 |
} else { |
| 3030 |
const domReference = focusManagerState ? focusManagerState.domReference : null; |
| 3031 |
const prevTabbable = getPreviousTabbable(domReference); |
| 3032 |
prevTabbable?.focus(); |
| 3033 |
} |
| 3034 |
} |
| 3035 |
}), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { |
| 3036 |
"aria-owns": portalNode.id, |
| 3037 |
style: ownerVisuallyHidden |
| 3038 |
}), portalNode && /* @__PURE__ */ ReactDOM2.createPortal(children, portalNode), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, { |
| 3039 |
"data-type": "outside", |
| 3040 |
ref: afterOutsideRef, |
| 3041 |
onFocus: (event) => { |
| 3042 |
if (isOutsideEvent(event, portalNode)) { |
| 3043 |
afterInsideRef.current?.focus(); |
| 3044 |
} else { |
| 3045 |
const domReference = focusManagerState ? focusManagerState.domReference : null; |
| 3046 |
const nextTabbable = getNextTabbable(domReference); |
| 3047 |
nextTabbable?.focus(); |
| 3048 |
if (focusManagerState?.closeOnFocusOut) { |
| 3049 |
focusManagerState?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.focusOut, event.nativeEvent)); |
| 3050 |
} |
| 3051 |
} |
| 3052 |
} |
| 3053 |
})] |
| 3054 |
})] |
| 3055 |
}); |
| 3056 |
}); |
| 3057 |
if (true) FloatingPortal.displayName = "FloatingPortal"; |
| 3058 |
|
| 3059 |
// node_modules/@base-ui/react/floating-ui-react/components/FloatingTree.mjs |
| 3060 |
var React16 = __toESM(require_react(), 1); |
| 3061 |
|
| 3062 |
// node_modules/@base-ui/react/floating-ui-react/utils/createEventEmitter.mjs |
| 3063 |
function createEventEmitter() { |
| 3064 |
const map = /* @__PURE__ */ new Map(); |
| 3065 |
return { |
| 3066 |
emit(event, data) { |
| 3067 |
map.get(event)?.forEach((listener) => listener(data)); |
| 3068 |
}, |
| 3069 |
on(event, listener) { |
| 3070 |
if (!map.has(event)) { |
| 3071 |
map.set(event, /* @__PURE__ */ new Set()); |
| 3072 |
} |
| 3073 |
map.get(event).add(listener); |
| 3074 |
}, |
| 3075 |
off(event, listener) { |
| 3076 |
map.get(event)?.delete(listener); |
| 3077 |
} |
| 3078 |
}; |
| 3079 |
} |
| 3080 |
|
| 3081 |
// node_modules/@base-ui/react/floating-ui-react/components/FloatingTree.mjs |
| 3082 |
var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1); |
| 3083 |
var FloatingNodeContext = /* @__PURE__ */ React16.createContext(null); |
| 3084 |
if (true) FloatingNodeContext.displayName = "FloatingNodeContext"; |
| 3085 |
var FloatingTreeContext = /* @__PURE__ */ React16.createContext(null); |
| 3086 |
if (true) FloatingTreeContext.displayName = "FloatingTreeContext"; |
| 3087 |
var useFloatingParentNodeId = () => React16.useContext(FloatingNodeContext)?.id || null; |
| 3088 |
var useFloatingTree = (externalTree) => { |
| 3089 |
const contextTree = React16.useContext(FloatingTreeContext); |
| 3090 |
return externalTree ?? contextTree; |
| 3091 |
}; |
| 3092 |
|
| 3093 |
// node_modules/@base-ui/react/floating-ui-react/hooks/useClientPoint.mjs |
| 3094 |
var React17 = __toESM(require_react(), 1); |
| 3095 |
function createVirtualElement(domElement, data) { |
| 3096 |
let offsetX = null; |
| 3097 |
let offsetY = null; |
| 3098 |
let isAutoUpdateEvent = false; |
| 3099 |
return { |
| 3100 |
contextElement: domElement || void 0, |
| 3101 |
getBoundingClientRect() { |
| 3102 |
const domRect = domElement?.getBoundingClientRect() || { |
| 3103 |
width: 0, |
| 3104 |
height: 0, |
| 3105 |
x: 0, |
| 3106 |
y: 0 |
| 3107 |
}; |
| 3108 |
const isXAxis = data.axis === "x" || data.axis === "both"; |
| 3109 |
const isYAxis = data.axis === "y" || data.axis === "both"; |
| 3110 |
const canTrackCursorOnAutoUpdate = ["mouseenter", "mousemove"].includes(data.dataRef.current.openEvent?.type || "") && data.pointerType !== "touch"; |
| 3111 |
let width = domRect.width; |
| 3112 |
let height = domRect.height; |
| 3113 |
let x = domRect.x; |
| 3114 |
let y = domRect.y; |
| 3115 |
if (offsetX == null && data.x && isXAxis) { |
| 3116 |
offsetX = domRect.x - data.x; |
| 3117 |
} |
| 3118 |
if (offsetY == null && data.y && isYAxis) { |
| 3119 |
offsetY = domRect.y - data.y; |
| 3120 |
} |
| 3121 |
x -= offsetX || 0; |
| 3122 |
y -= offsetY || 0; |
| 3123 |
width = 0; |
| 3124 |
height = 0; |
| 3125 |
if (!isAutoUpdateEvent || canTrackCursorOnAutoUpdate) { |
| 3126 |
width = data.axis === "y" ? domRect.width : 0; |
| 3127 |
height = data.axis === "x" ? domRect.height : 0; |
| 3128 |
x = isXAxis && data.x != null ? data.x : x; |
| 3129 |
y = isYAxis && data.y != null ? data.y : y; |
| 3130 |
} else if (isAutoUpdateEvent && !canTrackCursorOnAutoUpdate) { |
| 3131 |
height = data.axis === "x" ? domRect.height : height; |
| 3132 |
width = data.axis === "y" ? domRect.width : width; |
| 3133 |
} |
| 3134 |
isAutoUpdateEvent = true; |
| 3135 |
return { |
| 3136 |
width, |
| 3137 |
height, |
| 3138 |
x, |
| 3139 |
y, |
| 3140 |
top: y, |
| 3141 |
right: x + width, |
| 3142 |
bottom: y + height, |
| 3143 |
left: x |
| 3144 |
}; |
| 3145 |
} |
| 3146 |
}; |
| 3147 |
} |
| 3148 |
function isMouseBasedEvent(event) { |
| 3149 |
return event != null && event.clientX != null; |
| 3150 |
} |
| 3151 |
function useClientPoint(context, props = {}) { |
| 3152 |
const { |
| 3153 |
enabled = true, |
| 3154 |
axis = "both" |
| 3155 |
} = props; |
| 3156 |
const store2 = "rootStore" in context ? context.rootStore : context; |
| 3157 |
const open = store2.useState("open"); |
| 3158 |
const floating = store2.useState("floatingElement"); |
| 3159 |
const domReference = store2.useState("domReferenceElement"); |
| 3160 |
const dataRef = store2.context.dataRef; |
| 3161 |
const initialRef = React17.useRef(false); |
| 3162 |
const cleanupListenerRef = React17.useRef(null); |
| 3163 |
const [pointerType, setPointerType] = React17.useState(); |
| 3164 |
const [reactive, setReactive] = React17.useState([]); |
| 3165 |
const resetReference = useStableCallback((reference2) => { |
| 3166 |
store2.set("positionReference", reference2); |
| 3167 |
}); |
| 3168 |
const setReference = useStableCallback((newX, newY, referenceElement) => { |
| 3169 |
if (initialRef.current) { |
| 3170 |
return; |
| 3171 |
} |
| 3172 |
if (dataRef.current.openEvent && !isMouseBasedEvent(dataRef.current.openEvent)) { |
| 3173 |
return; |
| 3174 |
} |
| 3175 |
store2.set("positionReference", createVirtualElement(referenceElement ?? domReference, { |
| 3176 |
x: newX, |
| 3177 |
y: newY, |
| 3178 |
axis, |
| 3179 |
dataRef, |
| 3180 |
pointerType |
| 3181 |
})); |
| 3182 |
}); |
| 3183 |
const handleReferenceEnterOrMove = useStableCallback((event) => { |
| 3184 |
if (!open) { |
| 3185 |
setReference(event.clientX, event.clientY, event.currentTarget); |
| 3186 |
} else if (!cleanupListenerRef.current) { |
| 3187 |
setReference(event.clientX, event.clientY, event.currentTarget); |
| 3188 |
setReactive([]); |
| 3189 |
} |
| 3190 |
}); |
| 3191 |
const openCheck = isMouseLikePointerType(pointerType) ? floating : open; |
| 3192 |
React17.useEffect(() => { |
| 3193 |
if (!enabled) { |
| 3194 |
resetReference(domReference); |
| 3195 |
return void 0; |
| 3196 |
} |
| 3197 |
if (!openCheck) { |
| 3198 |
return void 0; |
| 3199 |
} |
| 3200 |
function cleanupListener() { |
| 3201 |
cleanupListenerRef.current?.(); |
| 3202 |
cleanupListenerRef.current = null; |
| 3203 |
} |
| 3204 |
const win = getWindow(floating); |
| 3205 |
function handleMouseMove(event) { |
| 3206 |
const target = getTarget(event); |
| 3207 |
if (!contains(floating, target)) { |
| 3208 |
setReference(event.clientX, event.clientY); |
| 3209 |
} else { |
| 3210 |
cleanupListener(); |
| 3211 |
} |
| 3212 |
} |
| 3213 |
if (!dataRef.current.openEvent || isMouseBasedEvent(dataRef.current.openEvent)) { |
| 3214 |
cleanupListenerRef.current = addEventListener(win, "mousemove", handleMouseMove); |
| 3215 |
} else { |
| 3216 |
resetReference(domReference); |
| 3217 |
} |
| 3218 |
return cleanupListener; |
| 3219 |
}, [openCheck, enabled, floating, dataRef, domReference, store2, setReference, resetReference, reactive]); |
| 3220 |
React17.useEffect(() => () => { |
| 3221 |
store2.set("positionReference", null); |
| 3222 |
}, [store2]); |
| 3223 |
React17.useEffect(() => { |
| 3224 |
if (enabled && !floating) { |
| 3225 |
initialRef.current = false; |
| 3226 |
} |
| 3227 |
}, [enabled, floating]); |
| 3228 |
React17.useEffect(() => { |
| 3229 |
if (!enabled && open) { |
| 3230 |
initialRef.current = true; |
| 3231 |
} |
| 3232 |
}, [enabled, open]); |
| 3233 |
const reference = React17.useMemo(() => { |
| 3234 |
function setPointerTypeRef(event) { |
| 3235 |
setPointerType(event.pointerType); |
| 3236 |
} |
| 3237 |
return { |
| 3238 |
onPointerDown: setPointerTypeRef, |
| 3239 |
onPointerEnter: setPointerTypeRef, |
| 3240 |
onMouseMove: handleReferenceEnterOrMove, |
| 3241 |
onMouseEnter: handleReferenceEnterOrMove |
| 3242 |
}; |
| 3243 |
}, [handleReferenceEnterOrMove]); |
| 3244 |
return React17.useMemo(() => enabled ? { |
| 3245 |
reference, |
| 3246 |
trigger: reference |
| 3247 |
} : {}, [enabled, reference]); |
| 3248 |
} |
| 3249 |
|
| 3250 |
// node_modules/@base-ui/react/floating-ui-react/hooks/useDismiss.mjs |
| 3251 |
var React18 = __toESM(require_react(), 1); |
| 3252 |
function alwaysFalse() { |
| 3253 |
return false; |
| 3254 |
} |
| 3255 |
function normalizeProp(normalizable) { |
| 3256 |
return { |
| 3257 |
escapeKey: typeof normalizable === "boolean" ? normalizable : normalizable?.escapeKey ?? false, |
| 3258 |
outsidePress: typeof normalizable === "boolean" ? normalizable : normalizable?.outsidePress ?? true |
| 3259 |
}; |
| 3260 |
} |
| 3261 |
function useDismiss(context, props = {}) { |
| 3262 |
const { |
| 3263 |
enabled = true, |
| 3264 |
escapeKey: escapeKey2 = true, |
| 3265 |
outsidePress: outsidePressProp = true, |
| 3266 |
outsidePressEvent = "sloppy", |
| 3267 |
referencePress = alwaysFalse, |
| 3268 |
bubbles, |
| 3269 |
externalTree |
| 3270 |
} = props; |
| 3271 |
const store2 = "rootStore" in context ? context.rootStore : context; |
| 3272 |
const open = store2.useState("open"); |
| 3273 |
const floatingElement = store2.useState("floatingElement"); |
| 3274 |
const { |
| 3275 |
dataRef |
| 3276 |
} = store2.context; |
| 3277 |
const tree = useFloatingTree(externalTree); |
| 3278 |
const outsidePressFn = useStableCallback(typeof outsidePressProp === "function" ? outsidePressProp : () => false); |
| 3279 |
const outsidePress2 = typeof outsidePressProp === "function" ? outsidePressFn : outsidePressProp; |
| 3280 |
const outsidePressEnabled = outsidePress2 !== false; |
| 3281 |
const getOutsidePressEventProp = useStableCallback(() => outsidePressEvent); |
| 3282 |
const { |
| 3283 |
escapeKey: escapeKeyBubbles, |
| 3284 |
outsidePress: outsidePressBubbles |
| 3285 |
} = normalizeProp(bubbles); |
| 3286 |
const pressStartedInsideRef = React18.useRef(false); |
| 3287 |
const pressStartPreventedRef = React18.useRef(false); |
| 3288 |
const suppressNextOutsideClickRef = React18.useRef(false); |
| 3289 |
const isComposingRef = React18.useRef(false); |
| 3290 |
const currentPointerTypeRef = React18.useRef(""); |
| 3291 |
const touchStateRef = React18.useRef(null); |
| 3292 |
const cancelDismissOnEndTimeout = useTimeout(); |
| 3293 |
const clearInsideReactTreeTimeout = useTimeout(); |
| 3294 |
const clearInsideReactTree = useStableCallback(() => { |
| 3295 |
clearInsideReactTreeTimeout.clear(); |
| 3296 |
dataRef.current.insideReactTree = false; |
| 3297 |
}); |
| 3298 |
const hasBlockingChild = useStableCallback((bubbleKey) => { |
| 3299 |
const nodeId = dataRef.current.floatingContext?.nodeId; |
| 3300 |
const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : []; |
| 3301 |
return children.some((child) => child.context?.open && !child.context.dataRef.current[bubbleKey]); |
| 3302 |
}); |
| 3303 |
const isEventWithinOwnElements = useStableCallback((event) => { |
| 3304 |
return isEventTargetWithin(event, store2.select("floatingElement")) || isEventTargetWithin(event, store2.select("domReferenceElement")); |
| 3305 |
}); |
| 3306 |
const closeOnReferencePress = useStableCallback((event) => { |
| 3307 |
if (!referencePress()) { |
| 3308 |
return; |
| 3309 |
} |
| 3310 |
store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent)); |
| 3311 |
}); |
| 3312 |
const closeOnEscapeKeyDown = useStableCallback((event) => { |
| 3313 |
if (!open || !enabled || !escapeKey2 || event.key !== "Escape") { |
| 3314 |
return; |
| 3315 |
} |
| 3316 |
if (isComposingRef.current) { |
| 3317 |
return; |
| 3318 |
} |
| 3319 |
if (!escapeKeyBubbles && hasBlockingChild("__escapeKeyBubbles")) { |
| 3320 |
return; |
| 3321 |
} |
| 3322 |
const native = isReactEvent(event) ? event.nativeEvent : event; |
| 3323 |
const eventDetails = createChangeEventDetails(reason_parts_exports.escapeKey, native); |
| 3324 |
store2.setOpen(false, eventDetails); |
| 3325 |
if (!eventDetails.isCanceled) { |
| 3326 |
event.preventDefault(); |
| 3327 |
} |
| 3328 |
if (!escapeKeyBubbles && !eventDetails.isPropagationAllowed) { |
| 3329 |
event.stopPropagation(); |
| 3330 |
} |
| 3331 |
}); |
| 3332 |
const markInsideReactTree = useStableCallback(() => { |
| 3333 |
dataRef.current.insideReactTree = true; |
| 3334 |
clearInsideReactTreeTimeout.start(0, clearInsideReactTree); |
| 3335 |
}); |
| 3336 |
const markPressStartedInsideReactTree = useStableCallback((event) => { |
| 3337 |
if (!open || !enabled || event.button !== 0) { |
| 3338 |
return; |
| 3339 |
} |
| 3340 |
const target = getTarget(event.nativeEvent); |
| 3341 |
if (!contains(store2.select("floatingElement"), target)) { |
| 3342 |
return; |
| 3343 |
} |
| 3344 |
if (!pressStartedInsideRef.current) { |
| 3345 |
pressStartedInsideRef.current = true; |
| 3346 |
pressStartPreventedRef.current = false; |
| 3347 |
} |
| 3348 |
}); |
| 3349 |
const markInsidePressStartPrevented = useStableCallback((event) => { |
| 3350 |
if (!open || !enabled) { |
| 3351 |
return; |
| 3352 |
} |
| 3353 |
if (!(event.defaultPrevented || event.nativeEvent.defaultPrevented)) { |
| 3354 |
return; |
| 3355 |
} |
| 3356 |
if (pressStartedInsideRef.current) { |
| 3357 |
pressStartPreventedRef.current = true; |
| 3358 |
} |
| 3359 |
}); |
| 3360 |
React18.useEffect(() => { |
| 3361 |
if (!open || !enabled) { |
| 3362 |
return void 0; |
| 3363 |
} |
| 3364 |
dataRef.current.__escapeKeyBubbles = escapeKeyBubbles; |
| 3365 |
dataRef.current.__outsidePressBubbles = outsidePressBubbles; |
| 3366 |
const compositionTimeout = new Timeout(); |
| 3367 |
const preventedPressSuppressionTimeout = new Timeout(); |
| 3368 |
function handleCompositionStart() { |
| 3369 |
compositionTimeout.clear(); |
| 3370 |
isComposingRef.current = true; |
| 3371 |
} |
| 3372 |
function handleCompositionEnd() { |
| 3373 |
compositionTimeout.start( |
| 3374 |
// 0ms or 1ms don't work in Safari. 5ms appears to consistently work. |
| 3375 |
// Only apply to WebKit for the test to remain 0ms. |
| 3376 |
parts_exports.engine.webkit ? 5 : 0, |
| 3377 |
() => { |
| 3378 |
isComposingRef.current = false; |
| 3379 |
} |
| 3380 |
); |
| 3381 |
} |
| 3382 |
function suppressImmediateOutsideClickAfterPreventedStart() { |
| 3383 |
suppressNextOutsideClickRef.current = true; |
| 3384 |
preventedPressSuppressionTimeout.start(0, () => { |
| 3385 |
suppressNextOutsideClickRef.current = false; |
| 3386 |
}); |
| 3387 |
} |
| 3388 |
function resetPressStartState() { |
| 3389 |
pressStartedInsideRef.current = false; |
| 3390 |
pressStartPreventedRef.current = false; |
| 3391 |
} |
| 3392 |
function getOutsidePressEvent() { |
| 3393 |
const type = currentPointerTypeRef.current; |
| 3394 |
const computedType = type === "pen" || !type ? "mouse" : type; |
| 3395 |
const outsidePressEventValue = getOutsidePressEventProp(); |
| 3396 |
const resolved = typeof outsidePressEventValue === "function" ? outsidePressEventValue() : outsidePressEventValue; |
| 3397 |
if (typeof resolved === "string") { |
| 3398 |
return resolved; |
| 3399 |
} |
| 3400 |
return resolved[computedType]; |
| 3401 |
} |
| 3402 |
function shouldIgnoreEvent(event) { |
| 3403 |
const computedOutsidePressEvent = getOutsidePressEvent(); |
| 3404 |
return computedOutsidePressEvent === "intentional" && event.type !== "click" || computedOutsidePressEvent === "sloppy" && event.type === "click"; |
| 3405 |
} |
| 3406 |
function isEventWithinFloatingTree(event) { |
| 3407 |
const nodeId = dataRef.current.floatingContext?.nodeId; |
| 3408 |
const targetIsInsideChildren = tree && getNodeChildren(tree.nodesRef.current, nodeId).some((node) => isEventTargetWithin(event, node.context?.elements.floating)); |
| 3409 |
return isEventWithinOwnElements(event) || targetIsInsideChildren; |
| 3410 |
} |
| 3411 |
function closeOnPressOutside(event) { |
| 3412 |
if (shouldIgnoreEvent(event)) { |
| 3413 |
if (event.type !== "click" && !isEventWithinOwnElements(event)) { |
| 3414 |
preventedPressSuppressionTimeout.clear(); |
| 3415 |
suppressNextOutsideClickRef.current = false; |
| 3416 |
} |
| 3417 |
clearInsideReactTree(); |
| 3418 |
return; |
| 3419 |
} |
| 3420 |
if (dataRef.current.insideReactTree) { |
| 3421 |
clearInsideReactTree(); |
| 3422 |
return; |
| 3423 |
} |
| 3424 |
const target = getTarget(event); |
| 3425 |
const inertSelector = `[${createAttribute("inert")}]`; |
| 3426 |
const targetRoot = isElement(target) ? target.getRootNode() : null; |
| 3427 |
const markers = Array.from((isShadowRoot(targetRoot) ? targetRoot : ownerDocument(store2.select("floatingElement"))).querySelectorAll(inertSelector)); |
| 3428 |
const triggers = store2.context.triggerElements; |
| 3429 |
if (target && (triggers.hasElement(target) || triggers.hasMatchingElement((trigger) => contains(trigger, target)))) { |
| 3430 |
return; |
| 3431 |
} |
| 3432 |
let targetRootAncestor = isElement(target) ? target : null; |
| 3433 |
while (targetRootAncestor && !isLastTraversableNode(targetRootAncestor)) { |
| 3434 |
const nextParent = getParentNode(targetRootAncestor); |
| 3435 |
if (isLastTraversableNode(nextParent) || !isElement(nextParent)) { |
| 3436 |
break; |
| 3437 |
} |
| 3438 |
targetRootAncestor = nextParent; |
| 3439 |
} |
| 3440 |
if (markers.length && isElement(target) && !isRootElement(target) && // Clicked on a direct ancestor (e.g. FloatingOverlay). |
| 3441 |
!contains(target, store2.select("floatingElement")) && // If the target root element contains none of the markers, then the |
| 3442 |
// element was injected after the floating element rendered. |
| 3443 |
markers.every((marker) => !contains(targetRootAncestor, marker))) { |
| 3444 |
return; |
| 3445 |
} |
| 3446 |
if (isHTMLElement(target) && !("touches" in event)) { |
| 3447 |
const lastTraversableNode = isLastTraversableNode(target); |
| 3448 |
const style = getComputedStyle2(target); |
| 3449 |
const scrollRe = /auto|scroll/; |
| 3450 |
const isScrollableX = lastTraversableNode || scrollRe.test(style.overflowX); |
| 3451 |
const isScrollableY = lastTraversableNode || scrollRe.test(style.overflowY); |
| 3452 |
const canScrollX = isScrollableX && target.clientWidth > 0 && target.scrollWidth > target.clientWidth; |
| 3453 |
const canScrollY = isScrollableY && target.clientHeight > 0 && target.scrollHeight > target.clientHeight; |
| 3454 |
const isRTL2 = style.direction === "rtl"; |
| 3455 |
const pressedVerticalScrollbar = canScrollY && (isRTL2 ? event.offsetX <= target.offsetWidth - target.clientWidth : event.offsetX > target.clientWidth); |
| 3456 |
const pressedHorizontalScrollbar = canScrollX && event.offsetY > target.clientHeight; |
| 3457 |
if (pressedVerticalScrollbar || pressedHorizontalScrollbar) { |
| 3458 |
return; |
| 3459 |
} |
| 3460 |
} |
| 3461 |
if (isEventWithinFloatingTree(event)) { |
| 3462 |
return; |
| 3463 |
} |
| 3464 |
if (getOutsidePressEvent() === "intentional" && suppressNextOutsideClickRef.current) { |
| 3465 |
preventedPressSuppressionTimeout.clear(); |
| 3466 |
suppressNextOutsideClickRef.current = false; |
| 3467 |
return; |
| 3468 |
} |
| 3469 |
if (typeof outsidePress2 === "function" && !outsidePress2(event)) { |
| 3470 |
return; |
| 3471 |
} |
| 3472 |
if (hasBlockingChild("__outsidePressBubbles")) { |
| 3473 |
return; |
| 3474 |
} |
| 3475 |
store2.setOpen(false, createChangeEventDetails(reason_parts_exports.outsidePress, event)); |
| 3476 |
clearInsideReactTree(); |
| 3477 |
} |
| 3478 |
function handlePointerDown(event) { |
| 3479 |
if (getOutsidePressEvent() !== "sloppy" || event.pointerType === "touch" || !store2.select("open") || !enabled || isEventWithinOwnElements(event)) { |
| 3480 |
return; |
| 3481 |
} |
| 3482 |
closeOnPressOutside(event); |
| 3483 |
} |
| 3484 |
function handleTouchStart(event) { |
| 3485 |
if (getOutsidePressEvent() !== "sloppy" || !store2.select("open") || !enabled || isEventWithinOwnElements(event)) { |
| 3486 |
return; |
| 3487 |
} |
| 3488 |
const touch = event.touches[0]; |
| 3489 |
if (touch) { |
| 3490 |
touchStateRef.current = { |
| 3491 |
startTime: Date.now(), |
| 3492 |
startX: touch.clientX, |
| 3493 |
startY: touch.clientY, |
| 3494 |
dismissOnTouchEnd: false, |
| 3495 |
dismissOnMouseDown: true |
| 3496 |
}; |
| 3497 |
cancelDismissOnEndTimeout.start(1e3, () => { |
| 3498 |
if (touchStateRef.current) { |
| 3499 |
touchStateRef.current.dismissOnTouchEnd = false; |
| 3500 |
touchStateRef.current.dismissOnMouseDown = false; |
| 3501 |
} |
| 3502 |
}); |
| 3503 |
} |
| 3504 |
} |
| 3505 |
function addTargetEventListenerOnce(event, listener) { |
| 3506 |
const target = getTarget(event); |
| 3507 |
if (!target) { |
| 3508 |
return; |
| 3509 |
} |
| 3510 |
const unsubscribe2 = addEventListener(target, event.type, () => { |
| 3511 |
listener(event); |
| 3512 |
unsubscribe2(); |
| 3513 |
}); |
| 3514 |
} |
| 3515 |
function handleTouchStartCapture(event) { |
| 3516 |
currentPointerTypeRef.current = "touch"; |
| 3517 |
addTargetEventListenerOnce(event, handleTouchStart); |
| 3518 |
} |
| 3519 |
function closeOnPressOutsideCapture(event) { |
| 3520 |
cancelDismissOnEndTimeout.clear(); |
| 3521 |
if (event.type === "pointerdown") { |
| 3522 |
currentPointerTypeRef.current = event.pointerType; |
| 3523 |
} |
| 3524 |
if (event.type === "mousedown" && touchStateRef.current && !touchStateRef.current.dismissOnMouseDown) { |
| 3525 |
return; |
| 3526 |
} |
| 3527 |
addTargetEventListenerOnce(event, (targetEvent) => { |
| 3528 |
if (targetEvent.type === "pointerdown") { |
| 3529 |
handlePointerDown(targetEvent); |
| 3530 |
} else { |
| 3531 |
closeOnPressOutside(targetEvent); |
| 3532 |
} |
| 3533 |
}); |
| 3534 |
} |
| 3535 |
function handlePressEndCapture(event) { |
| 3536 |
if (!pressStartedInsideRef.current) { |
| 3537 |
return; |
| 3538 |
} |
| 3539 |
const pressStartedInsideDefaultPrevented = pressStartPreventedRef.current; |
| 3540 |
resetPressStartState(); |
| 3541 |
if (getOutsidePressEvent() !== "intentional") { |
| 3542 |
return; |
| 3543 |
} |
| 3544 |
if (event.type === "pointercancel") { |
| 3545 |
if (pressStartedInsideDefaultPrevented) { |
| 3546 |
suppressImmediateOutsideClickAfterPreventedStart(); |
| 3547 |
} |
| 3548 |
return; |
| 3549 |
} |
| 3550 |
if (isEventWithinFloatingTree(event)) { |
| 3551 |
return; |
| 3552 |
} |
| 3553 |
if (pressStartedInsideDefaultPrevented) { |
| 3554 |
suppressImmediateOutsideClickAfterPreventedStart(); |
| 3555 |
return; |
| 3556 |
} |
| 3557 |
if (typeof outsidePress2 === "function" && !outsidePress2(event)) { |
| 3558 |
return; |
| 3559 |
} |
| 3560 |
preventedPressSuppressionTimeout.clear(); |
| 3561 |
suppressNextOutsideClickRef.current = true; |
| 3562 |
clearInsideReactTree(); |
| 3563 |
} |
| 3564 |
function handleTouchMove(event) { |
| 3565 |
if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) { |
| 3566 |
return; |
| 3567 |
} |
| 3568 |
const touch = event.touches[0]; |
| 3569 |
if (!touch) { |
| 3570 |
return; |
| 3571 |
} |
| 3572 |
const deltaX = Math.abs(touch.clientX - touchStateRef.current.startX); |
| 3573 |
const deltaY = Math.abs(touch.clientY - touchStateRef.current.startY); |
| 3574 |
const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY); |
| 3575 |
if (distance > 5) { |
| 3576 |
touchStateRef.current.dismissOnTouchEnd = true; |
| 3577 |
} |
| 3578 |
if (distance > 10) { |
| 3579 |
closeOnPressOutside(event); |
| 3580 |
cancelDismissOnEndTimeout.clear(); |
| 3581 |
touchStateRef.current = null; |
| 3582 |
} |
| 3583 |
} |
| 3584 |
function handleTouchMoveCapture(event) { |
| 3585 |
addTargetEventListenerOnce(event, handleTouchMove); |
| 3586 |
} |
| 3587 |
function handleTouchEnd(event) { |
| 3588 |
if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) { |
| 3589 |
return; |
| 3590 |
} |
| 3591 |
if (touchStateRef.current.dismissOnTouchEnd) { |
| 3592 |
closeOnPressOutside(event); |
| 3593 |
} |
| 3594 |
cancelDismissOnEndTimeout.clear(); |
| 3595 |
touchStateRef.current = null; |
| 3596 |
} |
| 3597 |
function handleTouchEndCapture(event) { |
| 3598 |
addTargetEventListenerOnce(event, handleTouchEnd); |
| 3599 |
} |
| 3600 |
const doc = ownerDocument(floatingElement); |
| 3601 |
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))); |
| 3602 |
return () => { |
| 3603 |
unsubscribe(); |
| 3604 |
compositionTimeout.clear(); |
| 3605 |
preventedPressSuppressionTimeout.clear(); |
| 3606 |
resetPressStartState(); |
| 3607 |
suppressNextOutsideClickRef.current = false; |
| 3608 |
}; |
| 3609 |
}, [dataRef, floatingElement, escapeKey2, outsidePressEnabled, outsidePress2, open, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, clearInsideReactTree, getOutsidePressEventProp, hasBlockingChild, isEventWithinOwnElements, tree, store2, cancelDismissOnEndTimeout]); |
| 3610 |
React18.useEffect(clearInsideReactTree, [outsidePress2, clearInsideReactTree]); |
| 3611 |
const reference = React18.useMemo(() => ({ |
| 3612 |
onKeyDown: closeOnEscapeKeyDown, |
| 3613 |
onPointerDown: closeOnReferencePress, |
| 3614 |
onClick: closeOnReferencePress |
| 3615 |
}), [closeOnEscapeKeyDown, closeOnReferencePress]); |
| 3616 |
const floating = React18.useMemo(() => ({ |
| 3617 |
onKeyDown: closeOnEscapeKeyDown, |
| 3618 |
// `onMouseDown` may be blocked if `event.preventDefault()` is called in |
| 3619 |
// `onPointerDown`, such as with <NumberField.ScrubArea>. |
| 3620 |
// See https://github.com/mui/base-ui/pull/3379 |
| 3621 |
onPointerDown: markInsidePressStartPrevented, |
| 3622 |
onMouseDown: markInsidePressStartPrevented, |
| 3623 |
onClickCapture: markInsideReactTree, |
| 3624 |
onMouseDownCapture(event) { |
| 3625 |
markInsideReactTree(); |
| 3626 |
markPressStartedInsideReactTree(event); |
| 3627 |
}, |
| 3628 |
onPointerDownCapture(event) { |
| 3629 |
markInsideReactTree(); |
| 3630 |
markPressStartedInsideReactTree(event); |
| 3631 |
}, |
| 3632 |
onMouseUpCapture: markInsideReactTree, |
| 3633 |
onTouchEndCapture: markInsideReactTree, |
| 3634 |
onTouchMoveCapture: markInsideReactTree |
| 3635 |
}), [closeOnEscapeKeyDown, markInsideReactTree, markPressStartedInsideReactTree, markInsidePressStartPrevented]); |
| 3636 |
return React18.useMemo(() => enabled ? { |
| 3637 |
reference, |
| 3638 |
floating, |
| 3639 |
trigger: reference |
| 3640 |
} : {}, [enabled, reference, floating]); |
| 3641 |
} |
| 3642 |
|
| 3643 |
// node_modules/@base-ui/react/floating-ui-react/hooks/useFloating.mjs |
| 3644 |
var React25 = __toESM(require_react(), 1); |
| 3645 |
|
| 3646 |
// node_modules/@floating-ui/core/dist/floating-ui.core.mjs |
| 3647 |
function computeCoordsFromPlacement(_ref, placement, rtl) { |
| 3648 |
let { |
| 3649 |
reference, |
| 3650 |
floating |
| 3651 |
} = _ref; |
| 3652 |
const sideAxis = getSideAxis(placement); |
| 3653 |
const alignmentAxis = getAlignmentAxis(placement); |
| 3654 |
const alignLength = getAxisLength(alignmentAxis); |
| 3655 |
const side = getSide(placement); |
| 3656 |
const isVertical = sideAxis === "y"; |
| 3657 |
const commonX = reference.x + reference.width / 2 - floating.width / 2; |
| 3658 |
const commonY = reference.y + reference.height / 2 - floating.height / 2; |
| 3659 |
const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2; |
| 3660 |
let coords; |
| 3661 |
switch (side) { |
| 3662 |
case "top": |
| 3663 |
coords = { |
| 3664 |
x: commonX, |
| 3665 |
y: reference.y - floating.height |
| 3666 |
}; |
| 3667 |
break; |
| 3668 |
case "bottom": |
| 3669 |
coords = { |
| 3670 |
x: commonX, |
| 3671 |
y: reference.y + reference.height |
| 3672 |
}; |
| 3673 |
break; |
| 3674 |
case "right": |
| 3675 |
coords = { |
| 3676 |
x: reference.x + reference.width, |
| 3677 |
y: commonY |
| 3678 |
}; |
| 3679 |
break; |
| 3680 |
case "left": |
| 3681 |
coords = { |
| 3682 |
x: reference.x - floating.width, |
| 3683 |
y: commonY |
| 3684 |
}; |
| 3685 |
break; |
| 3686 |
default: |
| 3687 |
coords = { |
| 3688 |
x: reference.x, |
| 3689 |
y: reference.y |
| 3690 |
}; |
| 3691 |
} |
| 3692 |
switch (getAlignment(placement)) { |
| 3693 |
case "start": |
| 3694 |
coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1); |
| 3695 |
break; |
| 3696 |
case "end": |
| 3697 |
coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1); |
| 3698 |
break; |
| 3699 |
} |
| 3700 |
return coords; |
| 3701 |
} |
| 3702 |
async function detectOverflow(state, options) { |
| 3703 |
var _await$platform$isEle; |
| 3704 |
if (options === void 0) { |
| 3705 |
options = {}; |
| 3706 |
} |
| 3707 |
const { |
| 3708 |
x, |
| 3709 |
y, |
| 3710 |
platform: platform3, |
| 3711 |
rects, |
| 3712 |
elements, |
| 3713 |
strategy |
| 3714 |
} = state; |
| 3715 |
const { |
| 3716 |
boundary = "clippingAncestors", |
| 3717 |
rootBoundary = "viewport", |
| 3718 |
elementContext = "floating", |
| 3719 |
altBoundary = false, |
| 3720 |
padding = 0 |
| 3721 |
} = evaluate(options, state); |
| 3722 |
const paddingObject = getPaddingObject(padding); |
| 3723 |
const altContext = elementContext === "floating" ? "reference" : "floating"; |
| 3724 |
const element = elements[altBoundary ? altContext : elementContext]; |
| 3725 |
const clippingClientRect = rectToClientRect(await platform3.getClippingRect({ |
| 3726 |
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)), |
| 3727 |
boundary, |
| 3728 |
rootBoundary, |
| 3729 |
strategy |
| 3730 |
})); |
| 3731 |
const rect = elementContext === "floating" ? { |
| 3732 |
x, |
| 3733 |
y, |
| 3734 |
width: rects.floating.width, |
| 3735 |
height: rects.floating.height |
| 3736 |
} : rects.reference; |
| 3737 |
const offsetParent = await (platform3.getOffsetParent == null ? void 0 : platform3.getOffsetParent(elements.floating)); |
| 3738 |
const offsetScale = await (platform3.isElement == null ? void 0 : platform3.isElement(offsetParent)) ? await (platform3.getScale == null ? void 0 : platform3.getScale(offsetParent)) || { |
| 3739 |
x: 1, |
| 3740 |
y: 1 |
| 3741 |
} : { |
| 3742 |
x: 1, |
| 3743 |
y: 1 |
| 3744 |
}; |
| 3745 |
const elementClientRect = rectToClientRect(platform3.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform3.convertOffsetParentRelativeRectToViewportRelativeRect({ |
| 3746 |
elements, |
| 3747 |
rect, |
| 3748 |
offsetParent, |
| 3749 |
strategy |
| 3750 |
}) : rect); |
| 3751 |
return { |
| 3752 |
top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y, |
| 3753 |
bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y, |
| 3754 |
left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x, |
| 3755 |
right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x |
| 3756 |
}; |
| 3757 |
} |
| 3758 |
var MAX_RESET_COUNT = 50; |
| 3759 |
var computePosition = async (reference, floating, config) => { |
| 3760 |
const { |
| 3761 |
placement = "bottom", |
| 3762 |
strategy = "absolute", |
| 3763 |
middleware = [], |
| 3764 |
platform: platform3 |
| 3765 |
} = config; |
| 3766 |
const platformWithDetectOverflow = platform3.detectOverflow ? platform3 : { |
| 3767 |
...platform3, |
| 3768 |
detectOverflow |
| 3769 |
}; |
| 3770 |
const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(floating)); |
| 3771 |
let rects = await platform3.getElementRects({ |
| 3772 |
reference, |
| 3773 |
floating, |
| 3774 |
strategy |
| 3775 |
}); |
| 3776 |
let { |
| 3777 |
x, |
| 3778 |
y |
| 3779 |
} = computeCoordsFromPlacement(rects, placement, rtl); |
| 3780 |
let statefulPlacement = placement; |
| 3781 |
let resetCount = 0; |
| 3782 |
const middlewareData = {}; |
| 3783 |
for (let i = 0; i < middleware.length; i++) { |
| 3784 |
const currentMiddleware = middleware[i]; |
| 3785 |
if (!currentMiddleware) { |
| 3786 |
continue; |
| 3787 |
} |
| 3788 |
const { |
| 3789 |
name, |
| 3790 |
fn |
| 3791 |
} = currentMiddleware; |
| 3792 |
const { |
| 3793 |
x: nextX, |
| 3794 |
y: nextY, |
| 3795 |
data, |
| 3796 |
reset |
| 3797 |
} = await fn({ |
| 3798 |
x, |
| 3799 |
y, |
| 3800 |
initialPlacement: placement, |
| 3801 |
placement: statefulPlacement, |
| 3802 |
strategy, |
| 3803 |
middlewareData, |
| 3804 |
rects, |
| 3805 |
platform: platformWithDetectOverflow, |
| 3806 |
elements: { |
| 3807 |
reference, |
| 3808 |
floating |
| 3809 |
} |
| 3810 |
}); |
| 3811 |
x = nextX != null ? nextX : x; |
| 3812 |
y = nextY != null ? nextY : y; |
| 3813 |
middlewareData[name] = { |
| 3814 |
...middlewareData[name], |
| 3815 |
...data |
| 3816 |
}; |
| 3817 |
if (reset && resetCount < MAX_RESET_COUNT) { |
| 3818 |
resetCount++; |
| 3819 |
if (typeof reset === "object") { |
| 3820 |
if (reset.placement) { |
| 3821 |
statefulPlacement = reset.placement; |
| 3822 |
} |
| 3823 |
if (reset.rects) { |
| 3824 |
rects = reset.rects === true ? await platform3.getElementRects({ |
| 3825 |
reference, |
| 3826 |
floating, |
| 3827 |
strategy |
| 3828 |
}) : reset.rects; |
| 3829 |
} |
| 3830 |
({ |
| 3831 |
x, |
| 3832 |
y |
| 3833 |
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl)); |
| 3834 |
} |
| 3835 |
i = -1; |
| 3836 |
} |
| 3837 |
} |
| 3838 |
return { |
| 3839 |
x, |
| 3840 |
y, |
| 3841 |
placement: statefulPlacement, |
| 3842 |
strategy, |
| 3843 |
middlewareData |
| 3844 |
}; |
| 3845 |
}; |
| 3846 |
var flip = function(options) { |
| 3847 |
if (options === void 0) { |
| 3848 |
options = {}; |
| 3849 |
} |
| 3850 |
return { |
| 3851 |
name: "flip", |
| 3852 |
options, |
| 3853 |
async fn(state) { |
| 3854 |
var _middlewareData$arrow, _middlewareData$flip; |
| 3855 |
const { |
| 3856 |
placement, |
| 3857 |
middlewareData, |
| 3858 |
rects, |
| 3859 |
initialPlacement, |
| 3860 |
platform: platform3, |
| 3861 |
elements |
| 3862 |
} = state; |
| 3863 |
const { |
| 3864 |
mainAxis: checkMainAxis = true, |
| 3865 |
crossAxis: checkCrossAxis = true, |
| 3866 |
fallbackPlacements: specifiedFallbackPlacements, |
| 3867 |
fallbackStrategy = "bestFit", |
| 3868 |
fallbackAxisSideDirection = "none", |
| 3869 |
flipAlignment = true, |
| 3870 |
...detectOverflowOptions |
| 3871 |
} = evaluate(options, state); |
| 3872 |
if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) { |
| 3873 |
return {}; |
| 3874 |
} |
| 3875 |
const side = getSide(placement); |
| 3876 |
const initialSideAxis = getSideAxis(initialPlacement); |
| 3877 |
const isBasePlacement = getSide(initialPlacement) === initialPlacement; |
| 3878 |
const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating)); |
| 3879 |
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement)); |
| 3880 |
const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none"; |
| 3881 |
if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) { |
| 3882 |
fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl)); |
| 3883 |
} |
| 3884 |
const placements2 = [initialPlacement, ...fallbackPlacements]; |
| 3885 |
const overflow = await platform3.detectOverflow(state, detectOverflowOptions); |
| 3886 |
const overflows = []; |
| 3887 |
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || []; |
| 3888 |
if (checkMainAxis) { |
| 3889 |
overflows.push(overflow[side]); |
| 3890 |
} |
| 3891 |
if (checkCrossAxis) { |
| 3892 |
const sides2 = getAlignmentSides(placement, rects, rtl); |
| 3893 |
overflows.push(overflow[sides2[0]], overflow[sides2[1]]); |
| 3894 |
} |
| 3895 |
overflowsData = [...overflowsData, { |
| 3896 |
placement, |
| 3897 |
overflows |
| 3898 |
}]; |
| 3899 |
if (!overflows.every((side2) => side2 <= 0)) { |
| 3900 |
var _middlewareData$flip2, _overflowsData$filter; |
| 3901 |
const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1; |
| 3902 |
const nextPlacement = placements2[nextIndex]; |
| 3903 |
if (nextPlacement) { |
| 3904 |
const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false; |
| 3905 |
if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis |
| 3906 |
// overflows the main axis. |
| 3907 |
overflowsData.every((d) => getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) { |
| 3908 |
return { |
| 3909 |
data: { |
| 3910 |
index: nextIndex, |
| 3911 |
overflows: overflowsData |
| 3912 |
}, |
| 3913 |
reset: { |
| 3914 |
placement: nextPlacement |
| 3915 |
} |
| 3916 |
}; |
| 3917 |
} |
| 3918 |
} |
| 3919 |
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; |
| 3920 |
if (!resetPlacement) { |
| 3921 |
switch (fallbackStrategy) { |
| 3922 |
case "bestFit": { |
| 3923 |
var _overflowsData$filter2; |
| 3924 |
const placement2 = (_overflowsData$filter2 = overflowsData.filter((d) => { |
| 3925 |
if (hasFallbackAxisSideDirection) { |
| 3926 |
const currentSideAxis = getSideAxis(d.placement); |
| 3927 |
return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal |
| 3928 |
// reading directions favoring greater width. |
| 3929 |
currentSideAxis === "y"; |
| 3930 |
} |
| 3931 |
return true; |
| 3932 |
}).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]; |
| 3933 |
if (placement2) { |
| 3934 |
resetPlacement = placement2; |
| 3935 |
} |
| 3936 |
break; |
| 3937 |
} |
| 3938 |
case "initialPlacement": |
| 3939 |
resetPlacement = initialPlacement; |
| 3940 |
break; |
| 3941 |
} |
| 3942 |
} |
| 3943 |
if (placement !== resetPlacement) { |
| 3944 |
return { |
| 3945 |
reset: { |
| 3946 |
placement: resetPlacement |
| 3947 |
} |
| 3948 |
}; |
| 3949 |
} |
| 3950 |
} |
| 3951 |
return {}; |
| 3952 |
} |
| 3953 |
}; |
| 3954 |
}; |
| 3955 |
function getSideOffsets(overflow, rect) { |
| 3956 |
return { |
| 3957 |
top: overflow.top - rect.height, |
| 3958 |
right: overflow.right - rect.width, |
| 3959 |
bottom: overflow.bottom - rect.height, |
| 3960 |
left: overflow.left - rect.width |
| 3961 |
}; |
| 3962 |
} |
| 3963 |
function isAnySideFullyClipped(overflow) { |
| 3964 |
return sides.some((side) => overflow[side] >= 0); |
| 3965 |
} |
| 3966 |
var hide = function(options) { |
| 3967 |
if (options === void 0) { |
| 3968 |
options = {}; |
| 3969 |
} |
| 3970 |
return { |
| 3971 |
name: "hide", |
| 3972 |
options, |
| 3973 |
async fn(state) { |
| 3974 |
const { |
| 3975 |
rects, |
| 3976 |
platform: platform3 |
| 3977 |
} = state; |
| 3978 |
const { |
| 3979 |
strategy = "referenceHidden", |
| 3980 |
...detectOverflowOptions |
| 3981 |
} = evaluate(options, state); |
| 3982 |
switch (strategy) { |
| 3983 |
case "referenceHidden": { |
| 3984 |
const overflow = await platform3.detectOverflow(state, { |
| 3985 |
...detectOverflowOptions, |
| 3986 |
elementContext: "reference" |
| 3987 |
}); |
| 3988 |
const offsets = getSideOffsets(overflow, rects.reference); |
| 3989 |
return { |
| 3990 |
data: { |
| 3991 |
referenceHiddenOffsets: offsets, |
| 3992 |
referenceHidden: isAnySideFullyClipped(offsets) |
| 3993 |
} |
| 3994 |
}; |
| 3995 |
} |
| 3996 |
case "escaped": { |
| 3997 |
const overflow = await platform3.detectOverflow(state, { |
| 3998 |
...detectOverflowOptions, |
| 3999 |
altBoundary: true |
| 4000 |
}); |
| 4001 |
const offsets = getSideOffsets(overflow, rects.floating); |
| 4002 |
return { |
| 4003 |
data: { |
| 4004 |
escapedOffsets: offsets, |
| 4005 |
escaped: isAnySideFullyClipped(offsets) |
| 4006 |
} |
| 4007 |
}; |
| 4008 |
} |
| 4009 |
default: { |
| 4010 |
return {}; |
| 4011 |
} |
| 4012 |
} |
| 4013 |
} |
| 4014 |
}; |
| 4015 |
}; |
| 4016 |
var originSides = /* @__PURE__ */ new Set(["left", "top"]); |
| 4017 |
async function convertValueToCoords(state, options) { |
| 4018 |
const { |
| 4019 |
placement, |
| 4020 |
platform: platform3, |
| 4021 |
elements |
| 4022 |
} = state; |
| 4023 |
const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating)); |
| 4024 |
const side = getSide(placement); |
| 4025 |
const alignment = getAlignment(placement); |
| 4026 |
const isVertical = getSideAxis(placement) === "y"; |
| 4027 |
const mainAxisMulti = originSides.has(side) ? -1 : 1; |
| 4028 |
const crossAxisMulti = rtl && isVertical ? -1 : 1; |
| 4029 |
const rawValue = evaluate(options, state); |
| 4030 |
let { |
| 4031 |
mainAxis, |
| 4032 |
crossAxis, |
| 4033 |
alignmentAxis |
| 4034 |
} = typeof rawValue === "number" ? { |
| 4035 |
mainAxis: rawValue, |
| 4036 |
crossAxis: 0, |
| 4037 |
alignmentAxis: null |
| 4038 |
} : { |
| 4039 |
mainAxis: rawValue.mainAxis || 0, |
| 4040 |
crossAxis: rawValue.crossAxis || 0, |
| 4041 |
alignmentAxis: rawValue.alignmentAxis |
| 4042 |
}; |
| 4043 |
if (alignment && typeof alignmentAxis === "number") { |
| 4044 |
crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis; |
| 4045 |
} |
| 4046 |
return isVertical ? { |
| 4047 |
x: crossAxis * crossAxisMulti, |
| 4048 |
y: mainAxis * mainAxisMulti |
| 4049 |
} : { |
| 4050 |
x: mainAxis * mainAxisMulti, |
| 4051 |
y: crossAxis * crossAxisMulti |
| 4052 |
}; |
| 4053 |
} |
| 4054 |
var offset = function(options) { |
| 4055 |
if (options === void 0) { |
| 4056 |
options = 0; |
| 4057 |
} |
| 4058 |
return { |
| 4059 |
name: "offset", |
| 4060 |
options, |
| 4061 |
async fn(state) { |
| 4062 |
var _middlewareData$offse, _middlewareData$arrow; |
| 4063 |
const { |
| 4064 |
x, |
| 4065 |
y, |
| 4066 |
placement, |
| 4067 |
middlewareData |
| 4068 |
} = state; |
| 4069 |
const diffCoords = await convertValueToCoords(state, options); |
| 4070 |
if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) { |
| 4071 |
return {}; |
| 4072 |
} |
| 4073 |
return { |
| 4074 |
x: x + diffCoords.x, |
| 4075 |
y: y + diffCoords.y, |
| 4076 |
data: { |
| 4077 |
...diffCoords, |
| 4078 |
placement |
| 4079 |
} |
| 4080 |
}; |
| 4081 |
} |
| 4082 |
}; |
| 4083 |
}; |
| 4084 |
var shift = function(options) { |
| 4085 |
if (options === void 0) { |
| 4086 |
options = {}; |
| 4087 |
} |
| 4088 |
return { |
| 4089 |
name: "shift", |
| 4090 |
options, |
| 4091 |
async fn(state) { |
| 4092 |
const { |
| 4093 |
x, |
| 4094 |
y, |
| 4095 |
placement, |
| 4096 |
platform: platform3 |
| 4097 |
} = state; |
| 4098 |
const { |
| 4099 |
mainAxis: checkMainAxis = true, |
| 4100 |
crossAxis: checkCrossAxis = false, |
| 4101 |
limiter = { |
| 4102 |
fn: (_ref) => { |
| 4103 |
let { |
| 4104 |
x: x2, |
| 4105 |
y: y2 |
| 4106 |
} = _ref; |
| 4107 |
return { |
| 4108 |
x: x2, |
| 4109 |
y: y2 |
| 4110 |
}; |
| 4111 |
} |
| 4112 |
}, |
| 4113 |
...detectOverflowOptions |
| 4114 |
} = evaluate(options, state); |
| 4115 |
const coords = { |
| 4116 |
x, |
| 4117 |
y |
| 4118 |
}; |
| 4119 |
const overflow = await platform3.detectOverflow(state, detectOverflowOptions); |
| 4120 |
const crossAxis = getSideAxis(getSide(placement)); |
| 4121 |
const mainAxis = getOppositeAxis(crossAxis); |
| 4122 |
let mainAxisCoord = coords[mainAxis]; |
| 4123 |
let crossAxisCoord = coords[crossAxis]; |
| 4124 |
if (checkMainAxis) { |
| 4125 |
const minSide = mainAxis === "y" ? "top" : "left"; |
| 4126 |
const maxSide = mainAxis === "y" ? "bottom" : "right"; |
| 4127 |
const min2 = mainAxisCoord + overflow[minSide]; |
| 4128 |
const max2 = mainAxisCoord - overflow[maxSide]; |
| 4129 |
mainAxisCoord = clamp(min2, mainAxisCoord, max2); |
| 4130 |
} |
| 4131 |
if (checkCrossAxis) { |
| 4132 |
const minSide = crossAxis === "y" ? "top" : "left"; |
| 4133 |
const maxSide = crossAxis === "y" ? "bottom" : "right"; |
| 4134 |
const min2 = crossAxisCoord + overflow[minSide]; |
| 4135 |
const max2 = crossAxisCoord - overflow[maxSide]; |
| 4136 |
crossAxisCoord = clamp(min2, crossAxisCoord, max2); |
| 4137 |
} |
| 4138 |
const limitedCoords = limiter.fn({ |
| 4139 |
...state, |
| 4140 |
[mainAxis]: mainAxisCoord, |
| 4141 |
[crossAxis]: crossAxisCoord |
| 4142 |
}); |
| 4143 |
return { |
| 4144 |
...limitedCoords, |
| 4145 |
data: { |
| 4146 |
x: limitedCoords.x - x, |
| 4147 |
y: limitedCoords.y - y, |
| 4148 |
enabled: { |
| 4149 |
[mainAxis]: checkMainAxis, |
| 4150 |
[crossAxis]: checkCrossAxis |
| 4151 |
} |
| 4152 |
} |
| 4153 |
}; |
| 4154 |
} |
| 4155 |
}; |
| 4156 |
}; |
| 4157 |
var limitShift = function(options) { |
| 4158 |
if (options === void 0) { |
| 4159 |
options = {}; |
| 4160 |
} |
| 4161 |
return { |
| 4162 |
options, |
| 4163 |
fn(state) { |
| 4164 |
const { |
| 4165 |
x, |
| 4166 |
y, |
| 4167 |
placement, |
| 4168 |
rects, |
| 4169 |
middlewareData |
| 4170 |
} = state; |
| 4171 |
const { |
| 4172 |
offset: offset4 = 0, |
| 4173 |
mainAxis: checkMainAxis = true, |
| 4174 |
crossAxis: checkCrossAxis = true |
| 4175 |
} = evaluate(options, state); |
| 4176 |
const coords = { |
| 4177 |
x, |
| 4178 |
y |
| 4179 |
}; |
| 4180 |
const crossAxis = getSideAxis(placement); |
| 4181 |
const mainAxis = getOppositeAxis(crossAxis); |
| 4182 |
let mainAxisCoord = coords[mainAxis]; |
| 4183 |
let crossAxisCoord = coords[crossAxis]; |
| 4184 |
const rawOffset = evaluate(offset4, state); |
| 4185 |
const computedOffset = typeof rawOffset === "number" ? { |
| 4186 |
mainAxis: rawOffset, |
| 4187 |
crossAxis: 0 |
| 4188 |
} : { |
| 4189 |
mainAxis: 0, |
| 4190 |
crossAxis: 0, |
| 4191 |
...rawOffset |
| 4192 |
}; |
| 4193 |
if (checkMainAxis) { |
| 4194 |
const len = mainAxis === "y" ? "height" : "width"; |
| 4195 |
const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis; |
| 4196 |
const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis; |
| 4197 |
if (mainAxisCoord < limitMin) { |
| 4198 |
mainAxisCoord = limitMin; |
| 4199 |
} else if (mainAxisCoord > limitMax) { |
| 4200 |
mainAxisCoord = limitMax; |
| 4201 |
} |
| 4202 |
} |
| 4203 |
if (checkCrossAxis) { |
| 4204 |
var _middlewareData$offse, _middlewareData$offse2; |
| 4205 |
const len = mainAxis === "y" ? "width" : "height"; |
| 4206 |
const isOriginSide = originSides.has(getSide(placement)); |
| 4207 |
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); |
| 4208 |
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); |
| 4209 |
if (crossAxisCoord < limitMin) { |
| 4210 |
crossAxisCoord = limitMin; |
| 4211 |
} else if (crossAxisCoord > limitMax) { |
| 4212 |
crossAxisCoord = limitMax; |
| 4213 |
} |
| 4214 |
} |
| 4215 |
return { |
| 4216 |
[mainAxis]: mainAxisCoord, |
| 4217 |
[crossAxis]: crossAxisCoord |
| 4218 |
}; |
| 4219 |
} |
| 4220 |
}; |
| 4221 |
}; |
| 4222 |
var size = function(options) { |
| 4223 |
if (options === void 0) { |
| 4224 |
options = {}; |
| 4225 |
} |
| 4226 |
return { |
| 4227 |
name: "size", |
| 4228 |
options, |
| 4229 |
async fn(state) { |
| 4230 |
var _state$middlewareData, _state$middlewareData2; |
| 4231 |
const { |
| 4232 |
placement, |
| 4233 |
rects, |
| 4234 |
platform: platform3, |
| 4235 |
elements |
| 4236 |
} = state; |
| 4237 |
const { |
| 4238 |
apply = () => { |
| 4239 |
}, |
| 4240 |
...detectOverflowOptions |
| 4241 |
} = evaluate(options, state); |
| 4242 |
const overflow = await platform3.detectOverflow(state, detectOverflowOptions); |
| 4243 |
const side = getSide(placement); |
| 4244 |
const alignment = getAlignment(placement); |
| 4245 |
const isYAxis = getSideAxis(placement) === "y"; |
| 4246 |
const { |
| 4247 |
width, |
| 4248 |
height |
| 4249 |
} = rects.floating; |
| 4250 |
let heightSide; |
| 4251 |
let widthSide; |
| 4252 |
if (side === "top" || side === "bottom") { |
| 4253 |
heightSide = side; |
| 4254 |
widthSide = alignment === (await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right"; |
| 4255 |
} else { |
| 4256 |
widthSide = side; |
| 4257 |
heightSide = alignment === "end" ? "top" : "bottom"; |
| 4258 |
} |
| 4259 |
const maximumClippingHeight = height - overflow.top - overflow.bottom; |
| 4260 |
const maximumClippingWidth = width - overflow.left - overflow.right; |
| 4261 |
const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight); |
| 4262 |
const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth); |
| 4263 |
const noShift = !state.middlewareData.shift; |
| 4264 |
let availableHeight = overflowAvailableHeight; |
| 4265 |
let availableWidth = overflowAvailableWidth; |
| 4266 |
if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) { |
| 4267 |
availableWidth = maximumClippingWidth; |
| 4268 |
} |
| 4269 |
if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) { |
| 4270 |
availableHeight = maximumClippingHeight; |
| 4271 |
} |
| 4272 |
if (noShift && !alignment) { |
| 4273 |
const xMin = max(overflow.left, 0); |
| 4274 |
const xMax = max(overflow.right, 0); |
| 4275 |
const yMin = max(overflow.top, 0); |
| 4276 |
const yMax = max(overflow.bottom, 0); |
| 4277 |
if (isYAxis) { |
| 4278 |
availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right)); |
| 4279 |
} else { |
| 4280 |
availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom)); |
| 4281 |
} |
| 4282 |
} |
| 4283 |
await apply({ |
| 4284 |
...state, |
| 4285 |
availableWidth, |
| 4286 |
availableHeight |
| 4287 |
}); |
| 4288 |
const nextDimensions = await platform3.getDimensions(elements.floating); |
| 4289 |
if (width !== nextDimensions.width || height !== nextDimensions.height) { |
| 4290 |
return { |
| 4291 |
reset: { |
| 4292 |
rects: true |
| 4293 |
} |
| 4294 |
}; |
| 4295 |
} |
| 4296 |
return {}; |
| 4297 |
} |
| 4298 |
}; |
| 4299 |
}; |
| 4300 |
|
| 4301 |
// node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs |
| 4302 |
function getCssDimensions(element) { |
| 4303 |
const css = getComputedStyle2(element); |
| 4304 |
let width = parseFloat(css.width) || 0; |
| 4305 |
let height = parseFloat(css.height) || 0; |
| 4306 |
const hasOffset = isHTMLElement(element); |
| 4307 |
const offsetWidth = hasOffset ? element.offsetWidth : width; |
| 4308 |
const offsetHeight = hasOffset ? element.offsetHeight : height; |
| 4309 |
const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight; |
| 4310 |
if (shouldFallback) { |
| 4311 |
width = offsetWidth; |
| 4312 |
height = offsetHeight; |
| 4313 |
} |
| 4314 |
return { |
| 4315 |
width, |
| 4316 |
height, |
| 4317 |
$: shouldFallback |
| 4318 |
}; |
| 4319 |
} |
| 4320 |
function unwrapElement(element) { |
| 4321 |
return !isElement(element) ? element.contextElement : element; |
| 4322 |
} |
| 4323 |
function getScale(element) { |
| 4324 |
const domElement = unwrapElement(element); |
| 4325 |
if (!isHTMLElement(domElement)) { |
| 4326 |
return createCoords(1); |
| 4327 |
} |
| 4328 |
const rect = domElement.getBoundingClientRect(); |
| 4329 |
const { |
| 4330 |
width, |
| 4331 |
height, |
| 4332 |
$ |
| 4333 |
} = getCssDimensions(domElement); |
| 4334 |
let x = ($ ? round(rect.width) : rect.width) / width; |
| 4335 |
let y = ($ ? round(rect.height) : rect.height) / height; |
| 4336 |
if (!x || !Number.isFinite(x)) { |
| 4337 |
x = 1; |
| 4338 |
} |
| 4339 |
if (!y || !Number.isFinite(y)) { |
| 4340 |
y = 1; |
| 4341 |
} |
| 4342 |
return { |
| 4343 |
x, |
| 4344 |
y |
| 4345 |
}; |
| 4346 |
} |
| 4347 |
var noOffsets = /* @__PURE__ */ createCoords(0); |
| 4348 |
function getVisualOffsets(element) { |
| 4349 |
const win = getWindow(element); |
| 4350 |
if (!isWebKit() || !win.visualViewport) { |
| 4351 |
return noOffsets; |
| 4352 |
} |
| 4353 |
return { |
| 4354 |
x: win.visualViewport.offsetLeft, |
| 4355 |
y: win.visualViewport.offsetTop |
| 4356 |
}; |
| 4357 |
} |
| 4358 |
function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) { |
| 4359 |
if (isFixed === void 0) { |
| 4360 |
isFixed = false; |
| 4361 |
} |
| 4362 |
if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) { |
| 4363 |
return false; |
| 4364 |
} |
| 4365 |
return isFixed; |
| 4366 |
} |
| 4367 |
function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) { |
| 4368 |
if (includeScale === void 0) { |
| 4369 |
includeScale = false; |
| 4370 |
} |
| 4371 |
if (isFixedStrategy === void 0) { |
| 4372 |
isFixedStrategy = false; |
| 4373 |
} |
| 4374 |
const clientRect = element.getBoundingClientRect(); |
| 4375 |
const domElement = unwrapElement(element); |
| 4376 |
let scale = createCoords(1); |
| 4377 |
if (includeScale) { |
| 4378 |
if (offsetParent) { |
| 4379 |
if (isElement(offsetParent)) { |
| 4380 |
scale = getScale(offsetParent); |
| 4381 |
} |
| 4382 |
} else { |
| 4383 |
scale = getScale(element); |
| 4384 |
} |
| 4385 |
} |
| 4386 |
const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0); |
| 4387 |
let x = (clientRect.left + visualOffsets.x) / scale.x; |
| 4388 |
let y = (clientRect.top + visualOffsets.y) / scale.y; |
| 4389 |
let width = clientRect.width / scale.x; |
| 4390 |
let height = clientRect.height / scale.y; |
| 4391 |
if (domElement) { |
| 4392 |
const win = getWindow(domElement); |
| 4393 |
const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent; |
| 4394 |
let currentWin = win; |
| 4395 |
let currentIFrame = getFrameElement(currentWin); |
| 4396 |
while (currentIFrame && offsetParent && offsetWin !== currentWin) { |
| 4397 |
const iframeScale = getScale(currentIFrame); |
| 4398 |
const iframeRect = currentIFrame.getBoundingClientRect(); |
| 4399 |
const css = getComputedStyle2(currentIFrame); |
| 4400 |
const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x; |
| 4401 |
const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y; |
| 4402 |
x *= iframeScale.x; |
| 4403 |
y *= iframeScale.y; |
| 4404 |
width *= iframeScale.x; |
| 4405 |
height *= iframeScale.y; |
| 4406 |
x += left; |
| 4407 |
y += top; |
| 4408 |
currentWin = getWindow(currentIFrame); |
| 4409 |
currentIFrame = getFrameElement(currentWin); |
| 4410 |
} |
| 4411 |
} |
| 4412 |
return rectToClientRect({ |
| 4413 |
width, |
| 4414 |
height, |
| 4415 |
x, |
| 4416 |
y |
| 4417 |
}); |
| 4418 |
} |
| 4419 |
function getWindowScrollBarX(element, rect) { |
| 4420 |
const leftScroll = getNodeScroll(element).scrollLeft; |
| 4421 |
if (!rect) { |
| 4422 |
return getBoundingClientRect(getDocumentElement(element)).left + leftScroll; |
| 4423 |
} |
| 4424 |
return rect.left + leftScroll; |
| 4425 |
} |
| 4426 |
function getHTMLOffset(documentElement, scroll) { |
| 4427 |
const htmlRect = documentElement.getBoundingClientRect(); |
| 4428 |
const x = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect); |
| 4429 |
const y = htmlRect.top + scroll.scrollTop; |
| 4430 |
return { |
| 4431 |
x, |
| 4432 |
y |
| 4433 |
}; |
| 4434 |
} |
| 4435 |
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) { |
| 4436 |
let { |
| 4437 |
elements, |
| 4438 |
rect, |
| 4439 |
offsetParent, |
| 4440 |
strategy |
| 4441 |
} = _ref; |
| 4442 |
const isFixed = strategy === "fixed"; |
| 4443 |
const documentElement = getDocumentElement(offsetParent); |
| 4444 |
const topLayer = elements ? isTopLayer(elements.floating) : false; |
| 4445 |
if (offsetParent === documentElement || topLayer && isFixed) { |
| 4446 |
return rect; |
| 4447 |
} |
| 4448 |
let scroll = { |
| 4449 |
scrollLeft: 0, |
| 4450 |
scrollTop: 0 |
| 4451 |
}; |
| 4452 |
let scale = createCoords(1); |
| 4453 |
const offsets = createCoords(0); |
| 4454 |
const isOffsetParentAnElement = isHTMLElement(offsetParent); |
| 4455 |
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) { |
| 4456 |
if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) { |
| 4457 |
scroll = getNodeScroll(offsetParent); |
| 4458 |
} |
| 4459 |
if (isOffsetParentAnElement) { |
| 4460 |
const offsetRect = getBoundingClientRect(offsetParent); |
| 4461 |
scale = getScale(offsetParent); |
| 4462 |
offsets.x = offsetRect.x + offsetParent.clientLeft; |
| 4463 |
offsets.y = offsetRect.y + offsetParent.clientTop; |
| 4464 |
} |
| 4465 |
} |
| 4466 |
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0); |
| 4467 |
return { |
| 4468 |
width: rect.width * scale.x, |
| 4469 |
height: rect.height * scale.y, |
| 4470 |
x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x, |
| 4471 |
y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y |
| 4472 |
}; |
| 4473 |
} |
| 4474 |
function getClientRects(element) { |
| 4475 |
return Array.from(element.getClientRects()); |
| 4476 |
} |
| 4477 |
function getDocumentRect(element) { |
| 4478 |
const html = getDocumentElement(element); |
| 4479 |
const scroll = getNodeScroll(element); |
| 4480 |
const body = element.ownerDocument.body; |
| 4481 |
const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth); |
| 4482 |
const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight); |
| 4483 |
let x = -scroll.scrollLeft + getWindowScrollBarX(element); |
| 4484 |
const y = -scroll.scrollTop; |
| 4485 |
if (getComputedStyle2(body).direction === "rtl") { |
| 4486 |
x += max(html.clientWidth, body.clientWidth) - width; |
| 4487 |
} |
| 4488 |
return { |
| 4489 |
width, |
| 4490 |
height, |
| 4491 |
x, |
| 4492 |
y |
| 4493 |
}; |
| 4494 |
} |
| 4495 |
var SCROLLBAR_MAX = 25; |
| 4496 |
function getViewportRect(element, strategy) { |
| 4497 |
const win = getWindow(element); |
| 4498 |
const html = getDocumentElement(element); |
| 4499 |
const visualViewport = win.visualViewport; |
| 4500 |
let width = html.clientWidth; |
| 4501 |
let height = html.clientHeight; |
| 4502 |
let x = 0; |
| 4503 |
let y = 0; |
| 4504 |
if (visualViewport) { |
| 4505 |
width = visualViewport.width; |
| 4506 |
height = visualViewport.height; |
| 4507 |
const visualViewportBased = isWebKit(); |
| 4508 |
if (!visualViewportBased || visualViewportBased && strategy === "fixed") { |
| 4509 |
x = visualViewport.offsetLeft; |
| 4510 |
y = visualViewport.offsetTop; |
| 4511 |
} |
| 4512 |
} |
| 4513 |
const windowScrollbarX = getWindowScrollBarX(html); |
| 4514 |
if (windowScrollbarX <= 0) { |
| 4515 |
const doc = html.ownerDocument; |
| 4516 |
const body = doc.body; |
| 4517 |
const bodyStyles = getComputedStyle(body); |
| 4518 |
const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0; |
| 4519 |
const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline); |
| 4520 |
if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) { |
| 4521 |
width -= clippingStableScrollbarWidth; |
| 4522 |
} |
| 4523 |
} else if (windowScrollbarX <= SCROLLBAR_MAX) { |
| 4524 |
width += windowScrollbarX; |
| 4525 |
} |
| 4526 |
return { |
| 4527 |
width, |
| 4528 |
height, |
| 4529 |
x, |
| 4530 |
y |
| 4531 |
}; |
| 4532 |
} |
| 4533 |
function getInnerBoundingClientRect(element, strategy) { |
| 4534 |
const clientRect = getBoundingClientRect(element, true, strategy === "fixed"); |
| 4535 |
const top = clientRect.top + element.clientTop; |
| 4536 |
const left = clientRect.left + element.clientLeft; |
| 4537 |
const scale = isHTMLElement(element) ? getScale(element) : createCoords(1); |
| 4538 |
const width = element.clientWidth * scale.x; |
| 4539 |
const height = element.clientHeight * scale.y; |
| 4540 |
const x = left * scale.x; |
| 4541 |
const y = top * scale.y; |
| 4542 |
return { |
| 4543 |
width, |
| 4544 |
height, |
| 4545 |
x, |
| 4546 |
y |
| 4547 |
}; |
| 4548 |
} |
| 4549 |
function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) { |
| 4550 |
let rect; |
| 4551 |
if (clippingAncestor === "viewport") { |
| 4552 |
rect = getViewportRect(element, strategy); |
| 4553 |
} else if (clippingAncestor === "document") { |
| 4554 |
rect = getDocumentRect(getDocumentElement(element)); |
| 4555 |
} else if (isElement(clippingAncestor)) { |
| 4556 |
rect = getInnerBoundingClientRect(clippingAncestor, strategy); |
| 4557 |
} else { |
| 4558 |
const visualOffsets = getVisualOffsets(element); |
| 4559 |
rect = { |
| 4560 |
x: clippingAncestor.x - visualOffsets.x, |
| 4561 |
y: clippingAncestor.y - visualOffsets.y, |
| 4562 |
width: clippingAncestor.width, |
| 4563 |
height: clippingAncestor.height |
| 4564 |
}; |
| 4565 |
} |
| 4566 |
return rectToClientRect(rect); |
| 4567 |
} |
| 4568 |
function hasFixedPositionAncestor(element, stopNode) { |
| 4569 |
const parentNode = getParentNode(element); |
| 4570 |
if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) { |
| 4571 |
return false; |
| 4572 |
} |
| 4573 |
return getComputedStyle2(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode); |
| 4574 |
} |
| 4575 |
function getClippingElementAncestors(element, cache) { |
| 4576 |
const cachedResult = cache.get(element); |
| 4577 |
if (cachedResult) { |
| 4578 |
return cachedResult; |
| 4579 |
} |
| 4580 |
let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body"); |
| 4581 |
let currentContainingBlockComputedStyle = null; |
| 4582 |
const elementIsFixed = getComputedStyle2(element).position === "fixed"; |
| 4583 |
let currentNode = elementIsFixed ? getParentNode(element) : element; |
| 4584 |
while (isElement(currentNode) && !isLastTraversableNode(currentNode)) { |
| 4585 |
const computedStyle = getComputedStyle2(currentNode); |
| 4586 |
const currentNodeIsContaining = isContainingBlock(currentNode); |
| 4587 |
if (!currentNodeIsContaining && computedStyle.position === "fixed") { |
| 4588 |
currentContainingBlockComputedStyle = null; |
| 4589 |
} |
| 4590 |
const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && (currentContainingBlockComputedStyle.position === "absolute" || currentContainingBlockComputedStyle.position === "fixed") || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode); |
| 4591 |
if (shouldDropCurrentNode) { |
| 4592 |
result = result.filter((ancestor) => ancestor !== currentNode); |
| 4593 |
} else { |
| 4594 |
currentContainingBlockComputedStyle = computedStyle; |
| 4595 |
} |
| 4596 |
currentNode = getParentNode(currentNode); |
| 4597 |
} |
| 4598 |
cache.set(element, result); |
| 4599 |
return result; |
| 4600 |
} |
| 4601 |
function getClippingRect(_ref) { |
| 4602 |
let { |
| 4603 |
element, |
| 4604 |
boundary, |
| 4605 |
rootBoundary, |
| 4606 |
strategy |
| 4607 |
} = _ref; |
| 4608 |
const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary); |
| 4609 |
const clippingAncestors = [...elementClippingAncestors, rootBoundary]; |
| 4610 |
const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy); |
| 4611 |
let top = firstRect.top; |
| 4612 |
let right = firstRect.right; |
| 4613 |
let bottom = firstRect.bottom; |
| 4614 |
let left = firstRect.left; |
| 4615 |
for (let i = 1; i < clippingAncestors.length; i++) { |
| 4616 |
const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i], strategy); |
| 4617 |
top = max(rect.top, top); |
| 4618 |
right = min(rect.right, right); |
| 4619 |
bottom = min(rect.bottom, bottom); |
| 4620 |
left = max(rect.left, left); |
| 4621 |
} |
| 4622 |
return { |
| 4623 |
width: right - left, |
| 4624 |
height: bottom - top, |
| 4625 |
x: left, |
| 4626 |
y: top |
| 4627 |
}; |
| 4628 |
} |
| 4629 |
function getDimensions(element) { |
| 4630 |
const { |
| 4631 |
width, |
| 4632 |
height |
| 4633 |
} = getCssDimensions(element); |
| 4634 |
return { |
| 4635 |
width, |
| 4636 |
height |
| 4637 |
}; |
| 4638 |
} |
| 4639 |
function getRectRelativeToOffsetParent(element, offsetParent, strategy) { |
| 4640 |
const isOffsetParentAnElement = isHTMLElement(offsetParent); |
| 4641 |
const documentElement = getDocumentElement(offsetParent); |
| 4642 |
const isFixed = strategy === "fixed"; |
| 4643 |
const rect = getBoundingClientRect(element, true, isFixed, offsetParent); |
| 4644 |
let scroll = { |
| 4645 |
scrollLeft: 0, |
| 4646 |
scrollTop: 0 |
| 4647 |
}; |
| 4648 |
const offsets = createCoords(0); |
| 4649 |
function setLeftRTLScrollbarOffset() { |
| 4650 |
offsets.x = getWindowScrollBarX(documentElement); |
| 4651 |
} |
| 4652 |
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) { |
| 4653 |
if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) { |
| 4654 |
scroll = getNodeScroll(offsetParent); |
| 4655 |
} |
| 4656 |
if (isOffsetParentAnElement) { |
| 4657 |
const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent); |
| 4658 |
offsets.x = offsetRect.x + offsetParent.clientLeft; |
| 4659 |
offsets.y = offsetRect.y + offsetParent.clientTop; |
| 4660 |
} else if (documentElement) { |
| 4661 |
setLeftRTLScrollbarOffset(); |
| 4662 |
} |
| 4663 |
} |
| 4664 |
if (isFixed && !isOffsetParentAnElement && documentElement) { |
| 4665 |
setLeftRTLScrollbarOffset(); |
| 4666 |
} |
| 4667 |
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0); |
| 4668 |
const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x; |
| 4669 |
const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y; |
| 4670 |
return { |
| 4671 |
x, |
| 4672 |
y, |
| 4673 |
width: rect.width, |
| 4674 |
height: rect.height |
| 4675 |
}; |
| 4676 |
} |
| 4677 |
function isStaticPositioned(element) { |
| 4678 |
return getComputedStyle2(element).position === "static"; |
| 4679 |
} |
| 4680 |
function getTrueOffsetParent(element, polyfill) { |
| 4681 |
if (!isHTMLElement(element) || getComputedStyle2(element).position === "fixed") { |
| 4682 |
return null; |
| 4683 |
} |
| 4684 |
if (polyfill) { |
| 4685 |
return polyfill(element); |
| 4686 |
} |
| 4687 |
let rawOffsetParent = element.offsetParent; |
| 4688 |
if (getDocumentElement(element) === rawOffsetParent) { |
| 4689 |
rawOffsetParent = rawOffsetParent.ownerDocument.body; |
| 4690 |
} |
| 4691 |
return rawOffsetParent; |
| 4692 |
} |
| 4693 |
function getOffsetParent(element, polyfill) { |
| 4694 |
const win = getWindow(element); |
| 4695 |
if (isTopLayer(element)) { |
| 4696 |
return win; |
| 4697 |
} |
| 4698 |
if (!isHTMLElement(element)) { |
| 4699 |
let svgOffsetParent = getParentNode(element); |
| 4700 |
while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) { |
| 4701 |
if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) { |
| 4702 |
return svgOffsetParent; |
| 4703 |
} |
| 4704 |
svgOffsetParent = getParentNode(svgOffsetParent); |
| 4705 |
} |
| 4706 |
return win; |
| 4707 |
} |
| 4708 |
let offsetParent = getTrueOffsetParent(element, polyfill); |
| 4709 |
while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) { |
| 4710 |
offsetParent = getTrueOffsetParent(offsetParent, polyfill); |
| 4711 |
} |
| 4712 |
if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) { |
| 4713 |
return win; |
| 4714 |
} |
| 4715 |
return offsetParent || getContainingBlock(element) || win; |
| 4716 |
} |
| 4717 |
var getElementRects = async function(data) { |
| 4718 |
const getOffsetParentFn = this.getOffsetParent || getOffsetParent; |
| 4719 |
const getDimensionsFn = this.getDimensions; |
| 4720 |
const floatingDimensions = await getDimensionsFn(data.floating); |
| 4721 |
return { |
| 4722 |
reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy), |
| 4723 |
floating: { |
| 4724 |
x: 0, |
| 4725 |
y: 0, |
| 4726 |
width: floatingDimensions.width, |
| 4727 |
height: floatingDimensions.height |
| 4728 |
} |
| 4729 |
}; |
| 4730 |
}; |
| 4731 |
function isRTL(element) { |
| 4732 |
return getComputedStyle2(element).direction === "rtl"; |
| 4733 |
} |
| 4734 |
var platform2 = { |
| 4735 |
convertOffsetParentRelativeRectToViewportRelativeRect, |
| 4736 |
getDocumentElement, |
| 4737 |
getClippingRect, |
| 4738 |
getOffsetParent, |
| 4739 |
getElementRects, |
| 4740 |
getClientRects, |
| 4741 |
getDimensions, |
| 4742 |
getScale, |
| 4743 |
isElement, |
| 4744 |
isRTL |
| 4745 |
}; |
| 4746 |
function rectsAreEqual(a, b) { |
| 4747 |
return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height; |
| 4748 |
} |
| 4749 |
function observeMove(element, onMove) { |
| 4750 |
let io = null; |
| 4751 |
let timeoutId; |
| 4752 |
const root = getDocumentElement(element); |
| 4753 |
function cleanup() { |
| 4754 |
var _io; |
| 4755 |
clearTimeout(timeoutId); |
| 4756 |
(_io = io) == null || _io.disconnect(); |
| 4757 |
io = null; |
| 4758 |
} |
| 4759 |
function refresh(skip, threshold) { |
| 4760 |
if (skip === void 0) { |
| 4761 |
skip = false; |
| 4762 |
} |
| 4763 |
if (threshold === void 0) { |
| 4764 |
threshold = 1; |
| 4765 |
} |
| 4766 |
cleanup(); |
| 4767 |
const elementRectForRootMargin = element.getBoundingClientRect(); |
| 4768 |
const { |
| 4769 |
left, |
| 4770 |
top, |
| 4771 |
width, |
| 4772 |
height |
| 4773 |
} = elementRectForRootMargin; |
| 4774 |
if (!skip) { |
| 4775 |
onMove(); |
| 4776 |
} |
| 4777 |
if (!width || !height) { |
| 4778 |
return; |
| 4779 |
} |
| 4780 |
const insetTop = floor(top); |
| 4781 |
const insetRight = floor(root.clientWidth - (left + width)); |
| 4782 |
const insetBottom = floor(root.clientHeight - (top + height)); |
| 4783 |
const insetLeft = floor(left); |
| 4784 |
const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px"; |
| 4785 |
const options = { |
| 4786 |
rootMargin, |
| 4787 |
threshold: max(0, min(1, threshold)) || 1 |
| 4788 |
}; |
| 4789 |
let isFirstUpdate = true; |
| 4790 |
function handleObserve(entries) { |
| 4791 |
const ratio = entries[0].intersectionRatio; |
| 4792 |
if (ratio !== threshold) { |
| 4793 |
if (!isFirstUpdate) { |
| 4794 |
return refresh(); |
| 4795 |
} |
| 4796 |
if (!ratio) { |
| 4797 |
timeoutId = setTimeout(() => { |
| 4798 |
refresh(false, 1e-7); |
| 4799 |
}, 1e3); |
| 4800 |
} else { |
| 4801 |
refresh(false, ratio); |
| 4802 |
} |
| 4803 |
} |
| 4804 |
if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) { |
| 4805 |
refresh(); |
| 4806 |
} |
| 4807 |
isFirstUpdate = false; |
| 4808 |
} |
| 4809 |
try { |
| 4810 |
io = new IntersectionObserver(handleObserve, { |
| 4811 |
...options, |
| 4812 |
// Handle <iframe>s |
| 4813 |
root: root.ownerDocument |
| 4814 |
}); |
| 4815 |
} catch (_e) { |
| 4816 |
io = new IntersectionObserver(handleObserve, options); |
| 4817 |
} |
| 4818 |
io.observe(element); |
| 4819 |
} |
| 4820 |
refresh(true); |
| 4821 |
return cleanup; |
| 4822 |
} |
| 4823 |
function autoUpdate(reference, floating, update2, options) { |
| 4824 |
if (options === void 0) { |
| 4825 |
options = {}; |
| 4826 |
} |
| 4827 |
const { |
| 4828 |
ancestorScroll = true, |
| 4829 |
ancestorResize = true, |
| 4830 |
elementResize = typeof ResizeObserver === "function", |
| 4831 |
layoutShift = typeof IntersectionObserver === "function", |
| 4832 |
animationFrame = false |
| 4833 |
} = options; |
| 4834 |
const referenceEl = unwrapElement(reference); |
| 4835 |
const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...floating ? getOverflowAncestors(floating) : []] : []; |
| 4836 |
ancestors.forEach((ancestor) => { |
| 4837 |
ancestorScroll && ancestor.addEventListener("scroll", update2, { |
| 4838 |
passive: true |
| 4839 |
}); |
| 4840 |
ancestorResize && ancestor.addEventListener("resize", update2); |
| 4841 |
}); |
| 4842 |
const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update2) : null; |
| 4843 |
let reobserveFrame = -1; |
| 4844 |
let resizeObserver = null; |
| 4845 |
if (elementResize) { |
| 4846 |
resizeObserver = new ResizeObserver((_ref) => { |
| 4847 |
let [firstEntry] = _ref; |
| 4848 |
if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) { |
| 4849 |
resizeObserver.unobserve(floating); |
| 4850 |
cancelAnimationFrame(reobserveFrame); |
| 4851 |
reobserveFrame = requestAnimationFrame(() => { |
| 4852 |
var _resizeObserver; |
| 4853 |
(_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating); |
| 4854 |
}); |
| 4855 |
} |
| 4856 |
update2(); |
| 4857 |
}); |
| 4858 |
if (referenceEl && !animationFrame) { |
| 4859 |
resizeObserver.observe(referenceEl); |
| 4860 |
} |
| 4861 |
if (floating) { |
| 4862 |
resizeObserver.observe(floating); |
| 4863 |
} |
| 4864 |
} |
| 4865 |
let frameId; |
| 4866 |
let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null; |
| 4867 |
if (animationFrame) { |
| 4868 |
frameLoop(); |
| 4869 |
} |
| 4870 |
function frameLoop() { |
| 4871 |
const nextRefRect = getBoundingClientRect(reference); |
| 4872 |
if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) { |
| 4873 |
update2(); |
| 4874 |
} |
| 4875 |
prevRefRect = nextRefRect; |
| 4876 |
frameId = requestAnimationFrame(frameLoop); |
| 4877 |
} |
| 4878 |
update2(); |
| 4879 |
return () => { |
| 4880 |
var _resizeObserver2; |
| 4881 |
ancestors.forEach((ancestor) => { |
| 4882 |
ancestorScroll && ancestor.removeEventListener("scroll", update2); |
| 4883 |
ancestorResize && ancestor.removeEventListener("resize", update2); |
| 4884 |
}); |
| 4885 |
cleanupIo == null || cleanupIo(); |
| 4886 |
(_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect(); |
| 4887 |
resizeObserver = null; |
| 4888 |
if (animationFrame) { |
| 4889 |
cancelAnimationFrame(frameId); |
| 4890 |
} |
| 4891 |
}; |
| 4892 |
} |
| 4893 |
var offset2 = offset; |
| 4894 |
var shift2 = shift; |
| 4895 |
var flip2 = flip; |
| 4896 |
var size2 = size; |
| 4897 |
var hide2 = hide; |
| 4898 |
var limitShift2 = limitShift; |
| 4899 |
var computePosition2 = (reference, floating, options) => { |
| 4900 |
const cache = /* @__PURE__ */ new Map(); |
| 4901 |
const mergedOptions = { |
| 4902 |
platform: platform2, |
| 4903 |
...options |
| 4904 |
}; |
| 4905 |
const platformWithCache = { |
| 4906 |
...mergedOptions.platform, |
| 4907 |
_c: cache |
| 4908 |
}; |
| 4909 |
return computePosition(reference, floating, { |
| 4910 |
...mergedOptions, |
| 4911 |
platform: platformWithCache |
| 4912 |
}); |
| 4913 |
}; |
| 4914 |
|
| 4915 |
// node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.mjs |
| 4916 |
var React19 = __toESM(require_react(), 1); |
| 4917 |
var import_react2 = __toESM(require_react(), 1); |
| 4918 |
var ReactDOM3 = __toESM(require_react_dom(), 1); |
| 4919 |
var isClient = typeof document !== "undefined"; |
| 4920 |
var noop2 = function noop3() { |
| 4921 |
}; |
| 4922 |
var index = isClient ? import_react2.useLayoutEffect : noop2; |
| 4923 |
function deepEqual(a, b) { |
| 4924 |
if (a === b) { |
| 4925 |
return true; |
| 4926 |
} |
| 4927 |
if (typeof a !== typeof b) { |
| 4928 |
return false; |
| 4929 |
} |
| 4930 |
if (typeof a === "function" && a.toString() === b.toString()) { |
| 4931 |
return true; |
| 4932 |
} |
| 4933 |
let length; |
| 4934 |
let i; |
| 4935 |
let keys; |
| 4936 |
if (a && b && typeof a === "object") { |
| 4937 |
if (Array.isArray(a)) { |
| 4938 |
length = a.length; |
| 4939 |
if (length !== b.length) return false; |
| 4940 |
for (i = length; i-- !== 0; ) { |
| 4941 |
if (!deepEqual(a[i], b[i])) { |
| 4942 |
return false; |
| 4943 |
} |
| 4944 |
} |
| 4945 |
return true; |
| 4946 |
} |
| 4947 |
keys = Object.keys(a); |
| 4948 |
length = keys.length; |
| 4949 |
if (length !== Object.keys(b).length) { |
| 4950 |
return false; |
| 4951 |
} |
| 4952 |
for (i = length; i-- !== 0; ) { |
| 4953 |
if (!{}.hasOwnProperty.call(b, keys[i])) { |
| 4954 |
return false; |
| 4955 |
} |
| 4956 |
} |
| 4957 |
for (i = length; i-- !== 0; ) { |
| 4958 |
const key = keys[i]; |
| 4959 |
if (key === "_owner" && a.$$typeof) { |
| 4960 |
continue; |
| 4961 |
} |
| 4962 |
if (!deepEqual(a[key], b[key])) { |
| 4963 |
return false; |
| 4964 |
} |
| 4965 |
} |
| 4966 |
return true; |
| 4967 |
} |
| 4968 |
return a !== a && b !== b; |
| 4969 |
} |
| 4970 |
function getDPR(element) { |
| 4971 |
if (typeof window === "undefined") { |
| 4972 |
return 1; |
| 4973 |
} |
| 4974 |
const win = element.ownerDocument.defaultView || window; |
| 4975 |
return win.devicePixelRatio || 1; |
| 4976 |
} |
| 4977 |
function roundByDPR(element, value) { |
| 4978 |
const dpr = getDPR(element); |
| 4979 |
return Math.round(value * dpr) / dpr; |
| 4980 |
} |
| 4981 |
function useLatestRef(value) { |
| 4982 |
const ref = React19.useRef(value); |
| 4983 |
index(() => { |
| 4984 |
ref.current = value; |
| 4985 |
}); |
| 4986 |
return ref; |
| 4987 |
} |
| 4988 |
function useFloating(options) { |
| 4989 |
if (options === void 0) { |
| 4990 |
options = {}; |
| 4991 |
} |
| 4992 |
const { |
| 4993 |
placement = "bottom", |
| 4994 |
strategy = "absolute", |
| 4995 |
middleware = [], |
| 4996 |
platform: platform3, |
| 4997 |
elements: { |
| 4998 |
reference: externalReference, |
| 4999 |
floating: externalFloating |
| 5000 |
} = {}, |
| 5001 |
transform = true, |
| 5002 |
whileElementsMounted, |
| 5003 |
open |
| 5004 |
} = options; |
| 5005 |
const [data, setData] = React19.useState({ |
| 5006 |
x: 0, |
| 5007 |
y: 0, |
| 5008 |
strategy, |
| 5009 |
placement, |
| 5010 |
middlewareData: {}, |
| 5011 |
isPositioned: false |
| 5012 |
}); |
| 5013 |
const [latestMiddleware, setLatestMiddleware] = React19.useState(middleware); |
| 5014 |
if (!deepEqual(latestMiddleware, middleware)) { |
| 5015 |
setLatestMiddleware(middleware); |
| 5016 |
} |
| 5017 |
const [_reference, _setReference] = React19.useState(null); |
| 5018 |
const [_floating, _setFloating] = React19.useState(null); |
| 5019 |
const setReference = React19.useCallback((node) => { |
| 5020 |
if (node !== referenceRef.current) { |
| 5021 |
referenceRef.current = node; |
| 5022 |
_setReference(node); |
| 5023 |
} |
| 5024 |
}, []); |
| 5025 |
const setFloating = React19.useCallback((node) => { |
| 5026 |
if (node !== floatingRef.current) { |
| 5027 |
floatingRef.current = node; |
| 5028 |
_setFloating(node); |
| 5029 |
} |
| 5030 |
}, []); |
| 5031 |
const referenceEl = externalReference || _reference; |
| 5032 |
const floatingEl = externalFloating || _floating; |
| 5033 |
const referenceRef = React19.useRef(null); |
| 5034 |
const floatingRef = React19.useRef(null); |
| 5035 |
const dataRef = React19.useRef(data); |
| 5036 |
const hasWhileElementsMounted = whileElementsMounted != null; |
| 5037 |
const whileElementsMountedRef = useLatestRef(whileElementsMounted); |
| 5038 |
const platformRef = useLatestRef(platform3); |
| 5039 |
const openRef = useLatestRef(open); |
| 5040 |
const update2 = React19.useCallback(() => { |
| 5041 |
if (!referenceRef.current || !floatingRef.current) { |
| 5042 |
return; |
| 5043 |
} |
| 5044 |
const config = { |
| 5045 |
placement, |
| 5046 |
strategy, |
| 5047 |
middleware: latestMiddleware |
| 5048 |
}; |
| 5049 |
if (platformRef.current) { |
| 5050 |
config.platform = platformRef.current; |
| 5051 |
} |
| 5052 |
computePosition2(referenceRef.current, floatingRef.current, config).then((data2) => { |
| 5053 |
const fullData = { |
| 5054 |
...data2, |
| 5055 |
// The floating element's position may be recomputed while it's closed |
| 5056 |
// but still mounted (such as when transitioning out). To ensure |
| 5057 |
// `isPositioned` will be `false` initially on the next open, avoid |
| 5058 |
// setting it to `true` when `open === false` (must be specified). |
| 5059 |
isPositioned: openRef.current !== false |
| 5060 |
}; |
| 5061 |
if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) { |
| 5062 |
dataRef.current = fullData; |
| 5063 |
ReactDOM3.flushSync(() => { |
| 5064 |
setData(fullData); |
| 5065 |
}); |
| 5066 |
} |
| 5067 |
}); |
| 5068 |
}, [latestMiddleware, placement, strategy, platformRef, openRef]); |
| 5069 |
index(() => { |
| 5070 |
if (open === false && dataRef.current.isPositioned) { |
| 5071 |
dataRef.current.isPositioned = false; |
| 5072 |
setData((data2) => ({ |
| 5073 |
...data2, |
| 5074 |
isPositioned: false |
| 5075 |
})); |
| 5076 |
} |
| 5077 |
}, [open]); |
| 5078 |
const isMountedRef = React19.useRef(false); |
| 5079 |
index(() => { |
| 5080 |
isMountedRef.current = true; |
| 5081 |
return () => { |
| 5082 |
isMountedRef.current = false; |
| 5083 |
}; |
| 5084 |
}, []); |
| 5085 |
index(() => { |
| 5086 |
if (referenceEl) referenceRef.current = referenceEl; |
| 5087 |
if (floatingEl) floatingRef.current = floatingEl; |
| 5088 |
if (referenceEl && floatingEl) { |
| 5089 |
if (whileElementsMountedRef.current) { |
| 5090 |
return whileElementsMountedRef.current(referenceEl, floatingEl, update2); |
| 5091 |
} |
| 5092 |
update2(); |
| 5093 |
} |
| 5094 |
}, [referenceEl, floatingEl, update2, whileElementsMountedRef, hasWhileElementsMounted]); |
| 5095 |
const refs = React19.useMemo(() => ({ |
| 5096 |
reference: referenceRef, |
| 5097 |
floating: floatingRef, |
| 5098 |
setReference, |
| 5099 |
setFloating |
| 5100 |
}), [setReference, setFloating]); |
| 5101 |
const elements = React19.useMemo(() => ({ |
| 5102 |
reference: referenceEl, |
| 5103 |
floating: floatingEl |
| 5104 |
}), [referenceEl, floatingEl]); |
| 5105 |
const floatingStyles = React19.useMemo(() => { |
| 5106 |
const initialStyles = { |
| 5107 |
position: strategy, |
| 5108 |
left: 0, |
| 5109 |
top: 0 |
| 5110 |
}; |
| 5111 |
if (!elements.floating) { |
| 5112 |
return initialStyles; |
| 5113 |
} |
| 5114 |
const x = roundByDPR(elements.floating, data.x); |
| 5115 |
const y = roundByDPR(elements.floating, data.y); |
| 5116 |
if (transform) { |
| 5117 |
return { |
| 5118 |
...initialStyles, |
| 5119 |
transform: "translate(" + x + "px, " + y + "px)", |
| 5120 |
...getDPR(elements.floating) >= 1.5 && { |
| 5121 |
willChange: "transform" |
| 5122 |
} |
| 5123 |
}; |
| 5124 |
} |
| 5125 |
return { |
| 5126 |
position: strategy, |
| 5127 |
left: x, |
| 5128 |
top: y |
| 5129 |
}; |
| 5130 |
}, [strategy, transform, elements.floating, data.x, data.y]); |
| 5131 |
return React19.useMemo(() => ({ |
| 5132 |
...data, |
| 5133 |
update: update2, |
| 5134 |
refs, |
| 5135 |
elements, |
| 5136 |
floatingStyles |
| 5137 |
}), [data, update2, refs, elements, floatingStyles]); |
| 5138 |
} |
| 5139 |
var offset3 = (options, deps) => { |
| 5140 |
const result = offset2(options); |
| 5141 |
return { |
| 5142 |
name: result.name, |
| 5143 |
fn: result.fn, |
| 5144 |
options: [options, deps] |
| 5145 |
}; |
| 5146 |
}; |
| 5147 |
var shift3 = (options, deps) => { |
| 5148 |
const result = shift2(options); |
| 5149 |
return { |
| 5150 |
name: result.name, |
| 5151 |
fn: result.fn, |
| 5152 |
options: [options, deps] |
| 5153 |
}; |
| 5154 |
}; |
| 5155 |
var limitShift3 = (options, deps) => { |
| 5156 |
const result = limitShift2(options); |
| 5157 |
return { |
| 5158 |
fn: result.fn, |
| 5159 |
options: [options, deps] |
| 5160 |
}; |
| 5161 |
}; |
| 5162 |
var flip3 = (options, deps) => { |
| 5163 |
const result = flip2(options); |
| 5164 |
return { |
| 5165 |
name: result.name, |
| 5166 |
fn: result.fn, |
| 5167 |
options: [options, deps] |
| 5168 |
}; |
| 5169 |
}; |
| 5170 |
var size3 = (options, deps) => { |
| 5171 |
const result = size2(options); |
| 5172 |
return { |
| 5173 |
name: result.name, |
| 5174 |
fn: result.fn, |
| 5175 |
options: [options, deps] |
| 5176 |
}; |
| 5177 |
}; |
| 5178 |
var hide3 = (options, deps) => { |
| 5179 |
const result = hide2(options); |
| 5180 |
return { |
| 5181 |
name: result.name, |
| 5182 |
fn: result.fn, |
| 5183 |
options: [options, deps] |
| 5184 |
}; |
| 5185 |
}; |
| 5186 |
|
| 5187 |
// node_modules/@base-ui/react/utils/popups/popupStoreUtils.mjs |
| 5188 |
var React24 = __toESM(require_react(), 1); |
| 5189 |
var ReactDOM4 = __toESM(require_react_dom(), 1); |
| 5190 |
|
| 5191 |
// node_modules/@base-ui/react/floating-ui-react/hooks/useSyncedFloatingRootContext.mjs |
| 5192 |
var React23 = __toESM(require_react(), 1); |
| 5193 |
|
| 5194 |
// node_modules/@base-ui/utils/store/createSelector.mjs |
| 5195 |
var createSelector2 = (a, b, c, d, e, f, ...other) => { |
| 5196 |
if (other.length > 0) { |
| 5197 |
throw new Error(true ? "Unsupported number of selectors" : formatErrorMessage_default(1)); |
| 5198 |
} |
| 5199 |
let selector; |
| 5200 |
if (a && b && c && d && e && f) { |
| 5201 |
selector = (state, a1, a2, a3) => { |
| 5202 |
const va = a(state, a1, a2, a3); |
| 5203 |
const vb = b(state, a1, a2, a3); |
| 5204 |
const vc = c(state, a1, a2, a3); |
| 5205 |
const vd = d(state, a1, a2, a3); |
| 5206 |
const ve = e(state, a1, a2, a3); |
| 5207 |
return f(va, vb, vc, vd, ve, a1, a2, a3); |
| 5208 |
}; |
| 5209 |
} else if (a && b && c && d && e) { |
| 5210 |
selector = (state, a1, a2, a3) => { |
| 5211 |
const va = a(state, a1, a2, a3); |
| 5212 |
const vb = b(state, a1, a2, a3); |
| 5213 |
const vc = c(state, a1, a2, a3); |
| 5214 |
const vd = d(state, a1, a2, a3); |
| 5215 |
return e(va, vb, vc, vd, a1, a2, a3); |
| 5216 |
}; |
| 5217 |
} else if (a && b && c && d) { |
| 5218 |
selector = (state, a1, a2, a3) => { |
| 5219 |
const va = a(state, a1, a2, a3); |
| 5220 |
const vb = b(state, a1, a2, a3); |
| 5221 |
const vc = c(state, a1, a2, a3); |
| 5222 |
return d(va, vb, vc, a1, a2, a3); |
| 5223 |
}; |
| 5224 |
} else if (a && b && c) { |
| 5225 |
selector = (state, a1, a2, a3) => { |
| 5226 |
const va = a(state, a1, a2, a3); |
| 5227 |
const vb = b(state, a1, a2, a3); |
| 5228 |
return c(va, vb, a1, a2, a3); |
| 5229 |
}; |
| 5230 |
} else if (a && b) { |
| 5231 |
selector = (state, a1, a2, a3) => { |
| 5232 |
const va = a(state, a1, a2, a3); |
| 5233 |
return b(va, a1, a2, a3); |
| 5234 |
}; |
| 5235 |
} else if (a) { |
| 5236 |
selector = a; |
| 5237 |
} else { |
| 5238 |
throw ( |
| 5239 |
/* minify-error-disabled */ |
| 5240 |
new Error("Missing arguments") |
| 5241 |
); |
| 5242 |
} |
| 5243 |
return selector; |
| 5244 |
}; |
| 5245 |
|
| 5246 |
// node_modules/@base-ui/utils/store/useStore.mjs |
| 5247 |
var React21 = __toESM(require_react(), 1); |
| 5248 |
var import_shim = __toESM(require_shim(), 1); |
| 5249 |
var import_with_selector = __toESM(require_with_selector(), 1); |
| 5250 |
|
| 5251 |
// node_modules/@base-ui/utils/fastHooks.mjs |
| 5252 |
var React20 = __toESM(require_react(), 1); |
| 5253 |
var hooks = []; |
| 5254 |
var currentInstance = void 0; |
| 5255 |
function getInstance() { |
| 5256 |
return currentInstance; |
| 5257 |
} |
| 5258 |
function register2(hook) { |
| 5259 |
hooks.push(hook); |
| 5260 |
} |
| 5261 |
function fastComponent(fn) { |
| 5262 |
const FastComponent = (props, forwardedRef) => { |
| 5263 |
const instance = useRefWithInit(createInstance).current; |
| 5264 |
let result; |
| 5265 |
try { |
| 5266 |
currentInstance = instance; |
| 5267 |
for (const hook of hooks) { |
| 5268 |
hook.before(instance); |
| 5269 |
} |
| 5270 |
result = fn(props, forwardedRef); |
| 5271 |
for (const hook of hooks) { |
| 5272 |
hook.after(instance); |
| 5273 |
} |
| 5274 |
instance.didInitialize = true; |
| 5275 |
} finally { |
| 5276 |
currentInstance = void 0; |
| 5277 |
} |
| 5278 |
return result; |
| 5279 |
}; |
| 5280 |
FastComponent.displayName = fn.displayName || fn.name; |
| 5281 |
return FastComponent; |
| 5282 |
} |
| 5283 |
function fastComponentRef(fn) { |
| 5284 |
return /* @__PURE__ */ React20.forwardRef(fastComponent(fn)); |
| 5285 |
} |
| 5286 |
function createInstance() { |
| 5287 |
return { |
| 5288 |
didInitialize: false |
| 5289 |
}; |
| 5290 |
} |
| 5291 |
|
| 5292 |
// node_modules/@base-ui/utils/store/useStore.mjs |
| 5293 |
var canUseRawUseSyncExternalStore = isReactVersionAtLeast(19); |
| 5294 |
var useStoreImplementation = canUseRawUseSyncExternalStore ? useStoreFast : useStoreLegacy; |
| 5295 |
function useStore(store2, selector, a1, a2, a3) { |
| 5296 |
return useStoreImplementation(store2, selector, a1, a2, a3); |
| 5297 |
} |
| 5298 |
function useStoreR19(store2, selector, a1, a2, a3) { |
| 5299 |
const getSelection = React21.useCallback(() => selector(store2.getSnapshot(), a1, a2, a3), [store2, selector, a1, a2, a3]); |
| 5300 |
return (0, import_shim.useSyncExternalStore)(store2.subscribe, getSelection, getSelection); |
| 5301 |
} |
| 5302 |
register2({ |
| 5303 |
before(instance) { |
| 5304 |
instance.syncIndex = 0; |
| 5305 |
if (!instance.didInitialize) { |
| 5306 |
instance.syncTick = 1; |
| 5307 |
instance.syncHooks = []; |
| 5308 |
instance.didChangeStore = true; |
| 5309 |
instance.getSnapshot = () => { |
| 5310 |
let didChange2 = false; |
| 5311 |
for (let i = 0; i < instance.syncHooks.length; i += 1) { |
| 5312 |
const hook = instance.syncHooks[i]; |
| 5313 |
const value = hook.selector(hook.store.state, hook.a1, hook.a2, hook.a3); |
| 5314 |
if (!Object.is(hook.value, value)) { |
| 5315 |
didChange2 = true; |
| 5316 |
hook.value = value; |
| 5317 |
} |
| 5318 |
} |
| 5319 |
if (didChange2) { |
| 5320 |
instance.syncTick += 1; |
| 5321 |
} |
| 5322 |
return instance.syncTick; |
| 5323 |
}; |
| 5324 |
} |
| 5325 |
}, |
| 5326 |
after(instance) { |
| 5327 |
if (instance.syncHooks.length > 0) { |
| 5328 |
if (instance.didChangeStore) { |
| 5329 |
instance.didChangeStore = false; |
| 5330 |
instance.subscribe = (onStoreChange) => { |
| 5331 |
const stores = /* @__PURE__ */ new Set(); |
| 5332 |
for (const hook of instance.syncHooks) { |
| 5333 |
stores.add(hook.store); |
| 5334 |
} |
| 5335 |
const unsubscribes = []; |
| 5336 |
for (const store2 of stores) { |
| 5337 |
unsubscribes.push(store2.subscribe(onStoreChange)); |
| 5338 |
} |
| 5339 |
return () => { |
| 5340 |
for (const unsubscribe of unsubscribes) { |
| 5341 |
unsubscribe(); |
| 5342 |
} |
| 5343 |
}; |
| 5344 |
}; |
| 5345 |
} |
| 5346 |
(0, import_shim.useSyncExternalStore)(instance.subscribe, instance.getSnapshot, instance.getSnapshot); |
| 5347 |
} |
| 5348 |
} |
| 5349 |
}); |
| 5350 |
function useStoreFast(store2, selector, a1, a2, a3) { |
| 5351 |
const instance = getInstance(); |
| 5352 |
if (!instance) { |
| 5353 |
return useStoreR19(store2, selector, a1, a2, a3); |
| 5354 |
} |
| 5355 |
const index2 = instance.syncIndex; |
| 5356 |
instance.syncIndex += 1; |
| 5357 |
let hook; |
| 5358 |
if (!instance.didInitialize) { |
| 5359 |
hook = { |
| 5360 |
store: store2, |
| 5361 |
selector, |
| 5362 |
a1, |
| 5363 |
a2, |
| 5364 |
a3, |
| 5365 |
value: selector(store2.getSnapshot(), a1, a2, a3) |
| 5366 |
}; |
| 5367 |
instance.syncHooks.push(hook); |
| 5368 |
} else { |
| 5369 |
hook = instance.syncHooks[index2]; |
| 5370 |
if (hook.store !== store2 || hook.selector !== selector || !Object.is(hook.a1, a1) || !Object.is(hook.a2, a2) || !Object.is(hook.a3, a3)) { |
| 5371 |
if (hook.store !== store2) { |
| 5372 |
instance.didChangeStore = true; |
| 5373 |
} |
| 5374 |
hook.store = store2; |
| 5375 |
hook.selector = selector; |
| 5376 |
hook.a1 = a1; |
| 5377 |
hook.a2 = a2; |
| 5378 |
hook.a3 = a3; |
| 5379 |
hook.value = selector(store2.getSnapshot(), a1, a2, a3); |
| 5380 |
} |
| 5381 |
} |
| 5382 |
return hook.value; |
| 5383 |
} |
| 5384 |
function useStoreLegacy(store2, selector, a1, a2, a3) { |
| 5385 |
return (0, import_with_selector.useSyncExternalStoreWithSelector)(store2.subscribe, store2.getSnapshot, store2.getSnapshot, (state) => selector(state, a1, a2, a3)); |
| 5386 |
} |
| 5387 |
|
| 5388 |
// node_modules/@base-ui/utils/store/Store.mjs |
| 5389 |
var Store = class { |
| 5390 |
/** |
| 5391 |
* The current state of the store. |
| 5392 |
* This property is updated immediately when the state changes as a result of calling {@link setState}, {@link update}, or {@link set}. |
| 5393 |
* 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). |
| 5394 |
* The values can be used directly (to avoid subscribing to the store) in effects or event handlers. |
| 5395 |
* |
| 5396 |
* Do not modify properties in state directly. Instead, use the provided methods to ensure proper state management and listener notification. |
| 5397 |
*/ |
| 5398 |
// Internal state to handle recursive `setState()` calls |
| 5399 |
constructor(state) { |
| 5400 |
this.state = state; |
| 5401 |
this.listeners = /* @__PURE__ */ new Set(); |
| 5402 |
this.updateTick = 0; |
| 5403 |
} |
| 5404 |
/** |
| 5405 |
* Registers a listener that will be called whenever the store's state changes. |
| 5406 |
* |
| 5407 |
* @param fn The listener function to be called on state changes. |
| 5408 |
* @returns A function to unsubscribe the listener. |
| 5409 |
*/ |
| 5410 |
subscribe = (fn) => { |
| 5411 |
this.listeners.add(fn); |
| 5412 |
return () => { |
| 5413 |
this.listeners.delete(fn); |
| 5414 |
}; |
| 5415 |
}; |
| 5416 |
/** |
| 5417 |
* Returns the current state of the store. |
| 5418 |
*/ |
| 5419 |
getSnapshot = () => { |
| 5420 |
return this.state; |
| 5421 |
}; |
| 5422 |
/** |
| 5423 |
* Updates the entire store's state and notifies all registered listeners. |
| 5424 |
* |
| 5425 |
* @param newState The new state to set for the store. |
| 5426 |
*/ |
| 5427 |
setState(newState) { |
| 5428 |
if (this.state === newState) { |
| 5429 |
return; |
| 5430 |
} |
| 5431 |
this.state = newState; |
| 5432 |
this.updateTick += 1; |
| 5433 |
const currentTick = this.updateTick; |
| 5434 |
for (const listener of this.listeners) { |
| 5435 |
if (currentTick !== this.updateTick) { |
| 5436 |
return; |
| 5437 |
} |
| 5438 |
listener(newState); |
| 5439 |
} |
| 5440 |
} |
| 5441 |
/** |
| 5442 |
* Merges the provided changes into the current state and notifies listeners if there are changes. |
| 5443 |
* |
| 5444 |
* @param changes An object containing the changes to apply to the current state. |
| 5445 |
*/ |
| 5446 |
update(changes) { |
| 5447 |
for (const key in changes) { |
| 5448 |
if (!Object.is(this.state[key], changes[key])) { |
| 5449 |
this.setState({ |
| 5450 |
...this.state, |
| 5451 |
...changes |
| 5452 |
}); |
| 5453 |
return; |
| 5454 |
} |
| 5455 |
} |
| 5456 |
} |
| 5457 |
/** |
| 5458 |
* Sets a specific key in the store's state to a new value and notifies listeners if the value has changed. |
| 5459 |
* |
| 5460 |
* @param key The key in the store's state to update. |
| 5461 |
* @param value The new value to set for the specified key. |
| 5462 |
*/ |
| 5463 |
set(key, value) { |
| 5464 |
if (!Object.is(this.state[key], value)) { |
| 5465 |
this.setState({ |
| 5466 |
...this.state, |
| 5467 |
[key]: value |
| 5468 |
}); |
| 5469 |
} |
| 5470 |
} |
| 5471 |
/** |
| 5472 |
* Gives the state a new reference and updates all registered listeners. |
| 5473 |
*/ |
| 5474 |
notifyAll() { |
| 5475 |
const newState = { |
| 5476 |
...this.state |
| 5477 |
}; |
| 5478 |
this.setState(newState); |
| 5479 |
} |
| 5480 |
use(selector, a1, a2, a3) { |
| 5481 |
return useStore(this, selector, a1, a2, a3); |
| 5482 |
} |
| 5483 |
}; |
| 5484 |
|
| 5485 |
// node_modules/@base-ui/utils/store/ReactStore.mjs |
| 5486 |
var React22 = __toESM(require_react(), 1); |
| 5487 |
var ReactStore = class extends Store { |
| 5488 |
/** |
| 5489 |
* Creates a new ReactStore instance. |
| 5490 |
* |
| 5491 |
* @param state Initial state of the store. |
| 5492 |
* @param context Non-reactive context values. |
| 5493 |
* @param selectors Optional selectors for use with `useState`. |
| 5494 |
*/ |
| 5495 |
constructor(state, context = {}, selectors3) { |
| 5496 |
super(state); |
| 5497 |
this.context = context; |
| 5498 |
this.selectors = selectors3; |
| 5499 |
} |
| 5500 |
/** |
| 5501 |
* Non-reactive values such as refs, callbacks, etc. |
| 5502 |
*/ |
| 5503 |
/** |
| 5504 |
* Synchronizes a single external value into the store. |
| 5505 |
* |
| 5506 |
* Note that the while the value in `state` is updated immediately, the value returned |
| 5507 |
* by `useState` is updated before the next render (similarly to React's `useState`). |
| 5508 |
*/ |
| 5509 |
useSyncedValue(key, value) { |
| 5510 |
React22.useDebugValue(key); |
| 5511 |
const store2 = this; |
| 5512 |
useIsoLayoutEffect(() => { |
| 5513 |
if (store2.state[key] !== value) { |
| 5514 |
store2.set(key, value); |
| 5515 |
} |
| 5516 |
}, [store2, key, value]); |
| 5517 |
} |
| 5518 |
/** |
| 5519 |
* Synchronizes a single external value into the store and |
| 5520 |
* cleans it up (sets to `undefined`) on unmount. |
| 5521 |
* |
| 5522 |
* Note that the while the value in `state` is updated immediately, the value returned |
| 5523 |
* by `useState` is updated before the next render (similarly to React's `useState`). |
| 5524 |
*/ |
| 5525 |
useSyncedValueWithCleanup(key, value) { |
| 5526 |
const store2 = this; |
| 5527 |
useIsoLayoutEffect(() => { |
| 5528 |
if (store2.state[key] !== value) { |
| 5529 |
store2.set(key, value); |
| 5530 |
} |
| 5531 |
return () => { |
| 5532 |
store2.set(key, void 0); |
| 5533 |
}; |
| 5534 |
}, [store2, key, value]); |
| 5535 |
} |
| 5536 |
/** |
| 5537 |
* Synchronizes multiple external values into the store. |
| 5538 |
* |
| 5539 |
* Note that the while the values in `state` are updated immediately, the values returned |
| 5540 |
* by `useState` are updated before the next render (similarly to React's `useState`). |
| 5541 |
*/ |
| 5542 |
useSyncedValues(statePart) { |
| 5543 |
const store2 = this; |
| 5544 |
if (true) { |
| 5545 |
React22.useDebugValue(statePart, (p) => Object.keys(p)); |
| 5546 |
const keys = React22.useRef(Object.keys(statePart)).current; |
| 5547 |
const nextKeys = Object.keys(statePart); |
| 5548 |
if (keys.length !== nextKeys.length || keys.some((key, index2) => key !== nextKeys[index2])) { |
| 5549 |
console.error("ReactStore.useSyncedValues expects the same prop keys on every render. Keys should be stable."); |
| 5550 |
} |
| 5551 |
} |
| 5552 |
const dependencies = Object.values(statePart); |
| 5553 |
useIsoLayoutEffect(() => { |
| 5554 |
store2.update(statePart); |
| 5555 |
}, [store2, ...dependencies]); |
| 5556 |
} |
| 5557 |
/** |
| 5558 |
* Registers a controllable prop pair (`controlled`, `defaultValue`) for a specific key. If `controlled` |
| 5559 |
* is non-undefined, the store's state at `key` is updated to match `controlled`. |
| 5560 |
*/ |
| 5561 |
useControlledProp(key, controlled) { |
| 5562 |
React22.useDebugValue(key); |
| 5563 |
const store2 = this; |
| 5564 |
const isControlled = controlled !== void 0; |
| 5565 |
useIsoLayoutEffect(() => { |
| 5566 |
if (isControlled && !Object.is(store2.state[key], controlled)) { |
| 5567 |
store2.setState({ |
| 5568 |
...store2.state, |
| 5569 |
[key]: controlled |
| 5570 |
}); |
| 5571 |
} |
| 5572 |
}, [store2, key, controlled, isControlled]); |
| 5573 |
if (true) { |
| 5574 |
const cache = this.controlledValues ??= /* @__PURE__ */ new Map(); |
| 5575 |
if (!cache.has(key)) { |
| 5576 |
cache.set(key, isControlled); |
| 5577 |
} |
| 5578 |
const previouslyControlled = cache.get(key); |
| 5579 |
if (previouslyControlled !== void 0 && previouslyControlled !== isControlled) { |
| 5580 |
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).`); |
| 5581 |
} |
| 5582 |
} |
| 5583 |
} |
| 5584 |
/** Gets the current value from the store using a selector with the provided key. |
| 5585 |
* |
| 5586 |
* @param key Key of the selector to use. |
| 5587 |
*/ |
| 5588 |
select(key, a1, a2, a3) { |
| 5589 |
const selector = this.selectors[key]; |
| 5590 |
return selector(this.state, a1, a2, a3); |
| 5591 |
} |
| 5592 |
/** |
| 5593 |
* Returns a value from the store's state using a selector function. |
| 5594 |
* Used to subscribe to specific parts of the state. |
| 5595 |
* This methods causes a rerender whenever the selected state changes. |
| 5596 |
* |
| 5597 |
* @param key Key of the selector to use. |
| 5598 |
*/ |
| 5599 |
useState(key, a1, a2, a3) { |
| 5600 |
React22.useDebugValue(key); |
| 5601 |
return useStore(this, this.selectors[key], a1, a2, a3); |
| 5602 |
} |
| 5603 |
/** |
| 5604 |
* Wraps a function with `useStableCallback` to ensure it has a stable reference |
| 5605 |
* and assigns it to the context. |
| 5606 |
* |
| 5607 |
* @param key Key of the event callback. Must be a function in the context. |
| 5608 |
* @param fn Function to assign. |
| 5609 |
*/ |
| 5610 |
useContextCallback(key, fn) { |
| 5611 |
React22.useDebugValue(key); |
| 5612 |
const stableFunction = useStableCallback(fn ?? NOOP); |
| 5613 |
this.context[key] = stableFunction; |
| 5614 |
} |
| 5615 |
/** |
| 5616 |
* Returns a stable setter function for a specific key in the store's state. |
| 5617 |
* It's commonly used to pass as a ref callback to React elements. |
| 5618 |
* |
| 5619 |
* @param key Key of the state to set. |
| 5620 |
*/ |
| 5621 |
useStateSetter(key) { |
| 5622 |
const ref = React22.useRef(void 0); |
| 5623 |
if (ref.current === void 0) { |
| 5624 |
ref.current = (value) => { |
| 5625 |
this.set(key, value); |
| 5626 |
}; |
| 5627 |
} |
| 5628 |
return ref.current; |
| 5629 |
} |
| 5630 |
/** |
| 5631 |
* Observes changes derived from the store's selectors and calls the listener when the selected value changes. |
| 5632 |
* |
| 5633 |
* @param key Key of the selector to observe. |
| 5634 |
* @param listener Listener function called when the selector result changes. |
| 5635 |
*/ |
| 5636 |
observe(selector, listener) { |
| 5637 |
let selectFn; |
| 5638 |
if (typeof selector === "function") { |
| 5639 |
selectFn = selector; |
| 5640 |
} else { |
| 5641 |
selectFn = this.selectors[selector]; |
| 5642 |
} |
| 5643 |
let prevValue = selectFn(this.state); |
| 5644 |
listener(prevValue, prevValue, this); |
| 5645 |
return this.subscribe((nextState) => { |
| 5646 |
const nextValue = selectFn(nextState); |
| 5647 |
if (!Object.is(prevValue, nextValue)) { |
| 5648 |
const oldValue = prevValue; |
| 5649 |
prevValue = nextValue; |
| 5650 |
listener(nextValue, oldValue, this); |
| 5651 |
} |
| 5652 |
}); |
| 5653 |
} |
| 5654 |
}; |
| 5655 |
|
| 5656 |
// node_modules/@base-ui/react/floating-ui-react/components/FloatingRootStore.mjs |
| 5657 |
var selectors = { |
| 5658 |
open: createSelector2((state) => state.open), |
| 5659 |
transitionStatus: createSelector2((state) => state.transitionStatus), |
| 5660 |
domReferenceElement: createSelector2((state) => state.domReferenceElement), |
| 5661 |
referenceElement: createSelector2((state) => state.positionReference ?? state.referenceElement), |
| 5662 |
floatingElement: createSelector2((state) => state.floatingElement), |
| 5663 |
floatingId: createSelector2((state) => state.floatingId) |
| 5664 |
}; |
| 5665 |
var FloatingRootStore = class extends ReactStore { |
| 5666 |
constructor(options) { |
| 5667 |
const { |
| 5668 |
syncOnly, |
| 5669 |
nested, |
| 5670 |
onOpenChange, |
| 5671 |
triggerElements, |
| 5672 |
...initialState |
| 5673 |
} = options; |
| 5674 |
super({ |
| 5675 |
...initialState, |
| 5676 |
positionReference: initialState.referenceElement, |
| 5677 |
domReferenceElement: initialState.referenceElement |
| 5678 |
}, { |
| 5679 |
onOpenChange, |
| 5680 |
dataRef: { |
| 5681 |
current: {} |
| 5682 |
}, |
| 5683 |
events: createEventEmitter(), |
| 5684 |
nested, |
| 5685 |
triggerElements |
| 5686 |
}, selectors); |
| 5687 |
this.syncOnly = syncOnly; |
| 5688 |
} |
| 5689 |
/** |
| 5690 |
* Syncs the event used by hover logic to distinguish hover-open from click-like interaction. |
| 5691 |
*/ |
| 5692 |
syncOpenEvent = (newOpen, event) => { |
| 5693 |
if (!newOpen || !this.state.open || // Prevent a pending hover-open from overwriting a click-open event, while allowing |
| 5694 |
// click events to upgrade a hover-open. |
| 5695 |
event != null && isClickLikeEvent(event)) { |
| 5696 |
this.context.dataRef.current.openEvent = newOpen ? event : void 0; |
| 5697 |
} |
| 5698 |
}; |
| 5699 |
/** |
| 5700 |
* Runs the root-owned side effects for an open state change. |
| 5701 |
*/ |
| 5702 |
dispatchOpenChange = (newOpen, eventDetails) => { |
| 5703 |
this.syncOpenEvent(newOpen, eventDetails.event); |
| 5704 |
const details = { |
| 5705 |
open: newOpen, |
| 5706 |
reason: eventDetails.reason, |
| 5707 |
nativeEvent: eventDetails.event, |
| 5708 |
nested: this.context.nested, |
| 5709 |
triggerElement: eventDetails.trigger |
| 5710 |
}; |
| 5711 |
this.context.events.emit("openchange", details); |
| 5712 |
}; |
| 5713 |
/** |
| 5714 |
* Emits the `openchange` event through the internal event emitter and calls the `onOpenChange` handler with the provided arguments. |
| 5715 |
* |
| 5716 |
* @param newOpen The new open state. |
| 5717 |
* @param eventDetails Details about the event that triggered the open state change. |
| 5718 |
*/ |
| 5719 |
setOpen = (newOpen, eventDetails) => { |
| 5720 |
if (this.syncOnly) { |
| 5721 |
this.context.onOpenChange?.(newOpen, eventDetails); |
| 5722 |
return; |
| 5723 |
} |
| 5724 |
this.dispatchOpenChange(newOpen, eventDetails); |
| 5725 |
this.context.onOpenChange?.(newOpen, eventDetails); |
| 5726 |
}; |
| 5727 |
}; |
| 5728 |
|
| 5729 |
// node_modules/@base-ui/react/floating-ui-react/hooks/useSyncedFloatingRootContext.mjs |
| 5730 |
function useSyncedFloatingRootContext(options) { |
| 5731 |
const { |
| 5732 |
popupStore, |
| 5733 |
treatPopupAsFloatingElement = false, |
| 5734 |
floatingRootContext: floatingRootContextProp, |
| 5735 |
floatingId, |
| 5736 |
nested, |
| 5737 |
onOpenChange |
| 5738 |
} = options; |
| 5739 |
const open = popupStore.useState("open"); |
| 5740 |
const referenceElement = popupStore.useState("activeTriggerElement"); |
| 5741 |
const floatingElement = popupStore.useState(treatPopupAsFloatingElement ? "popupElement" : "positionerElement"); |
| 5742 |
const triggerElements = popupStore.context.triggerElements; |
| 5743 |
const handleOpenChange = onOpenChange; |
| 5744 |
const internalStoreRef = React23.useRef(null); |
| 5745 |
if (floatingRootContextProp === void 0 && internalStoreRef.current === null) { |
| 5746 |
internalStoreRef.current = new FloatingRootStore({ |
| 5747 |
open, |
| 5748 |
transitionStatus: void 0, |
| 5749 |
referenceElement, |
| 5750 |
floatingElement, |
| 5751 |
triggerElements, |
| 5752 |
onOpenChange: handleOpenChange, |
| 5753 |
floatingId, |
| 5754 |
syncOnly: true, |
| 5755 |
nested |
| 5756 |
}); |
| 5757 |
} |
| 5758 |
const store2 = floatingRootContextProp ?? internalStoreRef.current; |
| 5759 |
popupStore.useSyncedValue("floatingId", floatingId); |
| 5760 |
useIsoLayoutEffect(() => { |
| 5761 |
const valuesToSync = { |
| 5762 |
open, |
| 5763 |
floatingId, |
| 5764 |
referenceElement, |
| 5765 |
floatingElement |
| 5766 |
}; |
| 5767 |
if (isElement(referenceElement)) { |
| 5768 |
valuesToSync.domReferenceElement = referenceElement; |
| 5769 |
} |
| 5770 |
if (store2.state.positionReference === store2.state.referenceElement) { |
| 5771 |
valuesToSync.positionReference = referenceElement; |
| 5772 |
} |
| 5773 |
store2.update(valuesToSync); |
| 5774 |
}, [open, floatingId, referenceElement, floatingElement, store2]); |
| 5775 |
store2.context.onOpenChange = handleOpenChange; |
| 5776 |
store2.context.nested = nested; |
| 5777 |
return store2; |
| 5778 |
} |
| 5779 |
|
| 5780 |
// node_modules/@base-ui/react/utils/popups/popupStoreUtils.mjs |
| 5781 |
var FOCUSABLE_POPUP_PROPS = { |
| 5782 |
tabIndex: -1, |
| 5783 |
[FOCUSABLE_ATTRIBUTE]: "" |
| 5784 |
}; |
| 5785 |
function usePopupStore(externalStore, createStore, treatPopupAsFloatingElement = false) { |
| 5786 |
const floatingId = useId(); |
| 5787 |
const nested = useFloatingParentNodeId() != null; |
| 5788 |
const internalStoreRef = React24.useRef(null); |
| 5789 |
if (externalStore === void 0 && internalStoreRef.current === null) { |
| 5790 |
internalStoreRef.current = createStore(floatingId, nested); |
| 5791 |
} |
| 5792 |
const store2 = externalStore ?? internalStoreRef.current; |
| 5793 |
useSyncedFloatingRootContext({ |
| 5794 |
popupStore: store2, |
| 5795 |
treatPopupAsFloatingElement, |
| 5796 |
floatingRootContext: store2.state.floatingRootContext, |
| 5797 |
floatingId, |
| 5798 |
nested, |
| 5799 |
onOpenChange: store2.setOpen |
| 5800 |
}); |
| 5801 |
return { |
| 5802 |
store: store2, |
| 5803 |
internalStore: internalStoreRef.current |
| 5804 |
}; |
| 5805 |
} |
| 5806 |
function useTriggerRegistration(id, store2) { |
| 5807 |
const registeredElementIdRef = React24.useRef(null); |
| 5808 |
const registeredElementRef = React24.useRef(null); |
| 5809 |
return React24.useCallback((element) => { |
| 5810 |
if (id === void 0) { |
| 5811 |
return; |
| 5812 |
} |
| 5813 |
let shouldSyncTriggerCount = false; |
| 5814 |
if (registeredElementIdRef.current !== null) { |
| 5815 |
const registeredId = registeredElementIdRef.current; |
| 5816 |
const registeredElement = registeredElementRef.current; |
| 5817 |
const currentElement = store2.context.triggerElements.getById(registeredId); |
| 5818 |
if (registeredElement && currentElement === registeredElement) { |
| 5819 |
store2.context.triggerElements.delete(registeredId); |
| 5820 |
shouldSyncTriggerCount = true; |
| 5821 |
} |
| 5822 |
registeredElementIdRef.current = null; |
| 5823 |
registeredElementRef.current = null; |
| 5824 |
} |
| 5825 |
if (element !== null) { |
| 5826 |
registeredElementIdRef.current = id; |
| 5827 |
registeredElementRef.current = element; |
| 5828 |
store2.context.triggerElements.add(id, element); |
| 5829 |
shouldSyncTriggerCount = true; |
| 5830 |
} |
| 5831 |
if (shouldSyncTriggerCount) { |
| 5832 |
const triggerCount = store2.context.triggerElements.size; |
| 5833 |
if (store2.select("open") && store2.state.triggerCount !== triggerCount) { |
| 5834 |
store2.set("triggerCount", triggerCount); |
| 5835 |
} |
| 5836 |
} |
| 5837 |
}, [store2, id]); |
| 5838 |
} |
| 5839 |
function setPopupOpenState(state, open, trigger, preventUnmountOnClose = false) { |
| 5840 |
if (open) { |
| 5841 |
state.preventUnmountingOnClose = false; |
| 5842 |
} else if (preventUnmountOnClose) { |
| 5843 |
state.preventUnmountingOnClose = true; |
| 5844 |
} |
| 5845 |
const triggerId = trigger?.id ?? null; |
| 5846 |
if (triggerId || open) { |
| 5847 |
state.activeTriggerId = triggerId; |
| 5848 |
state.activeTriggerElement = trigger ?? null; |
| 5849 |
} |
| 5850 |
} |
| 5851 |
function attachPreventUnmountOnClose(eventDetails) { |
| 5852 |
let preventUnmountOnClose = false; |
| 5853 |
eventDetails.preventUnmountOnClose = () => { |
| 5854 |
preventUnmountOnClose = true; |
| 5855 |
}; |
| 5856 |
return () => preventUnmountOnClose; |
| 5857 |
} |
| 5858 |
function applyPopupOpenChange(store2, nextOpen, eventDetails, options = {}) { |
| 5859 |
const reason = eventDetails.reason; |
| 5860 |
const isHover = reason === reason_parts_exports.triggerHover; |
| 5861 |
const isFocusOpen = nextOpen && reason === reason_parts_exports.triggerFocus; |
| 5862 |
const isDismissClose = !nextOpen && (reason === reason_parts_exports.triggerPress || reason === reason_parts_exports.escapeKey); |
| 5863 |
const shouldPreventUnmountOnClose = attachPreventUnmountOnClose(eventDetails); |
| 5864 |
store2.context.onOpenChange?.(nextOpen, eventDetails); |
| 5865 |
if (eventDetails.isCanceled) { |
| 5866 |
return; |
| 5867 |
} |
| 5868 |
options.onBeforeDispatch?.(); |
| 5869 |
store2.state.floatingRootContext.dispatchOpenChange(nextOpen, eventDetails); |
| 5870 |
const changeState = () => { |
| 5871 |
const updatedState = { |
| 5872 |
...options.extraState, |
| 5873 |
open: nextOpen |
| 5874 |
}; |
| 5875 |
if (isFocusOpen) { |
| 5876 |
updatedState.instantType = "focus"; |
| 5877 |
} else if (isDismissClose) { |
| 5878 |
updatedState.instantType = "dismiss"; |
| 5879 |
} else if (isHover) { |
| 5880 |
updatedState.instantType = void 0; |
| 5881 |
} |
| 5882 |
setPopupOpenState(updatedState, nextOpen, eventDetails.trigger, shouldPreventUnmountOnClose()); |
| 5883 |
store2.update(updatedState); |
| 5884 |
}; |
| 5885 |
if (isHover) { |
| 5886 |
ReactDOM4.flushSync(changeState); |
| 5887 |
} else { |
| 5888 |
changeState(); |
| 5889 |
} |
| 5890 |
} |
| 5891 |
function useInitialOpenSync(store2, openProp, defaultOpen, defaultTriggerId) { |
| 5892 |
useOnFirstRender(() => { |
| 5893 |
if (openProp === void 0 && store2.state.open === false && defaultOpen) { |
| 5894 |
store2.state = { |
| 5895 |
...store2.state, |
| 5896 |
open: true, |
| 5897 |
activeTriggerId: defaultTriggerId, |
| 5898 |
preventUnmountingOnClose: false |
| 5899 |
}; |
| 5900 |
} |
| 5901 |
}); |
| 5902 |
} |
| 5903 |
function useTriggerDataForwarding(triggerId, triggerElementRef, store2, stateUpdates) { |
| 5904 |
const isMountedByThisTrigger = store2.useState("isMountedByTrigger", triggerId); |
| 5905 |
const baseRegisterTrigger = useTriggerRegistration(triggerId, store2); |
| 5906 |
const registerTrigger = useStableCallback((element) => { |
| 5907 |
baseRegisterTrigger(element); |
| 5908 |
if (!element) { |
| 5909 |
return; |
| 5910 |
} |
| 5911 |
const open = store2.select("open"); |
| 5912 |
const activeTriggerId = store2.select("activeTriggerId"); |
| 5913 |
if (activeTriggerId === triggerId) { |
| 5914 |
store2.update({ |
| 5915 |
activeTriggerElement: element, |
| 5916 |
...open ? stateUpdates : null |
| 5917 |
}); |
| 5918 |
return; |
| 5919 |
} |
| 5920 |
if (activeTriggerId == null && open) { |
| 5921 |
store2.update({ |
| 5922 |
activeTriggerId: triggerId, |
| 5923 |
activeTriggerElement: element, |
| 5924 |
...stateUpdates |
| 5925 |
}); |
| 5926 |
} |
| 5927 |
}); |
| 5928 |
useIsoLayoutEffect(() => { |
| 5929 |
if (isMountedByThisTrigger) { |
| 5930 |
store2.update({ |
| 5931 |
activeTriggerElement: triggerElementRef.current, |
| 5932 |
...stateUpdates |
| 5933 |
}); |
| 5934 |
} |
| 5935 |
}, [isMountedByThisTrigger, store2, triggerElementRef, ...Object.values(stateUpdates)]); |
| 5936 |
return { |
| 5937 |
registerTrigger, |
| 5938 |
isMountedByThisTrigger |
| 5939 |
}; |
| 5940 |
} |
| 5941 |
function useImplicitActiveTrigger(store2, options = {}) { |
| 5942 |
const { |
| 5943 |
closeOnActiveTriggerUnmount = false |
| 5944 |
} = options; |
| 5945 |
const open = store2.useState("open"); |
| 5946 |
const reactiveTriggerCount = store2.useState("triggerCount"); |
| 5947 |
useIsoLayoutEffect(() => { |
| 5948 |
if (!open) { |
| 5949 |
if (store2.state.triggerCount !== 0) { |
| 5950 |
store2.set("triggerCount", 0); |
| 5951 |
} |
| 5952 |
return; |
| 5953 |
} |
| 5954 |
const triggerCount = store2.context.triggerElements.size; |
| 5955 |
const stateUpdates = {}; |
| 5956 |
if (store2.state.triggerCount !== triggerCount) { |
| 5957 |
stateUpdates.triggerCount = triggerCount; |
| 5958 |
} |
| 5959 |
const activeTriggerId = store2.select("activeTriggerId"); |
| 5960 |
let lostActiveTriggerId = null; |
| 5961 |
if (activeTriggerId) { |
| 5962 |
const activeTriggerElement = store2.context.triggerElements.getById(activeTriggerId); |
| 5963 |
if (!activeTriggerElement) { |
| 5964 |
lostActiveTriggerId = activeTriggerId; |
| 5965 |
} else if (activeTriggerElement !== store2.state.activeTriggerElement) { |
| 5966 |
stateUpdates.activeTriggerElement = activeTriggerElement; |
| 5967 |
} |
| 5968 |
} |
| 5969 |
if (!lostActiveTriggerId && !activeTriggerId && triggerCount === 1) { |
| 5970 |
const iteratorResult = store2.context.triggerElements.entries().next(); |
| 5971 |
if (!iteratorResult.done) { |
| 5972 |
const [implicitTriggerId, implicitTriggerElement] = iteratorResult.value; |
| 5973 |
stateUpdates.activeTriggerId = implicitTriggerId; |
| 5974 |
stateUpdates.activeTriggerElement = implicitTriggerElement; |
| 5975 |
} |
| 5976 |
} |
| 5977 |
if (stateUpdates.triggerCount !== void 0 || stateUpdates.activeTriggerId !== void 0 || stateUpdates.activeTriggerElement !== void 0) { |
| 5978 |
store2.update(stateUpdates); |
| 5979 |
} |
| 5980 |
if (lostActiveTriggerId) { |
| 5981 |
if (closeOnActiveTriggerUnmount) { |
| 5982 |
queueMicrotask(() => { |
| 5983 |
if (store2.select("open") && store2.select("activeTriggerId") === lostActiveTriggerId && !store2.context.triggerElements.getById(lostActiveTriggerId)) { |
| 5984 |
const eventDetails = createChangeEventDetails(reason_parts_exports.none); |
| 5985 |
store2.setOpen(false, eventDetails); |
| 5986 |
if (!eventDetails.isCanceled) { |
| 5987 |
store2.update({ |
| 5988 |
activeTriggerId: null, |
| 5989 |
activeTriggerElement: null |
| 5990 |
}); |
| 5991 |
} |
| 5992 |
} |
| 5993 |
}); |
| 5994 |
} |
| 5995 |
} |
| 5996 |
}, [open, store2, reactiveTriggerCount, closeOnActiveTriggerUnmount]); |
| 5997 |
} |
| 5998 |
function useOpenStateTransitions(open, store2, onUnmount) { |
| 5999 |
const { |
| 6000 |
mounted, |
| 6001 |
setMounted, |
| 6002 |
transitionStatus |
| 6003 |
} = useTransitionStatus(open); |
| 6004 |
const preventUnmountingOnClose = store2.useState("preventUnmountingOnClose"); |
| 6005 |
const syncedPreventUnmountingOnClose = open ? false : preventUnmountingOnClose; |
| 6006 |
store2.useSyncedValues({ |
| 6007 |
mounted, |
| 6008 |
transitionStatus, |
| 6009 |
preventUnmountingOnClose: syncedPreventUnmountingOnClose |
| 6010 |
}); |
| 6011 |
const forceUnmount = useStableCallback(() => { |
| 6012 |
setMounted(false); |
| 6013 |
store2.update({ |
| 6014 |
activeTriggerId: null, |
| 6015 |
activeTriggerElement: null, |
| 6016 |
mounted: false, |
| 6017 |
preventUnmountingOnClose: false |
| 6018 |
}); |
| 6019 |
onUnmount?.(); |
| 6020 |
store2.context.onOpenChangeComplete?.(false); |
| 6021 |
}); |
| 6022 |
useOpenChangeComplete({ |
| 6023 |
enabled: mounted && !open && !syncedPreventUnmountingOnClose, |
| 6024 |
open, |
| 6025 |
ref: store2.context.popupRef, |
| 6026 |
onComplete() { |
| 6027 |
if (!open) { |
| 6028 |
forceUnmount(); |
| 6029 |
} |
| 6030 |
} |
| 6031 |
}); |
| 6032 |
return { |
| 6033 |
forceUnmount, |
| 6034 |
transitionStatus |
| 6035 |
}; |
| 6036 |
} |
| 6037 |
function usePopupInteractionProps(store2, statePart) { |
| 6038 |
store2.useSyncedValues(statePart); |
| 6039 |
useIsoLayoutEffect(() => () => { |
| 6040 |
store2.update({ |
| 6041 |
activeTriggerProps: EMPTY_OBJECT, |
| 6042 |
inactiveTriggerProps: EMPTY_OBJECT, |
| 6043 |
popupProps: EMPTY_OBJECT |
| 6044 |
}); |
| 6045 |
}, [store2]); |
| 6046 |
} |
| 6047 |
|
| 6048 |
// node_modules/@base-ui/react/utils/popups/popupTriggerMap.mjs |
| 6049 |
var PopupTriggerMap = class { |
| 6050 |
constructor() { |
| 6051 |
this.elementsSet = /* @__PURE__ */ new Set(); |
| 6052 |
this.idMap = /* @__PURE__ */ new Map(); |
| 6053 |
} |
| 6054 |
/** |
| 6055 |
* Adds a trigger element with the given ID. |
| 6056 |
* |
| 6057 |
* Note: The provided element is assumed to not be registered under multiple IDs. |
| 6058 |
*/ |
| 6059 |
add(id, element) { |
| 6060 |
const existingElement = this.idMap.get(id); |
| 6061 |
if (existingElement === element) { |
| 6062 |
return; |
| 6063 |
} |
| 6064 |
if (existingElement !== void 0) { |
| 6065 |
this.elementsSet.delete(existingElement); |
| 6066 |
} |
| 6067 |
this.elementsSet.add(element); |
| 6068 |
this.idMap.set(id, element); |
| 6069 |
if (true) { |
| 6070 |
if (this.elementsSet.size !== this.idMap.size) { |
| 6071 |
throw new Error("Base UI: A trigger element cannot be registered under multiple IDs in PopupTriggerMap."); |
| 6072 |
} |
| 6073 |
} |
| 6074 |
} |
| 6075 |
/** |
| 6076 |
* Removes the trigger element with the given ID. |
| 6077 |
*/ |
| 6078 |
delete(id) { |
| 6079 |
const element = this.idMap.get(id); |
| 6080 |
if (element) { |
| 6081 |
this.elementsSet.delete(element); |
| 6082 |
this.idMap.delete(id); |
| 6083 |
} |
| 6084 |
} |
| 6085 |
/** |
| 6086 |
* Whether the given element is registered as a trigger. |
| 6087 |
*/ |
| 6088 |
hasElement(element) { |
| 6089 |
return this.elementsSet.has(element); |
| 6090 |
} |
| 6091 |
/** |
| 6092 |
* Whether there is a registered trigger element matching the given predicate. |
| 6093 |
*/ |
| 6094 |
hasMatchingElement(predicate) { |
| 6095 |
for (const element of this.elementsSet) { |
| 6096 |
if (predicate(element)) { |
| 6097 |
return true; |
| 6098 |
} |
| 6099 |
} |
| 6100 |
return false; |
| 6101 |
} |
| 6102 |
/** |
| 6103 |
* Returns the trigger element associated with the given ID, or undefined if no such element exists. |
| 6104 |
*/ |
| 6105 |
getById(id) { |
| 6106 |
return this.idMap.get(id); |
| 6107 |
} |
| 6108 |
/** |
| 6109 |
* Returns an iterable of all registered trigger entries, where each entry is a tuple of [id, element]. |
| 6110 |
*/ |
| 6111 |
entries() { |
| 6112 |
return this.idMap.entries(); |
| 6113 |
} |
| 6114 |
/** |
| 6115 |
* Returns an iterable of all registered trigger elements. |
| 6116 |
*/ |
| 6117 |
elements() { |
| 6118 |
return this.elementsSet.values(); |
| 6119 |
} |
| 6120 |
/** |
| 6121 |
* Returns the number of registered trigger elements. |
| 6122 |
*/ |
| 6123 |
get size() { |
| 6124 |
return this.idMap.size; |
| 6125 |
} |
| 6126 |
}; |
| 6127 |
|
| 6128 |
// node_modules/@base-ui/react/floating-ui-react/utils/getEmptyRootContext.mjs |
| 6129 |
function getEmptyRootContext() { |
| 6130 |
return new FloatingRootStore({ |
| 6131 |
open: false, |
| 6132 |
transitionStatus: void 0, |
| 6133 |
floatingElement: null, |
| 6134 |
referenceElement: null, |
| 6135 |
triggerElements: new PopupTriggerMap(), |
| 6136 |
floatingId: void 0, |
| 6137 |
syncOnly: false, |
| 6138 |
nested: false, |
| 6139 |
onOpenChange: void 0 |
| 6140 |
}); |
| 6141 |
} |
| 6142 |
|
| 6143 |
// node_modules/@base-ui/react/utils/popups/store.mjs |
| 6144 |
function createInitialPopupStoreState() { |
| 6145 |
return { |
| 6146 |
open: false, |
| 6147 |
openProp: void 0, |
| 6148 |
mounted: false, |
| 6149 |
transitionStatus: void 0, |
| 6150 |
floatingRootContext: getEmptyRootContext(), |
| 6151 |
floatingId: void 0, |
| 6152 |
triggerCount: 0, |
| 6153 |
preventUnmountingOnClose: false, |
| 6154 |
payload: void 0, |
| 6155 |
activeTriggerId: null, |
| 6156 |
activeTriggerElement: null, |
| 6157 |
triggerIdProp: void 0, |
| 6158 |
popupElement: null, |
| 6159 |
positionerElement: null, |
| 6160 |
activeTriggerProps: EMPTY_OBJECT, |
| 6161 |
inactiveTriggerProps: EMPTY_OBJECT, |
| 6162 |
popupProps: EMPTY_OBJECT |
| 6163 |
}; |
| 6164 |
} |
| 6165 |
function createPopupFloatingRootContext(triggerElements, floatingId, nested = false) { |
| 6166 |
return new FloatingRootStore({ |
| 6167 |
open: false, |
| 6168 |
transitionStatus: void 0, |
| 6169 |
floatingElement: null, |
| 6170 |
referenceElement: null, |
| 6171 |
triggerElements, |
| 6172 |
floatingId, |
| 6173 |
syncOnly: true, |
| 6174 |
nested, |
| 6175 |
onOpenChange: void 0 |
| 6176 |
}); |
| 6177 |
} |
| 6178 |
var activeTriggerIdSelector = createSelector2((state) => state.triggerIdProp ?? state.activeTriggerId); |
| 6179 |
var openSelector = createSelector2((state) => state.openProp ?? state.open); |
| 6180 |
var popupIdSelector = createSelector2((state) => { |
| 6181 |
const popupId = state.popupElement?.id ?? state.floatingId; |
| 6182 |
return popupId || void 0; |
| 6183 |
}); |
| 6184 |
function triggerOwnsOpenPopup(state, triggerId) { |
| 6185 |
return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) === triggerId; |
| 6186 |
} |
| 6187 |
function triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) { |
| 6188 |
if (triggerOwnsOpenPopup(state, triggerId)) { |
| 6189 |
return true; |
| 6190 |
} |
| 6191 |
return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) == null && state.triggerCount === 1; |
| 6192 |
} |
| 6193 |
var popupStoreSelectors = { |
| 6194 |
open: openSelector, |
| 6195 |
mounted: createSelector2((state) => state.mounted), |
| 6196 |
transitionStatus: createSelector2((state) => state.transitionStatus), |
| 6197 |
floatingRootContext: createSelector2((state) => state.floatingRootContext), |
| 6198 |
triggerCount: createSelector2((state) => state.triggerCount), |
| 6199 |
preventUnmountingOnClose: createSelector2((state) => state.preventUnmountingOnClose), |
| 6200 |
payload: createSelector2((state) => state.payload), |
| 6201 |
activeTriggerId: activeTriggerIdSelector, |
| 6202 |
activeTriggerElement: createSelector2((state) => state.mounted ? state.activeTriggerElement : null), |
| 6203 |
popupId: popupIdSelector, |
| 6204 |
/** |
| 6205 |
* Whether the trigger with the given ID was used to open the popup. |
| 6206 |
*/ |
| 6207 |
isTriggerActive: createSelector2((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId), |
| 6208 |
/** |
| 6209 |
* Whether the popup is open and was activated by a trigger with the given ID. |
| 6210 |
*/ |
| 6211 |
isOpenedByTrigger: createSelector2((state, triggerId) => triggerOwnsOpenPopup(state, triggerId)), |
| 6212 |
/** |
| 6213 |
* Whether the popup is mounted and was activated by a trigger with the given ID. |
| 6214 |
*/ |
| 6215 |
isMountedByTrigger: createSelector2((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId && state.mounted), |
| 6216 |
triggerProps: createSelector2((state, isActive) => isActive ? state.activeTriggerProps : state.inactiveTriggerProps), |
| 6217 |
/** |
| 6218 |
* Popup id for the trigger that currently owns the open popup. |
| 6219 |
*/ |
| 6220 |
triggerPopupId: createSelector2((state, triggerId) => triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) ? popupIdSelector(state) : void 0), |
| 6221 |
popupProps: createSelector2((state) => state.popupProps), |
| 6222 |
popupElement: createSelector2((state) => state.popupElement), |
| 6223 |
positionerElement: createSelector2((state) => state.positionerElement) |
| 6224 |
}; |
| 6225 |
|
| 6226 |
// node_modules/@base-ui/react/floating-ui-react/hooks/useFloatingRootContext.mjs |
| 6227 |
function useFloatingRootContext(options) { |
| 6228 |
const { |
| 6229 |
open = false, |
| 6230 |
onOpenChange, |
| 6231 |
elements = {} |
| 6232 |
} = options; |
| 6233 |
const floatingId = useId(); |
| 6234 |
const nested = useFloatingParentNodeId() != null; |
| 6235 |
if (true) { |
| 6236 |
const optionDomReference = elements.reference; |
| 6237 |
if (optionDomReference && !isElement(optionDomReference)) { |
| 6238 |
console.error("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `context.setPositionReference()`", "instead."); |
| 6239 |
} |
| 6240 |
} |
| 6241 |
const store2 = useRefWithInit(() => new FloatingRootStore({ |
| 6242 |
open, |
| 6243 |
transitionStatus: void 0, |
| 6244 |
onOpenChange, |
| 6245 |
referenceElement: elements.reference ?? null, |
| 6246 |
floatingElement: elements.floating ?? null, |
| 6247 |
triggerElements: new PopupTriggerMap(), |
| 6248 |
floatingId, |
| 6249 |
syncOnly: false, |
| 6250 |
nested |
| 6251 |
})).current; |
| 6252 |
useIsoLayoutEffect(() => { |
| 6253 |
const valuesToSync = { |
| 6254 |
open, |
| 6255 |
floatingId |
| 6256 |
}; |
| 6257 |
if (elements.reference !== void 0) { |
| 6258 |
valuesToSync.referenceElement = elements.reference; |
| 6259 |
valuesToSync.domReferenceElement = isElement(elements.reference) ? elements.reference : null; |
| 6260 |
} |
| 6261 |
if (elements.floating !== void 0) { |
| 6262 |
valuesToSync.floatingElement = elements.floating; |
| 6263 |
} |
| 6264 |
store2.update(valuesToSync); |
| 6265 |
}, [open, floatingId, elements.reference, elements.floating, store2]); |
| 6266 |
store2.context.onOpenChange = onOpenChange; |
| 6267 |
store2.context.nested = nested; |
| 6268 |
return store2; |
| 6269 |
} |
| 6270 |
|
| 6271 |
// node_modules/@base-ui/react/floating-ui-react/hooks/useFloating.mjs |
| 6272 |
function useFloating2(options = {}) { |
| 6273 |
const { |
| 6274 |
nodeId, |
| 6275 |
externalTree |
| 6276 |
} = options; |
| 6277 |
const internalStore = useFloatingRootContext(options); |
| 6278 |
const store2 = options.rootContext || internalStore; |
| 6279 |
const referenceElement = store2.useState("referenceElement"); |
| 6280 |
const floatingElement = store2.useState("floatingElement"); |
| 6281 |
const domReferenceElement = store2.useState("domReferenceElement"); |
| 6282 |
const open = store2.useState("open"); |
| 6283 |
const floatingId = store2.useState("floatingId"); |
| 6284 |
const [positionReference, setPositionReferenceRaw] = React25.useState(null); |
| 6285 |
const [localDomReference, setLocalDomReference] = React25.useState(void 0); |
| 6286 |
const [localFloatingElement, setLocalFloatingElement] = React25.useState(void 0); |
| 6287 |
const domReferenceRef = React25.useRef(null); |
| 6288 |
const tree = useFloatingTree(externalTree); |
| 6289 |
const storeElements = React25.useMemo(() => ({ |
| 6290 |
reference: referenceElement, |
| 6291 |
floating: floatingElement, |
| 6292 |
domReference: domReferenceElement |
| 6293 |
}), [referenceElement, floatingElement, domReferenceElement]); |
| 6294 |
const position = useFloating({ |
| 6295 |
...options, |
| 6296 |
elements: { |
| 6297 |
...storeElements, |
| 6298 |
...positionReference && { |
| 6299 |
reference: positionReference |
| 6300 |
} |
| 6301 |
} |
| 6302 |
}); |
| 6303 |
const localDomReferenceElement = isElement(localDomReference) ? localDomReference : null; |
| 6304 |
const syncedFloatingElement = localFloatingElement === void 0 ? store2.state.floatingElement : localFloatingElement; |
| 6305 |
store2.useSyncedValue("referenceElement", localDomReference ?? null); |
| 6306 |
store2.useSyncedValue("domReferenceElement", localDomReference === void 0 ? domReferenceElement : localDomReferenceElement); |
| 6307 |
store2.useSyncedValue("floatingElement", syncedFloatingElement); |
| 6308 |
const setPositionReference = React25.useCallback((node) => { |
| 6309 |
const computedPositionReference = isElement(node) ? { |
| 6310 |
getBoundingClientRect: () => node.getBoundingClientRect(), |
| 6311 |
getClientRects: () => node.getClientRects(), |
| 6312 |
contextElement: node |
| 6313 |
} : node; |
| 6314 |
setPositionReferenceRaw(computedPositionReference); |
| 6315 |
position.refs.setReference(computedPositionReference); |
| 6316 |
}, [position.refs]); |
| 6317 |
const setReference = React25.useCallback((node) => { |
| 6318 |
if (isElement(node) || node === null) { |
| 6319 |
domReferenceRef.current = node; |
| 6320 |
setLocalDomReference(node); |
| 6321 |
} |
| 6322 |
if (isElement(position.refs.reference.current) || position.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to |
| 6323 |
// `null` to support `positionReference` + an unstable `reference` |
| 6324 |
// callback ref. |
| 6325 |
node !== null && !isElement(node)) { |
| 6326 |
position.refs.setReference(node); |
| 6327 |
} |
| 6328 |
}, [position.refs, setLocalDomReference]); |
| 6329 |
const setFloating = React25.useCallback((node) => { |
| 6330 |
setLocalFloatingElement(node); |
| 6331 |
position.refs.setFloating(node); |
| 6332 |
}, [position.refs]); |
| 6333 |
const refs = React25.useMemo(() => ({ |
| 6334 |
...position.refs, |
| 6335 |
setReference, |
| 6336 |
setFloating, |
| 6337 |
setPositionReference, |
| 6338 |
domReference: domReferenceRef |
| 6339 |
}), [position.refs, setReference, setFloating, setPositionReference]); |
| 6340 |
const elements = React25.useMemo(() => ({ |
| 6341 |
...position.elements, |
| 6342 |
domReference: domReferenceElement |
| 6343 |
}), [position.elements, domReferenceElement]); |
| 6344 |
const context = React25.useMemo(() => ({ |
| 6345 |
...position, |
| 6346 |
dataRef: store2.context.dataRef, |
| 6347 |
open, |
| 6348 |
onOpenChange: store2.setOpen, |
| 6349 |
events: store2.context.events, |
| 6350 |
floatingId, |
| 6351 |
refs, |
| 6352 |
elements, |
| 6353 |
nodeId, |
| 6354 |
rootStore: store2 |
| 6355 |
}), [position, refs, elements, nodeId, store2, open, floatingId]); |
| 6356 |
useIsoLayoutEffect(() => { |
| 6357 |
if (domReferenceElement) { |
| 6358 |
domReferenceRef.current = domReferenceElement; |
| 6359 |
} |
| 6360 |
}, [domReferenceElement]); |
| 6361 |
useIsoLayoutEffect(() => { |
| 6362 |
store2.context.dataRef.current.floatingContext = context; |
| 6363 |
const node = tree?.nodesRef.current.find((n) => n.id === nodeId); |
| 6364 |
if (node) { |
| 6365 |
node.context = context; |
| 6366 |
} |
| 6367 |
}); |
| 6368 |
return React25.useMemo(() => ({ |
| 6369 |
...position, |
| 6370 |
context, |
| 6371 |
refs, |
| 6372 |
elements, |
| 6373 |
rootStore: store2 |
| 6374 |
}), [position, refs, elements, context, store2]); |
| 6375 |
} |
| 6376 |
|
| 6377 |
// node_modules/@base-ui/react/floating-ui-react/hooks/useFocus.mjs |
| 6378 |
var React26 = __toESM(require_react(), 1); |
| 6379 |
var isMacSafari = parts_exports.os.mac && parts_exports.engine.webkit; |
| 6380 |
function useFocus(context, props = {}) { |
| 6381 |
const { |
| 6382 |
enabled = true, |
| 6383 |
delay |
| 6384 |
} = props; |
| 6385 |
const store2 = "rootStore" in context ? context.rootStore : context; |
| 6386 |
const { |
| 6387 |
events, |
| 6388 |
dataRef |
| 6389 |
} = store2.context; |
| 6390 |
const blockFocusRef = React26.useRef(false); |
| 6391 |
const blockedReferenceRef = React26.useRef(null); |
| 6392 |
const keyboardModalityRef = React26.useRef(true); |
| 6393 |
const timeout = useTimeout(); |
| 6394 |
React26.useEffect(() => { |
| 6395 |
const domReference = store2.select("domReferenceElement"); |
| 6396 |
if (!enabled) { |
| 6397 |
return void 0; |
| 6398 |
} |
| 6399 |
const win = getWindow(domReference); |
| 6400 |
function onBlur() { |
| 6401 |
const currentDomReference = store2.select("domReferenceElement"); |
| 6402 |
if (!store2.select("open") && isHTMLElement(currentDomReference) && currentDomReference === activeElement(ownerDocument(currentDomReference))) { |
| 6403 |
blockFocusRef.current = true; |
| 6404 |
} |
| 6405 |
} |
| 6406 |
function onKeyDown() { |
| 6407 |
keyboardModalityRef.current = true; |
| 6408 |
} |
| 6409 |
function onPointerDown() { |
| 6410 |
keyboardModalityRef.current = false; |
| 6411 |
} |
| 6412 |
return mergeCleanups(addEventListener(win, "blur", onBlur), isMacSafari && addEventListener(win, "keydown", onKeyDown, true), isMacSafari && addEventListener(win, "pointerdown", onPointerDown, true)); |
| 6413 |
}, [store2, enabled]); |
| 6414 |
React26.useEffect(() => { |
| 6415 |
if (!enabled) { |
| 6416 |
return void 0; |
| 6417 |
} |
| 6418 |
function onOpenChangeLocal(details) { |
| 6419 |
if (details.reason === reason_parts_exports.triggerPress || details.reason === reason_parts_exports.escapeKey) { |
| 6420 |
const referenceElement = store2.select("domReferenceElement"); |
| 6421 |
if (isElement(referenceElement)) { |
| 6422 |
blockedReferenceRef.current = referenceElement; |
| 6423 |
blockFocusRef.current = true; |
| 6424 |
} |
| 6425 |
} |
| 6426 |
} |
| 6427 |
events.on("openchange", onOpenChangeLocal); |
| 6428 |
return () => { |
| 6429 |
events.off("openchange", onOpenChangeLocal); |
| 6430 |
}; |
| 6431 |
}, [events, enabled, store2]); |
| 6432 |
const reference = React26.useMemo(() => { |
| 6433 |
function resetBlockedFocus() { |
| 6434 |
blockFocusRef.current = false; |
| 6435 |
blockedReferenceRef.current = null; |
| 6436 |
} |
| 6437 |
return { |
| 6438 |
onMouseLeave() { |
| 6439 |
resetBlockedFocus(); |
| 6440 |
}, |
| 6441 |
onFocus(event) { |
| 6442 |
const focusTarget = event.currentTarget; |
| 6443 |
if (blockFocusRef.current) { |
| 6444 |
if (blockedReferenceRef.current === focusTarget) { |
| 6445 |
return; |
| 6446 |
} |
| 6447 |
resetBlockedFocus(); |
| 6448 |
} |
| 6449 |
const target = getTarget(event.nativeEvent); |
| 6450 |
if (isElement(target)) { |
| 6451 |
if (isMacSafari && !event.relatedTarget) { |
| 6452 |
if (!keyboardModalityRef.current && !isTypeableElement(target)) { |
| 6453 |
return; |
| 6454 |
} |
| 6455 |
} else if (!matchesFocusVisible(target)) { |
| 6456 |
return; |
| 6457 |
} |
| 6458 |
} |
| 6459 |
const movedFromOtherEnabledTrigger = isTargetInsideEnabledTrigger(event.relatedTarget, store2.context.triggerElements); |
| 6460 |
const { |
| 6461 |
nativeEvent, |
| 6462 |
currentTarget |
| 6463 |
} = event; |
| 6464 |
const delayValue = typeof delay === "function" ? delay() : delay; |
| 6465 |
if (store2.select("open") && movedFromOtherEnabledTrigger || delayValue === 0 || delayValue === void 0) { |
| 6466 |
store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget)); |
| 6467 |
return; |
| 6468 |
} |
| 6469 |
timeout.start(delayValue, () => { |
| 6470 |
if (blockFocusRef.current) { |
| 6471 |
return; |
| 6472 |
} |
| 6473 |
store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget)); |
| 6474 |
}); |
| 6475 |
}, |
| 6476 |
onBlur(event) { |
| 6477 |
resetBlockedFocus(); |
| 6478 |
const relatedTarget = event.relatedTarget; |
| 6479 |
const nativeEvent = event.nativeEvent; |
| 6480 |
const movedToFocusGuard = isElement(relatedTarget) && relatedTarget.hasAttribute(createAttribute("focus-guard")) && relatedTarget.getAttribute("data-type") === "outside"; |
| 6481 |
timeout.start(0, () => { |
| 6482 |
const domReference = store2.select("domReferenceElement"); |
| 6483 |
const activeEl = activeElement(ownerDocument(domReference)); |
| 6484 |
if (!relatedTarget && activeEl === domReference) { |
| 6485 |
return; |
| 6486 |
} |
| 6487 |
if (contains(dataRef.current.floatingContext?.refs.floating.current, activeEl) || contains(domReference, activeEl) || movedToFocusGuard) { |
| 6488 |
return; |
| 6489 |
} |
| 6490 |
const nextFocusedElement = relatedTarget ?? activeEl; |
| 6491 |
if (isTargetInsideEnabledTrigger(nextFocusedElement, store2.context.triggerElements)) { |
| 6492 |
return; |
| 6493 |
} |
| 6494 |
store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent)); |
| 6495 |
}); |
| 6496 |
} |
| 6497 |
}; |
| 6498 |
}, [dataRef, delay, store2, timeout]); |
| 6499 |
return React26.useMemo(() => enabled ? { |
| 6500 |
reference, |
| 6501 |
trigger: reference |
| 6502 |
} : {}, [enabled, reference]); |
| 6503 |
} |
| 6504 |
|
| 6505 |
// node_modules/@base-ui/react/floating-ui-react/hooks/useHoverFloatingInteraction.mjs |
| 6506 |
var React27 = __toESM(require_react(), 1); |
| 6507 |
|
| 6508 |
// node_modules/@base-ui/react/floating-ui-react/hooks/useHoverInteractionSharedState.mjs |
| 6509 |
var HoverInteraction = class _HoverInteraction { |
| 6510 |
constructor() { |
| 6511 |
this.pointerType = void 0; |
| 6512 |
this.interactedInside = false; |
| 6513 |
this.handler = void 0; |
| 6514 |
this.blockMouseMove = true; |
| 6515 |
this.performedPointerEventsMutation = false; |
| 6516 |
this.pointerEventsScopeElement = null; |
| 6517 |
this.pointerEventsReferenceElement = null; |
| 6518 |
this.pointerEventsFloatingElement = null; |
| 6519 |
this.restTimeoutPending = false; |
| 6520 |
this.openChangeTimeout = new Timeout(); |
| 6521 |
this.restTimeout = new Timeout(); |
| 6522 |
this.handleCloseOptions = void 0; |
| 6523 |
} |
| 6524 |
static create() { |
| 6525 |
return new _HoverInteraction(); |
| 6526 |
} |
| 6527 |
dispose = () => { |
| 6528 |
this.openChangeTimeout.clear(); |
| 6529 |
this.restTimeout.clear(); |
| 6530 |
}; |
| 6531 |
disposeEffect = () => { |
| 6532 |
return this.dispose; |
| 6533 |
}; |
| 6534 |
}; |
| 6535 |
var pointerEventsMutationOwnerByScopeElement = /* @__PURE__ */ new WeakMap(); |
| 6536 |
function clearSafePolygonPointerEventsMutation(instance) { |
| 6537 |
if (!instance.performedPointerEventsMutation) { |
| 6538 |
return; |
| 6539 |
} |
| 6540 |
const scopeElement = instance.pointerEventsScopeElement; |
| 6541 |
if (scopeElement && pointerEventsMutationOwnerByScopeElement.get(scopeElement) === instance) { |
| 6542 |
instance.pointerEventsScopeElement?.style.removeProperty("pointer-events"); |
| 6543 |
instance.pointerEventsReferenceElement?.style.removeProperty("pointer-events"); |
| 6544 |
instance.pointerEventsFloatingElement?.style.removeProperty("pointer-events"); |
| 6545 |
pointerEventsMutationOwnerByScopeElement.delete(scopeElement); |
| 6546 |
} |
| 6547 |
instance.performedPointerEventsMutation = false; |
| 6548 |
instance.pointerEventsScopeElement = null; |
| 6549 |
instance.pointerEventsReferenceElement = null; |
| 6550 |
instance.pointerEventsFloatingElement = null; |
| 6551 |
} |
| 6552 |
function applySafePolygonPointerEventsMutation(instance, options) { |
| 6553 |
const { |
| 6554 |
scopeElement, |
| 6555 |
referenceElement, |
| 6556 |
floatingElement |
| 6557 |
} = options; |
| 6558 |
const existingOwner = pointerEventsMutationOwnerByScopeElement.get(scopeElement); |
| 6559 |
if (existingOwner && existingOwner !== instance) { |
| 6560 |
clearSafePolygonPointerEventsMutation(existingOwner); |
| 6561 |
} |
| 6562 |
clearSafePolygonPointerEventsMutation(instance); |
| 6563 |
instance.performedPointerEventsMutation = true; |
| 6564 |
instance.pointerEventsScopeElement = scopeElement; |
| 6565 |
instance.pointerEventsReferenceElement = referenceElement; |
| 6566 |
instance.pointerEventsFloatingElement = floatingElement; |
| 6567 |
pointerEventsMutationOwnerByScopeElement.set(scopeElement, instance); |
| 6568 |
scopeElement.style.pointerEvents = "none"; |
| 6569 |
referenceElement.style.pointerEvents = "auto"; |
| 6570 |
floatingElement.style.pointerEvents = "auto"; |
| 6571 |
} |
| 6572 |
function useHoverInteractionSharedState(store2) { |
| 6573 |
const data = store2.context.dataRef.current; |
| 6574 |
const instance = useRefWithInit(() => data.hoverInteractionState ?? HoverInteraction.create()).current; |
| 6575 |
if (!data.hoverInteractionState) { |
| 6576 |
data.hoverInteractionState = instance; |
| 6577 |
} |
| 6578 |
useOnMount(data.hoverInteractionState.disposeEffect); |
| 6579 |
return data.hoverInteractionState; |
| 6580 |
} |
| 6581 |
|
| 6582 |
// node_modules/@base-ui/react/floating-ui-react/hooks/useHoverFloatingInteraction.mjs |
| 6583 |
function useHoverFloatingInteraction(context, parameters = {}) { |
| 6584 |
const { |
| 6585 |
enabled = true, |
| 6586 |
closeDelay: closeDelayProp = 0, |
| 6587 |
nodeId: nodeIdProp |
| 6588 |
} = parameters; |
| 6589 |
const store2 = "rootStore" in context ? context.rootStore : context; |
| 6590 |
const open = store2.useState("open"); |
| 6591 |
const floatingElement = store2.useState("floatingElement"); |
| 6592 |
const domReferenceElement = store2.useState("domReferenceElement"); |
| 6593 |
const { |
| 6594 |
dataRef |
| 6595 |
} = store2.context; |
| 6596 |
const tree = useFloatingTree(); |
| 6597 |
const parentId = useFloatingParentNodeId(); |
| 6598 |
const instance = useHoverInteractionSharedState(store2); |
| 6599 |
const childClosedTimeout = useTimeout(); |
| 6600 |
const isClickLikeOpenEvent2 = useStableCallback(() => { |
| 6601 |
return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside); |
| 6602 |
}); |
| 6603 |
const isHoverOpen = useStableCallback(() => { |
| 6604 |
return isHoverOpenEvent(dataRef.current.openEvent?.type); |
| 6605 |
}); |
| 6606 |
const clearPointerEvents = useStableCallback(() => { |
| 6607 |
clearSafePolygonPointerEventsMutation(instance); |
| 6608 |
}); |
| 6609 |
useIsoLayoutEffect(() => { |
| 6610 |
if (!open) { |
| 6611 |
instance.pointerType = void 0; |
| 6612 |
instance.restTimeoutPending = false; |
| 6613 |
instance.interactedInside = false; |
| 6614 |
clearPointerEvents(); |
| 6615 |
} |
| 6616 |
}, [open, instance, clearPointerEvents]); |
| 6617 |
React27.useEffect(() => { |
| 6618 |
return clearPointerEvents; |
| 6619 |
}, [clearPointerEvents]); |
| 6620 |
useIsoLayoutEffect(() => { |
| 6621 |
if (!enabled) { |
| 6622 |
return void 0; |
| 6623 |
} |
| 6624 |
if (open && instance.handleCloseOptions?.blockPointerEvents && isHoverOpen() && isElement(domReferenceElement) && floatingElement) { |
| 6625 |
const ref = domReferenceElement; |
| 6626 |
const floatingEl = floatingElement; |
| 6627 |
const doc = ownerDocument(floatingElement); |
| 6628 |
const parentFloating = tree?.nodesRef.current.find((node) => node.id === parentId)?.context?.elements.floating; |
| 6629 |
if (parentFloating) { |
| 6630 |
parentFloating.style.pointerEvents = ""; |
| 6631 |
} |
| 6632 |
const cachedScopeElement = instance.pointerEventsScopeElement !== floatingEl ? instance.pointerEventsScopeElement : null; |
| 6633 |
const parentScopeElement = parentFloating !== floatingEl ? parentFloating : null; |
| 6634 |
const scopeElement = instance.handleCloseOptions?.getScope?.() ?? cachedScopeElement ?? parentScopeElement ?? ref.closest("[data-rootownerid]") ?? doc.body; |
| 6635 |
applySafePolygonPointerEventsMutation(instance, { |
| 6636 |
scopeElement, |
| 6637 |
referenceElement: ref, |
| 6638 |
floatingElement: floatingEl |
| 6639 |
}); |
| 6640 |
return () => { |
| 6641 |
clearPointerEvents(); |
| 6642 |
}; |
| 6643 |
} |
| 6644 |
return void 0; |
| 6645 |
}, [enabled, open, domReferenceElement, floatingElement, instance, isHoverOpen, tree, parentId, clearPointerEvents]); |
| 6646 |
React27.useEffect(() => { |
| 6647 |
if (!enabled) { |
| 6648 |
return void 0; |
| 6649 |
} |
| 6650 |
function hasParentChildren() { |
| 6651 |
return !!(tree && parentId && getNodeChildren(tree.nodesRef.current, parentId).length > 0); |
| 6652 |
} |
| 6653 |
function closeWithDelay(event) { |
| 6654 |
const closeDelay = getDelay(closeDelayProp, "close", instance.pointerType); |
| 6655 |
const close = () => { |
| 6656 |
store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event)); |
| 6657 |
tree?.events.emit("floating.closed", event); |
| 6658 |
}; |
| 6659 |
if (closeDelay) { |
| 6660 |
instance.openChangeTimeout.start(closeDelay, close); |
| 6661 |
} else { |
| 6662 |
instance.openChangeTimeout.clear(); |
| 6663 |
close(); |
| 6664 |
} |
| 6665 |
} |
| 6666 |
function handleInteractInside(event) { |
| 6667 |
const target = getTarget(event); |
| 6668 |
if (!isInteractiveElement(target)) { |
| 6669 |
instance.interactedInside = false; |
| 6670 |
return; |
| 6671 |
} |
| 6672 |
instance.interactedInside = target?.closest("[aria-haspopup]") != null; |
| 6673 |
} |
| 6674 |
function onFloatingMouseEnter() { |
| 6675 |
instance.openChangeTimeout.clear(); |
| 6676 |
childClosedTimeout.clear(); |
| 6677 |
tree?.events.off("floating.closed", onNodeClosed); |
| 6678 |
clearPointerEvents(); |
| 6679 |
} |
| 6680 |
function onFloatingMouseLeave(event) { |
| 6681 |
if (hasParentChildren() && tree) { |
| 6682 |
tree.events.on("floating.closed", onNodeClosed); |
| 6683 |
return; |
| 6684 |
} |
| 6685 |
if (isTargetInsideEnabledTrigger(event.relatedTarget, store2.context.triggerElements)) { |
| 6686 |
return; |
| 6687 |
} |
| 6688 |
const currentNodeId = dataRef.current.floatingContext?.nodeId ?? nodeIdProp; |
| 6689 |
const relatedTarget = event.relatedTarget; |
| 6690 |
const isMovingIntoDescendantFloating = tree && currentNodeId && isElement(relatedTarget) && getNodeChildren(tree.nodesRef.current, currentNodeId, false).some((node) => contains(node.context?.elements.floating, relatedTarget)); |
| 6691 |
if (isMovingIntoDescendantFloating) { |
| 6692 |
return; |
| 6693 |
} |
| 6694 |
if (instance.handler) { |
| 6695 |
instance.handler(event); |
| 6696 |
return; |
| 6697 |
} |
| 6698 |
clearPointerEvents(); |
| 6699 |
if (isHoverOpen() && !isClickLikeOpenEvent2()) { |
| 6700 |
closeWithDelay(event); |
| 6701 |
} |
| 6702 |
} |
| 6703 |
function onNodeClosed(event) { |
| 6704 |
if (!tree || !parentId || hasParentChildren()) { |
| 6705 |
return; |
| 6706 |
} |
| 6707 |
childClosedTimeout.start(0, () => { |
| 6708 |
tree.events.off("floating.closed", onNodeClosed); |
| 6709 |
store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event)); |
| 6710 |
tree.events.emit("floating.closed", event); |
| 6711 |
}); |
| 6712 |
} |
| 6713 |
const floating = floatingElement; |
| 6714 |
return mergeCleanups(floating && addEventListener(floating, "mouseenter", onFloatingMouseEnter), floating && addEventListener(floating, "mouseleave", onFloatingMouseLeave), floating && addEventListener(floating, "pointerdown", handleInteractInside, true), () => { |
| 6715 |
tree?.events.off("floating.closed", onNodeClosed); |
| 6716 |
}); |
| 6717 |
}, [enabled, floatingElement, store2, dataRef, closeDelayProp, nodeIdProp, isHoverOpen, isClickLikeOpenEvent2, clearPointerEvents, instance, tree, parentId, childClosedTimeout]); |
| 6718 |
} |
| 6719 |
|
| 6720 |
// node_modules/@base-ui/react/floating-ui-react/hooks/useHoverReferenceInteraction.mjs |
| 6721 |
var React28 = __toESM(require_react(), 1); |
| 6722 |
var ReactDOM5 = __toESM(require_react_dom(), 1); |
| 6723 |
var EMPTY_REF = { |
| 6724 |
current: null |
| 6725 |
}; |
| 6726 |
function useHoverReferenceInteraction(context, props = {}) { |
| 6727 |
const { |
| 6728 |
enabled = true, |
| 6729 |
delay = 0, |
| 6730 |
handleClose = null, |
| 6731 |
mouseOnly = false, |
| 6732 |
restMs = 0, |
| 6733 |
move = true, |
| 6734 |
triggerElementRef = EMPTY_REF, |
| 6735 |
externalTree, |
| 6736 |
isActiveTrigger = true, |
| 6737 |
getHandleCloseContext, |
| 6738 |
isClosing, |
| 6739 |
shouldOpen: shouldOpenProp |
| 6740 |
} = props; |
| 6741 |
const store2 = "rootStore" in context ? context.rootStore : context; |
| 6742 |
const { |
| 6743 |
dataRef, |
| 6744 |
events |
| 6745 |
} = store2.context; |
| 6746 |
const tree = useFloatingTree(externalTree); |
| 6747 |
const instance = useHoverInteractionSharedState(store2); |
| 6748 |
const isHoverCloseActiveRef = React28.useRef(false); |
| 6749 |
const handleCloseRef = useValueAsRef(handleClose); |
| 6750 |
const delayRef = useValueAsRef(delay); |
| 6751 |
const restMsRef = useValueAsRef(restMs); |
| 6752 |
const enabledRef = useValueAsRef(enabled); |
| 6753 |
const shouldOpenRef = useValueAsRef(shouldOpenProp); |
| 6754 |
const isClosingRef = useValueAsRef(isClosing); |
| 6755 |
const isClickLikeOpenEvent2 = useStableCallback(() => { |
| 6756 |
return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside); |
| 6757 |
}); |
| 6758 |
const checkShouldOpen = useStableCallback(() => { |
| 6759 |
return shouldOpenRef.current?.() !== false; |
| 6760 |
}); |
| 6761 |
const isOverInactiveTrigger = useStableCallback((currentDomReference, currentTarget, target) => { |
| 6762 |
const allTriggers = store2.context.triggerElements; |
| 6763 |
if (allTriggers.hasElement(currentTarget)) { |
| 6764 |
return !currentDomReference || !contains(currentDomReference, currentTarget); |
| 6765 |
} |
| 6766 |
if (!isElement(target)) { |
| 6767 |
return false; |
| 6768 |
} |
| 6769 |
const targetElement = target; |
| 6770 |
return allTriggers.hasMatchingElement((trigger) => contains(trigger, targetElement)) && (!currentDomReference || !contains(currentDomReference, targetElement)); |
| 6771 |
}); |
| 6772 |
const cleanupMouseMoveHandler = useStableCallback(() => { |
| 6773 |
if (!instance.handler) { |
| 6774 |
return; |
| 6775 |
} |
| 6776 |
const doc = ownerDocument(store2.select("domReferenceElement")); |
| 6777 |
doc.removeEventListener("mousemove", instance.handler); |
| 6778 |
instance.handler = void 0; |
| 6779 |
}); |
| 6780 |
const clearPointerEvents = useStableCallback(() => { |
| 6781 |
clearSafePolygonPointerEventsMutation(instance); |
| 6782 |
}); |
| 6783 |
if (isActiveTrigger) { |
| 6784 |
instance.handleCloseOptions = handleCloseRef.current?.__options; |
| 6785 |
} |
| 6786 |
React28.useEffect(() => cleanupMouseMoveHandler, [cleanupMouseMoveHandler]); |
| 6787 |
React28.useEffect(() => { |
| 6788 |
if (!enabled) { |
| 6789 |
return void 0; |
| 6790 |
} |
| 6791 |
function onOpenChangeLocal(details) { |
| 6792 |
if (!details.open) { |
| 6793 |
isHoverCloseActiveRef.current = details.reason === reason_parts_exports.triggerHover; |
| 6794 |
cleanupMouseMoveHandler(); |
| 6795 |
instance.openChangeTimeout.clear(); |
| 6796 |
instance.restTimeout.clear(); |
| 6797 |
instance.blockMouseMove = true; |
| 6798 |
instance.restTimeoutPending = false; |
| 6799 |
} else { |
| 6800 |
isHoverCloseActiveRef.current = false; |
| 6801 |
} |
| 6802 |
} |
| 6803 |
events.on("openchange", onOpenChangeLocal); |
| 6804 |
return () => { |
| 6805 |
events.off("openchange", onOpenChangeLocal); |
| 6806 |
}; |
| 6807 |
}, [enabled, events, instance, cleanupMouseMoveHandler]); |
| 6808 |
React28.useEffect(() => { |
| 6809 |
if (!enabled) { |
| 6810 |
return void 0; |
| 6811 |
} |
| 6812 |
function closeWithDelay(event, runElseBranch = true) { |
| 6813 |
const closeDelay = getDelay(delayRef.current, "close", instance.pointerType); |
| 6814 |
if (closeDelay) { |
| 6815 |
instance.openChangeTimeout.start(closeDelay, () => { |
| 6816 |
store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event)); |
| 6817 |
tree?.events.emit("floating.closed", event); |
| 6818 |
}); |
| 6819 |
} else if (runElseBranch) { |
| 6820 |
instance.openChangeTimeout.clear(); |
| 6821 |
store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event)); |
| 6822 |
tree?.events.emit("floating.closed", event); |
| 6823 |
} |
| 6824 |
} |
| 6825 |
const trigger = triggerElementRef.current ?? (isActiveTrigger ? store2.select("domReferenceElement") : null); |
| 6826 |
if (!isElement(trigger)) { |
| 6827 |
return void 0; |
| 6828 |
} |
| 6829 |
function onMouseEnter(event) { |
| 6830 |
instance.openChangeTimeout.clear(); |
| 6831 |
instance.blockMouseMove = false; |
| 6832 |
if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) { |
| 6833 |
return; |
| 6834 |
} |
| 6835 |
const restMsValue = getRestMs(restMsRef.current); |
| 6836 |
const openDelay = getDelay(delayRef.current, "open", instance.pointerType); |
| 6837 |
const eventTarget = getTarget(event); |
| 6838 |
const currentTarget = event.currentTarget ?? null; |
| 6839 |
const currentDomReference = store2.select("domReferenceElement"); |
| 6840 |
let triggerNode = currentTarget; |
| 6841 |
if (isElement(eventTarget) && !store2.context.triggerElements.hasElement(eventTarget)) { |
| 6842 |
for (const triggerElement of store2.context.triggerElements.elements()) { |
| 6843 |
if (contains(triggerElement, eventTarget)) { |
| 6844 |
triggerNode = triggerElement; |
| 6845 |
break; |
| 6846 |
} |
| 6847 |
} |
| 6848 |
} |
| 6849 |
if (isElement(currentTarget) && isElement(currentDomReference) && !store2.context.triggerElements.hasElement(currentTarget) && contains(currentTarget, currentDomReference)) { |
| 6850 |
triggerNode = currentDomReference; |
| 6851 |
} |
| 6852 |
const isOverInactive = triggerNode == null ? false : isOverInactiveTrigger(currentDomReference, triggerNode, eventTarget); |
| 6853 |
const isOpen = store2.select("open"); |
| 6854 |
const isInClosingTransition = isClosingRef.current?.() ?? store2.select("transitionStatus") === "ending"; |
| 6855 |
const isHoverCloseTransition = !isOpen && isInClosingTransition && isHoverCloseActiveRef.current; |
| 6856 |
const isReenteringSameTriggerDuringCloseTransition = !isOverInactive && isElement(triggerNode) && isElement(currentDomReference) && contains(currentDomReference, triggerNode) && isHoverCloseTransition; |
| 6857 |
const isRestOnlyDelay = restMsValue > 0 && !openDelay; |
| 6858 |
const shouldOpenImmediately = isOverInactive && (isOpen || isHoverCloseTransition) || isReenteringSameTriggerDuringCloseTransition; |
| 6859 |
const shouldOpen = !isOpen || isOverInactive; |
| 6860 |
if (shouldOpenImmediately) { |
| 6861 |
if (checkShouldOpen()) { |
| 6862 |
store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode)); |
| 6863 |
} |
| 6864 |
return; |
| 6865 |
} |
| 6866 |
if (isRestOnlyDelay) { |
| 6867 |
return; |
| 6868 |
} |
| 6869 |
if (openDelay) { |
| 6870 |
instance.openChangeTimeout.start(openDelay, () => { |
| 6871 |
if (shouldOpen && checkShouldOpen()) { |
| 6872 |
store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode)); |
| 6873 |
} |
| 6874 |
}); |
| 6875 |
} else if (shouldOpen) { |
| 6876 |
if (checkShouldOpen()) { |
| 6877 |
store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode)); |
| 6878 |
} |
| 6879 |
} |
| 6880 |
} |
| 6881 |
function onMouseLeave(event) { |
| 6882 |
if (isClickLikeOpenEvent2()) { |
| 6883 |
clearPointerEvents(); |
| 6884 |
return; |
| 6885 |
} |
| 6886 |
cleanupMouseMoveHandler(); |
| 6887 |
const domReferenceElement = store2.select("domReferenceElement"); |
| 6888 |
const doc = ownerDocument(domReferenceElement); |
| 6889 |
instance.restTimeout.clear(); |
| 6890 |
instance.restTimeoutPending = false; |
| 6891 |
const handleCloseContextBase = dataRef.current.floatingContext ?? getHandleCloseContext?.(); |
| 6892 |
if (isTargetInsideEnabledTrigger(event.relatedTarget, store2.context.triggerElements)) { |
| 6893 |
return; |
| 6894 |
} |
| 6895 |
if (handleCloseRef.current && handleCloseContextBase) { |
| 6896 |
if (!store2.select("open")) { |
| 6897 |
instance.openChangeTimeout.clear(); |
| 6898 |
} |
| 6899 |
const currentTrigger = triggerElementRef.current; |
| 6900 |
instance.handler = handleCloseRef.current({ |
| 6901 |
...handleCloseContextBase, |
| 6902 |
tree, |
| 6903 |
x: event.clientX, |
| 6904 |
y: event.clientY, |
| 6905 |
onClose() { |
| 6906 |
clearPointerEvents(); |
| 6907 |
cleanupMouseMoveHandler(); |
| 6908 |
if (enabledRef.current && !isClickLikeOpenEvent2() && currentTrigger === store2.select("domReferenceElement")) { |
| 6909 |
closeWithDelay(event, true); |
| 6910 |
} |
| 6911 |
} |
| 6912 |
}); |
| 6913 |
doc.addEventListener("mousemove", instance.handler); |
| 6914 |
instance.handler(event); |
| 6915 |
return; |
| 6916 |
} |
| 6917 |
const shouldClose = instance.pointerType === "touch" ? !contains(store2.select("floatingElement"), event.relatedTarget) : true; |
| 6918 |
if (shouldClose) { |
| 6919 |
closeWithDelay(event); |
| 6920 |
} |
| 6921 |
} |
| 6922 |
if (move) { |
| 6923 |
return mergeCleanups(addEventListener(trigger, "mousemove", onMouseEnter, { |
| 6924 |
once: true |
| 6925 |
}), addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave)); |
| 6926 |
} |
| 6927 |
return mergeCleanups(addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave)); |
| 6928 |
}, [cleanupMouseMoveHandler, clearPointerEvents, dataRef, delayRef, store2, enabled, handleCloseRef, instance, isActiveTrigger, isOverInactiveTrigger, isClickLikeOpenEvent2, mouseOnly, move, restMsRef, triggerElementRef, tree, enabledRef, getHandleCloseContext, isClosingRef, checkShouldOpen]); |
| 6929 |
return React28.useMemo(() => { |
| 6930 |
if (!enabled) { |
| 6931 |
return void 0; |
| 6932 |
} |
| 6933 |
function setPointerRef(event) { |
| 6934 |
instance.pointerType = event.pointerType; |
| 6935 |
} |
| 6936 |
return { |
| 6937 |
onPointerDown: setPointerRef, |
| 6938 |
onPointerEnter: setPointerRef, |
| 6939 |
onMouseMove(event) { |
| 6940 |
const { |
| 6941 |
nativeEvent |
| 6942 |
} = event; |
| 6943 |
const trigger = event.currentTarget; |
| 6944 |
const currentDomReference = store2.select("domReferenceElement"); |
| 6945 |
const currentOpen = store2.select("open"); |
| 6946 |
const isOverInactive = isOverInactiveTrigger(currentDomReference, trigger, event.target); |
| 6947 |
if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) { |
| 6948 |
return; |
| 6949 |
} |
| 6950 |
if (currentOpen && isOverInactive && instance.handleCloseOptions?.blockPointerEvents) { |
| 6951 |
const floatingElement = store2.select("floatingElement"); |
| 6952 |
if (floatingElement) { |
| 6953 |
const scopeElement = instance.handleCloseOptions?.getScope?.() ?? trigger.ownerDocument.body; |
| 6954 |
applySafePolygonPointerEventsMutation(instance, { |
| 6955 |
scopeElement, |
| 6956 |
referenceElement: trigger, |
| 6957 |
floatingElement |
| 6958 |
}); |
| 6959 |
} |
| 6960 |
} |
| 6961 |
const restMsValue = getRestMs(restMsRef.current); |
| 6962 |
if (currentOpen && !isOverInactive || restMsValue === 0) { |
| 6963 |
return; |
| 6964 |
} |
| 6965 |
if (!isOverInactive && instance.restTimeoutPending && event.movementX ** 2 + event.movementY ** 2 < 2) { |
| 6966 |
return; |
| 6967 |
} |
| 6968 |
instance.restTimeout.clear(); |
| 6969 |
function handleMouseMove() { |
| 6970 |
instance.restTimeoutPending = false; |
| 6971 |
if (isClickLikeOpenEvent2()) { |
| 6972 |
return; |
| 6973 |
} |
| 6974 |
const latestOpen = store2.select("open"); |
| 6975 |
if (!instance.blockMouseMove && (!latestOpen || isOverInactive) && checkShouldOpen()) { |
| 6976 |
store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, nativeEvent, trigger)); |
| 6977 |
} |
| 6978 |
} |
| 6979 |
if (instance.pointerType === "touch") { |
| 6980 |
ReactDOM5.flushSync(() => { |
| 6981 |
handleMouseMove(); |
| 6982 |
}); |
| 6983 |
} else if (isOverInactive && currentOpen) { |
| 6984 |
handleMouseMove(); |
| 6985 |
} else { |
| 6986 |
instance.restTimeoutPending = true; |
| 6987 |
instance.restTimeout.start(restMsValue, handleMouseMove); |
| 6988 |
} |
| 6989 |
} |
| 6990 |
}; |
| 6991 |
}, [enabled, instance, isClickLikeOpenEvent2, isOverInactiveTrigger, mouseOnly, store2, restMsRef, checkShouldOpen]); |
| 6992 |
} |
| 6993 |
|
| 6994 |
// node_modules/@base-ui/react/floating-ui-react/safePolygon.mjs |
| 6995 |
var CURSOR_SPEED_THRESHOLD = 0.1; |
| 6996 |
var CURSOR_SPEED_THRESHOLD_SQUARED = CURSOR_SPEED_THRESHOLD * CURSOR_SPEED_THRESHOLD; |
| 6997 |
var POLYGON_BUFFER = 0.5; |
| 6998 |
function hasIntersectingEdge(pointX, pointY, xi, yi, xj, yj) { |
| 6999 |
return yi >= pointY !== yj >= pointY && pointX <= (xj - xi) * (pointY - yi) / (yj - yi) + xi; |
| 7000 |
} |
| 7001 |
function isPointInQuadrilateral(pointX, pointY, x1, y1, x2, y2, x3, y3, x4, y4) { |
| 7002 |
let isInsideValue = false; |
| 7003 |
if (hasIntersectingEdge(pointX, pointY, x1, y1, x2, y2)) { |
| 7004 |
isInsideValue = !isInsideValue; |
| 7005 |
} |
| 7006 |
if (hasIntersectingEdge(pointX, pointY, x2, y2, x3, y3)) { |
| 7007 |
isInsideValue = !isInsideValue; |
| 7008 |
} |
| 7009 |
if (hasIntersectingEdge(pointX, pointY, x3, y3, x4, y4)) { |
| 7010 |
isInsideValue = !isInsideValue; |
| 7011 |
} |
| 7012 |
if (hasIntersectingEdge(pointX, pointY, x4, y4, x1, y1)) { |
| 7013 |
isInsideValue = !isInsideValue; |
| 7014 |
} |
| 7015 |
return isInsideValue; |
| 7016 |
} |
| 7017 |
function isInsideRect(pointX, pointY, rect) { |
| 7018 |
return pointX >= rect.x && pointX <= rect.x + rect.width && pointY >= rect.y && pointY <= rect.y + rect.height; |
| 7019 |
} |
| 7020 |
function isInsideAxisAlignedRect(pointX, pointY, x1, y1, x2, y2) { |
| 7021 |
const minX = Math.min(x1, x2); |
| 7022 |
const maxX = Math.max(x1, x2); |
| 7023 |
const minY = Math.min(y1, y2); |
| 7024 |
const maxY = Math.max(y1, y2); |
| 7025 |
return pointX >= minX && pointX <= maxX && pointY >= minY && pointY <= maxY; |
| 7026 |
} |
| 7027 |
function safePolygon(options = {}) { |
| 7028 |
const { |
| 7029 |
blockPointerEvents = false |
| 7030 |
} = options; |
| 7031 |
const timeout = new Timeout(); |
| 7032 |
const fn = ({ |
| 7033 |
x, |
| 7034 |
y, |
| 7035 |
placement, |
| 7036 |
elements, |
| 7037 |
onClose, |
| 7038 |
nodeId, |
| 7039 |
tree |
| 7040 |
}) => { |
| 7041 |
const side = placement?.split("-")[0]; |
| 7042 |
let hasLanded = false; |
| 7043 |
let lastX = null; |
| 7044 |
let lastY = null; |
| 7045 |
let lastCursorTime = typeof performance !== "undefined" ? performance.now() : 0; |
| 7046 |
function isCursorMovingSlowly(nextX, nextY) { |
| 7047 |
const currentTime = performance.now(); |
| 7048 |
const elapsedTime = currentTime - lastCursorTime; |
| 7049 |
if (lastX === null || lastY === null || elapsedTime === 0) { |
| 7050 |
lastX = nextX; |
| 7051 |
lastY = nextY; |
| 7052 |
lastCursorTime = currentTime; |
| 7053 |
return false; |
| 7054 |
} |
| 7055 |
const deltaX = nextX - lastX; |
| 7056 |
const deltaY = nextY - lastY; |
| 7057 |
const distanceSquared = deltaX * deltaX + deltaY * deltaY; |
| 7058 |
const thresholdSquared = elapsedTime * elapsedTime * CURSOR_SPEED_THRESHOLD_SQUARED; |
| 7059 |
lastX = nextX; |
| 7060 |
lastY = nextY; |
| 7061 |
lastCursorTime = currentTime; |
| 7062 |
return distanceSquared < thresholdSquared; |
| 7063 |
} |
| 7064 |
function close() { |
| 7065 |
timeout.clear(); |
| 7066 |
onClose(); |
| 7067 |
} |
| 7068 |
return function onMouseMove(event) { |
| 7069 |
timeout.clear(); |
| 7070 |
const domReference = elements.domReference; |
| 7071 |
const floating = elements.floating; |
| 7072 |
if (!domReference || !floating || side == null || x == null || y == null) { |
| 7073 |
return void 0; |
| 7074 |
} |
| 7075 |
const { |
| 7076 |
clientX, |
| 7077 |
clientY |
| 7078 |
} = event; |
| 7079 |
const target = getTarget(event); |
| 7080 |
const isLeave = event.type === "mouseleave"; |
| 7081 |
const isOverFloatingEl = contains(floating, target); |
| 7082 |
const isOverReferenceEl = contains(domReference, target); |
| 7083 |
if (isOverFloatingEl) { |
| 7084 |
hasLanded = true; |
| 7085 |
if (!isLeave) { |
| 7086 |
return void 0; |
| 7087 |
} |
| 7088 |
} |
| 7089 |
if (isOverReferenceEl) { |
| 7090 |
hasLanded = false; |
| 7091 |
if (!isLeave) { |
| 7092 |
hasLanded = true; |
| 7093 |
return void 0; |
| 7094 |
} |
| 7095 |
} |
| 7096 |
if (isLeave && isElement(event.relatedTarget) && contains(floating, event.relatedTarget)) { |
| 7097 |
return void 0; |
| 7098 |
} |
| 7099 |
function hasOpenChildNode() { |
| 7100 |
return Boolean(tree && getNodeChildren(tree.nodesRef.current, nodeId).length > 0); |
| 7101 |
} |
| 7102 |
function closeIfNoOpenChild() { |
| 7103 |
if (!hasOpenChildNode()) { |
| 7104 |
close(); |
| 7105 |
} |
| 7106 |
} |
| 7107 |
if (hasOpenChildNode()) { |
| 7108 |
return void 0; |
| 7109 |
} |
| 7110 |
const refRect = domReference.getBoundingClientRect(); |
| 7111 |
const rect = floating.getBoundingClientRect(); |
| 7112 |
const cursorLeaveFromRight = x > rect.right - rect.width / 2; |
| 7113 |
const cursorLeaveFromBottom = y > rect.bottom - rect.height / 2; |
| 7114 |
const isFloatingWider = rect.width > refRect.width; |
| 7115 |
const isFloatingTaller = rect.height > refRect.height; |
| 7116 |
const left = (isFloatingWider ? refRect : rect).left; |
| 7117 |
const right = (isFloatingWider ? refRect : rect).right; |
| 7118 |
const top = (isFloatingTaller ? refRect : rect).top; |
| 7119 |
const bottom = (isFloatingTaller ? refRect : rect).bottom; |
| 7120 |
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) { |
| 7121 |
closeIfNoOpenChild(); |
| 7122 |
return void 0; |
| 7123 |
} |
| 7124 |
let isInsideTroughRect = false; |
| 7125 |
switch (side) { |
| 7126 |
case "top": |
| 7127 |
isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, refRect.top + 1, right, rect.bottom - 1); |
| 7128 |
break; |
| 7129 |
case "bottom": |
| 7130 |
isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, rect.top + 1, right, refRect.bottom - 1); |
| 7131 |
break; |
| 7132 |
case "left": |
| 7133 |
isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, rect.right - 1, bottom, refRect.left + 1, top); |
| 7134 |
break; |
| 7135 |
case "right": |
| 7136 |
isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, refRect.right - 1, bottom, rect.left + 1, top); |
| 7137 |
break; |
| 7138 |
default: |
| 7139 |
} |
| 7140 |
if (isInsideTroughRect) { |
| 7141 |
return void 0; |
| 7142 |
} |
| 7143 |
if (hasLanded && !isInsideRect(clientX, clientY, refRect)) { |
| 7144 |
closeIfNoOpenChild(); |
| 7145 |
return void 0; |
| 7146 |
} |
| 7147 |
if (!isLeave && isCursorMovingSlowly(clientX, clientY)) { |
| 7148 |
closeIfNoOpenChild(); |
| 7149 |
return void 0; |
| 7150 |
} |
| 7151 |
let isInsidePolygon = false; |
| 7152 |
switch (side) { |
| 7153 |
case "top": { |
| 7154 |
const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4; |
| 7155 |
const cursorPointOneX = isFloatingWider ? x + cursorXOffset : cursorLeaveFromRight ? x + cursorXOffset : x - cursorXOffset; |
| 7156 |
const cursorPointTwoX = isFloatingWider ? x - cursorXOffset : cursorLeaveFromRight ? x + cursorXOffset : x - cursorXOffset; |
| 7157 |
const cursorPointY = y + POLYGON_BUFFER + 1; |
| 7158 |
const commonYLeft = cursorLeaveFromRight ? rect.bottom - POLYGON_BUFFER : isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top; |
| 7159 |
const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top : rect.bottom - POLYGON_BUFFER; |
| 7160 |
isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight); |
| 7161 |
break; |
| 7162 |
} |
| 7163 |
case "bottom": { |
| 7164 |
const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4; |
| 7165 |
const cursorPointOneX = isFloatingWider ? x + cursorXOffset : cursorLeaveFromRight ? x + cursorXOffset : x - cursorXOffset; |
| 7166 |
const cursorPointTwoX = isFloatingWider ? x - cursorXOffset : cursorLeaveFromRight ? x + cursorXOffset : x - cursorXOffset; |
| 7167 |
const cursorPointY = y - POLYGON_BUFFER; |
| 7168 |
const commonYLeft = cursorLeaveFromRight ? rect.top + POLYGON_BUFFER : isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom; |
| 7169 |
const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom : rect.top + POLYGON_BUFFER; |
| 7170 |
isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight); |
| 7171 |
break; |
| 7172 |
} |
| 7173 |
case "left": { |
| 7174 |
const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4; |
| 7175 |
const cursorPointOneY = isFloatingTaller ? y + cursorYOffset : cursorLeaveFromBottom ? y + cursorYOffset : y - cursorYOffset; |
| 7176 |
const cursorPointTwoY = isFloatingTaller ? y - cursorYOffset : cursorLeaveFromBottom ? y + cursorYOffset : y - cursorYOffset; |
| 7177 |
const cursorPointX = x + POLYGON_BUFFER + 1; |
| 7178 |
const commonXTop = cursorLeaveFromBottom ? rect.right - POLYGON_BUFFER : isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left; |
| 7179 |
const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left : rect.right - POLYGON_BUFFER; |
| 7180 |
isInsidePolygon = isPointInQuadrilateral(clientX, clientY, commonXTop, rect.top, commonXBottom, rect.bottom, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY); |
| 7181 |
break; |
| 7182 |
} |
| 7183 |
case "right": { |
| 7184 |
const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4; |
| 7185 |
const cursorPointOneY = isFloatingTaller ? y + cursorYOffset : cursorLeaveFromBottom ? y + cursorYOffset : y - cursorYOffset; |
| 7186 |
const cursorPointTwoY = isFloatingTaller ? y - cursorYOffset : cursorLeaveFromBottom ? y + cursorYOffset : y - cursorYOffset; |
| 7187 |
const cursorPointX = x - POLYGON_BUFFER; |
| 7188 |
const commonXTop = cursorLeaveFromBottom ? rect.left + POLYGON_BUFFER : isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right; |
| 7189 |
const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right : rect.left + POLYGON_BUFFER; |
| 7190 |
isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY, commonXTop, rect.top, commonXBottom, rect.bottom); |
| 7191 |
break; |
| 7192 |
} |
| 7193 |
default: |
| 7194 |
} |
| 7195 |
if (!isInsidePolygon) { |
| 7196 |
closeIfNoOpenChild(); |
| 7197 |
} else if (!hasLanded) { |
| 7198 |
timeout.start(40, closeIfNoOpenChild); |
| 7199 |
} |
| 7200 |
return void 0; |
| 7201 |
}; |
| 7202 |
}; |
| 7203 |
fn.__options = { |
| 7204 |
...options, |
| 7205 |
blockPointerEvents |
| 7206 |
}; |
| 7207 |
return fn; |
| 7208 |
} |
| 7209 |
|
| 7210 |
// node_modules/@base-ui/react/utils/popupStateMapping.mjs |
| 7211 |
var CommonPopupDataAttributes = (function(CommonPopupDataAttributes2) { |
| 7212 |
CommonPopupDataAttributes2["open"] = "data-open"; |
| 7213 |
CommonPopupDataAttributes2["closed"] = "data-closed"; |
| 7214 |
CommonPopupDataAttributes2[CommonPopupDataAttributes2["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle"; |
| 7215 |
CommonPopupDataAttributes2[CommonPopupDataAttributes2["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle"; |
| 7216 |
CommonPopupDataAttributes2["anchorHidden"] = "data-anchor-hidden"; |
| 7217 |
CommonPopupDataAttributes2["side"] = "data-side"; |
| 7218 |
CommonPopupDataAttributes2["align"] = "data-align"; |
| 7219 |
return CommonPopupDataAttributes2; |
| 7220 |
})({}); |
| 7221 |
var CommonTriggerDataAttributes = /* @__PURE__ */ (function(CommonTriggerDataAttributes2) { |
| 7222 |
CommonTriggerDataAttributes2["popupOpen"] = "data-popup-open"; |
| 7223 |
CommonTriggerDataAttributes2["pressed"] = "data-pressed"; |
| 7224 |
return CommonTriggerDataAttributes2; |
| 7225 |
})({}); |
| 7226 |
var TRIGGER_HOOK = { |
| 7227 |
[CommonTriggerDataAttributes.popupOpen]: "" |
| 7228 |
}; |
| 7229 |
var PRESSABLE_TRIGGER_HOOK = { |
| 7230 |
[CommonTriggerDataAttributes.popupOpen]: "", |
| 7231 |
[CommonTriggerDataAttributes.pressed]: "" |
| 7232 |
}; |
| 7233 |
var POPUP_OPEN_HOOK = { |
| 7234 |
[CommonPopupDataAttributes.open]: "" |
| 7235 |
}; |
| 7236 |
var POPUP_CLOSED_HOOK = { |
| 7237 |
[CommonPopupDataAttributes.closed]: "" |
| 7238 |
}; |
| 7239 |
var ANCHOR_HIDDEN_HOOK = { |
| 7240 |
[CommonPopupDataAttributes.anchorHidden]: "" |
| 7241 |
}; |
| 7242 |
var triggerOpenStateMapping = { |
| 7243 |
open(value) { |
| 7244 |
if (value) { |
| 7245 |
return TRIGGER_HOOK; |
| 7246 |
} |
| 7247 |
return null; |
| 7248 |
} |
| 7249 |
}; |
| 7250 |
var popupStateMapping = { |
| 7251 |
open(value) { |
| 7252 |
if (value) { |
| 7253 |
return POPUP_OPEN_HOOK; |
| 7254 |
} |
| 7255 |
return POPUP_CLOSED_HOOK; |
| 7256 |
}, |
| 7257 |
anchorHidden(value) { |
| 7258 |
if (value) { |
| 7259 |
return ANCHOR_HIDDEN_HOOK; |
| 7260 |
} |
| 7261 |
return null; |
| 7262 |
} |
| 7263 |
}; |
| 7264 |
|
| 7265 |
// node_modules/@base-ui/utils/inertValue.mjs |
| 7266 |
function inertValue(value) { |
| 7267 |
if (isReactVersionAtLeast(19)) { |
| 7268 |
return value; |
| 7269 |
} |
| 7270 |
return value ? "true" : void 0; |
| 7271 |
} |
| 7272 |
|
| 7273 |
// node_modules/@base-ui/react/utils/useAnchorPositioning.mjs |
| 7274 |
var React29 = __toESM(require_react(), 1); |
| 7275 |
|
| 7276 |
// node_modules/@base-ui/react/floating-ui-react/middleware/arrow.mjs |
| 7277 |
var baseArrow = (options) => ({ |
| 7278 |
name: "arrow", |
| 7279 |
options, |
| 7280 |
async fn(state) { |
| 7281 |
const { |
| 7282 |
x, |
| 7283 |
y, |
| 7284 |
placement, |
| 7285 |
rects, |
| 7286 |
platform: platform3, |
| 7287 |
elements, |
| 7288 |
middlewareData |
| 7289 |
} = state; |
| 7290 |
const { |
| 7291 |
element, |
| 7292 |
padding = 0, |
| 7293 |
offsetParent = "real" |
| 7294 |
} = evaluate(options, state) || {}; |
| 7295 |
if (element == null) { |
| 7296 |
return {}; |
| 7297 |
} |
| 7298 |
const paddingObject = getPaddingObject(padding); |
| 7299 |
const coords = { |
| 7300 |
x, |
| 7301 |
y |
| 7302 |
}; |
| 7303 |
const axis = getAlignmentAxis(placement); |
| 7304 |
const length = getAxisLength(axis); |
| 7305 |
const arrowDimensions = await platform3.getDimensions(element); |
| 7306 |
const isYAxis = axis === "y"; |
| 7307 |
const minProp = isYAxis ? "top" : "left"; |
| 7308 |
const maxProp = isYAxis ? "bottom" : "right"; |
| 7309 |
const clientProp = isYAxis ? "clientHeight" : "clientWidth"; |
| 7310 |
const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length]; |
| 7311 |
const startDiff = coords[axis] - rects.reference[axis]; |
| 7312 |
const arrowOffsetParent = offsetParent === "real" ? await platform3.getOffsetParent?.(element) : elements.floating; |
| 7313 |
let clientSize = elements.floating[clientProp] || rects.floating[length]; |
| 7314 |
if (!clientSize || !await platform3.isElement?.(arrowOffsetParent)) { |
| 7315 |
clientSize = elements.floating[clientProp] || rects.floating[length]; |
| 7316 |
} |
| 7317 |
const centerToReference = endDiff / 2 - startDiff / 2; |
| 7318 |
const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1; |
| 7319 |
const minPadding = Math.min(paddingObject[minProp], largestPossiblePadding); |
| 7320 |
const maxPadding = Math.min(paddingObject[maxProp], largestPossiblePadding); |
| 7321 |
const min2 = minPadding; |
| 7322 |
const max2 = clientSize - arrowDimensions[length] - maxPadding; |
| 7323 |
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference; |
| 7324 |
const offset4 = clamp(min2, center, max2); |
| 7325 |
const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset4 && rects.reference[length] / 2 - (center < min2 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0; |
| 7326 |
const alignmentOffset = shouldAddOffset ? center < min2 ? center - min2 : center - max2 : 0; |
| 7327 |
return { |
| 7328 |
[axis]: coords[axis] + alignmentOffset, |
| 7329 |
data: { |
| 7330 |
[axis]: offset4, |
| 7331 |
centerOffset: center - offset4 - alignmentOffset, |
| 7332 |
...shouldAddOffset && { |
| 7333 |
alignmentOffset |
| 7334 |
} |
| 7335 |
}, |
| 7336 |
reset: shouldAddOffset |
| 7337 |
}; |
| 7338 |
} |
| 7339 |
}); |
| 7340 |
var arrow4 = (options, deps) => ({ |
| 7341 |
...baseArrow(options), |
| 7342 |
options: [options, deps] |
| 7343 |
}); |
| 7344 |
|
| 7345 |
// node_modules/@base-ui/react/utils/hideMiddleware.mjs |
| 7346 |
var nativeHideFn = hide3().fn; |
| 7347 |
var hide4 = { |
| 7348 |
name: "hide", |
| 7349 |
async fn(state) { |
| 7350 |
const { |
| 7351 |
width, |
| 7352 |
height, |
| 7353 |
x, |
| 7354 |
y |
| 7355 |
} = state.rects.reference; |
| 7356 |
const anchorHidden = width === 0 && height === 0 && x === 0 && y === 0; |
| 7357 |
const nativeHideResult = await nativeHideFn(state); |
| 7358 |
return { |
| 7359 |
data: { |
| 7360 |
referenceHidden: nativeHideResult.data?.referenceHidden || anchorHidden |
| 7361 |
} |
| 7362 |
}; |
| 7363 |
} |
| 7364 |
}; |
| 7365 |
|
| 7366 |
// node_modules/@base-ui/react/utils/adaptiveOriginMiddleware.mjs |
| 7367 |
var DEFAULT_SIDES = { |
| 7368 |
sideX: "left", |
| 7369 |
sideY: "top" |
| 7370 |
}; |
| 7371 |
var adaptiveOrigin = { |
| 7372 |
name: "adaptiveOrigin", |
| 7373 |
async fn(state) { |
| 7374 |
const { |
| 7375 |
x: rawX, |
| 7376 |
y: rawY, |
| 7377 |
rects: { |
| 7378 |
floating: floatRect |
| 7379 |
}, |
| 7380 |
elements: { |
| 7381 |
floating |
| 7382 |
}, |
| 7383 |
platform: platform3, |
| 7384 |
strategy, |
| 7385 |
placement |
| 7386 |
} = state; |
| 7387 |
const win = getWindow(floating); |
| 7388 |
const styles = win.getComputedStyle(floating); |
| 7389 |
const hasTransition = styles.transitionDuration !== "0s" && styles.transitionDuration !== ""; |
| 7390 |
if (!hasTransition) { |
| 7391 |
return { |
| 7392 |
x: rawX, |
| 7393 |
y: rawY, |
| 7394 |
data: DEFAULT_SIDES |
| 7395 |
}; |
| 7396 |
} |
| 7397 |
const offsetParent = await platform3.getOffsetParent?.(floating); |
| 7398 |
let offsetDimensions = { |
| 7399 |
width: 0, |
| 7400 |
height: 0 |
| 7401 |
}; |
| 7402 |
if (strategy === "fixed" && win?.visualViewport) { |
| 7403 |
offsetDimensions = { |
| 7404 |
width: win.visualViewport.width, |
| 7405 |
height: win.visualViewport.height |
| 7406 |
}; |
| 7407 |
} else if (offsetParent === win) { |
| 7408 |
const doc = ownerDocument(floating); |
| 7409 |
offsetDimensions = { |
| 7410 |
width: doc.documentElement.clientWidth, |
| 7411 |
height: doc.documentElement.clientHeight |
| 7412 |
}; |
| 7413 |
} else if (await platform3.isElement?.(offsetParent)) { |
| 7414 |
offsetDimensions = await platform3.getDimensions(offsetParent); |
| 7415 |
} |
| 7416 |
const currentSide = getSide(placement); |
| 7417 |
let x = rawX; |
| 7418 |
let y = rawY; |
| 7419 |
if (currentSide === "left") { |
| 7420 |
x = offsetDimensions.width - (rawX + floatRect.width); |
| 7421 |
} |
| 7422 |
if (currentSide === "top") { |
| 7423 |
y = offsetDimensions.height - (rawY + floatRect.height); |
| 7424 |
} |
| 7425 |
const sideX = currentSide === "left" ? "right" : DEFAULT_SIDES.sideX; |
| 7426 |
const sideY = currentSide === "top" ? "bottom" : DEFAULT_SIDES.sideY; |
| 7427 |
return { |
| 7428 |
x, |
| 7429 |
y, |
| 7430 |
data: { |
| 7431 |
sideX, |
| 7432 |
sideY |
| 7433 |
} |
| 7434 |
}; |
| 7435 |
} |
| 7436 |
}; |
| 7437 |
|
| 7438 |
// node_modules/@base-ui/react/utils/useAnchorPositioning.mjs |
| 7439 |
function getLogicalSide(sideParam, renderedSide, isRtl) { |
| 7440 |
const isLogicalSideParam = sideParam === "inline-start" || sideParam === "inline-end"; |
| 7441 |
const logicalRight = isRtl ? "inline-start" : "inline-end"; |
| 7442 |
const logicalLeft = isRtl ? "inline-end" : "inline-start"; |
| 7443 |
return { |
| 7444 |
top: "top", |
| 7445 |
right: isLogicalSideParam ? logicalRight : "right", |
| 7446 |
bottom: "bottom", |
| 7447 |
left: isLogicalSideParam ? logicalLeft : "left" |
| 7448 |
}[renderedSide]; |
| 7449 |
} |
| 7450 |
function getOffsetData(state, sideParam, isRtl) { |
| 7451 |
const { |
| 7452 |
rects, |
| 7453 |
placement |
| 7454 |
} = state; |
| 7455 |
const data = { |
| 7456 |
side: getLogicalSide(sideParam, getSide(placement), isRtl), |
| 7457 |
align: getAlignment(placement) || "center", |
| 7458 |
anchor: { |
| 7459 |
width: rects.reference.width, |
| 7460 |
height: rects.reference.height |
| 7461 |
}, |
| 7462 |
positioner: { |
| 7463 |
width: rects.floating.width, |
| 7464 |
height: rects.floating.height |
| 7465 |
} |
| 7466 |
}; |
| 7467 |
return data; |
| 7468 |
} |
| 7469 |
function useAnchorPositioning(params) { |
| 7470 |
const { |
| 7471 |
// Public parameters |
| 7472 |
anchor, |
| 7473 |
positionMethod = "absolute", |
| 7474 |
side: sideParam = "bottom", |
| 7475 |
sideOffset = 0, |
| 7476 |
align = "center", |
| 7477 |
alignOffset = 0, |
| 7478 |
collisionBoundary, |
| 7479 |
collisionPadding: collisionPaddingParam = 5, |
| 7480 |
sticky = false, |
| 7481 |
arrowPadding = 5, |
| 7482 |
disableAnchorTracking = false, |
| 7483 |
inline: inlineMiddleware, |
| 7484 |
// Private parameters |
| 7485 |
keepMounted = false, |
| 7486 |
floatingRootContext, |
| 7487 |
mounted, |
| 7488 |
collisionAvoidance, |
| 7489 |
shiftCrossAxis = false, |
| 7490 |
nodeId, |
| 7491 |
adaptiveOrigin: adaptiveOrigin2, |
| 7492 |
lazyFlip = false, |
| 7493 |
externalTree |
| 7494 |
} = params; |
| 7495 |
const [mountSide, setMountSide] = React29.useState(null); |
| 7496 |
if (!mounted && mountSide !== null) { |
| 7497 |
setMountSide(null); |
| 7498 |
} |
| 7499 |
const collisionAvoidanceSide = collisionAvoidance.side || "flip"; |
| 7500 |
const collisionAvoidanceAlign = collisionAvoidance.align || "flip"; |
| 7501 |
const collisionAvoidanceFallbackAxisSide = collisionAvoidance.fallbackAxisSide || "end"; |
| 7502 |
const anchorFn = typeof anchor === "function" ? anchor : void 0; |
| 7503 |
const anchorFnCallback = useStableCallback(anchorFn); |
| 7504 |
const anchorDep = anchorFn ? anchorFnCallback : anchor; |
| 7505 |
const anchorValueRef = useValueAsRef(anchor); |
| 7506 |
const mountedRef = useValueAsRef(mounted); |
| 7507 |
const direction = useDirection(); |
| 7508 |
const isRtl = direction === "rtl"; |
| 7509 |
const side = mountSide || { |
| 7510 |
top: "top", |
| 7511 |
right: "right", |
| 7512 |
bottom: "bottom", |
| 7513 |
left: "left", |
| 7514 |
"inline-end": isRtl ? "left" : "right", |
| 7515 |
"inline-start": isRtl ? "right" : "left" |
| 7516 |
}[sideParam]; |
| 7517 |
const placement = align === "center" ? side : `${side}-${align}`; |
| 7518 |
let collisionPadding = collisionPaddingParam; |
| 7519 |
const bias = 1; |
| 7520 |
const biasTop = sideParam === "bottom" ? bias : 0; |
| 7521 |
const biasBottom = sideParam === "top" ? bias : 0; |
| 7522 |
const biasLeft = sideParam === "right" ? bias : 0; |
| 7523 |
const biasRight = sideParam === "left" ? bias : 0; |
| 7524 |
if (typeof collisionPadding === "number") { |
| 7525 |
collisionPadding = { |
| 7526 |
top: collisionPadding + biasTop, |
| 7527 |
right: collisionPadding + biasRight, |
| 7528 |
bottom: collisionPadding + biasBottom, |
| 7529 |
left: collisionPadding + biasLeft |
| 7530 |
}; |
| 7531 |
} else if (collisionPadding) { |
| 7532 |
collisionPadding = { |
| 7533 |
top: (collisionPadding.top || 0) + biasTop, |
| 7534 |
right: (collisionPadding.right || 0) + biasRight, |
| 7535 |
bottom: (collisionPadding.bottom || 0) + biasBottom, |
| 7536 |
left: (collisionPadding.left || 0) + biasLeft |
| 7537 |
}; |
| 7538 |
} |
| 7539 |
const commonCollisionProps = { |
| 7540 |
boundary: collisionBoundary === "clipping-ancestors" ? "clippingAncestors" : collisionBoundary, |
| 7541 |
padding: collisionPadding |
| 7542 |
}; |
| 7543 |
const arrowRef = React29.useRef(null); |
| 7544 |
const sideOffsetRef = useValueAsRef(sideOffset); |
| 7545 |
const alignOffsetRef = useValueAsRef(alignOffset); |
| 7546 |
const sideOffsetDep = typeof sideOffset !== "function" ? sideOffset : 0; |
| 7547 |
const alignOffsetDep = typeof alignOffset !== "function" ? alignOffset : 0; |
| 7548 |
const middleware = []; |
| 7549 |
if (inlineMiddleware) { |
| 7550 |
middleware.push(inlineMiddleware); |
| 7551 |
} |
| 7552 |
middleware.push(offset3((state) => { |
| 7553 |
const data = getOffsetData(state, sideParam, isRtl); |
| 7554 |
const sideAxis = typeof sideOffsetRef.current === "function" ? sideOffsetRef.current(data) : sideOffsetRef.current; |
| 7555 |
const alignAxis = typeof alignOffsetRef.current === "function" ? alignOffsetRef.current(data) : alignOffsetRef.current; |
| 7556 |
return { |
| 7557 |
mainAxis: sideAxis, |
| 7558 |
crossAxis: alignAxis, |
| 7559 |
alignmentAxis: alignAxis |
| 7560 |
}; |
| 7561 |
}, [sideOffsetDep, alignOffsetDep, isRtl, sideParam])); |
| 7562 |
const shiftDisabled = collisionAvoidanceAlign === "none" && collisionAvoidanceSide !== "shift"; |
| 7563 |
const crossAxisShiftEnabled = !shiftDisabled && (sticky || shiftCrossAxis || collisionAvoidanceSide === "shift"); |
| 7564 |
const flipMiddleware = collisionAvoidanceSide === "none" ? null : flip3({ |
| 7565 |
...commonCollisionProps, |
| 7566 |
// Ensure the popup flips if it's been limited by its --available-height and it resizes. |
| 7567 |
// Since the size() padding is smaller than the flip() padding, flip() will take precedence. |
| 7568 |
padding: { |
| 7569 |
top: collisionPadding.top + bias, |
| 7570 |
right: collisionPadding.right + bias, |
| 7571 |
bottom: collisionPadding.bottom + bias, |
| 7572 |
left: collisionPadding.left + bias |
| 7573 |
}, |
| 7574 |
mainAxis: !shiftCrossAxis && collisionAvoidanceSide === "flip", |
| 7575 |
crossAxis: collisionAvoidanceAlign === "flip" ? "alignment" : false, |
| 7576 |
fallbackAxisSideDirection: collisionAvoidanceFallbackAxisSide |
| 7577 |
}); |
| 7578 |
const shiftMiddleware = shiftDisabled ? null : shift3((data) => { |
| 7579 |
const html = ownerDocument(data.elements.floating).documentElement; |
| 7580 |
return { |
| 7581 |
...commonCollisionProps, |
| 7582 |
// Use the Layout Viewport to avoid shifting around when pinch-zooming |
| 7583 |
// for context menus. |
| 7584 |
rootBoundary: shiftCrossAxis ? { |
| 7585 |
x: 0, |
| 7586 |
y: 0, |
| 7587 |
width: html.clientWidth, |
| 7588 |
height: html.clientHeight |
| 7589 |
} : void 0, |
| 7590 |
mainAxis: collisionAvoidanceAlign !== "none", |
| 7591 |
crossAxis: crossAxisShiftEnabled, |
| 7592 |
limiter: sticky || shiftCrossAxis ? void 0 : limitShift3((limitData) => { |
| 7593 |
if (!arrowRef.current) { |
| 7594 |
return {}; |
| 7595 |
} |
| 7596 |
const { |
| 7597 |
width, |
| 7598 |
height |
| 7599 |
} = arrowRef.current.getBoundingClientRect(); |
| 7600 |
const sideAxis = getSideAxis(getSide(limitData.placement)); |
| 7601 |
const arrowSize = sideAxis === "y" ? width : height; |
| 7602 |
const offsetAmount = sideAxis === "y" ? collisionPadding.left + collisionPadding.right : collisionPadding.top + collisionPadding.bottom; |
| 7603 |
return { |
| 7604 |
offset: arrowSize / 2 + offsetAmount / 2 |
| 7605 |
}; |
| 7606 |
}) |
| 7607 |
}; |
| 7608 |
}, [commonCollisionProps, sticky, shiftCrossAxis, collisionPadding, collisionAvoidanceAlign]); |
| 7609 |
if (collisionAvoidanceSide === "shift" || collisionAvoidanceAlign === "shift" || align === "center") { |
| 7610 |
middleware.push(shiftMiddleware, flipMiddleware); |
| 7611 |
} else { |
| 7612 |
middleware.push(flipMiddleware, shiftMiddleware); |
| 7613 |
} |
| 7614 |
middleware.push(size3({ |
| 7615 |
...commonCollisionProps, |
| 7616 |
apply({ |
| 7617 |
elements: { |
| 7618 |
floating |
| 7619 |
}, |
| 7620 |
availableWidth, |
| 7621 |
availableHeight, |
| 7622 |
rects |
| 7623 |
}) { |
| 7624 |
if (!mountedRef.current) { |
| 7625 |
return; |
| 7626 |
} |
| 7627 |
const floatingStyle = floating.style; |
| 7628 |
floatingStyle.setProperty("--available-width", `${availableWidth}px`); |
| 7629 |
floatingStyle.setProperty("--available-height", `${availableHeight}px`); |
| 7630 |
const dpr = getWindow(floating).devicePixelRatio || 1; |
| 7631 |
const { |
| 7632 |
x: x2, |
| 7633 |
y: y2, |
| 7634 |
width, |
| 7635 |
height |
| 7636 |
} = rects.reference; |
| 7637 |
const anchorWidth = (Math.round((x2 + width) * dpr) - Math.round(x2 * dpr)) / dpr; |
| 7638 |
const anchorHeight = (Math.round((y2 + height) * dpr) - Math.round(y2 * dpr)) / dpr; |
| 7639 |
floatingStyle.setProperty("--anchor-width", `${anchorWidth}px`); |
| 7640 |
floatingStyle.setProperty("--anchor-height", `${anchorHeight}px`); |
| 7641 |
} |
| 7642 |
}), arrow4((state) => ({ |
| 7643 |
// `transform-origin` calculations rely on an element existing. If the arrow hasn't been set, |
| 7644 |
// we'll create a fake element. |
| 7645 |
element: arrowRef.current || ownerDocument(state.elements.floating).createElement("div"), |
| 7646 |
padding: arrowPadding, |
| 7647 |
offsetParent: "floating" |
| 7648 |
}), [arrowPadding]), { |
| 7649 |
name: "transformOrigin", |
| 7650 |
fn(state) { |
| 7651 |
const { |
| 7652 |
elements: elements2, |
| 7653 |
middlewareData: middlewareData2, |
| 7654 |
placement: renderedPlacement2, |
| 7655 |
rects, |
| 7656 |
y: y2 |
| 7657 |
} = state; |
| 7658 |
const currentRenderedSide = getSide(renderedPlacement2); |
| 7659 |
const currentRenderedAxis = getSideAxis(currentRenderedSide); |
| 7660 |
const arrowEl = arrowRef.current; |
| 7661 |
const arrowX = middlewareData2.arrow?.x || 0; |
| 7662 |
const arrowY = middlewareData2.arrow?.y || 0; |
| 7663 |
const arrowWidth = arrowEl?.clientWidth || 0; |
| 7664 |
const arrowHeight = arrowEl?.clientHeight || 0; |
| 7665 |
const transformX = arrowX + arrowWidth / 2; |
| 7666 |
const transformY = arrowY + arrowHeight / 2; |
| 7667 |
const shiftY = Math.abs(middlewareData2.shift?.y || 0); |
| 7668 |
const halfAnchorHeight = rects.reference.height / 2; |
| 7669 |
const sideOffsetValue = typeof sideOffset === "function" ? sideOffset(getOffsetData(state, sideParam, isRtl)) : sideOffset; |
| 7670 |
const isOverlappingAnchor = shiftY > sideOffsetValue; |
| 7671 |
const adjacentTransformOrigin = { |
| 7672 |
top: `${transformX}px calc(100% + ${sideOffsetValue}px)`, |
| 7673 |
bottom: `${transformX}px ${-sideOffsetValue}px`, |
| 7674 |
left: `calc(100% + ${sideOffsetValue}px) ${transformY}px`, |
| 7675 |
right: `${-sideOffsetValue}px ${transformY}px` |
| 7676 |
}[currentRenderedSide]; |
| 7677 |
const overlapTransformOrigin = `${transformX}px ${rects.reference.y + halfAnchorHeight - y2}px`; |
| 7678 |
elements2.floating.style.setProperty("--transform-origin", crossAxisShiftEnabled && currentRenderedAxis === "y" && isOverlappingAnchor ? overlapTransformOrigin : adjacentTransformOrigin); |
| 7679 |
return {}; |
| 7680 |
} |
| 7681 |
}, hide4, adaptiveOrigin2); |
| 7682 |
useIsoLayoutEffect(() => { |
| 7683 |
if (!mounted && floatingRootContext) { |
| 7684 |
floatingRootContext.update({ |
| 7685 |
referenceElement: null, |
| 7686 |
floatingElement: null, |
| 7687 |
domReferenceElement: null, |
| 7688 |
positionReference: null |
| 7689 |
}); |
| 7690 |
} |
| 7691 |
}, [mounted, floatingRootContext]); |
| 7692 |
const autoUpdateOptions = React29.useMemo(() => ({ |
| 7693 |
elementResize: !disableAnchorTracking && typeof ResizeObserver !== "undefined", |
| 7694 |
layoutShift: !disableAnchorTracking && typeof IntersectionObserver !== "undefined" |
| 7695 |
}), [disableAnchorTracking]); |
| 7696 |
const { |
| 7697 |
refs, |
| 7698 |
elements, |
| 7699 |
x, |
| 7700 |
y, |
| 7701 |
middlewareData, |
| 7702 |
update: update2, |
| 7703 |
placement: renderedPlacement, |
| 7704 |
context, |
| 7705 |
isPositioned, |
| 7706 |
floatingStyles: originalFloatingStyles |
| 7707 |
} = useFloating2({ |
| 7708 |
rootContext: floatingRootContext, |
| 7709 |
open: keepMounted ? mounted : void 0, |
| 7710 |
placement, |
| 7711 |
middleware, |
| 7712 |
strategy: positionMethod, |
| 7713 |
whileElementsMounted: keepMounted ? void 0 : (...args) => autoUpdate(...args, autoUpdateOptions), |
| 7714 |
nodeId, |
| 7715 |
externalTree |
| 7716 |
}); |
| 7717 |
const { |
| 7718 |
sideX, |
| 7719 |
sideY |
| 7720 |
} = middlewareData.adaptiveOrigin || DEFAULT_SIDES; |
| 7721 |
const resolvedPosition = isPositioned ? positionMethod : "fixed"; |
| 7722 |
const floatingStyles = React29.useMemo(() => { |
| 7723 |
const base = adaptiveOrigin2 ? { |
| 7724 |
position: resolvedPosition, |
| 7725 |
[sideX]: x, |
| 7726 |
[sideY]: y |
| 7727 |
} : { |
| 7728 |
position: resolvedPosition, |
| 7729 |
...originalFloatingStyles |
| 7730 |
}; |
| 7731 |
if (!isPositioned) { |
| 7732 |
base.opacity = 0; |
| 7733 |
} |
| 7734 |
return base; |
| 7735 |
}, [adaptiveOrigin2, resolvedPosition, sideX, x, sideY, y, originalFloatingStyles, isPositioned]); |
| 7736 |
const registeredPositionReferenceRef = React29.useRef(null); |
| 7737 |
useIsoLayoutEffect(() => { |
| 7738 |
if (!mounted) { |
| 7739 |
return; |
| 7740 |
} |
| 7741 |
const anchorValue = anchorValueRef.current; |
| 7742 |
const resolvedAnchor = typeof anchorValue === "function" ? anchorValue() : anchorValue; |
| 7743 |
const unwrappedElement = (isRef(resolvedAnchor) ? resolvedAnchor.current : resolvedAnchor) || null; |
| 7744 |
const finalAnchor = unwrappedElement || null; |
| 7745 |
if (finalAnchor !== registeredPositionReferenceRef.current) { |
| 7746 |
refs.setPositionReference(finalAnchor); |
| 7747 |
registeredPositionReferenceRef.current = finalAnchor; |
| 7748 |
} |
| 7749 |
}, [mounted, refs, anchorDep, anchorValueRef]); |
| 7750 |
React29.useEffect(() => { |
| 7751 |
if (!mounted) { |
| 7752 |
return; |
| 7753 |
} |
| 7754 |
const anchorValue = anchorValueRef.current; |
| 7755 |
if (typeof anchorValue === "function") { |
| 7756 |
return; |
| 7757 |
} |
| 7758 |
if (isRef(anchorValue) && anchorValue.current !== registeredPositionReferenceRef.current) { |
| 7759 |
refs.setPositionReference(anchorValue.current); |
| 7760 |
registeredPositionReferenceRef.current = anchorValue.current; |
| 7761 |
} |
| 7762 |
}, [mounted, refs, anchorDep, anchorValueRef]); |
| 7763 |
React29.useEffect(() => { |
| 7764 |
if (keepMounted && mounted && elements.reference && elements.floating) { |
| 7765 |
return autoUpdate(elements.reference, elements.floating, update2, autoUpdateOptions); |
| 7766 |
} |
| 7767 |
return void 0; |
| 7768 |
}, [keepMounted, mounted, elements, update2, autoUpdateOptions]); |
| 7769 |
const renderedSide = getSide(renderedPlacement); |
| 7770 |
const logicalRenderedSide = getLogicalSide(sideParam, renderedSide, isRtl); |
| 7771 |
const renderedAlign = getAlignment(renderedPlacement) || "center"; |
| 7772 |
const anchorHidden = Boolean(middlewareData.hide?.referenceHidden); |
| 7773 |
useIsoLayoutEffect(() => { |
| 7774 |
if (lazyFlip && mounted && isPositioned) { |
| 7775 |
setMountSide(renderedSide); |
| 7776 |
} |
| 7777 |
}, [lazyFlip, mounted, isPositioned, renderedSide]); |
| 7778 |
const arrowStyles = React29.useMemo(() => ({ |
| 7779 |
position: "absolute", |
| 7780 |
top: middlewareData.arrow?.y, |
| 7781 |
left: middlewareData.arrow?.x |
| 7782 |
}), [middlewareData.arrow]); |
| 7783 |
const arrowUncentered = middlewareData.arrow?.centerOffset !== 0; |
| 7784 |
return React29.useMemo(() => ({ |
| 7785 |
positionerStyles: floatingStyles, |
| 7786 |
arrowStyles, |
| 7787 |
arrowRef, |
| 7788 |
arrowUncentered, |
| 7789 |
side: logicalRenderedSide, |
| 7790 |
align: renderedAlign, |
| 7791 |
physicalSide: renderedSide, |
| 7792 |
anchorHidden, |
| 7793 |
refs, |
| 7794 |
context, |
| 7795 |
isPositioned, |
| 7796 |
update: update2 |
| 7797 |
}), [floatingStyles, arrowStyles, arrowRef, arrowUncentered, logicalRenderedSide, renderedAlign, renderedSide, anchorHidden, refs, context, isPositioned, update2]); |
| 7798 |
} |
| 7799 |
function isRef(param) { |
| 7800 |
return param != null && "current" in param; |
| 7801 |
} |
| 7802 |
|
| 7803 |
// node_modules/@base-ui/react/utils/getDisabledMountTransitionStyles.mjs |
| 7804 |
function getDisabledMountTransitionStyles(transitionStatus) { |
| 7805 |
return transitionStatus === "starting" ? DISABLED_TRANSITIONS_STYLE : EMPTY_OBJECT; |
| 7806 |
} |
| 7807 |
|
| 7808 |
// node_modules/@base-ui/react/utils/usePositioner.mjs |
| 7809 |
function usePositioner(componentProps, state, { |
| 7810 |
styles, |
| 7811 |
transitionStatus, |
| 7812 |
props, |
| 7813 |
refs, |
| 7814 |
hidden, |
| 7815 |
inert = false |
| 7816 |
}) { |
| 7817 |
const style = { |
| 7818 |
...styles |
| 7819 |
}; |
| 7820 |
if (inert) { |
| 7821 |
style.pointerEvents = "none"; |
| 7822 |
} |
| 7823 |
return useRenderElement("div", componentProps, { |
| 7824 |
state, |
| 7825 |
ref: refs, |
| 7826 |
props: [{ |
| 7827 |
role: "presentation", |
| 7828 |
hidden, |
| 7829 |
style |
| 7830 |
}, getDisabledMountTransitionStyles(transitionStatus), props], |
| 7831 |
stateAttributesMapping: popupStateMapping |
| 7832 |
}); |
| 7833 |
} |
| 7834 |
|
| 7835 |
// node_modules/@base-ui/react/utils/usePopupViewport.mjs |
| 7836 |
var React32 = __toESM(require_react(), 1); |
| 7837 |
var ReactDOM6 = __toESM(require_react_dom(), 1); |
| 7838 |
|
| 7839 |
// node_modules/@base-ui/utils/usePreviousValue.mjs |
| 7840 |
var React30 = __toESM(require_react(), 1); |
| 7841 |
function usePreviousValue(value) { |
| 7842 |
const [state, setState] = React30.useState({ |
| 7843 |
current: value, |
| 7844 |
previous: null |
| 7845 |
}); |
| 7846 |
if (value !== state.current) { |
| 7847 |
setState({ |
| 7848 |
current: value, |
| 7849 |
previous: state.current |
| 7850 |
}); |
| 7851 |
} |
| 7852 |
return state.previous; |
| 7853 |
} |
| 7854 |
|
| 7855 |
// node_modules/@base-ui/react/utils/usePopupAutoResize.mjs |
| 7856 |
var React31 = __toESM(require_react(), 1); |
| 7857 |
|
| 7858 |
// node_modules/@base-ui/react/utils/getCssDimensions.mjs |
| 7859 |
function getCssDimensions2(element) { |
| 7860 |
const css = getComputedStyle2(element); |
| 7861 |
let width = parseFloat(css.width) || 0; |
| 7862 |
let height = parseFloat(css.height) || 0; |
| 7863 |
const hasOffset = isHTMLElement(element); |
| 7864 |
const offsetWidth = hasOffset ? element.offsetWidth : width; |
| 7865 |
const offsetHeight = hasOffset ? element.offsetHeight : height; |
| 7866 |
const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight; |
| 7867 |
if (shouldFallback) { |
| 7868 |
width = offsetWidth; |
| 7869 |
height = offsetHeight; |
| 7870 |
} |
| 7871 |
return { |
| 7872 |
width, |
| 7873 |
height |
| 7874 |
}; |
| 7875 |
} |
| 7876 |
|
| 7877 |
// node_modules/@base-ui/react/utils/usePopupAutoResize.mjs |
| 7878 |
function usePopupAutoResize(parameters) { |
| 7879 |
const { |
| 7880 |
popupElement, |
| 7881 |
positionerElement, |
| 7882 |
content, |
| 7883 |
mounted, |
| 7884 |
onMeasureLayout: onMeasureLayoutParam, |
| 7885 |
onMeasureLayoutComplete: onMeasureLayoutCompleteParam, |
| 7886 |
side, |
| 7887 |
direction |
| 7888 |
} = parameters; |
| 7889 |
const runOnceAnimationsFinish = useAnimationsFinished(popupElement, true, false); |
| 7890 |
const animationFrame = useAnimationFrame(); |
| 7891 |
const committedDimensionsRef = React31.useRef(null); |
| 7892 |
const isInitialRenderRef = React31.useRef(true); |
| 7893 |
const restoreAnchoringStylesRef = React31.useRef(NOOP); |
| 7894 |
const onMeasureLayout = useStableCallback(onMeasureLayoutParam); |
| 7895 |
const onMeasureLayoutComplete = useStableCallback(onMeasureLayoutCompleteParam); |
| 7896 |
const anchoringStyles = React31.useMemo(() => { |
| 7897 |
let isOriginSide = side === "top"; |
| 7898 |
let isPhysicalLeft = side === "left"; |
| 7899 |
if (direction === "rtl") { |
| 7900 |
isOriginSide = isOriginSide || side === "inline-end"; |
| 7901 |
isPhysicalLeft = isPhysicalLeft || side === "inline-end"; |
| 7902 |
} else { |
| 7903 |
isOriginSide = isOriginSide || side === "inline-start"; |
| 7904 |
isPhysicalLeft = isPhysicalLeft || side === "inline-start"; |
| 7905 |
} |
| 7906 |
return isOriginSide ? { |
| 7907 |
position: "absolute", |
| 7908 |
[side === "top" ? "bottom" : "top"]: "0", |
| 7909 |
[isPhysicalLeft ? "right" : "left"]: "0" |
| 7910 |
} : EMPTY_OBJECT; |
| 7911 |
}, [side, direction]); |
| 7912 |
useIsoLayoutEffect(() => { |
| 7913 |
if (!mounted) { |
| 7914 |
restoreAnchoringStylesRef.current = NOOP; |
| 7915 |
isInitialRenderRef.current = true; |
| 7916 |
committedDimensionsRef.current = null; |
| 7917 |
return void 0; |
| 7918 |
} |
| 7919 |
if (!popupElement || !positionerElement) { |
| 7920 |
return void 0; |
| 7921 |
} |
| 7922 |
restoreAnchoringStylesRef.current = applyElementStyles(popupElement, anchoringStyles); |
| 7923 |
setPopupCssSize(popupElement, "auto"); |
| 7924 |
const restorePopupPosition = overrideElementStyle(popupElement, "position", "static"); |
| 7925 |
const restorePopupTransform = overrideElementStyle(popupElement, "transform", "none"); |
| 7926 |
const restorePopupScale = overrideElementStyle(popupElement, "scale", "1"); |
| 7927 |
const restorePositionerAvailableSize = applyElementStyles(positionerElement, { |
| 7928 |
"--available-width": "max-content", |
| 7929 |
"--available-height": "max-content" |
| 7930 |
}); |
| 7931 |
function restoreMeasurementOverrides() { |
| 7932 |
restorePopupPosition(); |
| 7933 |
restorePopupTransform(); |
| 7934 |
restorePositionerAvailableSize(); |
| 7935 |
} |
| 7936 |
function restoreMeasurementOverridesIncludingScale() { |
| 7937 |
restoreMeasurementOverrides(); |
| 7938 |
restorePopupScale(); |
| 7939 |
} |
| 7940 |
onMeasureLayout?.(); |
| 7941 |
if (isInitialRenderRef.current || committedDimensionsRef.current === null) { |
| 7942 |
setPositionerCssSize(positionerElement, "max-content"); |
| 7943 |
const dimensions = getCssDimensions2(popupElement); |
| 7944 |
committedDimensionsRef.current = dimensions; |
| 7945 |
setPositionerCssSize(positionerElement, dimensions); |
| 7946 |
restoreMeasurementOverridesIncludingScale(); |
| 7947 |
onMeasureLayoutComplete?.(null, dimensions); |
| 7948 |
isInitialRenderRef.current = false; |
| 7949 |
return () => { |
| 7950 |
restoreAnchoringStylesRef.current(); |
| 7951 |
restoreAnchoringStylesRef.current = NOOP; |
| 7952 |
}; |
| 7953 |
} |
| 7954 |
setPositionerCssSize(positionerElement, "max-content"); |
| 7955 |
const previousDimensions = committedDimensionsRef.current; |
| 7956 |
const newDimensions = getCssDimensions2(popupElement); |
| 7957 |
committedDimensionsRef.current = newDimensions; |
| 7958 |
setPopupCssSize(popupElement, previousDimensions); |
| 7959 |
restoreMeasurementOverridesIncludingScale(); |
| 7960 |
onMeasureLayoutComplete?.(previousDimensions, newDimensions); |
| 7961 |
setPositionerCssSize(positionerElement, newDimensions); |
| 7962 |
const abortController = new AbortController(); |
| 7963 |
animationFrame.request(() => { |
| 7964 |
setPopupCssSize(popupElement, newDimensions); |
| 7965 |
runOnceAnimationsFinish(() => { |
| 7966 |
popupElement.style.setProperty("--popup-width", "auto"); |
| 7967 |
popupElement.style.setProperty("--popup-height", "auto"); |
| 7968 |
}, abortController.signal); |
| 7969 |
}); |
| 7970 |
return () => { |
| 7971 |
abortController.abort(); |
| 7972 |
animationFrame.cancel(); |
| 7973 |
restoreAnchoringStylesRef.current(); |
| 7974 |
restoreAnchoringStylesRef.current = NOOP; |
| 7975 |
}; |
| 7976 |
}, [content, popupElement, positionerElement, runOnceAnimationsFinish, animationFrame, mounted, onMeasureLayout, onMeasureLayoutComplete, anchoringStyles]); |
| 7977 |
} |
| 7978 |
function overrideElementStyle(element, property, value) { |
| 7979 |
const originalValue = element.style.getPropertyValue(property); |
| 7980 |
element.style.setProperty(property, value); |
| 7981 |
return () => { |
| 7982 |
element.style.setProperty(property, originalValue); |
| 7983 |
}; |
| 7984 |
} |
| 7985 |
function applyElementStyles(element, styles) { |
| 7986 |
const restorers = []; |
| 7987 |
for (const [key, value] of Object.entries(styles)) { |
| 7988 |
restorers.push(overrideElementStyle(element, key, value)); |
| 7989 |
} |
| 7990 |
return restorers.length ? () => { |
| 7991 |
restorers.forEach((restore) => restore()); |
| 7992 |
} : NOOP; |
| 7993 |
} |
| 7994 |
function setPopupCssSize(popupElement, size4) { |
| 7995 |
const width = size4 === "auto" ? "auto" : `${size4.width}px`; |
| 7996 |
const height = size4 === "auto" ? "auto" : `${size4.height}px`; |
| 7997 |
popupElement.style.setProperty("--popup-width", width); |
| 7998 |
popupElement.style.setProperty("--popup-height", height); |
| 7999 |
} |
| 8000 |
function setPositionerCssSize(positionerElement, size4) { |
| 8001 |
const width = size4 === "max-content" ? "max-content" : `${size4.width}px`; |
| 8002 |
const height = size4 === "max-content" ? "max-content" : `${size4.height}px`; |
| 8003 |
positionerElement.style.setProperty("--positioner-width", width); |
| 8004 |
positionerElement.style.setProperty("--positioner-height", height); |
| 8005 |
} |
| 8006 |
|
| 8007 |
// node_modules/@base-ui/react/utils/usePopupViewport.mjs |
| 8008 |
var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1); |
| 8009 |
function usePopupViewport(parameters) { |
| 8010 |
const { |
| 8011 |
store: store2, |
| 8012 |
side, |
| 8013 |
cssVars, |
| 8014 |
children |
| 8015 |
} = parameters; |
| 8016 |
const direction = useDirection(); |
| 8017 |
const activeTrigger = store2.useState("activeTriggerElement"); |
| 8018 |
const activeTriggerId = store2.useState("activeTriggerId"); |
| 8019 |
const open = store2.useState("open"); |
| 8020 |
const payload = store2.useState("payload"); |
| 8021 |
const mounted = store2.useState("mounted"); |
| 8022 |
const popupElement = store2.useState("popupElement"); |
| 8023 |
const positionerElement = store2.useState("positionerElement"); |
| 8024 |
const previousActiveTrigger = usePreviousValue(open ? activeTrigger : null); |
| 8025 |
const currentContentKey = usePopupContentKey(activeTriggerId, payload); |
| 8026 |
const capturedNodeRef = React32.useRef(null); |
| 8027 |
const [previousContentNode, setPreviousContentNode] = React32.useState(null); |
| 8028 |
const [newTriggerOffset, setNewTriggerOffset] = React32.useState(null); |
| 8029 |
const currentContainerRef = React32.useRef(null); |
| 8030 |
const previousContainerRef = React32.useRef(null); |
| 8031 |
const onAnimationsFinished = useAnimationsFinished(currentContainerRef, true, false); |
| 8032 |
const cleanupFrame = useAnimationFrame(); |
| 8033 |
const [previousContentDimensions, setPreviousContentDimensions] = React32.useState(null); |
| 8034 |
const [showStartingStyleAttribute, setShowStartingStyleAttribute] = React32.useState(false); |
| 8035 |
useIsoLayoutEffect(() => { |
| 8036 |
store2.set("hasViewport", true); |
| 8037 |
return () => { |
| 8038 |
store2.set("hasViewport", false); |
| 8039 |
}; |
| 8040 |
}, [store2]); |
| 8041 |
const handleMeasureLayout = useStableCallback(() => { |
| 8042 |
currentContainerRef.current?.style.setProperty("animation", "none"); |
| 8043 |
currentContainerRef.current?.style.setProperty("transition", "none"); |
| 8044 |
previousContainerRef.current?.style.setProperty("display", "none"); |
| 8045 |
}); |
| 8046 |
const handleMeasureLayoutComplete = useStableCallback((previousDimensions) => { |
| 8047 |
currentContainerRef.current?.style.removeProperty("animation"); |
| 8048 |
currentContainerRef.current?.style.removeProperty("transition"); |
| 8049 |
previousContainerRef.current?.style.removeProperty("display"); |
| 8050 |
if (previousDimensions) { |
| 8051 |
setPreviousContentDimensions(previousDimensions); |
| 8052 |
} |
| 8053 |
}); |
| 8054 |
const lastHandledTriggerRef = React32.useRef(null); |
| 8055 |
useIsoLayoutEffect(() => { |
| 8056 |
if (!open || !mounted) { |
| 8057 |
lastHandledTriggerRef.current = null; |
| 8058 |
} |
| 8059 |
}, [open, mounted]); |
| 8060 |
useIsoLayoutEffect(() => { |
| 8061 |
if (activeTrigger && previousActiveTrigger && activeTrigger !== previousActiveTrigger && lastHandledTriggerRef.current !== activeTrigger && capturedNodeRef.current) { |
| 8062 |
setPreviousContentNode(capturedNodeRef.current); |
| 8063 |
setShowStartingStyleAttribute(true); |
| 8064 |
const offset4 = calculateRelativePosition(previousActiveTrigger, activeTrigger); |
| 8065 |
setNewTriggerOffset(offset4); |
| 8066 |
cleanupFrame.request(() => { |
| 8067 |
ReactDOM6.flushSync(() => { |
| 8068 |
setShowStartingStyleAttribute(false); |
| 8069 |
}); |
| 8070 |
onAnimationsFinished(() => { |
| 8071 |
setPreviousContentNode(null); |
| 8072 |
setPreviousContentDimensions(null); |
| 8073 |
capturedNodeRef.current = null; |
| 8074 |
}); |
| 8075 |
}); |
| 8076 |
lastHandledTriggerRef.current = activeTrigger; |
| 8077 |
} |
| 8078 |
}, [activeTrigger, previousActiveTrigger, previousContentNode, onAnimationsFinished, cleanupFrame]); |
| 8079 |
useIsoLayoutEffect(() => { |
| 8080 |
const source = currentContainerRef.current; |
| 8081 |
if (!source) { |
| 8082 |
return; |
| 8083 |
} |
| 8084 |
const wrapper = ownerDocument(source).createElement("div"); |
| 8085 |
for (const child of Array.from(source.childNodes)) { |
| 8086 |
wrapper.appendChild(child.cloneNode(true)); |
| 8087 |
} |
| 8088 |
capturedNodeRef.current = wrapper; |
| 8089 |
}); |
| 8090 |
const isTransitioning = previousContentNode != null; |
| 8091 |
let childrenToRender; |
| 8092 |
if (!isTransitioning) { |
| 8093 |
childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { |
| 8094 |
"data-current": true, |
| 8095 |
ref: currentContainerRef, |
| 8096 |
children |
| 8097 |
}, currentContentKey); |
| 8098 |
} else { |
| 8099 |
childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(React32.Fragment, { |
| 8100 |
children: [/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { |
| 8101 |
"data-previous": true, |
| 8102 |
inert: inertValue(true), |
| 8103 |
ref: previousContainerRef, |
| 8104 |
style: { |
| 8105 |
...previousContentDimensions ? { |
| 8106 |
[cssVars.popupWidth]: `${previousContentDimensions.width}px`, |
| 8107 |
[cssVars.popupHeight]: `${previousContentDimensions.height}px` |
| 8108 |
} : null, |
| 8109 |
position: "absolute" |
| 8110 |
}, |
| 8111 |
"data-ending-style": showStartingStyleAttribute ? void 0 : "" |
| 8112 |
}, "previous"), /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { |
| 8113 |
"data-current": true, |
| 8114 |
ref: currentContainerRef, |
| 8115 |
"data-starting-style": showStartingStyleAttribute ? "" : void 0, |
| 8116 |
children |
| 8117 |
}, currentContentKey)] |
| 8118 |
}); |
| 8119 |
} |
| 8120 |
useIsoLayoutEffect(() => { |
| 8121 |
const container = previousContainerRef.current; |
| 8122 |
if (!container || !previousContentNode) { |
| 8123 |
return; |
| 8124 |
} |
| 8125 |
container.replaceChildren(...Array.from(previousContentNode.childNodes)); |
| 8126 |
}, [previousContentNode]); |
| 8127 |
usePopupAutoResize({ |
| 8128 |
popupElement, |
| 8129 |
positionerElement, |
| 8130 |
mounted, |
| 8131 |
content: payload, |
| 8132 |
onMeasureLayout: handleMeasureLayout, |
| 8133 |
onMeasureLayoutComplete: handleMeasureLayoutComplete, |
| 8134 |
side, |
| 8135 |
direction |
| 8136 |
}); |
| 8137 |
const state = { |
| 8138 |
activationDirection: getActivationDirection(newTriggerOffset), |
| 8139 |
transitioning: isTransitioning |
| 8140 |
}; |
| 8141 |
return { |
| 8142 |
children: childrenToRender, |
| 8143 |
state |
| 8144 |
}; |
| 8145 |
} |
| 8146 |
function getActivationDirection(offset4) { |
| 8147 |
if (!offset4) { |
| 8148 |
return void 0; |
| 8149 |
} |
| 8150 |
return `${getValueWithTolerance(offset4.horizontal, 5, "right", "left")} ${getValueWithTolerance(offset4.vertical, 5, "down", "up")}`; |
| 8151 |
} |
| 8152 |
function getValueWithTolerance(value, tolerance, positiveLabel, negativeLabel) { |
| 8153 |
if (value > tolerance) { |
| 8154 |
return positiveLabel; |
| 8155 |
} |
| 8156 |
if (value < -tolerance) { |
| 8157 |
return negativeLabel; |
| 8158 |
} |
| 8159 |
return ""; |
| 8160 |
} |
| 8161 |
function calculateRelativePosition(from, to) { |
| 8162 |
const fromRect = from.getBoundingClientRect(); |
| 8163 |
const toRect = to.getBoundingClientRect(); |
| 8164 |
const fromCenter = { |
| 8165 |
x: fromRect.left + fromRect.width / 2, |
| 8166 |
y: fromRect.top + fromRect.height / 2 |
| 8167 |
}; |
| 8168 |
const toCenter = { |
| 8169 |
x: toRect.left + toRect.width / 2, |
| 8170 |
y: toRect.top + toRect.height / 2 |
| 8171 |
}; |
| 8172 |
return { |
| 8173 |
horizontal: toCenter.x - fromCenter.x, |
| 8174 |
vertical: toCenter.y - fromCenter.y |
| 8175 |
}; |
| 8176 |
} |
| 8177 |
function usePopupContentKey(activeTriggerId, payload) { |
| 8178 |
const [contentKey, setContentKey] = React32.useState(0); |
| 8179 |
const previousActiveTriggerIdRef = React32.useRef(activeTriggerId); |
| 8180 |
const previousPayloadRef = React32.useRef(payload); |
| 8181 |
const pendingPayloadUpdateRef = React32.useRef(false); |
| 8182 |
useIsoLayoutEffect(() => { |
| 8183 |
const previousActiveTriggerId = previousActiveTriggerIdRef.current; |
| 8184 |
const previousPayload = previousPayloadRef.current; |
| 8185 |
const triggerIdChanged = activeTriggerId !== previousActiveTriggerId; |
| 8186 |
const payloadChanged = payload !== previousPayload; |
| 8187 |
if (triggerIdChanged) { |
| 8188 |
setContentKey((value) => value + 1); |
| 8189 |
pendingPayloadUpdateRef.current = !payloadChanged; |
| 8190 |
} else if (pendingPayloadUpdateRef.current && payloadChanged) { |
| 8191 |
setContentKey((value) => value + 1); |
| 8192 |
pendingPayloadUpdateRef.current = false; |
| 8193 |
} |
| 8194 |
previousActiveTriggerIdRef.current = activeTriggerId; |
| 8195 |
previousPayloadRef.current = payload; |
| 8196 |
}, [activeTriggerId, payload]); |
| 8197 |
return `${activeTriggerId ?? "current"}-${contentKey}`; |
| 8198 |
} |
| 8199 |
|
| 8200 |
// node_modules/@base-ui/react/utils/FloatingPortalLite.mjs |
| 8201 |
var React33 = __toESM(require_react(), 1); |
| 8202 |
var ReactDOM7 = __toESM(require_react_dom(), 1); |
| 8203 |
var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1); |
| 8204 |
var FloatingPortalLite = /* @__PURE__ */ React33.forwardRef(function FloatingPortalLite2(componentProps, forwardedRef) { |
| 8205 |
const { |
| 8206 |
children, |
| 8207 |
container, |
| 8208 |
className, |
| 8209 |
render, |
| 8210 |
style, |
| 8211 |
...elementProps |
| 8212 |
} = componentProps; |
| 8213 |
const { |
| 8214 |
portalNode, |
| 8215 |
portalSubtree |
| 8216 |
} = useFloatingPortalNode({ |
| 8217 |
container, |
| 8218 |
ref: forwardedRef, |
| 8219 |
componentProps, |
| 8220 |
elementProps |
| 8221 |
}); |
| 8222 |
if (!portalSubtree && !portalNode) { |
| 8223 |
return null; |
| 8224 |
} |
| 8225 |
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(React33.Fragment, { |
| 8226 |
children: [portalSubtree, portalNode && /* @__PURE__ */ ReactDOM7.createPortal(children, portalNode)] |
| 8227 |
}); |
| 8228 |
}); |
| 8229 |
if (true) FloatingPortalLite.displayName = "FloatingPortalLite"; |
| 8230 |
|
| 8231 |
// node_modules/@base-ui/react/tooltip/index.parts.mjs |
| 8232 |
var index_parts_exports = {}; |
| 8233 |
__export(index_parts_exports, { |
| 8234 |
Arrow: () => TooltipArrow, |
| 8235 |
Handle: () => TooltipHandle, |
| 8236 |
Popup: () => TooltipPopup, |
| 8237 |
Portal: () => TooltipPortal, |
| 8238 |
Positioner: () => TooltipPositioner, |
| 8239 |
Provider: () => TooltipProvider, |
| 8240 |
Root: () => TooltipRoot, |
| 8241 |
Trigger: () => TooltipTrigger, |
| 8242 |
Viewport: () => TooltipViewport, |
| 8243 |
createHandle: () => createTooltipHandle |
| 8244 |
}); |
| 8245 |
|
| 8246 |
// node_modules/@base-ui/react/tooltip/root/TooltipRoot.mjs |
| 8247 |
var React36 = __toESM(require_react(), 1); |
| 8248 |
|
| 8249 |
// node_modules/@base-ui/react/tooltip/root/TooltipRootContext.mjs |
| 8250 |
var React34 = __toESM(require_react(), 1); |
| 8251 |
var TooltipRootContext = /* @__PURE__ */ React34.createContext(void 0); |
| 8252 |
if (true) TooltipRootContext.displayName = "TooltipRootContext"; |
| 8253 |
function useTooltipRootContext(optional) { |
| 8254 |
const context = React34.useContext(TooltipRootContext); |
| 8255 |
if (context === void 0 && !optional) { |
| 8256 |
throw new Error(true ? "Base UI: TooltipRootContext is missing. Tooltip parts must be placed within <Tooltip.Root>." : formatErrorMessage_default(72)); |
| 8257 |
} |
| 8258 |
return context; |
| 8259 |
} |
| 8260 |
|
| 8261 |
// node_modules/@base-ui/react/tooltip/store/TooltipStore.mjs |
| 8262 |
var React35 = __toESM(require_react(), 1); |
| 8263 |
var selectors2 = { |
| 8264 |
...popupStoreSelectors, |
| 8265 |
disabled: createSelector2((state) => state.disabled), |
| 8266 |
instantType: createSelector2((state) => state.instantType), |
| 8267 |
isInstantPhase: createSelector2((state) => state.isInstantPhase), |
| 8268 |
trackCursorAxis: createSelector2((state) => state.trackCursorAxis), |
| 8269 |
disableHoverablePopup: createSelector2((state) => state.disableHoverablePopup), |
| 8270 |
lastOpenChangeReason: createSelector2((state) => state.openChangeReason), |
| 8271 |
closeOnClick: createSelector2((state) => state.closeOnClick), |
| 8272 |
closeDelay: createSelector2((state) => state.closeDelay), |
| 8273 |
hasViewport: createSelector2((state) => state.hasViewport) |
| 8274 |
}; |
| 8275 |
var TooltipStore = class _TooltipStore extends ReactStore { |
| 8276 |
constructor(initialState, floatingId, nested = false) { |
| 8277 |
const triggerElements = new PopupTriggerMap(); |
| 8278 |
const state = { |
| 8279 |
...createInitialState(), |
| 8280 |
...initialState |
| 8281 |
}; |
| 8282 |
state.floatingRootContext = createPopupFloatingRootContext(triggerElements, floatingId, nested); |
| 8283 |
super(state, { |
| 8284 |
popupRef: /* @__PURE__ */ React35.createRef(), |
| 8285 |
onOpenChange: void 0, |
| 8286 |
onOpenChangeComplete: void 0, |
| 8287 |
triggerElements |
| 8288 |
}, selectors2); |
| 8289 |
} |
| 8290 |
setOpen = (nextOpen, eventDetails) => { |
| 8291 |
applyPopupOpenChange(this, nextOpen, eventDetails, { |
| 8292 |
extraState: { |
| 8293 |
openChangeReason: eventDetails.reason |
| 8294 |
} |
| 8295 |
}); |
| 8296 |
}; |
| 8297 |
// Used by trigger clicks to clear a delayed hover open without reporting a public open-state change. |
| 8298 |
cancelPendingOpen(event) { |
| 8299 |
this.state.floatingRootContext.dispatchOpenChange(false, createChangeEventDetails(reason_parts_exports.triggerPress, event)); |
| 8300 |
} |
| 8301 |
static useStore(externalStore, initialState) { |
| 8302 |
const store2 = usePopupStore(externalStore, (floatingId, nested) => new _TooltipStore(initialState, floatingId, nested)).store; |
| 8303 |
return store2; |
| 8304 |
} |
| 8305 |
}; |
| 8306 |
function createInitialState() { |
| 8307 |
return { |
| 8308 |
...createInitialPopupStoreState(), |
| 8309 |
disabled: false, |
| 8310 |
instantType: void 0, |
| 8311 |
isInstantPhase: false, |
| 8312 |
trackCursorAxis: "none", |
| 8313 |
disableHoverablePopup: false, |
| 8314 |
openChangeReason: null, |
| 8315 |
closeOnClick: true, |
| 8316 |
closeDelay: 0, |
| 8317 |
hasViewport: false |
| 8318 |
}; |
| 8319 |
} |
| 8320 |
|
| 8321 |
// node_modules/@base-ui/react/tooltip/root/TooltipRoot.mjs |
| 8322 |
var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1); |
| 8323 |
var TooltipRoot = fastComponent(function TooltipRoot2(props) { |
| 8324 |
const { |
| 8325 |
disabled: disabled2 = false, |
| 8326 |
defaultOpen = false, |
| 8327 |
open: openProp, |
| 8328 |
disableHoverablePopup = false, |
| 8329 |
trackCursorAxis = "none", |
| 8330 |
actionsRef, |
| 8331 |
onOpenChange, |
| 8332 |
onOpenChangeComplete, |
| 8333 |
handle, |
| 8334 |
triggerId: triggerIdProp, |
| 8335 |
defaultTriggerId: defaultTriggerIdProp = null, |
| 8336 |
children |
| 8337 |
} = props; |
| 8338 |
const store2 = TooltipStore.useStore(handle?.store, { |
| 8339 |
open: defaultOpen, |
| 8340 |
openProp, |
| 8341 |
activeTriggerId: defaultTriggerIdProp, |
| 8342 |
triggerIdProp |
| 8343 |
}); |
| 8344 |
useInitialOpenSync(store2, openProp, defaultOpen, defaultTriggerIdProp); |
| 8345 |
store2.useControlledProp("openProp", openProp); |
| 8346 |
store2.useControlledProp("triggerIdProp", triggerIdProp); |
| 8347 |
store2.useContextCallback("onOpenChange", onOpenChange); |
| 8348 |
store2.useContextCallback("onOpenChangeComplete", onOpenChangeComplete); |
| 8349 |
const openState = store2.useState("open"); |
| 8350 |
const open = !disabled2 && openState; |
| 8351 |
const activeTriggerId = store2.useState("activeTriggerId"); |
| 8352 |
const mounted = store2.useState("mounted"); |
| 8353 |
const payload = store2.useState("payload"); |
| 8354 |
store2.useSyncedValues({ |
| 8355 |
trackCursorAxis, |
| 8356 |
disableHoverablePopup |
| 8357 |
}); |
| 8358 |
store2.useSyncedValue("disabled", disabled2); |
| 8359 |
useImplicitActiveTrigger(store2, { |
| 8360 |
closeOnActiveTriggerUnmount: true |
| 8361 |
}); |
| 8362 |
const { |
| 8363 |
forceUnmount, |
| 8364 |
transitionStatus |
| 8365 |
} = useOpenStateTransitions(open, store2); |
| 8366 |
const isInstantPhase = store2.useState("isInstantPhase"); |
| 8367 |
const instantType = store2.useState("instantType"); |
| 8368 |
const lastOpenChangeReason = store2.useState("lastOpenChangeReason"); |
| 8369 |
const previousInstantTypeRef = React36.useRef(null); |
| 8370 |
useIsoLayoutEffect(() => { |
| 8371 |
if (openState && disabled2) { |
| 8372 |
store2.setOpen(false, createChangeEventDetails(reason_parts_exports.disabled)); |
| 8373 |
} |
| 8374 |
}, [openState, disabled2, store2]); |
| 8375 |
useIsoLayoutEffect(() => { |
| 8376 |
if (transitionStatus === "ending" && lastOpenChangeReason === reason_parts_exports.none || transitionStatus !== "ending" && isInstantPhase) { |
| 8377 |
if (instantType !== "delay") { |
| 8378 |
previousInstantTypeRef.current = instantType; |
| 8379 |
} |
| 8380 |
store2.set("instantType", "delay"); |
| 8381 |
} else if (previousInstantTypeRef.current !== null) { |
| 8382 |
store2.set("instantType", previousInstantTypeRef.current); |
| 8383 |
previousInstantTypeRef.current = null; |
| 8384 |
} |
| 8385 |
}, [transitionStatus, isInstantPhase, lastOpenChangeReason, instantType, store2]); |
| 8386 |
useIsoLayoutEffect(() => { |
| 8387 |
if (open) { |
| 8388 |
if (activeTriggerId == null) { |
| 8389 |
store2.set("payload", void 0); |
| 8390 |
} |
| 8391 |
} |
| 8392 |
}, [store2, activeTriggerId, open]); |
| 8393 |
const handleImperativeClose = React36.useCallback(() => { |
| 8394 |
store2.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction)); |
| 8395 |
}, [store2]); |
| 8396 |
React36.useImperativeHandle(actionsRef, () => ({ |
| 8397 |
unmount: forceUnmount, |
| 8398 |
close: handleImperativeClose |
| 8399 |
}), [forceUnmount, handleImperativeClose]); |
| 8400 |
const shouldRenderInteractions = open || mounted || !disabled2 && trackCursorAxis !== "none"; |
| 8401 |
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(TooltipRootContext.Provider, { |
| 8402 |
value: store2, |
| 8403 |
children: [shouldRenderInteractions && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(TooltipInteractions, { |
| 8404 |
store: store2, |
| 8405 |
disabled: disabled2, |
| 8406 |
trackCursorAxis |
| 8407 |
}), typeof children === "function" ? children({ |
| 8408 |
payload |
| 8409 |
}) : children] |
| 8410 |
}); |
| 8411 |
}); |
| 8412 |
if (true) TooltipRoot.displayName = "TooltipRoot"; |
| 8413 |
function TooltipInteractions({ |
| 8414 |
store: store2, |
| 8415 |
disabled: disabled2, |
| 8416 |
trackCursorAxis |
| 8417 |
}) { |
| 8418 |
const floatingRootContext = store2.useState("floatingRootContext"); |
| 8419 |
const dismiss = useDismiss(floatingRootContext, { |
| 8420 |
enabled: !disabled2, |
| 8421 |
referencePress: () => store2.select("closeOnClick") |
| 8422 |
}); |
| 8423 |
const clientPoint = useClientPoint(floatingRootContext, { |
| 8424 |
enabled: !disabled2 && trackCursorAxis !== "none", |
| 8425 |
axis: trackCursorAxis === "none" ? void 0 : trackCursorAxis |
| 8426 |
}); |
| 8427 |
const activeTriggerProps = React36.useMemo(() => mergeProps(clientPoint.reference, dismiss.reference), [clientPoint.reference, dismiss.reference]); |
| 8428 |
const inactiveTriggerProps = React36.useMemo(() => mergeProps(clientPoint.trigger, dismiss.trigger), [clientPoint.trigger, dismiss.trigger]); |
| 8429 |
const popupProps = React36.useMemo(() => mergeProps(FOCUSABLE_POPUP_PROPS, clientPoint.floating, dismiss.floating), [clientPoint.floating, dismiss.floating]); |
| 8430 |
usePopupInteractionProps(store2, { |
| 8431 |
activeTriggerProps, |
| 8432 |
inactiveTriggerProps, |
| 8433 |
popupProps |
| 8434 |
}); |
| 8435 |
return null; |
| 8436 |
} |
| 8437 |
|
| 8438 |
// node_modules/@base-ui/react/tooltip/trigger/TooltipTrigger.mjs |
| 8439 |
var React38 = __toESM(require_react(), 1); |
| 8440 |
|
| 8441 |
// node_modules/@base-ui/react/tooltip/provider/TooltipProviderContext.mjs |
| 8442 |
var React37 = __toESM(require_react(), 1); |
| 8443 |
var TooltipProviderContext = /* @__PURE__ */ React37.createContext(void 0); |
| 8444 |
if (true) TooltipProviderContext.displayName = "TooltipProviderContext"; |
| 8445 |
function useTooltipProviderContext() { |
| 8446 |
return React37.useContext(TooltipProviderContext); |
| 8447 |
} |
| 8448 |
|
| 8449 |
// node_modules/@base-ui/react/tooltip/trigger/TooltipTriggerDataAttributes.mjs |
| 8450 |
var TooltipTriggerDataAttributes = (function(TooltipTriggerDataAttributes2) { |
| 8451 |
TooltipTriggerDataAttributes2[TooltipTriggerDataAttributes2["popupOpen"] = CommonTriggerDataAttributes.popupOpen] = "popupOpen"; |
| 8452 |
TooltipTriggerDataAttributes2["triggerDisabled"] = "data-trigger-disabled"; |
| 8453 |
return TooltipTriggerDataAttributes2; |
| 8454 |
})({}); |
| 8455 |
|
| 8456 |
// node_modules/@base-ui/react/tooltip/utils/constants.mjs |
| 8457 |
var OPEN_DELAY = 600; |
| 8458 |
|
| 8459 |
// node_modules/@base-ui/react/tooltip/trigger/TooltipTrigger.mjs |
| 8460 |
var TOOLTIP_TRIGGER_IDENTIFIER = "data-base-ui-tooltip-trigger"; |
| 8461 |
function getTargetElement(event) { |
| 8462 |
if ("composedPath" in event) { |
| 8463 |
const path = event.composedPath(); |
| 8464 |
for (let i = 0; i < path.length; i += 1) { |
| 8465 |
const element = path[i]; |
| 8466 |
if (isElement(element)) { |
| 8467 |
return element; |
| 8468 |
} |
| 8469 |
} |
| 8470 |
} |
| 8471 |
const target = event.target; |
| 8472 |
if (isElement(target)) { |
| 8473 |
return target; |
| 8474 |
} |
| 8475 |
return null; |
| 8476 |
} |
| 8477 |
function closestEnabledTooltipTrigger(element) { |
| 8478 |
let current = element; |
| 8479 |
while (current) { |
| 8480 |
if (current.hasAttribute(TOOLTIP_TRIGGER_IDENTIFIER)) { |
| 8481 |
return current; |
| 8482 |
} |
| 8483 |
const parentElement = current.parentElement; |
| 8484 |
if (parentElement) { |
| 8485 |
current = parentElement; |
| 8486 |
continue; |
| 8487 |
} |
| 8488 |
const root = current.getRootNode(); |
| 8489 |
current = "host" in root && isElement(root.host) ? root.host : null; |
| 8490 |
} |
| 8491 |
return null; |
| 8492 |
} |
| 8493 |
var TooltipTrigger = fastComponentRef(function TooltipTrigger2(componentProps, forwardedRef) { |
| 8494 |
const { |
| 8495 |
render, |
| 8496 |
className, |
| 8497 |
style, |
| 8498 |
handle, |
| 8499 |
payload, |
| 8500 |
disabled: disabledProp, |
| 8501 |
delay, |
| 8502 |
closeOnClick = true, |
| 8503 |
closeDelay, |
| 8504 |
id: idProp, |
| 8505 |
...elementProps |
| 8506 |
} = componentProps; |
| 8507 |
const rootContext = useTooltipRootContext(true); |
| 8508 |
const store2 = handle?.store ?? rootContext; |
| 8509 |
if (!store2) { |
| 8510 |
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)); |
| 8511 |
} |
| 8512 |
const thisTriggerId = useBaseUiId(idProp); |
| 8513 |
const isTriggerActive = store2.useState("isTriggerActive", thisTriggerId); |
| 8514 |
const isOpenedByThisTrigger = store2.useState("isOpenedByTrigger", thisTriggerId); |
| 8515 |
const floatingRootContext = store2.useState("floatingRootContext"); |
| 8516 |
const triggerElementRef = React38.useRef(null); |
| 8517 |
const delayWithDefault = delay ?? OPEN_DELAY; |
| 8518 |
const closeDelayWithDefault = closeDelay ?? 0; |
| 8519 |
const { |
| 8520 |
registerTrigger, |
| 8521 |
isMountedByThisTrigger |
| 8522 |
} = useTriggerDataForwarding(thisTriggerId, triggerElementRef, store2, { |
| 8523 |
payload, |
| 8524 |
closeOnClick, |
| 8525 |
closeDelay: closeDelayWithDefault |
| 8526 |
}); |
| 8527 |
const providerContext = useTooltipProviderContext(); |
| 8528 |
const { |
| 8529 |
delayRef, |
| 8530 |
isInstantPhase, |
| 8531 |
hasProvider |
| 8532 |
} = useDelayGroup(floatingRootContext, { |
| 8533 |
open: isOpenedByThisTrigger |
| 8534 |
}); |
| 8535 |
const hoverInteraction = useHoverInteractionSharedState(floatingRootContext); |
| 8536 |
store2.useSyncedValue("isInstantPhase", isInstantPhase); |
| 8537 |
const rootDisabled = store2.useState("disabled"); |
| 8538 |
const disabled2 = disabledProp ?? rootDisabled; |
| 8539 |
const disabledRef = useValueAsRef(disabled2); |
| 8540 |
const trackCursorAxis = store2.useState("trackCursorAxis"); |
| 8541 |
const disableHoverablePopup = store2.useState("disableHoverablePopup"); |
| 8542 |
const isNestedTriggerHoveredRef = React38.useRef(false); |
| 8543 |
const nestedTriggerOpenTimeout = useTimeout(); |
| 8544 |
const pointerTypeRef = React38.useRef(void 0); |
| 8545 |
function getOpenDelay() { |
| 8546 |
const providerDelay = providerContext?.delay; |
| 8547 |
const groupOpenValue = typeof delayRef.current === "object" ? delayRef.current.open : void 0; |
| 8548 |
let computedOpenDelay = delayWithDefault; |
| 8549 |
if (hasProvider) { |
| 8550 |
if (groupOpenValue !== 0) { |
| 8551 |
computedOpenDelay = delay ?? providerDelay ?? delayWithDefault; |
| 8552 |
} else { |
| 8553 |
computedOpenDelay = 0; |
| 8554 |
} |
| 8555 |
} |
| 8556 |
return computedOpenDelay; |
| 8557 |
} |
| 8558 |
function isEnabledNestedTriggerTarget(target) { |
| 8559 |
const triggerEl = triggerElementRef.current; |
| 8560 |
if (!triggerEl || !target) { |
| 8561 |
return false; |
| 8562 |
} |
| 8563 |
const nearestTrigger = closestEnabledTooltipTrigger(target); |
| 8564 |
return nearestTrigger !== null && nearestTrigger !== triggerEl && contains(triggerEl, nearestTrigger); |
| 8565 |
} |
| 8566 |
function detectNestedTriggerHover(target) { |
| 8567 |
const nestedTriggerHovered = isEnabledNestedTriggerTarget(target); |
| 8568 |
isNestedTriggerHoveredRef.current = nestedTriggerHovered; |
| 8569 |
if (nestedTriggerHovered) { |
| 8570 |
hoverInteraction.openChangeTimeout.clear(); |
| 8571 |
hoverInteraction.restTimeout.clear(); |
| 8572 |
hoverInteraction.restTimeoutPending = false; |
| 8573 |
nestedTriggerOpenTimeout.clear(); |
| 8574 |
} |
| 8575 |
return nestedTriggerHovered; |
| 8576 |
} |
| 8577 |
const hoverProps = useHoverReferenceInteraction(floatingRootContext, { |
| 8578 |
enabled: !disabled2, |
| 8579 |
mouseOnly: true, |
| 8580 |
move: false, |
| 8581 |
handleClose: !disableHoverablePopup && trackCursorAxis !== "both" ? safePolygon() : null, |
| 8582 |
restMs: getOpenDelay, |
| 8583 |
delay() { |
| 8584 |
const closeValue = typeof delayRef.current === "object" ? delayRef.current.close : void 0; |
| 8585 |
let computedCloseDelay = closeDelayWithDefault; |
| 8586 |
if (closeDelay == null && hasProvider) { |
| 8587 |
computedCloseDelay = closeValue; |
| 8588 |
} |
| 8589 |
return { |
| 8590 |
close: computedCloseDelay |
| 8591 |
}; |
| 8592 |
}, |
| 8593 |
triggerElementRef, |
| 8594 |
isActiveTrigger: isTriggerActive, |
| 8595 |
isClosing: () => store2.select("transitionStatus") === "ending", |
| 8596 |
shouldOpen() { |
| 8597 |
return !isNestedTriggerHoveredRef.current; |
| 8598 |
} |
| 8599 |
}); |
| 8600 |
const focusProps = useFocus(floatingRootContext, { |
| 8601 |
enabled: !disabled2 |
| 8602 |
}).reference; |
| 8603 |
const handleNestedTriggerHover = (event) => { |
| 8604 |
const wasNestedTriggerHovered = isNestedTriggerHoveredRef.current; |
| 8605 |
const target = getTargetElement(event); |
| 8606 |
const nestedTriggerHovered = detectNestedTriggerHover(target); |
| 8607 |
const triggerEl = triggerElementRef.current; |
| 8608 |
const targetInsideTrigger = triggerEl && target && contains(triggerEl, target); |
| 8609 |
if (nestedTriggerHovered && store2.select("open") && store2.select("lastOpenChangeReason") === reason_parts_exports.triggerHover) { |
| 8610 |
store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event)); |
| 8611 |
return; |
| 8612 |
} |
| 8613 |
if (wasNestedTriggerHovered && !nestedTriggerHovered && targetInsideTrigger && !disabledRef.current && !store2.select("open") && triggerEl && // Match the hover hook's non-strict mouse fallback for mouse-only event sequences. |
| 8614 |
isMouseLikePointerType(pointerTypeRef.current)) { |
| 8615 |
const open = () => { |
| 8616 |
if (!isNestedTriggerHoveredRef.current && !disabledRef.current && !store2.select("open")) { |
| 8617 |
store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerEl)); |
| 8618 |
} |
| 8619 |
}; |
| 8620 |
const openDelay = getOpenDelay(); |
| 8621 |
if (openDelay === 0) { |
| 8622 |
nestedTriggerOpenTimeout.clear(); |
| 8623 |
open(); |
| 8624 |
} else { |
| 8625 |
nestedTriggerOpenTimeout.start(openDelay, open); |
| 8626 |
} |
| 8627 |
} |
| 8628 |
}; |
| 8629 |
const rootTriggerProps = store2.useState("triggerProps", isMountedByThisTrigger); |
| 8630 |
const shouldApplyRootTriggerProps = isMountedByThisTrigger || trackCursorAxis !== "none"; |
| 8631 |
const state = { |
| 8632 |
open: isOpenedByThisTrigger |
| 8633 |
}; |
| 8634 |
const element = useRenderElement("button", componentProps, { |
| 8635 |
state, |
| 8636 |
ref: [forwardedRef, registerTrigger, triggerElementRef], |
| 8637 |
props: [hoverProps, focusProps, shouldApplyRootTriggerProps ? rootTriggerProps : void 0, { |
| 8638 |
onMouseOver(event) { |
| 8639 |
handleNestedTriggerHover(event.nativeEvent); |
| 8640 |
}, |
| 8641 |
onFocus(event) { |
| 8642 |
if (isEnabledNestedTriggerTarget(getTargetElement(event.nativeEvent))) { |
| 8643 |
event.preventBaseUIHandler(); |
| 8644 |
} |
| 8645 |
}, |
| 8646 |
onMouseLeave() { |
| 8647 |
isNestedTriggerHoveredRef.current = false; |
| 8648 |
nestedTriggerOpenTimeout.clear(); |
| 8649 |
pointerTypeRef.current = void 0; |
| 8650 |
}, |
| 8651 |
onPointerEnter(event) { |
| 8652 |
pointerTypeRef.current = event.pointerType; |
| 8653 |
}, |
| 8654 |
onPointerDown(event) { |
| 8655 |
pointerTypeRef.current = event.pointerType; |
| 8656 |
store2.set("closeOnClick", closeOnClick); |
| 8657 |
if (closeOnClick && !store2.select("open")) { |
| 8658 |
store2.cancelPendingOpen(event.nativeEvent); |
| 8659 |
} |
| 8660 |
}, |
| 8661 |
onClick(event) { |
| 8662 |
if (closeOnClick && !store2.select("open")) { |
| 8663 |
store2.cancelPendingOpen(event.nativeEvent); |
| 8664 |
} |
| 8665 |
}, |
| 8666 |
id: thisTriggerId, |
| 8667 |
[TooltipTriggerDataAttributes.triggerDisabled]: disabled2 ? "" : void 0, |
| 8668 |
[TOOLTIP_TRIGGER_IDENTIFIER]: disabled2 ? void 0 : "" |
| 8669 |
}, elementProps], |
| 8670 |
stateAttributesMapping: triggerOpenStateMapping |
| 8671 |
}); |
| 8672 |
return element; |
| 8673 |
}); |
| 8674 |
if (true) TooltipTrigger.displayName = "TooltipTrigger"; |
| 8675 |
|
| 8676 |
// node_modules/@base-ui/react/tooltip/portal/TooltipPortal.mjs |
| 8677 |
var React40 = __toESM(require_react(), 1); |
| 8678 |
|
| 8679 |
// node_modules/@base-ui/react/tooltip/portal/TooltipPortalContext.mjs |
| 8680 |
var React39 = __toESM(require_react(), 1); |
| 8681 |
var TooltipPortalContext = /* @__PURE__ */ React39.createContext(void 0); |
| 8682 |
if (true) TooltipPortalContext.displayName = "TooltipPortalContext"; |
| 8683 |
function useTooltipPortalContext() { |
| 8684 |
const value = React39.useContext(TooltipPortalContext); |
| 8685 |
if (value === void 0) { |
| 8686 |
throw new Error(true ? "Base UI: <Tooltip.Portal> is missing." : formatErrorMessage_default(70)); |
| 8687 |
} |
| 8688 |
return value; |
| 8689 |
} |
| 8690 |
|
| 8691 |
// node_modules/@base-ui/react/tooltip/portal/TooltipPortal.mjs |
| 8692 |
var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1); |
| 8693 |
var TooltipPortal = /* @__PURE__ */ React40.forwardRef(function TooltipPortal2(props, forwardedRef) { |
| 8694 |
const { |
| 8695 |
keepMounted = false, |
| 8696 |
...portalProps |
| 8697 |
} = props; |
| 8698 |
const store2 = useTooltipRootContext(); |
| 8699 |
const mounted = store2.useState("mounted"); |
| 8700 |
const shouldRender = mounted || keepMounted; |
| 8701 |
if (!shouldRender) { |
| 8702 |
return null; |
| 8703 |
} |
| 8704 |
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(TooltipPortalContext.Provider, { |
| 8705 |
value: keepMounted, |
| 8706 |
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(FloatingPortalLite, { |
| 8707 |
ref: forwardedRef, |
| 8708 |
...portalProps |
| 8709 |
}) |
| 8710 |
}); |
| 8711 |
}); |
| 8712 |
if (true) TooltipPortal.displayName = "TooltipPortal"; |
| 8713 |
|
| 8714 |
// node_modules/@base-ui/react/tooltip/positioner/TooltipPositioner.mjs |
| 8715 |
var React42 = __toESM(require_react(), 1); |
| 8716 |
|
| 8717 |
// node_modules/@base-ui/react/tooltip/positioner/TooltipPositionerContext.mjs |
| 8718 |
var React41 = __toESM(require_react(), 1); |
| 8719 |
var TooltipPositionerContext = /* @__PURE__ */ React41.createContext(void 0); |
| 8720 |
if (true) TooltipPositionerContext.displayName = "TooltipPositionerContext"; |
| 8721 |
function useTooltipPositionerContext() { |
| 8722 |
const context = React41.useContext(TooltipPositionerContext); |
| 8723 |
if (context === void 0) { |
| 8724 |
throw new Error(true ? "Base UI: TooltipPositionerContext is missing. TooltipPositioner parts must be placed within <Tooltip.Positioner>." : formatErrorMessage_default(71)); |
| 8725 |
} |
| 8726 |
return context; |
| 8727 |
} |
| 8728 |
|
| 8729 |
// node_modules/@base-ui/react/tooltip/positioner/TooltipPositioner.mjs |
| 8730 |
var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1); |
| 8731 |
var TooltipPositioner = /* @__PURE__ */ React42.forwardRef(function TooltipPositioner2(componentProps, forwardedRef) { |
| 8732 |
const { |
| 8733 |
render, |
| 8734 |
className, |
| 8735 |
anchor, |
| 8736 |
positionMethod = "absolute", |
| 8737 |
side = "top", |
| 8738 |
align = "center", |
| 8739 |
sideOffset = 0, |
| 8740 |
alignOffset = 0, |
| 8741 |
collisionBoundary = "clipping-ancestors", |
| 8742 |
collisionPadding = 5, |
| 8743 |
arrowPadding = 5, |
| 8744 |
sticky = false, |
| 8745 |
disableAnchorTracking = false, |
| 8746 |
collisionAvoidance = POPUP_COLLISION_AVOIDANCE, |
| 8747 |
style, |
| 8748 |
...elementProps |
| 8749 |
} = componentProps; |
| 8750 |
const store2 = useTooltipRootContext(); |
| 8751 |
const keepMounted = useTooltipPortalContext(); |
| 8752 |
const open = store2.useState("open"); |
| 8753 |
const mounted = store2.useState("mounted"); |
| 8754 |
const trackCursorAxis = store2.useState("trackCursorAxis"); |
| 8755 |
const disableHoverablePopup = store2.useState("disableHoverablePopup"); |
| 8756 |
const floatingRootContext = store2.useState("floatingRootContext"); |
| 8757 |
const instantType = store2.useState("instantType"); |
| 8758 |
const transitionStatus = store2.useState("transitionStatus"); |
| 8759 |
const hasViewport = store2.useState("hasViewport"); |
| 8760 |
const positioning = useAnchorPositioning({ |
| 8761 |
anchor, |
| 8762 |
positionMethod, |
| 8763 |
floatingRootContext, |
| 8764 |
mounted, |
| 8765 |
side, |
| 8766 |
sideOffset, |
| 8767 |
align, |
| 8768 |
alignOffset, |
| 8769 |
collisionBoundary, |
| 8770 |
collisionPadding, |
| 8771 |
sticky, |
| 8772 |
arrowPadding, |
| 8773 |
disableAnchorTracking, |
| 8774 |
keepMounted, |
| 8775 |
collisionAvoidance, |
| 8776 |
adaptiveOrigin: hasViewport ? adaptiveOrigin : void 0 |
| 8777 |
}); |
| 8778 |
const state = React42.useMemo(() => ({ |
| 8779 |
open, |
| 8780 |
side: positioning.side, |
| 8781 |
align: positioning.align, |
| 8782 |
anchorHidden: positioning.anchorHidden, |
| 8783 |
instant: trackCursorAxis !== "none" ? "tracking-cursor" : instantType |
| 8784 |
}), [open, positioning.side, positioning.align, positioning.anchorHidden, trackCursorAxis, instantType]); |
| 8785 |
const element = usePositioner(componentProps, state, { |
| 8786 |
styles: positioning.positionerStyles, |
| 8787 |
transitionStatus, |
| 8788 |
props: elementProps, |
| 8789 |
refs: [forwardedRef, store2.useStateSetter("positionerElement")], |
| 8790 |
hidden: !mounted, |
| 8791 |
inert: !open || trackCursorAxis === "both" || disableHoverablePopup |
| 8792 |
}); |
| 8793 |
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(TooltipPositionerContext.Provider, { |
| 8794 |
value: positioning, |
| 8795 |
children: element |
| 8796 |
}); |
| 8797 |
}); |
| 8798 |
if (true) TooltipPositioner.displayName = "TooltipPositioner"; |
| 8799 |
|
| 8800 |
// node_modules/@base-ui/react/tooltip/popup/TooltipPopup.mjs |
| 8801 |
var React43 = __toESM(require_react(), 1); |
| 8802 |
var stateAttributesMapping = { |
| 8803 |
...popupStateMapping, |
| 8804 |
...transitionStatusMapping |
| 8805 |
}; |
| 8806 |
var TooltipPopup = /* @__PURE__ */ React43.forwardRef(function TooltipPopup2(componentProps, forwardedRef) { |
| 8807 |
const { |
| 8808 |
render, |
| 8809 |
className, |
| 8810 |
style, |
| 8811 |
...elementProps |
| 8812 |
} = componentProps; |
| 8813 |
const store2 = useTooltipRootContext(); |
| 8814 |
const { |
| 8815 |
side, |
| 8816 |
align |
| 8817 |
} = useTooltipPositionerContext(); |
| 8818 |
const open = store2.useState("open"); |
| 8819 |
const instantType = store2.useState("instantType"); |
| 8820 |
const transitionStatus = store2.useState("transitionStatus"); |
| 8821 |
const popupProps = store2.useState("popupProps"); |
| 8822 |
const floatingContext = store2.useState("floatingRootContext"); |
| 8823 |
const disabled2 = store2.useState("disabled"); |
| 8824 |
const closeDelay = store2.useState("closeDelay"); |
| 8825 |
useOpenChangeComplete({ |
| 8826 |
open, |
| 8827 |
ref: store2.context.popupRef, |
| 8828 |
onComplete() { |
| 8829 |
if (open) { |
| 8830 |
store2.context.onOpenChangeComplete?.(true); |
| 8831 |
} |
| 8832 |
} |
| 8833 |
}); |
| 8834 |
useHoverFloatingInteraction(floatingContext, { |
| 8835 |
enabled: !disabled2, |
| 8836 |
closeDelay |
| 8837 |
}); |
| 8838 |
const setPopupElement = store2.useStateSetter("popupElement"); |
| 8839 |
const state = { |
| 8840 |
open, |
| 8841 |
side, |
| 8842 |
align, |
| 8843 |
instant: instantType, |
| 8844 |
transitionStatus |
| 8845 |
}; |
| 8846 |
const element = useRenderElement("div", componentProps, { |
| 8847 |
state, |
| 8848 |
ref: [forwardedRef, store2.context.popupRef, setPopupElement], |
| 8849 |
props: [popupProps, getDisabledMountTransitionStyles(transitionStatus), elementProps], |
| 8850 |
stateAttributesMapping |
| 8851 |
}); |
| 8852 |
return element; |
| 8853 |
}); |
| 8854 |
if (true) TooltipPopup.displayName = "TooltipPopup"; |
| 8855 |
|
| 8856 |
// node_modules/@base-ui/react/tooltip/arrow/TooltipArrow.mjs |
| 8857 |
var React44 = __toESM(require_react(), 1); |
| 8858 |
var TooltipArrow = /* @__PURE__ */ React44.forwardRef(function TooltipArrow2(componentProps, forwardedRef) { |
| 8859 |
const { |
| 8860 |
render, |
| 8861 |
className, |
| 8862 |
style, |
| 8863 |
...elementProps |
| 8864 |
} = componentProps; |
| 8865 |
const store2 = useTooltipRootContext(); |
| 8866 |
const { |
| 8867 |
arrowRef, |
| 8868 |
side, |
| 8869 |
align, |
| 8870 |
arrowUncentered, |
| 8871 |
arrowStyles |
| 8872 |
} = useTooltipPositionerContext(); |
| 8873 |
const open = store2.useState("open"); |
| 8874 |
const instantType = store2.useState("instantType"); |
| 8875 |
const state = { |
| 8876 |
open, |
| 8877 |
side, |
| 8878 |
align, |
| 8879 |
uncentered: arrowUncentered, |
| 8880 |
instant: instantType |
| 8881 |
}; |
| 8882 |
const element = useRenderElement("div", componentProps, { |
| 8883 |
state, |
| 8884 |
ref: [forwardedRef, arrowRef], |
| 8885 |
props: [{ |
| 8886 |
style: arrowStyles, |
| 8887 |
"aria-hidden": true |
| 8888 |
}, elementProps], |
| 8889 |
stateAttributesMapping: popupStateMapping |
| 8890 |
}); |
| 8891 |
return element; |
| 8892 |
}); |
| 8893 |
if (true) TooltipArrow.displayName = "TooltipArrow"; |
| 8894 |
|
| 8895 |
// node_modules/@base-ui/react/tooltip/provider/TooltipProvider.mjs |
| 8896 |
var React45 = __toESM(require_react(), 1); |
| 8897 |
var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1); |
| 8898 |
var TooltipProvider = function TooltipProvider2(props) { |
| 8899 |
const { |
| 8900 |
delay, |
| 8901 |
closeDelay, |
| 8902 |
timeout = 400 |
| 8903 |
} = props; |
| 8904 |
const contextValue = React45.useMemo(() => ({ |
| 8905 |
delay, |
| 8906 |
closeDelay |
| 8907 |
}), [delay, closeDelay]); |
| 8908 |
const delayValue = React45.useMemo(() => ({ |
| 8909 |
open: delay, |
| 8910 |
close: closeDelay |
| 8911 |
}), [delay, closeDelay]); |
| 8912 |
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(TooltipProviderContext.Provider, { |
| 8913 |
value: contextValue, |
| 8914 |
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(FloatingDelayGroup, { |
| 8915 |
delay: delayValue, |
| 8916 |
timeoutMs: timeout, |
| 8917 |
children: props.children |
| 8918 |
}) |
| 8919 |
}); |
| 8920 |
}; |
| 8921 |
if (true) TooltipProvider.displayName = "TooltipProvider"; |
| 8922 |
|
| 8923 |
// node_modules/@base-ui/react/tooltip/viewport/TooltipViewport.mjs |
| 8924 |
var React46 = __toESM(require_react(), 1); |
| 8925 |
|
| 8926 |
// node_modules/@base-ui/react/tooltip/viewport/TooltipViewportCssVars.mjs |
| 8927 |
var TooltipViewportCssVars = /* @__PURE__ */ (function(TooltipViewportCssVars2) { |
| 8928 |
TooltipViewportCssVars2["popupWidth"] = "--popup-width"; |
| 8929 |
TooltipViewportCssVars2["popupHeight"] = "--popup-height"; |
| 8930 |
return TooltipViewportCssVars2; |
| 8931 |
})({}); |
| 8932 |
|
| 8933 |
// node_modules/@base-ui/react/tooltip/viewport/TooltipViewport.mjs |
| 8934 |
var stateAttributesMapping2 = { |
| 8935 |
activationDirection: (value) => value ? { |
| 8936 |
"data-activation-direction": value |
| 8937 |
} : null |
| 8938 |
}; |
| 8939 |
var TooltipViewport = /* @__PURE__ */ React46.forwardRef(function TooltipViewport2(componentProps, forwardedRef) { |
| 8940 |
const { |
| 8941 |
render, |
| 8942 |
className, |
| 8943 |
style, |
| 8944 |
children, |
| 8945 |
...elementProps |
| 8946 |
} = componentProps; |
| 8947 |
const store2 = useTooltipRootContext(); |
| 8948 |
const positioner = useTooltipPositionerContext(); |
| 8949 |
const instantType = store2.useState("instantType"); |
| 8950 |
const { |
| 8951 |
children: childrenToRender, |
| 8952 |
state: viewportState |
| 8953 |
} = usePopupViewport({ |
| 8954 |
store: store2, |
| 8955 |
side: positioner.side, |
| 8956 |
cssVars: TooltipViewportCssVars, |
| 8957 |
children |
| 8958 |
}); |
| 8959 |
const state = { |
| 8960 |
activationDirection: viewportState.activationDirection, |
| 8961 |
transitioning: viewportState.transitioning, |
| 8962 |
instant: instantType |
| 8963 |
}; |
| 8964 |
return useRenderElement("div", componentProps, { |
| 8965 |
state, |
| 8966 |
ref: forwardedRef, |
| 8967 |
props: [elementProps, { |
| 8968 |
children: childrenToRender |
| 8969 |
}], |
| 8970 |
stateAttributesMapping: stateAttributesMapping2 |
| 8971 |
}); |
| 8972 |
}); |
| 8973 |
if (true) TooltipViewport.displayName = "TooltipViewport"; |
| 8974 |
|
| 8975 |
// node_modules/@base-ui/react/tooltip/store/TooltipHandle.mjs |
| 8976 |
var TooltipHandle = class { |
| 8977 |
/** |
| 8978 |
* Internal store holding the tooltip state. |
| 8979 |
* @internal |
| 8980 |
*/ |
| 8981 |
constructor() { |
| 8982 |
this.store = new TooltipStore(); |
| 8983 |
} |
| 8984 |
/** |
| 8985 |
* Opens the tooltip and associates it with the trigger with the given ID. |
| 8986 |
* The trigger must be a Tooltip.Trigger component with this handle passed as a prop. |
| 8987 |
* |
| 8988 |
* This method should only be called in an event handler or an effect (not during rendering). |
| 8989 |
* |
| 8990 |
* @param triggerId ID of the trigger to associate with the tooltip. |
| 8991 |
*/ |
| 8992 |
open(triggerId) { |
| 8993 |
const triggerElement = triggerId ? this.store.context.triggerElements.getById(triggerId) : void 0; |
| 8994 |
if (triggerId && !triggerElement) { |
| 8995 |
throw new Error(true ? `Base UI: TooltipHandle.open: No trigger found with id "${triggerId}".` : formatErrorMessage_default(81, triggerId)); |
| 8996 |
} |
| 8997 |
this.store.setOpen(true, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, triggerElement)); |
| 8998 |
} |
| 8999 |
/** |
| 9000 |
* Closes the tooltip. |
| 9001 |
*/ |
| 9002 |
close() { |
| 9003 |
this.store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, void 0)); |
| 9004 |
} |
| 9005 |
/** |
| 9006 |
* Indicates whether the tooltip is currently open. |
| 9007 |
*/ |
| 9008 |
get isOpen() { |
| 9009 |
return this.store.select("open"); |
| 9010 |
} |
| 9011 |
}; |
| 9012 |
function createTooltipHandle() { |
| 9013 |
return new TooltipHandle(); |
| 9014 |
} |
| 9015 |
|
| 9016 |
// node_modules/@base-ui/react/use-render/useRender.mjs |
| 9017 |
function useRender(params) { |
| 9018 |
return useRenderElement(params.defaultTagName ?? "div", params, params); |
| 9019 |
} |
| 9020 |
|
| 9021 |
// packages/icons/build-module/icon/index.mjs |
| 9022 |
var import_element11 = __toESM(require_element(), 1); |
| 9023 |
var icon_default = (0, import_element11.forwardRef)( |
| 9024 |
({ icon, size: size4 = 24, ...props }, ref) => { |
| 9025 |
return (0, import_element11.cloneElement)(icon, { |
| 9026 |
width: size4, |
| 9027 |
height: size4, |
| 9028 |
...props, |
| 9029 |
ref |
| 9030 |
}); |
| 9031 |
} |
| 9032 |
); |
| 9033 |
|
| 9034 |
// packages/icons/build-module/library/star-empty.mjs |
| 9035 |
var import_primitives = __toESM(require_primitives(), 1); |
| 9036 |
var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1); |
| 9037 |
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" }) }); |
| 9038 |
|
| 9039 |
// packages/icons/build-module/library/star-filled.mjs |
| 9040 |
var import_primitives2 = __toESM(require_primitives(), 1); |
| 9041 |
var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1); |
| 9042 |
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" }) }); |
| 9043 |
|
| 9044 |
// packages/icons/build-module/library/star-half.mjs |
| 9045 |
var import_primitives3 = __toESM(require_primitives(), 1); |
| 9046 |
var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1); |
| 9047 |
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" }) }); |
| 9048 |
|
| 9049 |
// packages/ui/build-module/utils/render-slot-with-children.mjs |
| 9050 |
var import_element12 = __toESM(require_element(), 1); |
| 9051 |
function renderSlotWithChildren(slot, defaultSlot, children) { |
| 9052 |
return (0, import_element12.cloneElement)(slot ?? defaultSlot, { children }); |
| 9053 |
} |
| 9054 |
|
| 9055 |
// packages/ui/build-module/utils/theme-provider.mjs |
| 9056 |
var theme = __toESM(require_theme(), 1); |
| 9057 |
|
| 9058 |
// packages/ui/build-module/lock-unlock.mjs |
| 9059 |
var import_private_apis = __toESM(require_private_apis(), 1); |
| 9060 |
var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)( |
| 9061 |
"I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.", |
| 9062 |
"@wordpress/ui" |
| 9063 |
); |
| 9064 |
|
| 9065 |
// packages/ui/build-module/utils/theme-provider.mjs |
| 9066 |
function getThemeProvider() { |
| 9067 |
const themePackage = theme; |
| 9068 |
if (themePackage.ThemeProvider) { |
| 9069 |
return themePackage.ThemeProvider; |
| 9070 |
} |
| 9071 |
if (!themePackage.privateApis) { |
| 9072 |
throw new Error( |
| 9073 |
"@wordpress/ui: @wordpress/theme must expose `ThemeProvider` or `privateApis.ThemeProvider`." |
| 9074 |
); |
| 9075 |
} |
| 9076 |
return unlock( |
| 9077 |
themePackage.privateApis |
| 9078 |
).ThemeProvider; |
| 9079 |
} |
| 9080 |
var ThemeProvider = getThemeProvider(); |
| 9081 |
|
| 9082 |
// packages/ui/build-module/tooltip/index.mjs |
| 9083 |
var tooltip_exports = {}; |
| 9084 |
__export(tooltip_exports, { |
| 9085 |
Popup: () => Popup, |
| 9086 |
Portal: () => Portal, |
| 9087 |
Positioner: () => Positioner, |
| 9088 |
Provider: () => Provider, |
| 9089 |
Root: () => Root, |
| 9090 |
Trigger: () => Trigger |
| 9091 |
}); |
| 9092 |
|
| 9093 |
// packages/ui/build-module/tooltip/popup.mjs |
| 9094 |
var import_element15 = __toESM(require_element(), 1); |
| 9095 |
|
| 9096 |
// packages/ui/build-module/tooltip/portal.mjs |
| 9097 |
var import_element13 = __toESM(require_element(), 1); |
| 9098 |
|
| 9099 |
// packages/ui/build-module/utils/wp-compat-overlay-slot.mjs |
| 9100 |
var STYLE_HASH_ATTRIBUTE = "data-wp-hash"; |
| 9101 |
function getRuntime() { |
| 9102 |
const globalScope = globalThis; |
| 9103 |
if (globalScope.__wpStyleRuntime) { |
| 9104 |
return globalScope.__wpStyleRuntime; |
| 9105 |
} |
| 9106 |
globalScope.__wpStyleRuntime = { |
| 9107 |
documents: /* @__PURE__ */ new Map(), |
| 9108 |
styles: /* @__PURE__ */ new Map(), |
| 9109 |
injectedStyles: /* @__PURE__ */ new WeakMap() |
| 9110 |
}; |
| 9111 |
if (typeof document !== "undefined") { |
| 9112 |
registerDocument(document); |
| 9113 |
} |
| 9114 |
return globalScope.__wpStyleRuntime; |
| 9115 |
} |
| 9116 |
function documentContainsStyleHash(targetDocument, hash) { |
| 9117 |
if (!targetDocument.head) { |
| 9118 |
return false; |
| 9119 |
} |
| 9120 |
for (const style of targetDocument.head.querySelectorAll( |
| 9121 |
`style[${STYLE_HASH_ATTRIBUTE}]` |
| 9122 |
)) { |
| 9123 |
if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) { |
| 9124 |
return true; |
| 9125 |
} |
| 9126 |
} |
| 9127 |
return false; |
| 9128 |
} |
| 9129 |
function injectStyle(targetDocument, hash, css) { |
| 9130 |
if (!targetDocument.head) { |
| 9131 |
return; |
| 9132 |
} |
| 9133 |
const runtime = getRuntime(); |
| 9134 |
let injectedStyles = runtime.injectedStyles.get(targetDocument); |
| 9135 |
if (!injectedStyles) { |
| 9136 |
injectedStyles = /* @__PURE__ */ new Set(); |
| 9137 |
runtime.injectedStyles.set(targetDocument, injectedStyles); |
| 9138 |
} |
| 9139 |
if (injectedStyles.has(hash)) { |
| 9140 |
return; |
| 9141 |
} |
| 9142 |
if (documentContainsStyleHash(targetDocument, hash)) { |
| 9143 |
injectedStyles.add(hash); |
| 9144 |
return; |
| 9145 |
} |
| 9146 |
const style = targetDocument.createElement("style"); |
| 9147 |
style.setAttribute(STYLE_HASH_ATTRIBUTE, hash); |
| 9148 |
style.appendChild(targetDocument.createTextNode(css)); |
| 9149 |
targetDocument.head.appendChild(style); |
| 9150 |
injectedStyles.add(hash); |
| 9151 |
} |
| 9152 |
function registerDocument(targetDocument) { |
| 9153 |
const runtime = getRuntime(); |
| 9154 |
runtime.documents.set( |
| 9155 |
targetDocument, |
| 9156 |
(runtime.documents.get(targetDocument) ?? 0) + 1 |
| 9157 |
); |
| 9158 |
for (const [hash, css] of runtime.styles) { |
| 9159 |
injectStyle(targetDocument, hash, css); |
| 9160 |
} |
| 9161 |
return () => { |
| 9162 |
const count = runtime.documents.get(targetDocument); |
| 9163 |
if (count === void 0) { |
| 9164 |
return; |
| 9165 |
} |
| 9166 |
if (count <= 1) { |
| 9167 |
runtime.documents.delete(targetDocument); |
| 9168 |
return; |
| 9169 |
} |
| 9170 |
runtime.documents.set(targetDocument, count - 1); |
| 9171 |
}; |
| 9172 |
} |
| 9173 |
function registerStyle(hash, css) { |
| 9174 |
const runtime = getRuntime(); |
| 9175 |
runtime.styles.set(hash, css); |
| 9176 |
for (const targetDocument of runtime.documents.keys()) { |
| 9177 |
injectStyle(targetDocument, hash, css); |
| 9178 |
} |
| 9179 |
} |
| 9180 |
if (typeof process === "undefined" || true) { |
| 9181 |
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}}}"); |
| 9182 |
} |
| 9183 |
var wp_compat_overlay_slot_default = { "slot": "_11fc52b637ff8a7e__slot" }; |
| 9184 |
var WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE = "data-wp-compat-overlay-slot"; |
| 9185 |
function resolveOwnerDocument() { |
| 9186 |
return typeof document === "undefined" ? null : document; |
| 9187 |
} |
| 9188 |
function isInWordPressEnvironment() { |
| 9189 |
let topWp; |
| 9190 |
try { |
| 9191 |
topWp = window.top?.wp; |
| 9192 |
} catch { |
| 9193 |
} |
| 9194 |
const wp = topWp ?? window.wp; |
| 9195 |
return typeof wp?.components === "object" && wp.components !== null; |
| 9196 |
} |
| 9197 |
var cachedSlot = null; |
| 9198 |
function ensureSlotIsAccessible(element) { |
| 9199 |
element.setAttribute("aria-hidden", "false"); |
| 9200 |
return element; |
| 9201 |
} |
| 9202 |
function createSlot(ownerDocument2) { |
| 9203 |
const element = ownerDocument2.createElement("div"); |
| 9204 |
element.setAttribute(WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE, ""); |
| 9205 |
if (wp_compat_overlay_slot_default.slot) { |
| 9206 |
element.classList.add(wp_compat_overlay_slot_default.slot); |
| 9207 |
} |
| 9208 |
ownerDocument2.body.appendChild(element); |
| 9209 |
return element; |
| 9210 |
} |
| 9211 |
function getWpCompatOverlaySlot() { |
| 9212 |
if (typeof window === "undefined") { |
| 9213 |
return void 0; |
| 9214 |
} |
| 9215 |
if (!isInWordPressEnvironment() && window.__wpUiCompatOverlaySlotEnabled !== true) { |
| 9216 |
return void 0; |
| 9217 |
} |
| 9218 |
const ownerDocument2 = resolveOwnerDocument(); |
| 9219 |
if (!ownerDocument2 || !ownerDocument2.body) { |
| 9220 |
return void 0; |
| 9221 |
} |
| 9222 |
if (cachedSlot && cachedSlot.ownerDocument === ownerDocument2 && cachedSlot.isConnected) { |
| 9223 |
return ensureSlotIsAccessible(cachedSlot); |
| 9224 |
} |
| 9225 |
const existing = ownerDocument2.querySelector( |
| 9226 |
`[${WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE}]` |
| 9227 |
); |
| 9228 |
if (existing instanceof HTMLDivElement) { |
| 9229 |
cachedSlot = ensureSlotIsAccessible(existing); |
| 9230 |
return cachedSlot; |
| 9231 |
} |
| 9232 |
if (cachedSlot?.isConnected) { |
| 9233 |
cachedSlot.remove(); |
| 9234 |
} |
| 9235 |
cachedSlot = ensureSlotIsAccessible(createSlot(ownerDocument2)); |
| 9236 |
return cachedSlot; |
| 9237 |
} |
| 9238 |
|
| 9239 |
// packages/ui/build-module/tooltip/portal.mjs |
| 9240 |
var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1); |
| 9241 |
var Portal = (0, import_element13.forwardRef)( |
| 9242 |
function TooltipPortal3({ container, ...restProps }, ref) { |
| 9243 |
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)( |
| 9244 |
index_parts_exports.Portal, |
| 9245 |
{ |
| 9246 |
container: container ?? getWpCompatOverlaySlot(), |
| 9247 |
...restProps, |
| 9248 |
ref |
| 9249 |
} |
| 9250 |
); |
| 9251 |
} |
| 9252 |
); |
| 9253 |
|
| 9254 |
// packages/ui/build-module/tooltip/positioner.mjs |
| 9255 |
var import_element14 = __toESM(require_element(), 1); |
| 9256 |
var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1); |
| 9257 |
var STYLE_HASH_ATTRIBUTE2 = "data-wp-hash"; |
| 9258 |
function getRuntime2() { |
| 9259 |
const globalScope = globalThis; |
| 9260 |
if (globalScope.__wpStyleRuntime) { |
| 9261 |
return globalScope.__wpStyleRuntime; |
| 9262 |
} |
| 9263 |
globalScope.__wpStyleRuntime = { |
| 9264 |
documents: /* @__PURE__ */ new Map(), |
| 9265 |
styles: /* @__PURE__ */ new Map(), |
| 9266 |
injectedStyles: /* @__PURE__ */ new WeakMap() |
| 9267 |
}; |
| 9268 |
if (typeof document !== "undefined") { |
| 9269 |
registerDocument2(document); |
| 9270 |
} |
| 9271 |
return globalScope.__wpStyleRuntime; |
| 9272 |
} |
| 9273 |
function documentContainsStyleHash2(targetDocument, hash) { |
| 9274 |
if (!targetDocument.head) { |
| 9275 |
return false; |
| 9276 |
} |
| 9277 |
for (const style of targetDocument.head.querySelectorAll( |
| 9278 |
`style[${STYLE_HASH_ATTRIBUTE2}]` |
| 9279 |
)) { |
| 9280 |
if (style.getAttribute(STYLE_HASH_ATTRIBUTE2) === hash) { |
| 9281 |
return true; |
| 9282 |
} |
| 9283 |
} |
| 9284 |
return false; |
| 9285 |
} |
| 9286 |
function injectStyle2(targetDocument, hash, css) { |
| 9287 |
if (!targetDocument.head) { |
| 9288 |
return; |
| 9289 |
} |
| 9290 |
const runtime = getRuntime2(); |
| 9291 |
let injectedStyles = runtime.injectedStyles.get(targetDocument); |
| 9292 |
if (!injectedStyles) { |
| 9293 |
injectedStyles = /* @__PURE__ */ new Set(); |
| 9294 |
runtime.injectedStyles.set(targetDocument, injectedStyles); |
| 9295 |
} |
| 9296 |
if (injectedStyles.has(hash)) { |
| 9297 |
return; |
| 9298 |
} |
| 9299 |
if (documentContainsStyleHash2(targetDocument, hash)) { |
| 9300 |
injectedStyles.add(hash); |
| 9301 |
return; |
| 9302 |
} |
| 9303 |
const style = targetDocument.createElement("style"); |
| 9304 |
style.setAttribute(STYLE_HASH_ATTRIBUTE2, hash); |
| 9305 |
style.appendChild(targetDocument.createTextNode(css)); |
| 9306 |
targetDocument.head.appendChild(style); |
| 9307 |
injectedStyles.add(hash); |
| 9308 |
} |
| 9309 |
function registerDocument2(targetDocument) { |
| 9310 |
const runtime = getRuntime2(); |
| 9311 |
runtime.documents.set( |
| 9312 |
targetDocument, |
| 9313 |
(runtime.documents.get(targetDocument) ?? 0) + 1 |
| 9314 |
); |
| 9315 |
for (const [hash, css] of runtime.styles) { |
| 9316 |
injectStyle2(targetDocument, hash, css); |
| 9317 |
} |
| 9318 |
return () => { |
| 9319 |
const count = runtime.documents.get(targetDocument); |
| 9320 |
if (count === void 0) { |
| 9321 |
return; |
| 9322 |
} |
| 9323 |
if (count <= 1) { |
| 9324 |
runtime.documents.delete(targetDocument); |
| 9325 |
return; |
| 9326 |
} |
| 9327 |
runtime.documents.set(targetDocument, count - 1); |
| 9328 |
}; |
| 9329 |
} |
| 9330 |
function registerStyle2(hash, css) { |
| 9331 |
const runtime = getRuntime2(); |
| 9332 |
runtime.styles.set(hash, css); |
| 9333 |
for (const targetDocument of runtime.documents.keys()) { |
| 9334 |
injectStyle2(targetDocument, hash, css); |
| 9335 |
} |
| 9336 |
} |
| 9337 |
if (typeof process === "undefined" || true) { |
| 9338 |
registerStyle2("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}"); |
| 9339 |
} |
| 9340 |
var resets_default = { "box-sizing": "_336cd3e4e743482f__box-sizing" }; |
| 9341 |
if (typeof process === "undefined" || true) { |
| 9342 |
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}}}}'); |
| 9343 |
} |
| 9344 |
var style_default = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" }; |
| 9345 |
var Positioner = (0, import_element14.forwardRef)( |
| 9346 |
function TooltipPositioner3({ align = "center", className, side = "top", sideOffset = 4, ...props }, ref) { |
| 9347 |
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)( |
| 9348 |
index_parts_exports.Positioner, |
| 9349 |
{ |
| 9350 |
ref, |
| 9351 |
align, |
| 9352 |
side, |
| 9353 |
sideOffset, |
| 9354 |
...props, |
| 9355 |
className: clsx_default( |
| 9356 |
resets_default["box-sizing"], |
| 9357 |
style_default.positioner, |
| 9358 |
className |
| 9359 |
) |
| 9360 |
} |
| 9361 |
); |
| 9362 |
} |
| 9363 |
); |
| 9364 |
|
| 9365 |
// packages/ui/build-module/tooltip/popup.mjs |
| 9366 |
var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1); |
| 9367 |
var STYLE_HASH_ATTRIBUTE3 = "data-wp-hash"; |
| 9368 |
function getRuntime3() { |
| 9369 |
const globalScope = globalThis; |
| 9370 |
if (globalScope.__wpStyleRuntime) { |
| 9371 |
return globalScope.__wpStyleRuntime; |
| 9372 |
} |
| 9373 |
globalScope.__wpStyleRuntime = { |
| 9374 |
documents: /* @__PURE__ */ new Map(), |
| 9375 |
styles: /* @__PURE__ */ new Map(), |
| 9376 |
injectedStyles: /* @__PURE__ */ new WeakMap() |
| 9377 |
}; |
| 9378 |
if (typeof document !== "undefined") { |
| 9379 |
registerDocument3(document); |
| 9380 |
} |
| 9381 |
return globalScope.__wpStyleRuntime; |
| 9382 |
} |
| 9383 |
function documentContainsStyleHash3(targetDocument, hash) { |
| 9384 |
if (!targetDocument.head) { |
| 9385 |
return false; |
| 9386 |
} |
| 9387 |
for (const style of targetDocument.head.querySelectorAll( |
| 9388 |
`style[${STYLE_HASH_ATTRIBUTE3}]` |
| 9389 |
)) { |
| 9390 |
if (style.getAttribute(STYLE_HASH_ATTRIBUTE3) === hash) { |
| 9391 |
return true; |
| 9392 |
} |
| 9393 |
} |
| 9394 |
return false; |
| 9395 |
} |
| 9396 |
function injectStyle3(targetDocument, hash, css) { |
| 9397 |
if (!targetDocument.head) { |
| 9398 |
return; |
| 9399 |
} |
| 9400 |
const runtime = getRuntime3(); |
| 9401 |
let injectedStyles = runtime.injectedStyles.get(targetDocument); |
| 9402 |
if (!injectedStyles) { |
| 9403 |
injectedStyles = /* @__PURE__ */ new Set(); |
| 9404 |
runtime.injectedStyles.set(targetDocument, injectedStyles); |
| 9405 |
} |
| 9406 |
if (injectedStyles.has(hash)) { |
| 9407 |
return; |
| 9408 |
} |
| 9409 |
if (documentContainsStyleHash3(targetDocument, hash)) { |
| 9410 |
injectedStyles.add(hash); |
| 9411 |
return; |
| 9412 |
} |
| 9413 |
const style = targetDocument.createElement("style"); |
| 9414 |
style.setAttribute(STYLE_HASH_ATTRIBUTE3, hash); |
| 9415 |
style.appendChild(targetDocument.createTextNode(css)); |
| 9416 |
targetDocument.head.appendChild(style); |
| 9417 |
injectedStyles.add(hash); |
| 9418 |
} |
| 9419 |
function registerDocument3(targetDocument) { |
| 9420 |
const runtime = getRuntime3(); |
| 9421 |
runtime.documents.set( |
| 9422 |
targetDocument, |
| 9423 |
(runtime.documents.get(targetDocument) ?? 0) + 1 |
| 9424 |
); |
| 9425 |
for (const [hash, css] of runtime.styles) { |
| 9426 |
injectStyle3(targetDocument, hash, css); |
| 9427 |
} |
| 9428 |
return () => { |
| 9429 |
const count = runtime.documents.get(targetDocument); |
| 9430 |
if (count === void 0) { |
| 9431 |
return; |
| 9432 |
} |
| 9433 |
if (count <= 1) { |
| 9434 |
runtime.documents.delete(targetDocument); |
| 9435 |
return; |
| 9436 |
} |
| 9437 |
runtime.documents.set(targetDocument, count - 1); |
| 9438 |
}; |
| 9439 |
} |
| 9440 |
function registerStyle3(hash, css) { |
| 9441 |
const runtime = getRuntime3(); |
| 9442 |
runtime.styles.set(hash, css); |
| 9443 |
for (const targetDocument of runtime.documents.keys()) { |
| 9444 |
injectStyle3(targetDocument, hash, css); |
| 9445 |
} |
| 9446 |
} |
| 9447 |
if (typeof process === "undefined" || true) { |
| 9448 |
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}}}}'); |
| 9449 |
} |
| 9450 |
var style_default2 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" }; |
| 9451 |
var POPUP_COLOR = { background: "#1e1e1e" }; |
| 9452 |
var Popup = (0, import_element15.forwardRef)(function TooltipPopup3({ portal, positioner, children, className, ...props }, ref) { |
| 9453 |
const popupContent = /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ThemeProvider, { color: POPUP_COLOR, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)( |
| 9454 |
index_parts_exports.Popup, |
| 9455 |
{ |
| 9456 |
ref, |
| 9457 |
className: clsx_default(style_default2.popup, className), |
| 9458 |
...props, |
| 9459 |
children |
| 9460 |
} |
| 9461 |
) }); |
| 9462 |
const positionedPopup = renderSlotWithChildren( |
| 9463 |
positioner, |
| 9464 |
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Positioner, {}), |
| 9465 |
popupContent |
| 9466 |
); |
| 9467 |
return renderSlotWithChildren(portal, /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Portal, {}), positionedPopup); |
| 9468 |
}); |
| 9469 |
|
| 9470 |
// packages/ui/build-module/tooltip/trigger.mjs |
| 9471 |
var import_element16 = __toESM(require_element(), 1); |
| 9472 |
var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1); |
| 9473 |
var Trigger = (0, import_element16.forwardRef)( |
| 9474 |
function TooltipTrigger3(props, ref) { |
| 9475 |
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(index_parts_exports.Trigger, { ref, ...props }); |
| 9476 |
} |
| 9477 |
); |
| 9478 |
|
| 9479 |
// packages/ui/build-module/tooltip/root.mjs |
| 9480 |
var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1); |
| 9481 |
function Root(props) { |
| 9482 |
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(index_parts_exports.Root, { ...props }); |
| 9483 |
} |
| 9484 |
|
| 9485 |
// packages/ui/build-module/tooltip/provider.mjs |
| 9486 |
var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1); |
| 9487 |
function Provider({ ...props }) { |
| 9488 |
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(index_parts_exports.Provider, { ...props }); |
| 9489 |
} |
| 9490 |
|
| 9491 |
// packages/ui/build-module/visually-hidden/visually-hidden.mjs |
| 9492 |
var import_element17 = __toESM(require_element(), 1); |
| 9493 |
var STYLE_HASH_ATTRIBUTE4 = "data-wp-hash"; |
| 9494 |
function getRuntime4() { |
| 9495 |
const globalScope = globalThis; |
| 9496 |
if (globalScope.__wpStyleRuntime) { |
| 9497 |
return globalScope.__wpStyleRuntime; |
| 9498 |
} |
| 9499 |
globalScope.__wpStyleRuntime = { |
| 9500 |
documents: /* @__PURE__ */ new Map(), |
| 9501 |
styles: /* @__PURE__ */ new Map(), |
| 9502 |
injectedStyles: /* @__PURE__ */ new WeakMap() |
| 9503 |
}; |
| 9504 |
if (typeof document !== "undefined") { |
| 9505 |
registerDocument4(document); |
| 9506 |
} |
| 9507 |
return globalScope.__wpStyleRuntime; |
| 9508 |
} |
| 9509 |
function documentContainsStyleHash4(targetDocument, hash) { |
| 9510 |
if (!targetDocument.head) { |
| 9511 |
return false; |
| 9512 |
} |
| 9513 |
for (const style of targetDocument.head.querySelectorAll( |
| 9514 |
`style[${STYLE_HASH_ATTRIBUTE4}]` |
| 9515 |
)) { |
| 9516 |
if (style.getAttribute(STYLE_HASH_ATTRIBUTE4) === hash) { |
| 9517 |
return true; |
| 9518 |
} |
| 9519 |
} |
| 9520 |
return false; |
| 9521 |
} |
| 9522 |
function injectStyle4(targetDocument, hash, css) { |
| 9523 |
if (!targetDocument.head) { |
| 9524 |
return; |
| 9525 |
} |
| 9526 |
const runtime = getRuntime4(); |
| 9527 |
let injectedStyles = runtime.injectedStyles.get(targetDocument); |
| 9528 |
if (!injectedStyles) { |
| 9529 |
injectedStyles = /* @__PURE__ */ new Set(); |
| 9530 |
runtime.injectedStyles.set(targetDocument, injectedStyles); |
| 9531 |
} |
| 9532 |
if (injectedStyles.has(hash)) { |
| 9533 |
return; |
| 9534 |
} |
| 9535 |
if (documentContainsStyleHash4(targetDocument, hash)) { |
| 9536 |
injectedStyles.add(hash); |
| 9537 |
return; |
| 9538 |
} |
| 9539 |
const style = targetDocument.createElement("style"); |
| 9540 |
style.setAttribute(STYLE_HASH_ATTRIBUTE4, hash); |
| 9541 |
style.appendChild(targetDocument.createTextNode(css)); |
| 9542 |
targetDocument.head.appendChild(style); |
| 9543 |
injectedStyles.add(hash); |
| 9544 |
} |
| 9545 |
function registerDocument4(targetDocument) { |
| 9546 |
const runtime = getRuntime4(); |
| 9547 |
runtime.documents.set( |
| 9548 |
targetDocument, |
| 9549 |
(runtime.documents.get(targetDocument) ?? 0) + 1 |
| 9550 |
); |
| 9551 |
for (const [hash, css] of runtime.styles) { |
| 9552 |
injectStyle4(targetDocument, hash, css); |
| 9553 |
} |
| 9554 |
return () => { |
| 9555 |
const count = runtime.documents.get(targetDocument); |
| 9556 |
if (count === void 0) { |
| 9557 |
return; |
| 9558 |
} |
| 9559 |
if (count <= 1) { |
| 9560 |
runtime.documents.delete(targetDocument); |
| 9561 |
return; |
| 9562 |
} |
| 9563 |
runtime.documents.set(targetDocument, count - 1); |
| 9564 |
}; |
| 9565 |
} |
| 9566 |
function registerStyle4(hash, css) { |
| 9567 |
const runtime = getRuntime4(); |
| 9568 |
runtime.styles.set(hash, css); |
| 9569 |
for (const targetDocument of runtime.documents.keys()) { |
| 9570 |
injectStyle4(targetDocument, hash, css); |
| 9571 |
} |
| 9572 |
} |
| 9573 |
if (typeof process === "undefined" || true) { |
| 9574 |
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}}}"); |
| 9575 |
} |
| 9576 |
var style_default3 = { "visually-hidden": "f37b9e2e191ebd66__visually-hidden" }; |
| 9577 |
var VisuallyHidden = (0, import_element17.forwardRef)( |
| 9578 |
function VisuallyHidden2({ render, ...restProps }, ref) { |
| 9579 |
const element = useRender({ |
| 9580 |
render, |
| 9581 |
ref, |
| 9582 |
props: mergeProps( |
| 9583 |
{ className: style_default3["visually-hidden"] }, |
| 9584 |
restProps, |
| 9585 |
{ |
| 9586 |
// @ts-expect-error Arbitrary data-* attributes aren't indexable on the typed div props. Kept hardcoded so consumers can't change or remove it. |
| 9587 |
"data-visually-hidden": "" |
| 9588 |
} |
| 9589 |
) |
| 9590 |
}); |
| 9591 |
return element; |
| 9592 |
} |
| 9593 |
); |
| 9594 |
|
| 9595 |
// packages/block-directory/build-module/components/block-ratings/stars.mjs |
| 9596 |
var import_i18n2 = __toESM(require_i18n(), 1); |
| 9597 |
var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1); |
| 9598 |
function Stars({ rating }) { |
| 9599 |
const stars = Math.round(rating / 0.5) * 0.5; |
| 9600 |
const fullStarCount = Math.floor(rating); |
| 9601 |
const halfStarCount = Math.ceil(rating - fullStarCount); |
| 9602 |
const emptyStarCount = 5 - (fullStarCount + halfStarCount); |
| 9603 |
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)( |
| 9604 |
"span", |
| 9605 |
{ |
| 9606 |
"aria-label": (0, import_i18n2.sprintf)( |
| 9607 |
/* translators: %s: number of stars. */ |
| 9608 |
(0, import_i18n2.__)("%s out of 5 stars"), |
| 9609 |
stars |
| 9610 |
), |
| 9611 |
children: [ |
| 9612 |
Array.from({ length: fullStarCount }).map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)( |
| 9613 |
icon_default, |
| 9614 |
{ |
| 9615 |
className: "block-directory-block-ratings__star-full", |
| 9616 |
icon: star_filled_default, |
| 9617 |
size: 16 |
| 9618 |
}, |
| 9619 |
`full_stars_${i}` |
| 9620 |
)), |
| 9621 |
Array.from({ length: halfStarCount }).map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)( |
| 9622 |
icon_default, |
| 9623 |
{ |
| 9624 |
className: "block-directory-block-ratings__star-half-full", |
| 9625 |
icon: star_half_default, |
| 9626 |
size: 16 |
| 9627 |
}, |
| 9628 |
`half_stars_${i}` |
| 9629 |
)), |
| 9630 |
Array.from({ length: emptyStarCount }).map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)( |
| 9631 |
icon_default, |
| 9632 |
{ |
| 9633 |
className: "block-directory-block-ratings__star-empty", |
| 9634 |
icon: star_empty_default, |
| 9635 |
size: 16 |
| 9636 |
}, |
| 9637 |
`empty_stars_${i}` |
| 9638 |
)) |
| 9639 |
] |
| 9640 |
} |
| 9641 |
); |
| 9642 |
} |
| 9643 |
var stars_default = Stars; |
| 9644 |
|
| 9645 |
// packages/block-directory/build-module/components/block-ratings/index.mjs |
| 9646 |
var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1); |
| 9647 |
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 }) }); |
| 9648 |
var block_ratings_default = BlockRatings; |
| 9649 |
|
| 9650 |
// packages/block-directory/build-module/components/downloadable-block-icon/index.mjs |
| 9651 |
var import_block_editor2 = __toESM(require_block_editor(), 1); |
| 9652 |
var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1); |
| 9653 |
function DownloadableBlockIcon({ icon }) { |
| 9654 |
const className = "block-directory-downloadable-block-icon"; |
| 9655 |
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 }); |
| 9656 |
} |
| 9657 |
var downloadable_block_icon_default = DownloadableBlockIcon; |
| 9658 |
|
| 9659 |
// packages/block-directory/build-module/components/downloadable-block-notice/index.mjs |
| 9660 |
var import_i18n3 = __toESM(require_i18n(), 1); |
| 9661 |
var import_data5 = __toESM(require_data(), 1); |
| 9662 |
var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1); |
| 9663 |
var DownloadableBlockNotice = ({ block }) => { |
| 9664 |
const errorNotice = (0, import_data5.useSelect)( |
| 9665 |
(select) => select(store).getErrorNoticeForBlock(block.id), |
| 9666 |
[block] |
| 9667 |
); |
| 9668 |
if (!errorNotice) { |
| 9669 |
return null; |
| 9670 |
} |
| 9671 |
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: [ |
| 9672 |
errorNotice.message, |
| 9673 |
errorNotice.isFatal ? " " + (0, import_i18n3.__)("Try reloading the page.") : null |
| 9674 |
] }) }); |
| 9675 |
}; |
| 9676 |
var downloadable_block_notice_default = DownloadableBlockNotice; |
| 9677 |
|
| 9678 |
// packages/block-directory/build-module/components/downloadable-block-list-item/index.mjs |
| 9679 |
var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1); |
| 9680 |
function getDownloadableBlockLabel({ title, rating, ratingCount }, { hasNotice, isInstalled, isInstalling: isInstalling2 }) { |
| 9681 |
const stars = Math.round(rating / 0.5) * 0.5; |
| 9682 |
if (!isInstalled && hasNotice) { |
| 9683 |
return (0, import_i18n4.sprintf)("Retry installing %s.", (0, import_html_entities.decodeEntities)(title)); |
| 9684 |
} |
| 9685 |
if (isInstalled) { |
| 9686 |
return (0, import_i18n4.sprintf)("Add %s.", (0, import_html_entities.decodeEntities)(title)); |
| 9687 |
} |
| 9688 |
if (isInstalling2) { |
| 9689 |
return (0, import_i18n4.sprintf)("Installing %s.", (0, import_html_entities.decodeEntities)(title)); |
| 9690 |
} |
| 9691 |
if (ratingCount < 1) { |
| 9692 |
return (0, import_i18n4.sprintf)("Install %s.", (0, import_html_entities.decodeEntities)(title)); |
| 9693 |
} |
| 9694 |
return (0, import_i18n4.sprintf)( |
| 9695 |
/* translators: 1: block title, 2: average rating, 3: total ratings count. */ |
| 9696 |
(0, import_i18n4._n)( |
| 9697 |
"Install %1$s. %2$s stars with %3$s review.", |
| 9698 |
"Install %1$s. %2$s stars with %3$s reviews.", |
| 9699 |
ratingCount |
| 9700 |
), |
| 9701 |
(0, import_html_entities.decodeEntities)(title), |
| 9702 |
stars, |
| 9703 |
ratingCount |
| 9704 |
); |
| 9705 |
} |
| 9706 |
function DownloadableBlockListItem({ item, onClick }) { |
| 9707 |
const { author, description, icon, rating, title } = item; |
| 9708 |
const isInstalled = !!(0, import_blocks3.getBlockType)(item.name); |
| 9709 |
const { hasNotice, isInstalling: isInstalling2, isInstallable } = (0, import_data6.useSelect)( |
| 9710 |
(select) => { |
| 9711 |
const { getErrorNoticeForBlock: getErrorNoticeForBlock2, isInstalling: isBlockInstalling } = select(store); |
| 9712 |
const notice = getErrorNoticeForBlock2(item.id); |
| 9713 |
const hasFatal = notice && notice.isFatal; |
| 9714 |
return { |
| 9715 |
hasNotice: !!notice, |
| 9716 |
isInstalling: isBlockInstalling(item.id), |
| 9717 |
isInstallable: !hasFatal |
| 9718 |
}; |
| 9719 |
}, |
| 9720 |
[item] |
| 9721 |
); |
| 9722 |
let statusText = ""; |
| 9723 |
if (isInstalled) { |
| 9724 |
statusText = (0, import_i18n4.__)("Installed!"); |
| 9725 |
} else if (isInstalling2) { |
| 9726 |
statusText = (0, import_i18n4.__)("Installing\u2026"); |
| 9727 |
} |
| 9728 |
const itemLabel = getDownloadableBlockLabel(item, { |
| 9729 |
hasNotice, |
| 9730 |
isInstalled, |
| 9731 |
isInstalling: isInstalling2 |
| 9732 |
}); |
| 9733 |
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(tooltip_exports.Root, { children: [ |
| 9734 |
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)( |
| 9735 |
tooltip_exports.Trigger, |
| 9736 |
{ |
| 9737 |
render: /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)( |
| 9738 |
import_components.Composite.Item, |
| 9739 |
{ |
| 9740 |
className: clsx_default( |
| 9741 |
"block-directory-downloadable-block-list-item", |
| 9742 |
isInstalling2 && "is-installing" |
| 9743 |
), |
| 9744 |
accessibleWhenDisabled: true, |
| 9745 |
disabled: isInstalling2 || !isInstallable, |
| 9746 |
onClick: (event) => { |
| 9747 |
event.preventDefault(); |
| 9748 |
onClick(); |
| 9749 |
}, |
| 9750 |
"aria-label": itemLabel, |
| 9751 |
type: "button", |
| 9752 |
role: "option", |
| 9753 |
children: [ |
| 9754 |
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "block-directory-downloadable-block-list-item__icon", children: [ |
| 9755 |
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)( |
| 9756 |
downloadable_block_icon_default, |
| 9757 |
{ |
| 9758 |
icon, |
| 9759 |
title |
| 9760 |
} |
| 9761 |
), |
| 9762 |
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 }) |
| 9763 |
] }), |
| 9764 |
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("span", { className: "block-directory-downloadable-block-list-item__details", children: [ |
| 9765 |
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "block-directory-downloadable-block-list-item__title", children: (0, import_element18.createInterpolateElement)( |
| 9766 |
(0, import_i18n4.sprintf)( |
| 9767 |
/* translators: 1: block title. 2: author name. */ |
| 9768 |
(0, import_i18n4.__)("%1$s <span>by %2$s</span>"), |
| 9769 |
(0, import_html_entities.decodeEntities)(title), |
| 9770 |
author |
| 9771 |
), |
| 9772 |
{ |
| 9773 |
span: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "block-directory-downloadable-block-list-item__author" }) |
| 9774 |
} |
| 9775 |
) }), |
| 9776 |
hasNotice ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(downloadable_block_notice_default, { block: item }) : /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_jsx_runtime24.Fragment, { children: [ |
| 9777 |
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "block-directory-downloadable-block-list-item__desc", children: !!statusText ? statusText : (0, import_html_entities.decodeEntities)(description) }), |
| 9778 |
isInstallable && !(isInstalled || isInstalling2) && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(VisuallyHidden, { children: (0, import_i18n4.__)("Install block") }) |
| 9779 |
] }) |
| 9780 |
] }) |
| 9781 |
] |
| 9782 |
} |
| 9783 |
) |
| 9784 |
} |
| 9785 |
), |
| 9786 |
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(tooltip_exports.Popup, { children: itemLabel }) |
| 9787 |
] }); |
| 9788 |
} |
| 9789 |
var downloadable_block_list_item_default = DownloadableBlockListItem; |
| 9790 |
|
| 9791 |
// packages/block-directory/build-module/components/downloadable-blocks-list/index.mjs |
| 9792 |
var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1); |
| 9793 |
var noop4 = () => { |
| 9794 |
}; |
| 9795 |
function DownloadableBlocksList({ items, onHover = noop4, onSelect }) { |
| 9796 |
const { installBlockType: installBlockType2 } = (0, import_data7.useDispatch)(store); |
| 9797 |
if (!items.length) { |
| 9798 |
return null; |
| 9799 |
} |
| 9800 |
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)( |
| 9801 |
import_components2.Composite, |
| 9802 |
{ |
| 9803 |
role: "listbox", |
| 9804 |
className: "block-directory-downloadable-blocks-list", |
| 9805 |
"aria-label": (0, import_i18n5.__)("Blocks available for install"), |
| 9806 |
children: items.map((item) => { |
| 9807 |
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)( |
| 9808 |
downloadable_block_list_item_default, |
| 9809 |
{ |
| 9810 |
onClick: () => { |
| 9811 |
if ((0, import_blocks4.getBlockType)(item.name)) { |
| 9812 |
onSelect(item); |
| 9813 |
} else { |
| 9814 |
installBlockType2(item).then((success) => { |
| 9815 |
if (success) { |
| 9816 |
onSelect(item); |
| 9817 |
} |
| 9818 |
}); |
| 9819 |
} |
| 9820 |
onHover(null); |
| 9821 |
}, |
| 9822 |
onHover, |
| 9823 |
item |
| 9824 |
}, |
| 9825 |
item.id |
| 9826 |
); |
| 9827 |
}) |
| 9828 |
} |
| 9829 |
); |
| 9830 |
} |
| 9831 |
var downloadable_blocks_list_default = DownloadableBlocksList; |
| 9832 |
|
| 9833 |
// packages/block-directory/build-module/components/downloadable-blocks-panel/inserter-panel.mjs |
| 9834 |
var import_i18n6 = __toESM(require_i18n(), 1); |
| 9835 |
var import_element19 = __toESM(require_element(), 1); |
| 9836 |
var import_a11y = __toESM(require_a11y(), 1); |
| 9837 |
var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1); |
| 9838 |
function DownloadableBlocksInserterPanel({ |
| 9839 |
children, |
| 9840 |
downloadableItems, |
| 9841 |
hasLocalBlocks |
| 9842 |
}) { |
| 9843 |
const count = downloadableItems.length; |
| 9844 |
(0, import_element19.useEffect)(() => { |
| 9845 |
(0, import_a11y.speak)( |
| 9846 |
(0, import_i18n6.sprintf)( |
| 9847 |
/* translators: %d: number of available blocks. */ |
| 9848 |
(0, import_i18n6._n)( |
| 9849 |
"%d additional block is available to install.", |
| 9850 |
"%d additional blocks are available to install.", |
| 9851 |
count |
| 9852 |
), |
| 9853 |
count |
| 9854 |
) |
| 9855 |
); |
| 9856 |
}, [count]); |
| 9857 |
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [ |
| 9858 |
!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.") }), |
| 9859 |
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "block-editor-inserter__quick-inserter-separator" }), |
| 9860 |
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "block-directory-downloadable-blocks-panel", children: [ |
| 9861 |
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "block-directory-downloadable-blocks-panel__header", children: [ |
| 9862 |
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("h2", { className: "block-directory-downloadable-blocks-panel__title", children: (0, import_i18n6.__)("Available to install") }), |
| 9863 |
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("p", { className: "block-directory-downloadable-blocks-panel__description", children: (0, import_i18n6.__)( |
| 9864 |
"Select a block to install and add it to your post." |
| 9865 |
) }) |
| 9866 |
] }), |
| 9867 |
children |
| 9868 |
] }) |
| 9869 |
] }); |
| 9870 |
} |
| 9871 |
var inserter_panel_default = DownloadableBlocksInserterPanel; |
| 9872 |
|
| 9873 |
// packages/block-directory/build-module/components/downloadable-blocks-panel/no-results.mjs |
| 9874 |
var import_i18n7 = __toESM(require_i18n(), 1); |
| 9875 |
var import_components3 = __toESM(require_components(), 1); |
| 9876 |
var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1); |
| 9877 |
function DownloadableBlocksNoResults() { |
| 9878 |
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_jsx_runtime27.Fragment, { children: [ |
| 9879 |
/* @__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.") }) }), |
| 9880 |
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "block-editor-inserter__tips", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_components3.Tip, { children: [ |
| 9881 |
(0, import_i18n7.__)("Interested in creating your own block?"), |
| 9882 |
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("br", {}), |
| 9883 |
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_components3.ExternalLink, { href: "https://developer.wordpress.org/block-editor/", children: [ |
| 9884 |
(0, import_i18n7.__)("Get started here"), |
| 9885 |
"." |
| 9886 |
] }) |
| 9887 |
] }) }) |
| 9888 |
] }); |
| 9889 |
} |
| 9890 |
var no_results_default = DownloadableBlocksNoResults; |
| 9891 |
|
| 9892 |
// packages/block-directory/build-module/components/downloadable-blocks-panel/index.mjs |
| 9893 |
var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1); |
| 9894 |
var EMPTY_ARRAY3 = []; |
| 9895 |
var useDownloadableBlocks = (filterValue) => (0, import_data8.useSelect)( |
| 9896 |
(select) => { |
| 9897 |
const { |
| 9898 |
getDownloadableBlocks: getDownloadableBlocks3, |
| 9899 |
isRequestingDownloadableBlocks: isRequestingDownloadableBlocks2, |
| 9900 |
getInstalledBlockTypes: getInstalledBlockTypes2 |
| 9901 |
} = select(store); |
| 9902 |
const hasPermission = select(import_core_data.store).canUser( |
| 9903 |
"read", |
| 9904 |
"block-directory/search" |
| 9905 |
); |
| 9906 |
let downloadableBlocks2 = EMPTY_ARRAY3; |
| 9907 |
if (hasPermission) { |
| 9908 |
downloadableBlocks2 = getDownloadableBlocks3(filterValue); |
| 9909 |
const installedBlockTypes = getInstalledBlockTypes2(); |
| 9910 |
const installableBlocks = downloadableBlocks2.filter( |
| 9911 |
({ name }) => { |
| 9912 |
const isJustInstalled = installedBlockTypes.some( |
| 9913 |
(blockType) => blockType.name === name |
| 9914 |
); |
| 9915 |
const isPreviouslyInstalled = (0, import_blocks5.getBlockType)(name); |
| 9916 |
return isJustInstalled || !isPreviouslyInstalled; |
| 9917 |
} |
| 9918 |
); |
| 9919 |
if (installableBlocks.length !== downloadableBlocks2.length) { |
| 9920 |
downloadableBlocks2 = installableBlocks; |
| 9921 |
} |
| 9922 |
if (downloadableBlocks2.length === 0) { |
| 9923 |
downloadableBlocks2 = EMPTY_ARRAY3; |
| 9924 |
} |
| 9925 |
} |
| 9926 |
return { |
| 9927 |
hasPermission, |
| 9928 |
downloadableBlocks: downloadableBlocks2, |
| 9929 |
isLoading: isRequestingDownloadableBlocks2(filterValue) |
| 9930 |
}; |
| 9931 |
}, |
| 9932 |
[filterValue] |
| 9933 |
); |
| 9934 |
function DownloadableBlocksPanel({ |
| 9935 |
onSelect, |
| 9936 |
onHover, |
| 9937 |
hasLocalBlocks, |
| 9938 |
isTyping, |
| 9939 |
filterValue |
| 9940 |
}) { |
| 9941 |
const { hasPermission, downloadableBlocks: downloadableBlocks2, isLoading } = useDownloadableBlocks(filterValue); |
| 9942 |
if (hasPermission === void 0 || isLoading || isTyping) { |
| 9943 |
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_jsx_runtime28.Fragment, { children: [ |
| 9944 |
hasPermission && !hasLocalBlocks && /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_jsx_runtime28.Fragment, { children: [ |
| 9945 |
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("p", { className: "block-directory-downloadable-blocks-panel__no-local", children: (0, import_i18n8.__)( |
| 9946 |
"No results available from your installed blocks." |
| 9947 |
) }), |
| 9948 |
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "block-editor-inserter__quick-inserter-separator" }) |
| 9949 |
] }), |
| 9950 |
/* @__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, {}) }) |
| 9951 |
] }); |
| 9952 |
} |
| 9953 |
if (false === hasPermission) { |
| 9954 |
if (!hasLocalBlocks) { |
| 9955 |
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(no_results_default, {}); |
| 9956 |
} |
| 9957 |
return null; |
| 9958 |
} |
| 9959 |
if (downloadableBlocks2.length === 0) { |
| 9960 |
return hasLocalBlocks ? null : /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(no_results_default, {}); |
| 9961 |
} |
| 9962 |
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)( |
| 9963 |
inserter_panel_default, |
| 9964 |
{ |
| 9965 |
downloadableItems: downloadableBlocks2, |
| 9966 |
hasLocalBlocks, |
| 9967 |
children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)( |
| 9968 |
downloadable_blocks_list_default, |
| 9969 |
{ |
| 9970 |
items: downloadableBlocks2, |
| 9971 |
onSelect, |
| 9972 |
onHover |
| 9973 |
} |
| 9974 |
) |
| 9975 |
} |
| 9976 |
); |
| 9977 |
} |
| 9978 |
|
| 9979 |
// packages/block-directory/build-module/plugins/inserter-menu-downloadable-blocks-panel/index.mjs |
| 9980 |
var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1); |
| 9981 |
function InserterMenuDownloadableBlocksPanel() { |
| 9982 |
const [debouncedFilterValue, setFilterValue] = (0, import_element20.useState)(""); |
| 9983 |
const debouncedSetFilterValue = (0, import_compose.debounce)(setFilterValue, 400); |
| 9984 |
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_block_editor3.__unstableInserterMenuExtension, { children: ({ onSelect, onHover, filterValue, hasItems }) => { |
| 9985 |
if (debouncedFilterValue !== filterValue) { |
| 9986 |
debouncedSetFilterValue(filterValue); |
| 9987 |
} |
| 9988 |
if (!debouncedFilterValue) { |
| 9989 |
return null; |
| 9990 |
} |
| 9991 |
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)( |
| 9992 |
DownloadableBlocksPanel, |
| 9993 |
{ |
| 9994 |
onSelect, |
| 9995 |
onHover, |
| 9996 |
filterValue: debouncedFilterValue, |
| 9997 |
hasLocalBlocks: hasItems, |
| 9998 |
isTyping: filterValue !== debouncedFilterValue |
| 9999 |
} |
| 10000 |
); |
| 10001 |
} }); |
| 10002 |
} |
| 10003 |
var inserter_menu_downloadable_blocks_panel_default = InserterMenuDownloadableBlocksPanel; |
| 10004 |
|
| 10005 |
// packages/block-directory/build-module/plugins/installed-blocks-pre-publish-panel/index.mjs |
| 10006 |
var import_i18n10 = __toESM(require_i18n(), 1); |
| 10007 |
var import_data9 = __toESM(require_data(), 1); |
| 10008 |
var import_editor2 = __toESM(require_editor(), 1); |
| 10009 |
|
| 10010 |
// packages/block-directory/build-module/components/compact-list/index.mjs |
| 10011 |
var import_i18n9 = __toESM(require_i18n(), 1); |
| 10012 |
var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1); |
| 10013 |
function CompactList({ items }) { |
| 10014 |
if (!items.length) { |
| 10015 |
return null; |
| 10016 |
} |
| 10017 |
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: [ |
| 10018 |
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(downloadable_block_icon_default, { icon, title }), |
| 10019 |
/* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "block-directory-compact-list__item-details", children: [ |
| 10020 |
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: "block-directory-compact-list__item-title", children: title }), |
| 10021 |
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: "block-directory-compact-list__item-author", children: (0, import_i18n9.sprintf)( |
| 10022 |
/* translators: %s: Name of the block author. */ |
| 10023 |
(0, import_i18n9.__)("By %s"), |
| 10024 |
author |
| 10025 |
) }) |
| 10026 |
] }) |
| 10027 |
] }, id)) }); |
| 10028 |
} |
| 10029 |
|
| 10030 |
// packages/block-directory/build-module/plugins/installed-blocks-pre-publish-panel/index.mjs |
| 10031 |
var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1); |
| 10032 |
function InstalledBlocksPrePublishPanel() { |
| 10033 |
const newBlockTypes = (0, import_data9.useSelect)( |
| 10034 |
(select) => select(store).getNewBlockTypes(), |
| 10035 |
[] |
| 10036 |
); |
| 10037 |
if (!newBlockTypes.length) { |
| 10038 |
return null; |
| 10039 |
} |
| 10040 |
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)( |
| 10041 |
import_editor2.PluginPrePublishPanel, |
| 10042 |
{ |
| 10043 |
title: (0, import_i18n10.sprintf)( |
| 10044 |
// translators: %d: number of blocks (number). |
| 10045 |
(0, import_i18n10._n)( |
| 10046 |
"Added: %d block", |
| 10047 |
"Added: %d blocks", |
| 10048 |
newBlockTypes.length |
| 10049 |
), |
| 10050 |
newBlockTypes.length |
| 10051 |
), |
| 10052 |
initialOpen: true, |
| 10053 |
children: [ |
| 10054 |
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("p", { className: "installed-blocks-pre-publish-panel__copy", children: (0, import_i18n10._n)( |
| 10055 |
"The following block has been added to your site.", |
| 10056 |
"The following blocks have been added to your site.", |
| 10057 |
newBlockTypes.length |
| 10058 |
) }), |
| 10059 |
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(CompactList, { items: newBlockTypes }) |
| 10060 |
] |
| 10061 |
} |
| 10062 |
); |
| 10063 |
} |
| 10064 |
|
| 10065 |
// packages/block-directory/build-module/plugins/get-install-missing/index.mjs |
| 10066 |
var import_i18n12 = __toESM(require_i18n(), 1); |
| 10067 |
var import_components6 = __toESM(require_components(), 1); |
| 10068 |
var import_blocks7 = __toESM(require_blocks(), 1); |
| 10069 |
var import_element21 = __toESM(require_element(), 1); |
| 10070 |
var import_data11 = __toESM(require_data(), 1); |
| 10071 |
var import_core_data2 = __toESM(require_core_data(), 1); |
| 10072 |
var import_block_editor5 = __toESM(require_block_editor(), 1); |
| 10073 |
|
| 10074 |
// packages/block-directory/build-module/plugins/get-install-missing/install-button.mjs |
| 10075 |
var import_i18n11 = __toESM(require_i18n(), 1); |
| 10076 |
var import_components5 = __toESM(require_components(), 1); |
| 10077 |
var import_blocks6 = __toESM(require_blocks(), 1); |
| 10078 |
var import_data10 = __toESM(require_data(), 1); |
| 10079 |
var import_block_editor4 = __toESM(require_block_editor(), 1); |
| 10080 |
var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1); |
| 10081 |
function InstallButton({ attributes, block, clientId }) { |
| 10082 |
const isInstallingBlock = (0, import_data10.useSelect)( |
| 10083 |
(select) => select(store).isInstalling(block.id), |
| 10084 |
[block.id] |
| 10085 |
); |
| 10086 |
const { installBlockType: installBlockType2 } = (0, import_data10.useDispatch)(store); |
| 10087 |
const { replaceBlock } = (0, import_data10.useDispatch)(import_block_editor4.store); |
| 10088 |
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)( |
| 10089 |
import_components5.Button, |
| 10090 |
{ |
| 10091 |
__next40pxDefaultSize: true, |
| 10092 |
onClick: () => installBlockType2(block).then((success) => { |
| 10093 |
if (success) { |
| 10094 |
const blockType = (0, import_blocks6.getBlockType)(block.name); |
| 10095 |
const [originalBlock] = (0, import_blocks6.parse)( |
| 10096 |
attributes.originalContent |
| 10097 |
); |
| 10098 |
if (originalBlock && blockType) { |
| 10099 |
replaceBlock( |
| 10100 |
clientId, |
| 10101 |
(0, import_blocks6.createBlock)( |
| 10102 |
blockType.name, |
| 10103 |
originalBlock.attributes, |
| 10104 |
originalBlock.innerBlocks |
| 10105 |
) |
| 10106 |
); |
| 10107 |
} |
| 10108 |
} |
| 10109 |
}), |
| 10110 |
accessibleWhenDisabled: true, |
| 10111 |
disabled: isInstallingBlock, |
| 10112 |
isBusy: isInstallingBlock, |
| 10113 |
variant: "primary", |
| 10114 |
children: (0, import_i18n11.sprintf)( |
| 10115 |
/* translators: %s: block name */ |
| 10116 |
(0, import_i18n11.__)("Install %s"), |
| 10117 |
block.title |
| 10118 |
) |
| 10119 |
} |
| 10120 |
); |
| 10121 |
} |
| 10122 |
|
| 10123 |
// packages/block-directory/build-module/plugins/get-install-missing/index.mjs |
| 10124 |
var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1); |
| 10125 |
var getInstallMissing = (OriginalComponent) => (props) => { |
| 10126 |
const { originalName } = props.attributes; |
| 10127 |
const { block, hasPermission } = (0, import_data11.useSelect)( |
| 10128 |
(select) => { |
| 10129 |
const { getDownloadableBlocks: getDownloadableBlocks3 } = select(store); |
| 10130 |
const blocks = getDownloadableBlocks3( |
| 10131 |
"block:" + originalName |
| 10132 |
).filter(({ name }) => originalName === name); |
| 10133 |
return { |
| 10134 |
hasPermission: select(import_core_data2.store).canUser( |
| 10135 |
"read", |
| 10136 |
"block-directory/search" |
| 10137 |
), |
| 10138 |
block: blocks.length && blocks[0] |
| 10139 |
}; |
| 10140 |
}, |
| 10141 |
[originalName] |
| 10142 |
); |
| 10143 |
if (!hasPermission || !block) { |
| 10144 |
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(OriginalComponent, { ...props }); |
| 10145 |
} |
| 10146 |
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(ModifiedWarning, { ...props, originalBlock: block }); |
| 10147 |
}; |
| 10148 |
var ModifiedWarning = ({ originalBlock, ...props }) => { |
| 10149 |
const { originalName, originalUndelimitedContent, clientId } = props.attributes; |
| 10150 |
const { replaceBlock } = (0, import_data11.useDispatch)(import_block_editor5.store); |
| 10151 |
const convertToHTML = () => { |
| 10152 |
replaceBlock( |
| 10153 |
props.clientId, |
| 10154 |
(0, import_blocks7.createBlock)("core/html", {}, [], [originalUndelimitedContent]) |
| 10155 |
); |
| 10156 |
}; |
| 10157 |
const hasContent = !!originalUndelimitedContent; |
| 10158 |
const hasHTMLBlock = (0, import_data11.useSelect)( |
| 10159 |
(select) => { |
| 10160 |
const { canInsertBlockType, getBlockRootClientId } = select(import_block_editor5.store); |
| 10161 |
return canInsertBlockType( |
| 10162 |
"core/html", |
| 10163 |
getBlockRootClientId(clientId) |
| 10164 |
); |
| 10165 |
}, |
| 10166 |
[clientId] |
| 10167 |
); |
| 10168 |
let messageHTML = (0, import_i18n12.sprintf)( |
| 10169 |
/* translators: %s: block name */ |
| 10170 |
(0, import_i18n12.__)( |
| 10171 |
"Your site doesn\u2019t include support for the %s block. You can try installing the block or remove it entirely." |
| 10172 |
), |
| 10173 |
originalBlock.title || originalName |
| 10174 |
); |
| 10175 |
const actions = [ |
| 10176 |
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)( |
| 10177 |
InstallButton, |
| 10178 |
{ |
| 10179 |
block: originalBlock, |
| 10180 |
attributes: props.attributes, |
| 10181 |
clientId: props.clientId |
| 10182 |
}, |
| 10183 |
"install" |
| 10184 |
) |
| 10185 |
]; |
| 10186 |
if (hasContent && hasHTMLBlock) { |
| 10187 |
messageHTML = (0, import_i18n12.sprintf)( |
| 10188 |
/* translators: %s: block name */ |
| 10189 |
(0, import_i18n12.__)( |
| 10190 |
"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." |
| 10191 |
), |
| 10192 |
originalBlock.title || originalName |
| 10193 |
); |
| 10194 |
actions.push( |
| 10195 |
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)( |
| 10196 |
import_components6.Button, |
| 10197 |
{ |
| 10198 |
__next40pxDefaultSize: true, |
| 10199 |
onClick: convertToHTML, |
| 10200 |
variant: "tertiary", |
| 10201 |
children: (0, import_i18n12.__)("Keep as HTML") |
| 10202 |
}, |
| 10203 |
"convert" |
| 10204 |
) |
| 10205 |
); |
| 10206 |
} |
| 10207 |
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { ...(0, import_block_editor5.useBlockProps)(), children: [ |
| 10208 |
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_block_editor5.Warning, { actions, children: messageHTML }), |
| 10209 |
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_element21.RawHTML, { children: originalUndelimitedContent }) |
| 10210 |
] }); |
| 10211 |
}; |
| 10212 |
var get_install_missing_default = getInstallMissing; |
| 10213 |
|
| 10214 |
// packages/block-directory/build-module/plugins/index.mjs |
| 10215 |
var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1); |
| 10216 |
(0, import_plugins.registerPlugin)("block-directory", { |
| 10217 |
// The icon is explicitly set to undefined to prevent PluginPrePublishPanel |
| 10218 |
// from rendering the fallback icon pluginIcon. |
| 10219 |
icon: void 0, |
| 10220 |
render() { |
| 10221 |
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [ |
| 10222 |
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(AutoBlockUninstaller, {}), |
| 10223 |
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(inserter_menu_downloadable_blocks_panel_default, {}), |
| 10224 |
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(InstalledBlocksPrePublishPanel, {}) |
| 10225 |
] }); |
| 10226 |
} |
| 10227 |
}); |
| 10228 |
(0, import_hooks.addFilter)( |
| 10229 |
"blocks.registerBlockType", |
| 10230 |
"block-directory/fallback", |
| 10231 |
(settings, name) => { |
| 10232 |
if (name !== "core/missing") { |
| 10233 |
return settings; |
| 10234 |
} |
| 10235 |
settings.edit = get_install_missing_default(settings.edit); |
| 10236 |
return settings; |
| 10237 |
} |
| 10238 |
); |
| 10239 |
return __toCommonJS(index_exports); |
| 10240 |
})(); |
| 10241 |
/*! Bundled license information: |
| 10242 |
|
| 10243 |
use-sync-external-store/cjs/use-sync-external-store-shim.development.js: |
| 10244 |
(** |
| 10245 |
* @license React |
| 10246 |
* use-sync-external-store-shim.development.js |
| 10247 |
* |
| 10248 |
* Copyright (c) Meta Platforms, Inc. and affiliates. |
| 10249 |
* |
| 10250 |
* This source code is licensed under the MIT license found in the |
| 10251 |
* LICENSE file in the root directory of this source tree. |
| 10252 |
*) |
| 10253 |
|
| 10254 |
use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js: |
| 10255 |
(** |
| 10256 |
* @license React |
| 10257 |
* use-sync-external-store-shim/with-selector.development.js |
| 10258 |
* |
| 10259 |
* Copyright (c) Meta Platforms, Inc. and affiliates. |
| 10260 |
* |
| 10261 |
* This source code is licensed under the MIT license found in the |
| 10262 |
* LICENSE file in the root directory of this source tree. |
| 10263 |
*) |
| 10264 |
*/ |
| 10265 |
//# sourceMappingURL=index.js.map |
| 10266 |
|