PluginProbe
Gutenberg / 23.3.2
Gutenberg v23.3.2
23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 7.4.0 All 402 releases
gutenberg / build / scripts / block-directory / index.js

index.js in Gutenberg 23.3.2, at build/scripts/block-directory/index.js

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