PluginProbe
Gutenberg / 23.5.0
Gutenberg v23.5.0
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 / edit-post / index.js

index.js in Gutenberg 23.5.0, at build/scripts/edit-post/index.js

11,953 lines 439.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 var wp;
2 (wp ||= {}).editPost = (() => {
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/blocks
35 var require_blocks = __commonJS({
36 "package-external:@wordpress/blocks"(exports, module) {
37 module.exports = window.wp.blocks;
38 }
39 });
40
41 // package-external:@wordpress/block-library
42 var require_block_library = __commonJS({
43 "package-external:@wordpress/block-library"(exports, module) {
44 module.exports = window.wp.blockLibrary;
45 }
46 });
47
48 // package-external:@wordpress/deprecated
49 var require_deprecated = __commonJS({
50 "package-external:@wordpress/deprecated"(exports, module) {
51 module.exports = window.wp.deprecated;
52 }
53 });
54
55 // package-external:@wordpress/element
56 var require_element = __commonJS({
57 "package-external:@wordpress/element"(exports, module) {
58 module.exports = window.wp.element;
59 }
60 });
61
62 // package-external:@wordpress/data
63 var require_data = __commonJS({
64 "package-external:@wordpress/data"(exports, module) {
65 module.exports = window.wp.data;
66 }
67 });
68
69 // package-external:@wordpress/preferences
70 var require_preferences = __commonJS({
71 "package-external:@wordpress/preferences"(exports, module) {
72 module.exports = window.wp.preferences;
73 }
74 });
75
76 // package-external:@wordpress/widgets
77 var require_widgets = __commonJS({
78 "package-external:@wordpress/widgets"(exports, module) {
79 module.exports = window.wp.widgets;
80 }
81 });
82
83 // package-external:@wordpress/editor
84 var require_editor = __commonJS({
85 "package-external:@wordpress/editor"(exports, module) {
86 module.exports = window.wp.editor;
87 }
88 });
89
90 // package-external:@wordpress/core-data
91 var require_core_data = __commonJS({
92 "package-external:@wordpress/core-data"(exports, module) {
93 module.exports = window.wp.coreData;
94 }
95 });
96
97 // package-external:@wordpress/api-fetch
98 var require_api_fetch = __commonJS({
99 "package-external:@wordpress/api-fetch"(exports, module) {
100 module.exports = window.wp.apiFetch;
101 }
102 });
103
104 // package-external:@wordpress/i18n
105 var require_i18n = __commonJS({
106 "package-external:@wordpress/i18n"(exports, module) {
107 module.exports = window.wp.i18n;
108 }
109 });
110
111 // vendor-external:react
112 var require_react = __commonJS({
113 "vendor-external:react"(exports, module) {
114 module.exports = window.React;
115 }
116 });
117
118 // vendor-external:react/jsx-runtime
119 var require_jsx_runtime = __commonJS({
120 "vendor-external:react/jsx-runtime"(exports, module) {
121 module.exports = window.ReactJSXRuntime;
122 }
123 });
124
125 // vendor-external:react-dom
126 var require_react_dom = __commonJS({
127 "vendor-external:react-dom"(exports, module) {
128 module.exports = window.ReactDOM;
129 }
130 });
131
132 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js
133 var require_use_sync_external_store_shim_development = __commonJS({
134 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports) {
135 "use strict";
136 (function() {
137 function is(x, y) {
138 return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
139 }
140 function useSyncExternalStore$2(subscribe, getSnapshot) {
141 didWarnOld18Alpha || void 0 === React47.startTransition || (didWarnOld18Alpha = true, console.error(
142 "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."
143 ));
144 var value = getSnapshot();
145 if (!didWarnUncachedGetSnapshot) {
146 var cachedValue = getSnapshot();
147 objectIs(value, cachedValue) || (console.error(
148 "The result of getSnapshot should be cached to avoid an infinite loop"
149 ), didWarnUncachedGetSnapshot = true);
150 }
151 cachedValue = useState16({
152 inst: { value, getSnapshot }
153 });
154 var inst = cachedValue[0].inst, forceUpdate = cachedValue[1];
155 useLayoutEffect3(
156 function() {
157 inst.value = value;
158 inst.getSnapshot = getSnapshot;
159 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
160 },
161 [subscribe, value, getSnapshot]
162 );
163 useEffect17(
164 function() {
165 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
166 return subscribe(function() {
167 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
168 });
169 },
170 [subscribe]
171 );
172 useDebugValue2(value);
173 return value;
174 }
175 function checkIfSnapshotChanged(inst) {
176 var latestGetSnapshot = inst.getSnapshot;
177 inst = inst.value;
178 try {
179 var nextValue = latestGetSnapshot();
180 return !objectIs(inst, nextValue);
181 } catch (error) {
182 return true;
183 }
184 }
185 function useSyncExternalStore$1(subscribe, getSnapshot) {
186 return getSnapshot();
187 }
188 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
189 var React47 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is, useState16 = React47.useState, useEffect17 = React47.useEffect, useLayoutEffect3 = React47.useLayoutEffect, useDebugValue2 = React47.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
190 exports.useSyncExternalStore = void 0 !== React47.useSyncExternalStore ? React47.useSyncExternalStore : shim;
191 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
192 })();
193 }
194 });
195
196 // node_modules/use-sync-external-store/shim/index.js
197 var require_shim = __commonJS({
198 "node_modules/use-sync-external-store/shim/index.js"(exports, module) {
199 "use strict";
200 if (false) {
201 module.exports = null;
202 } else {
203 module.exports = require_use_sync_external_store_shim_development();
204 }
205 }
206 });
207
208 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js
209 var require_with_selector_development = __commonJS({
210 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js"(exports) {
211 "use strict";
212 (function() {
213 function is(x, y) {
214 return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
215 }
216 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
217 var React47 = require_react(), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore2 = shim.useSyncExternalStore, useRef22 = React47.useRef, useEffect17 = React47.useEffect, useMemo16 = React47.useMemo, useDebugValue2 = React47.useDebugValue;
218 exports.useSyncExternalStoreWithSelector = function(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
219 var instRef = useRef22(null);
220 if (null === instRef.current) {
221 var inst = { hasValue: false, value: null };
222 instRef.current = inst;
223 } else inst = instRef.current;
224 instRef = useMemo16(
225 function() {
226 function memoizedSelector(nextSnapshot) {
227 if (!hasMemo) {
228 hasMemo = true;
229 memoizedSnapshot = nextSnapshot;
230 nextSnapshot = selector(nextSnapshot);
231 if (void 0 !== isEqual && inst.hasValue) {
232 var currentSelection = inst.value;
233 if (isEqual(currentSelection, nextSnapshot))
234 return memoizedSelection = currentSelection;
235 }
236 return memoizedSelection = nextSnapshot;
237 }
238 currentSelection = memoizedSelection;
239 if (objectIs(memoizedSnapshot, nextSnapshot))
240 return currentSelection;
241 var nextSelection = selector(nextSnapshot);
242 if (void 0 !== isEqual && isEqual(currentSelection, nextSelection))
243 return memoizedSnapshot = nextSnapshot, currentSelection;
244 memoizedSnapshot = nextSnapshot;
245 return memoizedSelection = nextSelection;
246 }
247 var hasMemo = false, memoizedSnapshot, memoizedSelection, maybeGetServerSnapshot = void 0 === getServerSnapshot ? null : getServerSnapshot;
248 return [
249 function() {
250 return memoizedSelector(getSnapshot());
251 },
252 null === maybeGetServerSnapshot ? void 0 : function() {
253 return memoizedSelector(maybeGetServerSnapshot());
254 }
255 ];
256 },
257 [getSnapshot, getServerSnapshot, selector, isEqual]
258 );
259 var value = useSyncExternalStore2(subscribe, instRef[0], instRef[1]);
260 useEffect17(
261 function() {
262 inst.hasValue = true;
263 inst.value = value;
264 },
265 [value]
266 );
267 useDebugValue2(value);
268 return value;
269 };
270 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
271 })();
272 }
273 });
274
275 // node_modules/use-sync-external-store/shim/with-selector.js
276 var require_with_selector = __commonJS({
277 "node_modules/use-sync-external-store/shim/with-selector.js"(exports, module) {
278 "use strict";
279 if (false) {
280 module.exports = null;
281 } else {
282 module.exports = require_with_selector_development();
283 }
284 }
285 });
286
287 // package-external:@wordpress/primitives
288 var require_primitives = __commonJS({
289 "package-external:@wordpress/primitives"(exports, module) {
290 module.exports = window.wp.primitives;
291 }
292 });
293
294 // package-external:@wordpress/compose
295 var require_compose = __commonJS({
296 "package-external:@wordpress/compose"(exports, module) {
297 module.exports = window.wp.compose;
298 }
299 });
300
301 // package-external:@wordpress/theme
302 var require_theme = __commonJS({
303 "package-external:@wordpress/theme"(exports, module) {
304 module.exports = window.wp.theme;
305 }
306 });
307
308 // package-external:@wordpress/private-apis
309 var require_private_apis = __commonJS({
310 "package-external:@wordpress/private-apis"(exports, module) {
311 module.exports = window.wp.privateApis;
312 }
313 });
314
315 // package-external:@wordpress/components
316 var require_components = __commonJS({
317 "package-external:@wordpress/components"(exports, module) {
318 module.exports = window.wp.components;
319 }
320 });
321
322 // package-external:@wordpress/block-editor
323 var require_block_editor = __commonJS({
324 "package-external:@wordpress/block-editor"(exports, module) {
325 module.exports = window.wp.blockEditor;
326 }
327 });
328
329 // package-external:@wordpress/style-engine
330 var require_style_engine = __commonJS({
331 "package-external:@wordpress/style-engine"(exports, module) {
332 module.exports = window.wp.styleEngine;
333 }
334 });
335
336 // package-external:@wordpress/plugins
337 var require_plugins = __commonJS({
338 "package-external:@wordpress/plugins"(exports, module) {
339 module.exports = window.wp.plugins;
340 }
341 });
342
343 // package-external:@wordpress/notices
344 var require_notices = __commonJS({
345 "package-external:@wordpress/notices"(exports, module) {
346 module.exports = window.wp.notices;
347 }
348 });
349
350 // package-external:@wordpress/commands
351 var require_commands = __commonJS({
352 "package-external:@wordpress/commands"(exports, module) {
353 module.exports = window.wp.commands;
354 }
355 });
356
357 // package-external:@wordpress/url
358 var require_url = __commonJS({
359 "package-external:@wordpress/url"(exports, module) {
360 module.exports = window.wp.url;
361 }
362 });
363
364 // package-external:@wordpress/html-entities
365 var require_html_entities = __commonJS({
366 "package-external:@wordpress/html-entities"(exports, module) {
367 module.exports = window.wp.htmlEntities;
368 }
369 });
370
371 // package-external:@wordpress/keyboard-shortcuts
372 var require_keyboard_shortcuts = __commonJS({
373 "package-external:@wordpress/keyboard-shortcuts"(exports, module) {
374 module.exports = window.wp.keyboardShortcuts;
375 }
376 });
377
378 // package-external:@wordpress/hooks
379 var require_hooks = __commonJS({
380 "package-external:@wordpress/hooks"(exports, module) {
381 module.exports = window.wp.hooks;
382 }
383 });
384
385 // package-external:@wordpress/keycodes
386 var require_keycodes = __commonJS({
387 "package-external:@wordpress/keycodes"(exports, module) {
388 module.exports = window.wp.keycodes;
389 }
390 });
391
392 // packages/edit-post/build-module/index.mjs
393 var index_exports = {};
394 __export(index_exports, {
395 PluginBlockSettingsMenuItem: () => PluginBlockSettingsMenuItem,
396 PluginDocumentSettingPanel: () => PluginDocumentSettingPanel,
397 PluginMoreMenuItem: () => PluginMoreMenuItem,
398 PluginPostPublishPanel: () => PluginPostPublishPanel,
399 PluginPostStatusInfo: () => PluginPostStatusInfo,
400 PluginPrePublishPanel: () => PluginPrePublishPanel,
401 PluginSidebar: () => PluginSidebar,
402 PluginSidebarMoreMenuItem: () => PluginSidebarMoreMenuItem,
403 __experimentalFullscreenModeClose: () => fullscreen_mode_close_default,
404 __experimentalMainDashboardButton: () => __experimentalMainDashboardButton,
405 __experimentalPluginPostExcerpt: () => __experimentalPluginPostExcerpt,
406 initializeEditor: () => initializeEditor,
407 reinitializeEditor: () => reinitializeEditor,
408 store: () => store
409 });
410 var import_blocks3 = __toESM(require_blocks(), 1);
411 var import_block_library2 = __toESM(require_block_library(), 1);
412 var import_deprecated4 = __toESM(require_deprecated(), 1);
413 var import_element29 = __toESM(require_element(), 1);
414 var import_data26 = __toESM(require_data(), 1);
415 var import_preferences11 = __toESM(require_preferences(), 1);
416 var import_widgets = __toESM(require_widgets(), 1);
417 var import_editor20 = __toESM(require_editor(), 1);
418 var import_core_data9 = __toESM(require_core_data(), 1);
419 var import_api_fetch2 = __toESM(require_api_fetch(), 1);
420
421 // node_modules/clsx/dist/clsx.mjs
422 function r(e) {
423 var t, f, n = "";
424 if ("string" == typeof e || "number" == typeof e) n += e;
425 else if ("object" == typeof e) if (Array.isArray(e)) {
426 var o = e.length;
427 for (t = 0; t < o; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
428 } else for (f in e) e[f] && (n && (n += " "), n += f);
429 return n;
430 }
431 function clsx() {
432 for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
433 return n;
434 }
435 var clsx_default = clsx;
436
437 // node_modules/@base-ui/utils/esm/safeReact.js
438 var React = __toESM(require_react(), 1);
439 var SafeReact = {
440 ...React
441 };
442
443 // node_modules/@base-ui/utils/esm/useRefWithInit.js
444 var React2 = __toESM(require_react(), 1);
445 var UNINITIALIZED = {};
446 function useRefWithInit(init, initArg) {
447 const ref = React2.useRef(UNINITIALIZED);
448 if (ref.current === UNINITIALIZED) {
449 ref.current = init(initArg);
450 }
451 return ref;
452 }
453
454 // node_modules/@base-ui/utils/esm/useStableCallback.js
455 var useInsertionEffect = SafeReact.useInsertionEffect;
456 var useSafeInsertionEffect = (
457 // React 17 doesn't have useInsertionEffect.
458 useInsertionEffect && // Preact replaces useInsertionEffect with useLayoutEffect and fires too late.
459 useInsertionEffect !== SafeReact.useLayoutEffect ? useInsertionEffect : (fn) => fn()
460 );
461 function useStableCallback(callback) {
462 const stable = useRefWithInit(createStableCallback).current;
463 stable.next = callback;
464 useSafeInsertionEffect(stable.effect);
465 return stable.trampoline;
466 }
467 function createStableCallback() {
468 const stable = {
469 next: void 0,
470 callback: assertNotCalled,
471 trampoline: (...args) => stable.callback?.(...args),
472 effect: () => {
473 stable.callback = stable.next;
474 }
475 };
476 return stable;
477 }
478 function assertNotCalled() {
479 if (true) {
480 throw (
481 /* minify-error-disabled */
482 new Error("Base UI: Cannot call an event handler while rendering.")
483 );
484 }
485 }
486
487 // node_modules/@base-ui/utils/esm/useIsoLayoutEffect.js
488 var React3 = __toESM(require_react(), 1);
489 var noop = () => {
490 };
491 var useIsoLayoutEffect = typeof document !== "undefined" ? React3.useLayoutEffect : noop;
492
493 // node_modules/@base-ui/utils/esm/warn.js
494 var set;
495 if (true) {
496 set = /* @__PURE__ */ new Set();
497 }
498 function warn(...messages) {
499 if (true) {
500 const messageKey = messages.join(" ");
501 if (!set.has(messageKey)) {
502 set.add(messageKey);
503 console.warn(`Base UI: ${messageKey}`);
504 }
505 }
506 }
507
508 // node_modules/@base-ui/react/esm/internals/direction-context/DirectionContext.js
509 var React4 = __toESM(require_react(), 1);
510 var DirectionContext = /* @__PURE__ */ React4.createContext(void 0);
511 if (true) DirectionContext.displayName = "DirectionContext";
512 function useDirection() {
513 const context = React4.useContext(DirectionContext);
514 return context?.direction ?? "ltr";
515 }
516
517 // node_modules/@base-ui/react/esm/internals/useRenderElement.js
518 var React7 = __toESM(require_react(), 1);
519
520 // node_modules/@base-ui/utils/esm/useMergedRefs.js
521 function useMergedRefs(a, b, c, d) {
522 const forkRef = useRefWithInit(createForkRef).current;
523 if (didChange(forkRef, a, b, c, d)) {
524 update(forkRef, [a, b, c, d]);
525 }
526 return forkRef.callback;
527 }
528 function useMergedRefsN(refs) {
529 const forkRef = useRefWithInit(createForkRef).current;
530 if (didChangeN(forkRef, refs)) {
531 update(forkRef, refs);
532 }
533 return forkRef.callback;
534 }
535 function createForkRef() {
536 return {
537 callback: null,
538 cleanup: null,
539 refs: []
540 };
541 }
542 function didChange(forkRef, a, b, c, d) {
543 return forkRef.refs[0] !== a || forkRef.refs[1] !== b || forkRef.refs[2] !== c || forkRef.refs[3] !== d;
544 }
545 function didChangeN(forkRef, newRefs) {
546 return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index2) => ref !== newRefs[index2]);
547 }
548 function update(forkRef, refs) {
549 forkRef.refs = refs;
550 if (refs.every((ref) => ref == null)) {
551 forkRef.callback = null;
552 return;
553 }
554 forkRef.callback = (instance) => {
555 if (forkRef.cleanup) {
556 forkRef.cleanup();
557 forkRef.cleanup = null;
558 }
559 if (instance != null) {
560 const cleanupCallbacks = Array(refs.length).fill(null);
561 for (let i = 0; i < refs.length; i += 1) {
562 const ref = refs[i];
563 if (ref == null) {
564 continue;
565 }
566 switch (typeof ref) {
567 case "function": {
568 const refCleanup = ref(instance);
569 if (typeof refCleanup === "function") {
570 cleanupCallbacks[i] = refCleanup;
571 }
572 break;
573 }
574 case "object": {
575 ref.current = instance;
576 break;
577 }
578 default:
579 }
580 }
581 forkRef.cleanup = () => {
582 for (let i = 0; i < refs.length; i += 1) {
583 const ref = refs[i];
584 if (ref == null) {
585 continue;
586 }
587 switch (typeof ref) {
588 case "function": {
589 const cleanupCallback = cleanupCallbacks[i];
590 if (typeof cleanupCallback === "function") {
591 cleanupCallback();
592 } else {
593 ref(null);
594 }
595 break;
596 }
597 case "object": {
598 ref.current = null;
599 break;
600 }
601 default:
602 }
603 }
604 };
605 }
606 };
607 }
608
609 // node_modules/@base-ui/utils/esm/getReactElementRef.js
610 var React6 = __toESM(require_react(), 1);
611
612 // node_modules/@base-ui/utils/esm/reactVersion.js
613 var React5 = __toESM(require_react(), 1);
614 var majorVersion = parseInt(React5.version, 10);
615 function isReactVersionAtLeast(reactVersionToCheck) {
616 return majorVersion >= reactVersionToCheck;
617 }
618
619 // node_modules/@base-ui/utils/esm/getReactElementRef.js
620 function getReactElementRef(element) {
621 if (!/* @__PURE__ */ React6.isValidElement(element)) {
622 return null;
623 }
624 const reactElement = element;
625 const propsWithRef = reactElement.props;
626 return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
627 }
628
629 // node_modules/@base-ui/utils/esm/mergeObjects.js
630 function mergeObjects(a, b) {
631 if (a && !b) {
632 return a;
633 }
634 if (!a && b) {
635 return b;
636 }
637 if (a || b) {
638 return {
639 ...a,
640 ...b
641 };
642 }
643 return void 0;
644 }
645
646 // node_modules/@base-ui/utils/esm/empty.js
647 function NOOP() {
648 }
649 var EMPTY_ARRAY = Object.freeze([]);
650 var EMPTY_OBJECT = Object.freeze({});
651
652 // node_modules/@base-ui/react/esm/internals/getStateAttributesProps.js
653 function getStateAttributesProps(state, customMapping) {
654 const props = {};
655 for (const key in state) {
656 const value = state[key];
657 if (customMapping?.hasOwnProperty(key)) {
658 const customProps = customMapping[key](value);
659 if (customProps != null) {
660 Object.assign(props, customProps);
661 }
662 continue;
663 }
664 if (value === true) {
665 props[`data-${key.toLowerCase()}`] = "";
666 } else if (value) {
667 props[`data-${key.toLowerCase()}`] = value.toString();
668 }
669 }
670 return props;
671 }
672
673 // node_modules/@base-ui/react/esm/utils/resolveClassName.js
674 function resolveClassName(className, state) {
675 return typeof className === "function" ? className(state) : className;
676 }
677
678 // node_modules/@base-ui/react/esm/utils/resolveStyle.js
679 function resolveStyle(style, state) {
680 return typeof style === "function" ? style(state) : style;
681 }
682
683 // node_modules/@base-ui/react/esm/merge-props/mergeProps.js
684 var EMPTY_PROPS = {};
685 function mergeProps(a, b, c, d, e) {
686 if (!c && !d && !e && !a) {
687 return createInitialMergedProps(b);
688 }
689 let merged = createInitialMergedProps(a);
690 if (b) {
691 merged = mergeInto(merged, b);
692 }
693 if (c) {
694 merged = mergeInto(merged, c);
695 }
696 if (d) {
697 merged = mergeInto(merged, d);
698 }
699 if (e) {
700 merged = mergeInto(merged, e);
701 }
702 return merged;
703 }
704 function mergePropsN(props) {
705 if (props.length === 0) {
706 return EMPTY_PROPS;
707 }
708 if (props.length === 1) {
709 return createInitialMergedProps(props[0]);
710 }
711 let merged = createInitialMergedProps(props[0]);
712 for (let i = 1; i < props.length; i += 1) {
713 merged = mergeInto(merged, props[i]);
714 }
715 return merged;
716 }
717 function createInitialMergedProps(inputProps) {
718 if (isPropsGetter(inputProps)) {
719 return {
720 ...resolvePropsGetter(inputProps, EMPTY_PROPS)
721 };
722 }
723 return copyInitialProps(inputProps);
724 }
725 function mergeInto(merged, inputProps) {
726 if (isPropsGetter(inputProps)) {
727 return resolvePropsGetter(inputProps, merged);
728 }
729 return mutablyMergeInto(merged, inputProps);
730 }
731 function copyInitialProps(inputProps) {
732 const copiedProps = {
733 ...inputProps
734 };
735 for (const propName in copiedProps) {
736 const propValue = copiedProps[propName];
737 if (isEventHandler(propName, propValue)) {
738 copiedProps[propName] = wrapEventHandler(propValue);
739 }
740 }
741 return copiedProps;
742 }
743 function mutablyMergeInto(mergedProps, externalProps) {
744 if (!externalProps) {
745 return mergedProps;
746 }
747 for (const propName in externalProps) {
748 const externalPropValue = externalProps[propName];
749 switch (propName) {
750 case "style": {
751 mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
752 break;
753 }
754 case "className": {
755 mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
756 break;
757 }
758 default: {
759 if (isEventHandler(propName, externalPropValue)) {
760 mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
761 } else {
762 mergedProps[propName] = externalPropValue;
763 }
764 }
765 }
766 }
767 return mergedProps;
768 }
769 function isEventHandler(key, value) {
770 const code0 = key.charCodeAt(0);
771 const code1 = key.charCodeAt(1);
772 const code2 = key.charCodeAt(2);
773 return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined");
774 }
775 function isPropsGetter(inputProps) {
776 return typeof inputProps === "function";
777 }
778 function resolvePropsGetter(inputProps, previousProps) {
779 if (isPropsGetter(inputProps)) {
780 return inputProps(previousProps);
781 }
782 return inputProps ?? EMPTY_PROPS;
783 }
784 function mergeEventHandlers(ourHandler, theirHandler) {
785 if (!theirHandler) {
786 return ourHandler;
787 }
788 if (!ourHandler) {
789 return wrapEventHandler(theirHandler);
790 }
791 return (...args) => {
792 const event = args[0];
793 if (isSyntheticEvent(event)) {
794 const baseUIEvent = event;
795 makeEventPreventable(baseUIEvent);
796 const result2 = theirHandler(...args);
797 if (!baseUIEvent.baseUIHandlerPrevented) {
798 ourHandler?.(...args);
799 }
800 return result2;
801 }
802 const result = theirHandler(...args);
803 ourHandler?.(...args);
804 return result;
805 };
806 }
807 function wrapEventHandler(handler) {
808 if (!handler) {
809 return handler;
810 }
811 return (...args) => {
812 const event = args[0];
813 if (isSyntheticEvent(event)) {
814 makeEventPreventable(event);
815 }
816 return handler(...args);
817 };
818 }
819 function makeEventPreventable(event) {
820 event.preventBaseUIHandler = () => {
821 event.baseUIHandlerPrevented = true;
822 };
823 return event;
824 }
825 function mergeClassNames(ourClassName, theirClassName) {
826 if (theirClassName) {
827 if (ourClassName) {
828 return theirClassName + " " + ourClassName;
829 }
830 return theirClassName;
831 }
832 return ourClassName;
833 }
834 function isSyntheticEvent(event) {
835 return event != null && typeof event === "object" && "nativeEvent" in event;
836 }
837
838 // node_modules/@base-ui/react/esm/internals/useRenderElement.js
839 var import_react = __toESM(require_react(), 1);
840 function useRenderElement(element, componentProps, params = {}) {
841 const renderProp = componentProps.render;
842 const outProps = useRenderElementProps(componentProps, params);
843 if (params.enabled === false) {
844 return null;
845 }
846 const state = params.state ?? EMPTY_OBJECT;
847 return evaluateRenderProp(element, renderProp, outProps, state);
848 }
849 function useRenderElementProps(componentProps, params = {}) {
850 const {
851 className: classNameProp,
852 style: styleProp,
853 render: renderProp
854 } = componentProps;
855 const {
856 state = EMPTY_OBJECT,
857 ref,
858 props,
859 stateAttributesMapping: stateAttributesMapping3,
860 enabled = true
861 } = params;
862 const className = enabled ? resolveClassName(classNameProp, state) : void 0;
863 const style = enabled ? resolveStyle(styleProp, state) : void 0;
864 const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping3) : EMPTY_OBJECT;
865 const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0;
866 const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT;
867 if (typeof document !== "undefined") {
868 if (!enabled) {
869 useMergedRefs(null, null);
870 } else if (Array.isArray(ref)) {
871 outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]);
872 } else {
873 outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
874 }
875 }
876 if (!enabled) {
877 return EMPTY_OBJECT;
878 }
879 if (className !== void 0) {
880 outProps.className = mergeClassNames(outProps.className, className);
881 }
882 if (style !== void 0) {
883 outProps.style = mergeObjects(outProps.style, style);
884 }
885 return outProps;
886 }
887 function resolveRenderFunctionProps(props) {
888 if (Array.isArray(props)) {
889 return mergePropsN(props);
890 }
891 return mergeProps(void 0, props);
892 }
893 var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
894 var COMPONENT_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9$]*$/;
895 var LOWERCASE_CHARACTER_PATTERN = /[a-z]/;
896 function evaluateRenderProp(element, render, props, state) {
897 if (render) {
898 if (typeof render === "function") {
899 if (true) {
900 warnIfRenderPropLooksLikeComponent(render);
901 }
902 return render(props, state);
903 }
904 const mergedProps = mergeProps(props, render.props);
905 mergedProps.ref = props.ref;
906 let newElement = render;
907 if (newElement?.$$typeof === REACT_LAZY_TYPE) {
908 const children = React7.Children.toArray(render);
909 newElement = children[0];
910 }
911 if (true) {
912 if (!/* @__PURE__ */ React7.isValidElement(newElement)) {
913 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"));
914 }
915 }
916 return /* @__PURE__ */ React7.cloneElement(newElement, mergedProps);
917 }
918 if (element) {
919 if (typeof element === "string") {
920 return renderTag(element, props);
921 }
922 }
923 throw new Error(true ? "Base UI: Render element or function are not defined." : formatErrorMessage_default(8));
924 }
925 function warnIfRenderPropLooksLikeComponent(renderFn) {
926 const functionName = renderFn.name;
927 if (functionName.length === 0) {
928 return;
929 }
930 if (!COMPONENT_IDENTIFIER_PATTERN.test(functionName)) {
931 return;
932 }
933 if (!LOWERCASE_CHARACTER_PATTERN.test(functionName)) {
934 return;
935 }
936 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");
937 }
938 function renderTag(Tag, props) {
939 if (Tag === "button") {
940 return /* @__PURE__ */ (0, import_react.createElement)("button", {
941 type: "button",
942 ...props,
943 key: props.key
944 });
945 }
946 if (Tag === "img") {
947 return /* @__PURE__ */ (0, import_react.createElement)("img", {
948 alt: "",
949 ...props,
950 key: props.key
951 });
952 }
953 return /* @__PURE__ */ React7.createElement(Tag, props);
954 }
955
956 // node_modules/@base-ui/react/esm/internals/reason-parts.js
957 var reason_parts_exports = {};
958 __export(reason_parts_exports, {
959 cancelOpen: () => cancelOpen,
960 chipRemovePress: () => chipRemovePress,
961 clearPress: () => clearPress,
962 closePress: () => closePress,
963 closeWatcher: () => closeWatcher,
964 decrementPress: () => decrementPress,
965 disabled: () => disabled,
966 drag: () => drag,
967 escapeKey: () => escapeKey,
968 focusOut: () => focusOut,
969 imperativeAction: () => imperativeAction,
970 incrementPress: () => incrementPress,
971 initial: () => initial,
972 inputBlur: () => inputBlur,
973 inputChange: () => inputChange,
974 inputClear: () => inputClear,
975 inputPaste: () => inputPaste,
976 inputPress: () => inputPress,
977 itemPress: () => itemPress,
978 keyboard: () => keyboard,
979 linkPress: () => linkPress,
980 listNavigation: () => listNavigation,
981 missing: () => missing,
982 none: () => none,
983 outsidePress: () => outsidePress,
984 pointer: () => pointer,
985 scrub: () => scrub,
986 siblingOpen: () => siblingOpen,
987 swipe: () => swipe,
988 trackPress: () => trackPress,
989 triggerFocus: () => triggerFocus,
990 triggerHover: () => triggerHover,
991 triggerPress: () => triggerPress,
992 wheel: () => wheel,
993 windowResize: () => windowResize
994 });
995 var none = "none";
996 var triggerPress = "trigger-press";
997 var triggerHover = "trigger-hover";
998 var triggerFocus = "trigger-focus";
999 var outsidePress = "outside-press";
1000 var itemPress = "item-press";
1001 var closePress = "close-press";
1002 var linkPress = "link-press";
1003 var clearPress = "clear-press";
1004 var chipRemovePress = "chip-remove-press";
1005 var trackPress = "track-press";
1006 var incrementPress = "increment-press";
1007 var decrementPress = "decrement-press";
1008 var inputChange = "input-change";
1009 var inputClear = "input-clear";
1010 var inputBlur = "input-blur";
1011 var inputPaste = "input-paste";
1012 var inputPress = "input-press";
1013 var focusOut = "focus-out";
1014 var escapeKey = "escape-key";
1015 var closeWatcher = "close-watcher";
1016 var listNavigation = "list-navigation";
1017 var keyboard = "keyboard";
1018 var pointer = "pointer";
1019 var drag = "drag";
1020 var wheel = "wheel";
1021 var scrub = "scrub";
1022 var cancelOpen = "cancel-open";
1023 var siblingOpen = "sibling-open";
1024 var disabled = "disabled";
1025 var missing = "missing";
1026 var initial = "initial";
1027 var imperativeAction = "imperative-action";
1028 var swipe = "swipe";
1029 var windowResize = "window-resize";
1030
1031 // node_modules/@base-ui/react/esm/internals/createBaseUIEventDetails.js
1032 function createChangeEventDetails(reason, event, trigger, customProperties) {
1033 let canceled = false;
1034 let allowPropagation = false;
1035 const custom = customProperties ?? EMPTY_OBJECT;
1036 const details = {
1037 reason,
1038 event: event ?? new Event("base-ui"),
1039 cancel() {
1040 canceled = true;
1041 },
1042 allowPropagation() {
1043 allowPropagation = true;
1044 },
1045 get isCanceled() {
1046 return canceled;
1047 },
1048 get isPropagationAllowed() {
1049 return allowPropagation;
1050 },
1051 trigger,
1052 ...custom
1053 };
1054 return details;
1055 }
1056
1057 // node_modules/@base-ui/utils/esm/useId.js
1058 var React8 = __toESM(require_react(), 1);
1059 var globalId = 0;
1060 function useGlobalId(idOverride, prefix = "mui") {
1061 const [defaultId, setDefaultId] = React8.useState(idOverride);
1062 const id = idOverride || defaultId;
1063 React8.useEffect(() => {
1064 if (defaultId == null) {
1065 globalId += 1;
1066 setDefaultId(`${prefix}-${globalId}`);
1067 }
1068 }, [defaultId, prefix]);
1069 return id;
1070 }
1071 var maybeReactUseId = SafeReact.useId;
1072 function useId(idOverride, prefix) {
1073 if (maybeReactUseId !== void 0) {
1074 const reactId = maybeReactUseId();
1075 return idOverride ?? (prefix ? `${prefix}-${reactId}` : reactId);
1076 }
1077 return useGlobalId(idOverride, prefix);
1078 }
1079
1080 // node_modules/@base-ui/react/esm/internals/useBaseUiId.js
1081 function useBaseUiId(idOverride) {
1082 return useId(idOverride, "base-ui");
1083 }
1084
1085 // node_modules/@base-ui/react/esm/internals/useTransitionStatus.js
1086 var React10 = __toESM(require_react(), 1);
1087
1088 // node_modules/@base-ui/utils/esm/useOnMount.js
1089 var React9 = __toESM(require_react(), 1);
1090 var EMPTY = [];
1091 function useOnMount(fn) {
1092 React9.useEffect(fn, EMPTY);
1093 }
1094
1095 // node_modules/@base-ui/utils/esm/useAnimationFrame.js
1096 var EMPTY2 = null;
1097 var LAST_RAF = globalThis.requestAnimationFrame;
1098 var Scheduler = class {
1099 /* This implementation uses an array as a backing data-structure for frame callbacks.
1100 * It allows `O(1)` callback cancelling by inserting a `null` in the array, though it
1101 * never calls the native `cancelAnimationFrame` if there are no frames left. This can
1102 * be much more efficient if there is a call pattern that alterns as
1103 * "request-cancel-request-cancel-…".
1104 * But in the case of "request-request-…-cancel-cancel-…", it leaves the final animation
1105 * frame to run anyway. We turn that frame into a `O(1)` no-op via `callbacksCount`. */
1106 callbacks = [];
1107 callbacksCount = 0;
1108 nextId = 1;
1109 startId = 1;
1110 isScheduled = false;
1111 tick = (timestamp) => {
1112 this.isScheduled = false;
1113 const currentCallbacks = this.callbacks;
1114 const currentCallbacksCount = this.callbacksCount;
1115 this.callbacks = [];
1116 this.callbacksCount = 0;
1117 this.startId = this.nextId;
1118 if (currentCallbacksCount > 0) {
1119 for (let i = 0; i < currentCallbacks.length; i += 1) {
1120 currentCallbacks[i]?.(timestamp);
1121 }
1122 }
1123 };
1124 request(fn) {
1125 const id = this.nextId;
1126 this.nextId += 1;
1127 this.callbacks.push(fn);
1128 this.callbacksCount += 1;
1129 const didRAFChange = LAST_RAF !== requestAnimationFrame && (LAST_RAF = requestAnimationFrame, true);
1130 if (!this.isScheduled || didRAFChange) {
1131 requestAnimationFrame(this.tick);
1132 this.isScheduled = true;
1133 }
1134 return id;
1135 }
1136 cancel(id) {
1137 const index2 = id - this.startId;
1138 if (index2 < 0 || index2 >= this.callbacks.length) {
1139 return;
1140 }
1141 this.callbacks[index2] = null;
1142 this.callbacksCount -= 1;
1143 }
1144 };
1145 var scheduler = new Scheduler();
1146 var AnimationFrame = class _AnimationFrame {
1147 static create() {
1148 return new _AnimationFrame();
1149 }
1150 static request(fn) {
1151 return scheduler.request(fn);
1152 }
1153 static cancel(id) {
1154 return scheduler.cancel(id);
1155 }
1156 currentId = EMPTY2;
1157 /**
1158 * Executes `fn` after `delay`, clearing any previously scheduled call.
1159 */
1160 request(fn) {
1161 this.cancel();
1162 this.currentId = scheduler.request(() => {
1163 this.currentId = EMPTY2;
1164 fn();
1165 });
1166 }
1167 cancel = () => {
1168 if (this.currentId !== EMPTY2) {
1169 scheduler.cancel(this.currentId);
1170 this.currentId = EMPTY2;
1171 }
1172 };
1173 disposeEffect = () => {
1174 return this.cancel;
1175 };
1176 };
1177 function useAnimationFrame() {
1178 const timeout = useRefWithInit(AnimationFrame.create).current;
1179 useOnMount(timeout.disposeEffect);
1180 return timeout;
1181 }
1182
1183 // node_modules/@base-ui/react/esm/internals/useTransitionStatus.js
1184 function useTransitionStatus(open, enableIdleState = false, deferEndingState = false) {
1185 const [transitionStatus, setTransitionStatus] = React10.useState(open && enableIdleState ? "idle" : void 0);
1186 const [mounted, setMounted] = React10.useState(open);
1187 if (open && !mounted) {
1188 setMounted(true);
1189 setTransitionStatus("starting");
1190 }
1191 if (!open && mounted && transitionStatus !== "ending" && !deferEndingState) {
1192 setTransitionStatus("ending");
1193 }
1194 if (!open && !mounted && transitionStatus === "ending") {
1195 setTransitionStatus(void 0);
1196 }
1197 useIsoLayoutEffect(() => {
1198 if (!open && mounted && transitionStatus !== "ending" && deferEndingState) {
1199 const frame = AnimationFrame.request(() => {
1200 setTransitionStatus("ending");
1201 });
1202 return () => {
1203 AnimationFrame.cancel(frame);
1204 };
1205 }
1206 return void 0;
1207 }, [open, mounted, transitionStatus, deferEndingState]);
1208 useIsoLayoutEffect(() => {
1209 if (!open || enableIdleState) {
1210 return void 0;
1211 }
1212 const frame = AnimationFrame.request(() => {
1213 setTransitionStatus(void 0);
1214 });
1215 return () => {
1216 AnimationFrame.cancel(frame);
1217 };
1218 }, [enableIdleState, open]);
1219 useIsoLayoutEffect(() => {
1220 if (!open || !enableIdleState) {
1221 return void 0;
1222 }
1223 if (open && mounted && transitionStatus !== "idle") {
1224 setTransitionStatus("starting");
1225 }
1226 const frame = AnimationFrame.request(() => {
1227 setTransitionStatus("idle");
1228 });
1229 return () => {
1230 AnimationFrame.cancel(frame);
1231 };
1232 }, [enableIdleState, open, mounted, transitionStatus]);
1233 return {
1234 mounted,
1235 setMounted,
1236 transitionStatus
1237 };
1238 }
1239
1240 // node_modules/@base-ui/react/esm/internals/stateAttributesMapping.js
1241 var TransitionStatusDataAttributes = /* @__PURE__ */ (function(TransitionStatusDataAttributes2) {
1242 TransitionStatusDataAttributes2["startingStyle"] = "data-starting-style";
1243 TransitionStatusDataAttributes2["endingStyle"] = "data-ending-style";
1244 return TransitionStatusDataAttributes2;
1245 })({});
1246 var STARTING_HOOK = {
1247 [TransitionStatusDataAttributes.startingStyle]: ""
1248 };
1249 var ENDING_HOOK = {
1250 [TransitionStatusDataAttributes.endingStyle]: ""
1251 };
1252 var transitionStatusMapping = {
1253 transitionStatus(value) {
1254 if (value === "starting") {
1255 return STARTING_HOOK;
1256 }
1257 if (value === "ending") {
1258 return ENDING_HOOK;
1259 }
1260 return null;
1261 }
1262 };
1263
1264 // node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
1265 function hasWindow() {
1266 return typeof window !== "undefined";
1267 }
1268 function getNodeName(node) {
1269 if (isNode(node)) {
1270 return (node.nodeName || "").toLowerCase();
1271 }
1272 return "#document";
1273 }
1274 function getWindow(node) {
1275 var _node$ownerDocument;
1276 return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
1277 }
1278 function getDocumentElement(node) {
1279 var _ref;
1280 return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
1281 }
1282 function isNode(value) {
1283 if (!hasWindow()) {
1284 return false;
1285 }
1286 return value instanceof Node || value instanceof getWindow(value).Node;
1287 }
1288 function isElement(value) {
1289 if (!hasWindow()) {
1290 return false;
1291 }
1292 return value instanceof Element || value instanceof getWindow(value).Element;
1293 }
1294 function isHTMLElement(value) {
1295 if (!hasWindow()) {
1296 return false;
1297 }
1298 return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
1299 }
1300 function isShadowRoot(value) {
1301 if (!hasWindow() || typeof ShadowRoot === "undefined") {
1302 return false;
1303 }
1304 return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
1305 }
1306 function isOverflowElement(element) {
1307 const {
1308 overflow,
1309 overflowX,
1310 overflowY,
1311 display
1312 } = getComputedStyle2(element);
1313 return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== "inline" && display !== "contents";
1314 }
1315 function isTableElement(element) {
1316 return /^(table|td|th)$/.test(getNodeName(element));
1317 }
1318 function isTopLayer(element) {
1319 try {
1320 if (element.matches(":popover-open")) {
1321 return true;
1322 }
1323 } catch (_e) {
1324 }
1325 try {
1326 return element.matches(":modal");
1327 } catch (_e) {
1328 return false;
1329 }
1330 }
1331 var willChangeRe = /transform|translate|scale|rotate|perspective|filter/;
1332 var containRe = /paint|layout|strict|content/;
1333 var isNotNone = (value) => !!value && value !== "none";
1334 var isWebKitValue;
1335 function isContainingBlock(elementOrCss) {
1336 const css = isElement(elementOrCss) ? getComputedStyle2(elementOrCss) : elementOrCss;
1337 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 || "");
1338 }
1339 function getContainingBlock(element) {
1340 let currentNode = getParentNode(element);
1341 while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
1342 if (isContainingBlock(currentNode)) {
1343 return currentNode;
1344 } else if (isTopLayer(currentNode)) {
1345 return null;
1346 }
1347 currentNode = getParentNode(currentNode);
1348 }
1349 return null;
1350 }
1351 function isWebKit() {
1352 if (isWebKitValue == null) {
1353 isWebKitValue = typeof CSS !== "undefined" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none");
1354 }
1355 return isWebKitValue;
1356 }
1357 function isLastTraversableNode(node) {
1358 return /^(html|body|#document)$/.test(getNodeName(node));
1359 }
1360 function getComputedStyle2(element) {
1361 return getWindow(element).getComputedStyle(element);
1362 }
1363 function getNodeScroll(element) {
1364 if (isElement(element)) {
1365 return {
1366 scrollLeft: element.scrollLeft,
1367 scrollTop: element.scrollTop
1368 };
1369 }
1370 return {
1371 scrollLeft: element.scrollX,
1372 scrollTop: element.scrollY
1373 };
1374 }
1375 function getParentNode(node) {
1376 if (getNodeName(node) === "html") {
1377 return node;
1378 }
1379 const result = (
1380 // Step into the shadow DOM of the parent of a slotted node.
1381 node.assignedSlot || // DOM Element detected.
1382 node.parentNode || // ShadowRoot detected.
1383 isShadowRoot(node) && node.host || // Fallback.
1384 getDocumentElement(node)
1385 );
1386 return isShadowRoot(result) ? result.host : result;
1387 }
1388 function getNearestOverflowAncestor(node) {
1389 const parentNode = getParentNode(node);
1390 if (isLastTraversableNode(parentNode)) {
1391 return node.ownerDocument ? node.ownerDocument.body : node.body;
1392 }
1393 if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
1394 return parentNode;
1395 }
1396 return getNearestOverflowAncestor(parentNode);
1397 }
1398 function getOverflowAncestors(node, list, traverseIframes) {
1399 var _node$ownerDocument2;
1400 if (list === void 0) {
1401 list = [];
1402 }
1403 if (traverseIframes === void 0) {
1404 traverseIframes = true;
1405 }
1406 const scrollableAncestor = getNearestOverflowAncestor(node);
1407 const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
1408 const win = getWindow(scrollableAncestor);
1409 if (isBody) {
1410 const frameElement = getFrameElement(win);
1411 return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
1412 } else {
1413 return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
1414 }
1415 }
1416 function getFrameElement(win) {
1417 return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
1418 }
1419
1420 // node_modules/@base-ui/utils/esm/detectBrowser.js
1421 var hasNavigator = typeof navigator !== "undefined";
1422 var nav = getNavigatorData();
1423 var platform = getPlatform();
1424 var userAgent = getUserAgent();
1425 var isWebKit2 = typeof CSS === "undefined" || !CSS.supports ? false : CSS.supports("-webkit-backdrop-filter:none");
1426 var isIOS = (
1427 // iPads can claim to be MacIntel
1428 nav.platform === "MacIntel" && nav.maxTouchPoints > 1 ? true : /iP(hone|ad|od)|iOS/.test(nav.platform)
1429 );
1430 var isFirefox = hasNavigator && /firefox/i.test(userAgent);
1431 var isSafari = hasNavigator && /apple/i.test(navigator.vendor);
1432 var isEdge = hasNavigator && /Edg/i.test(userAgent);
1433 var isAndroid = hasNavigator && /android/i.test(platform) || /android/i.test(userAgent);
1434 var isMac = hasNavigator && platform.toLowerCase().startsWith("mac") && !navigator.maxTouchPoints;
1435 var isJSDOM = userAgent.includes("jsdom/");
1436 function getNavigatorData() {
1437 if (!hasNavigator) {
1438 return {
1439 platform: "",
1440 maxTouchPoints: -1
1441 };
1442 }
1443 const uaData = navigator.userAgentData;
1444 if (uaData?.platform) {
1445 return {
1446 platform: uaData.platform,
1447 maxTouchPoints: navigator.maxTouchPoints
1448 };
1449 }
1450 return {
1451 platform: navigator.platform ?? "",
1452 maxTouchPoints: navigator.maxTouchPoints ?? -1
1453 };
1454 }
1455 function getUserAgent() {
1456 if (!hasNavigator) {
1457 return "";
1458 }
1459 const uaData = navigator.userAgentData;
1460 if (uaData && Array.isArray(uaData.brands)) {
1461 return uaData.brands.map(({
1462 brand,
1463 version: version2
1464 }) => `${brand}/${version2}`).join(" ");
1465 }
1466 return navigator.userAgent;
1467 }
1468 function getPlatform() {
1469 if (!hasNavigator) {
1470 return "";
1471 }
1472 const uaData = navigator.userAgentData;
1473 if (uaData?.platform) {
1474 return uaData.platform;
1475 }
1476 return navigator.platform ?? "";
1477 }
1478
1479 // node_modules/@base-ui/react/esm/floating-ui-react/utils/constants.js
1480 var FOCUSABLE_ATTRIBUTE = "data-base-ui-focusable";
1481 var TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
1482
1483 // node_modules/@base-ui/react/esm/internals/shadowDom.js
1484 function activeElement(doc) {
1485 let element = doc.activeElement;
1486 while (element?.shadowRoot?.activeElement != null) {
1487 element = element.shadowRoot.activeElement;
1488 }
1489 return element;
1490 }
1491 function contains(parent, child) {
1492 if (!parent || !child) {
1493 return false;
1494 }
1495 const rootNode = child.getRootNode?.();
1496 if (parent.contains(child)) {
1497 return true;
1498 }
1499 if (rootNode && isShadowRoot(rootNode)) {
1500 let next = child;
1501 while (next) {
1502 if (parent === next) {
1503 return true;
1504 }
1505 next = next.parentNode || next.host;
1506 }
1507 }
1508 return false;
1509 }
1510 function getTarget(event) {
1511 if ("composedPath" in event) {
1512 return event.composedPath()[0];
1513 }
1514 return event.target;
1515 }
1516
1517 // node_modules/@base-ui/react/esm/floating-ui-react/utils/element.js
1518 function isTargetInsideEnabledTrigger(target, triggerElements) {
1519 if (!isElement(target)) {
1520 return false;
1521 }
1522 const targetElement = target;
1523 if (triggerElements.hasElement(targetElement)) {
1524 return !targetElement.hasAttribute("data-trigger-disabled");
1525 }
1526 for (const [, trigger] of triggerElements.entries()) {
1527 if (contains(trigger, targetElement)) {
1528 return !trigger.hasAttribute("data-trigger-disabled");
1529 }
1530 }
1531 return false;
1532 }
1533 function isEventTargetWithin(event, node) {
1534 if (node == null) {
1535 return false;
1536 }
1537 if ("composedPath" in event) {
1538 return event.composedPath().includes(node);
1539 }
1540 const eventAgain = event;
1541 return eventAgain.target != null && node.contains(eventAgain.target);
1542 }
1543 function isRootElement(element) {
1544 return element.matches("html,body");
1545 }
1546 function isTypeableElement(element) {
1547 return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR);
1548 }
1549 function isInteractiveElement(element) {
1550 return element?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${TYPEABLE_SELECTOR}`) != null;
1551 }
1552 function matchesFocusVisible(element) {
1553 if (!element || isJSDOM) {
1554 return true;
1555 }
1556 try {
1557 return element.matches(":focus-visible");
1558 } catch (_e) {
1559 return true;
1560 }
1561 }
1562
1563 // node_modules/@base-ui/react/esm/floating-ui-react/utils/nodes.js
1564 function getNodeChildren(nodes, id, onlyOpenChildren = true) {
1565 const directChildren = nodes.filter((node) => node.parentId === id);
1566 return directChildren.flatMap((child) => [...!onlyOpenChildren || child.context?.open ? [child] : [], ...getNodeChildren(nodes, child.id, onlyOpenChildren)]);
1567 }
1568
1569 // node_modules/@base-ui/react/esm/floating-ui-react/utils/event.js
1570 function isReactEvent(event) {
1571 return "nativeEvent" in event;
1572 }
1573 function isMouseLikePointerType(pointerType, strict) {
1574 const values = ["mouse", "pen"];
1575 if (!strict) {
1576 values.push("", void 0);
1577 }
1578 return values.includes(pointerType);
1579 }
1580 function isClickLikeEvent(event) {
1581 const type = event.type;
1582 return type === "click" || type === "mousedown" || type === "keydown" || type === "keyup";
1583 }
1584
1585 // node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
1586 var sides = ["top", "right", "bottom", "left"];
1587 var min = Math.min;
1588 var max = Math.max;
1589 var round = Math.round;
1590 var floor = Math.floor;
1591 var createCoords = (v) => ({
1592 x: v,
1593 y: v
1594 });
1595 var oppositeSideMap = {
1596 left: "right",
1597 right: "left",
1598 bottom: "top",
1599 top: "bottom"
1600 };
1601 function clamp(start, value, end) {
1602 return max(start, min(value, end));
1603 }
1604 function evaluate(value, param) {
1605 return typeof value === "function" ? value(param) : value;
1606 }
1607 function getSide(placement) {
1608 return placement.split("-")[0];
1609 }
1610 function getAlignment(placement) {
1611 return placement.split("-")[1];
1612 }
1613 function getOppositeAxis(axis) {
1614 return axis === "x" ? "y" : "x";
1615 }
1616 function getAxisLength(axis) {
1617 return axis === "y" ? "height" : "width";
1618 }
1619 function getSideAxis(placement) {
1620 const firstChar = placement[0];
1621 return firstChar === "t" || firstChar === "b" ? "y" : "x";
1622 }
1623 function getAlignmentAxis(placement) {
1624 return getOppositeAxis(getSideAxis(placement));
1625 }
1626 function getAlignmentSides(placement, rects, rtl) {
1627 if (rtl === void 0) {
1628 rtl = false;
1629 }
1630 const alignment = getAlignment(placement);
1631 const alignmentAxis = getAlignmentAxis(placement);
1632 const length = getAxisLength(alignmentAxis);
1633 let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
1634 if (rects.reference[length] > rects.floating[length]) {
1635 mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
1636 }
1637 return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
1638 }
1639 function getExpandedPlacements(placement) {
1640 const oppositePlacement = getOppositePlacement(placement);
1641 return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
1642 }
1643 function getOppositeAlignmentPlacement(placement) {
1644 return placement.includes("start") ? placement.replace("start", "end") : placement.replace("end", "start");
1645 }
1646 var lrPlacement = ["left", "right"];
1647 var rlPlacement = ["right", "left"];
1648 var tbPlacement = ["top", "bottom"];
1649 var btPlacement = ["bottom", "top"];
1650 function getSideList(side, isStart, rtl) {
1651 switch (side) {
1652 case "top":
1653 case "bottom":
1654 if (rtl) return isStart ? rlPlacement : lrPlacement;
1655 return isStart ? lrPlacement : rlPlacement;
1656 case "left":
1657 case "right":
1658 return isStart ? tbPlacement : btPlacement;
1659 default:
1660 return [];
1661 }
1662 }
1663 function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
1664 const alignment = getAlignment(placement);
1665 let list = getSideList(getSide(placement), direction === "start", rtl);
1666 if (alignment) {
1667 list = list.map((side) => side + "-" + alignment);
1668 if (flipAlignment) {
1669 list = list.concat(list.map(getOppositeAlignmentPlacement));
1670 }
1671 }
1672 return list;
1673 }
1674 function getOppositePlacement(placement) {
1675 const side = getSide(placement);
1676 return oppositeSideMap[side] + placement.slice(side.length);
1677 }
1678 function expandPaddingObject(padding) {
1679 return {
1680 top: 0,
1681 right: 0,
1682 bottom: 0,
1683 left: 0,
1684 ...padding
1685 };
1686 }
1687 function getPaddingObject(padding) {
1688 return typeof padding !== "number" ? expandPaddingObject(padding) : {
1689 top: padding,
1690 right: padding,
1691 bottom: padding,
1692 left: padding
1693 };
1694 }
1695 function rectToClientRect(rect) {
1696 const {
1697 x,
1698 y,
1699 width,
1700 height
1701 } = rect;
1702 return {
1703 width,
1704 height,
1705 top: y,
1706 left: x,
1707 right: x + width,
1708 bottom: y + height,
1709 x,
1710 y
1711 };
1712 }
1713
1714 // node_modules/@base-ui/react/esm/floating-ui-react/utils/composite.js
1715 function isHiddenByStyles(styles) {
1716 return styles.visibility === "hidden" || styles.visibility === "collapse";
1717 }
1718 function isElementVisible(element, styles = element ? getComputedStyle2(element) : null) {
1719 if (!element || !element.isConnected || !styles || isHiddenByStyles(styles)) {
1720 return false;
1721 }
1722 if (typeof element.checkVisibility === "function") {
1723 return element.checkVisibility();
1724 }
1725 return styles.display !== "none" && styles.display !== "contents";
1726 }
1727
1728 // node_modules/@base-ui/utils/esm/owner.js
1729 function ownerDocument(node) {
1730 return node?.ownerDocument || document;
1731 }
1732
1733 // node_modules/@base-ui/react/esm/floating-ui-react/utils/tabbable.js
1734 var CANDIDATE_SELECTOR = 'a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';
1735 function getParentElement(element) {
1736 const assignedSlot = element.assignedSlot;
1737 if (assignedSlot) {
1738 return assignedSlot;
1739 }
1740 if (element.parentElement) {
1741 return element.parentElement;
1742 }
1743 const rootNode = element.getRootNode();
1744 return isShadowRoot(rootNode) ? rootNode.host : null;
1745 }
1746 function getDetailsSummary(details) {
1747 for (const child of Array.from(details.children)) {
1748 if (getNodeName(child) === "summary") {
1749 return child;
1750 }
1751 }
1752 return null;
1753 }
1754 function isWithinOpenDetailsSummary(element, details) {
1755 const summary = getDetailsSummary(details);
1756 return !!summary && (element === summary || contains(summary, element));
1757 }
1758 function isFocusableCandidate(element) {
1759 const nodeName = element ? getNodeName(element) : "";
1760 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");
1761 }
1762 function isFocusableElement(element) {
1763 if (!isFocusableCandidate(element) || !element.isConnected || element.matches(":disabled")) {
1764 return false;
1765 }
1766 for (let current = element; current; current = getParentElement(current)) {
1767 const isAncestor = current !== element;
1768 const isSlot = getNodeName(current) === "slot";
1769 if (current.hasAttribute("inert")) {
1770 return false;
1771 }
1772 if (isAncestor && getNodeName(current) === "details" && !current.open && !isWithinOpenDetailsSummary(element, current) || current.hasAttribute("hidden") || !isSlot && !isVisibleInTabbableTree(current, isAncestor)) {
1773 return false;
1774 }
1775 }
1776 return true;
1777 }
1778 function isVisibleInTabbableTree(element, isAncestor) {
1779 const styles = getComputedStyle2(element);
1780 if (!isAncestor) {
1781 return isElementVisible(element, styles);
1782 }
1783 return styles.display !== "none";
1784 }
1785 function getTabIndex(element) {
1786 const tabIndex = element.tabIndex;
1787 if (tabIndex < 0) {
1788 const nodeName = getNodeName(element);
1789 if (nodeName === "details" || nodeName === "audio" || nodeName === "video" || isHTMLElement(element) && element.isContentEditable) {
1790 return 0;
1791 }
1792 }
1793 return tabIndex;
1794 }
1795 function getNamedRadioInput(element) {
1796 if (getNodeName(element) !== "input") {
1797 return null;
1798 }
1799 const input = element;
1800 return input.type === "radio" && input.name !== "" ? input : null;
1801 }
1802 function isTabbableRadio(element, candidates) {
1803 const input = getNamedRadioInput(element);
1804 if (!input) {
1805 return true;
1806 }
1807 const checkedRadio = candidates.find((candidate) => {
1808 const radio = getNamedRadioInput(candidate);
1809 return radio?.name === input.name && radio.form === input.form && radio.checked;
1810 });
1811 if (checkedRadio) {
1812 return checkedRadio === input;
1813 }
1814 return candidates.find((candidate) => {
1815 const radio = getNamedRadioInput(candidate);
1816 return radio?.name === input.name && radio.form === input.form;
1817 }) === input;
1818 }
1819 function getComposedChildren(container) {
1820 if (isHTMLElement(container) && getNodeName(container) === "slot") {
1821 const assignedElements = container.assignedElements({
1822 flatten: true
1823 });
1824 if (assignedElements.length > 0) {
1825 return assignedElements;
1826 }
1827 }
1828 if (isHTMLElement(container) && container.shadowRoot) {
1829 return Array.from(container.shadowRoot.children);
1830 }
1831 return Array.from(container.children);
1832 }
1833 function appendCandidates(container, list) {
1834 getComposedChildren(container).forEach((child) => {
1835 if (isFocusableCandidate(child)) {
1836 list.push(child);
1837 }
1838 appendCandidates(child, list);
1839 });
1840 }
1841 function appendMatchingElements(container, selector, list) {
1842 getComposedChildren(container).forEach((child) => {
1843 if (isHTMLElement(child) && child.matches(selector)) {
1844 list.push(child);
1845 }
1846 appendMatchingElements(child, selector, list);
1847 });
1848 }
1849 function focusable(container) {
1850 const candidates = [];
1851 appendCandidates(container, candidates);
1852 return candidates.filter(isFocusableElement);
1853 }
1854 function tabbable(container) {
1855 const candidates = focusable(container);
1856 return candidates.filter((element) => getTabIndex(element) >= 0 && isTabbableRadio(element, candidates));
1857 }
1858 function getTabbableIn(container, dir) {
1859 const list = tabbable(container);
1860 const len = list.length;
1861 if (len === 0) {
1862 return void 0;
1863 }
1864 const active = activeElement(ownerDocument(container));
1865 const index2 = list.indexOf(active);
1866 const nextIndex = index2 === -1 ? dir === 1 ? 0 : len - 1 : index2 + dir;
1867 return list[nextIndex];
1868 }
1869 function getNextTabbable(referenceElement) {
1870 return getTabbableIn(ownerDocument(referenceElement).body, 1) || referenceElement;
1871 }
1872 function getPreviousTabbable(referenceElement) {
1873 return getTabbableIn(ownerDocument(referenceElement).body, -1) || referenceElement;
1874 }
1875 function isOutsideEvent(event, container) {
1876 const containerElement = container || event.currentTarget;
1877 const relatedTarget = event.relatedTarget;
1878 return !relatedTarget || !contains(containerElement, relatedTarget);
1879 }
1880 function disableFocusInside(container) {
1881 const tabbableElements = tabbable(container);
1882 tabbableElements.forEach((element) => {
1883 element.dataset.tabindex = element.getAttribute("tabindex") || "";
1884 element.setAttribute("tabindex", "-1");
1885 });
1886 }
1887 function enableFocusInside(container) {
1888 const elements = [];
1889 appendMatchingElements(container, "[data-tabindex]", elements);
1890 elements.forEach((element) => {
1891 const tabindex = element.dataset.tabindex;
1892 delete element.dataset.tabindex;
1893 if (tabindex) {
1894 element.setAttribute("tabindex", tabindex);
1895 } else {
1896 element.removeAttribute("tabindex");
1897 }
1898 });
1899 }
1900
1901 // node_modules/@base-ui/utils/esm/addEventListener.js
1902 function addEventListener(target, type, listener, options) {
1903 target.addEventListener(type, listener, options);
1904 return () => {
1905 target.removeEventListener(type, listener, options);
1906 };
1907 }
1908
1909 // node_modules/@base-ui/utils/esm/useValueAsRef.js
1910 function useValueAsRef(value) {
1911 const latest = useRefWithInit(createLatestRef, value).current;
1912 latest.next = value;
1913 useIsoLayoutEffect(latest.effect);
1914 return latest;
1915 }
1916 function createLatestRef(value) {
1917 const latest = {
1918 current: value,
1919 next: value,
1920 effect: () => {
1921 latest.current = latest.next;
1922 }
1923 };
1924 return latest;
1925 }
1926
1927 // node_modules/@base-ui/react/esm/internals/useOpenChangeComplete.js
1928 var React11 = __toESM(require_react(), 1);
1929
1930 // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js
1931 var ReactDOM = __toESM(require_react_dom(), 1);
1932
1933 // node_modules/@base-ui/react/esm/utils/resolveRef.js
1934 function resolveRef(maybeRef) {
1935 if (maybeRef == null) {
1936 return maybeRef;
1937 }
1938 return "current" in maybeRef ? maybeRef.current : maybeRef;
1939 }
1940
1941 // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js
1942 function useAnimationsFinished(elementOrRef, waitForStartingStyleRemoved = false, treatAbortedAsFinished = true) {
1943 const frame = useAnimationFrame();
1944 return useStableCallback((fnToExecute, signal = null) => {
1945 frame.cancel();
1946 const element = resolveRef(elementOrRef);
1947 if (element == null) {
1948 return;
1949 }
1950 const resolvedElement = element;
1951 const done = () => {
1952 ReactDOM.flushSync(fnToExecute);
1953 };
1954 if (typeof resolvedElement.getAnimations !== "function" || globalThis.BASE_UI_ANIMATIONS_DISABLED) {
1955 fnToExecute();
1956 return;
1957 }
1958 function exec() {
1959 Promise.all(resolvedElement.getAnimations().map((animation) => animation.finished)).then(() => {
1960 if (!signal?.aborted) {
1961 done();
1962 }
1963 }).catch(() => {
1964 if (treatAbortedAsFinished) {
1965 if (!signal?.aborted) {
1966 done();
1967 }
1968 return;
1969 }
1970 const currentAnimations = resolvedElement.getAnimations();
1971 if (!signal?.aborted && currentAnimations.length > 0 && currentAnimations.some((animation) => animation.pending || animation.playState !== "finished")) {
1972 exec();
1973 }
1974 });
1975 }
1976 if (waitForStartingStyleRemoved) {
1977 const startingStyleAttribute = TransitionStatusDataAttributes.startingStyle;
1978 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
1979 frame.request(exec);
1980 return;
1981 }
1982 const attributeObserver = new MutationObserver(() => {
1983 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
1984 attributeObserver.disconnect();
1985 exec();
1986 }
1987 });
1988 attributeObserver.observe(resolvedElement, {
1989 attributes: true,
1990 attributeFilter: [startingStyleAttribute]
1991 });
1992 signal?.addEventListener("abort", () => attributeObserver.disconnect(), {
1993 once: true
1994 });
1995 return;
1996 }
1997 frame.request(exec);
1998 });
1999 }
2000
2001 // node_modules/@base-ui/react/esm/internals/useOpenChangeComplete.js
2002 function useOpenChangeComplete(parameters) {
2003 const {
2004 enabled = true,
2005 open,
2006 ref,
2007 onComplete: onCompleteParam
2008 } = parameters;
2009 const onComplete = useStableCallback(onCompleteParam);
2010 const runOnceAnimationsFinish = useAnimationsFinished(ref, open, false);
2011 React11.useEffect(() => {
2012 if (!enabled) {
2013 return void 0;
2014 }
2015 const abortController = new AbortController();
2016 runOnceAnimationsFinish(onComplete, abortController.signal);
2017 return () => {
2018 abortController.abort();
2019 };
2020 }, [enabled, open, onComplete, runOnceAnimationsFinish]);
2021 }
2022
2023 // node_modules/@base-ui/utils/esm/useOnFirstRender.js
2024 var React12 = __toESM(require_react(), 1);
2025 function useOnFirstRender(fn) {
2026 const ref = React12.useRef(true);
2027 if (ref.current) {
2028 ref.current = false;
2029 fn();
2030 }
2031 }
2032
2033 // node_modules/@base-ui/utils/esm/useTimeout.js
2034 var EMPTY3 = 0;
2035 var Timeout = class _Timeout {
2036 static create() {
2037 return new _Timeout();
2038 }
2039 currentId = EMPTY3;
2040 /**
2041 * Executes `fn` after `delay`, clearing any previously scheduled call.
2042 */
2043 start(delay, fn) {
2044 this.clear();
2045 this.currentId = setTimeout(() => {
2046 this.currentId = EMPTY3;
2047 fn();
2048 }, delay);
2049 }
2050 isStarted() {
2051 return this.currentId !== EMPTY3;
2052 }
2053 clear = () => {
2054 if (this.currentId !== EMPTY3) {
2055 clearTimeout(this.currentId);
2056 this.currentId = EMPTY3;
2057 }
2058 };
2059 disposeEffect = () => {
2060 return this.clear;
2061 };
2062 };
2063 function useTimeout() {
2064 const timeout = useRefWithInit(Timeout.create).current;
2065 useOnMount(timeout.disposeEffect);
2066 return timeout;
2067 }
2068
2069 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingDelayGroup.js
2070 var React13 = __toESM(require_react(), 1);
2071
2072 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverShared.js
2073 function resolveValue(value, pointerType) {
2074 if (pointerType != null && !isMouseLikePointerType(pointerType)) {
2075 return 0;
2076 }
2077 if (typeof value === "function") {
2078 return value();
2079 }
2080 return value;
2081 }
2082 function getDelay(value, prop, pointerType) {
2083 const result = resolveValue(value, pointerType);
2084 if (typeof result === "number") {
2085 return result;
2086 }
2087 return result?.[prop];
2088 }
2089 function getRestMs(value) {
2090 if (typeof value === "function") {
2091 return value();
2092 }
2093 return value;
2094 }
2095 function isClickLikeOpenEvent(openEventType, interactedInside) {
2096 return interactedInside || openEventType === "click" || openEventType === "mousedown";
2097 }
2098 function isHoverOpenEvent(openEventType) {
2099 return openEventType?.includes("mouse") && openEventType !== "mousedown";
2100 }
2101
2102 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingDelayGroup.js
2103 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
2104 var FloatingDelayGroupContext = /* @__PURE__ */ React13.createContext({
2105 hasProvider: false,
2106 timeoutMs: 0,
2107 delayRef: {
2108 current: 0
2109 },
2110 initialDelayRef: {
2111 current: 0
2112 },
2113 timeout: new Timeout(),
2114 currentIdRef: {
2115 current: null
2116 },
2117 currentContextRef: {
2118 current: null
2119 }
2120 });
2121 if (true) FloatingDelayGroupContext.displayName = "FloatingDelayGroupContext";
2122 function FloatingDelayGroup(props) {
2123 const {
2124 children,
2125 delay,
2126 timeoutMs = 0
2127 } = props;
2128 const delayRef = React13.useRef(delay);
2129 const initialDelayRef = React13.useRef(delay);
2130 const currentIdRef = React13.useRef(null);
2131 const currentContextRef = React13.useRef(null);
2132 const timeout = useTimeout();
2133 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FloatingDelayGroupContext.Provider, {
2134 value: React13.useMemo(() => ({
2135 hasProvider: true,
2136 delayRef,
2137 initialDelayRef,
2138 currentIdRef,
2139 timeoutMs,
2140 currentContextRef,
2141 timeout
2142 }), [timeoutMs, timeout]),
2143 children
2144 });
2145 }
2146 function useDelayGroup(context, options = {
2147 open: false
2148 }) {
2149 const {
2150 open
2151 } = options;
2152 const store2 = "rootStore" in context ? context.rootStore : context;
2153 const floatingId = store2.useState("floatingId");
2154 const groupContext = React13.useContext(FloatingDelayGroupContext);
2155 const {
2156 currentIdRef,
2157 delayRef,
2158 timeoutMs,
2159 initialDelayRef,
2160 currentContextRef,
2161 hasProvider,
2162 timeout
2163 } = groupContext;
2164 const [isInstantPhase, setIsInstantPhase] = React13.useState(false);
2165 useIsoLayoutEffect(() => {
2166 function unset() {
2167 setIsInstantPhase(false);
2168 currentContextRef.current?.setIsInstantPhase(false);
2169 currentIdRef.current = null;
2170 currentContextRef.current = null;
2171 delayRef.current = initialDelayRef.current;
2172 }
2173 if (!currentIdRef.current) {
2174 return void 0;
2175 }
2176 if (!open && currentIdRef.current === floatingId) {
2177 setIsInstantPhase(false);
2178 if (timeoutMs) {
2179 const closingId = floatingId;
2180 timeout.start(timeoutMs, () => {
2181 if (store2.select("open") || currentIdRef.current && currentIdRef.current !== closingId) {
2182 return;
2183 }
2184 unset();
2185 });
2186 return () => {
2187 timeout.clear();
2188 };
2189 }
2190 unset();
2191 }
2192 return void 0;
2193 }, [open, floatingId, currentIdRef, delayRef, timeoutMs, initialDelayRef, currentContextRef, timeout, store2]);
2194 useIsoLayoutEffect(() => {
2195 if (!open) {
2196 return;
2197 }
2198 const prevContext = currentContextRef.current;
2199 const prevId = currentIdRef.current;
2200 timeout.clear();
2201 currentContextRef.current = {
2202 onOpenChange: store2.setOpen,
2203 setIsInstantPhase
2204 };
2205 currentIdRef.current = floatingId;
2206 delayRef.current = {
2207 open: 0,
2208 close: getDelay(initialDelayRef.current, "close")
2209 };
2210 if (prevId !== null && prevId !== floatingId) {
2211 setIsInstantPhase(true);
2212 prevContext?.setIsInstantPhase(true);
2213 prevContext?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.none));
2214 } else {
2215 setIsInstantPhase(false);
2216 prevContext?.setIsInstantPhase(false);
2217 }
2218 }, [open, floatingId, store2, currentIdRef, delayRef, initialDelayRef, currentContextRef, timeout]);
2219 useIsoLayoutEffect(() => {
2220 return () => {
2221 currentContextRef.current = null;
2222 };
2223 }, [currentContextRef]);
2224 return React13.useMemo(() => ({
2225 hasProvider,
2226 delayRef,
2227 isInstantPhase
2228 }), [hasProvider, delayRef, isInstantPhase]);
2229 }
2230
2231 // node_modules/@base-ui/utils/esm/mergeCleanups.js
2232 function mergeCleanups(...cleanups) {
2233 return () => {
2234 for (let i = 0; i < cleanups.length; i += 1) {
2235 const cleanup = cleanups[i];
2236 if (cleanup) {
2237 cleanup();
2238 }
2239 }
2240 };
2241 }
2242
2243 // node_modules/@base-ui/react/esm/utils/FocusGuard.js
2244 var React14 = __toESM(require_react(), 1);
2245
2246 // node_modules/@base-ui/utils/esm/visuallyHidden.js
2247 var visuallyHiddenBase = {
2248 clipPath: "inset(50%)",
2249 overflow: "hidden",
2250 whiteSpace: "nowrap",
2251 border: 0,
2252 padding: 0,
2253 width: 1,
2254 height: 1,
2255 margin: -1
2256 };
2257 var visuallyHidden = {
2258 ...visuallyHiddenBase,
2259 position: "fixed",
2260 top: 0,
2261 left: 0
2262 };
2263 var visuallyHiddenInput = {
2264 ...visuallyHiddenBase,
2265 position: "absolute"
2266 };
2267
2268 // node_modules/@base-ui/react/esm/utils/FocusGuard.js
2269 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
2270 var FocusGuard = /* @__PURE__ */ React14.forwardRef(function FocusGuard2(props, ref) {
2271 const [role, setRole] = React14.useState();
2272 useIsoLayoutEffect(() => {
2273 if (isSafari) {
2274 setRole("button");
2275 }
2276 }, []);
2277 const restProps = {
2278 tabIndex: 0,
2279 // Role is only for VoiceOver
2280 role
2281 };
2282 return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", {
2283 ...props,
2284 ref,
2285 style: visuallyHidden,
2286 "aria-hidden": role ? void 0 : true,
2287 ...restProps,
2288 "data-base-ui-focus-guard": ""
2289 });
2290 });
2291 if (true) FocusGuard.displayName = "FocusGuard";
2292
2293 // node_modules/@base-ui/react/esm/floating-ui-react/utils/createAttribute.js
2294 function createAttribute(name) {
2295 return `data-base-ui-${name}`;
2296 }
2297
2298 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingPortal.js
2299 var React15 = __toESM(require_react(), 1);
2300 var ReactDOM2 = __toESM(require_react_dom(), 1);
2301
2302 // node_modules/@base-ui/react/esm/internals/constants.js
2303 var DISABLED_TRANSITIONS_STYLE = {
2304 style: {
2305 transition: "none"
2306 }
2307 };
2308 var BASE_UI_SWIPE_IGNORE_ATTRIBUTE = "data-base-ui-swipe-ignore";
2309 var LEGACY_SWIPE_IGNORE_ATTRIBUTE = "data-swipe-ignore";
2310 var BASE_UI_SWIPE_IGNORE_SELECTOR = `[${BASE_UI_SWIPE_IGNORE_ATTRIBUTE}]`;
2311 var LEGACY_SWIPE_IGNORE_SELECTOR = `[${LEGACY_SWIPE_IGNORE_ATTRIBUTE}]`;
2312 var POPUP_COLLISION_AVOIDANCE = {
2313 fallbackAxisSide: "end"
2314 };
2315 var ownerVisuallyHidden = {
2316 clipPath: "inset(50%)",
2317 position: "fixed",
2318 top: 0,
2319 left: 0
2320 };
2321
2322 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingPortal.js
2323 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
2324 var PortalContext = /* @__PURE__ */ React15.createContext(null);
2325 if (true) PortalContext.displayName = "PortalContext";
2326 var usePortalContext = () => React15.useContext(PortalContext);
2327 var attr = createAttribute("portal");
2328 function useFloatingPortalNode(props = {}) {
2329 const {
2330 ref,
2331 container: containerProp,
2332 componentProps = EMPTY_OBJECT,
2333 elementProps
2334 } = props;
2335 const uniqueId = useId();
2336 const portalContext = usePortalContext();
2337 const parentPortalNode = portalContext?.portalNode;
2338 const [containerElement, setContainerElement] = React15.useState(null);
2339 const [portalNode, setPortalNode] = React15.useState(null);
2340 const setPortalNodeRef = useStableCallback((node) => {
2341 if (node !== null) {
2342 setPortalNode(node);
2343 }
2344 });
2345 const containerRef = React15.useRef(null);
2346 useIsoLayoutEffect(() => {
2347 if (containerProp === null) {
2348 if (containerRef.current) {
2349 containerRef.current = null;
2350 setPortalNode(null);
2351 setContainerElement(null);
2352 }
2353 return;
2354 }
2355 if (uniqueId == null) {
2356 return;
2357 }
2358 const resolvedContainer = (containerProp && (isNode(containerProp) ? containerProp : containerProp.current)) ?? parentPortalNode ?? document.body;
2359 if (resolvedContainer == null) {
2360 if (containerRef.current) {
2361 containerRef.current = null;
2362 setPortalNode(null);
2363 setContainerElement(null);
2364 }
2365 return;
2366 }
2367 if (containerRef.current !== resolvedContainer) {
2368 containerRef.current = resolvedContainer;
2369 setPortalNode(null);
2370 setContainerElement(resolvedContainer);
2371 }
2372 }, [containerProp, parentPortalNode, uniqueId]);
2373 const portalElement = useRenderElement("div", componentProps, {
2374 ref: [ref, setPortalNodeRef],
2375 props: [{
2376 id: uniqueId,
2377 [attr]: ""
2378 }, elementProps]
2379 });
2380 const portalSubtree = containerElement && portalElement ? /* @__PURE__ */ ReactDOM2.createPortal(portalElement, containerElement) : null;
2381 return {
2382 portalNode,
2383 portalSubtree
2384 };
2385 }
2386 var FloatingPortal = /* @__PURE__ */ React15.forwardRef(function FloatingPortal2(componentProps, forwardedRef) {
2387 const {
2388 render,
2389 className,
2390 style,
2391 children,
2392 container,
2393 renderGuards,
2394 ...elementProps
2395 } = componentProps;
2396 const {
2397 portalNode,
2398 portalSubtree
2399 } = useFloatingPortalNode({
2400 container,
2401 ref: forwardedRef,
2402 componentProps,
2403 elementProps
2404 });
2405 const beforeOutsideRef = React15.useRef(null);
2406 const afterOutsideRef = React15.useRef(null);
2407 const beforeInsideRef = React15.useRef(null);
2408 const afterInsideRef = React15.useRef(null);
2409 const [focusManagerState, setFocusManagerState] = React15.useState(null);
2410 const focusInsideDisabledRef = React15.useRef(false);
2411 const modal = focusManagerState?.modal;
2412 const open = focusManagerState?.open;
2413 const shouldRenderGuards = typeof renderGuards === "boolean" ? renderGuards : !!focusManagerState && !focusManagerState.modal && focusManagerState.open && !!portalNode;
2414 React15.useEffect(() => {
2415 if (!portalNode || modal) {
2416 return void 0;
2417 }
2418 function onFocus(event) {
2419 if (portalNode && event.relatedTarget && isOutsideEvent(event)) {
2420 if (event.type === "focusin") {
2421 if (focusInsideDisabledRef.current) {
2422 enableFocusInside(portalNode);
2423 focusInsideDisabledRef.current = false;
2424 }
2425 } else {
2426 disableFocusInside(portalNode);
2427 focusInsideDisabledRef.current = true;
2428 }
2429 }
2430 }
2431 return mergeCleanups(addEventListener(portalNode, "focusin", onFocus, true), addEventListener(portalNode, "focusout", onFocus, true));
2432 }, [portalNode, modal]);
2433 React15.useEffect(() => {
2434 if (!portalNode || open !== false) {
2435 return;
2436 }
2437 enableFocusInside(portalNode);
2438 focusInsideDisabledRef.current = false;
2439 }, [open, portalNode]);
2440 const portalContextValue = React15.useMemo(() => ({
2441 beforeOutsideRef,
2442 afterOutsideRef,
2443 beforeInsideRef,
2444 afterInsideRef,
2445 portalNode,
2446 setFocusManagerState
2447 }), [portalNode]);
2448 return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(React15.Fragment, {
2449 children: [portalSubtree, /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(PortalContext.Provider, {
2450 value: portalContextValue,
2451 children: [shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, {
2452 "data-type": "outside",
2453 ref: beforeOutsideRef,
2454 onFocus: (event) => {
2455 if (isOutsideEvent(event, portalNode)) {
2456 beforeInsideRef.current?.focus();
2457 } else {
2458 const domReference = focusManagerState ? focusManagerState.domReference : null;
2459 const prevTabbable = getPreviousTabbable(domReference);
2460 prevTabbable?.focus();
2461 }
2462 }
2463 }), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", {
2464 "aria-owns": portalNode.id,
2465 style: ownerVisuallyHidden
2466 }), portalNode && /* @__PURE__ */ ReactDOM2.createPortal(children, portalNode), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, {
2467 "data-type": "outside",
2468 ref: afterOutsideRef,
2469 onFocus: (event) => {
2470 if (isOutsideEvent(event, portalNode)) {
2471 afterInsideRef.current?.focus();
2472 } else {
2473 const domReference = focusManagerState ? focusManagerState.domReference : null;
2474 const nextTabbable = getNextTabbable(domReference);
2475 nextTabbable?.focus();
2476 if (focusManagerState?.closeOnFocusOut) {
2477 focusManagerState?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.focusOut, event.nativeEvent));
2478 }
2479 }
2480 }
2481 })]
2482 })]
2483 });
2484 });
2485 if (true) FloatingPortal.displayName = "FloatingPortal";
2486
2487 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingTree.js
2488 var React16 = __toESM(require_react(), 1);
2489
2490 // node_modules/@base-ui/react/esm/floating-ui-react/utils/createEventEmitter.js
2491 function createEventEmitter() {
2492 const map = /* @__PURE__ */ new Map();
2493 return {
2494 emit(event, data) {
2495 map.get(event)?.forEach((listener) => listener(data));
2496 },
2497 on(event, listener) {
2498 if (!map.has(event)) {
2499 map.set(event, /* @__PURE__ */ new Set());
2500 }
2501 map.get(event).add(listener);
2502 },
2503 off(event, listener) {
2504 map.get(event)?.delete(listener);
2505 }
2506 };
2507 }
2508
2509 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingTree.js
2510 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
2511 var FloatingNodeContext = /* @__PURE__ */ React16.createContext(null);
2512 if (true) FloatingNodeContext.displayName = "FloatingNodeContext";
2513 var FloatingTreeContext = /* @__PURE__ */ React16.createContext(null);
2514 if (true) FloatingTreeContext.displayName = "FloatingTreeContext";
2515 var useFloatingParentNodeId = () => React16.useContext(FloatingNodeContext)?.id || null;
2516 var useFloatingTree = (externalTree) => {
2517 const contextTree = React16.useContext(FloatingTreeContext);
2518 return externalTree ?? contextTree;
2519 };
2520
2521 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useClientPoint.js
2522 var React17 = __toESM(require_react(), 1);
2523 function createVirtualElement(domElement, data) {
2524 let offsetX = null;
2525 let offsetY = null;
2526 let isAutoUpdateEvent = false;
2527 return {
2528 contextElement: domElement || void 0,
2529 getBoundingClientRect() {
2530 const domRect = domElement?.getBoundingClientRect() || {
2531 width: 0,
2532 height: 0,
2533 x: 0,
2534 y: 0
2535 };
2536 const isXAxis = data.axis === "x" || data.axis === "both";
2537 const isYAxis = data.axis === "y" || data.axis === "both";
2538 const canTrackCursorOnAutoUpdate = ["mouseenter", "mousemove"].includes(data.dataRef.current.openEvent?.type || "") && data.pointerType !== "touch";
2539 let width = domRect.width;
2540 let height = domRect.height;
2541 let x = domRect.x;
2542 let y = domRect.y;
2543 if (offsetX == null && data.x && isXAxis) {
2544 offsetX = domRect.x - data.x;
2545 }
2546 if (offsetY == null && data.y && isYAxis) {
2547 offsetY = domRect.y - data.y;
2548 }
2549 x -= offsetX || 0;
2550 y -= offsetY || 0;
2551 width = 0;
2552 height = 0;
2553 if (!isAutoUpdateEvent || canTrackCursorOnAutoUpdate) {
2554 width = data.axis === "y" ? domRect.width : 0;
2555 height = data.axis === "x" ? domRect.height : 0;
2556 x = isXAxis && data.x != null ? data.x : x;
2557 y = isYAxis && data.y != null ? data.y : y;
2558 } else if (isAutoUpdateEvent && !canTrackCursorOnAutoUpdate) {
2559 height = data.axis === "x" ? domRect.height : height;
2560 width = data.axis === "y" ? domRect.width : width;
2561 }
2562 isAutoUpdateEvent = true;
2563 return {
2564 width,
2565 height,
2566 x,
2567 y,
2568 top: y,
2569 right: x + width,
2570 bottom: y + height,
2571 left: x
2572 };
2573 }
2574 };
2575 }
2576 function isMouseBasedEvent(event) {
2577 return event != null && event.clientX != null;
2578 }
2579 function useClientPoint(context, props = {}) {
2580 const {
2581 enabled = true,
2582 axis = "both"
2583 } = props;
2584 const store2 = "rootStore" in context ? context.rootStore : context;
2585 const open = store2.useState("open");
2586 const floating = store2.useState("floatingElement");
2587 const domReference = store2.useState("domReferenceElement");
2588 const dataRef = store2.context.dataRef;
2589 const initialRef = React17.useRef(false);
2590 const cleanupListenerRef = React17.useRef(null);
2591 const [pointerType, setPointerType] = React17.useState();
2592 const [reactive, setReactive] = React17.useState([]);
2593 const resetReference = useStableCallback((reference2) => {
2594 store2.set("positionReference", reference2);
2595 });
2596 const setReference = useStableCallback((newX, newY, referenceElement) => {
2597 if (initialRef.current) {
2598 return;
2599 }
2600 if (dataRef.current.openEvent && !isMouseBasedEvent(dataRef.current.openEvent)) {
2601 return;
2602 }
2603 store2.set("positionReference", createVirtualElement(referenceElement ?? domReference, {
2604 x: newX,
2605 y: newY,
2606 axis,
2607 dataRef,
2608 pointerType
2609 }));
2610 });
2611 const handleReferenceEnterOrMove = useStableCallback((event) => {
2612 if (!open) {
2613 setReference(event.clientX, event.clientY, event.currentTarget);
2614 } else if (!cleanupListenerRef.current) {
2615 setReference(event.clientX, event.clientY, event.currentTarget);
2616 setReactive([]);
2617 }
2618 });
2619 const openCheck = isMouseLikePointerType(pointerType) ? floating : open;
2620 React17.useEffect(() => {
2621 if (!enabled) {
2622 resetReference(domReference);
2623 return void 0;
2624 }
2625 if (!openCheck) {
2626 return void 0;
2627 }
2628 function cleanupListener() {
2629 cleanupListenerRef.current?.();
2630 cleanupListenerRef.current = null;
2631 }
2632 const win = getWindow(floating);
2633 function handleMouseMove(event) {
2634 const target = getTarget(event);
2635 if (!contains(floating, target)) {
2636 setReference(event.clientX, event.clientY);
2637 } else {
2638 cleanupListener();
2639 }
2640 }
2641 if (!dataRef.current.openEvent || isMouseBasedEvent(dataRef.current.openEvent)) {
2642 cleanupListenerRef.current = addEventListener(win, "mousemove", handleMouseMove);
2643 } else {
2644 resetReference(domReference);
2645 }
2646 return cleanupListener;
2647 }, [openCheck, enabled, floating, dataRef, domReference, store2, setReference, resetReference, reactive]);
2648 React17.useEffect(() => () => {
2649 store2.set("positionReference", null);
2650 }, [store2]);
2651 React17.useEffect(() => {
2652 if (enabled && !floating) {
2653 initialRef.current = false;
2654 }
2655 }, [enabled, floating]);
2656 React17.useEffect(() => {
2657 if (!enabled && open) {
2658 initialRef.current = true;
2659 }
2660 }, [enabled, open]);
2661 const reference = React17.useMemo(() => {
2662 function setPointerTypeRef(event) {
2663 setPointerType(event.pointerType);
2664 }
2665 return {
2666 onPointerDown: setPointerTypeRef,
2667 onPointerEnter: setPointerTypeRef,
2668 onMouseMove: handleReferenceEnterOrMove,
2669 onMouseEnter: handleReferenceEnterOrMove
2670 };
2671 }, [handleReferenceEnterOrMove]);
2672 return React17.useMemo(() => enabled ? {
2673 reference,
2674 trigger: reference
2675 } : {}, [enabled, reference]);
2676 }
2677
2678 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useDismiss.js
2679 var React18 = __toESM(require_react(), 1);
2680 var bubbleHandlerKeys = {
2681 intentional: "onClick",
2682 sloppy: "onPointerDown"
2683 };
2684 function alwaysFalse() {
2685 return false;
2686 }
2687 function normalizeProp(normalizable) {
2688 return {
2689 escapeKey: typeof normalizable === "boolean" ? normalizable : normalizable?.escapeKey ?? false,
2690 outsidePress: typeof normalizable === "boolean" ? normalizable : normalizable?.outsidePress ?? true
2691 };
2692 }
2693 function useDismiss(context, props = {}) {
2694 const {
2695 enabled = true,
2696 escapeKey: escapeKey2 = true,
2697 outsidePress: outsidePressProp = true,
2698 outsidePressEvent = "sloppy",
2699 referencePress = alwaysFalse,
2700 referencePressEvent = "sloppy",
2701 bubbles,
2702 externalTree
2703 } = props;
2704 const store2 = "rootStore" in context ? context.rootStore : context;
2705 const open = store2.useState("open");
2706 const floatingElement = store2.useState("floatingElement");
2707 const {
2708 dataRef
2709 } = store2.context;
2710 const tree = useFloatingTree(externalTree);
2711 const outsidePressFn = useStableCallback(typeof outsidePressProp === "function" ? outsidePressProp : () => false);
2712 const outsidePress2 = typeof outsidePressProp === "function" ? outsidePressFn : outsidePressProp;
2713 const outsidePressEnabled = outsidePress2 !== false;
2714 const getOutsidePressEventProp = useStableCallback(() => outsidePressEvent);
2715 const {
2716 escapeKey: escapeKeyBubbles,
2717 outsidePress: outsidePressBubbles
2718 } = normalizeProp(bubbles);
2719 const pressStartedInsideRef = React18.useRef(false);
2720 const pressStartPreventedRef = React18.useRef(false);
2721 const suppressNextOutsideClickRef = React18.useRef(false);
2722 const isComposingRef = React18.useRef(false);
2723 const currentPointerTypeRef = React18.useRef("");
2724 const touchStateRef = React18.useRef(null);
2725 const cancelDismissOnEndTimeout = useTimeout();
2726 const clearInsideReactTreeTimeout = useTimeout();
2727 const clearInsideReactTree = useStableCallback(() => {
2728 clearInsideReactTreeTimeout.clear();
2729 dataRef.current.insideReactTree = false;
2730 });
2731 const hasBlockingChild = useStableCallback((bubbleKey) => {
2732 const nodeId = dataRef.current.floatingContext?.nodeId;
2733 const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : [];
2734 return children.some((child) => child.context?.open && !child.context.dataRef.current[bubbleKey]);
2735 });
2736 const isEventWithinOwnElements = useStableCallback((event) => {
2737 return isEventTargetWithin(event, store2.select("floatingElement")) || isEventTargetWithin(event, store2.select("domReferenceElement"));
2738 });
2739 const closeOnReferencePress = useStableCallback((event) => {
2740 if (!referencePress()) {
2741 return;
2742 }
2743 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent));
2744 });
2745 const closeOnEscapeKeyDown = useStableCallback((event) => {
2746 if (!open || !enabled || !escapeKey2 || event.key !== "Escape") {
2747 return;
2748 }
2749 if (isComposingRef.current) {
2750 return;
2751 }
2752 if (!escapeKeyBubbles && hasBlockingChild("__escapeKeyBubbles")) {
2753 return;
2754 }
2755 const native = isReactEvent(event) ? event.nativeEvent : event;
2756 const eventDetails = createChangeEventDetails(reason_parts_exports.escapeKey, native);
2757 store2.setOpen(false, eventDetails);
2758 if (!eventDetails.isCanceled) {
2759 event.preventDefault();
2760 }
2761 if (!escapeKeyBubbles && !eventDetails.isPropagationAllowed) {
2762 event.stopPropagation();
2763 }
2764 });
2765 const markInsideReactTree = useStableCallback(() => {
2766 dataRef.current.insideReactTree = true;
2767 clearInsideReactTreeTimeout.start(0, clearInsideReactTree);
2768 });
2769 const markPressStartedInsideReactTree = useStableCallback((event) => {
2770 if (!open || !enabled || event.button !== 0) {
2771 return;
2772 }
2773 const target = getTarget(event.nativeEvent);
2774 if (!contains(store2.select("floatingElement"), target)) {
2775 return;
2776 }
2777 if (!pressStartedInsideRef.current) {
2778 pressStartedInsideRef.current = true;
2779 pressStartPreventedRef.current = false;
2780 }
2781 });
2782 const markInsidePressStartPrevented = useStableCallback((event) => {
2783 if (!open || !enabled) {
2784 return;
2785 }
2786 if (!(event.defaultPrevented || event.nativeEvent.defaultPrevented)) {
2787 return;
2788 }
2789 if (pressStartedInsideRef.current) {
2790 pressStartPreventedRef.current = true;
2791 }
2792 });
2793 React18.useEffect(() => {
2794 if (!open || !enabled) {
2795 return void 0;
2796 }
2797 dataRef.current.__escapeKeyBubbles = escapeKeyBubbles;
2798 dataRef.current.__outsidePressBubbles = outsidePressBubbles;
2799 const compositionTimeout = new Timeout();
2800 const preventedPressSuppressionTimeout = new Timeout();
2801 function handleCompositionStart() {
2802 compositionTimeout.clear();
2803 isComposingRef.current = true;
2804 }
2805 function handleCompositionEnd() {
2806 compositionTimeout.start(
2807 // 0ms or 1ms don't work in Safari. 5ms appears to consistently work.
2808 // Only apply to WebKit for the test to remain 0ms.
2809 isWebKit() ? 5 : 0,
2810 () => {
2811 isComposingRef.current = false;
2812 }
2813 );
2814 }
2815 function suppressImmediateOutsideClickAfterPreventedStart() {
2816 suppressNextOutsideClickRef.current = true;
2817 preventedPressSuppressionTimeout.start(0, () => {
2818 suppressNextOutsideClickRef.current = false;
2819 });
2820 }
2821 function resetPressStartState() {
2822 pressStartedInsideRef.current = false;
2823 pressStartPreventedRef.current = false;
2824 }
2825 function getOutsidePressEvent() {
2826 const type = currentPointerTypeRef.current;
2827 const computedType = type === "pen" || !type ? "mouse" : type;
2828 const outsidePressEventValue = getOutsidePressEventProp();
2829 const resolved = typeof outsidePressEventValue === "function" ? outsidePressEventValue() : outsidePressEventValue;
2830 if (typeof resolved === "string") {
2831 return resolved;
2832 }
2833 return resolved[computedType];
2834 }
2835 function shouldIgnoreEvent(event) {
2836 const computedOutsidePressEvent = getOutsidePressEvent();
2837 return computedOutsidePressEvent === "intentional" && event.type !== "click" || computedOutsidePressEvent === "sloppy" && event.type === "click";
2838 }
2839 function isEventWithinFloatingTree(event) {
2840 const nodeId = dataRef.current.floatingContext?.nodeId;
2841 const targetIsInsideChildren = tree && getNodeChildren(tree.nodesRef.current, nodeId).some((node) => isEventTargetWithin(event, node.context?.elements.floating));
2842 return isEventWithinOwnElements(event) || targetIsInsideChildren;
2843 }
2844 function closeOnPressOutside(event) {
2845 if (shouldIgnoreEvent(event)) {
2846 if (event.type !== "click" && !isEventWithinOwnElements(event)) {
2847 preventedPressSuppressionTimeout.clear();
2848 suppressNextOutsideClickRef.current = false;
2849 }
2850 clearInsideReactTree();
2851 return;
2852 }
2853 if (dataRef.current.insideReactTree) {
2854 clearInsideReactTree();
2855 return;
2856 }
2857 const target = getTarget(event);
2858 const inertSelector = `[${createAttribute("inert")}]`;
2859 const targetRoot = isElement(target) ? target.getRootNode() : null;
2860 const markers = Array.from((isShadowRoot(targetRoot) ? targetRoot : ownerDocument(store2.select("floatingElement"))).querySelectorAll(inertSelector));
2861 const triggers = store2.context.triggerElements;
2862 if (target && (triggers.hasElement(target) || triggers.hasMatchingElement((trigger) => contains(trigger, target)))) {
2863 return;
2864 }
2865 let targetRootAncestor = isElement(target) ? target : null;
2866 while (targetRootAncestor && !isLastTraversableNode(targetRootAncestor)) {
2867 const nextParent = getParentNode(targetRootAncestor);
2868 if (isLastTraversableNode(nextParent) || !isElement(nextParent)) {
2869 break;
2870 }
2871 targetRootAncestor = nextParent;
2872 }
2873 if (markers.length && isElement(target) && !isRootElement(target) && // Clicked on a direct ancestor (e.g. FloatingOverlay).
2874 !contains(target, store2.select("floatingElement")) && // If the target root element contains none of the markers, then the
2875 // element was injected after the floating element rendered.
2876 markers.every((marker) => !contains(targetRootAncestor, marker))) {
2877 return;
2878 }
2879 if (isHTMLElement(target) && !("touches" in event)) {
2880 const lastTraversableNode = isLastTraversableNode(target);
2881 const style = getComputedStyle2(target);
2882 const scrollRe = /auto|scroll/;
2883 const isScrollableX = lastTraversableNode || scrollRe.test(style.overflowX);
2884 const isScrollableY = lastTraversableNode || scrollRe.test(style.overflowY);
2885 const canScrollX = isScrollableX && target.clientWidth > 0 && target.scrollWidth > target.clientWidth;
2886 const canScrollY = isScrollableY && target.clientHeight > 0 && target.scrollHeight > target.clientHeight;
2887 const isRTL3 = style.direction === "rtl";
2888 const pressedVerticalScrollbar = canScrollY && (isRTL3 ? event.offsetX <= target.offsetWidth - target.clientWidth : event.offsetX > target.clientWidth);
2889 const pressedHorizontalScrollbar = canScrollX && event.offsetY > target.clientHeight;
2890 if (pressedVerticalScrollbar || pressedHorizontalScrollbar) {
2891 return;
2892 }
2893 }
2894 if (isEventWithinFloatingTree(event)) {
2895 return;
2896 }
2897 if (getOutsidePressEvent() === "intentional" && suppressNextOutsideClickRef.current) {
2898 preventedPressSuppressionTimeout.clear();
2899 suppressNextOutsideClickRef.current = false;
2900 return;
2901 }
2902 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
2903 return;
2904 }
2905 if (hasBlockingChild("__outsidePressBubbles")) {
2906 return;
2907 }
2908 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.outsidePress, event));
2909 clearInsideReactTree();
2910 }
2911 function handlePointerDown(event) {
2912 if (getOutsidePressEvent() !== "sloppy" || event.pointerType === "touch" || !store2.select("open") || !enabled || isEventWithinOwnElements(event)) {
2913 return;
2914 }
2915 closeOnPressOutside(event);
2916 }
2917 function handleTouchStart(event) {
2918 if (getOutsidePressEvent() !== "sloppy" || !store2.select("open") || !enabled || isEventWithinOwnElements(event)) {
2919 return;
2920 }
2921 const touch = event.touches[0];
2922 if (touch) {
2923 touchStateRef.current = {
2924 startTime: Date.now(),
2925 startX: touch.clientX,
2926 startY: touch.clientY,
2927 dismissOnTouchEnd: false,
2928 dismissOnMouseDown: true
2929 };
2930 cancelDismissOnEndTimeout.start(1e3, () => {
2931 if (touchStateRef.current) {
2932 touchStateRef.current.dismissOnTouchEnd = false;
2933 touchStateRef.current.dismissOnMouseDown = false;
2934 }
2935 });
2936 }
2937 }
2938 function addTargetEventListenerOnce(event, listener) {
2939 const target = getTarget(event);
2940 if (!target) {
2941 return;
2942 }
2943 const unsubscribe2 = addEventListener(target, event.type, () => {
2944 listener(event);
2945 unsubscribe2();
2946 });
2947 }
2948 function handleTouchStartCapture(event) {
2949 currentPointerTypeRef.current = "touch";
2950 addTargetEventListenerOnce(event, handleTouchStart);
2951 }
2952 function closeOnPressOutsideCapture(event) {
2953 cancelDismissOnEndTimeout.clear();
2954 if (event.type === "pointerdown") {
2955 currentPointerTypeRef.current = event.pointerType;
2956 }
2957 if (event.type === "mousedown" && touchStateRef.current && !touchStateRef.current.dismissOnMouseDown) {
2958 return;
2959 }
2960 addTargetEventListenerOnce(event, (targetEvent) => {
2961 if (targetEvent.type === "pointerdown") {
2962 handlePointerDown(targetEvent);
2963 } else {
2964 closeOnPressOutside(targetEvent);
2965 }
2966 });
2967 }
2968 function handlePressEndCapture(event) {
2969 if (!pressStartedInsideRef.current) {
2970 return;
2971 }
2972 const pressStartedInsideDefaultPrevented = pressStartPreventedRef.current;
2973 resetPressStartState();
2974 if (getOutsidePressEvent() !== "intentional") {
2975 return;
2976 }
2977 if (event.type === "pointercancel") {
2978 if (pressStartedInsideDefaultPrevented) {
2979 suppressImmediateOutsideClickAfterPreventedStart();
2980 }
2981 return;
2982 }
2983 if (isEventWithinFloatingTree(event)) {
2984 return;
2985 }
2986 if (pressStartedInsideDefaultPrevented) {
2987 suppressImmediateOutsideClickAfterPreventedStart();
2988 return;
2989 }
2990 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
2991 return;
2992 }
2993 preventedPressSuppressionTimeout.clear();
2994 suppressNextOutsideClickRef.current = true;
2995 clearInsideReactTree();
2996 }
2997 function handleTouchMove(event) {
2998 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) {
2999 return;
3000 }
3001 const touch = event.touches[0];
3002 if (!touch) {
3003 return;
3004 }
3005 const deltaX = Math.abs(touch.clientX - touchStateRef.current.startX);
3006 const deltaY = Math.abs(touch.clientY - touchStateRef.current.startY);
3007 const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
3008 if (distance > 5) {
3009 touchStateRef.current.dismissOnTouchEnd = true;
3010 }
3011 if (distance > 10) {
3012 closeOnPressOutside(event);
3013 cancelDismissOnEndTimeout.clear();
3014 touchStateRef.current = null;
3015 }
3016 }
3017 function handleTouchMoveCapture(event) {
3018 addTargetEventListenerOnce(event, handleTouchMove);
3019 }
3020 function handleTouchEnd(event) {
3021 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) {
3022 return;
3023 }
3024 if (touchStateRef.current.dismissOnTouchEnd) {
3025 closeOnPressOutside(event);
3026 }
3027 cancelDismissOnEndTimeout.clear();
3028 touchStateRef.current = null;
3029 }
3030 function handleTouchEndCapture(event) {
3031 addTargetEventListenerOnce(event, handleTouchEnd);
3032 }
3033 const doc = ownerDocument(floatingElement);
3034 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)));
3035 return () => {
3036 unsubscribe();
3037 compositionTimeout.clear();
3038 preventedPressSuppressionTimeout.clear();
3039 resetPressStartState();
3040 suppressNextOutsideClickRef.current = false;
3041 };
3042 }, [dataRef, floatingElement, escapeKey2, outsidePressEnabled, outsidePress2, open, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, clearInsideReactTree, getOutsidePressEventProp, hasBlockingChild, isEventWithinOwnElements, tree, store2, cancelDismissOnEndTimeout]);
3043 React18.useEffect(clearInsideReactTree, [outsidePress2, clearInsideReactTree]);
3044 const reference = React18.useMemo(() => ({
3045 onKeyDown: closeOnEscapeKeyDown,
3046 [bubbleHandlerKeys[referencePressEvent]]: closeOnReferencePress,
3047 ...referencePressEvent !== "intentional" && {
3048 onClick: closeOnReferencePress
3049 }
3050 }), [closeOnEscapeKeyDown, closeOnReferencePress, referencePressEvent]);
3051 const floating = React18.useMemo(() => ({
3052 onKeyDown: closeOnEscapeKeyDown,
3053 // `onMouseDown` may be blocked if `event.preventDefault()` is called in
3054 // `onPointerDown`, such as with <NumberField.ScrubArea>.
3055 // See https://github.com/mui/base-ui/pull/3379
3056 onPointerDown: markInsidePressStartPrevented,
3057 onMouseDown: markInsidePressStartPrevented,
3058 onClickCapture: markInsideReactTree,
3059 onMouseDownCapture(event) {
3060 markInsideReactTree();
3061 markPressStartedInsideReactTree(event);
3062 },
3063 onPointerDownCapture(event) {
3064 markInsideReactTree();
3065 markPressStartedInsideReactTree(event);
3066 },
3067 onMouseUpCapture: markInsideReactTree,
3068 onTouchEndCapture: markInsideReactTree,
3069 onTouchMoveCapture: markInsideReactTree
3070 }), [closeOnEscapeKeyDown, markInsideReactTree, markPressStartedInsideReactTree, markInsidePressStartPrevented]);
3071 return React18.useMemo(() => enabled ? {
3072 reference,
3073 floating,
3074 trigger: reference
3075 } : {}, [enabled, reference, floating]);
3076 }
3077
3078 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloating.js
3079 var React25 = __toESM(require_react(), 1);
3080
3081 // node_modules/@floating-ui/core/dist/floating-ui.core.mjs
3082 function computeCoordsFromPlacement(_ref, placement, rtl) {
3083 let {
3084 reference,
3085 floating
3086 } = _ref;
3087 const sideAxis = getSideAxis(placement);
3088 const alignmentAxis = getAlignmentAxis(placement);
3089 const alignLength = getAxisLength(alignmentAxis);
3090 const side = getSide(placement);
3091 const isVertical = sideAxis === "y";
3092 const commonX = reference.x + reference.width / 2 - floating.width / 2;
3093 const commonY = reference.y + reference.height / 2 - floating.height / 2;
3094 const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
3095 let coords;
3096 switch (side) {
3097 case "top":
3098 coords = {
3099 x: commonX,
3100 y: reference.y - floating.height
3101 };
3102 break;
3103 case "bottom":
3104 coords = {
3105 x: commonX,
3106 y: reference.y + reference.height
3107 };
3108 break;
3109 case "right":
3110 coords = {
3111 x: reference.x + reference.width,
3112 y: commonY
3113 };
3114 break;
3115 case "left":
3116 coords = {
3117 x: reference.x - floating.width,
3118 y: commonY
3119 };
3120 break;
3121 default:
3122 coords = {
3123 x: reference.x,
3124 y: reference.y
3125 };
3126 }
3127 switch (getAlignment(placement)) {
3128 case "start":
3129 coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
3130 break;
3131 case "end":
3132 coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
3133 break;
3134 }
3135 return coords;
3136 }
3137 async function detectOverflow(state, options) {
3138 var _await$platform$isEle;
3139 if (options === void 0) {
3140 options = {};
3141 }
3142 const {
3143 x,
3144 y,
3145 platform: platform3,
3146 rects,
3147 elements,
3148 strategy
3149 } = state;
3150 const {
3151 boundary = "clippingAncestors",
3152 rootBoundary = "viewport",
3153 elementContext = "floating",
3154 altBoundary = false,
3155 padding = 0
3156 } = evaluate(options, state);
3157 const paddingObject = getPaddingObject(padding);
3158 const altContext = elementContext === "floating" ? "reference" : "floating";
3159 const element = elements[altBoundary ? altContext : elementContext];
3160 const clippingClientRect = rectToClientRect(await platform3.getClippingRect({
3161 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)),
3162 boundary,
3163 rootBoundary,
3164 strategy
3165 }));
3166 const rect = elementContext === "floating" ? {
3167 x,
3168 y,
3169 width: rects.floating.width,
3170 height: rects.floating.height
3171 } : rects.reference;
3172 const offsetParent = await (platform3.getOffsetParent == null ? void 0 : platform3.getOffsetParent(elements.floating));
3173 const offsetScale = await (platform3.isElement == null ? void 0 : platform3.isElement(offsetParent)) ? await (platform3.getScale == null ? void 0 : platform3.getScale(offsetParent)) || {
3174 x: 1,
3175 y: 1
3176 } : {
3177 x: 1,
3178 y: 1
3179 };
3180 const elementClientRect = rectToClientRect(platform3.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform3.convertOffsetParentRelativeRectToViewportRelativeRect({
3181 elements,
3182 rect,
3183 offsetParent,
3184 strategy
3185 }) : rect);
3186 return {
3187 top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
3188 bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
3189 left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
3190 right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
3191 };
3192 }
3193 var MAX_RESET_COUNT = 50;
3194 var computePosition = async (reference, floating, config) => {
3195 const {
3196 placement = "bottom",
3197 strategy = "absolute",
3198 middleware = [],
3199 platform: platform3
3200 } = config;
3201 const platformWithDetectOverflow = platform3.detectOverflow ? platform3 : {
3202 ...platform3,
3203 detectOverflow
3204 };
3205 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(floating));
3206 let rects = await platform3.getElementRects({
3207 reference,
3208 floating,
3209 strategy
3210 });
3211 let {
3212 x,
3213 y
3214 } = computeCoordsFromPlacement(rects, placement, rtl);
3215 let statefulPlacement = placement;
3216 let resetCount = 0;
3217 const middlewareData = {};
3218 for (let i = 0; i < middleware.length; i++) {
3219 const currentMiddleware = middleware[i];
3220 if (!currentMiddleware) {
3221 continue;
3222 }
3223 const {
3224 name,
3225 fn
3226 } = currentMiddleware;
3227 const {
3228 x: nextX,
3229 y: nextY,
3230 data,
3231 reset
3232 } = await fn({
3233 x,
3234 y,
3235 initialPlacement: placement,
3236 placement: statefulPlacement,
3237 strategy,
3238 middlewareData,
3239 rects,
3240 platform: platformWithDetectOverflow,
3241 elements: {
3242 reference,
3243 floating
3244 }
3245 });
3246 x = nextX != null ? nextX : x;
3247 y = nextY != null ? nextY : y;
3248 middlewareData[name] = {
3249 ...middlewareData[name],
3250 ...data
3251 };
3252 if (reset && resetCount < MAX_RESET_COUNT) {
3253 resetCount++;
3254 if (typeof reset === "object") {
3255 if (reset.placement) {
3256 statefulPlacement = reset.placement;
3257 }
3258 if (reset.rects) {
3259 rects = reset.rects === true ? await platform3.getElementRects({
3260 reference,
3261 floating,
3262 strategy
3263 }) : reset.rects;
3264 }
3265 ({
3266 x,
3267 y
3268 } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
3269 }
3270 i = -1;
3271 }
3272 }
3273 return {
3274 x,
3275 y,
3276 placement: statefulPlacement,
3277 strategy,
3278 middlewareData
3279 };
3280 };
3281 var flip = function(options) {
3282 if (options === void 0) {
3283 options = {};
3284 }
3285 return {
3286 name: "flip",
3287 options,
3288 async fn(state) {
3289 var _middlewareData$arrow, _middlewareData$flip;
3290 const {
3291 placement,
3292 middlewareData,
3293 rects,
3294 initialPlacement,
3295 platform: platform3,
3296 elements
3297 } = state;
3298 const {
3299 mainAxis: checkMainAxis = true,
3300 crossAxis: checkCrossAxis = true,
3301 fallbackPlacements: specifiedFallbackPlacements,
3302 fallbackStrategy = "bestFit",
3303 fallbackAxisSideDirection = "none",
3304 flipAlignment = true,
3305 ...detectOverflowOptions
3306 } = evaluate(options, state);
3307 if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
3308 return {};
3309 }
3310 const side = getSide(placement);
3311 const initialSideAxis = getSideAxis(initialPlacement);
3312 const isBasePlacement = getSide(initialPlacement) === initialPlacement;
3313 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
3314 const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
3315 const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
3316 if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
3317 fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
3318 }
3319 const placements2 = [initialPlacement, ...fallbackPlacements];
3320 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
3321 const overflows = [];
3322 let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
3323 if (checkMainAxis) {
3324 overflows.push(overflow[side]);
3325 }
3326 if (checkCrossAxis) {
3327 const sides2 = getAlignmentSides(placement, rects, rtl);
3328 overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
3329 }
3330 overflowsData = [...overflowsData, {
3331 placement,
3332 overflows
3333 }];
3334 if (!overflows.every((side2) => side2 <= 0)) {
3335 var _middlewareData$flip2, _overflowsData$filter;
3336 const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
3337 const nextPlacement = placements2[nextIndex];
3338 if (nextPlacement) {
3339 const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false;
3340 if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis
3341 // overflows the main axis.
3342 overflowsData.every((d) => getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) {
3343 return {
3344 data: {
3345 index: nextIndex,
3346 overflows: overflowsData
3347 },
3348 reset: {
3349 placement: nextPlacement
3350 }
3351 };
3352 }
3353 }
3354 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;
3355 if (!resetPlacement) {
3356 switch (fallbackStrategy) {
3357 case "bestFit": {
3358 var _overflowsData$filter2;
3359 const placement2 = (_overflowsData$filter2 = overflowsData.filter((d) => {
3360 if (hasFallbackAxisSideDirection) {
3361 const currentSideAxis = getSideAxis(d.placement);
3362 return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
3363 // reading directions favoring greater width.
3364 currentSideAxis === "y";
3365 }
3366 return true;
3367 }).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];
3368 if (placement2) {
3369 resetPlacement = placement2;
3370 }
3371 break;
3372 }
3373 case "initialPlacement":
3374 resetPlacement = initialPlacement;
3375 break;
3376 }
3377 }
3378 if (placement !== resetPlacement) {
3379 return {
3380 reset: {
3381 placement: resetPlacement
3382 }
3383 };
3384 }
3385 }
3386 return {};
3387 }
3388 };
3389 };
3390 function getSideOffsets(overflow, rect) {
3391 return {
3392 top: overflow.top - rect.height,
3393 right: overflow.right - rect.width,
3394 bottom: overflow.bottom - rect.height,
3395 left: overflow.left - rect.width
3396 };
3397 }
3398 function isAnySideFullyClipped(overflow) {
3399 return sides.some((side) => overflow[side] >= 0);
3400 }
3401 var hide = function(options) {
3402 if (options === void 0) {
3403 options = {};
3404 }
3405 return {
3406 name: "hide",
3407 options,
3408 async fn(state) {
3409 const {
3410 rects,
3411 platform: platform3
3412 } = state;
3413 const {
3414 strategy = "referenceHidden",
3415 ...detectOverflowOptions
3416 } = evaluate(options, state);
3417 switch (strategy) {
3418 case "referenceHidden": {
3419 const overflow = await platform3.detectOverflow(state, {
3420 ...detectOverflowOptions,
3421 elementContext: "reference"
3422 });
3423 const offsets = getSideOffsets(overflow, rects.reference);
3424 return {
3425 data: {
3426 referenceHiddenOffsets: offsets,
3427 referenceHidden: isAnySideFullyClipped(offsets)
3428 }
3429 };
3430 }
3431 case "escaped": {
3432 const overflow = await platform3.detectOverflow(state, {
3433 ...detectOverflowOptions,
3434 altBoundary: true
3435 });
3436 const offsets = getSideOffsets(overflow, rects.floating);
3437 return {
3438 data: {
3439 escapedOffsets: offsets,
3440 escaped: isAnySideFullyClipped(offsets)
3441 }
3442 };
3443 }
3444 default: {
3445 return {};
3446 }
3447 }
3448 }
3449 };
3450 };
3451 var originSides = /* @__PURE__ */ new Set(["left", "top"]);
3452 async function convertValueToCoords(state, options) {
3453 const {
3454 placement,
3455 platform: platform3,
3456 elements
3457 } = state;
3458 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
3459 const side = getSide(placement);
3460 const alignment = getAlignment(placement);
3461 const isVertical = getSideAxis(placement) === "y";
3462 const mainAxisMulti = originSides.has(side) ? -1 : 1;
3463 const crossAxisMulti = rtl && isVertical ? -1 : 1;
3464 const rawValue = evaluate(options, state);
3465 let {
3466 mainAxis,
3467 crossAxis,
3468 alignmentAxis
3469 } = typeof rawValue === "number" ? {
3470 mainAxis: rawValue,
3471 crossAxis: 0,
3472 alignmentAxis: null
3473 } : {
3474 mainAxis: rawValue.mainAxis || 0,
3475 crossAxis: rawValue.crossAxis || 0,
3476 alignmentAxis: rawValue.alignmentAxis
3477 };
3478 if (alignment && typeof alignmentAxis === "number") {
3479 crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
3480 }
3481 return isVertical ? {
3482 x: crossAxis * crossAxisMulti,
3483 y: mainAxis * mainAxisMulti
3484 } : {
3485 x: mainAxis * mainAxisMulti,
3486 y: crossAxis * crossAxisMulti
3487 };
3488 }
3489 var offset = function(options) {
3490 if (options === void 0) {
3491 options = 0;
3492 }
3493 return {
3494 name: "offset",
3495 options,
3496 async fn(state) {
3497 var _middlewareData$offse, _middlewareData$arrow;
3498 const {
3499 x,
3500 y,
3501 placement,
3502 middlewareData
3503 } = state;
3504 const diffCoords = await convertValueToCoords(state, options);
3505 if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
3506 return {};
3507 }
3508 return {
3509 x: x + diffCoords.x,
3510 y: y + diffCoords.y,
3511 data: {
3512 ...diffCoords,
3513 placement
3514 }
3515 };
3516 }
3517 };
3518 };
3519 var shift = function(options) {
3520 if (options === void 0) {
3521 options = {};
3522 }
3523 return {
3524 name: "shift",
3525 options,
3526 async fn(state) {
3527 const {
3528 x,
3529 y,
3530 placement,
3531 platform: platform3
3532 } = state;
3533 const {
3534 mainAxis: checkMainAxis = true,
3535 crossAxis: checkCrossAxis = false,
3536 limiter = {
3537 fn: (_ref) => {
3538 let {
3539 x: x2,
3540 y: y2
3541 } = _ref;
3542 return {
3543 x: x2,
3544 y: y2
3545 };
3546 }
3547 },
3548 ...detectOverflowOptions
3549 } = evaluate(options, state);
3550 const coords = {
3551 x,
3552 y
3553 };
3554 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
3555 const crossAxis = getSideAxis(getSide(placement));
3556 const mainAxis = getOppositeAxis(crossAxis);
3557 let mainAxisCoord = coords[mainAxis];
3558 let crossAxisCoord = coords[crossAxis];
3559 if (checkMainAxis) {
3560 const minSide = mainAxis === "y" ? "top" : "left";
3561 const maxSide = mainAxis === "y" ? "bottom" : "right";
3562 const min2 = mainAxisCoord + overflow[minSide];
3563 const max2 = mainAxisCoord - overflow[maxSide];
3564 mainAxisCoord = clamp(min2, mainAxisCoord, max2);
3565 }
3566 if (checkCrossAxis) {
3567 const minSide = crossAxis === "y" ? "top" : "left";
3568 const maxSide = crossAxis === "y" ? "bottom" : "right";
3569 const min2 = crossAxisCoord + overflow[minSide];
3570 const max2 = crossAxisCoord - overflow[maxSide];
3571 crossAxisCoord = clamp(min2, crossAxisCoord, max2);
3572 }
3573 const limitedCoords = limiter.fn({
3574 ...state,
3575 [mainAxis]: mainAxisCoord,
3576 [crossAxis]: crossAxisCoord
3577 });
3578 return {
3579 ...limitedCoords,
3580 data: {
3581 x: limitedCoords.x - x,
3582 y: limitedCoords.y - y,
3583 enabled: {
3584 [mainAxis]: checkMainAxis,
3585 [crossAxis]: checkCrossAxis
3586 }
3587 }
3588 };
3589 }
3590 };
3591 };
3592 var limitShift = function(options) {
3593 if (options === void 0) {
3594 options = {};
3595 }
3596 return {
3597 options,
3598 fn(state) {
3599 const {
3600 x,
3601 y,
3602 placement,
3603 rects,
3604 middlewareData
3605 } = state;
3606 const {
3607 offset: offset4 = 0,
3608 mainAxis: checkMainAxis = true,
3609 crossAxis: checkCrossAxis = true
3610 } = evaluate(options, state);
3611 const coords = {
3612 x,
3613 y
3614 };
3615 const crossAxis = getSideAxis(placement);
3616 const mainAxis = getOppositeAxis(crossAxis);
3617 let mainAxisCoord = coords[mainAxis];
3618 let crossAxisCoord = coords[crossAxis];
3619 const rawOffset = evaluate(offset4, state);
3620 const computedOffset = typeof rawOffset === "number" ? {
3621 mainAxis: rawOffset,
3622 crossAxis: 0
3623 } : {
3624 mainAxis: 0,
3625 crossAxis: 0,
3626 ...rawOffset
3627 };
3628 if (checkMainAxis) {
3629 const len = mainAxis === "y" ? "height" : "width";
3630 const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
3631 const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
3632 if (mainAxisCoord < limitMin) {
3633 mainAxisCoord = limitMin;
3634 } else if (mainAxisCoord > limitMax) {
3635 mainAxisCoord = limitMax;
3636 }
3637 }
3638 if (checkCrossAxis) {
3639 var _middlewareData$offse, _middlewareData$offse2;
3640 const len = mainAxis === "y" ? "width" : "height";
3641 const isOriginSide = originSides.has(getSide(placement));
3642 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);
3643 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);
3644 if (crossAxisCoord < limitMin) {
3645 crossAxisCoord = limitMin;
3646 } else if (crossAxisCoord > limitMax) {
3647 crossAxisCoord = limitMax;
3648 }
3649 }
3650 return {
3651 [mainAxis]: mainAxisCoord,
3652 [crossAxis]: crossAxisCoord
3653 };
3654 }
3655 };
3656 };
3657 var size = function(options) {
3658 if (options === void 0) {
3659 options = {};
3660 }
3661 return {
3662 name: "size",
3663 options,
3664 async fn(state) {
3665 var _state$middlewareData, _state$middlewareData2;
3666 const {
3667 placement,
3668 rects,
3669 platform: platform3,
3670 elements
3671 } = state;
3672 const {
3673 apply = () => {
3674 },
3675 ...detectOverflowOptions
3676 } = evaluate(options, state);
3677 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
3678 const side = getSide(placement);
3679 const alignment = getAlignment(placement);
3680 const isYAxis = getSideAxis(placement) === "y";
3681 const {
3682 width,
3683 height
3684 } = rects.floating;
3685 let heightSide;
3686 let widthSide;
3687 if (side === "top" || side === "bottom") {
3688 heightSide = side;
3689 widthSide = alignment === (await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
3690 } else {
3691 widthSide = side;
3692 heightSide = alignment === "end" ? "top" : "bottom";
3693 }
3694 const maximumClippingHeight = height - overflow.top - overflow.bottom;
3695 const maximumClippingWidth = width - overflow.left - overflow.right;
3696 const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
3697 const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
3698 const noShift = !state.middlewareData.shift;
3699 let availableHeight = overflowAvailableHeight;
3700 let availableWidth = overflowAvailableWidth;
3701 if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
3702 availableWidth = maximumClippingWidth;
3703 }
3704 if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
3705 availableHeight = maximumClippingHeight;
3706 }
3707 if (noShift && !alignment) {
3708 const xMin = max(overflow.left, 0);
3709 const xMax = max(overflow.right, 0);
3710 const yMin = max(overflow.top, 0);
3711 const yMax = max(overflow.bottom, 0);
3712 if (isYAxis) {
3713 availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
3714 } else {
3715 availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
3716 }
3717 }
3718 await apply({
3719 ...state,
3720 availableWidth,
3721 availableHeight
3722 });
3723 const nextDimensions = await platform3.getDimensions(elements.floating);
3724 if (width !== nextDimensions.width || height !== nextDimensions.height) {
3725 return {
3726 reset: {
3727 rects: true
3728 }
3729 };
3730 }
3731 return {};
3732 }
3733 };
3734 };
3735
3736 // node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs
3737 function getCssDimensions(element) {
3738 const css = getComputedStyle2(element);
3739 let width = parseFloat(css.width) || 0;
3740 let height = parseFloat(css.height) || 0;
3741 const hasOffset = isHTMLElement(element);
3742 const offsetWidth = hasOffset ? element.offsetWidth : width;
3743 const offsetHeight = hasOffset ? element.offsetHeight : height;
3744 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
3745 if (shouldFallback) {
3746 width = offsetWidth;
3747 height = offsetHeight;
3748 }
3749 return {
3750 width,
3751 height,
3752 $: shouldFallback
3753 };
3754 }
3755 function unwrapElement(element) {
3756 return !isElement(element) ? element.contextElement : element;
3757 }
3758 function getScale(element) {
3759 const domElement = unwrapElement(element);
3760 if (!isHTMLElement(domElement)) {
3761 return createCoords(1);
3762 }
3763 const rect = domElement.getBoundingClientRect();
3764 const {
3765 width,
3766 height,
3767 $
3768 } = getCssDimensions(domElement);
3769 let x = ($ ? round(rect.width) : rect.width) / width;
3770 let y = ($ ? round(rect.height) : rect.height) / height;
3771 if (!x || !Number.isFinite(x)) {
3772 x = 1;
3773 }
3774 if (!y || !Number.isFinite(y)) {
3775 y = 1;
3776 }
3777 return {
3778 x,
3779 y
3780 };
3781 }
3782 var noOffsets = /* @__PURE__ */ createCoords(0);
3783 function getVisualOffsets(element) {
3784 const win = getWindow(element);
3785 if (!isWebKit() || !win.visualViewport) {
3786 return noOffsets;
3787 }
3788 return {
3789 x: win.visualViewport.offsetLeft,
3790 y: win.visualViewport.offsetTop
3791 };
3792 }
3793 function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
3794 if (isFixed === void 0) {
3795 isFixed = false;
3796 }
3797 if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
3798 return false;
3799 }
3800 return isFixed;
3801 }
3802 function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
3803 if (includeScale === void 0) {
3804 includeScale = false;
3805 }
3806 if (isFixedStrategy === void 0) {
3807 isFixedStrategy = false;
3808 }
3809 const clientRect = element.getBoundingClientRect();
3810 const domElement = unwrapElement(element);
3811 let scale = createCoords(1);
3812 if (includeScale) {
3813 if (offsetParent) {
3814 if (isElement(offsetParent)) {
3815 scale = getScale(offsetParent);
3816 }
3817 } else {
3818 scale = getScale(element);
3819 }
3820 }
3821 const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
3822 let x = (clientRect.left + visualOffsets.x) / scale.x;
3823 let y = (clientRect.top + visualOffsets.y) / scale.y;
3824 let width = clientRect.width / scale.x;
3825 let height = clientRect.height / scale.y;
3826 if (domElement) {
3827 const win = getWindow(domElement);
3828 const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
3829 let currentWin = win;
3830 let currentIFrame = getFrameElement(currentWin);
3831 while (currentIFrame && offsetParent && offsetWin !== currentWin) {
3832 const iframeScale = getScale(currentIFrame);
3833 const iframeRect = currentIFrame.getBoundingClientRect();
3834 const css = getComputedStyle2(currentIFrame);
3835 const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
3836 const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
3837 x *= iframeScale.x;
3838 y *= iframeScale.y;
3839 width *= iframeScale.x;
3840 height *= iframeScale.y;
3841 x += left;
3842 y += top;
3843 currentWin = getWindow(currentIFrame);
3844 currentIFrame = getFrameElement(currentWin);
3845 }
3846 }
3847 return rectToClientRect({
3848 width,
3849 height,
3850 x,
3851 y
3852 });
3853 }
3854 function getWindowScrollBarX(element, rect) {
3855 const leftScroll = getNodeScroll(element).scrollLeft;
3856 if (!rect) {
3857 return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
3858 }
3859 return rect.left + leftScroll;
3860 }
3861 function getHTMLOffset(documentElement, scroll) {
3862 const htmlRect = documentElement.getBoundingClientRect();
3863 const x = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
3864 const y = htmlRect.top + scroll.scrollTop;
3865 return {
3866 x,
3867 y
3868 };
3869 }
3870 function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
3871 let {
3872 elements,
3873 rect,
3874 offsetParent,
3875 strategy
3876 } = _ref;
3877 const isFixed = strategy === "fixed";
3878 const documentElement = getDocumentElement(offsetParent);
3879 const topLayer = elements ? isTopLayer(elements.floating) : false;
3880 if (offsetParent === documentElement || topLayer && isFixed) {
3881 return rect;
3882 }
3883 let scroll = {
3884 scrollLeft: 0,
3885 scrollTop: 0
3886 };
3887 let scale = createCoords(1);
3888 const offsets = createCoords(0);
3889 const isOffsetParentAnElement = isHTMLElement(offsetParent);
3890 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
3891 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
3892 scroll = getNodeScroll(offsetParent);
3893 }
3894 if (isOffsetParentAnElement) {
3895 const offsetRect = getBoundingClientRect(offsetParent);
3896 scale = getScale(offsetParent);
3897 offsets.x = offsetRect.x + offsetParent.clientLeft;
3898 offsets.y = offsetRect.y + offsetParent.clientTop;
3899 }
3900 }
3901 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
3902 return {
3903 width: rect.width * scale.x,
3904 height: rect.height * scale.y,
3905 x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
3906 y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
3907 };
3908 }
3909 function getClientRects(element) {
3910 return Array.from(element.getClientRects());
3911 }
3912 function getDocumentRect(element) {
3913 const html = getDocumentElement(element);
3914 const scroll = getNodeScroll(element);
3915 const body = element.ownerDocument.body;
3916 const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
3917 const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
3918 let x = -scroll.scrollLeft + getWindowScrollBarX(element);
3919 const y = -scroll.scrollTop;
3920 if (getComputedStyle2(body).direction === "rtl") {
3921 x += max(html.clientWidth, body.clientWidth) - width;
3922 }
3923 return {
3924 width,
3925 height,
3926 x,
3927 y
3928 };
3929 }
3930 var SCROLLBAR_MAX = 25;
3931 function getViewportRect(element, strategy) {
3932 const win = getWindow(element);
3933 const html = getDocumentElement(element);
3934 const visualViewport = win.visualViewport;
3935 let width = html.clientWidth;
3936 let height = html.clientHeight;
3937 let x = 0;
3938 let y = 0;
3939 if (visualViewport) {
3940 width = visualViewport.width;
3941 height = visualViewport.height;
3942 const visualViewportBased = isWebKit();
3943 if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
3944 x = visualViewport.offsetLeft;
3945 y = visualViewport.offsetTop;
3946 }
3947 }
3948 const windowScrollbarX = getWindowScrollBarX(html);
3949 if (windowScrollbarX <= 0) {
3950 const doc = html.ownerDocument;
3951 const body = doc.body;
3952 const bodyStyles = getComputedStyle(body);
3953 const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
3954 const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
3955 if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
3956 width -= clippingStableScrollbarWidth;
3957 }
3958 } else if (windowScrollbarX <= SCROLLBAR_MAX) {
3959 width += windowScrollbarX;
3960 }
3961 return {
3962 width,
3963 height,
3964 x,
3965 y
3966 };
3967 }
3968 function getInnerBoundingClientRect(element, strategy) {
3969 const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
3970 const top = clientRect.top + element.clientTop;
3971 const left = clientRect.left + element.clientLeft;
3972 const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
3973 const width = element.clientWidth * scale.x;
3974 const height = element.clientHeight * scale.y;
3975 const x = left * scale.x;
3976 const y = top * scale.y;
3977 return {
3978 width,
3979 height,
3980 x,
3981 y
3982 };
3983 }
3984 function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
3985 let rect;
3986 if (clippingAncestor === "viewport") {
3987 rect = getViewportRect(element, strategy);
3988 } else if (clippingAncestor === "document") {
3989 rect = getDocumentRect(getDocumentElement(element));
3990 } else if (isElement(clippingAncestor)) {
3991 rect = getInnerBoundingClientRect(clippingAncestor, strategy);
3992 } else {
3993 const visualOffsets = getVisualOffsets(element);
3994 rect = {
3995 x: clippingAncestor.x - visualOffsets.x,
3996 y: clippingAncestor.y - visualOffsets.y,
3997 width: clippingAncestor.width,
3998 height: clippingAncestor.height
3999 };
4000 }
4001 return rectToClientRect(rect);
4002 }
4003 function hasFixedPositionAncestor(element, stopNode) {
4004 const parentNode = getParentNode(element);
4005 if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
4006 return false;
4007 }
4008 return getComputedStyle2(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
4009 }
4010 function getClippingElementAncestors(element, cache) {
4011 const cachedResult = cache.get(element);
4012 if (cachedResult) {
4013 return cachedResult;
4014 }
4015 let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
4016 let currentContainingBlockComputedStyle = null;
4017 const elementIsFixed = getComputedStyle2(element).position === "fixed";
4018 let currentNode = elementIsFixed ? getParentNode(element) : element;
4019 while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
4020 const computedStyle = getComputedStyle2(currentNode);
4021 const currentNodeIsContaining = isContainingBlock(currentNode);
4022 if (!currentNodeIsContaining && computedStyle.position === "fixed") {
4023 currentContainingBlockComputedStyle = null;
4024 }
4025 const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && (currentContainingBlockComputedStyle.position === "absolute" || currentContainingBlockComputedStyle.position === "fixed") || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
4026 if (shouldDropCurrentNode) {
4027 result = result.filter((ancestor) => ancestor !== currentNode);
4028 } else {
4029 currentContainingBlockComputedStyle = computedStyle;
4030 }
4031 currentNode = getParentNode(currentNode);
4032 }
4033 cache.set(element, result);
4034 return result;
4035 }
4036 function getClippingRect(_ref) {
4037 let {
4038 element,
4039 boundary,
4040 rootBoundary,
4041 strategy
4042 } = _ref;
4043 const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
4044 const clippingAncestors = [...elementClippingAncestors, rootBoundary];
4045 const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy);
4046 let top = firstRect.top;
4047 let right = firstRect.right;
4048 let bottom = firstRect.bottom;
4049 let left = firstRect.left;
4050 for (let i = 1; i < clippingAncestors.length; i++) {
4051 const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i], strategy);
4052 top = max(rect.top, top);
4053 right = min(rect.right, right);
4054 bottom = min(rect.bottom, bottom);
4055 left = max(rect.left, left);
4056 }
4057 return {
4058 width: right - left,
4059 height: bottom - top,
4060 x: left,
4061 y: top
4062 };
4063 }
4064 function getDimensions(element) {
4065 const {
4066 width,
4067 height
4068 } = getCssDimensions(element);
4069 return {
4070 width,
4071 height
4072 };
4073 }
4074 function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
4075 const isOffsetParentAnElement = isHTMLElement(offsetParent);
4076 const documentElement = getDocumentElement(offsetParent);
4077 const isFixed = strategy === "fixed";
4078 const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
4079 let scroll = {
4080 scrollLeft: 0,
4081 scrollTop: 0
4082 };
4083 const offsets = createCoords(0);
4084 function setLeftRTLScrollbarOffset() {
4085 offsets.x = getWindowScrollBarX(documentElement);
4086 }
4087 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
4088 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
4089 scroll = getNodeScroll(offsetParent);
4090 }
4091 if (isOffsetParentAnElement) {
4092 const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
4093 offsets.x = offsetRect.x + offsetParent.clientLeft;
4094 offsets.y = offsetRect.y + offsetParent.clientTop;
4095 } else if (documentElement) {
4096 setLeftRTLScrollbarOffset();
4097 }
4098 }
4099 if (isFixed && !isOffsetParentAnElement && documentElement) {
4100 setLeftRTLScrollbarOffset();
4101 }
4102 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
4103 const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
4104 const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
4105 return {
4106 x,
4107 y,
4108 width: rect.width,
4109 height: rect.height
4110 };
4111 }
4112 function isStaticPositioned(element) {
4113 return getComputedStyle2(element).position === "static";
4114 }
4115 function getTrueOffsetParent(element, polyfill) {
4116 if (!isHTMLElement(element) || getComputedStyle2(element).position === "fixed") {
4117 return null;
4118 }
4119 if (polyfill) {
4120 return polyfill(element);
4121 }
4122 let rawOffsetParent = element.offsetParent;
4123 if (getDocumentElement(element) === rawOffsetParent) {
4124 rawOffsetParent = rawOffsetParent.ownerDocument.body;
4125 }
4126 return rawOffsetParent;
4127 }
4128 function getOffsetParent(element, polyfill) {
4129 const win = getWindow(element);
4130 if (isTopLayer(element)) {
4131 return win;
4132 }
4133 if (!isHTMLElement(element)) {
4134 let svgOffsetParent = getParentNode(element);
4135 while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
4136 if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
4137 return svgOffsetParent;
4138 }
4139 svgOffsetParent = getParentNode(svgOffsetParent);
4140 }
4141 return win;
4142 }
4143 let offsetParent = getTrueOffsetParent(element, polyfill);
4144 while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
4145 offsetParent = getTrueOffsetParent(offsetParent, polyfill);
4146 }
4147 if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
4148 return win;
4149 }
4150 return offsetParent || getContainingBlock(element) || win;
4151 }
4152 var getElementRects = async function(data) {
4153 const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
4154 const getDimensionsFn = this.getDimensions;
4155 const floatingDimensions = await getDimensionsFn(data.floating);
4156 return {
4157 reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
4158 floating: {
4159 x: 0,
4160 y: 0,
4161 width: floatingDimensions.width,
4162 height: floatingDimensions.height
4163 }
4164 };
4165 };
4166 function isRTL(element) {
4167 return getComputedStyle2(element).direction === "rtl";
4168 }
4169 var platform2 = {
4170 convertOffsetParentRelativeRectToViewportRelativeRect,
4171 getDocumentElement,
4172 getClippingRect,
4173 getOffsetParent,
4174 getElementRects,
4175 getClientRects,
4176 getDimensions,
4177 getScale,
4178 isElement,
4179 isRTL
4180 };
4181 function rectsAreEqual(a, b) {
4182 return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
4183 }
4184 function observeMove(element, onMove) {
4185 let io = null;
4186 let timeoutId;
4187 const root = getDocumentElement(element);
4188 function cleanup() {
4189 var _io;
4190 clearTimeout(timeoutId);
4191 (_io = io) == null || _io.disconnect();
4192 io = null;
4193 }
4194 function refresh(skip, threshold) {
4195 if (skip === void 0) {
4196 skip = false;
4197 }
4198 if (threshold === void 0) {
4199 threshold = 1;
4200 }
4201 cleanup();
4202 const elementRectForRootMargin = element.getBoundingClientRect();
4203 const {
4204 left,
4205 top,
4206 width,
4207 height
4208 } = elementRectForRootMargin;
4209 if (!skip) {
4210 onMove();
4211 }
4212 if (!width || !height) {
4213 return;
4214 }
4215 const insetTop = floor(top);
4216 const insetRight = floor(root.clientWidth - (left + width));
4217 const insetBottom = floor(root.clientHeight - (top + height));
4218 const insetLeft = floor(left);
4219 const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
4220 const options = {
4221 rootMargin,
4222 threshold: max(0, min(1, threshold)) || 1
4223 };
4224 let isFirstUpdate = true;
4225 function handleObserve(entries) {
4226 const ratio = entries[0].intersectionRatio;
4227 if (ratio !== threshold) {
4228 if (!isFirstUpdate) {
4229 return refresh();
4230 }
4231 if (!ratio) {
4232 timeoutId = setTimeout(() => {
4233 refresh(false, 1e-7);
4234 }, 1e3);
4235 } else {
4236 refresh(false, ratio);
4237 }
4238 }
4239 if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
4240 refresh();
4241 }
4242 isFirstUpdate = false;
4243 }
4244 try {
4245 io = new IntersectionObserver(handleObserve, {
4246 ...options,
4247 // Handle <iframe>s
4248 root: root.ownerDocument
4249 });
4250 } catch (_e) {
4251 io = new IntersectionObserver(handleObserve, options);
4252 }
4253 io.observe(element);
4254 }
4255 refresh(true);
4256 return cleanup;
4257 }
4258 function autoUpdate(reference, floating, update2, options) {
4259 if (options === void 0) {
4260 options = {};
4261 }
4262 const {
4263 ancestorScroll = true,
4264 ancestorResize = true,
4265 elementResize = typeof ResizeObserver === "function",
4266 layoutShift = typeof IntersectionObserver === "function",
4267 animationFrame = false
4268 } = options;
4269 const referenceEl = unwrapElement(reference);
4270 const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...floating ? getOverflowAncestors(floating) : []] : [];
4271 ancestors.forEach((ancestor) => {
4272 ancestorScroll && ancestor.addEventListener("scroll", update2, {
4273 passive: true
4274 });
4275 ancestorResize && ancestor.addEventListener("resize", update2);
4276 });
4277 const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update2) : null;
4278 let reobserveFrame = -1;
4279 let resizeObserver = null;
4280 if (elementResize) {
4281 resizeObserver = new ResizeObserver((_ref) => {
4282 let [firstEntry] = _ref;
4283 if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) {
4284 resizeObserver.unobserve(floating);
4285 cancelAnimationFrame(reobserveFrame);
4286 reobserveFrame = requestAnimationFrame(() => {
4287 var _resizeObserver;
4288 (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
4289 });
4290 }
4291 update2();
4292 });
4293 if (referenceEl && !animationFrame) {
4294 resizeObserver.observe(referenceEl);
4295 }
4296 if (floating) {
4297 resizeObserver.observe(floating);
4298 }
4299 }
4300 let frameId;
4301 let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
4302 if (animationFrame) {
4303 frameLoop();
4304 }
4305 function frameLoop() {
4306 const nextRefRect = getBoundingClientRect(reference);
4307 if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
4308 update2();
4309 }
4310 prevRefRect = nextRefRect;
4311 frameId = requestAnimationFrame(frameLoop);
4312 }
4313 update2();
4314 return () => {
4315 var _resizeObserver2;
4316 ancestors.forEach((ancestor) => {
4317 ancestorScroll && ancestor.removeEventListener("scroll", update2);
4318 ancestorResize && ancestor.removeEventListener("resize", update2);
4319 });
4320 cleanupIo == null || cleanupIo();
4321 (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
4322 resizeObserver = null;
4323 if (animationFrame) {
4324 cancelAnimationFrame(frameId);
4325 }
4326 };
4327 }
4328 var offset2 = offset;
4329 var shift2 = shift;
4330 var flip2 = flip;
4331 var size2 = size;
4332 var hide2 = hide;
4333 var limitShift2 = limitShift;
4334 var computePosition2 = (reference, floating, options) => {
4335 const cache = /* @__PURE__ */ new Map();
4336 const mergedOptions = {
4337 platform: platform2,
4338 ...options
4339 };
4340 const platformWithCache = {
4341 ...mergedOptions.platform,
4342 _c: cache
4343 };
4344 return computePosition(reference, floating, {
4345 ...mergedOptions,
4346 platform: platformWithCache
4347 });
4348 };
4349
4350 // node_modules/@base-ui/react/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.mjs
4351 var React19 = __toESM(require_react(), 1);
4352 var import_react2 = __toESM(require_react(), 1);
4353 var ReactDOM3 = __toESM(require_react_dom(), 1);
4354 var isClient = typeof document !== "undefined";
4355 var noop2 = function noop3() {
4356 };
4357 var index = isClient ? import_react2.useLayoutEffect : noop2;
4358 function deepEqual(a, b) {
4359 if (a === b) {
4360 return true;
4361 }
4362 if (typeof a !== typeof b) {
4363 return false;
4364 }
4365 if (typeof a === "function" && a.toString() === b.toString()) {
4366 return true;
4367 }
4368 let length;
4369 let i;
4370 let keys;
4371 if (a && b && typeof a === "object") {
4372 if (Array.isArray(a)) {
4373 length = a.length;
4374 if (length !== b.length) return false;
4375 for (i = length; i-- !== 0; ) {
4376 if (!deepEqual(a[i], b[i])) {
4377 return false;
4378 }
4379 }
4380 return true;
4381 }
4382 keys = Object.keys(a);
4383 length = keys.length;
4384 if (length !== Object.keys(b).length) {
4385 return false;
4386 }
4387 for (i = length; i-- !== 0; ) {
4388 if (!{}.hasOwnProperty.call(b, keys[i])) {
4389 return false;
4390 }
4391 }
4392 for (i = length; i-- !== 0; ) {
4393 const key = keys[i];
4394 if (key === "_owner" && a.$$typeof) {
4395 continue;
4396 }
4397 if (!deepEqual(a[key], b[key])) {
4398 return false;
4399 }
4400 }
4401 return true;
4402 }
4403 return a !== a && b !== b;
4404 }
4405 function getDPR(element) {
4406 if (typeof window === "undefined") {
4407 return 1;
4408 }
4409 const win = element.ownerDocument.defaultView || window;
4410 return win.devicePixelRatio || 1;
4411 }
4412 function roundByDPR(element, value) {
4413 const dpr = getDPR(element);
4414 return Math.round(value * dpr) / dpr;
4415 }
4416 function useLatestRef(value) {
4417 const ref = React19.useRef(value);
4418 index(() => {
4419 ref.current = value;
4420 });
4421 return ref;
4422 }
4423 function useFloating(options) {
4424 if (options === void 0) {
4425 options = {};
4426 }
4427 const {
4428 placement = "bottom",
4429 strategy = "absolute",
4430 middleware = [],
4431 platform: platform3,
4432 elements: {
4433 reference: externalReference,
4434 floating: externalFloating
4435 } = {},
4436 transform = true,
4437 whileElementsMounted,
4438 open
4439 } = options;
4440 const [data, setData] = React19.useState({
4441 x: 0,
4442 y: 0,
4443 strategy,
4444 placement,
4445 middlewareData: {},
4446 isPositioned: false
4447 });
4448 const [latestMiddleware, setLatestMiddleware] = React19.useState(middleware);
4449 if (!deepEqual(latestMiddleware, middleware)) {
4450 setLatestMiddleware(middleware);
4451 }
4452 const [_reference, _setReference] = React19.useState(null);
4453 const [_floating, _setFloating] = React19.useState(null);
4454 const setReference = React19.useCallback((node) => {
4455 if (node !== referenceRef.current) {
4456 referenceRef.current = node;
4457 _setReference(node);
4458 }
4459 }, []);
4460 const setFloating = React19.useCallback((node) => {
4461 if (node !== floatingRef.current) {
4462 floatingRef.current = node;
4463 _setFloating(node);
4464 }
4465 }, []);
4466 const referenceEl = externalReference || _reference;
4467 const floatingEl = externalFloating || _floating;
4468 const referenceRef = React19.useRef(null);
4469 const floatingRef = React19.useRef(null);
4470 const dataRef = React19.useRef(data);
4471 const hasWhileElementsMounted = whileElementsMounted != null;
4472 const whileElementsMountedRef = useLatestRef(whileElementsMounted);
4473 const platformRef = useLatestRef(platform3);
4474 const openRef = useLatestRef(open);
4475 const update2 = React19.useCallback(() => {
4476 if (!referenceRef.current || !floatingRef.current) {
4477 return;
4478 }
4479 const config = {
4480 placement,
4481 strategy,
4482 middleware: latestMiddleware
4483 };
4484 if (platformRef.current) {
4485 config.platform = platformRef.current;
4486 }
4487 computePosition2(referenceRef.current, floatingRef.current, config).then((data2) => {
4488 const fullData = {
4489 ...data2,
4490 // The floating element's position may be recomputed while it's closed
4491 // but still mounted (such as when transitioning out). To ensure
4492 // `isPositioned` will be `false` initially on the next open, avoid
4493 // setting it to `true` when `open === false` (must be specified).
4494 isPositioned: openRef.current !== false
4495 };
4496 if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
4497 dataRef.current = fullData;
4498 ReactDOM3.flushSync(() => {
4499 setData(fullData);
4500 });
4501 }
4502 });
4503 }, [latestMiddleware, placement, strategy, platformRef, openRef]);
4504 index(() => {
4505 if (open === false && dataRef.current.isPositioned) {
4506 dataRef.current.isPositioned = false;
4507 setData((data2) => ({
4508 ...data2,
4509 isPositioned: false
4510 }));
4511 }
4512 }, [open]);
4513 const isMountedRef = React19.useRef(false);
4514 index(() => {
4515 isMountedRef.current = true;
4516 return () => {
4517 isMountedRef.current = false;
4518 };
4519 }, []);
4520 index(() => {
4521 if (referenceEl) referenceRef.current = referenceEl;
4522 if (floatingEl) floatingRef.current = floatingEl;
4523 if (referenceEl && floatingEl) {
4524 if (whileElementsMountedRef.current) {
4525 return whileElementsMountedRef.current(referenceEl, floatingEl, update2);
4526 }
4527 update2();
4528 }
4529 }, [referenceEl, floatingEl, update2, whileElementsMountedRef, hasWhileElementsMounted]);
4530 const refs = React19.useMemo(() => ({
4531 reference: referenceRef,
4532 floating: floatingRef,
4533 setReference,
4534 setFloating
4535 }), [setReference, setFloating]);
4536 const elements = React19.useMemo(() => ({
4537 reference: referenceEl,
4538 floating: floatingEl
4539 }), [referenceEl, floatingEl]);
4540 const floatingStyles = React19.useMemo(() => {
4541 const initialStyles = {
4542 position: strategy,
4543 left: 0,
4544 top: 0
4545 };
4546 if (!elements.floating) {
4547 return initialStyles;
4548 }
4549 const x = roundByDPR(elements.floating, data.x);
4550 const y = roundByDPR(elements.floating, data.y);
4551 if (transform) {
4552 return {
4553 ...initialStyles,
4554 transform: "translate(" + x + "px, " + y + "px)",
4555 ...getDPR(elements.floating) >= 1.5 && {
4556 willChange: "transform"
4557 }
4558 };
4559 }
4560 return {
4561 position: strategy,
4562 left: x,
4563 top: y
4564 };
4565 }, [strategy, transform, elements.floating, data.x, data.y]);
4566 return React19.useMemo(() => ({
4567 ...data,
4568 update: update2,
4569 refs,
4570 elements,
4571 floatingStyles
4572 }), [data, update2, refs, elements, floatingStyles]);
4573 }
4574 var offset3 = (options, deps) => {
4575 const result = offset2(options);
4576 return {
4577 name: result.name,
4578 fn: result.fn,
4579 options: [options, deps]
4580 };
4581 };
4582 var shift3 = (options, deps) => {
4583 const result = shift2(options);
4584 return {
4585 name: result.name,
4586 fn: result.fn,
4587 options: [options, deps]
4588 };
4589 };
4590 var limitShift3 = (options, deps) => {
4591 const result = limitShift2(options);
4592 return {
4593 fn: result.fn,
4594 options: [options, deps]
4595 };
4596 };
4597 var flip3 = (options, deps) => {
4598 const result = flip2(options);
4599 return {
4600 name: result.name,
4601 fn: result.fn,
4602 options: [options, deps]
4603 };
4604 };
4605 var size3 = (options, deps) => {
4606 const result = size2(options);
4607 return {
4608 name: result.name,
4609 fn: result.fn,
4610 options: [options, deps]
4611 };
4612 };
4613 var hide3 = (options, deps) => {
4614 const result = hide2(options);
4615 return {
4616 name: result.name,
4617 fn: result.fn,
4618 options: [options, deps]
4619 };
4620 };
4621
4622 // node_modules/@base-ui/react/esm/utils/popups/popupStoreUtils.js
4623 var React24 = __toESM(require_react(), 1);
4624
4625 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useSyncedFloatingRootContext.js
4626 var React23 = __toESM(require_react(), 1);
4627
4628 // node_modules/@base-ui/utils/esm/store/createSelector.js
4629 var createSelector = (a, b, c, d, e, f, ...other) => {
4630 if (other.length > 0) {
4631 throw new Error(true ? "Unsupported number of selectors" : formatErrorMessage_default(1));
4632 }
4633 let selector;
4634 if (a && b && c && d && e && f) {
4635 selector = (state, a1, a2, a3) => {
4636 const va = a(state, a1, a2, a3);
4637 const vb = b(state, a1, a2, a3);
4638 const vc = c(state, a1, a2, a3);
4639 const vd = d(state, a1, a2, a3);
4640 const ve = e(state, a1, a2, a3);
4641 return f(va, vb, vc, vd, ve, a1, a2, a3);
4642 };
4643 } else if (a && b && c && d && e) {
4644 selector = (state, a1, a2, a3) => {
4645 const va = a(state, a1, a2, a3);
4646 const vb = b(state, a1, a2, a3);
4647 const vc = c(state, a1, a2, a3);
4648 const vd = d(state, a1, a2, a3);
4649 return e(va, vb, vc, vd, a1, a2, a3);
4650 };
4651 } else if (a && b && c && d) {
4652 selector = (state, a1, a2, a3) => {
4653 const va = a(state, a1, a2, a3);
4654 const vb = b(state, a1, a2, a3);
4655 const vc = c(state, a1, a2, a3);
4656 return d(va, vb, vc, a1, a2, a3);
4657 };
4658 } else if (a && b && c) {
4659 selector = (state, a1, a2, a3) => {
4660 const va = a(state, a1, a2, a3);
4661 const vb = b(state, a1, a2, a3);
4662 return c(va, vb, a1, a2, a3);
4663 };
4664 } else if (a && b) {
4665 selector = (state, a1, a2, a3) => {
4666 const va = a(state, a1, a2, a3);
4667 return b(va, a1, a2, a3);
4668 };
4669 } else if (a) {
4670 selector = a;
4671 } else {
4672 throw (
4673 /* minify-error-disabled */
4674 new Error("Missing arguments")
4675 );
4676 }
4677 return selector;
4678 };
4679
4680 // node_modules/@base-ui/utils/esm/store/useStore.js
4681 var React21 = __toESM(require_react(), 1);
4682 var import_shim = __toESM(require_shim(), 1);
4683 var import_with_selector = __toESM(require_with_selector(), 1);
4684
4685 // node_modules/@base-ui/utils/esm/fastHooks.js
4686 var React20 = __toESM(require_react(), 1);
4687 var hooks = [];
4688 var currentInstance = void 0;
4689 function getInstance() {
4690 return currentInstance;
4691 }
4692 function register(hook) {
4693 hooks.push(hook);
4694 }
4695 function fastComponent(fn) {
4696 const FastComponent = (props, forwardedRef) => {
4697 const instance = useRefWithInit(createInstance).current;
4698 let result;
4699 try {
4700 currentInstance = instance;
4701 for (const hook of hooks) {
4702 hook.before(instance);
4703 }
4704 result = fn(props, forwardedRef);
4705 for (const hook of hooks) {
4706 hook.after(instance);
4707 }
4708 instance.didInitialize = true;
4709 } finally {
4710 currentInstance = void 0;
4711 }
4712 return result;
4713 };
4714 FastComponent.displayName = fn.displayName || fn.name;
4715 return FastComponent;
4716 }
4717 function fastComponentRef(fn) {
4718 return /* @__PURE__ */ React20.forwardRef(fastComponent(fn));
4719 }
4720 function createInstance() {
4721 return {
4722 didInitialize: false
4723 };
4724 }
4725
4726 // node_modules/@base-ui/utils/esm/store/useStore.js
4727 var canUseRawUseSyncExternalStore = isReactVersionAtLeast(19);
4728 var useStoreImplementation = canUseRawUseSyncExternalStore ? useStoreFast : useStoreLegacy;
4729 function useStore(store2, selector, a1, a2, a3) {
4730 return useStoreImplementation(store2, selector, a1, a2, a3);
4731 }
4732 function useStoreR19(store2, selector, a1, a2, a3) {
4733 const getSelection = React21.useCallback(() => selector(store2.getSnapshot(), a1, a2, a3), [store2, selector, a1, a2, a3]);
4734 return (0, import_shim.useSyncExternalStore)(store2.subscribe, getSelection, getSelection);
4735 }
4736 register({
4737 before(instance) {
4738 instance.syncIndex = 0;
4739 if (!instance.didInitialize) {
4740 instance.syncTick = 1;
4741 instance.syncHooks = [];
4742 instance.didChangeStore = true;
4743 instance.getSnapshot = () => {
4744 let didChange2 = false;
4745 for (let i = 0; i < instance.syncHooks.length; i += 1) {
4746 const hook = instance.syncHooks[i];
4747 const value = hook.selector(hook.store.state, hook.a1, hook.a2, hook.a3);
4748 if (hook.didChange || !Object.is(hook.value, value)) {
4749 didChange2 = true;
4750 hook.value = value;
4751 hook.didChange = false;
4752 }
4753 }
4754 if (didChange2) {
4755 instance.syncTick += 1;
4756 }
4757 return instance.syncTick;
4758 };
4759 }
4760 },
4761 after(instance) {
4762 if (instance.syncHooks.length > 0) {
4763 if (instance.didChangeStore) {
4764 instance.didChangeStore = false;
4765 instance.subscribe = (onStoreChange) => {
4766 const stores = /* @__PURE__ */ new Set();
4767 for (const hook of instance.syncHooks) {
4768 stores.add(hook.store);
4769 }
4770 const unsubscribes = [];
4771 for (const store2 of stores) {
4772 unsubscribes.push(store2.subscribe(onStoreChange));
4773 }
4774 return () => {
4775 for (const unsubscribe of unsubscribes) {
4776 unsubscribe();
4777 }
4778 };
4779 };
4780 }
4781 (0, import_shim.useSyncExternalStore)(instance.subscribe, instance.getSnapshot, instance.getSnapshot);
4782 }
4783 }
4784 });
4785 function useStoreFast(store2, selector, a1, a2, a3) {
4786 const instance = getInstance();
4787 if (!instance) {
4788 return useStoreR19(store2, selector, a1, a2, a3);
4789 }
4790 const index2 = instance.syncIndex;
4791 instance.syncIndex += 1;
4792 let hook;
4793 if (!instance.didInitialize) {
4794 hook = {
4795 store: store2,
4796 selector,
4797 a1,
4798 a2,
4799 a3,
4800 value: selector(store2.getSnapshot(), a1, a2, a3),
4801 didChange: false
4802 };
4803 instance.syncHooks.push(hook);
4804 } else {
4805 hook = instance.syncHooks[index2];
4806 if (hook.store !== store2 || hook.selector !== selector || !Object.is(hook.a1, a1) || !Object.is(hook.a2, a2) || !Object.is(hook.a3, a3)) {
4807 if (hook.store !== store2) {
4808 instance.didChangeStore = true;
4809 }
4810 hook.store = store2;
4811 hook.selector = selector;
4812 hook.a1 = a1;
4813 hook.a2 = a2;
4814 hook.a3 = a3;
4815 hook.didChange = true;
4816 }
4817 }
4818 return hook.value;
4819 }
4820 function useStoreLegacy(store2, selector, a1, a2, a3) {
4821 return (0, import_with_selector.useSyncExternalStoreWithSelector)(store2.subscribe, store2.getSnapshot, store2.getSnapshot, (state) => selector(state, a1, a2, a3));
4822 }
4823
4824 // node_modules/@base-ui/utils/esm/store/Store.js
4825 var Store = class {
4826 /**
4827 * The current state of the store.
4828 * This property is updated immediately when the state changes as a result of calling {@link setState}, {@link update}, or {@link set}.
4829 * 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).
4830 * The values can be used directly (to avoid subscribing to the store) in effects or event handlers.
4831 *
4832 * Do not modify properties in state directly. Instead, use the provided methods to ensure proper state management and listener notification.
4833 */
4834 // Internal state to handle recursive `setState()` calls
4835 constructor(state) {
4836 this.state = state;
4837 this.listeners = /* @__PURE__ */ new Set();
4838 this.updateTick = 0;
4839 }
4840 /**
4841 * Registers a listener that will be called whenever the store's state changes.
4842 *
4843 * @param fn The listener function to be called on state changes.
4844 * @returns A function to unsubscribe the listener.
4845 */
4846 subscribe = (fn) => {
4847 this.listeners.add(fn);
4848 return () => {
4849 this.listeners.delete(fn);
4850 };
4851 };
4852 /**
4853 * Returns the current state of the store.
4854 */
4855 getSnapshot = () => {
4856 return this.state;
4857 };
4858 /**
4859 * Updates the entire store's state and notifies all registered listeners.
4860 *
4861 * @param newState The new state to set for the store.
4862 */
4863 setState(newState) {
4864 if (this.state === newState) {
4865 return;
4866 }
4867 this.state = newState;
4868 this.updateTick += 1;
4869 const currentTick = this.updateTick;
4870 for (const listener of this.listeners) {
4871 if (currentTick !== this.updateTick) {
4872 return;
4873 }
4874 listener(newState);
4875 }
4876 }
4877 /**
4878 * Merges the provided changes into the current state and notifies listeners if there are changes.
4879 *
4880 * @param changes An object containing the changes to apply to the current state.
4881 */
4882 update(changes) {
4883 for (const key in changes) {
4884 if (!Object.is(this.state[key], changes[key])) {
4885 this.setState({
4886 ...this.state,
4887 ...changes
4888 });
4889 return;
4890 }
4891 }
4892 }
4893 /**
4894 * Sets a specific key in the store's state to a new value and notifies listeners if the value has changed.
4895 *
4896 * @param key The key in the store's state to update.
4897 * @param value The new value to set for the specified key.
4898 */
4899 set(key, value) {
4900 if (!Object.is(this.state[key], value)) {
4901 this.setState({
4902 ...this.state,
4903 [key]: value
4904 });
4905 }
4906 }
4907 /**
4908 * Gives the state a new reference and updates all registered listeners.
4909 */
4910 notifyAll() {
4911 const newState = {
4912 ...this.state
4913 };
4914 this.setState(newState);
4915 }
4916 use(selector, a1, a2, a3) {
4917 return useStore(this, selector, a1, a2, a3);
4918 }
4919 };
4920
4921 // node_modules/@base-ui/utils/esm/store/ReactStore.js
4922 var React22 = __toESM(require_react(), 1);
4923 var ReactStore = class extends Store {
4924 /**
4925 * Creates a new ReactStore instance.
4926 *
4927 * @param state Initial state of the store.
4928 * @param context Non-reactive context values.
4929 * @param selectors Optional selectors for use with `useState`.
4930 */
4931 constructor(state, context = {}, selectors3) {
4932 super(state);
4933 this.context = context;
4934 this.selectors = selectors3;
4935 }
4936 /**
4937 * Non-reactive values such as refs, callbacks, etc.
4938 */
4939 /**
4940 * Synchronizes a single external value into the store.
4941 *
4942 * Note that the while the value in `state` is updated immediately, the value returned
4943 * by `useState` is updated before the next render (similarly to React's `useState`).
4944 */
4945 useSyncedValue(key, value) {
4946 React22.useDebugValue(key);
4947 const store2 = this;
4948 useIsoLayoutEffect(() => {
4949 if (store2.state[key] !== value) {
4950 store2.set(key, value);
4951 }
4952 }, [store2, key, value]);
4953 }
4954 /**
4955 * Synchronizes a single external value into the store and
4956 * cleans it up (sets to `undefined`) on unmount.
4957 *
4958 * Note that the while the value in `state` is updated immediately, the value returned
4959 * by `useState` is updated before the next render (similarly to React's `useState`).
4960 */
4961 useSyncedValueWithCleanup(key, value) {
4962 const store2 = this;
4963 useIsoLayoutEffect(() => {
4964 if (store2.state[key] !== value) {
4965 store2.set(key, value);
4966 }
4967 return () => {
4968 store2.set(key, void 0);
4969 };
4970 }, [store2, key, value]);
4971 }
4972 /**
4973 * Synchronizes multiple external values into the store.
4974 *
4975 * Note that the while the values in `state` are updated immediately, the values returned
4976 * by `useState` are updated before the next render (similarly to React's `useState`).
4977 */
4978 useSyncedValues(statePart) {
4979 const store2 = this;
4980 if (true) {
4981 React22.useDebugValue(statePart, (p) => Object.keys(p));
4982 const keys = React22.useRef(Object.keys(statePart)).current;
4983 const nextKeys = Object.keys(statePart);
4984 if (keys.length !== nextKeys.length || keys.some((key, index2) => key !== nextKeys[index2])) {
4985 console.error("ReactStore.useSyncedValues expects the same prop keys on every render. Keys should be stable.");
4986 }
4987 }
4988 const dependencies = Object.values(statePart);
4989 useIsoLayoutEffect(() => {
4990 store2.update(statePart);
4991 }, [store2, ...dependencies]);
4992 }
4993 /**
4994 * Registers a controllable prop pair (`controlled`, `defaultValue`) for a specific key. If `controlled`
4995 * is non-undefined, the store's state at `key` is updated to match `controlled`.
4996 */
4997 useControlledProp(key, controlled) {
4998 React22.useDebugValue(key);
4999 const store2 = this;
5000 const isControlled = controlled !== void 0;
5001 useIsoLayoutEffect(() => {
5002 if (isControlled && !Object.is(store2.state[key], controlled)) {
5003 store2.setState({
5004 ...store2.state,
5005 [key]: controlled
5006 });
5007 }
5008 }, [store2, key, controlled, isControlled]);
5009 if (true) {
5010 const cache = this.controlledValues ??= /* @__PURE__ */ new Map();
5011 if (!cache.has(key)) {
5012 cache.set(key, isControlled);
5013 }
5014 const previouslyControlled = cache.get(key);
5015 if (previouslyControlled !== void 0 && previouslyControlled !== isControlled) {
5016 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).`);
5017 }
5018 }
5019 }
5020 /** Gets the current value from the store using a selector with the provided key.
5021 *
5022 * @param key Key of the selector to use.
5023 */
5024 select(key, a1, a2, a3) {
5025 const selector = this.selectors[key];
5026 return selector(this.state, a1, a2, a3);
5027 }
5028 /**
5029 * Returns a value from the store's state using a selector function.
5030 * Used to subscribe to specific parts of the state.
5031 * This methods causes a rerender whenever the selected state changes.
5032 *
5033 * @param key Key of the selector to use.
5034 */
5035 useState(key, a1, a2, a3) {
5036 React22.useDebugValue(key);
5037 return useStore(this, this.selectors[key], a1, a2, a3);
5038 }
5039 /**
5040 * Wraps a function with `useStableCallback` to ensure it has a stable reference
5041 * and assigns it to the context.
5042 *
5043 * @param key Key of the event callback. Must be a function in the context.
5044 * @param fn Function to assign.
5045 */
5046 useContextCallback(key, fn) {
5047 React22.useDebugValue(key);
5048 const stableFunction = useStableCallback(fn ?? NOOP);
5049 this.context[key] = stableFunction;
5050 }
5051 /**
5052 * Returns a stable setter function for a specific key in the store's state.
5053 * It's commonly used to pass as a ref callback to React elements.
5054 *
5055 * @param key Key of the state to set.
5056 */
5057 useStateSetter(key) {
5058 const ref = React22.useRef(void 0);
5059 if (ref.current === void 0) {
5060 ref.current = (value) => {
5061 this.set(key, value);
5062 };
5063 }
5064 return ref.current;
5065 }
5066 /**
5067 * Observes changes derived from the store's selectors and calls the listener when the selected value changes.
5068 *
5069 * @param key Key of the selector to observe.
5070 * @param listener Listener function called when the selector result changes.
5071 */
5072 observe(selector, listener) {
5073 let selectFn;
5074 if (typeof selector === "function") {
5075 selectFn = selector;
5076 } else {
5077 selectFn = this.selectors[selector];
5078 }
5079 let prevValue = selectFn(this.state);
5080 listener(prevValue, prevValue, this);
5081 return this.subscribe((nextState) => {
5082 const nextValue = selectFn(nextState);
5083 if (!Object.is(prevValue, nextValue)) {
5084 const oldValue = prevValue;
5085 prevValue = nextValue;
5086 listener(nextValue, oldValue, this);
5087 }
5088 });
5089 }
5090 };
5091
5092 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingRootStore.js
5093 var selectors = {
5094 open: createSelector((state) => state.open),
5095 transitionStatus: createSelector((state) => state.transitionStatus),
5096 domReferenceElement: createSelector((state) => state.domReferenceElement),
5097 referenceElement: createSelector((state) => state.positionReference ?? state.referenceElement),
5098 floatingElement: createSelector((state) => state.floatingElement),
5099 floatingId: createSelector((state) => state.floatingId)
5100 };
5101 var FloatingRootStore = class extends ReactStore {
5102 constructor(options) {
5103 const {
5104 syncOnly,
5105 nested,
5106 onOpenChange,
5107 triggerElements,
5108 ...initialState
5109 } = options;
5110 super({
5111 ...initialState,
5112 positionReference: initialState.referenceElement,
5113 domReferenceElement: initialState.referenceElement
5114 }, {
5115 onOpenChange,
5116 dataRef: {
5117 current: {}
5118 },
5119 events: createEventEmitter(),
5120 nested,
5121 triggerElements
5122 }, selectors);
5123 this.syncOnly = syncOnly;
5124 }
5125 /**
5126 * Syncs the event used by hover logic to distinguish hover-open from click-like interaction.
5127 */
5128 syncOpenEvent = (newOpen, event) => {
5129 if (!newOpen || !this.state.open || // Prevent a pending hover-open from overwriting a click-open event, while allowing
5130 // click events to upgrade a hover-open.
5131 event != null && isClickLikeEvent(event)) {
5132 this.context.dataRef.current.openEvent = newOpen ? event : void 0;
5133 }
5134 };
5135 /**
5136 * Runs the root-owned side effects for an open state change.
5137 */
5138 dispatchOpenChange = (newOpen, eventDetails) => {
5139 this.syncOpenEvent(newOpen, eventDetails.event);
5140 const details = {
5141 open: newOpen,
5142 reason: eventDetails.reason,
5143 nativeEvent: eventDetails.event,
5144 nested: this.context.nested,
5145 triggerElement: eventDetails.trigger
5146 };
5147 this.context.events.emit("openchange", details);
5148 };
5149 /**
5150 * Emits the `openchange` event through the internal event emitter and calls the `onOpenChange` handler with the provided arguments.
5151 *
5152 * @param newOpen The new open state.
5153 * @param eventDetails Details about the event that triggered the open state change.
5154 */
5155 setOpen = (newOpen, eventDetails) => {
5156 if (this.syncOnly) {
5157 this.context.onOpenChange?.(newOpen, eventDetails);
5158 return;
5159 }
5160 this.dispatchOpenChange(newOpen, eventDetails);
5161 this.context.onOpenChange?.(newOpen, eventDetails);
5162 };
5163 };
5164
5165 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useSyncedFloatingRootContext.js
5166 function useSyncedFloatingRootContext(options) {
5167 const {
5168 popupStore,
5169 treatPopupAsFloatingElement = false,
5170 floatingRootContext: floatingRootContextProp,
5171 floatingId,
5172 nested,
5173 onOpenChange
5174 } = options;
5175 const open = popupStore.useState("open");
5176 const referenceElement = popupStore.useState("activeTriggerElement");
5177 const floatingElement = popupStore.useState(treatPopupAsFloatingElement ? "popupElement" : "positionerElement");
5178 const triggerElements = popupStore.context.triggerElements;
5179 const handleOpenChange = onOpenChange;
5180 const internalStoreRef = React23.useRef(null);
5181 if (floatingRootContextProp === void 0 && internalStoreRef.current === null) {
5182 internalStoreRef.current = new FloatingRootStore({
5183 open,
5184 transitionStatus: void 0,
5185 referenceElement,
5186 floatingElement,
5187 triggerElements,
5188 onOpenChange: handleOpenChange,
5189 floatingId,
5190 syncOnly: true,
5191 nested
5192 });
5193 }
5194 const store2 = floatingRootContextProp ?? internalStoreRef.current;
5195 popupStore.useSyncedValue("floatingId", floatingId);
5196 useIsoLayoutEffect(() => {
5197 const valuesToSync = {
5198 open,
5199 floatingId,
5200 referenceElement,
5201 floatingElement
5202 };
5203 if (isElement(referenceElement)) {
5204 valuesToSync.domReferenceElement = referenceElement;
5205 }
5206 if (store2.state.positionReference === store2.state.referenceElement) {
5207 valuesToSync.positionReference = referenceElement;
5208 }
5209 store2.update(valuesToSync);
5210 }, [open, floatingId, referenceElement, floatingElement, store2]);
5211 store2.context.onOpenChange = handleOpenChange;
5212 store2.context.nested = nested;
5213 return store2;
5214 }
5215
5216 // node_modules/@base-ui/react/esm/utils/popups/popupStoreUtils.js
5217 var FOCUSABLE_POPUP_PROPS = {
5218 tabIndex: -1,
5219 [FOCUSABLE_ATTRIBUTE]: ""
5220 };
5221 function usePopupStore(externalStore, createStore, treatPopupAsFloatingElement = false) {
5222 const floatingId = useId();
5223 const nested = useFloatingParentNodeId() != null;
5224 const internalStoreRef = React24.useRef(null);
5225 if (externalStore === void 0 && internalStoreRef.current === null) {
5226 internalStoreRef.current = createStore(floatingId, nested);
5227 }
5228 const store2 = externalStore ?? internalStoreRef.current;
5229 useSyncedFloatingRootContext({
5230 popupStore: store2,
5231 treatPopupAsFloatingElement,
5232 floatingRootContext: store2.state.floatingRootContext,
5233 floatingId,
5234 nested,
5235 onOpenChange: store2.setOpen
5236 });
5237 return {
5238 store: store2,
5239 internalStore: internalStoreRef.current
5240 };
5241 }
5242 function useTriggerRegistration(id, store2) {
5243 const registeredElementIdRef = React24.useRef(null);
5244 const registeredElementRef = React24.useRef(null);
5245 return React24.useCallback((element) => {
5246 if (id === void 0) {
5247 return;
5248 }
5249 let shouldSyncTriggerCount = false;
5250 if (registeredElementIdRef.current !== null) {
5251 const registeredId = registeredElementIdRef.current;
5252 const registeredElement = registeredElementRef.current;
5253 const currentElement = store2.context.triggerElements.getById(registeredId);
5254 if (registeredElement && currentElement === registeredElement) {
5255 store2.context.triggerElements.delete(registeredId);
5256 shouldSyncTriggerCount = true;
5257 }
5258 registeredElementIdRef.current = null;
5259 registeredElementRef.current = null;
5260 }
5261 if (element !== null) {
5262 registeredElementIdRef.current = id;
5263 registeredElementRef.current = element;
5264 store2.context.triggerElements.add(id, element);
5265 shouldSyncTriggerCount = true;
5266 }
5267 if (shouldSyncTriggerCount) {
5268 const triggerCount = store2.context.triggerElements.size;
5269 if (store2.select("open") && store2.state.triggerCount !== triggerCount) {
5270 store2.set("triggerCount", triggerCount);
5271 }
5272 }
5273 }, [store2, id]);
5274 }
5275 function setOpenTriggerState(state, open, trigger) {
5276 const triggerId = trigger?.id ?? null;
5277 if (triggerId || open) {
5278 state.activeTriggerId = triggerId;
5279 state.activeTriggerElement = trigger ?? null;
5280 }
5281 }
5282 function useTriggerDataForwarding(triggerId, triggerElementRef, store2, stateUpdates) {
5283 const isMountedByThisTrigger = store2.useState("isMountedByTrigger", triggerId);
5284 const baseRegisterTrigger = useTriggerRegistration(triggerId, store2);
5285 const registerTrigger = useStableCallback((element) => {
5286 baseRegisterTrigger(element);
5287 if (!element) {
5288 return;
5289 }
5290 const open = store2.select("open");
5291 const activeTriggerId = store2.select("activeTriggerId");
5292 if (activeTriggerId === triggerId) {
5293 store2.update({
5294 activeTriggerElement: element,
5295 ...open ? stateUpdates : null
5296 });
5297 return;
5298 }
5299 if (activeTriggerId == null && open) {
5300 store2.update({
5301 activeTriggerId: triggerId,
5302 activeTriggerElement: element,
5303 ...stateUpdates
5304 });
5305 }
5306 });
5307 useIsoLayoutEffect(() => {
5308 if (isMountedByThisTrigger) {
5309 store2.update({
5310 activeTriggerElement: triggerElementRef.current,
5311 ...stateUpdates
5312 });
5313 }
5314 }, [isMountedByThisTrigger, store2, triggerElementRef, ...Object.values(stateUpdates)]);
5315 return {
5316 registerTrigger,
5317 isMountedByThisTrigger
5318 };
5319 }
5320 function useImplicitActiveTrigger(store2) {
5321 const open = store2.useState("open");
5322 const reactiveTriggerCount = store2.useState("triggerCount");
5323 useIsoLayoutEffect(() => {
5324 if (!open) {
5325 if (store2.state.triggerCount !== 0) {
5326 store2.set("triggerCount", 0);
5327 }
5328 return;
5329 }
5330 const triggerCount = store2.context.triggerElements.size;
5331 const stateUpdates = {};
5332 if (store2.state.triggerCount !== triggerCount) {
5333 stateUpdates.triggerCount = triggerCount;
5334 }
5335 if (!store2.select("activeTriggerId") && triggerCount === 1) {
5336 const iteratorResult = store2.context.triggerElements.entries().next();
5337 if (!iteratorResult.done) {
5338 const [implicitTriggerId, implicitTriggerElement] = iteratorResult.value;
5339 stateUpdates.activeTriggerId = implicitTriggerId;
5340 stateUpdates.activeTriggerElement = implicitTriggerElement;
5341 }
5342 }
5343 if (stateUpdates.triggerCount !== void 0 || stateUpdates.activeTriggerId !== void 0) {
5344 store2.update(stateUpdates);
5345 }
5346 }, [open, store2, reactiveTriggerCount]);
5347 }
5348 function useOpenStateTransitions(open, store2, onUnmount) {
5349 const {
5350 mounted,
5351 setMounted,
5352 transitionStatus
5353 } = useTransitionStatus(open);
5354 store2.useSyncedValues({
5355 mounted,
5356 transitionStatus
5357 });
5358 const forceUnmount = useStableCallback(() => {
5359 setMounted(false);
5360 store2.update({
5361 activeTriggerId: null,
5362 activeTriggerElement: null,
5363 mounted: false,
5364 preventUnmountingOnClose: false
5365 });
5366 onUnmount?.();
5367 store2.context.onOpenChangeComplete?.(false);
5368 });
5369 const preventUnmountingOnClose = store2.useState("preventUnmountingOnClose");
5370 useOpenChangeComplete({
5371 enabled: mounted && !open && !preventUnmountingOnClose,
5372 open,
5373 ref: store2.context.popupRef,
5374 onComplete() {
5375 if (!open) {
5376 forceUnmount();
5377 }
5378 }
5379 });
5380 return {
5381 forceUnmount,
5382 transitionStatus
5383 };
5384 }
5385 function usePopupInteractionProps(store2, statePart) {
5386 store2.useSyncedValues(statePart);
5387 useIsoLayoutEffect(() => () => {
5388 store2.update({
5389 activeTriggerProps: EMPTY_OBJECT,
5390 inactiveTriggerProps: EMPTY_OBJECT,
5391 popupProps: EMPTY_OBJECT
5392 });
5393 }, [store2]);
5394 }
5395
5396 // node_modules/@base-ui/react/esm/utils/popups/popupTriggerMap.js
5397 var PopupTriggerMap = class {
5398 constructor() {
5399 this.elementsSet = /* @__PURE__ */ new Set();
5400 this.idMap = /* @__PURE__ */ new Map();
5401 }
5402 /**
5403 * Adds a trigger element with the given ID.
5404 *
5405 * Note: The provided element is assumed to not be registered under multiple IDs.
5406 */
5407 add(id, element) {
5408 const existingElement = this.idMap.get(id);
5409 if (existingElement === element) {
5410 return;
5411 }
5412 if (existingElement !== void 0) {
5413 this.elementsSet.delete(existingElement);
5414 }
5415 this.elementsSet.add(element);
5416 this.idMap.set(id, element);
5417 if (true) {
5418 if (this.elementsSet.size !== this.idMap.size) {
5419 throw new Error("Base UI: A trigger element cannot be registered under multiple IDs in PopupTriggerMap.");
5420 }
5421 }
5422 }
5423 /**
5424 * Removes the trigger element with the given ID.
5425 */
5426 delete(id) {
5427 const element = this.idMap.get(id);
5428 if (element) {
5429 this.elementsSet.delete(element);
5430 this.idMap.delete(id);
5431 }
5432 }
5433 /**
5434 * Whether the given element is registered as a trigger.
5435 */
5436 hasElement(element) {
5437 return this.elementsSet.has(element);
5438 }
5439 /**
5440 * Whether there is a registered trigger element matching the given predicate.
5441 */
5442 hasMatchingElement(predicate) {
5443 for (const element of this.elementsSet) {
5444 if (predicate(element)) {
5445 return true;
5446 }
5447 }
5448 return false;
5449 }
5450 /**
5451 * Returns the trigger element associated with the given ID, or undefined if no such element exists.
5452 */
5453 getById(id) {
5454 return this.idMap.get(id);
5455 }
5456 /**
5457 * Returns an iterable of all registered trigger entries, where each entry is a tuple of [id, element].
5458 */
5459 entries() {
5460 return this.idMap.entries();
5461 }
5462 /**
5463 * Returns an iterable of all registered trigger elements.
5464 */
5465 elements() {
5466 return this.elementsSet.values();
5467 }
5468 /**
5469 * Returns the number of registered trigger elements.
5470 */
5471 get size() {
5472 return this.idMap.size;
5473 }
5474 };
5475
5476 // node_modules/@base-ui/react/esm/floating-ui-react/utils/getEmptyRootContext.js
5477 function getEmptyRootContext() {
5478 return new FloatingRootStore({
5479 open: false,
5480 transitionStatus: void 0,
5481 floatingElement: null,
5482 referenceElement: null,
5483 triggerElements: new PopupTriggerMap(),
5484 floatingId: void 0,
5485 syncOnly: false,
5486 nested: false,
5487 onOpenChange: void 0
5488 });
5489 }
5490
5491 // node_modules/@base-ui/react/esm/utils/popups/store.js
5492 function createInitialPopupStoreState() {
5493 return {
5494 open: false,
5495 openProp: void 0,
5496 mounted: false,
5497 transitionStatus: void 0,
5498 floatingRootContext: getEmptyRootContext(),
5499 floatingId: void 0,
5500 triggerCount: 0,
5501 preventUnmountingOnClose: false,
5502 payload: void 0,
5503 activeTriggerId: null,
5504 activeTriggerElement: null,
5505 triggerIdProp: void 0,
5506 popupElement: null,
5507 positionerElement: null,
5508 activeTriggerProps: EMPTY_OBJECT,
5509 inactiveTriggerProps: EMPTY_OBJECT,
5510 popupProps: EMPTY_OBJECT
5511 };
5512 }
5513 function createPopupFloatingRootContext(triggerElements, floatingId, nested = false) {
5514 return new FloatingRootStore({
5515 open: false,
5516 transitionStatus: void 0,
5517 floatingElement: null,
5518 referenceElement: null,
5519 triggerElements,
5520 floatingId,
5521 syncOnly: true,
5522 nested,
5523 onOpenChange: void 0
5524 });
5525 }
5526 var activeTriggerIdSelector = createSelector((state) => state.triggerIdProp ?? state.activeTriggerId);
5527 var openSelector = createSelector((state) => state.openProp ?? state.open);
5528 var popupIdSelector = createSelector((state) => {
5529 const popupId = state.popupElement?.id ?? state.floatingId;
5530 return popupId || void 0;
5531 });
5532 function triggerOwnsOpenPopup(state, triggerId) {
5533 return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) === triggerId;
5534 }
5535 function triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) {
5536 if (triggerOwnsOpenPopup(state, triggerId)) {
5537 return true;
5538 }
5539 return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) == null && state.triggerCount === 1;
5540 }
5541 var popupStoreSelectors = {
5542 open: openSelector,
5543 mounted: createSelector((state) => state.mounted),
5544 transitionStatus: createSelector((state) => state.transitionStatus),
5545 floatingRootContext: createSelector((state) => state.floatingRootContext),
5546 triggerCount: createSelector((state) => state.triggerCount),
5547 preventUnmountingOnClose: createSelector((state) => state.preventUnmountingOnClose),
5548 payload: createSelector((state) => state.payload),
5549 activeTriggerId: activeTriggerIdSelector,
5550 activeTriggerElement: createSelector((state) => state.mounted ? state.activeTriggerElement : null),
5551 popupId: popupIdSelector,
5552 /**
5553 * Whether the trigger with the given ID was used to open the popup.
5554 */
5555 isTriggerActive: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId),
5556 /**
5557 * Whether the popup is open and was activated by a trigger with the given ID.
5558 */
5559 isOpenedByTrigger: createSelector((state, triggerId) => triggerOwnsOpenPopup(state, triggerId)),
5560 /**
5561 * Whether the popup is mounted and was activated by a trigger with the given ID.
5562 */
5563 isMountedByTrigger: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId && state.mounted),
5564 triggerProps: createSelector((state, isActive) => isActive ? state.activeTriggerProps : state.inactiveTriggerProps),
5565 /**
5566 * Popup id for the trigger that currently owns the open popup.
5567 */
5568 triggerPopupId: createSelector((state, triggerId) => triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) ? popupIdSelector(state) : void 0),
5569 popupProps: createSelector((state) => state.popupProps),
5570 popupElement: createSelector((state) => state.popupElement),
5571 positionerElement: createSelector((state) => state.positionerElement)
5572 };
5573
5574 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloatingRootContext.js
5575 function useFloatingRootContext(options) {
5576 const {
5577 open = false,
5578 onOpenChange,
5579 elements = {}
5580 } = options;
5581 const floatingId = useId();
5582 const nested = useFloatingParentNodeId() != null;
5583 if (true) {
5584 const optionDomReference = elements.reference;
5585 if (optionDomReference && !isElement(optionDomReference)) {
5586 console.error("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `context.setPositionReference()`", "instead.");
5587 }
5588 }
5589 const store2 = useRefWithInit(() => new FloatingRootStore({
5590 open,
5591 transitionStatus: void 0,
5592 onOpenChange,
5593 referenceElement: elements.reference ?? null,
5594 floatingElement: elements.floating ?? null,
5595 triggerElements: new PopupTriggerMap(),
5596 floatingId,
5597 syncOnly: false,
5598 nested
5599 })).current;
5600 useIsoLayoutEffect(() => {
5601 const valuesToSync = {
5602 open,
5603 floatingId
5604 };
5605 if (elements.reference !== void 0) {
5606 valuesToSync.referenceElement = elements.reference;
5607 valuesToSync.domReferenceElement = isElement(elements.reference) ? elements.reference : null;
5608 }
5609 if (elements.floating !== void 0) {
5610 valuesToSync.floatingElement = elements.floating;
5611 }
5612 store2.update(valuesToSync);
5613 }, [open, floatingId, elements.reference, elements.floating, store2]);
5614 store2.context.onOpenChange = onOpenChange;
5615 store2.context.nested = nested;
5616 return store2;
5617 }
5618
5619 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloating.js
5620 function useFloating2(options = {}) {
5621 const {
5622 nodeId,
5623 externalTree
5624 } = options;
5625 const internalStore = useFloatingRootContext(options);
5626 const store2 = options.rootContext || internalStore;
5627 const referenceElement = store2.useState("referenceElement");
5628 const floatingElement = store2.useState("floatingElement");
5629 const domReferenceElement = store2.useState("domReferenceElement");
5630 const open = store2.useState("open");
5631 const floatingId = store2.useState("floatingId");
5632 const [positionReference, setPositionReferenceRaw] = React25.useState(null);
5633 const [localDomReference, setLocalDomReference] = React25.useState(void 0);
5634 const [localFloatingElement, setLocalFloatingElement] = React25.useState(void 0);
5635 const domReferenceRef = React25.useRef(null);
5636 const tree = useFloatingTree(externalTree);
5637 const storeElements = React25.useMemo(() => ({
5638 reference: referenceElement,
5639 floating: floatingElement,
5640 domReference: domReferenceElement
5641 }), [referenceElement, floatingElement, domReferenceElement]);
5642 const position = useFloating({
5643 ...options,
5644 elements: {
5645 ...storeElements,
5646 ...positionReference && {
5647 reference: positionReference
5648 }
5649 }
5650 });
5651 const localDomReferenceElement = isElement(localDomReference) ? localDomReference : null;
5652 const syncedFloatingElement = localFloatingElement === void 0 ? store2.state.floatingElement : localFloatingElement;
5653 store2.useSyncedValue("referenceElement", localDomReference ?? null);
5654 store2.useSyncedValue("domReferenceElement", localDomReference === void 0 ? domReferenceElement : localDomReferenceElement);
5655 store2.useSyncedValue("floatingElement", syncedFloatingElement);
5656 const setPositionReference = React25.useCallback((node) => {
5657 const computedPositionReference = isElement(node) ? {
5658 getBoundingClientRect: () => node.getBoundingClientRect(),
5659 getClientRects: () => node.getClientRects(),
5660 contextElement: node
5661 } : node;
5662 setPositionReferenceRaw(computedPositionReference);
5663 position.refs.setReference(computedPositionReference);
5664 }, [position.refs]);
5665 const setReference = React25.useCallback((node) => {
5666 if (isElement(node) || node === null) {
5667 domReferenceRef.current = node;
5668 setLocalDomReference(node);
5669 }
5670 if (isElement(position.refs.reference.current) || position.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
5671 // `null` to support `positionReference` + an unstable `reference`
5672 // callback ref.
5673 node !== null && !isElement(node)) {
5674 position.refs.setReference(node);
5675 }
5676 }, [position.refs, setLocalDomReference]);
5677 const setFloating = React25.useCallback((node) => {
5678 setLocalFloatingElement(node);
5679 position.refs.setFloating(node);
5680 }, [position.refs]);
5681 const refs = React25.useMemo(() => ({
5682 ...position.refs,
5683 setReference,
5684 setFloating,
5685 setPositionReference,
5686 domReference: domReferenceRef
5687 }), [position.refs, setReference, setFloating, setPositionReference]);
5688 const elements = React25.useMemo(() => ({
5689 ...position.elements,
5690 domReference: domReferenceElement
5691 }), [position.elements, domReferenceElement]);
5692 const context = React25.useMemo(() => ({
5693 ...position,
5694 dataRef: store2.context.dataRef,
5695 open,
5696 onOpenChange: store2.setOpen,
5697 events: store2.context.events,
5698 floatingId,
5699 refs,
5700 elements,
5701 nodeId,
5702 rootStore: store2
5703 }), [position, refs, elements, nodeId, store2, open, floatingId]);
5704 useIsoLayoutEffect(() => {
5705 if (domReferenceElement) {
5706 domReferenceRef.current = domReferenceElement;
5707 }
5708 }, [domReferenceElement]);
5709 useIsoLayoutEffect(() => {
5710 store2.context.dataRef.current.floatingContext = context;
5711 const node = tree?.nodesRef.current.find((n) => n.id === nodeId);
5712 if (node) {
5713 node.context = context;
5714 }
5715 });
5716 return React25.useMemo(() => ({
5717 ...position,
5718 context,
5719 refs,
5720 elements,
5721 rootStore: store2
5722 }), [position, refs, elements, context, store2]);
5723 }
5724
5725 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFocus.js
5726 var React26 = __toESM(require_react(), 1);
5727 var isMacSafari = isMac && isSafari;
5728 function useFocus(context, props = {}) {
5729 const {
5730 enabled = true,
5731 delay
5732 } = props;
5733 const store2 = "rootStore" in context ? context.rootStore : context;
5734 const {
5735 events,
5736 dataRef
5737 } = store2.context;
5738 const blockFocusRef = React26.useRef(false);
5739 const blockedReferenceRef = React26.useRef(null);
5740 const keyboardModalityRef = React26.useRef(true);
5741 const timeout = useTimeout();
5742 React26.useEffect(() => {
5743 const domReference = store2.select("domReferenceElement");
5744 if (!enabled) {
5745 return void 0;
5746 }
5747 const win = getWindow(domReference);
5748 function onBlur() {
5749 const currentDomReference = store2.select("domReferenceElement");
5750 if (!store2.select("open") && isHTMLElement(currentDomReference) && currentDomReference === activeElement(ownerDocument(currentDomReference))) {
5751 blockFocusRef.current = true;
5752 }
5753 }
5754 function onKeyDown() {
5755 keyboardModalityRef.current = true;
5756 }
5757 function onPointerDown() {
5758 keyboardModalityRef.current = false;
5759 }
5760 return mergeCleanups(addEventListener(win, "blur", onBlur), isMacSafari && addEventListener(win, "keydown", onKeyDown, true), isMacSafari && addEventListener(win, "pointerdown", onPointerDown, true));
5761 }, [store2, enabled]);
5762 React26.useEffect(() => {
5763 if (!enabled) {
5764 return void 0;
5765 }
5766 function onOpenChangeLocal(details) {
5767 if (details.reason === reason_parts_exports.triggerPress || details.reason === reason_parts_exports.escapeKey) {
5768 const referenceElement = store2.select("domReferenceElement");
5769 if (isElement(referenceElement)) {
5770 blockedReferenceRef.current = referenceElement;
5771 blockFocusRef.current = true;
5772 }
5773 }
5774 }
5775 events.on("openchange", onOpenChangeLocal);
5776 return () => {
5777 events.off("openchange", onOpenChangeLocal);
5778 };
5779 }, [events, enabled, store2]);
5780 const reference = React26.useMemo(() => {
5781 function resetBlockedFocus() {
5782 blockFocusRef.current = false;
5783 blockedReferenceRef.current = null;
5784 }
5785 return {
5786 onMouseLeave() {
5787 resetBlockedFocus();
5788 },
5789 onFocus(event) {
5790 const focusTarget = event.currentTarget;
5791 if (blockFocusRef.current) {
5792 if (blockedReferenceRef.current === focusTarget) {
5793 return;
5794 }
5795 resetBlockedFocus();
5796 }
5797 const target = getTarget(event.nativeEvent);
5798 if (isElement(target)) {
5799 if (isMacSafari && !event.relatedTarget) {
5800 if (!keyboardModalityRef.current && !isTypeableElement(target)) {
5801 return;
5802 }
5803 } else if (!matchesFocusVisible(target)) {
5804 return;
5805 }
5806 }
5807 const movedFromOtherEnabledTrigger = isTargetInsideEnabledTrigger(event.relatedTarget, store2.context.triggerElements);
5808 const {
5809 nativeEvent,
5810 currentTarget
5811 } = event;
5812 const delayValue = typeof delay === "function" ? delay() : delay;
5813 if (store2.select("open") && movedFromOtherEnabledTrigger || delayValue === 0 || delayValue === void 0) {
5814 store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
5815 return;
5816 }
5817 timeout.start(delayValue, () => {
5818 if (blockFocusRef.current) {
5819 return;
5820 }
5821 store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
5822 });
5823 },
5824 onBlur(event) {
5825 resetBlockedFocus();
5826 const relatedTarget = event.relatedTarget;
5827 const nativeEvent = event.nativeEvent;
5828 const movedToFocusGuard = isElement(relatedTarget) && relatedTarget.hasAttribute(createAttribute("focus-guard")) && relatedTarget.getAttribute("data-type") === "outside";
5829 timeout.start(0, () => {
5830 const domReference = store2.select("domReferenceElement");
5831 const activeEl = activeElement(ownerDocument(domReference));
5832 if (!relatedTarget && activeEl === domReference) {
5833 return;
5834 }
5835 if (contains(dataRef.current.floatingContext?.refs.floating.current, activeEl) || contains(domReference, activeEl) || movedToFocusGuard) {
5836 return;
5837 }
5838 const nextFocusedElement = relatedTarget ?? activeEl;
5839 if (isTargetInsideEnabledTrigger(nextFocusedElement, store2.context.triggerElements)) {
5840 return;
5841 }
5842 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent));
5843 });
5844 }
5845 };
5846 }, [dataRef, delay, store2, timeout]);
5847 return React26.useMemo(() => enabled ? {
5848 reference,
5849 trigger: reference
5850 } : {}, [enabled, reference]);
5851 }
5852
5853 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverFloatingInteraction.js
5854 var React27 = __toESM(require_react(), 1);
5855
5856 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverInteractionSharedState.js
5857 var HoverInteraction = class _HoverInteraction {
5858 constructor() {
5859 this.pointerType = void 0;
5860 this.interactedInside = false;
5861 this.handler = void 0;
5862 this.blockMouseMove = true;
5863 this.performedPointerEventsMutation = false;
5864 this.pointerEventsScopeElement = null;
5865 this.pointerEventsReferenceElement = null;
5866 this.pointerEventsFloatingElement = null;
5867 this.restTimeoutPending = false;
5868 this.openChangeTimeout = new Timeout();
5869 this.restTimeout = new Timeout();
5870 this.handleCloseOptions = void 0;
5871 }
5872 static create() {
5873 return new _HoverInteraction();
5874 }
5875 dispose = () => {
5876 this.openChangeTimeout.clear();
5877 this.restTimeout.clear();
5878 };
5879 disposeEffect = () => {
5880 return this.dispose;
5881 };
5882 };
5883 var pointerEventsMutationOwnerByScopeElement = /* @__PURE__ */ new WeakMap();
5884 function clearSafePolygonPointerEventsMutation(instance) {
5885 if (!instance.performedPointerEventsMutation) {
5886 return;
5887 }
5888 const scopeElement = instance.pointerEventsScopeElement;
5889 if (scopeElement && pointerEventsMutationOwnerByScopeElement.get(scopeElement) === instance) {
5890 instance.pointerEventsScopeElement?.style.removeProperty("pointer-events");
5891 instance.pointerEventsReferenceElement?.style.removeProperty("pointer-events");
5892 instance.pointerEventsFloatingElement?.style.removeProperty("pointer-events");
5893 pointerEventsMutationOwnerByScopeElement.delete(scopeElement);
5894 }
5895 instance.performedPointerEventsMutation = false;
5896 instance.pointerEventsScopeElement = null;
5897 instance.pointerEventsReferenceElement = null;
5898 instance.pointerEventsFloatingElement = null;
5899 }
5900 function applySafePolygonPointerEventsMutation(instance, options) {
5901 const {
5902 scopeElement,
5903 referenceElement,
5904 floatingElement
5905 } = options;
5906 const existingOwner = pointerEventsMutationOwnerByScopeElement.get(scopeElement);
5907 if (existingOwner && existingOwner !== instance) {
5908 clearSafePolygonPointerEventsMutation(existingOwner);
5909 }
5910 clearSafePolygonPointerEventsMutation(instance);
5911 instance.performedPointerEventsMutation = true;
5912 instance.pointerEventsScopeElement = scopeElement;
5913 instance.pointerEventsReferenceElement = referenceElement;
5914 instance.pointerEventsFloatingElement = floatingElement;
5915 pointerEventsMutationOwnerByScopeElement.set(scopeElement, instance);
5916 scopeElement.style.pointerEvents = "none";
5917 referenceElement.style.pointerEvents = "auto";
5918 floatingElement.style.pointerEvents = "auto";
5919 }
5920 function useHoverInteractionSharedState(store2) {
5921 const data = store2.context.dataRef.current;
5922 const instance = useRefWithInit(() => data.hoverInteractionState ?? HoverInteraction.create()).current;
5923 if (!data.hoverInteractionState) {
5924 data.hoverInteractionState = instance;
5925 }
5926 useOnMount(data.hoverInteractionState.disposeEffect);
5927 return data.hoverInteractionState;
5928 }
5929
5930 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverFloatingInteraction.js
5931 function useHoverFloatingInteraction(context, parameters = {}) {
5932 const {
5933 enabled = true,
5934 closeDelay: closeDelayProp = 0,
5935 nodeId: nodeIdProp
5936 } = parameters;
5937 const store2 = "rootStore" in context ? context.rootStore : context;
5938 const open = store2.useState("open");
5939 const floatingElement = store2.useState("floatingElement");
5940 const domReferenceElement = store2.useState("domReferenceElement");
5941 const {
5942 dataRef
5943 } = store2.context;
5944 const tree = useFloatingTree();
5945 const parentId = useFloatingParentNodeId();
5946 const instance = useHoverInteractionSharedState(store2);
5947 const childClosedTimeout = useTimeout();
5948 const isClickLikeOpenEvent2 = useStableCallback(() => {
5949 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
5950 });
5951 const isHoverOpen = useStableCallback(() => {
5952 return isHoverOpenEvent(dataRef.current.openEvent?.type);
5953 });
5954 const clearPointerEvents = useStableCallback(() => {
5955 clearSafePolygonPointerEventsMutation(instance);
5956 });
5957 useIsoLayoutEffect(() => {
5958 if (!open) {
5959 instance.pointerType = void 0;
5960 instance.restTimeoutPending = false;
5961 instance.interactedInside = false;
5962 clearPointerEvents();
5963 }
5964 }, [open, instance, clearPointerEvents]);
5965 React27.useEffect(() => {
5966 return clearPointerEvents;
5967 }, [clearPointerEvents]);
5968 useIsoLayoutEffect(() => {
5969 if (!enabled) {
5970 return void 0;
5971 }
5972 if (open && instance.handleCloseOptions?.blockPointerEvents && isHoverOpen() && isElement(domReferenceElement) && floatingElement) {
5973 const ref = domReferenceElement;
5974 const floatingEl = floatingElement;
5975 const doc = ownerDocument(floatingElement);
5976 const parentFloating = tree?.nodesRef.current.find((node) => node.id === parentId)?.context?.elements.floating;
5977 if (parentFloating) {
5978 parentFloating.style.pointerEvents = "";
5979 }
5980 const cachedScopeElement = instance.pointerEventsScopeElement !== floatingEl ? instance.pointerEventsScopeElement : null;
5981 const parentScopeElement = parentFloating !== floatingEl ? parentFloating : null;
5982 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? cachedScopeElement ?? parentScopeElement ?? ref.closest("[data-rootownerid]") ?? doc.body;
5983 applySafePolygonPointerEventsMutation(instance, {
5984 scopeElement,
5985 referenceElement: ref,
5986 floatingElement: floatingEl
5987 });
5988 return () => {
5989 clearPointerEvents();
5990 };
5991 }
5992 return void 0;
5993 }, [enabled, open, domReferenceElement, floatingElement, instance, isHoverOpen, tree, parentId, clearPointerEvents]);
5994 React27.useEffect(() => {
5995 if (!enabled) {
5996 return void 0;
5997 }
5998 function hasParentChildren() {
5999 return !!(tree && parentId && getNodeChildren(tree.nodesRef.current, parentId).length > 0);
6000 }
6001 function closeWithDelay(event) {
6002 const closeDelay = getDelay(closeDelayProp, "close", instance.pointerType);
6003 const close = () => {
6004 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6005 tree?.events.emit("floating.closed", event);
6006 };
6007 if (closeDelay) {
6008 instance.openChangeTimeout.start(closeDelay, close);
6009 } else {
6010 instance.openChangeTimeout.clear();
6011 close();
6012 }
6013 }
6014 function handleInteractInside(event) {
6015 const target = getTarget(event);
6016 if (!isInteractiveElement(target)) {
6017 instance.interactedInside = false;
6018 return;
6019 }
6020 instance.interactedInside = target?.closest("[aria-haspopup]") != null;
6021 }
6022 function onFloatingMouseEnter() {
6023 instance.openChangeTimeout.clear();
6024 childClosedTimeout.clear();
6025 tree?.events.off("floating.closed", onNodeClosed);
6026 clearPointerEvents();
6027 }
6028 function onFloatingMouseLeave(event) {
6029 if (hasParentChildren() && tree) {
6030 tree.events.on("floating.closed", onNodeClosed);
6031 return;
6032 }
6033 if (isTargetInsideEnabledTrigger(event.relatedTarget, store2.context.triggerElements)) {
6034 return;
6035 }
6036 const currentNodeId = dataRef.current.floatingContext?.nodeId ?? nodeIdProp;
6037 const relatedTarget = event.relatedTarget;
6038 const isMovingIntoDescendantFloating = tree && currentNodeId && isElement(relatedTarget) && getNodeChildren(tree.nodesRef.current, currentNodeId, false).some((node) => contains(node.context?.elements.floating, relatedTarget));
6039 if (isMovingIntoDescendantFloating) {
6040 return;
6041 }
6042 if (instance.handler) {
6043 instance.handler(event);
6044 return;
6045 }
6046 clearPointerEvents();
6047 if (!isClickLikeOpenEvent2()) {
6048 closeWithDelay(event);
6049 }
6050 }
6051 function onNodeClosed(event) {
6052 if (!tree || !parentId || hasParentChildren()) {
6053 return;
6054 }
6055 childClosedTimeout.start(0, () => {
6056 tree.events.off("floating.closed", onNodeClosed);
6057 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6058 tree.events.emit("floating.closed", event);
6059 });
6060 }
6061 const floating = floatingElement;
6062 return mergeCleanups(floating && addEventListener(floating, "mouseenter", onFloatingMouseEnter), floating && addEventListener(floating, "mouseleave", onFloatingMouseLeave), floating && addEventListener(floating, "pointerdown", handleInteractInside, true), () => {
6063 tree?.events.off("floating.closed", onNodeClosed);
6064 });
6065 }, [enabled, floatingElement, store2, dataRef, closeDelayProp, nodeIdProp, isClickLikeOpenEvent2, clearPointerEvents, instance, tree, parentId, childClosedTimeout]);
6066 }
6067
6068 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverReferenceInteraction.js
6069 var React28 = __toESM(require_react(), 1);
6070 var ReactDOM4 = __toESM(require_react_dom(), 1);
6071 var EMPTY_REF = {
6072 current: null
6073 };
6074 function useHoverReferenceInteraction(context, props = {}) {
6075 const {
6076 enabled = true,
6077 delay = 0,
6078 handleClose = null,
6079 mouseOnly = false,
6080 restMs = 0,
6081 move = true,
6082 triggerElementRef = EMPTY_REF,
6083 externalTree,
6084 isActiveTrigger = true,
6085 getHandleCloseContext,
6086 isClosing,
6087 shouldOpen: shouldOpenProp
6088 } = props;
6089 const store2 = "rootStore" in context ? context.rootStore : context;
6090 const {
6091 dataRef,
6092 events
6093 } = store2.context;
6094 const tree = useFloatingTree(externalTree);
6095 const instance = useHoverInteractionSharedState(store2);
6096 const isHoverCloseActiveRef = React28.useRef(false);
6097 const handleCloseRef = useValueAsRef(handleClose);
6098 const delayRef = useValueAsRef(delay);
6099 const restMsRef = useValueAsRef(restMs);
6100 const enabledRef = useValueAsRef(enabled);
6101 const shouldOpenRef = useValueAsRef(shouldOpenProp);
6102 const isClosingRef = useValueAsRef(isClosing);
6103 const isClickLikeOpenEvent2 = useStableCallback(() => {
6104 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
6105 });
6106 const checkShouldOpen = useStableCallback(() => {
6107 return shouldOpenRef.current?.() !== false;
6108 });
6109 const isOverInactiveTrigger = useStableCallback((currentDomReference, currentTarget, target) => {
6110 const allTriggers = store2.context.triggerElements;
6111 if (allTriggers.hasElement(currentTarget)) {
6112 return !currentDomReference || !contains(currentDomReference, currentTarget);
6113 }
6114 if (!isElement(target)) {
6115 return false;
6116 }
6117 const targetElement = target;
6118 return allTriggers.hasMatchingElement((trigger) => contains(trigger, targetElement)) && (!currentDomReference || !contains(currentDomReference, targetElement));
6119 });
6120 const cleanupMouseMoveHandler = useStableCallback(() => {
6121 if (!instance.handler) {
6122 return;
6123 }
6124 const doc = ownerDocument(store2.select("domReferenceElement"));
6125 doc.removeEventListener("mousemove", instance.handler);
6126 instance.handler = void 0;
6127 });
6128 const clearPointerEvents = useStableCallback(() => {
6129 clearSafePolygonPointerEventsMutation(instance);
6130 });
6131 if (isActiveTrigger) {
6132 instance.handleCloseOptions = handleCloseRef.current?.__options;
6133 }
6134 React28.useEffect(() => cleanupMouseMoveHandler, [cleanupMouseMoveHandler]);
6135 React28.useEffect(() => {
6136 if (!enabled) {
6137 return void 0;
6138 }
6139 function onOpenChangeLocal(details) {
6140 if (!details.open) {
6141 isHoverCloseActiveRef.current = details.reason === reason_parts_exports.triggerHover;
6142 cleanupMouseMoveHandler();
6143 instance.openChangeTimeout.clear();
6144 instance.restTimeout.clear();
6145 instance.blockMouseMove = true;
6146 instance.restTimeoutPending = false;
6147 } else {
6148 isHoverCloseActiveRef.current = false;
6149 }
6150 }
6151 events.on("openchange", onOpenChangeLocal);
6152 return () => {
6153 events.off("openchange", onOpenChangeLocal);
6154 };
6155 }, [enabled, events, instance, cleanupMouseMoveHandler]);
6156 React28.useEffect(() => {
6157 if (!enabled) {
6158 return void 0;
6159 }
6160 function closeWithDelay(event, runElseBranch = true) {
6161 const closeDelay = getDelay(delayRef.current, "close", instance.pointerType);
6162 if (closeDelay) {
6163 instance.openChangeTimeout.start(closeDelay, () => {
6164 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6165 tree?.events.emit("floating.closed", event);
6166 });
6167 } else if (runElseBranch) {
6168 instance.openChangeTimeout.clear();
6169 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6170 tree?.events.emit("floating.closed", event);
6171 }
6172 }
6173 const trigger = triggerElementRef.current ?? (isActiveTrigger ? store2.select("domReferenceElement") : null);
6174 if (!isElement(trigger)) {
6175 return void 0;
6176 }
6177 function onMouseEnter(event) {
6178 instance.openChangeTimeout.clear();
6179 instance.blockMouseMove = false;
6180 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
6181 return;
6182 }
6183 const restMsValue = getRestMs(restMsRef.current);
6184 const openDelay = getDelay(delayRef.current, "open", instance.pointerType);
6185 const eventTarget = getTarget(event);
6186 const currentTarget = event.currentTarget ?? null;
6187 const currentDomReference = store2.select("domReferenceElement");
6188 let triggerNode = currentTarget;
6189 if (isElement(eventTarget) && !store2.context.triggerElements.hasElement(eventTarget)) {
6190 for (const triggerElement of store2.context.triggerElements.elements()) {
6191 if (contains(triggerElement, eventTarget)) {
6192 triggerNode = triggerElement;
6193 break;
6194 }
6195 }
6196 }
6197 if (isElement(currentTarget) && isElement(currentDomReference) && !store2.context.triggerElements.hasElement(currentTarget) && contains(currentTarget, currentDomReference)) {
6198 triggerNode = currentDomReference;
6199 }
6200 const isOverInactive = triggerNode == null ? false : isOverInactiveTrigger(currentDomReference, triggerNode, eventTarget);
6201 const isOpen = store2.select("open");
6202 const isInClosingTransition = isClosingRef.current?.() ?? store2.select("transitionStatus") === "ending";
6203 const isHoverCloseTransition = !isOpen && isInClosingTransition && isHoverCloseActiveRef.current;
6204 const isReenteringSameTriggerDuringCloseTransition = !isOverInactive && isElement(triggerNode) && isElement(currentDomReference) && contains(currentDomReference, triggerNode) && isHoverCloseTransition;
6205 const isRestOnlyDelay = restMsValue > 0 && !openDelay;
6206 const shouldOpenImmediately = isOverInactive && (isOpen || isHoverCloseTransition) || isReenteringSameTriggerDuringCloseTransition;
6207 const shouldOpen = !isOpen || isOverInactive;
6208 if (shouldOpenImmediately) {
6209 if (checkShouldOpen()) {
6210 store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
6211 }
6212 return;
6213 }
6214 if (isRestOnlyDelay) {
6215 return;
6216 }
6217 if (openDelay) {
6218 instance.openChangeTimeout.start(openDelay, () => {
6219 if (shouldOpen && checkShouldOpen()) {
6220 store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
6221 }
6222 });
6223 } else if (shouldOpen) {
6224 if (checkShouldOpen()) {
6225 store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
6226 }
6227 }
6228 }
6229 function onMouseLeave(event) {
6230 if (isClickLikeOpenEvent2()) {
6231 clearPointerEvents();
6232 return;
6233 }
6234 cleanupMouseMoveHandler();
6235 const domReferenceElement = store2.select("domReferenceElement");
6236 const doc = ownerDocument(domReferenceElement);
6237 instance.restTimeout.clear();
6238 instance.restTimeoutPending = false;
6239 const handleCloseContextBase = dataRef.current.floatingContext ?? getHandleCloseContext?.();
6240 if (isTargetInsideEnabledTrigger(event.relatedTarget, store2.context.triggerElements)) {
6241 return;
6242 }
6243 if (handleCloseRef.current && handleCloseContextBase) {
6244 if (!store2.select("open")) {
6245 instance.openChangeTimeout.clear();
6246 }
6247 const currentTrigger = triggerElementRef.current;
6248 instance.handler = handleCloseRef.current({
6249 ...handleCloseContextBase,
6250 tree,
6251 x: event.clientX,
6252 y: event.clientY,
6253 onClose() {
6254 clearPointerEvents();
6255 cleanupMouseMoveHandler();
6256 if (enabledRef.current && !isClickLikeOpenEvent2() && currentTrigger === store2.select("domReferenceElement")) {
6257 closeWithDelay(event, true);
6258 }
6259 }
6260 });
6261 doc.addEventListener("mousemove", instance.handler);
6262 instance.handler(event);
6263 return;
6264 }
6265 const shouldClose = instance.pointerType === "touch" ? !contains(store2.select("floatingElement"), event.relatedTarget) : true;
6266 if (shouldClose) {
6267 closeWithDelay(event);
6268 }
6269 }
6270 if (move) {
6271 return mergeCleanups(addEventListener(trigger, "mousemove", onMouseEnter, {
6272 once: true
6273 }), addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
6274 }
6275 return mergeCleanups(addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
6276 }, [cleanupMouseMoveHandler, clearPointerEvents, dataRef, delayRef, store2, enabled, handleCloseRef, instance, isActiveTrigger, isOverInactiveTrigger, isClickLikeOpenEvent2, mouseOnly, move, restMsRef, triggerElementRef, tree, enabledRef, getHandleCloseContext, isClosingRef, checkShouldOpen]);
6277 return React28.useMemo(() => {
6278 if (!enabled) {
6279 return void 0;
6280 }
6281 function setPointerRef(event) {
6282 instance.pointerType = event.pointerType;
6283 }
6284 return {
6285 onPointerDown: setPointerRef,
6286 onPointerEnter: setPointerRef,
6287 onMouseMove(event) {
6288 const {
6289 nativeEvent
6290 } = event;
6291 const trigger = event.currentTarget;
6292 const currentDomReference = store2.select("domReferenceElement");
6293 const currentOpen = store2.select("open");
6294 const isOverInactive = isOverInactiveTrigger(currentDomReference, trigger, event.target);
6295 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
6296 return;
6297 }
6298 if (currentOpen && isOverInactive && instance.handleCloseOptions?.blockPointerEvents) {
6299 const floatingElement = store2.select("floatingElement");
6300 if (floatingElement) {
6301 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? trigger.ownerDocument.body;
6302 applySafePolygonPointerEventsMutation(instance, {
6303 scopeElement,
6304 referenceElement: trigger,
6305 floatingElement
6306 });
6307 }
6308 }
6309 const restMsValue = getRestMs(restMsRef.current);
6310 if (currentOpen && !isOverInactive || restMsValue === 0) {
6311 return;
6312 }
6313 if (!isOverInactive && instance.restTimeoutPending && event.movementX ** 2 + event.movementY ** 2 < 2) {
6314 return;
6315 }
6316 instance.restTimeout.clear();
6317 function handleMouseMove() {
6318 instance.restTimeoutPending = false;
6319 if (isClickLikeOpenEvent2()) {
6320 return;
6321 }
6322 const latestOpen = store2.select("open");
6323 if (!instance.blockMouseMove && (!latestOpen || isOverInactive) && checkShouldOpen()) {
6324 store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, nativeEvent, trigger));
6325 }
6326 }
6327 if (instance.pointerType === "touch") {
6328 ReactDOM4.flushSync(() => {
6329 handleMouseMove();
6330 });
6331 } else if (isOverInactive && currentOpen) {
6332 handleMouseMove();
6333 } else {
6334 instance.restTimeoutPending = true;
6335 instance.restTimeout.start(restMsValue, handleMouseMove);
6336 }
6337 }
6338 };
6339 }, [enabled, instance, isClickLikeOpenEvent2, isOverInactiveTrigger, mouseOnly, store2, restMsRef, checkShouldOpen]);
6340 }
6341
6342 // node_modules/@base-ui/react/esm/floating-ui-react/safePolygon.js
6343 var CURSOR_SPEED_THRESHOLD = 0.1;
6344 var CURSOR_SPEED_THRESHOLD_SQUARED = CURSOR_SPEED_THRESHOLD * CURSOR_SPEED_THRESHOLD;
6345 var POLYGON_BUFFER = 0.5;
6346 function hasIntersectingEdge(pointX, pointY, xi, yi, xj, yj) {
6347 return yi >= pointY !== yj >= pointY && pointX <= (xj - xi) * (pointY - yi) / (yj - yi) + xi;
6348 }
6349 function isPointInQuadrilateral(pointX, pointY, x1, y1, x2, y2, x3, y3, x4, y4) {
6350 let isInsideValue = false;
6351 if (hasIntersectingEdge(pointX, pointY, x1, y1, x2, y2)) {
6352 isInsideValue = !isInsideValue;
6353 }
6354 if (hasIntersectingEdge(pointX, pointY, x2, y2, x3, y3)) {
6355 isInsideValue = !isInsideValue;
6356 }
6357 if (hasIntersectingEdge(pointX, pointY, x3, y3, x4, y4)) {
6358 isInsideValue = !isInsideValue;
6359 }
6360 if (hasIntersectingEdge(pointX, pointY, x4, y4, x1, y1)) {
6361 isInsideValue = !isInsideValue;
6362 }
6363 return isInsideValue;
6364 }
6365 function isInsideRect(pointX, pointY, rect) {
6366 return pointX >= rect.x && pointX <= rect.x + rect.width && pointY >= rect.y && pointY <= rect.y + rect.height;
6367 }
6368 function isInsideAxisAlignedRect(pointX, pointY, x1, y1, x2, y2) {
6369 const minX = Math.min(x1, x2);
6370 const maxX = Math.max(x1, x2);
6371 const minY = Math.min(y1, y2);
6372 const maxY = Math.max(y1, y2);
6373 return pointX >= minX && pointX <= maxX && pointY >= minY && pointY <= maxY;
6374 }
6375 function safePolygon(options = {}) {
6376 const {
6377 blockPointerEvents = false
6378 } = options;
6379 const timeout = new Timeout();
6380 const fn = ({
6381 x,
6382 y,
6383 placement,
6384 elements,
6385 onClose,
6386 nodeId,
6387 tree
6388 }) => {
6389 const side = placement?.split("-")[0];
6390 let hasLanded = false;
6391 let lastX = null;
6392 let lastY = null;
6393 let lastCursorTime = typeof performance !== "undefined" ? performance.now() : 0;
6394 function isCursorMovingSlowly(nextX, nextY) {
6395 const currentTime = performance.now();
6396 const elapsedTime = currentTime - lastCursorTime;
6397 if (lastX === null || lastY === null || elapsedTime === 0) {
6398 lastX = nextX;
6399 lastY = nextY;
6400 lastCursorTime = currentTime;
6401 return false;
6402 }
6403 const deltaX = nextX - lastX;
6404 const deltaY = nextY - lastY;
6405 const distanceSquared = deltaX * deltaX + deltaY * deltaY;
6406 const thresholdSquared = elapsedTime * elapsedTime * CURSOR_SPEED_THRESHOLD_SQUARED;
6407 lastX = nextX;
6408 lastY = nextY;
6409 lastCursorTime = currentTime;
6410 return distanceSquared < thresholdSquared;
6411 }
6412 function close() {
6413 timeout.clear();
6414 onClose();
6415 }
6416 return function onMouseMove(event) {
6417 timeout.clear();
6418 const domReference = elements.domReference;
6419 const floating = elements.floating;
6420 if (!domReference || !floating || side == null || x == null || y == null) {
6421 return void 0;
6422 }
6423 const {
6424 clientX,
6425 clientY
6426 } = event;
6427 const target = getTarget(event);
6428 const isLeave = event.type === "mouseleave";
6429 const isOverFloatingEl = contains(floating, target);
6430 const isOverReferenceEl = contains(domReference, target);
6431 if (isOverFloatingEl) {
6432 hasLanded = true;
6433 if (!isLeave) {
6434 return void 0;
6435 }
6436 }
6437 if (isOverReferenceEl) {
6438 hasLanded = false;
6439 if (!isLeave) {
6440 hasLanded = true;
6441 return void 0;
6442 }
6443 }
6444 if (isLeave && isElement(event.relatedTarget) && contains(floating, event.relatedTarget)) {
6445 return void 0;
6446 }
6447 function hasOpenChildNode() {
6448 return Boolean(tree && getNodeChildren(tree.nodesRef.current, nodeId).length > 0);
6449 }
6450 function closeIfNoOpenChild() {
6451 if (!hasOpenChildNode()) {
6452 close();
6453 }
6454 }
6455 if (hasOpenChildNode()) {
6456 return void 0;
6457 }
6458 const refRect = domReference.getBoundingClientRect();
6459 const rect = floating.getBoundingClientRect();
6460 const cursorLeaveFromRight = x > rect.right - rect.width / 2;
6461 const cursorLeaveFromBottom = y > rect.bottom - rect.height / 2;
6462 const isFloatingWider = rect.width > refRect.width;
6463 const isFloatingTaller = rect.height > refRect.height;
6464 const left = (isFloatingWider ? refRect : rect).left;
6465 const right = (isFloatingWider ? refRect : rect).right;
6466 const top = (isFloatingTaller ? refRect : rect).top;
6467 const bottom = (isFloatingTaller ? refRect : rect).bottom;
6468 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) {
6469 closeIfNoOpenChild();
6470 return void 0;
6471 }
6472 let isInsideTroughRect = false;
6473 switch (side) {
6474 case "top":
6475 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, refRect.top + 1, right, rect.bottom - 1);
6476 break;
6477 case "bottom":
6478 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, rect.top + 1, right, refRect.bottom - 1);
6479 break;
6480 case "left":
6481 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, rect.right - 1, bottom, refRect.left + 1, top);
6482 break;
6483 case "right":
6484 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, refRect.right - 1, bottom, rect.left + 1, top);
6485 break;
6486 default:
6487 }
6488 if (isInsideTroughRect) {
6489 return void 0;
6490 }
6491 if (hasLanded && !isInsideRect(clientX, clientY, refRect)) {
6492 closeIfNoOpenChild();
6493 return void 0;
6494 }
6495 if (!isLeave && isCursorMovingSlowly(clientX, clientY)) {
6496 closeIfNoOpenChild();
6497 return void 0;
6498 }
6499 let isInsidePolygon = false;
6500 switch (side) {
6501 case "top": {
6502 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
6503 const cursorPointOneX = isFloatingWider ? x + cursorXOffset : cursorLeaveFromRight ? x + cursorXOffset : x - cursorXOffset;
6504 const cursorPointTwoX = isFloatingWider ? x - cursorXOffset : cursorLeaveFromRight ? x + cursorXOffset : x - cursorXOffset;
6505 const cursorPointY = y + POLYGON_BUFFER + 1;
6506 const commonYLeft = cursorLeaveFromRight ? rect.bottom - POLYGON_BUFFER : isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top;
6507 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top : rect.bottom - POLYGON_BUFFER;
6508 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
6509 break;
6510 }
6511 case "bottom": {
6512 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
6513 const cursorPointOneX = isFloatingWider ? x + cursorXOffset : cursorLeaveFromRight ? x + cursorXOffset : x - cursorXOffset;
6514 const cursorPointTwoX = isFloatingWider ? x - cursorXOffset : cursorLeaveFromRight ? x + cursorXOffset : x - cursorXOffset;
6515 const cursorPointY = y - POLYGON_BUFFER;
6516 const commonYLeft = cursorLeaveFromRight ? rect.top + POLYGON_BUFFER : isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom;
6517 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom : rect.top + POLYGON_BUFFER;
6518 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
6519 break;
6520 }
6521 case "left": {
6522 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
6523 const cursorPointOneY = isFloatingTaller ? y + cursorYOffset : cursorLeaveFromBottom ? y + cursorYOffset : y - cursorYOffset;
6524 const cursorPointTwoY = isFloatingTaller ? y - cursorYOffset : cursorLeaveFromBottom ? y + cursorYOffset : y - cursorYOffset;
6525 const cursorPointX = x + POLYGON_BUFFER + 1;
6526 const commonXTop = cursorLeaveFromBottom ? rect.right - POLYGON_BUFFER : isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left;
6527 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left : rect.right - POLYGON_BUFFER;
6528 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, commonXTop, rect.top, commonXBottom, rect.bottom, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY);
6529 break;
6530 }
6531 case "right": {
6532 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
6533 const cursorPointOneY = isFloatingTaller ? y + cursorYOffset : cursorLeaveFromBottom ? y + cursorYOffset : y - cursorYOffset;
6534 const cursorPointTwoY = isFloatingTaller ? y - cursorYOffset : cursorLeaveFromBottom ? y + cursorYOffset : y - cursorYOffset;
6535 const cursorPointX = x - POLYGON_BUFFER;
6536 const commonXTop = cursorLeaveFromBottom ? rect.left + POLYGON_BUFFER : isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right;
6537 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right : rect.left + POLYGON_BUFFER;
6538 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY, commonXTop, rect.top, commonXBottom, rect.bottom);
6539 break;
6540 }
6541 default:
6542 }
6543 if (!isInsidePolygon) {
6544 closeIfNoOpenChild();
6545 } else if (!hasLanded) {
6546 timeout.start(40, closeIfNoOpenChild);
6547 }
6548 return void 0;
6549 };
6550 };
6551 fn.__options = {
6552 ...options,
6553 blockPointerEvents
6554 };
6555 return fn;
6556 }
6557
6558 // node_modules/@base-ui/react/esm/utils/popupStateMapping.js
6559 var CommonPopupDataAttributes = (function(CommonPopupDataAttributes2) {
6560 CommonPopupDataAttributes2["open"] = "data-open";
6561 CommonPopupDataAttributes2["closed"] = "data-closed";
6562 CommonPopupDataAttributes2[CommonPopupDataAttributes2["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle";
6563 CommonPopupDataAttributes2[CommonPopupDataAttributes2["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle";
6564 CommonPopupDataAttributes2["anchorHidden"] = "data-anchor-hidden";
6565 CommonPopupDataAttributes2["side"] = "data-side";
6566 CommonPopupDataAttributes2["align"] = "data-align";
6567 return CommonPopupDataAttributes2;
6568 })({});
6569 var CommonTriggerDataAttributes = /* @__PURE__ */ (function(CommonTriggerDataAttributes2) {
6570 CommonTriggerDataAttributes2["popupOpen"] = "data-popup-open";
6571 CommonTriggerDataAttributes2["pressed"] = "data-pressed";
6572 return CommonTriggerDataAttributes2;
6573 })({});
6574 var TRIGGER_HOOK = {
6575 [CommonTriggerDataAttributes.popupOpen]: ""
6576 };
6577 var PRESSABLE_TRIGGER_HOOK = {
6578 [CommonTriggerDataAttributes.popupOpen]: "",
6579 [CommonTriggerDataAttributes.pressed]: ""
6580 };
6581 var POPUP_OPEN_HOOK = {
6582 [CommonPopupDataAttributes.open]: ""
6583 };
6584 var POPUP_CLOSED_HOOK = {
6585 [CommonPopupDataAttributes.closed]: ""
6586 };
6587 var ANCHOR_HIDDEN_HOOK = {
6588 [CommonPopupDataAttributes.anchorHidden]: ""
6589 };
6590 var triggerOpenStateMapping = {
6591 open(value) {
6592 if (value) {
6593 return TRIGGER_HOOK;
6594 }
6595 return null;
6596 }
6597 };
6598 var popupStateMapping = {
6599 open(value) {
6600 if (value) {
6601 return POPUP_OPEN_HOOK;
6602 }
6603 return POPUP_CLOSED_HOOK;
6604 },
6605 anchorHidden(value) {
6606 if (value) {
6607 return ANCHOR_HIDDEN_HOOK;
6608 }
6609 return null;
6610 }
6611 };
6612
6613 // node_modules/@base-ui/utils/esm/inertValue.js
6614 function inertValue(value) {
6615 if (isReactVersionAtLeast(19)) {
6616 return value;
6617 }
6618 return value ? "true" : void 0;
6619 }
6620
6621 // node_modules/@base-ui/react/esm/utils/useAnchorPositioning.js
6622 var React29 = __toESM(require_react(), 1);
6623
6624 // node_modules/@base-ui/react/esm/floating-ui-react/middleware/arrow.js
6625 var baseArrow = (options) => ({
6626 name: "arrow",
6627 options,
6628 async fn(state) {
6629 const {
6630 x,
6631 y,
6632 placement,
6633 rects,
6634 platform: platform3,
6635 elements,
6636 middlewareData
6637 } = state;
6638 const {
6639 element,
6640 padding = 0,
6641 offsetParent = "real"
6642 } = evaluate(options, state) || {};
6643 if (element == null) {
6644 return {};
6645 }
6646 const paddingObject = getPaddingObject(padding);
6647 const coords = {
6648 x,
6649 y
6650 };
6651 const axis = getAlignmentAxis(placement);
6652 const length = getAxisLength(axis);
6653 const arrowDimensions = await platform3.getDimensions(element);
6654 const isYAxis = axis === "y";
6655 const minProp = isYAxis ? "top" : "left";
6656 const maxProp = isYAxis ? "bottom" : "right";
6657 const clientProp = isYAxis ? "clientHeight" : "clientWidth";
6658 const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
6659 const startDiff = coords[axis] - rects.reference[axis];
6660 const arrowOffsetParent = offsetParent === "real" ? await platform3.getOffsetParent?.(element) : elements.floating;
6661 let clientSize = elements.floating[clientProp] || rects.floating[length];
6662 if (!clientSize || !await platform3.isElement?.(arrowOffsetParent)) {
6663 clientSize = elements.floating[clientProp] || rects.floating[length];
6664 }
6665 const centerToReference = endDiff / 2 - startDiff / 2;
6666 const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
6667 const minPadding = Math.min(paddingObject[minProp], largestPossiblePadding);
6668 const maxPadding = Math.min(paddingObject[maxProp], largestPossiblePadding);
6669 const min2 = minPadding;
6670 const max2 = clientSize - arrowDimensions[length] - maxPadding;
6671 const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
6672 const offset4 = clamp(min2, center, max2);
6673 const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset4 && rects.reference[length] / 2 - (center < min2 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
6674 const alignmentOffset = shouldAddOffset ? center < min2 ? center - min2 : center - max2 : 0;
6675 return {
6676 [axis]: coords[axis] + alignmentOffset,
6677 data: {
6678 [axis]: offset4,
6679 centerOffset: center - offset4 - alignmentOffset,
6680 ...shouldAddOffset && {
6681 alignmentOffset
6682 }
6683 },
6684 reset: shouldAddOffset
6685 };
6686 }
6687 });
6688 var arrow4 = (options, deps) => ({
6689 ...baseArrow(options),
6690 options: [options, deps]
6691 });
6692
6693 // node_modules/@base-ui/react/esm/utils/hideMiddleware.js
6694 var hide4 = {
6695 name: "hide",
6696 async fn(state) {
6697 const {
6698 width,
6699 height,
6700 x,
6701 y
6702 } = state.rects.reference;
6703 const anchorHidden = width === 0 && height === 0 && x === 0 && y === 0;
6704 const nativeHideResult = await hide3().fn(state);
6705 return {
6706 data: {
6707 referenceHidden: nativeHideResult.data?.referenceHidden || anchorHidden
6708 }
6709 };
6710 }
6711 };
6712
6713 // node_modules/@base-ui/react/esm/utils/adaptiveOriginMiddleware.js
6714 var DEFAULT_SIDES = {
6715 sideX: "left",
6716 sideY: "top"
6717 };
6718 var adaptiveOrigin = {
6719 name: "adaptiveOrigin",
6720 async fn(state) {
6721 const {
6722 x: rawX,
6723 y: rawY,
6724 rects: {
6725 floating: floatRect
6726 },
6727 elements: {
6728 floating
6729 },
6730 platform: platform3,
6731 strategy,
6732 placement
6733 } = state;
6734 const win = getWindow(floating);
6735 const styles = win.getComputedStyle(floating);
6736 const hasTransition = styles.transitionDuration !== "0s" && styles.transitionDuration !== "";
6737 if (!hasTransition) {
6738 return {
6739 x: rawX,
6740 y: rawY,
6741 data: DEFAULT_SIDES
6742 };
6743 }
6744 const offsetParent = await platform3.getOffsetParent?.(floating);
6745 let offsetDimensions = {
6746 width: 0,
6747 height: 0
6748 };
6749 if (strategy === "fixed" && win?.visualViewport) {
6750 offsetDimensions = {
6751 width: win.visualViewport.width,
6752 height: win.visualViewport.height
6753 };
6754 } else if (offsetParent === win) {
6755 const doc = ownerDocument(floating);
6756 offsetDimensions = {
6757 width: doc.documentElement.clientWidth,
6758 height: doc.documentElement.clientHeight
6759 };
6760 } else if (await platform3.isElement?.(offsetParent)) {
6761 offsetDimensions = await platform3.getDimensions(offsetParent);
6762 }
6763 const currentSide = getSide(placement);
6764 let x = rawX;
6765 let y = rawY;
6766 if (currentSide === "left") {
6767 x = offsetDimensions.width - (rawX + floatRect.width);
6768 }
6769 if (currentSide === "top") {
6770 y = offsetDimensions.height - (rawY + floatRect.height);
6771 }
6772 const sideX = currentSide === "left" ? "right" : DEFAULT_SIDES.sideX;
6773 const sideY = currentSide === "top" ? "bottom" : DEFAULT_SIDES.sideY;
6774 return {
6775 x,
6776 y,
6777 data: {
6778 sideX,
6779 sideY
6780 }
6781 };
6782 }
6783 };
6784
6785 // node_modules/@base-ui/react/esm/utils/useAnchorPositioning.js
6786 function getLogicalSide(sideParam, renderedSide, isRtl) {
6787 const isLogicalSideParam = sideParam === "inline-start" || sideParam === "inline-end";
6788 const logicalRight = isRtl ? "inline-start" : "inline-end";
6789 const logicalLeft = isRtl ? "inline-end" : "inline-start";
6790 return {
6791 top: "top",
6792 right: isLogicalSideParam ? logicalRight : "right",
6793 bottom: "bottom",
6794 left: isLogicalSideParam ? logicalLeft : "left"
6795 }[renderedSide];
6796 }
6797 function getOffsetData(state, sideParam, isRtl) {
6798 const {
6799 rects,
6800 placement
6801 } = state;
6802 const data = {
6803 side: getLogicalSide(sideParam, getSide(placement), isRtl),
6804 align: getAlignment(placement) || "center",
6805 anchor: {
6806 width: rects.reference.width,
6807 height: rects.reference.height
6808 },
6809 positioner: {
6810 width: rects.floating.width,
6811 height: rects.floating.height
6812 }
6813 };
6814 return data;
6815 }
6816 function useAnchorPositioning(params) {
6817 const {
6818 // Public parameters
6819 anchor,
6820 positionMethod = "absolute",
6821 side: sideParam = "bottom",
6822 sideOffset = 0,
6823 align = "center",
6824 alignOffset = 0,
6825 collisionBoundary,
6826 collisionPadding: collisionPaddingParam = 5,
6827 sticky = false,
6828 arrowPadding = 5,
6829 disableAnchorTracking = false,
6830 inline: inlineMiddleware,
6831 // Private parameters
6832 keepMounted = false,
6833 floatingRootContext,
6834 mounted,
6835 collisionAvoidance,
6836 shiftCrossAxis = false,
6837 nodeId,
6838 adaptiveOrigin: adaptiveOrigin2,
6839 lazyFlip = false,
6840 externalTree
6841 } = params;
6842 const [mountSide, setMountSide] = React29.useState(null);
6843 if (!mounted && mountSide !== null) {
6844 setMountSide(null);
6845 }
6846 const collisionAvoidanceSide = collisionAvoidance.side || "flip";
6847 const collisionAvoidanceAlign = collisionAvoidance.align || "flip";
6848 const collisionAvoidanceFallbackAxisSide = collisionAvoidance.fallbackAxisSide || "end";
6849 const anchorFn = typeof anchor === "function" ? anchor : void 0;
6850 const anchorFnCallback = useStableCallback(anchorFn);
6851 const anchorDep = anchorFn ? anchorFnCallback : anchor;
6852 const anchorValueRef = useValueAsRef(anchor);
6853 const mountedRef = useValueAsRef(mounted);
6854 const direction = useDirection();
6855 const isRtl = direction === "rtl";
6856 const side = mountSide || {
6857 top: "top",
6858 right: "right",
6859 bottom: "bottom",
6860 left: "left",
6861 "inline-end": isRtl ? "left" : "right",
6862 "inline-start": isRtl ? "right" : "left"
6863 }[sideParam];
6864 const placement = align === "center" ? side : `${side}-${align}`;
6865 let collisionPadding = collisionPaddingParam;
6866 const bias = 1;
6867 const biasTop = sideParam === "bottom" ? bias : 0;
6868 const biasBottom = sideParam === "top" ? bias : 0;
6869 const biasLeft = sideParam === "right" ? bias : 0;
6870 const biasRight = sideParam === "left" ? bias : 0;
6871 if (typeof collisionPadding === "number") {
6872 collisionPadding = {
6873 top: collisionPadding + biasTop,
6874 right: collisionPadding + biasRight,
6875 bottom: collisionPadding + biasBottom,
6876 left: collisionPadding + biasLeft
6877 };
6878 } else if (collisionPadding) {
6879 collisionPadding = {
6880 top: (collisionPadding.top || 0) + biasTop,
6881 right: (collisionPadding.right || 0) + biasRight,
6882 bottom: (collisionPadding.bottom || 0) + biasBottom,
6883 left: (collisionPadding.left || 0) + biasLeft
6884 };
6885 }
6886 const commonCollisionProps = {
6887 boundary: collisionBoundary === "clipping-ancestors" ? "clippingAncestors" : collisionBoundary,
6888 padding: collisionPadding
6889 };
6890 const arrowRef = React29.useRef(null);
6891 const sideOffsetRef = useValueAsRef(sideOffset);
6892 const alignOffsetRef = useValueAsRef(alignOffset);
6893 const sideOffsetDep = typeof sideOffset !== "function" ? sideOffset : 0;
6894 const alignOffsetDep = typeof alignOffset !== "function" ? alignOffset : 0;
6895 const middleware = [];
6896 if (inlineMiddleware) {
6897 middleware.push(inlineMiddleware);
6898 }
6899 middleware.push(offset3((state) => {
6900 const data = getOffsetData(state, sideParam, isRtl);
6901 const sideAxis = typeof sideOffsetRef.current === "function" ? sideOffsetRef.current(data) : sideOffsetRef.current;
6902 const alignAxis = typeof alignOffsetRef.current === "function" ? alignOffsetRef.current(data) : alignOffsetRef.current;
6903 return {
6904 mainAxis: sideAxis,
6905 crossAxis: alignAxis,
6906 alignmentAxis: alignAxis
6907 };
6908 }, [sideOffsetDep, alignOffsetDep, isRtl, sideParam]));
6909 const shiftDisabled = collisionAvoidanceAlign === "none" && collisionAvoidanceSide !== "shift";
6910 const crossAxisShiftEnabled = !shiftDisabled && (sticky || shiftCrossAxis || collisionAvoidanceSide === "shift");
6911 const flipMiddleware = collisionAvoidanceSide === "none" ? null : flip3({
6912 ...commonCollisionProps,
6913 // Ensure the popup flips if it's been limited by its --available-height and it resizes.
6914 // Since the size() padding is smaller than the flip() padding, flip() will take precedence.
6915 padding: {
6916 top: collisionPadding.top + bias,
6917 right: collisionPadding.right + bias,
6918 bottom: collisionPadding.bottom + bias,
6919 left: collisionPadding.left + bias
6920 },
6921 mainAxis: !shiftCrossAxis && collisionAvoidanceSide === "flip",
6922 crossAxis: collisionAvoidanceAlign === "flip" ? "alignment" : false,
6923 fallbackAxisSideDirection: collisionAvoidanceFallbackAxisSide
6924 });
6925 const shiftMiddleware = shiftDisabled ? null : shift3((data) => {
6926 const html = ownerDocument(data.elements.floating).documentElement;
6927 return {
6928 ...commonCollisionProps,
6929 // Use the Layout Viewport to avoid shifting around when pinch-zooming
6930 // for context menus.
6931 rootBoundary: shiftCrossAxis ? {
6932 x: 0,
6933 y: 0,
6934 width: html.clientWidth,
6935 height: html.clientHeight
6936 } : void 0,
6937 mainAxis: collisionAvoidanceAlign !== "none",
6938 crossAxis: crossAxisShiftEnabled,
6939 limiter: sticky || shiftCrossAxis ? void 0 : limitShift3((limitData) => {
6940 if (!arrowRef.current) {
6941 return {};
6942 }
6943 const {
6944 width,
6945 height
6946 } = arrowRef.current.getBoundingClientRect();
6947 const sideAxis = getSideAxis(getSide(limitData.placement));
6948 const arrowSize = sideAxis === "y" ? width : height;
6949 const offsetAmount = sideAxis === "y" ? collisionPadding.left + collisionPadding.right : collisionPadding.top + collisionPadding.bottom;
6950 return {
6951 offset: arrowSize / 2 + offsetAmount / 2
6952 };
6953 })
6954 };
6955 }, [commonCollisionProps, sticky, shiftCrossAxis, collisionPadding, collisionAvoidanceAlign]);
6956 if (collisionAvoidanceSide === "shift" || collisionAvoidanceAlign === "shift" || align === "center") {
6957 middleware.push(shiftMiddleware, flipMiddleware);
6958 } else {
6959 middleware.push(flipMiddleware, shiftMiddleware);
6960 }
6961 middleware.push(size3({
6962 ...commonCollisionProps,
6963 apply({
6964 elements: {
6965 floating
6966 },
6967 availableWidth,
6968 availableHeight,
6969 rects
6970 }) {
6971 if (!mountedRef.current) {
6972 return;
6973 }
6974 const floatingStyle = floating.style;
6975 floatingStyle.setProperty("--available-width", `${availableWidth}px`);
6976 floatingStyle.setProperty("--available-height", `${availableHeight}px`);
6977 const dpr = getWindow(floating).devicePixelRatio || 1;
6978 const {
6979 x: x2,
6980 y: y2,
6981 width,
6982 height
6983 } = rects.reference;
6984 const anchorWidth = (Math.round((x2 + width) * dpr) - Math.round(x2 * dpr)) / dpr;
6985 const anchorHeight = (Math.round((y2 + height) * dpr) - Math.round(y2 * dpr)) / dpr;
6986 floatingStyle.setProperty("--anchor-width", `${anchorWidth}px`);
6987 floatingStyle.setProperty("--anchor-height", `${anchorHeight}px`);
6988 }
6989 }), arrow4((state) => ({
6990 // `transform-origin` calculations rely on an element existing. If the arrow hasn't been set,
6991 // we'll create a fake element.
6992 element: arrowRef.current || ownerDocument(state.elements.floating).createElement("div"),
6993 padding: arrowPadding,
6994 offsetParent: "floating"
6995 }), [arrowPadding]), {
6996 name: "transformOrigin",
6997 fn(state) {
6998 const {
6999 elements: elements2,
7000 middlewareData: middlewareData2,
7001 placement: renderedPlacement2,
7002 rects,
7003 y: y2
7004 } = state;
7005 const currentRenderedSide = getSide(renderedPlacement2);
7006 const currentRenderedAxis = getSideAxis(currentRenderedSide);
7007 const arrowEl = arrowRef.current;
7008 const arrowX = middlewareData2.arrow?.x || 0;
7009 const arrowY = middlewareData2.arrow?.y || 0;
7010 const arrowWidth = arrowEl?.clientWidth || 0;
7011 const arrowHeight = arrowEl?.clientHeight || 0;
7012 const transformX = arrowX + arrowWidth / 2;
7013 const transformY = arrowY + arrowHeight / 2;
7014 const shiftY = Math.abs(middlewareData2.shift?.y || 0);
7015 const halfAnchorHeight = rects.reference.height / 2;
7016 const sideOffsetValue = typeof sideOffset === "function" ? sideOffset(getOffsetData(state, sideParam, isRtl)) : sideOffset;
7017 const isOverlappingAnchor = shiftY > sideOffsetValue;
7018 const adjacentTransformOrigin = {
7019 top: `${transformX}px calc(100% + ${sideOffsetValue}px)`,
7020 bottom: `${transformX}px ${-sideOffsetValue}px`,
7021 left: `calc(100% + ${sideOffsetValue}px) ${transformY}px`,
7022 right: `${-sideOffsetValue}px ${transformY}px`
7023 }[currentRenderedSide];
7024 const overlapTransformOrigin = `${transformX}px ${rects.reference.y + halfAnchorHeight - y2}px`;
7025 elements2.floating.style.setProperty("--transform-origin", crossAxisShiftEnabled && currentRenderedAxis === "y" && isOverlappingAnchor ? overlapTransformOrigin : adjacentTransformOrigin);
7026 return {};
7027 }
7028 }, hide4, adaptiveOrigin2);
7029 useIsoLayoutEffect(() => {
7030 if (!mounted && floatingRootContext) {
7031 floatingRootContext.update({
7032 referenceElement: null,
7033 floatingElement: null,
7034 domReferenceElement: null,
7035 positionReference: null
7036 });
7037 }
7038 }, [mounted, floatingRootContext]);
7039 const autoUpdateOptions = React29.useMemo(() => ({
7040 elementResize: !disableAnchorTracking && typeof ResizeObserver !== "undefined",
7041 layoutShift: !disableAnchorTracking && typeof IntersectionObserver !== "undefined"
7042 }), [disableAnchorTracking]);
7043 const {
7044 refs,
7045 elements,
7046 x,
7047 y,
7048 middlewareData,
7049 update: update2,
7050 placement: renderedPlacement,
7051 context,
7052 isPositioned,
7053 floatingStyles: originalFloatingStyles
7054 } = useFloating2({
7055 rootContext: floatingRootContext,
7056 open: keepMounted ? mounted : void 0,
7057 placement,
7058 middleware,
7059 strategy: positionMethod,
7060 whileElementsMounted: keepMounted ? void 0 : (...args) => autoUpdate(...args, autoUpdateOptions),
7061 nodeId,
7062 externalTree
7063 });
7064 const {
7065 sideX,
7066 sideY
7067 } = middlewareData.adaptiveOrigin || DEFAULT_SIDES;
7068 const resolvedPosition = isPositioned ? positionMethod : "fixed";
7069 const floatingStyles = React29.useMemo(() => {
7070 const base = adaptiveOrigin2 ? {
7071 position: resolvedPosition,
7072 [sideX]: x,
7073 [sideY]: y
7074 } : {
7075 position: resolvedPosition,
7076 ...originalFloatingStyles
7077 };
7078 if (!isPositioned) {
7079 base.opacity = 0;
7080 }
7081 return base;
7082 }, [adaptiveOrigin2, resolvedPosition, sideX, x, sideY, y, originalFloatingStyles, isPositioned]);
7083 const registeredPositionReferenceRef = React29.useRef(null);
7084 useIsoLayoutEffect(() => {
7085 if (!mounted) {
7086 return;
7087 }
7088 const anchorValue = anchorValueRef.current;
7089 const resolvedAnchor = typeof anchorValue === "function" ? anchorValue() : anchorValue;
7090 const unwrappedElement = (isRef(resolvedAnchor) ? resolvedAnchor.current : resolvedAnchor) || null;
7091 const finalAnchor = unwrappedElement || null;
7092 if (finalAnchor !== registeredPositionReferenceRef.current) {
7093 refs.setPositionReference(finalAnchor);
7094 registeredPositionReferenceRef.current = finalAnchor;
7095 }
7096 }, [mounted, refs, anchorDep, anchorValueRef]);
7097 React29.useEffect(() => {
7098 if (!mounted) {
7099 return;
7100 }
7101 const anchorValue = anchorValueRef.current;
7102 if (typeof anchorValue === "function") {
7103 return;
7104 }
7105 if (isRef(anchorValue) && anchorValue.current !== registeredPositionReferenceRef.current) {
7106 refs.setPositionReference(anchorValue.current);
7107 registeredPositionReferenceRef.current = anchorValue.current;
7108 }
7109 }, [mounted, refs, anchorDep, anchorValueRef]);
7110 React29.useEffect(() => {
7111 if (keepMounted && mounted && elements.domReference && elements.floating) {
7112 return autoUpdate(elements.domReference, elements.floating, update2, autoUpdateOptions);
7113 }
7114 return void 0;
7115 }, [keepMounted, mounted, elements, update2, autoUpdateOptions]);
7116 const renderedSide = getSide(renderedPlacement);
7117 const logicalRenderedSide = getLogicalSide(sideParam, renderedSide, isRtl);
7118 const renderedAlign = getAlignment(renderedPlacement) || "center";
7119 const anchorHidden = Boolean(middlewareData.hide?.referenceHidden);
7120 useIsoLayoutEffect(() => {
7121 if (lazyFlip && mounted && isPositioned) {
7122 setMountSide(renderedSide);
7123 }
7124 }, [lazyFlip, mounted, isPositioned, renderedSide]);
7125 const arrowStyles = React29.useMemo(() => ({
7126 position: "absolute",
7127 top: middlewareData.arrow?.y,
7128 left: middlewareData.arrow?.x
7129 }), [middlewareData.arrow]);
7130 const arrowUncentered = middlewareData.arrow?.centerOffset !== 0;
7131 return React29.useMemo(() => ({
7132 positionerStyles: floatingStyles,
7133 arrowStyles,
7134 arrowRef,
7135 arrowUncentered,
7136 side: logicalRenderedSide,
7137 align: renderedAlign,
7138 physicalSide: renderedSide,
7139 anchorHidden,
7140 refs,
7141 context,
7142 isPositioned,
7143 update: update2
7144 }), [floatingStyles, arrowStyles, arrowRef, arrowUncentered, logicalRenderedSide, renderedAlign, renderedSide, anchorHidden, refs, context, isPositioned, update2]);
7145 }
7146 function isRef(param) {
7147 return param != null && "current" in param;
7148 }
7149
7150 // node_modules/@base-ui/react/esm/utils/getDisabledMountTransitionStyles.js
7151 function getDisabledMountTransitionStyles(transitionStatus) {
7152 return transitionStatus === "starting" ? DISABLED_TRANSITIONS_STYLE : EMPTY_OBJECT;
7153 }
7154
7155 // node_modules/@base-ui/react/esm/utils/usePositioner.js
7156 function usePositioner(componentProps, state, {
7157 styles,
7158 transitionStatus,
7159 props,
7160 refs,
7161 hidden,
7162 inert = false
7163 }) {
7164 const style = {
7165 ...styles
7166 };
7167 if (inert) {
7168 style.pointerEvents = "none";
7169 }
7170 return useRenderElement("div", componentProps, {
7171 state,
7172 ref: refs,
7173 props: [{
7174 role: "presentation",
7175 hidden,
7176 style
7177 }, getDisabledMountTransitionStyles(transitionStatus), props],
7178 stateAttributesMapping: popupStateMapping
7179 });
7180 }
7181
7182 // node_modules/@base-ui/react/esm/utils/usePopupViewport.js
7183 var React32 = __toESM(require_react(), 1);
7184 var ReactDOM5 = __toESM(require_react_dom(), 1);
7185
7186 // node_modules/@base-ui/utils/esm/usePreviousValue.js
7187 var React30 = __toESM(require_react(), 1);
7188 function usePreviousValue(value) {
7189 const [state, setState] = React30.useState({
7190 current: value,
7191 previous: null
7192 });
7193 if (value !== state.current) {
7194 setState({
7195 current: value,
7196 previous: state.current
7197 });
7198 }
7199 return state.previous;
7200 }
7201
7202 // node_modules/@base-ui/react/esm/utils/usePopupAutoResize.js
7203 var React31 = __toESM(require_react(), 1);
7204
7205 // node_modules/@base-ui/react/esm/utils/getCssDimensions.js
7206 function getCssDimensions2(element) {
7207 const css = getComputedStyle2(element);
7208 let width = parseFloat(css.width) || 0;
7209 let height = parseFloat(css.height) || 0;
7210 const hasOffset = isHTMLElement(element);
7211 const offsetWidth = hasOffset ? element.offsetWidth : width;
7212 const offsetHeight = hasOffset ? element.offsetHeight : height;
7213 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
7214 if (shouldFallback) {
7215 width = offsetWidth;
7216 height = offsetHeight;
7217 }
7218 return {
7219 width,
7220 height
7221 };
7222 }
7223
7224 // node_modules/@base-ui/react/esm/utils/usePopupAutoResize.js
7225 var DEFAULT_ENABLED = () => true;
7226 function usePopupAutoResize(parameters) {
7227 const {
7228 popupElement,
7229 positionerElement,
7230 content,
7231 mounted,
7232 enabled = DEFAULT_ENABLED,
7233 onMeasureLayout: onMeasureLayoutParam,
7234 onMeasureLayoutComplete: onMeasureLayoutCompleteParam,
7235 side,
7236 direction
7237 } = parameters;
7238 const runOnceAnimationsFinish = useAnimationsFinished(popupElement, true, false);
7239 const animationFrame = useAnimationFrame();
7240 const committedDimensionsRef = React31.useRef(null);
7241 const liveDimensionsRef = React31.useRef(null);
7242 const isInitialRenderRef = React31.useRef(true);
7243 const restoreAnchoringStylesRef = React31.useRef(NOOP);
7244 const onMeasureLayout = useStableCallback(onMeasureLayoutParam);
7245 const onMeasureLayoutComplete = useStableCallback(onMeasureLayoutCompleteParam);
7246 const anchoringStyles = React31.useMemo(() => {
7247 let isOriginSide = side === "top";
7248 let isPhysicalLeft = side === "left";
7249 if (direction === "rtl") {
7250 isOriginSide = isOriginSide || side === "inline-end";
7251 isPhysicalLeft = isPhysicalLeft || side === "inline-end";
7252 } else {
7253 isOriginSide = isOriginSide || side === "inline-start";
7254 isPhysicalLeft = isPhysicalLeft || side === "inline-start";
7255 }
7256 return isOriginSide ? {
7257 position: "absolute",
7258 [side === "top" ? "bottom" : "top"]: "0",
7259 [isPhysicalLeft ? "right" : "left"]: "0"
7260 } : EMPTY_OBJECT;
7261 }, [side, direction]);
7262 useIsoLayoutEffect(() => {
7263 if (!mounted || !enabled() || typeof ResizeObserver !== "function") {
7264 restoreAnchoringStylesRef.current = NOOP;
7265 isInitialRenderRef.current = true;
7266 committedDimensionsRef.current = null;
7267 liveDimensionsRef.current = null;
7268 return void 0;
7269 }
7270 if (!popupElement || !positionerElement) {
7271 return void 0;
7272 }
7273 restoreAnchoringStylesRef.current = applyElementStyles(popupElement, anchoringStyles);
7274 const observer = new ResizeObserver((entries) => {
7275 const entry = entries[0];
7276 if (entry) {
7277 liveDimensionsRef.current = {
7278 width: Math.ceil(entry.borderBoxSize[0].inlineSize),
7279 height: Math.ceil(entry.borderBoxSize[0].blockSize)
7280 };
7281 }
7282 });
7283 observer.observe(popupElement);
7284 setPopupCssSize(popupElement, "auto");
7285 const restorePopupPosition = overrideElementStyle(popupElement, "position", "static");
7286 const restorePopupTransform = overrideElementStyle(popupElement, "transform", "none");
7287 const restorePopupScale = overrideElementStyle(popupElement, "scale", "1");
7288 const restorePositionerAvailableSize = applyElementStyles(positionerElement, {
7289 "--available-width": "max-content",
7290 "--available-height": "max-content"
7291 });
7292 function restoreMeasurementOverrides() {
7293 restorePopupPosition();
7294 restorePopupTransform();
7295 restorePositionerAvailableSize();
7296 }
7297 function restoreMeasurementOverridesIncludingScale() {
7298 restoreMeasurementOverrides();
7299 restorePopupScale();
7300 }
7301 onMeasureLayout?.();
7302 if (isInitialRenderRef.current || committedDimensionsRef.current === null) {
7303 setPositionerCssSize(positionerElement, "max-content");
7304 const dimensions = getCssDimensions2(popupElement);
7305 committedDimensionsRef.current = dimensions;
7306 setPositionerCssSize(positionerElement, dimensions);
7307 restoreMeasurementOverridesIncludingScale();
7308 onMeasureLayoutComplete?.(null, dimensions);
7309 isInitialRenderRef.current = false;
7310 return () => {
7311 observer.disconnect();
7312 restoreAnchoringStylesRef.current();
7313 restoreAnchoringStylesRef.current = NOOP;
7314 };
7315 }
7316 setPopupCssSize(popupElement, "auto");
7317 setPositionerCssSize(positionerElement, "max-content");
7318 const previousDimensions = committedDimensionsRef.current ?? liveDimensionsRef.current;
7319 const newDimensions = getCssDimensions2(popupElement);
7320 committedDimensionsRef.current = newDimensions;
7321 if (!previousDimensions) {
7322 setPositionerCssSize(positionerElement, newDimensions);
7323 restoreMeasurementOverridesIncludingScale();
7324 onMeasureLayoutComplete?.(null, newDimensions);
7325 return () => {
7326 observer.disconnect();
7327 animationFrame.cancel();
7328 restoreAnchoringStylesRef.current();
7329 restoreAnchoringStylesRef.current = NOOP;
7330 };
7331 }
7332 setPopupCssSize(popupElement, previousDimensions);
7333 restoreMeasurementOverridesIncludingScale();
7334 onMeasureLayoutComplete?.(previousDimensions, newDimensions);
7335 setPositionerCssSize(positionerElement, newDimensions);
7336 const abortController = new AbortController();
7337 animationFrame.request(() => {
7338 setPopupCssSize(popupElement, newDimensions);
7339 runOnceAnimationsFinish(() => {
7340 popupElement.style.setProperty("--popup-width", "auto");
7341 popupElement.style.setProperty("--popup-height", "auto");
7342 }, abortController.signal);
7343 });
7344 return () => {
7345 observer.disconnect();
7346 abortController.abort();
7347 animationFrame.cancel();
7348 restoreAnchoringStylesRef.current();
7349 restoreAnchoringStylesRef.current = NOOP;
7350 };
7351 }, [content, popupElement, positionerElement, runOnceAnimationsFinish, animationFrame, enabled, mounted, onMeasureLayout, onMeasureLayoutComplete, anchoringStyles]);
7352 }
7353 function overrideElementStyle(element, property, value) {
7354 const originalValue = element.style.getPropertyValue(property);
7355 element.style.setProperty(property, value);
7356 return () => {
7357 element.style.setProperty(property, originalValue);
7358 };
7359 }
7360 function applyElementStyles(element, styles) {
7361 const restorers = [];
7362 for (const [key, value] of Object.entries(styles)) {
7363 restorers.push(overrideElementStyle(element, key, value));
7364 }
7365 return restorers.length ? () => {
7366 restorers.forEach((restore) => restore());
7367 } : NOOP;
7368 }
7369 function setPopupCssSize(popupElement, size4) {
7370 const width = size4 === "auto" ? "auto" : `${size4.width}px`;
7371 const height = size4 === "auto" ? "auto" : `${size4.height}px`;
7372 popupElement.style.setProperty("--popup-width", width);
7373 popupElement.style.setProperty("--popup-height", height);
7374 }
7375 function setPositionerCssSize(positionerElement, size4) {
7376 const width = size4 === "max-content" ? "max-content" : `${size4.width}px`;
7377 const height = size4 === "max-content" ? "max-content" : `${size4.height}px`;
7378 positionerElement.style.setProperty("--positioner-width", width);
7379 positionerElement.style.setProperty("--positioner-height", height);
7380 }
7381
7382 // node_modules/@base-ui/react/esm/utils/usePopupViewport.js
7383 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
7384 function usePopupViewport(parameters) {
7385 const {
7386 store: store2,
7387 side,
7388 cssVars,
7389 children
7390 } = parameters;
7391 const direction = useDirection();
7392 const activeTrigger = store2.useState("activeTriggerElement");
7393 const activeTriggerId = store2.useState("activeTriggerId");
7394 const open = store2.useState("open");
7395 const payload = store2.useState("payload");
7396 const mounted = store2.useState("mounted");
7397 const popupElement = store2.useState("popupElement");
7398 const positionerElement = store2.useState("positionerElement");
7399 const previousActiveTrigger = usePreviousValue(open ? activeTrigger : null);
7400 const currentContentKey = usePopupContentKey(activeTriggerId, payload);
7401 const capturedNodeRef = React32.useRef(null);
7402 const [previousContentNode, setPreviousContentNode] = React32.useState(null);
7403 const [newTriggerOffset, setNewTriggerOffset] = React32.useState(null);
7404 const currentContainerRef = React32.useRef(null);
7405 const previousContainerRef = React32.useRef(null);
7406 const onAnimationsFinished = useAnimationsFinished(currentContainerRef, true, false);
7407 const cleanupFrame = useAnimationFrame();
7408 const [previousContentDimensions, setPreviousContentDimensions] = React32.useState(null);
7409 const [showStartingStyleAttribute, setShowStartingStyleAttribute] = React32.useState(false);
7410 useIsoLayoutEffect(() => {
7411 store2.set("hasViewport", true);
7412 return () => {
7413 store2.set("hasViewport", false);
7414 };
7415 }, [store2]);
7416 const handleMeasureLayout = useStableCallback(() => {
7417 currentContainerRef.current?.style.setProperty("animation", "none");
7418 currentContainerRef.current?.style.setProperty("transition", "none");
7419 previousContainerRef.current?.style.setProperty("display", "none");
7420 });
7421 const handleMeasureLayoutComplete = useStableCallback((previousDimensions) => {
7422 currentContainerRef.current?.style.removeProperty("animation");
7423 currentContainerRef.current?.style.removeProperty("transition");
7424 previousContainerRef.current?.style.removeProperty("display");
7425 if (previousDimensions) {
7426 setPreviousContentDimensions(previousDimensions);
7427 }
7428 });
7429 const lastHandledTriggerRef = React32.useRef(null);
7430 useIsoLayoutEffect(() => {
7431 if (activeTrigger && previousActiveTrigger && activeTrigger !== previousActiveTrigger && lastHandledTriggerRef.current !== activeTrigger && capturedNodeRef.current) {
7432 setPreviousContentNode(capturedNodeRef.current);
7433 setShowStartingStyleAttribute(true);
7434 const offset4 = calculateRelativePosition(previousActiveTrigger, activeTrigger);
7435 setNewTriggerOffset(offset4);
7436 cleanupFrame.request(() => {
7437 ReactDOM5.flushSync(() => {
7438 setShowStartingStyleAttribute(false);
7439 });
7440 onAnimationsFinished(() => {
7441 setPreviousContentNode(null);
7442 setPreviousContentDimensions(null);
7443 capturedNodeRef.current = null;
7444 });
7445 });
7446 lastHandledTriggerRef.current = activeTrigger;
7447 }
7448 }, [activeTrigger, previousActiveTrigger, previousContentNode, onAnimationsFinished, cleanupFrame]);
7449 useIsoLayoutEffect(() => {
7450 const source = currentContainerRef.current;
7451 if (!source) {
7452 return;
7453 }
7454 const wrapper = ownerDocument(source).createElement("div");
7455 for (const child of Array.from(source.childNodes)) {
7456 wrapper.appendChild(child.cloneNode(true));
7457 }
7458 capturedNodeRef.current = wrapper;
7459 });
7460 const isTransitioning = previousContentNode != null;
7461 let childrenToRender;
7462 if (!isTransitioning) {
7463 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
7464 "data-current": true,
7465 ref: currentContainerRef,
7466 children
7467 }, currentContentKey);
7468 } else {
7469 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(React32.Fragment, {
7470 children: [/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
7471 "data-previous": true,
7472 inert: inertValue(true),
7473 ref: previousContainerRef,
7474 style: {
7475 ...previousContentDimensions ? {
7476 [cssVars.popupWidth]: `${previousContentDimensions.width}px`,
7477 [cssVars.popupHeight]: `${previousContentDimensions.height}px`
7478 } : null,
7479 position: "absolute"
7480 },
7481 "data-ending-style": showStartingStyleAttribute ? void 0 : ""
7482 }, "previous"), /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
7483 "data-current": true,
7484 ref: currentContainerRef,
7485 "data-starting-style": showStartingStyleAttribute ? "" : void 0,
7486 children
7487 }, currentContentKey)]
7488 });
7489 }
7490 useIsoLayoutEffect(() => {
7491 const container = previousContainerRef.current;
7492 if (!container || !previousContentNode) {
7493 return;
7494 }
7495 container.replaceChildren(...Array.from(previousContentNode.childNodes));
7496 }, [previousContentNode]);
7497 usePopupAutoResize({
7498 popupElement,
7499 positionerElement,
7500 mounted,
7501 content: payload,
7502 onMeasureLayout: handleMeasureLayout,
7503 onMeasureLayoutComplete: handleMeasureLayoutComplete,
7504 side,
7505 direction
7506 });
7507 const state = {
7508 activationDirection: getActivationDirection(newTriggerOffset),
7509 transitioning: isTransitioning
7510 };
7511 return {
7512 children: childrenToRender,
7513 state
7514 };
7515 }
7516 function getActivationDirection(offset4) {
7517 if (!offset4) {
7518 return void 0;
7519 }
7520 return `${getValueWithTolerance(offset4.horizontal, 5, "right", "left")} ${getValueWithTolerance(offset4.vertical, 5, "down", "up")}`;
7521 }
7522 function getValueWithTolerance(value, tolerance, positiveLabel, negativeLabel) {
7523 if (value > tolerance) {
7524 return positiveLabel;
7525 }
7526 if (value < -tolerance) {
7527 return negativeLabel;
7528 }
7529 return "";
7530 }
7531 function calculateRelativePosition(from, to) {
7532 const fromRect = from.getBoundingClientRect();
7533 const toRect = to.getBoundingClientRect();
7534 const fromCenter = {
7535 x: fromRect.left + fromRect.width / 2,
7536 y: fromRect.top + fromRect.height / 2
7537 };
7538 const toCenter = {
7539 x: toRect.left + toRect.width / 2,
7540 y: toRect.top + toRect.height / 2
7541 };
7542 return {
7543 horizontal: toCenter.x - fromCenter.x,
7544 vertical: toCenter.y - fromCenter.y
7545 };
7546 }
7547 function usePopupContentKey(activeTriggerId, payload) {
7548 const [contentKey, setContentKey] = React32.useState(0);
7549 const previousActiveTriggerIdRef = React32.useRef(activeTriggerId);
7550 const previousPayloadRef = React32.useRef(payload);
7551 const pendingPayloadUpdateRef = React32.useRef(false);
7552 useIsoLayoutEffect(() => {
7553 const previousActiveTriggerId = previousActiveTriggerIdRef.current;
7554 const previousPayload = previousPayloadRef.current;
7555 const triggerIdChanged = activeTriggerId !== previousActiveTriggerId;
7556 const payloadChanged = payload !== previousPayload;
7557 if (triggerIdChanged) {
7558 setContentKey((value) => value + 1);
7559 pendingPayloadUpdateRef.current = !payloadChanged;
7560 } else if (pendingPayloadUpdateRef.current && payloadChanged) {
7561 setContentKey((value) => value + 1);
7562 pendingPayloadUpdateRef.current = false;
7563 }
7564 previousActiveTriggerIdRef.current = activeTriggerId;
7565 previousPayloadRef.current = payload;
7566 }, [activeTriggerId, payload]);
7567 return `${activeTriggerId ?? "current"}-${contentKey}`;
7568 }
7569
7570 // node_modules/@base-ui/react/esm/utils/FloatingPortalLite.js
7571 var React33 = __toESM(require_react(), 1);
7572 var ReactDOM6 = __toESM(require_react_dom(), 1);
7573 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
7574 var FloatingPortalLite = /* @__PURE__ */ React33.forwardRef(function FloatingPortalLite2(componentProps, forwardedRef) {
7575 const {
7576 children,
7577 container,
7578 className,
7579 render,
7580 style,
7581 ...elementProps
7582 } = componentProps;
7583 const {
7584 portalNode,
7585 portalSubtree
7586 } = useFloatingPortalNode({
7587 container,
7588 ref: forwardedRef,
7589 componentProps,
7590 elementProps
7591 });
7592 if (!portalSubtree && !portalNode) {
7593 return null;
7594 }
7595 return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(React33.Fragment, {
7596 children: [portalSubtree, portalNode && /* @__PURE__ */ ReactDOM6.createPortal(children, portalNode)]
7597 });
7598 });
7599 if (true) FloatingPortalLite.displayName = "FloatingPortalLite";
7600
7601 // node_modules/@base-ui/react/esm/tooltip/index.parts.js
7602 var index_parts_exports = {};
7603 __export(index_parts_exports, {
7604 Arrow: () => TooltipArrow,
7605 Handle: () => TooltipHandle,
7606 Popup: () => TooltipPopup,
7607 Portal: () => TooltipPortal,
7608 Positioner: () => TooltipPositioner,
7609 Provider: () => TooltipProvider,
7610 Root: () => TooltipRoot,
7611 Trigger: () => TooltipTrigger,
7612 Viewport: () => TooltipViewport,
7613 createHandle: () => createTooltipHandle
7614 });
7615
7616 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRoot.js
7617 var React36 = __toESM(require_react(), 1);
7618
7619 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRootContext.js
7620 var React34 = __toESM(require_react(), 1);
7621 var TooltipRootContext = /* @__PURE__ */ React34.createContext(void 0);
7622 if (true) TooltipRootContext.displayName = "TooltipRootContext";
7623 function useTooltipRootContext(optional) {
7624 const context = React34.useContext(TooltipRootContext);
7625 if (context === void 0 && !optional) {
7626 throw new Error(true ? "Base UI: TooltipRootContext is missing. Tooltip parts must be placed within <Tooltip.Root>." : formatErrorMessage_default(72));
7627 }
7628 return context;
7629 }
7630
7631 // node_modules/@base-ui/react/esm/tooltip/store/TooltipStore.js
7632 var React35 = __toESM(require_react(), 1);
7633 var ReactDOM7 = __toESM(require_react_dom(), 1);
7634 var selectors2 = {
7635 ...popupStoreSelectors,
7636 disabled: createSelector((state) => state.disabled),
7637 instantType: createSelector((state) => state.instantType),
7638 isInstantPhase: createSelector((state) => state.isInstantPhase),
7639 trackCursorAxis: createSelector((state) => state.trackCursorAxis),
7640 disableHoverablePopup: createSelector((state) => state.disableHoverablePopup),
7641 lastOpenChangeReason: createSelector((state) => state.openChangeReason),
7642 closeOnClick: createSelector((state) => state.closeOnClick),
7643 closeDelay: createSelector((state) => state.closeDelay),
7644 hasViewport: createSelector((state) => state.hasViewport)
7645 };
7646 var TooltipStore = class _TooltipStore extends ReactStore {
7647 constructor(initialState, floatingId, nested = false) {
7648 const triggerElements = new PopupTriggerMap();
7649 const state = {
7650 ...createInitialState(),
7651 ...initialState
7652 };
7653 state.floatingRootContext = createPopupFloatingRootContext(triggerElements, floatingId, nested);
7654 super(state, {
7655 popupRef: /* @__PURE__ */ React35.createRef(),
7656 onOpenChange: void 0,
7657 onOpenChangeComplete: void 0,
7658 triggerElements
7659 }, selectors2);
7660 }
7661 setOpen = (nextOpen, eventDetails) => {
7662 const reason = eventDetails.reason;
7663 const isHover = reason === reason_parts_exports.triggerHover;
7664 const isFocusOpen = nextOpen && reason === reason_parts_exports.triggerFocus;
7665 const isDismissClose = !nextOpen && (reason === reason_parts_exports.triggerPress || reason === reason_parts_exports.escapeKey);
7666 eventDetails.preventUnmountOnClose = () => {
7667 this.set("preventUnmountingOnClose", true);
7668 };
7669 this.context.onOpenChange?.(nextOpen, eventDetails);
7670 if (eventDetails.isCanceled) {
7671 return;
7672 }
7673 this.state.floatingRootContext.dispatchOpenChange(nextOpen, eventDetails);
7674 const changeState = () => {
7675 const updatedState = {
7676 open: nextOpen,
7677 openChangeReason: reason
7678 };
7679 if (isFocusOpen) {
7680 updatedState.instantType = "focus";
7681 } else if (isDismissClose) {
7682 updatedState.instantType = "dismiss";
7683 } else if (reason === reason_parts_exports.triggerHover) {
7684 updatedState.instantType = void 0;
7685 }
7686 setOpenTriggerState(updatedState, nextOpen, eventDetails.trigger);
7687 this.update(updatedState);
7688 };
7689 if (isHover) {
7690 ReactDOM7.flushSync(changeState);
7691 } else {
7692 changeState();
7693 }
7694 };
7695 // Used by trigger clicks to clear a delayed hover open without reporting a public open-state change.
7696 cancelPendingOpen(event) {
7697 this.state.floatingRootContext.dispatchOpenChange(false, createChangeEventDetails(reason_parts_exports.triggerPress, event));
7698 }
7699 static useStore(externalStore, initialState) {
7700 const store2 = usePopupStore(externalStore, (floatingId, nested) => new _TooltipStore(initialState, floatingId, nested)).store;
7701 return store2;
7702 }
7703 };
7704 function createInitialState() {
7705 return {
7706 ...createInitialPopupStoreState(),
7707 disabled: false,
7708 instantType: void 0,
7709 isInstantPhase: false,
7710 trackCursorAxis: "none",
7711 disableHoverablePopup: false,
7712 openChangeReason: null,
7713 closeOnClick: true,
7714 closeDelay: 0,
7715 hasViewport: false
7716 };
7717 }
7718
7719 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRoot.js
7720 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
7721 var TooltipRoot = fastComponent(function TooltipRoot2(props) {
7722 const {
7723 disabled: disabled2 = false,
7724 defaultOpen = false,
7725 open: openProp,
7726 disableHoverablePopup = false,
7727 trackCursorAxis = "none",
7728 actionsRef,
7729 onOpenChange,
7730 onOpenChangeComplete,
7731 handle,
7732 triggerId: triggerIdProp,
7733 defaultTriggerId: defaultTriggerIdProp = null,
7734 children
7735 } = props;
7736 const store2 = TooltipStore.useStore(handle?.store, {
7737 open: defaultOpen,
7738 openProp,
7739 activeTriggerId: defaultTriggerIdProp,
7740 triggerIdProp
7741 });
7742 useOnFirstRender(() => {
7743 if (openProp === void 0 && store2.state.open === false && defaultOpen === true) {
7744 store2.update({
7745 open: true,
7746 activeTriggerId: defaultTriggerIdProp
7747 });
7748 }
7749 });
7750 store2.useControlledProp("openProp", openProp);
7751 store2.useControlledProp("triggerIdProp", triggerIdProp);
7752 store2.useContextCallback("onOpenChange", onOpenChange);
7753 store2.useContextCallback("onOpenChangeComplete", onOpenChangeComplete);
7754 const openState = store2.useState("open");
7755 const open = !disabled2 && openState;
7756 const activeTriggerId = store2.useState("activeTriggerId");
7757 const mounted = store2.useState("mounted");
7758 const payload = store2.useState("payload");
7759 store2.useSyncedValues({
7760 trackCursorAxis,
7761 disableHoverablePopup
7762 });
7763 store2.useSyncedValue("disabled", disabled2);
7764 useImplicitActiveTrigger(store2);
7765 const {
7766 forceUnmount,
7767 transitionStatus
7768 } = useOpenStateTransitions(open, store2);
7769 const isInstantPhase = store2.useState("isInstantPhase");
7770 const instantType = store2.useState("instantType");
7771 const lastOpenChangeReason = store2.useState("lastOpenChangeReason");
7772 const previousInstantTypeRef = React36.useRef(null);
7773 useIsoLayoutEffect(() => {
7774 if (openState && disabled2) {
7775 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.disabled));
7776 }
7777 }, [openState, disabled2, store2]);
7778 useIsoLayoutEffect(() => {
7779 if (transitionStatus === "ending" && lastOpenChangeReason === reason_parts_exports.none || transitionStatus !== "ending" && isInstantPhase) {
7780 if (instantType !== "delay") {
7781 previousInstantTypeRef.current = instantType;
7782 }
7783 store2.set("instantType", "delay");
7784 } else if (previousInstantTypeRef.current !== null) {
7785 store2.set("instantType", previousInstantTypeRef.current);
7786 previousInstantTypeRef.current = null;
7787 }
7788 }, [transitionStatus, isInstantPhase, lastOpenChangeReason, instantType, store2]);
7789 useIsoLayoutEffect(() => {
7790 if (open) {
7791 if (activeTriggerId == null) {
7792 store2.set("payload", void 0);
7793 }
7794 }
7795 }, [store2, activeTriggerId, open]);
7796 const handleImperativeClose = React36.useCallback(() => {
7797 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction));
7798 }, [store2]);
7799 React36.useImperativeHandle(actionsRef, () => ({
7800 unmount: forceUnmount,
7801 close: handleImperativeClose
7802 }), [forceUnmount, handleImperativeClose]);
7803 const shouldRenderInteractions = open || mounted || !disabled2 && trackCursorAxis !== "none";
7804 return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(TooltipRootContext.Provider, {
7805 value: store2,
7806 children: [shouldRenderInteractions && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(TooltipInteractions, {
7807 store: store2,
7808 disabled: disabled2,
7809 trackCursorAxis
7810 }), typeof children === "function" ? children({
7811 payload
7812 }) : children]
7813 });
7814 });
7815 if (true) TooltipRoot.displayName = "TooltipRoot";
7816 function TooltipInteractions({
7817 store: store2,
7818 disabled: disabled2,
7819 trackCursorAxis
7820 }) {
7821 const floatingRootContext = store2.useState("floatingRootContext");
7822 const dismiss = useDismiss(floatingRootContext, {
7823 enabled: !disabled2,
7824 referencePress: () => store2.select("closeOnClick")
7825 });
7826 const clientPoint = useClientPoint(floatingRootContext, {
7827 enabled: !disabled2 && trackCursorAxis !== "none",
7828 axis: trackCursorAxis === "none" ? void 0 : trackCursorAxis
7829 });
7830 const activeTriggerProps = React36.useMemo(() => mergeProps(clientPoint.reference, dismiss.reference), [clientPoint.reference, dismiss.reference]);
7831 const inactiveTriggerProps = React36.useMemo(() => mergeProps(clientPoint.trigger, dismiss.trigger), [clientPoint.trigger, dismiss.trigger]);
7832 const popupProps = React36.useMemo(() => mergeProps(FOCUSABLE_POPUP_PROPS, clientPoint.floating, dismiss.floating), [clientPoint.floating, dismiss.floating]);
7833 usePopupInteractionProps(store2, {
7834 activeTriggerProps,
7835 inactiveTriggerProps,
7836 popupProps
7837 });
7838 return null;
7839 }
7840
7841 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTrigger.js
7842 var React38 = __toESM(require_react(), 1);
7843
7844 // node_modules/@base-ui/react/esm/tooltip/provider/TooltipProviderContext.js
7845 var React37 = __toESM(require_react(), 1);
7846 var TooltipProviderContext = /* @__PURE__ */ React37.createContext(void 0);
7847 if (true) TooltipProviderContext.displayName = "TooltipProviderContext";
7848 function useTooltipProviderContext() {
7849 return React37.useContext(TooltipProviderContext);
7850 }
7851
7852 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTriggerDataAttributes.js
7853 var TooltipTriggerDataAttributes = (function(TooltipTriggerDataAttributes2) {
7854 TooltipTriggerDataAttributes2[TooltipTriggerDataAttributes2["popupOpen"] = CommonTriggerDataAttributes.popupOpen] = "popupOpen";
7855 TooltipTriggerDataAttributes2["triggerDisabled"] = "data-trigger-disabled";
7856 return TooltipTriggerDataAttributes2;
7857 })({});
7858
7859 // node_modules/@base-ui/react/esm/tooltip/utils/constants.js
7860 var OPEN_DELAY = 600;
7861
7862 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTrigger.js
7863 var TOOLTIP_TRIGGER_IDENTIFIER = "data-base-ui-tooltip-trigger";
7864 function getTargetElement(event) {
7865 if ("composedPath" in event) {
7866 const path = event.composedPath();
7867 for (let i = 0; i < path.length; i += 1) {
7868 const element = path[i];
7869 if (isElement(element)) {
7870 return element;
7871 }
7872 }
7873 }
7874 const target = event.target;
7875 if (isElement(target)) {
7876 return target;
7877 }
7878 return null;
7879 }
7880 function closestEnabledTooltipTrigger(element) {
7881 let current = element;
7882 while (current) {
7883 if (current.hasAttribute(TOOLTIP_TRIGGER_IDENTIFIER)) {
7884 return current;
7885 }
7886 const parentElement = current.parentElement;
7887 if (parentElement) {
7888 current = parentElement;
7889 continue;
7890 }
7891 const root = current.getRootNode();
7892 current = "host" in root && isElement(root.host) ? root.host : null;
7893 }
7894 return null;
7895 }
7896 var TooltipTrigger = fastComponentRef(function TooltipTrigger2(componentProps, forwardedRef) {
7897 const {
7898 render,
7899 className,
7900 style,
7901 handle,
7902 payload,
7903 disabled: disabledProp,
7904 delay,
7905 closeOnClick = true,
7906 closeDelay,
7907 id: idProp,
7908 ...elementProps
7909 } = componentProps;
7910 const rootContext = useTooltipRootContext(true);
7911 const store2 = handle?.store ?? rootContext;
7912 if (!store2) {
7913 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));
7914 }
7915 const thisTriggerId = useBaseUiId(idProp);
7916 const isTriggerActive = store2.useState("isTriggerActive", thisTriggerId);
7917 const isOpenedByThisTrigger = store2.useState("isOpenedByTrigger", thisTriggerId);
7918 const floatingRootContext = store2.useState("floatingRootContext");
7919 const triggerElementRef = React38.useRef(null);
7920 const delayWithDefault = delay ?? OPEN_DELAY;
7921 const closeDelayWithDefault = closeDelay ?? 0;
7922 const {
7923 registerTrigger,
7924 isMountedByThisTrigger
7925 } = useTriggerDataForwarding(thisTriggerId, triggerElementRef, store2, {
7926 payload,
7927 closeOnClick,
7928 closeDelay: closeDelayWithDefault
7929 });
7930 const providerContext = useTooltipProviderContext();
7931 const {
7932 delayRef,
7933 isInstantPhase,
7934 hasProvider
7935 } = useDelayGroup(floatingRootContext, {
7936 open: isOpenedByThisTrigger
7937 });
7938 const hoverInteraction = useHoverInteractionSharedState(floatingRootContext);
7939 store2.useSyncedValue("isInstantPhase", isInstantPhase);
7940 const rootDisabled = store2.useState("disabled");
7941 const disabled2 = disabledProp ?? rootDisabled;
7942 const disabledRef = useValueAsRef(disabled2);
7943 const trackCursorAxis = store2.useState("trackCursorAxis");
7944 const disableHoverablePopup = store2.useState("disableHoverablePopup");
7945 const isNestedTriggerHoveredRef = React38.useRef(false);
7946 const nestedTriggerOpenTimeout = useTimeout();
7947 const pointerTypeRef = React38.useRef(void 0);
7948 function getOpenDelay() {
7949 const providerDelay = providerContext?.delay;
7950 const groupOpenValue = typeof delayRef.current === "object" ? delayRef.current.open : void 0;
7951 let computedOpenDelay = delayWithDefault;
7952 if (hasProvider) {
7953 if (groupOpenValue !== 0) {
7954 computedOpenDelay = delay ?? providerDelay ?? delayWithDefault;
7955 } else {
7956 computedOpenDelay = 0;
7957 }
7958 }
7959 return computedOpenDelay;
7960 }
7961 function isEnabledNestedTriggerTarget(target) {
7962 const triggerEl = triggerElementRef.current;
7963 if (!triggerEl || !target) {
7964 return false;
7965 }
7966 const nearestTrigger = closestEnabledTooltipTrigger(target);
7967 return nearestTrigger !== null && nearestTrigger !== triggerEl && contains(triggerEl, nearestTrigger);
7968 }
7969 function detectNestedTriggerHover(target) {
7970 const nestedTriggerHovered = isEnabledNestedTriggerTarget(target);
7971 isNestedTriggerHoveredRef.current = nestedTriggerHovered;
7972 if (nestedTriggerHovered) {
7973 hoverInteraction.openChangeTimeout.clear();
7974 hoverInteraction.restTimeout.clear();
7975 hoverInteraction.restTimeoutPending = false;
7976 nestedTriggerOpenTimeout.clear();
7977 }
7978 return nestedTriggerHovered;
7979 }
7980 const hoverProps = useHoverReferenceInteraction(floatingRootContext, {
7981 enabled: !disabled2,
7982 mouseOnly: true,
7983 move: false,
7984 handleClose: !disableHoverablePopup && trackCursorAxis !== "both" ? safePolygon() : null,
7985 restMs: getOpenDelay,
7986 delay() {
7987 const closeValue = typeof delayRef.current === "object" ? delayRef.current.close : void 0;
7988 let computedCloseDelay = closeDelayWithDefault;
7989 if (closeDelay == null && hasProvider) {
7990 computedCloseDelay = closeValue;
7991 }
7992 return {
7993 close: computedCloseDelay
7994 };
7995 },
7996 triggerElementRef,
7997 isActiveTrigger: isTriggerActive,
7998 isClosing: () => store2.select("transitionStatus") === "ending",
7999 shouldOpen() {
8000 return !isNestedTriggerHoveredRef.current;
8001 }
8002 });
8003 const focusProps = useFocus(floatingRootContext, {
8004 enabled: !disabled2
8005 }).reference;
8006 const handleNestedTriggerHover = (event) => {
8007 const wasNestedTriggerHovered = isNestedTriggerHoveredRef.current;
8008 const target = getTargetElement(event);
8009 const nestedTriggerHovered = detectNestedTriggerHover(target);
8010 const triggerEl = triggerElementRef.current;
8011 const targetInsideTrigger = triggerEl && target && contains(triggerEl, target);
8012 if (nestedTriggerHovered && store2.select("open") && store2.select("lastOpenChangeReason") === reason_parts_exports.triggerHover) {
8013 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
8014 return;
8015 }
8016 if (wasNestedTriggerHovered && !nestedTriggerHovered && targetInsideTrigger && !disabledRef.current && !store2.select("open") && triggerEl && // Match the hover hook's non-strict mouse fallback for mouse-only event sequences.
8017 isMouseLikePointerType(pointerTypeRef.current)) {
8018 const open = () => {
8019 if (!isNestedTriggerHoveredRef.current && !disabledRef.current && !store2.select("open")) {
8020 store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerEl));
8021 }
8022 };
8023 const openDelay = getOpenDelay();
8024 if (openDelay === 0) {
8025 nestedTriggerOpenTimeout.clear();
8026 open();
8027 } else {
8028 nestedTriggerOpenTimeout.start(openDelay, open);
8029 }
8030 }
8031 };
8032 const rootTriggerProps = store2.useState("triggerProps", isMountedByThisTrigger);
8033 const shouldApplyRootTriggerProps = isMountedByThisTrigger || trackCursorAxis !== "none";
8034 const state = {
8035 open: isOpenedByThisTrigger
8036 };
8037 const element = useRenderElement("button", componentProps, {
8038 state,
8039 ref: [forwardedRef, registerTrigger, triggerElementRef],
8040 props: [hoverProps, focusProps, shouldApplyRootTriggerProps ? rootTriggerProps : void 0, {
8041 onMouseOver(event) {
8042 handleNestedTriggerHover(event.nativeEvent);
8043 },
8044 onFocus(event) {
8045 if (isEnabledNestedTriggerTarget(getTargetElement(event.nativeEvent))) {
8046 event.preventBaseUIHandler();
8047 }
8048 },
8049 onMouseLeave() {
8050 isNestedTriggerHoveredRef.current = false;
8051 nestedTriggerOpenTimeout.clear();
8052 pointerTypeRef.current = void 0;
8053 },
8054 onPointerEnter(event) {
8055 pointerTypeRef.current = event.pointerType;
8056 },
8057 onPointerDown(event) {
8058 pointerTypeRef.current = event.pointerType;
8059 store2.set("closeOnClick", closeOnClick);
8060 if (closeOnClick && !store2.select("open")) {
8061 store2.cancelPendingOpen(event.nativeEvent);
8062 }
8063 },
8064 onClick(event) {
8065 if (closeOnClick && !store2.select("open")) {
8066 store2.cancelPendingOpen(event.nativeEvent);
8067 }
8068 },
8069 id: thisTriggerId,
8070 [TooltipTriggerDataAttributes.triggerDisabled]: disabled2 ? "" : void 0,
8071 [TOOLTIP_TRIGGER_IDENTIFIER]: disabled2 ? void 0 : ""
8072 }, elementProps],
8073 stateAttributesMapping: triggerOpenStateMapping
8074 });
8075 return element;
8076 });
8077 if (true) TooltipTrigger.displayName = "TooltipTrigger";
8078
8079 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortal.js
8080 var React40 = __toESM(require_react(), 1);
8081
8082 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortalContext.js
8083 var React39 = __toESM(require_react(), 1);
8084 var TooltipPortalContext = /* @__PURE__ */ React39.createContext(void 0);
8085 if (true) TooltipPortalContext.displayName = "TooltipPortalContext";
8086 function useTooltipPortalContext() {
8087 const value = React39.useContext(TooltipPortalContext);
8088 if (value === void 0) {
8089 throw new Error(true ? "Base UI: <Tooltip.Portal> is missing." : formatErrorMessage_default(70));
8090 }
8091 return value;
8092 }
8093
8094 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortal.js
8095 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
8096 var TooltipPortal = /* @__PURE__ */ React40.forwardRef(function TooltipPortal2(props, forwardedRef) {
8097 const {
8098 keepMounted = false,
8099 ...portalProps
8100 } = props;
8101 const store2 = useTooltipRootContext();
8102 const mounted = store2.useState("mounted");
8103 const shouldRender = mounted || keepMounted;
8104 if (!shouldRender) {
8105 return null;
8106 }
8107 return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(TooltipPortalContext.Provider, {
8108 value: keepMounted,
8109 children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(FloatingPortalLite, {
8110 ref: forwardedRef,
8111 ...portalProps
8112 })
8113 });
8114 });
8115 if (true) TooltipPortal.displayName = "TooltipPortal";
8116
8117 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositioner.js
8118 var React42 = __toESM(require_react(), 1);
8119
8120 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositionerContext.js
8121 var React41 = __toESM(require_react(), 1);
8122 var TooltipPositionerContext = /* @__PURE__ */ React41.createContext(void 0);
8123 if (true) TooltipPositionerContext.displayName = "TooltipPositionerContext";
8124 function useTooltipPositionerContext() {
8125 const context = React41.useContext(TooltipPositionerContext);
8126 if (context === void 0) {
8127 throw new Error(true ? "Base UI: TooltipPositionerContext is missing. TooltipPositioner parts must be placed within <Tooltip.Positioner>." : formatErrorMessage_default(71));
8128 }
8129 return context;
8130 }
8131
8132 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositioner.js
8133 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
8134 var TooltipPositioner = /* @__PURE__ */ React42.forwardRef(function TooltipPositioner2(componentProps, forwardedRef) {
8135 const {
8136 render,
8137 className,
8138 anchor,
8139 positionMethod = "absolute",
8140 side = "top",
8141 align = "center",
8142 sideOffset = 0,
8143 alignOffset = 0,
8144 collisionBoundary = "clipping-ancestors",
8145 collisionPadding = 5,
8146 arrowPadding = 5,
8147 sticky = false,
8148 disableAnchorTracking = false,
8149 collisionAvoidance = POPUP_COLLISION_AVOIDANCE,
8150 style,
8151 ...elementProps
8152 } = componentProps;
8153 const store2 = useTooltipRootContext();
8154 const keepMounted = useTooltipPortalContext();
8155 const open = store2.useState("open");
8156 const mounted = store2.useState("mounted");
8157 const trackCursorAxis = store2.useState("trackCursorAxis");
8158 const disableHoverablePopup = store2.useState("disableHoverablePopup");
8159 const floatingRootContext = store2.useState("floatingRootContext");
8160 const instantType = store2.useState("instantType");
8161 const transitionStatus = store2.useState("transitionStatus");
8162 const hasViewport = store2.useState("hasViewport");
8163 const positioning = useAnchorPositioning({
8164 anchor,
8165 positionMethod,
8166 floatingRootContext,
8167 mounted,
8168 side,
8169 sideOffset,
8170 align,
8171 alignOffset,
8172 collisionBoundary,
8173 collisionPadding,
8174 sticky,
8175 arrowPadding,
8176 disableAnchorTracking,
8177 keepMounted,
8178 collisionAvoidance,
8179 adaptiveOrigin: hasViewport ? adaptiveOrigin : void 0
8180 });
8181 const state = React42.useMemo(() => ({
8182 open,
8183 side: positioning.side,
8184 align: positioning.align,
8185 anchorHidden: positioning.anchorHidden,
8186 instant: trackCursorAxis !== "none" ? "tracking-cursor" : instantType
8187 }), [open, positioning.side, positioning.align, positioning.anchorHidden, trackCursorAxis, instantType]);
8188 const element = usePositioner(componentProps, state, {
8189 styles: positioning.positionerStyles,
8190 transitionStatus,
8191 props: elementProps,
8192 refs: [forwardedRef, store2.useStateSetter("positionerElement")],
8193 hidden: !mounted,
8194 inert: !open || trackCursorAxis === "both" || disableHoverablePopup
8195 });
8196 return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(TooltipPositionerContext.Provider, {
8197 value: positioning,
8198 children: element
8199 });
8200 });
8201 if (true) TooltipPositioner.displayName = "TooltipPositioner";
8202
8203 // node_modules/@base-ui/react/esm/tooltip/popup/TooltipPopup.js
8204 var React43 = __toESM(require_react(), 1);
8205 var stateAttributesMapping = {
8206 ...popupStateMapping,
8207 ...transitionStatusMapping
8208 };
8209 var TooltipPopup = /* @__PURE__ */ React43.forwardRef(function TooltipPopup2(componentProps, forwardedRef) {
8210 const {
8211 render,
8212 className,
8213 style,
8214 ...elementProps
8215 } = componentProps;
8216 const store2 = useTooltipRootContext();
8217 const {
8218 side,
8219 align
8220 } = useTooltipPositionerContext();
8221 const open = store2.useState("open");
8222 const instantType = store2.useState("instantType");
8223 const transitionStatus = store2.useState("transitionStatus");
8224 const popupProps = store2.useState("popupProps");
8225 const floatingContext = store2.useState("floatingRootContext");
8226 const disabled2 = store2.useState("disabled");
8227 const closeDelay = store2.useState("closeDelay");
8228 useOpenChangeComplete({
8229 open,
8230 ref: store2.context.popupRef,
8231 onComplete() {
8232 if (open) {
8233 store2.context.onOpenChangeComplete?.(true);
8234 }
8235 }
8236 });
8237 useHoverFloatingInteraction(floatingContext, {
8238 enabled: !disabled2,
8239 closeDelay
8240 });
8241 const setPopupElement = store2.useStateSetter("popupElement");
8242 const state = {
8243 open,
8244 side,
8245 align,
8246 instant: instantType,
8247 transitionStatus
8248 };
8249 const element = useRenderElement("div", componentProps, {
8250 state,
8251 ref: [forwardedRef, store2.context.popupRef, setPopupElement],
8252 props: [popupProps, getDisabledMountTransitionStyles(transitionStatus), elementProps],
8253 stateAttributesMapping
8254 });
8255 return element;
8256 });
8257 if (true) TooltipPopup.displayName = "TooltipPopup";
8258
8259 // node_modules/@base-ui/react/esm/tooltip/arrow/TooltipArrow.js
8260 var React44 = __toESM(require_react(), 1);
8261 var TooltipArrow = /* @__PURE__ */ React44.forwardRef(function TooltipArrow2(componentProps, forwardedRef) {
8262 const {
8263 render,
8264 className,
8265 style,
8266 ...elementProps
8267 } = componentProps;
8268 const store2 = useTooltipRootContext();
8269 const {
8270 arrowRef,
8271 side,
8272 align,
8273 arrowUncentered,
8274 arrowStyles
8275 } = useTooltipPositionerContext();
8276 const open = store2.useState("open");
8277 const instantType = store2.useState("instantType");
8278 const state = {
8279 open,
8280 side,
8281 align,
8282 uncentered: arrowUncentered,
8283 instant: instantType
8284 };
8285 const element = useRenderElement("div", componentProps, {
8286 state,
8287 ref: [forwardedRef, arrowRef],
8288 props: [{
8289 style: arrowStyles,
8290 "aria-hidden": true
8291 }, elementProps],
8292 stateAttributesMapping: popupStateMapping
8293 });
8294 return element;
8295 });
8296 if (true) TooltipArrow.displayName = "TooltipArrow";
8297
8298 // node_modules/@base-ui/react/esm/tooltip/provider/TooltipProvider.js
8299 var React45 = __toESM(require_react(), 1);
8300 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
8301 var TooltipProvider = function TooltipProvider2(props) {
8302 const {
8303 delay,
8304 closeDelay,
8305 timeout = 400
8306 } = props;
8307 const contextValue = React45.useMemo(() => ({
8308 delay,
8309 closeDelay
8310 }), [delay, closeDelay]);
8311 const delayValue = React45.useMemo(() => ({
8312 open: delay,
8313 close: closeDelay
8314 }), [delay, closeDelay]);
8315 return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(TooltipProviderContext.Provider, {
8316 value: contextValue,
8317 children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(FloatingDelayGroup, {
8318 delay: delayValue,
8319 timeoutMs: timeout,
8320 children: props.children
8321 })
8322 });
8323 };
8324 if (true) TooltipProvider.displayName = "TooltipProvider";
8325
8326 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewport.js
8327 var React46 = __toESM(require_react(), 1);
8328
8329 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewportCssVars.js
8330 var TooltipViewportCssVars = /* @__PURE__ */ (function(TooltipViewportCssVars2) {
8331 TooltipViewportCssVars2["popupWidth"] = "--popup-width";
8332 TooltipViewportCssVars2["popupHeight"] = "--popup-height";
8333 return TooltipViewportCssVars2;
8334 })({});
8335
8336 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewport.js
8337 var stateAttributesMapping2 = {
8338 activationDirection: (value) => value ? {
8339 "data-activation-direction": value
8340 } : null
8341 };
8342 var TooltipViewport = /* @__PURE__ */ React46.forwardRef(function TooltipViewport2(componentProps, forwardedRef) {
8343 const {
8344 render,
8345 className,
8346 style,
8347 children,
8348 ...elementProps
8349 } = componentProps;
8350 const store2 = useTooltipRootContext();
8351 const positioner = useTooltipPositionerContext();
8352 const instantType = store2.useState("instantType");
8353 const {
8354 children: childrenToRender,
8355 state: viewportState
8356 } = usePopupViewport({
8357 store: store2,
8358 side: positioner.side,
8359 cssVars: TooltipViewportCssVars,
8360 children
8361 });
8362 const state = {
8363 activationDirection: viewportState.activationDirection,
8364 transitioning: viewportState.transitioning,
8365 instant: instantType
8366 };
8367 return useRenderElement("div", componentProps, {
8368 state,
8369 ref: forwardedRef,
8370 props: [elementProps, {
8371 children: childrenToRender
8372 }],
8373 stateAttributesMapping: stateAttributesMapping2
8374 });
8375 });
8376 if (true) TooltipViewport.displayName = "TooltipViewport";
8377
8378 // node_modules/@base-ui/react/esm/tooltip/store/TooltipHandle.js
8379 var TooltipHandle = class {
8380 /**
8381 * Internal store holding the tooltip state.
8382 * @internal
8383 */
8384 constructor() {
8385 this.store = new TooltipStore();
8386 }
8387 /**
8388 * Opens the tooltip and associates it with the trigger with the given ID.
8389 * The trigger must be a Tooltip.Trigger component with this handle passed as a prop.
8390 *
8391 * This method should only be called in an event handler or an effect (not during rendering).
8392 *
8393 * @param triggerId ID of the trigger to associate with the tooltip.
8394 */
8395 open(triggerId) {
8396 const triggerElement = triggerId ? this.store.context.triggerElements.getById(triggerId) : void 0;
8397 if (triggerId && !triggerElement) {
8398 throw new Error(true ? `Base UI: TooltipHandle.open: No trigger found with id "${triggerId}".` : formatErrorMessage_default(81, triggerId));
8399 }
8400 this.store.setOpen(true, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, triggerElement));
8401 }
8402 /**
8403 * Closes the tooltip.
8404 */
8405 close() {
8406 this.store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, void 0));
8407 }
8408 /**
8409 * Indicates whether the tooltip is currently open.
8410 */
8411 get isOpen() {
8412 return this.store.select("open");
8413 }
8414 };
8415 function createTooltipHandle() {
8416 return new TooltipHandle();
8417 }
8418
8419 // node_modules/@base-ui/react/esm/use-render/useRender.js
8420 function useRender(params) {
8421 return useRenderElement(params.defaultTagName ?? "div", params, params);
8422 }
8423
8424 // packages/icons/build-module/library/arrow-up-left.mjs
8425 var import_primitives = __toESM(require_primitives(), 1);
8426 var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
8427 var arrow_up_left_default = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives.Path, { d: "M14 6H6v8h1.5V8.5L17 18l1-1-9.5-9.5H14V6Z" }) });
8428
8429 // packages/icons/build-module/library/arrow-up-right.mjs
8430 var import_primitives2 = __toESM(require_primitives(), 1);
8431 var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
8432 var arrow_up_right_default = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives2.Path, { d: "M10 6H18V14H16.5V8.5L7 18L6 17L15.5 7.5H10V6Z" }) });
8433
8434 // packages/icons/build-module/library/chevron-down.mjs
8435 var import_primitives3 = __toESM(require_primitives(), 1);
8436 var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
8437 var chevron_down_default = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives3.Path, { d: "M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z" }) });
8438
8439 // packages/icons/build-module/library/chevron-left.mjs
8440 var import_primitives4 = __toESM(require_primitives(), 1);
8441 var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
8442 var chevron_left_default = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives4.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives4.Path, { d: "M14.6 7l-1.2-1L8 12l5.4 6 1.2-1-4.6-5z" }) });
8443
8444 // packages/icons/build-module/library/chevron-right.mjs
8445 var import_primitives5 = __toESM(require_primitives(), 1);
8446 var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
8447 var chevron_right_default = /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives5.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives5.Path, { d: "M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z" }) });
8448
8449 // packages/icons/build-module/library/chevron-up.mjs
8450 var import_primitives6 = __toESM(require_primitives(), 1);
8451 var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
8452 var chevron_up_default = /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives6.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives6.Path, { d: "M6.5 12.4L12 8l5.5 4.4-.9 1.2L12 10l-4.5 3.6-1-1.2z" }) });
8453
8454 // packages/icons/build-module/library/fullscreen.mjs
8455 var import_primitives7 = __toESM(require_primitives(), 1);
8456 var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
8457 var fullscreen_default = /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives7.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives7.Path, { d: "M6 4a2 2 0 0 0-2 2v3h1.5V6a.5.5 0 0 1 .5-.5h3V4H6Zm3 14.5H6a.5.5 0 0 1-.5-.5v-3H4v3a2 2 0 0 0 2 2h3v-1.5Zm6 1.5v-1.5h3a.5.5 0 0 0 .5-.5v-3H20v3a2 2 0 0 1-2 2h-3Zm3-16a2 2 0 0 1 2 2v3h-1.5V6a.5.5 0 0 0-.5-.5h-3V4h3Z" }) });
8458
8459 // packages/icons/build-module/library/wordpress.mjs
8460 var import_primitives8 = __toESM(require_primitives(), 1);
8461 var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
8462 var wordpress_default = /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives8.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "-2 -2 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives8.Path, { d: "M20 10c0-5.51-4.49-10-10-10C4.48 0 0 4.49 0 10c0 5.52 4.48 10 10 10 5.51 0 10-4.48 10-10zM7.78 15.37L4.37 6.22c.55-.02 1.17-.08 1.17-.08.5-.06.44-1.13-.06-1.11 0 0-1.45.11-2.37.11-.18 0-.37 0-.58-.01C4.12 2.69 6.87 1.11 10 1.11c2.33 0 4.45.87 6.05 2.34-.68-.11-1.65.39-1.65 1.58 0 .74.45 1.36.9 2.1.35.61.55 1.36.55 2.46 0 1.49-1.4 5-1.4 5l-3.03-8.37c.54-.02.82-.17.82-.17.5-.05.44-1.25-.06-1.22 0 0-1.44.12-2.38.12-.87 0-2.33-.12-2.33-.12-.5-.03-.56 1.2-.06 1.22l.92.08 1.26 3.41zM17.41 10c.24-.64.74-1.87.43-4.25.7 1.29 1.05 2.71 1.05 4.25 0 3.29-1.73 6.24-4.4 7.78.97-2.59 1.94-5.2 2.92-7.78zM6.1 18.09C3.12 16.65 1.11 13.53 1.11 10c0-1.3.23-2.48.72-3.59C3.25 10.3 4.67 14.2 6.1 18.09zm4.03-6.63l2.58 6.98c-.86.29-1.76.45-2.71.45-.79 0-1.57-.11-2.29-.33.81-2.38 1.62-4.74 2.42-7.1z" }) });
8463
8464 // packages/ui/build-module/utils/render-slot-with-children.mjs
8465 var import_element10 = __toESM(require_element(), 1);
8466 function renderSlotWithChildren(slot, defaultSlot, children) {
8467 return (0, import_element10.cloneElement)(slot ?? defaultSlot, { children });
8468 }
8469
8470 // packages/ui/build-module/utils/theme-provider.mjs
8471 var theme = __toESM(require_theme(), 1);
8472
8473 // packages/ui/build-module/lock-unlock.mjs
8474 var import_private_apis = __toESM(require_private_apis(), 1);
8475 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
8476 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
8477 "@wordpress/ui"
8478 );
8479
8480 // packages/ui/build-module/utils/theme-provider.mjs
8481 function getThemeProvider() {
8482 const themePackage = theme;
8483 if (themePackage.ThemeProvider) {
8484 return themePackage.ThemeProvider;
8485 }
8486 if (!themePackage.privateApis) {
8487 throw new Error(
8488 "@wordpress/ui: @wordpress/theme must expose `ThemeProvider` or `privateApis.ThemeProvider`."
8489 );
8490 }
8491 return unlock(
8492 themePackage.privateApis
8493 ).ThemeProvider;
8494 }
8495 var ThemeProvider = getThemeProvider();
8496
8497 // packages/ui/build-module/stack/stack.mjs
8498 var import_element11 = __toESM(require_element(), 1);
8499 var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
8500 function getRuntime() {
8501 const globalScope = globalThis;
8502 if (globalScope.__wpStyleRuntime) {
8503 return globalScope.__wpStyleRuntime;
8504 }
8505 globalScope.__wpStyleRuntime = {
8506 documents: /* @__PURE__ */ new Map(),
8507 styles: /* @__PURE__ */ new Map(),
8508 injectedStyles: /* @__PURE__ */ new WeakMap()
8509 };
8510 if (typeof document !== "undefined") {
8511 registerDocument(document);
8512 }
8513 return globalScope.__wpStyleRuntime;
8514 }
8515 function documentContainsStyleHash(targetDocument, hash) {
8516 if (!targetDocument.head) {
8517 return false;
8518 }
8519 for (const style of targetDocument.head.querySelectorAll(
8520 `style[${STYLE_HASH_ATTRIBUTE}]`
8521 )) {
8522 if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
8523 return true;
8524 }
8525 }
8526 return false;
8527 }
8528 function injectStyle(targetDocument, hash, css) {
8529 if (!targetDocument.head) {
8530 return;
8531 }
8532 const runtime = getRuntime();
8533 let injectedStyles = runtime.injectedStyles.get(targetDocument);
8534 if (!injectedStyles) {
8535 injectedStyles = /* @__PURE__ */ new Set();
8536 runtime.injectedStyles.set(targetDocument, injectedStyles);
8537 }
8538 if (injectedStyles.has(hash)) {
8539 return;
8540 }
8541 if (documentContainsStyleHash(targetDocument, hash)) {
8542 injectedStyles.add(hash);
8543 return;
8544 }
8545 const style = targetDocument.createElement("style");
8546 style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
8547 style.appendChild(targetDocument.createTextNode(css));
8548 targetDocument.head.appendChild(style);
8549 injectedStyles.add(hash);
8550 }
8551 function registerDocument(targetDocument) {
8552 const runtime = getRuntime();
8553 runtime.documents.set(
8554 targetDocument,
8555 (runtime.documents.get(targetDocument) ?? 0) + 1
8556 );
8557 for (const [hash, css] of runtime.styles) {
8558 injectStyle(targetDocument, hash, css);
8559 }
8560 return () => {
8561 const count = runtime.documents.get(targetDocument);
8562 if (count === void 0) {
8563 return;
8564 }
8565 if (count <= 1) {
8566 runtime.documents.delete(targetDocument);
8567 return;
8568 }
8569 runtime.documents.set(targetDocument, count - 1);
8570 };
8571 }
8572 function registerStyle(hash, css) {
8573 const runtime = getRuntime();
8574 runtime.styles.set(hash, css);
8575 for (const targetDocument of runtime.documents.keys()) {
8576 injectStyle(targetDocument, hash, css);
8577 }
8578 }
8579 if (typeof process === "undefined" || true) {
8580 registerStyle("32aba35fe1", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._19ce0419607e1896__stack{display:flex}}}");
8581 }
8582 var style_default = { "stack": "_19ce0419607e1896__stack" };
8583 var gapTokens = {
8584 xs: "var(--wpds-dimension-gap-xs, 4px)",
8585 sm: "var(--wpds-dimension-gap-sm, 8px)",
8586 md: "var(--wpds-dimension-gap-md, 12px)",
8587 lg: "var(--wpds-dimension-gap-lg, 16px)",
8588 xl: "var(--wpds-dimension-gap-xl, 24px)",
8589 "2xl": "var(--wpds-dimension-gap-2xl, 32px)",
8590 "3xl": "var(--wpds-dimension-gap-3xl, 40px)"
8591 };
8592 var Stack = (0, import_element11.forwardRef)(function Stack2({ direction, gap, align, justify, wrap, render, ...props }, ref) {
8593 const style = {
8594 gap: gap && gapTokens[gap],
8595 alignItems: align,
8596 justifyContent: justify,
8597 flexDirection: direction,
8598 flexWrap: wrap
8599 };
8600 const element = useRender({
8601 render,
8602 ref,
8603 props: mergeProps(props, { style, className: style_default.stack })
8604 });
8605 return element;
8606 });
8607
8608 // packages/ui/build-module/tooltip/index.mjs
8609 var tooltip_exports = {};
8610 __export(tooltip_exports, {
8611 Popup: () => Popup,
8612 Portal: () => Portal,
8613 Positioner: () => Positioner,
8614 Provider: () => Provider,
8615 Root: () => Root,
8616 Trigger: () => Trigger
8617 });
8618
8619 // packages/ui/build-module/tooltip/popup.mjs
8620 var import_element14 = __toESM(require_element(), 1);
8621
8622 // packages/ui/build-module/tooltip/portal.mjs
8623 var import_element12 = __toESM(require_element(), 1);
8624
8625 // packages/ui/build-module/utils/wp-compat-overlay-slot.mjs
8626 var STYLE_HASH_ATTRIBUTE2 = "data-wp-hash";
8627 function getRuntime2() {
8628 const globalScope = globalThis;
8629 if (globalScope.__wpStyleRuntime) {
8630 return globalScope.__wpStyleRuntime;
8631 }
8632 globalScope.__wpStyleRuntime = {
8633 documents: /* @__PURE__ */ new Map(),
8634 styles: /* @__PURE__ */ new Map(),
8635 injectedStyles: /* @__PURE__ */ new WeakMap()
8636 };
8637 if (typeof document !== "undefined") {
8638 registerDocument2(document);
8639 }
8640 return globalScope.__wpStyleRuntime;
8641 }
8642 function documentContainsStyleHash2(targetDocument, hash) {
8643 if (!targetDocument.head) {
8644 return false;
8645 }
8646 for (const style of targetDocument.head.querySelectorAll(
8647 `style[${STYLE_HASH_ATTRIBUTE2}]`
8648 )) {
8649 if (style.getAttribute(STYLE_HASH_ATTRIBUTE2) === hash) {
8650 return true;
8651 }
8652 }
8653 return false;
8654 }
8655 function injectStyle2(targetDocument, hash, css) {
8656 if (!targetDocument.head) {
8657 return;
8658 }
8659 const runtime = getRuntime2();
8660 let injectedStyles = runtime.injectedStyles.get(targetDocument);
8661 if (!injectedStyles) {
8662 injectedStyles = /* @__PURE__ */ new Set();
8663 runtime.injectedStyles.set(targetDocument, injectedStyles);
8664 }
8665 if (injectedStyles.has(hash)) {
8666 return;
8667 }
8668 if (documentContainsStyleHash2(targetDocument, hash)) {
8669 injectedStyles.add(hash);
8670 return;
8671 }
8672 const style = targetDocument.createElement("style");
8673 style.setAttribute(STYLE_HASH_ATTRIBUTE2, hash);
8674 style.appendChild(targetDocument.createTextNode(css));
8675 targetDocument.head.appendChild(style);
8676 injectedStyles.add(hash);
8677 }
8678 function registerDocument2(targetDocument) {
8679 const runtime = getRuntime2();
8680 runtime.documents.set(
8681 targetDocument,
8682 (runtime.documents.get(targetDocument) ?? 0) + 1
8683 );
8684 for (const [hash, css] of runtime.styles) {
8685 injectStyle2(targetDocument, hash, css);
8686 }
8687 return () => {
8688 const count = runtime.documents.get(targetDocument);
8689 if (count === void 0) {
8690 return;
8691 }
8692 if (count <= 1) {
8693 runtime.documents.delete(targetDocument);
8694 return;
8695 }
8696 runtime.documents.set(targetDocument, count - 1);
8697 };
8698 }
8699 function registerStyle2(hash, css) {
8700 const runtime = getRuntime2();
8701 runtime.styles.set(hash, css);
8702 for (const targetDocument of runtime.documents.keys()) {
8703 injectStyle2(targetDocument, hash, css);
8704 }
8705 }
8706 if (typeof process === "undefined" || true) {
8707 registerStyle2("be37f31c1e", "._11fc52b637ff8a7e__slot{inset:0;isolation:isolate;pointer-events:none;position:fixed;z-index:1000000003}@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._11fc52b637ff8a7e__slot>*{pointer-events:auto}}}");
8708 }
8709 var wp_compat_overlay_slot_default = { "slot": "_11fc52b637ff8a7e__slot" };
8710 var WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE = "data-wp-compat-overlay-slot";
8711 function resolveOwnerDocument() {
8712 return typeof document === "undefined" ? null : document;
8713 }
8714 function isInWordPressEnvironment() {
8715 let topWp;
8716 try {
8717 topWp = window.top?.wp;
8718 } catch {
8719 }
8720 const wp = topWp ?? window.wp;
8721 return typeof wp?.components === "object" && wp.components !== null;
8722 }
8723 var cachedSlot = null;
8724 function createSlot(ownerDocument2) {
8725 const element = ownerDocument2.createElement("div");
8726 element.setAttribute(WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE, "");
8727 if (wp_compat_overlay_slot_default.slot) {
8728 element.classList.add(wp_compat_overlay_slot_default.slot);
8729 }
8730 ownerDocument2.body.appendChild(element);
8731 return element;
8732 }
8733 function getWpCompatOverlaySlot() {
8734 if (typeof window === "undefined") {
8735 return void 0;
8736 }
8737 if (!isInWordPressEnvironment() && window.__wpUiCompatOverlaySlotEnabled !== true) {
8738 return void 0;
8739 }
8740 const ownerDocument2 = resolveOwnerDocument();
8741 if (!ownerDocument2 || !ownerDocument2.body) {
8742 return void 0;
8743 }
8744 if (cachedSlot && cachedSlot.ownerDocument === ownerDocument2 && cachedSlot.isConnected) {
8745 return cachedSlot;
8746 }
8747 const existing = ownerDocument2.querySelector(
8748 `[${WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE}]`
8749 );
8750 if (existing instanceof HTMLDivElement) {
8751 cachedSlot = existing;
8752 return existing;
8753 }
8754 if (cachedSlot?.isConnected) {
8755 cachedSlot.remove();
8756 }
8757 cachedSlot = createSlot(ownerDocument2);
8758 return cachedSlot;
8759 }
8760
8761 // packages/ui/build-module/tooltip/portal.mjs
8762 var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);
8763 var Portal = (0, import_element12.forwardRef)(
8764 function TooltipPortal3({ container, ...restProps }, ref) {
8765 return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
8766 index_parts_exports.Portal,
8767 {
8768 container: container ?? getWpCompatOverlaySlot(),
8769 ...restProps,
8770 ref
8771 }
8772 );
8773 }
8774 );
8775
8776 // packages/ui/build-module/tooltip/positioner.mjs
8777 var import_element13 = __toESM(require_element(), 1);
8778 var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1);
8779 var STYLE_HASH_ATTRIBUTE3 = "data-wp-hash";
8780 function getRuntime3() {
8781 const globalScope = globalThis;
8782 if (globalScope.__wpStyleRuntime) {
8783 return globalScope.__wpStyleRuntime;
8784 }
8785 globalScope.__wpStyleRuntime = {
8786 documents: /* @__PURE__ */ new Map(),
8787 styles: /* @__PURE__ */ new Map(),
8788 injectedStyles: /* @__PURE__ */ new WeakMap()
8789 };
8790 if (typeof document !== "undefined") {
8791 registerDocument3(document);
8792 }
8793 return globalScope.__wpStyleRuntime;
8794 }
8795 function documentContainsStyleHash3(targetDocument, hash) {
8796 if (!targetDocument.head) {
8797 return false;
8798 }
8799 for (const style of targetDocument.head.querySelectorAll(
8800 `style[${STYLE_HASH_ATTRIBUTE3}]`
8801 )) {
8802 if (style.getAttribute(STYLE_HASH_ATTRIBUTE3) === hash) {
8803 return true;
8804 }
8805 }
8806 return false;
8807 }
8808 function injectStyle3(targetDocument, hash, css) {
8809 if (!targetDocument.head) {
8810 return;
8811 }
8812 const runtime = getRuntime3();
8813 let injectedStyles = runtime.injectedStyles.get(targetDocument);
8814 if (!injectedStyles) {
8815 injectedStyles = /* @__PURE__ */ new Set();
8816 runtime.injectedStyles.set(targetDocument, injectedStyles);
8817 }
8818 if (injectedStyles.has(hash)) {
8819 return;
8820 }
8821 if (documentContainsStyleHash3(targetDocument, hash)) {
8822 injectedStyles.add(hash);
8823 return;
8824 }
8825 const style = targetDocument.createElement("style");
8826 style.setAttribute(STYLE_HASH_ATTRIBUTE3, hash);
8827 style.appendChild(targetDocument.createTextNode(css));
8828 targetDocument.head.appendChild(style);
8829 injectedStyles.add(hash);
8830 }
8831 function registerDocument3(targetDocument) {
8832 const runtime = getRuntime3();
8833 runtime.documents.set(
8834 targetDocument,
8835 (runtime.documents.get(targetDocument) ?? 0) + 1
8836 );
8837 for (const [hash, css] of runtime.styles) {
8838 injectStyle3(targetDocument, hash, css);
8839 }
8840 return () => {
8841 const count = runtime.documents.get(targetDocument);
8842 if (count === void 0) {
8843 return;
8844 }
8845 if (count <= 1) {
8846 runtime.documents.delete(targetDocument);
8847 return;
8848 }
8849 runtime.documents.set(targetDocument, count - 1);
8850 };
8851 }
8852 function registerStyle3(hash, css) {
8853 const runtime = getRuntime3();
8854 runtime.styles.set(hash, css);
8855 for (const targetDocument of runtime.documents.keys()) {
8856 injectStyle3(targetDocument, hash, css);
8857 }
8858 }
8859 if (typeof process === "undefined" || true) {
8860 registerStyle3("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}");
8861 }
8862 var resets_default = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
8863 if (typeof process === "undefined" || true) {
8864 registerStyle3("789467362f", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-md,4px);box-shadow:var(--wpds-elevation-sm,0 1px 2px 0 #0000000d,0 2px 3px 0 #0000000a,0 6px 6px 0 #00000008,0 8px 8px 0 #00000005);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-sm,12px);line-height:1.4;padding:var(--wpds-dimension-padding-xs,4px) var(--wpds-dimension-padding-sm,8px);@media (forced-colors:active){border-bottom-color:CanvasText;border-bottom-style:solid;border-bottom-width:1px;border-left-color:CanvasText;border-left-style:solid;border-left-width:1px;border-right-color:CanvasText;border-right-style:solid;border-right-width:1px;border-top-color:CanvasText;border-top-style:solid;border-top-width:1px}}}}');
8865 }
8866 var style_default2 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
8867 var Positioner = (0, import_element13.forwardRef)(
8868 function TooltipPositioner3({ align = "center", className, side = "top", sideOffset = 4, ...props }, ref) {
8869 return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
8870 index_parts_exports.Positioner,
8871 {
8872 ref,
8873 align,
8874 side,
8875 sideOffset,
8876 ...props,
8877 className: clsx_default(
8878 resets_default["box-sizing"],
8879 style_default2.positioner,
8880 className
8881 )
8882 }
8883 );
8884 }
8885 );
8886
8887 // packages/ui/build-module/tooltip/popup.mjs
8888 var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1);
8889 var STYLE_HASH_ATTRIBUTE4 = "data-wp-hash";
8890 function getRuntime4() {
8891 const globalScope = globalThis;
8892 if (globalScope.__wpStyleRuntime) {
8893 return globalScope.__wpStyleRuntime;
8894 }
8895 globalScope.__wpStyleRuntime = {
8896 documents: /* @__PURE__ */ new Map(),
8897 styles: /* @__PURE__ */ new Map(),
8898 injectedStyles: /* @__PURE__ */ new WeakMap()
8899 };
8900 if (typeof document !== "undefined") {
8901 registerDocument4(document);
8902 }
8903 return globalScope.__wpStyleRuntime;
8904 }
8905 function documentContainsStyleHash4(targetDocument, hash) {
8906 if (!targetDocument.head) {
8907 return false;
8908 }
8909 for (const style of targetDocument.head.querySelectorAll(
8910 `style[${STYLE_HASH_ATTRIBUTE4}]`
8911 )) {
8912 if (style.getAttribute(STYLE_HASH_ATTRIBUTE4) === hash) {
8913 return true;
8914 }
8915 }
8916 return false;
8917 }
8918 function injectStyle4(targetDocument, hash, css) {
8919 if (!targetDocument.head) {
8920 return;
8921 }
8922 const runtime = getRuntime4();
8923 let injectedStyles = runtime.injectedStyles.get(targetDocument);
8924 if (!injectedStyles) {
8925 injectedStyles = /* @__PURE__ */ new Set();
8926 runtime.injectedStyles.set(targetDocument, injectedStyles);
8927 }
8928 if (injectedStyles.has(hash)) {
8929 return;
8930 }
8931 if (documentContainsStyleHash4(targetDocument, hash)) {
8932 injectedStyles.add(hash);
8933 return;
8934 }
8935 const style = targetDocument.createElement("style");
8936 style.setAttribute(STYLE_HASH_ATTRIBUTE4, hash);
8937 style.appendChild(targetDocument.createTextNode(css));
8938 targetDocument.head.appendChild(style);
8939 injectedStyles.add(hash);
8940 }
8941 function registerDocument4(targetDocument) {
8942 const runtime = getRuntime4();
8943 runtime.documents.set(
8944 targetDocument,
8945 (runtime.documents.get(targetDocument) ?? 0) + 1
8946 );
8947 for (const [hash, css] of runtime.styles) {
8948 injectStyle4(targetDocument, hash, css);
8949 }
8950 return () => {
8951 const count = runtime.documents.get(targetDocument);
8952 if (count === void 0) {
8953 return;
8954 }
8955 if (count <= 1) {
8956 runtime.documents.delete(targetDocument);
8957 return;
8958 }
8959 runtime.documents.set(targetDocument, count - 1);
8960 };
8961 }
8962 function registerStyle4(hash, css) {
8963 const runtime = getRuntime4();
8964 runtime.styles.set(hash, css);
8965 for (const targetDocument of runtime.documents.keys()) {
8966 injectStyle4(targetDocument, hash, css);
8967 }
8968 }
8969 if (typeof process === "undefined" || true) {
8970 registerStyle4("789467362f", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-md,4px);box-shadow:var(--wpds-elevation-sm,0 1px 2px 0 #0000000d,0 2px 3px 0 #0000000a,0 6px 6px 0 #00000008,0 8px 8px 0 #00000005);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-sm,12px);line-height:1.4;padding:var(--wpds-dimension-padding-xs,4px) var(--wpds-dimension-padding-sm,8px);@media (forced-colors:active){border-bottom-color:CanvasText;border-bottom-style:solid;border-bottom-width:1px;border-left-color:CanvasText;border-left-style:solid;border-left-width:1px;border-right-color:CanvasText;border-right-style:solid;border-right-width:1px;border-top-color:CanvasText;border-top-style:solid;border-top-width:1px}}}}');
8971 }
8972 var style_default3 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
8973 var POPUP_COLOR = { background: "#1e1e1e" };
8974 var Popup = (0, import_element14.forwardRef)(function TooltipPopup3({ portal, positioner, children, className, ...props }, ref) {
8975 const popupContent = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ThemeProvider, { color: POPUP_COLOR, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
8976 index_parts_exports.Popup,
8977 {
8978 ref,
8979 className: clsx_default(style_default3.popup, className),
8980 ...props,
8981 children
8982 }
8983 ) });
8984 const positionedPopup = renderSlotWithChildren(
8985 positioner,
8986 /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Positioner, {}),
8987 popupContent
8988 );
8989 return renderSlotWithChildren(portal, /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Portal, {}), positionedPopup);
8990 });
8991
8992 // packages/ui/build-module/tooltip/trigger.mjs
8993 var import_element15 = __toESM(require_element(), 1);
8994 var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1);
8995 var Trigger = (0, import_element15.forwardRef)(
8996 function TooltipTrigger3(props, ref) {
8997 return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(index_parts_exports.Trigger, { ref, ...props });
8998 }
8999 );
9000
9001 // packages/ui/build-module/tooltip/root.mjs
9002 var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1);
9003 function Root(props) {
9004 return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(index_parts_exports.Root, { ...props });
9005 }
9006
9007 // packages/ui/build-module/tooltip/provider.mjs
9008 var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1);
9009 function Provider({ ...props }) {
9010 return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(index_parts_exports.Provider, { ...props });
9011 }
9012
9013 // packages/ui/build-module/visually-hidden/visually-hidden.mjs
9014 var import_element16 = __toESM(require_element(), 1);
9015 var STYLE_HASH_ATTRIBUTE5 = "data-wp-hash";
9016 function getRuntime5() {
9017 const globalScope = globalThis;
9018 if (globalScope.__wpStyleRuntime) {
9019 return globalScope.__wpStyleRuntime;
9020 }
9021 globalScope.__wpStyleRuntime = {
9022 documents: /* @__PURE__ */ new Map(),
9023 styles: /* @__PURE__ */ new Map(),
9024 injectedStyles: /* @__PURE__ */ new WeakMap()
9025 };
9026 if (typeof document !== "undefined") {
9027 registerDocument5(document);
9028 }
9029 return globalScope.__wpStyleRuntime;
9030 }
9031 function documentContainsStyleHash5(targetDocument, hash) {
9032 if (!targetDocument.head) {
9033 return false;
9034 }
9035 for (const style of targetDocument.head.querySelectorAll(
9036 `style[${STYLE_HASH_ATTRIBUTE5}]`
9037 )) {
9038 if (style.getAttribute(STYLE_HASH_ATTRIBUTE5) === hash) {
9039 return true;
9040 }
9041 }
9042 return false;
9043 }
9044 function injectStyle5(targetDocument, hash, css) {
9045 if (!targetDocument.head) {
9046 return;
9047 }
9048 const runtime = getRuntime5();
9049 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9050 if (!injectedStyles) {
9051 injectedStyles = /* @__PURE__ */ new Set();
9052 runtime.injectedStyles.set(targetDocument, injectedStyles);
9053 }
9054 if (injectedStyles.has(hash)) {
9055 return;
9056 }
9057 if (documentContainsStyleHash5(targetDocument, hash)) {
9058 injectedStyles.add(hash);
9059 return;
9060 }
9061 const style = targetDocument.createElement("style");
9062 style.setAttribute(STYLE_HASH_ATTRIBUTE5, hash);
9063 style.appendChild(targetDocument.createTextNode(css));
9064 targetDocument.head.appendChild(style);
9065 injectedStyles.add(hash);
9066 }
9067 function registerDocument5(targetDocument) {
9068 const runtime = getRuntime5();
9069 runtime.documents.set(
9070 targetDocument,
9071 (runtime.documents.get(targetDocument) ?? 0) + 1
9072 );
9073 for (const [hash, css] of runtime.styles) {
9074 injectStyle5(targetDocument, hash, css);
9075 }
9076 return () => {
9077 const count = runtime.documents.get(targetDocument);
9078 if (count === void 0) {
9079 return;
9080 }
9081 if (count <= 1) {
9082 runtime.documents.delete(targetDocument);
9083 return;
9084 }
9085 runtime.documents.set(targetDocument, count - 1);
9086 };
9087 }
9088 function registerStyle5(hash, css) {
9089 const runtime = getRuntime5();
9090 runtime.styles.set(hash, css);
9091 for (const targetDocument of runtime.documents.keys()) {
9092 injectStyle5(targetDocument, hash, css);
9093 }
9094 }
9095 if (typeof process === "undefined" || true) {
9096 registerStyle5("fa606a57ae", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{.f37b9e2e191ebd66__visually-hidden{word-wrap:normal;border:0;clip-path:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;word-break:normal}}}");
9097 }
9098 var style_default4 = { "visually-hidden": "f37b9e2e191ebd66__visually-hidden" };
9099 var VisuallyHidden = (0, import_element16.forwardRef)(
9100 function VisuallyHidden2({ render, ...restProps }, ref) {
9101 const element = useRender({
9102 render,
9103 ref,
9104 props: mergeProps(
9105 { className: style_default4["visually-hidden"] },
9106 restProps,
9107 {
9108 // @ts-expect-error Arbitrary data-* attributes aren't indexable on the typed div props. Kept hardcoded so consumers can't change or remove it.
9109 "data-visually-hidden": ""
9110 }
9111 )
9112 });
9113 return element;
9114 }
9115 );
9116
9117 // packages/admin-ui/build-module/navigable-region/index.mjs
9118 var import_element17 = __toESM(require_element(), 1);
9119 var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1);
9120 var NavigableRegion = (0, import_element17.forwardRef)(
9121 ({ children, className, ariaLabel, as: Tag = "div", ...props }, ref) => {
9122 return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
9123 Tag,
9124 {
9125 ref,
9126 className: clsx_default("admin-ui-navigable-region", className),
9127 "aria-label": ariaLabel,
9128 role: "region",
9129 tabIndex: "-1",
9130 ...props,
9131 children
9132 }
9133 );
9134 }
9135 );
9136 NavigableRegion.displayName = "NavigableRegion";
9137 var navigable_region_default = NavigableRegion;
9138
9139 // packages/edit-post/build-module/components/layout/index.mjs
9140 var import_editor18 = __toESM(require_editor(), 1);
9141 var import_data25 = __toESM(require_data(), 1);
9142 var import_block_editor2 = __toESM(require_block_editor(), 1);
9143
9144 // packages/global-styles-engine/build-module/utils/common.mjs
9145 var import_style_engine = __toESM(require_style_engine(), 1);
9146 var ROOT_BLOCK_SELECTOR = "body";
9147 var ROOT_CSS_PROPERTIES_SELECTOR = ":root";
9148
9149 // packages/global-styles-engine/build-module/core/render.mjs
9150 var import_blocks = __toESM(require_blocks(), 1);
9151 var import_style_engine2 = __toESM(require_style_engine(), 1);
9152 var import_data = __toESM(require_data(), 1);
9153
9154 // packages/global-styles-engine/build-module/utils/spacing.mjs
9155 function getSpacingPresetCssVar(value) {
9156 if (!value) {
9157 return;
9158 }
9159 const slug = value.match(/var:preset\|spacing\|(.+)/);
9160 if (!slug) {
9161 return value;
9162 }
9163 return `var(--wp--preset--spacing--${slug[1]})`;
9164 }
9165
9166 // packages/global-styles-engine/build-module/utils/gap.mjs
9167 function getGapBoxControlValueFromStyle(blockGapValue) {
9168 if (!blockGapValue) {
9169 return null;
9170 }
9171 const isValueString = typeof blockGapValue === "string";
9172 return {
9173 top: isValueString ? blockGapValue : blockGapValue?.top,
9174 left: isValueString ? blockGapValue : blockGapValue?.left
9175 };
9176 }
9177 function getGapCSSValue(blockGapValue, defaultValue = "0") {
9178 const blockGapBoxControlValue = getGapBoxControlValueFromStyle(blockGapValue);
9179 if (!blockGapBoxControlValue) {
9180 return null;
9181 }
9182 const row = getSpacingPresetCssVar(blockGapBoxControlValue?.top) || defaultValue;
9183 const column = getSpacingPresetCssVar(blockGapBoxControlValue?.left) || defaultValue;
9184 return row === column ? row : `${row} ${column}`;
9185 }
9186
9187 // packages/global-styles-engine/build-module/utils/layout.mjs
9188 var LAYOUT_DEFINITIONS = {
9189 default: {
9190 name: "default",
9191 slug: "flow",
9192 className: "is-layout-flow",
9193 baseStyles: [
9194 {
9195 selector: " > .alignleft",
9196 rules: {
9197 float: "left",
9198 "margin-inline-start": "0",
9199 "margin-inline-end": "2em"
9200 }
9201 },
9202 {
9203 selector: " > .alignright",
9204 rules: {
9205 float: "right",
9206 "margin-inline-start": "2em",
9207 "margin-inline-end": "0"
9208 }
9209 },
9210 {
9211 selector: " > .aligncenter",
9212 rules: {
9213 "margin-left": "auto !important",
9214 "margin-right": "auto !important"
9215 }
9216 }
9217 ],
9218 spacingStyles: [
9219 {
9220 selector: " > :first-child",
9221 rules: {
9222 "margin-block-start": "0"
9223 }
9224 },
9225 {
9226 selector: " > :last-child",
9227 rules: {
9228 "margin-block-end": "0"
9229 }
9230 },
9231 {
9232 selector: " > *",
9233 rules: {
9234 "margin-block-start": null,
9235 "margin-block-end": "0"
9236 }
9237 }
9238 ]
9239 },
9240 constrained: {
9241 name: "constrained",
9242 slug: "constrained",
9243 className: "is-layout-constrained",
9244 baseStyles: [
9245 {
9246 selector: " > .alignleft",
9247 rules: {
9248 float: "left",
9249 "margin-inline-start": "0",
9250 "margin-inline-end": "2em"
9251 }
9252 },
9253 {
9254 selector: " > .alignright",
9255 rules: {
9256 float: "right",
9257 "margin-inline-start": "2em",
9258 "margin-inline-end": "0"
9259 }
9260 },
9261 {
9262 selector: " > .aligncenter",
9263 rules: {
9264 "margin-left": "auto !important",
9265 "margin-right": "auto !important"
9266 }
9267 },
9268 {
9269 selector: " > :where(:not(.alignleft):not(.alignright):not(.alignfull))",
9270 rules: {
9271 "max-width": "var(--wp--style--global--content-size)",
9272 "margin-left": "auto !important",
9273 "margin-right": "auto !important"
9274 }
9275 },
9276 {
9277 selector: " > .alignwide",
9278 rules: {
9279 "max-width": "var(--wp--style--global--wide-size)"
9280 }
9281 }
9282 ],
9283 spacingStyles: [
9284 {
9285 selector: " > :first-child",
9286 rules: {
9287 "margin-block-start": "0"
9288 }
9289 },
9290 {
9291 selector: " > :last-child",
9292 rules: {
9293 "margin-block-end": "0"
9294 }
9295 },
9296 {
9297 selector: " > *",
9298 rules: {
9299 "margin-block-start": null,
9300 "margin-block-end": "0"
9301 }
9302 }
9303 ]
9304 },
9305 flex: {
9306 name: "flex",
9307 slug: "flex",
9308 className: "is-layout-flex",
9309 displayMode: "flex",
9310 baseStyles: [
9311 {
9312 selector: "",
9313 rules: {
9314 "flex-wrap": "wrap",
9315 "align-items": "center"
9316 }
9317 },
9318 {
9319 selector: " > :is(*, div)",
9320 // :is(*, div) instead of just * increases the specificity by 001.
9321 rules: {
9322 margin: "0"
9323 }
9324 }
9325 ],
9326 spacingStyles: [
9327 {
9328 selector: "",
9329 rules: {
9330 gap: null
9331 }
9332 }
9333 ]
9334 },
9335 grid: {
9336 name: "grid",
9337 slug: "grid",
9338 className: "is-layout-grid",
9339 displayMode: "grid",
9340 baseStyles: [
9341 {
9342 selector: " > :is(*, div)",
9343 // :is(*, div) instead of just * increases the specificity by 001.
9344 rules: {
9345 margin: "0"
9346 }
9347 }
9348 ],
9349 spacingStyles: [
9350 {
9351 selector: "",
9352 rules: {
9353 gap: null
9354 }
9355 }
9356 ]
9357 }
9358 };
9359
9360 // packages/global-styles-engine/build-module/core/render.mjs
9361 function getLayoutStyles({
9362 layoutDefinitions = LAYOUT_DEFINITIONS,
9363 style,
9364 selector,
9365 hasBlockGapSupport,
9366 hasFallbackGapSupport,
9367 fallbackGapValue
9368 }) {
9369 let ruleset = "";
9370 let gapValue = hasBlockGapSupport ? getGapCSSValue(style?.spacing?.blockGap) : "";
9371 if (hasFallbackGapSupport) {
9372 if (selector === ROOT_BLOCK_SELECTOR) {
9373 gapValue = !gapValue ? "0.5em" : gapValue;
9374 } else if (!hasBlockGapSupport && fallbackGapValue) {
9375 gapValue = fallbackGapValue;
9376 }
9377 }
9378 if (gapValue && layoutDefinitions) {
9379 Object.values(layoutDefinitions).forEach(
9380 ({ className, name, spacingStyles }) => {
9381 if (!hasBlockGapSupport && "flex" !== name && "grid" !== name) {
9382 return;
9383 }
9384 if (spacingStyles?.length) {
9385 spacingStyles.forEach((spacingStyle) => {
9386 const declarations = [];
9387 if (spacingStyle.rules) {
9388 Object.entries(spacingStyle.rules).forEach(
9389 ([cssProperty, cssValue]) => {
9390 declarations.push(
9391 `${cssProperty}: ${cssValue ? cssValue : gapValue}`
9392 );
9393 }
9394 );
9395 }
9396 if (declarations.length) {
9397 let combinedSelector = "";
9398 if (!hasBlockGapSupport) {
9399 combinedSelector = selector === ROOT_BLOCK_SELECTOR ? `:where(.${className}${spacingStyle?.selector || ""})` : `:where(${selector}.${className}${spacingStyle?.selector || ""})`;
9400 } else {
9401 combinedSelector = selector === ROOT_BLOCK_SELECTOR ? `:root :where(.${className})${spacingStyle?.selector || ""}` : `:root :where(${selector}-${className})${spacingStyle?.selector || ""}`;
9402 }
9403 ruleset += `${combinedSelector} { ${declarations.join(
9404 "; "
9405 )}; }`;
9406 }
9407 });
9408 }
9409 }
9410 );
9411 if (selector === ROOT_BLOCK_SELECTOR && hasBlockGapSupport) {
9412 ruleset += `${ROOT_CSS_PROPERTIES_SELECTOR} { --wp--style--block-gap: ${gapValue}; }`;
9413 }
9414 }
9415 if (selector === ROOT_BLOCK_SELECTOR && layoutDefinitions) {
9416 const validDisplayModes = ["block", "flex", "grid"];
9417 Object.values(layoutDefinitions).forEach(
9418 ({ className, displayMode, baseStyles }) => {
9419 if (displayMode && validDisplayModes.includes(displayMode)) {
9420 ruleset += `${selector} .${className} { display:${displayMode}; }`;
9421 }
9422 if (baseStyles?.length) {
9423 baseStyles.forEach((baseStyle) => {
9424 const declarations = [];
9425 if (baseStyle.rules) {
9426 Object.entries(baseStyle.rules).forEach(
9427 ([cssProperty, cssValue]) => {
9428 declarations.push(
9429 `${cssProperty}: ${cssValue}`
9430 );
9431 }
9432 );
9433 }
9434 if (declarations.length) {
9435 const combinedSelector = `.${className}${baseStyle?.selector || ""}`;
9436 ruleset += `${combinedSelector} { ${declarations.join(
9437 "; "
9438 )}; }`;
9439 }
9440 });
9441 }
9442 }
9443 );
9444 }
9445 return ruleset;
9446 }
9447
9448 // packages/edit-post/build-module/components/layout/index.mjs
9449 var import_plugins = __toESM(require_plugins(), 1);
9450 var import_i18n14 = __toESM(require_i18n(), 1);
9451 var import_element28 = __toESM(require_element(), 1);
9452 var import_notices3 = __toESM(require_notices(), 1);
9453 var import_preferences10 = __toESM(require_preferences(), 1);
9454 var import_commands2 = __toESM(require_commands(), 1);
9455 var import_block_library = __toESM(require_block_library(), 1);
9456 var import_url5 = __toESM(require_url(), 1);
9457 var import_html_entities = __toESM(require_html_entities(), 1);
9458 var import_core_data8 = __toESM(require_core_data(), 1);
9459 var import_components9 = __toESM(require_components(), 1);
9460 var import_compose3 = __toESM(require_compose(), 1);
9461
9462 // packages/edit-post/build-module/components/back-button/index.mjs
9463 var import_editor2 = __toESM(require_editor(), 1);
9464 var import_components2 = __toESM(require_components(), 1);
9465
9466 // packages/edit-post/build-module/components/back-button/fullscreen-mode-close.mjs
9467 var import_data2 = __toESM(require_data(), 1);
9468 var import_components = __toESM(require_components(), 1);
9469 var import_i18n = __toESM(require_i18n(), 1);
9470 var import_url = __toESM(require_url(), 1);
9471 var import_editor = __toESM(require_editor(), 1);
9472 var import_core_data = __toESM(require_core_data(), 1);
9473 var import_compose = __toESM(require_compose(), 1);
9474 var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1);
9475 var siteIconVariants = {
9476 edit: {
9477 clipPath: "inset(0% round 0px)"
9478 },
9479 hover: {
9480 clipPath: "inset( 22% round 2px )"
9481 },
9482 tap: {
9483 clipPath: "inset(0% round 0px)"
9484 }
9485 };
9486 var toggleHomeIconVariants = {
9487 edit: {
9488 opacity: 0,
9489 scale: 0.2
9490 },
9491 hover: {
9492 opacity: 1,
9493 scale: 1,
9494 clipPath: "inset( 22% round 2px )"
9495 }
9496 };
9497 function FullscreenModeClose({ showTooltip, icon, href, initialPost }) {
9498 const { isRequestingSiteIcon, postType, siteIconUrl } = (0, import_data2.useSelect)(
9499 (select3) => {
9500 const { getCurrentPostType } = select3(import_editor.store);
9501 const { getEntityRecord, getPostType, isResolving } = select3(import_core_data.store);
9502 const siteData = getEntityRecord("root", "__unstableBase", void 0) || {};
9503 const _postType = initialPost?.type || getCurrentPostType();
9504 return {
9505 isRequestingSiteIcon: isResolving("getEntityRecord", [
9506 "root",
9507 "__unstableBase",
9508 void 0
9509 ]),
9510 postType: getPostType(_postType),
9511 siteIconUrl: siteData.site_icon_url
9512 };
9513 },
9514 [initialPost?.type]
9515 );
9516 const disableMotion = (0, import_compose.useReducedMotion)();
9517 const transition = {
9518 duration: disableMotion ? 0 : 0.2
9519 };
9520 if (!postType) {
9521 return null;
9522 }
9523 let siteIconContent;
9524 if (isRequestingSiteIcon && !siteIconUrl) {
9525 siteIconContent = /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "edit-post-fullscreen-mode-close-site-icon__image" });
9526 } else if (siteIconUrl) {
9527 siteIconContent = /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
9528 "img",
9529 {
9530 className: "edit-post-fullscreen-mode-close-site-icon__image",
9531 alt: (0, import_i18n.__)("Site Icon"),
9532 src: siteIconUrl
9533 }
9534 );
9535 } else {
9536 siteIconContent = /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
9537 import_components.Icon,
9538 {
9539 className: "edit-post-fullscreen-mode-close-site-icon__icon",
9540 icon: wordpress_default,
9541 size: 48
9542 }
9543 );
9544 }
9545 const buttonIcon = icon ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_components.Icon, { size: "36px", icon }) : /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "edit-post-fullscreen-mode-close-site-icon", children: siteIconContent });
9546 const classes = clsx_default("edit-post-fullscreen-mode-close", {
9547 "has-icon": siteIconUrl
9548 });
9549 const buttonHref = href ?? (0, import_url.addQueryArgs)("edit.php", {
9550 post_type: postType.slug
9551 });
9552 const buttonLabel = postType?.labels?.view_items ?? (0, import_i18n.__)("Back");
9553 const hasAdminBarInEditor = window.__experimentalAdminBarInEditor;
9554 return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
9555 import_components.__unstableMotion.div,
9556 {
9557 className: "edit-post-fullscreen-mode-close__view-mode-toggle",
9558 animate: "edit",
9559 initial: "edit",
9560 whileHover: "hover",
9561 whileTap: "tap",
9562 transition,
9563 children: [
9564 /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
9565 import_components.Button,
9566 {
9567 __next40pxDefaultSize: true,
9568 className: classes,
9569 href: buttonHref,
9570 label: buttonLabel,
9571 showTooltip,
9572 tooltipPosition: "bottom",
9573 children: !hasAdminBarInEditor && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
9574 import_components.__unstableMotion.div,
9575 {
9576 variants: !disableMotion && siteIconVariants,
9577 children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "edit-post-fullscreen-mode-close__view-mode-toggle-icon", children: buttonIcon })
9578 }
9579 )
9580 }
9581 ),
9582 hasAdminBarInEditor ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "edit-post-fullscreen-mode-close__back-icon", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_components.Icon, { icon: (0, import_i18n.isRTL)() ? chevron_right_default : chevron_left_default }) }) : /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
9583 import_components.__unstableMotion.div,
9584 {
9585 className: clsx_default(
9586 "edit-post-fullscreen-mode-close__back-icon",
9587 {
9588 "has-site-icon": siteIconUrl
9589 }
9590 ),
9591 variants: !disableMotion && toggleHomeIconVariants,
9592 children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_components.Icon, { icon: (0, import_i18n.isRTL)() ? arrow_up_right_default : arrow_up_left_default })
9593 }
9594 )
9595 ]
9596 }
9597 );
9598 }
9599 var fullscreen_mode_close_default = FullscreenModeClose;
9600
9601 // packages/edit-post/build-module/lock-unlock.mjs
9602 var import_private_apis2 = __toESM(require_private_apis(), 1);
9603 var { lock: lock2, unlock: unlock2 } = (0, import_private_apis2.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
9604 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
9605 "@wordpress/edit-post"
9606 );
9607
9608 // packages/edit-post/build-module/components/back-button/index.mjs
9609 var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1);
9610 var { BackButton: BackButtonFill } = unlock2(import_editor2.privateApis);
9611 var slideX = {
9612 hidden: { x: "-100%" },
9613 distractionFreeInactive: { x: 0 },
9614 hover: { x: 0, transition: { type: "tween", delay: 0.2 } }
9615 };
9616 function BackButton({ initialPost }) {
9617 return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(BackButtonFill, { children: ({ length }) => length <= 1 && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
9618 import_components2.__unstableMotion.div,
9619 {
9620 variants: slideX,
9621 transition: { type: "tween", delay: 0.8 },
9622 children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
9623 fullscreen_mode_close_default,
9624 {
9625 showTooltip: true,
9626 initialPost
9627 }
9628 )
9629 }
9630 ) });
9631 }
9632 var back_button_default = BackButton;
9633
9634 // packages/edit-post/build-module/components/editor-initialization/listener-hooks.mjs
9635 var import_data3 = __toESM(require_data(), 1);
9636 var import_element18 = __toESM(require_element(), 1);
9637 var import_editor3 = __toESM(require_editor(), 1);
9638 var import_core_data2 = __toESM(require_core_data(), 1);
9639
9640 // packages/edit-post/build-module/store/constants.mjs
9641 var STORE_NAME = "core/edit-post";
9642 var VIEW_AS_LINK_SELECTOR = "#wp-admin-bar-view a";
9643 var VIEW_AS_PREVIEW_LINK_SELECTOR = "#wp-admin-bar-preview a";
9644
9645 // packages/edit-post/build-module/components/editor-initialization/listener-hooks.mjs
9646 var useUpdatePostLinkListener = () => {
9647 const { isViewable, newPermalink } = (0, import_data3.useSelect)((select3) => {
9648 const { getPostType } = select3(import_core_data2.store);
9649 const { getCurrentPost, getEditedPostAttribute } = select3(import_editor3.store);
9650 const postType = getPostType(getEditedPostAttribute("type"));
9651 return {
9652 isViewable: postType?.viewable,
9653 newPermalink: getCurrentPost().link
9654 };
9655 }, []);
9656 const nodeToUpdateRef = (0, import_element18.useRef)();
9657 (0, import_element18.useEffect)(() => {
9658 nodeToUpdateRef.current = document.querySelector(VIEW_AS_PREVIEW_LINK_SELECTOR) || document.querySelector(VIEW_AS_LINK_SELECTOR);
9659 }, []);
9660 (0, import_element18.useEffect)(() => {
9661 if (!newPermalink || !nodeToUpdateRef.current) {
9662 return;
9663 }
9664 if (!isViewable) {
9665 nodeToUpdateRef.current.style.display = "none";
9666 return;
9667 }
9668 nodeToUpdateRef.current.style.display = "";
9669 nodeToUpdateRef.current.setAttribute("href", newPermalink);
9670 }, [newPermalink, isViewable]);
9671 };
9672
9673 // packages/edit-post/build-module/components/editor-initialization/index.mjs
9674 function EditorInitialization() {
9675 useUpdatePostLinkListener();
9676 return null;
9677 }
9678
9679 // packages/edit-post/build-module/components/keyboard-shortcuts/index.mjs
9680 var import_element19 = __toESM(require_element(), 1);
9681 var import_data7 = __toESM(require_data(), 1);
9682 var import_keyboard_shortcuts = __toESM(require_keyboard_shortcuts(), 1);
9683 var import_i18n3 = __toESM(require_i18n(), 1);
9684
9685 // packages/edit-post/build-module/store/index.mjs
9686 var import_data6 = __toESM(require_data(), 1);
9687
9688 // packages/edit-post/build-module/store/reducer.mjs
9689 var import_data4 = __toESM(require_data(), 1);
9690 function isSavingMetaBoxes(state = false, action) {
9691 switch (action.type) {
9692 case "REQUEST_META_BOX_UPDATES":
9693 return true;
9694 case "META_BOX_UPDATES_SUCCESS":
9695 case "META_BOX_UPDATES_FAILURE":
9696 return false;
9697 default:
9698 return state;
9699 }
9700 }
9701 function mergeMetaboxes(metaboxes = [], newMetaboxes) {
9702 const mergedMetaboxes = [...metaboxes];
9703 for (const metabox of newMetaboxes) {
9704 const existing = mergedMetaboxes.findIndex(
9705 (box) => box.id === metabox.id
9706 );
9707 if (existing !== -1) {
9708 mergedMetaboxes[existing] = {
9709 ...mergedMetaboxes[existing],
9710 ...metabox
9711 };
9712 } else {
9713 mergedMetaboxes.push(metabox);
9714 }
9715 }
9716 return mergedMetaboxes;
9717 }
9718 function metaBoxLocations(state = {}, action) {
9719 switch (action.type) {
9720 case "SET_META_BOXES_PER_LOCATIONS": {
9721 const newState = { ...state };
9722 for (const [location, metaboxes] of Object.entries(
9723 action.metaBoxesPerLocation
9724 )) {
9725 newState[location] = mergeMetaboxes(
9726 newState[location],
9727 metaboxes
9728 );
9729 }
9730 return newState;
9731 }
9732 }
9733 return state;
9734 }
9735 function metaBoxesInitialized(state = false, action) {
9736 switch (action.type) {
9737 case "META_BOXES_INITIALIZED":
9738 return true;
9739 }
9740 return state;
9741 }
9742 var metaBoxes = (0, import_data4.combineReducers)({
9743 isSaving: isSavingMetaBoxes,
9744 locations: metaBoxLocations,
9745 initialized: metaBoxesInitialized
9746 });
9747 var reducer_default = (0, import_data4.combineReducers)({
9748 metaBoxes
9749 });
9750
9751 // packages/edit-post/build-module/store/actions.mjs
9752 var actions_exports = {};
9753 __export(actions_exports, {
9754 __experimentalSetPreviewDeviceType: () => __experimentalSetPreviewDeviceType,
9755 __unstableCreateTemplate: () => __unstableCreateTemplate,
9756 closeGeneralSidebar: () => closeGeneralSidebar,
9757 closeModal: () => closeModal,
9758 closePublishSidebar: () => closePublishSidebar,
9759 hideBlockTypes: () => hideBlockTypes,
9760 initializeMetaBoxes: () => initializeMetaBoxes,
9761 metaBoxUpdatesFailure: () => metaBoxUpdatesFailure,
9762 metaBoxUpdatesSuccess: () => metaBoxUpdatesSuccess,
9763 openGeneralSidebar: () => openGeneralSidebar,
9764 openModal: () => openModal,
9765 openPublishSidebar: () => openPublishSidebar,
9766 removeEditorPanel: () => removeEditorPanel,
9767 requestMetaBoxUpdates: () => requestMetaBoxUpdates,
9768 setAvailableMetaBoxesPerLocation: () => setAvailableMetaBoxesPerLocation,
9769 setIsEditingTemplate: () => setIsEditingTemplate,
9770 setIsInserterOpened: () => setIsInserterOpened,
9771 setIsListViewOpened: () => setIsListViewOpened,
9772 showBlockTypes: () => showBlockTypes,
9773 switchEditorMode: () => switchEditorMode,
9774 toggleDistractionFree: () => toggleDistractionFree,
9775 toggleEditorPanelEnabled: () => toggleEditorPanelEnabled,
9776 toggleEditorPanelOpened: () => toggleEditorPanelOpened,
9777 toggleFeature: () => toggleFeature,
9778 toggleFullscreenMode: () => toggleFullscreenMode,
9779 togglePinnedPluginItem: () => togglePinnedPluginItem,
9780 togglePublishSidebar: () => togglePublishSidebar,
9781 updatePreferredStyleVariations: () => updatePreferredStyleVariations
9782 });
9783 var import_api_fetch = __toESM(require_api_fetch(), 1);
9784 var import_preferences = __toESM(require_preferences(), 1);
9785 var import_editor4 = __toESM(require_editor(), 1);
9786 var import_deprecated = __toESM(require_deprecated(), 1);
9787 var import_hooks = __toESM(require_hooks(), 1);
9788 var import_core_data3 = __toESM(require_core_data(), 1);
9789 var import_notices = __toESM(require_notices(), 1);
9790 var import_i18n2 = __toESM(require_i18n(), 1);
9791
9792 // packages/edit-post/build-module/utils/meta-boxes.mjs
9793 var getMetaBoxContainer = (location) => {
9794 const area = document.querySelector(
9795 `.edit-post-meta-boxes-area.is-${location} .metabox-location-${location}`
9796 );
9797 if (area) {
9798 return area;
9799 }
9800 return document.querySelector("#metaboxes .metabox-location-" + location);
9801 };
9802
9803 // packages/edit-post/build-module/store/actions.mjs
9804 var { interfaceStore } = unlock2(import_editor4.privateApis);
9805 var openGeneralSidebar = (name) => ({ registry }) => {
9806 registry.dispatch(interfaceStore).enableComplementaryArea("core", name);
9807 };
9808 var closeGeneralSidebar = () => ({ registry }) => registry.dispatch(interfaceStore).disableComplementaryArea("core");
9809 var openModal = (name) => ({ registry }) => {
9810 (0, import_deprecated.default)("select( 'core/edit-post' ).openModal( name )", {
9811 since: "6.3",
9812 alternative: "select( 'core/interface').openModal( name )"
9813 });
9814 return registry.dispatch(interfaceStore).openModal(name);
9815 };
9816 var closeModal = () => ({ registry }) => {
9817 (0, import_deprecated.default)("select( 'core/edit-post' ).closeModal()", {
9818 since: "6.3",
9819 alternative: "select( 'core/interface').closeModal()"
9820 });
9821 return registry.dispatch(interfaceStore).closeModal();
9822 };
9823 var openPublishSidebar = () => ({ registry }) => {
9824 (0, import_deprecated.default)("dispatch( 'core/edit-post' ).openPublishSidebar", {
9825 since: "6.6",
9826 alternative: "dispatch( 'core/editor').openPublishSidebar"
9827 });
9828 registry.dispatch(import_editor4.store).openPublishSidebar();
9829 };
9830 var closePublishSidebar = () => ({ registry }) => {
9831 (0, import_deprecated.default)("dispatch( 'core/edit-post' ).closePublishSidebar", {
9832 since: "6.6",
9833 alternative: "dispatch( 'core/editor').closePublishSidebar"
9834 });
9835 registry.dispatch(import_editor4.store).closePublishSidebar();
9836 };
9837 var togglePublishSidebar = () => ({ registry }) => {
9838 (0, import_deprecated.default)("dispatch( 'core/edit-post' ).togglePublishSidebar", {
9839 since: "6.6",
9840 alternative: "dispatch( 'core/editor').togglePublishSidebar"
9841 });
9842 registry.dispatch(import_editor4.store).togglePublishSidebar();
9843 };
9844 var toggleEditorPanelEnabled = (panelName) => ({ registry }) => {
9845 (0, import_deprecated.default)("dispatch( 'core/edit-post' ).toggleEditorPanelEnabled", {
9846 since: "6.5",
9847 alternative: "dispatch( 'core/editor').toggleEditorPanelEnabled"
9848 });
9849 registry.dispatch(import_editor4.store).toggleEditorPanelEnabled(panelName);
9850 };
9851 var toggleEditorPanelOpened = (panelName) => ({ registry }) => {
9852 (0, import_deprecated.default)("dispatch( 'core/edit-post' ).toggleEditorPanelOpened", {
9853 since: "6.5",
9854 alternative: "dispatch( 'core/editor').toggleEditorPanelOpened"
9855 });
9856 registry.dispatch(import_editor4.store).toggleEditorPanelOpened(panelName);
9857 };
9858 var removeEditorPanel = (panelName) => ({ registry }) => {
9859 (0, import_deprecated.default)("dispatch( 'core/edit-post' ).removeEditorPanel", {
9860 since: "6.5",
9861 alternative: "dispatch( 'core/editor').removeEditorPanel"
9862 });
9863 registry.dispatch(import_editor4.store).removeEditorPanel(panelName);
9864 };
9865 var toggleFeature = (feature) => ({ registry }) => registry.dispatch(import_preferences.store).toggle("core/edit-post", feature);
9866 var switchEditorMode = (mode) => ({ registry }) => {
9867 (0, import_deprecated.default)("dispatch( 'core/edit-post' ).switchEditorMode", {
9868 since: "6.6",
9869 alternative: "dispatch( 'core/editor').switchEditorMode"
9870 });
9871 registry.dispatch(import_editor4.store).switchEditorMode(mode);
9872 };
9873 var togglePinnedPluginItem = (pluginName) => ({ registry }) => {
9874 const isPinned = registry.select(interfaceStore).isItemPinned("core", pluginName);
9875 registry.dispatch(interfaceStore)[isPinned ? "unpinItem" : "pinItem"]("core", pluginName);
9876 };
9877 function updatePreferredStyleVariations() {
9878 (0, import_deprecated.default)("dispatch( 'core/edit-post' ).updatePreferredStyleVariations", {
9879 since: "6.6",
9880 hint: "Preferred Style Variations are not supported anymore."
9881 });
9882 return { type: "NOTHING" };
9883 }
9884 var showBlockTypes = (blockNames) => ({ registry }) => {
9885 unlock2(registry.dispatch(import_editor4.store)).showBlockTypes(blockNames);
9886 };
9887 var hideBlockTypes = (blockNames) => ({ registry }) => {
9888 unlock2(registry.dispatch(import_editor4.store)).hideBlockTypes(blockNames);
9889 };
9890 function setAvailableMetaBoxesPerLocation(metaBoxesPerLocation) {
9891 return {
9892 type: "SET_META_BOXES_PER_LOCATIONS",
9893 metaBoxesPerLocation
9894 };
9895 }
9896 var requestMetaBoxUpdates = () => async ({ registry, select: select3, dispatch: dispatch2 }) => {
9897 dispatch2({
9898 type: "REQUEST_META_BOX_UPDATES"
9899 });
9900 if (window.tinyMCE) {
9901 window.tinyMCE.triggerSave();
9902 }
9903 const baseFormData = new window.FormData(
9904 document.querySelector(".metabox-base-form")
9905 );
9906 const postId = baseFormData.get("post_ID");
9907 const postType = baseFormData.get("post_type");
9908 const post = registry.select(import_core_data3.store).getEditedEntityRecord("postType", postType, postId);
9909 const additionalData = [
9910 post.comment_status ? ["comment_status", post.comment_status] : false,
9911 post.ping_status ? ["ping_status", post.ping_status] : false,
9912 post.sticky ? ["sticky", post.sticky] : false,
9913 post.author ? ["post_author", post.author] : false
9914 ].filter(Boolean);
9915 const activeMetaBoxLocations = select3.getActiveMetaBoxLocations();
9916 const formDataToMerge = [
9917 baseFormData,
9918 ...activeMetaBoxLocations.map(
9919 (location) => new window.FormData(getMetaBoxContainer(location))
9920 )
9921 ];
9922 const formData = formDataToMerge.reduce((memo, currentFormData) => {
9923 for (const [key, value] of currentFormData) {
9924 memo.append(key, value);
9925 }
9926 return memo;
9927 }, new window.FormData());
9928 additionalData.forEach(
9929 ([key, value]) => formData.append(key, value)
9930 );
9931 try {
9932 await (0, import_api_fetch.default)({
9933 url: window._wpMetaBoxUrl,
9934 method: "POST",
9935 body: formData,
9936 parse: false
9937 });
9938 dispatch2.metaBoxUpdatesSuccess();
9939 } catch {
9940 dispatch2.metaBoxUpdatesFailure();
9941 }
9942 };
9943 function metaBoxUpdatesSuccess() {
9944 return {
9945 type: "META_BOX_UPDATES_SUCCESS"
9946 };
9947 }
9948 function metaBoxUpdatesFailure() {
9949 return {
9950 type: "META_BOX_UPDATES_FAILURE"
9951 };
9952 }
9953 var __experimentalSetPreviewDeviceType = (deviceType) => ({ registry }) => {
9954 (0, import_deprecated.default)(
9955 "dispatch( 'core/edit-post' ).__experimentalSetPreviewDeviceType",
9956 {
9957 since: "6.5",
9958 version: "6.7",
9959 hint: "registry.dispatch( editorStore ).setDeviceType"
9960 }
9961 );
9962 registry.dispatch(import_editor4.store).setDeviceType(deviceType);
9963 };
9964 var setIsInserterOpened = (value) => ({ registry }) => {
9965 (0, import_deprecated.default)("dispatch( 'core/edit-post' ).setIsInserterOpened", {
9966 since: "6.5",
9967 alternative: "dispatch( 'core/editor').setIsInserterOpened"
9968 });
9969 registry.dispatch(import_editor4.store).setIsInserterOpened(value);
9970 };
9971 var setIsListViewOpened = (isOpen) => ({ registry }) => {
9972 (0, import_deprecated.default)("dispatch( 'core/edit-post' ).setIsListViewOpened", {
9973 since: "6.5",
9974 alternative: "dispatch( 'core/editor').setIsListViewOpened"
9975 });
9976 registry.dispatch(import_editor4.store).setIsListViewOpened(isOpen);
9977 };
9978 function setIsEditingTemplate() {
9979 (0, import_deprecated.default)("dispatch( 'core/edit-post' ).setIsEditingTemplate", {
9980 since: "6.5",
9981 alternative: "dispatch( 'core/editor').setRenderingMode"
9982 });
9983 return { type: "NOTHING" };
9984 }
9985 function __unstableCreateTemplate() {
9986 (0, import_deprecated.default)("dispatch( 'core/edit-post' ).__unstableCreateTemplate", {
9987 since: "6.5"
9988 });
9989 return { type: "NOTHING" };
9990 }
9991 var metaBoxesInitialized2 = false;
9992 var initializeMetaBoxes = () => ({ registry, select: select3, dispatch: dispatch2 }) => {
9993 const isEditorReady = registry.select(import_editor4.store).__unstableIsEditorReady();
9994 if (!isEditorReady) {
9995 return;
9996 }
9997 if (metaBoxesInitialized2) {
9998 return;
9999 }
10000 const postType = registry.select(import_editor4.store).getCurrentPostType();
10001 if (window.postboxes.page !== postType) {
10002 window.postboxes.add_postbox_toggles(postType);
10003 }
10004 metaBoxesInitialized2 = true;
10005 (0, import_hooks.addAction)(
10006 "editor.savePost",
10007 "core/edit-post/save-metaboxes",
10008 async (post, options) => {
10009 if (!options.isAutosave && select3.hasMetaBoxes()) {
10010 await dispatch2.requestMetaBoxUpdates();
10011 }
10012 }
10013 );
10014 dispatch2({
10015 type: "META_BOXES_INITIALIZED"
10016 });
10017 };
10018 var toggleDistractionFree = () => ({ registry }) => {
10019 (0, import_deprecated.default)("dispatch( 'core/edit-post' ).toggleDistractionFree", {
10020 since: "6.6",
10021 alternative: "dispatch( 'core/editor').toggleDistractionFree"
10022 });
10023 registry.dispatch(import_editor4.store).toggleDistractionFree();
10024 };
10025 var toggleFullscreenMode = () => ({ registry }) => {
10026 const isFullscreen = registry.select(import_preferences.store).get("core/edit-post", "fullscreenMode");
10027 registry.dispatch(import_preferences.store).toggle("core/edit-post", "fullscreenMode");
10028 registry.dispatch(import_notices.store).createInfoNotice(
10029 isFullscreen ? (0, import_i18n2.__)("Fullscreen mode deactivated.") : (0, import_i18n2.__)("Fullscreen mode activated."),
10030 {
10031 id: "core/edit-post/toggle-fullscreen-mode/notice",
10032 type: "snackbar",
10033 actions: [
10034 {
10035 label: (0, import_i18n2.__)("Undo"),
10036 onClick: () => {
10037 registry.dispatch(import_preferences.store).toggle(
10038 "core/edit-post",
10039 "fullscreenMode"
10040 );
10041 }
10042 }
10043 ]
10044 }
10045 );
10046 };
10047
10048 // packages/edit-post/build-module/store/selectors.mjs
10049 var selectors_exports = {};
10050 __export(selectors_exports, {
10051 __experimentalGetInsertionPoint: () => __experimentalGetInsertionPoint,
10052 __experimentalGetPreviewDeviceType: () => __experimentalGetPreviewDeviceType,
10053 areMetaBoxesInitialized: () => areMetaBoxesInitialized,
10054 getActiveGeneralSidebarName: () => getActiveGeneralSidebarName,
10055 getActiveMetaBoxLocations: () => getActiveMetaBoxLocations,
10056 getAllMetaBoxes: () => getAllMetaBoxes,
10057 getEditedPostTemplate: () => getEditedPostTemplate,
10058 getEditorMode: () => getEditorMode,
10059 getHiddenBlockTypes: () => getHiddenBlockTypes,
10060 getMetaBoxesPerLocation: () => getMetaBoxesPerLocation,
10061 getPreference: () => getPreference,
10062 getPreferences: () => getPreferences,
10063 hasMetaBoxes: () => hasMetaBoxes,
10064 isEditingTemplate: () => isEditingTemplate,
10065 isEditorPanelEnabled: () => isEditorPanelEnabled,
10066 isEditorPanelOpened: () => isEditorPanelOpened,
10067 isEditorPanelRemoved: () => isEditorPanelRemoved,
10068 isEditorSidebarOpened: () => isEditorSidebarOpened,
10069 isFeatureActive: () => isFeatureActive,
10070 isInserterOpened: () => isInserterOpened,
10071 isListViewOpened: () => isListViewOpened,
10072 isMetaBoxLocationActive: () => isMetaBoxLocationActive,
10073 isMetaBoxLocationVisible: () => isMetaBoxLocationVisible,
10074 isModalActive: () => isModalActive,
10075 isPluginItemPinned: () => isPluginItemPinned,
10076 isPluginSidebarOpened: () => isPluginSidebarOpened,
10077 isPublishSidebarOpened: () => isPublishSidebarOpened,
10078 isSavingMetaBoxes: () => isSavingMetaBoxes2
10079 });
10080 var import_data5 = __toESM(require_data(), 1);
10081 var import_preferences2 = __toESM(require_preferences(), 1);
10082 var import_core_data4 = __toESM(require_core_data(), 1);
10083 var import_editor5 = __toESM(require_editor(), 1);
10084 var import_deprecated2 = __toESM(require_deprecated(), 1);
10085 var { interfaceStore: interfaceStore2 } = unlock2(import_editor5.privateApis);
10086 var EMPTY_ARRAY2 = [];
10087 var EMPTY_OBJECT2 = {};
10088 var getEditorMode = (0, import_data5.createRegistrySelector)(
10089 (select3) => () => select3(import_preferences2.store).get("core", "editorMode") ?? "visual"
10090 );
10091 var isEditorSidebarOpened = (0, import_data5.createRegistrySelector)(
10092 (select3) => () => {
10093 const activeGeneralSidebar = select3(interfaceStore2).getActiveComplementaryArea("core");
10094 return ["edit-post/document", "edit-post/block"].includes(
10095 activeGeneralSidebar
10096 );
10097 }
10098 );
10099 var isPluginSidebarOpened = (0, import_data5.createRegistrySelector)(
10100 (select3) => () => {
10101 const activeGeneralSidebar = select3(interfaceStore2).getActiveComplementaryArea("core");
10102 return !!activeGeneralSidebar && !["edit-post/document", "edit-post/block"].includes(
10103 activeGeneralSidebar
10104 );
10105 }
10106 );
10107 var getActiveGeneralSidebarName = (0, import_data5.createRegistrySelector)(
10108 (select3) => () => {
10109 return select3(interfaceStore2).getActiveComplementaryArea("core");
10110 }
10111 );
10112 function convertPanelsToOldFormat(inactivePanels, openPanels) {
10113 const panelsWithEnabledState = inactivePanels?.reduce(
10114 (accumulatedPanels, panelName) => ({
10115 ...accumulatedPanels,
10116 [panelName]: {
10117 enabled: false
10118 }
10119 }),
10120 {}
10121 );
10122 const panels = openPanels?.reduce((accumulatedPanels, panelName) => {
10123 const currentPanelState = accumulatedPanels?.[panelName];
10124 return {
10125 ...accumulatedPanels,
10126 [panelName]: {
10127 ...currentPanelState,
10128 opened: true
10129 }
10130 };
10131 }, panelsWithEnabledState ?? {});
10132 return panels ?? panelsWithEnabledState ?? EMPTY_OBJECT2;
10133 }
10134 var getPreferences = (0, import_data5.createRegistrySelector)((select3) => () => {
10135 (0, import_deprecated2.default)(`select( 'core/edit-post' ).getPreferences`, {
10136 since: "6.0",
10137 alternative: `select( 'core/preferences' ).get`
10138 });
10139 const corePreferences = ["editorMode", "hiddenBlockTypes"].reduce(
10140 (accumulatedPrefs, preferenceKey) => {
10141 const value = select3(import_preferences2.store).get(
10142 "core",
10143 preferenceKey
10144 );
10145 return {
10146 ...accumulatedPrefs,
10147 [preferenceKey]: value
10148 };
10149 },
10150 {}
10151 );
10152 const inactivePanels = select3(import_preferences2.store).get(
10153 "core",
10154 "inactivePanels"
10155 );
10156 const openPanels = select3(import_preferences2.store).get("core", "openPanels");
10157 const panels = convertPanelsToOldFormat(inactivePanels, openPanels);
10158 return {
10159 ...corePreferences,
10160 panels
10161 };
10162 });
10163 function getPreference(state, preferenceKey, defaultValue) {
10164 (0, import_deprecated2.default)(`select( 'core/edit-post' ).getPreference`, {
10165 since: "6.0",
10166 alternative: `select( 'core/preferences' ).get`
10167 });
10168 const preferences = getPreferences(state);
10169 const value = preferences[preferenceKey];
10170 return value === void 0 ? defaultValue : value;
10171 }
10172 var getHiddenBlockTypes = (0, import_data5.createRegistrySelector)((select3) => () => {
10173 return select3(import_preferences2.store).get("core", "hiddenBlockTypes") ?? EMPTY_ARRAY2;
10174 });
10175 var isPublishSidebarOpened = (0, import_data5.createRegistrySelector)(
10176 (select3) => () => {
10177 (0, import_deprecated2.default)(`select( 'core/edit-post' ).isPublishSidebarOpened`, {
10178 since: "6.6",
10179 alternative: `select( 'core/editor' ).isPublishSidebarOpened`
10180 });
10181 return select3(import_editor5.store).isPublishSidebarOpened();
10182 }
10183 );
10184 var isEditorPanelRemoved = (0, import_data5.createRegistrySelector)(
10185 (select3) => (state, panelName) => {
10186 (0, import_deprecated2.default)(`select( 'core/edit-post' ).isEditorPanelRemoved`, {
10187 since: "6.5",
10188 alternative: `select( 'core/editor' ).isEditorPanelRemoved`
10189 });
10190 return select3(import_editor5.store).isEditorPanelRemoved(panelName);
10191 }
10192 );
10193 var isEditorPanelEnabled = (0, import_data5.createRegistrySelector)(
10194 (select3) => (state, panelName) => {
10195 (0, import_deprecated2.default)(`select( 'core/edit-post' ).isEditorPanelEnabled`, {
10196 since: "6.5",
10197 alternative: `select( 'core/editor' ).isEditorPanelEnabled`
10198 });
10199 return select3(import_editor5.store).isEditorPanelEnabled(panelName);
10200 }
10201 );
10202 var isEditorPanelOpened = (0, import_data5.createRegistrySelector)(
10203 (select3) => (state, panelName) => {
10204 (0, import_deprecated2.default)(`select( 'core/edit-post' ).isEditorPanelOpened`, {
10205 since: "6.5",
10206 alternative: `select( 'core/editor' ).isEditorPanelOpened`
10207 });
10208 return select3(import_editor5.store).isEditorPanelOpened(panelName);
10209 }
10210 );
10211 var isModalActive = (0, import_data5.createRegistrySelector)(
10212 (select3) => (state, modalName) => {
10213 (0, import_deprecated2.default)(`select( 'core/edit-post' ).isModalActive`, {
10214 since: "6.3",
10215 alternative: `select( 'core/interface' ).isModalActive`
10216 });
10217 return !!select3(interfaceStore2).isModalActive(modalName);
10218 }
10219 );
10220 var isFeatureActive = (0, import_data5.createRegistrySelector)(
10221 (select3) => (state, feature) => {
10222 return !!select3(import_preferences2.store).get("core/edit-post", feature);
10223 }
10224 );
10225 var isPluginItemPinned = (0, import_data5.createRegistrySelector)(
10226 (select3) => (state, pluginName) => {
10227 return select3(interfaceStore2).isItemPinned("core", pluginName);
10228 }
10229 );
10230 var getActiveMetaBoxLocations = (0, import_data5.createSelector)(
10231 (state) => {
10232 return Object.keys(state.metaBoxes.locations).filter(
10233 (location) => isMetaBoxLocationActive(state, location)
10234 );
10235 },
10236 (state) => [state.metaBoxes.locations]
10237 );
10238 var isMetaBoxLocationVisible = (0, import_data5.createRegistrySelector)(
10239 (select3) => (state, location) => {
10240 return isMetaBoxLocationActive(state, location) && getMetaBoxesPerLocation(state, location)?.some(({ id }) => {
10241 return select3(import_editor5.store).isEditorPanelEnabled(
10242 `meta-box-${id}`
10243 );
10244 });
10245 }
10246 );
10247 function isMetaBoxLocationActive(state, location) {
10248 const metaBoxes2 = getMetaBoxesPerLocation(state, location);
10249 return !!metaBoxes2 && metaBoxes2.length !== 0;
10250 }
10251 function getMetaBoxesPerLocation(state, location) {
10252 return state.metaBoxes.locations[location];
10253 }
10254 var getAllMetaBoxes = (0, import_data5.createSelector)(
10255 (state) => {
10256 return Object.values(state.metaBoxes.locations).flat();
10257 },
10258 (state) => [state.metaBoxes.locations]
10259 );
10260 function hasMetaBoxes(state) {
10261 return getActiveMetaBoxLocations(state).length > 0;
10262 }
10263 function isSavingMetaBoxes2(state) {
10264 return state.metaBoxes.isSaving;
10265 }
10266 var __experimentalGetPreviewDeviceType = (0, import_data5.createRegistrySelector)(
10267 (select3) => () => {
10268 (0, import_deprecated2.default)(
10269 `select( 'core/edit-site' ).__experimentalGetPreviewDeviceType`,
10270 {
10271 since: "6.5",
10272 version: "6.7",
10273 alternative: `select( 'core/editor' ).getDeviceType`
10274 }
10275 );
10276 return select3(import_editor5.store).getDeviceType();
10277 }
10278 );
10279 var isInserterOpened = (0, import_data5.createRegistrySelector)((select3) => () => {
10280 (0, import_deprecated2.default)(`select( 'core/edit-post' ).isInserterOpened`, {
10281 since: "6.5",
10282 alternative: `select( 'core/editor' ).isInserterOpened`
10283 });
10284 return select3(import_editor5.store).isInserterOpened();
10285 });
10286 var __experimentalGetInsertionPoint = (0, import_data5.createRegistrySelector)(
10287 (select3) => () => {
10288 (0, import_deprecated2.default)(
10289 `select( 'core/edit-post' ).__experimentalGetInsertionPoint`,
10290 {
10291 since: "6.5",
10292 version: "6.7"
10293 }
10294 );
10295 return unlock2(select3(import_editor5.store)).getInserter();
10296 }
10297 );
10298 var isListViewOpened = (0, import_data5.createRegistrySelector)((select3) => () => {
10299 (0, import_deprecated2.default)(`select( 'core/edit-post' ).isListViewOpened`, {
10300 since: "6.5",
10301 alternative: `select( 'core/editor' ).isListViewOpened`
10302 });
10303 return select3(import_editor5.store).isListViewOpened();
10304 });
10305 var isEditingTemplate = (0, import_data5.createRegistrySelector)((select3) => () => {
10306 (0, import_deprecated2.default)(`select( 'core/edit-post' ).isEditingTemplate`, {
10307 since: "6.5",
10308 alternative: `select( 'core/editor' ).getRenderingMode`
10309 });
10310 return select3(import_editor5.store).getCurrentPostType() === "wp_template";
10311 });
10312 function areMetaBoxesInitialized(state) {
10313 return state.metaBoxes.initialized;
10314 }
10315 var getEditedPostTemplate = (0, import_data5.createRegistrySelector)(
10316 (select3) => () => {
10317 const { id: postId, type: postType } = select3(import_editor5.store).getCurrentPost();
10318 const templateId = unlock2(select3(import_core_data4.store)).getTemplateId(
10319 postType,
10320 postId
10321 );
10322 if (!templateId) {
10323 return void 0;
10324 }
10325 return select3(import_core_data4.store).getEditedEntityRecord(
10326 "postType",
10327 "wp_template",
10328 templateId
10329 );
10330 }
10331 );
10332
10333 // packages/edit-post/build-module/store/index.mjs
10334 var store = (0, import_data6.createReduxStore)(STORE_NAME, {
10335 reducer: reducer_default,
10336 actions: actions_exports,
10337 selectors: selectors_exports
10338 });
10339 (0, import_data6.register)(store);
10340
10341 // packages/edit-post/build-module/components/keyboard-shortcuts/index.mjs
10342 function KeyboardShortcuts() {
10343 const { toggleFullscreenMode: toggleFullscreenMode2 } = (0, import_data7.useDispatch)(store);
10344 const { registerShortcut } = (0, import_data7.useDispatch)(import_keyboard_shortcuts.store);
10345 (0, import_element19.useEffect)(() => {
10346 registerShortcut({
10347 name: "core/edit-post/toggle-fullscreen",
10348 category: "global",
10349 description: (0, import_i18n3.__)("Enable or disable fullscreen mode."),
10350 keyCombination: {
10351 modifier: "secondary",
10352 character: "f"
10353 }
10354 });
10355 }, []);
10356 (0, import_keyboard_shortcuts.useShortcut)("core/edit-post/toggle-fullscreen", () => {
10357 toggleFullscreenMode2();
10358 });
10359 return null;
10360 }
10361 var keyboard_shortcuts_default = KeyboardShortcuts;
10362
10363 // packages/edit-post/build-module/components/init-pattern-modal/index.mjs
10364 var import_data8 = __toESM(require_data(), 1);
10365 var import_i18n4 = __toESM(require_i18n(), 1);
10366 var import_components3 = __toESM(require_components(), 1);
10367 var import_element20 = __toESM(require_element(), 1);
10368 var import_editor6 = __toESM(require_editor(), 1);
10369 var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1);
10370 function InitPatternModal() {
10371 const { editPost } = (0, import_data8.useDispatch)(import_editor6.store);
10372 const { isCleanNewPost } = (0, import_data8.useSelect)(import_editor6.store);
10373 const [syncType, setSyncType] = (0, import_element20.useState)(void 0);
10374 const [title, setTitle] = (0, import_element20.useState)("");
10375 const [isModalOpen, setIsModalOpen] = (0, import_element20.useState)(() => isCleanNewPost());
10376 if (!isModalOpen) {
10377 return null;
10378 }
10379 return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
10380 import_components3.Modal,
10381 {
10382 title: (0, import_i18n4.__)("Create pattern"),
10383 onRequestClose: () => {
10384 setIsModalOpen(false);
10385 },
10386 overlayClassName: "patterns-create-modal",
10387 children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
10388 "form",
10389 {
10390 onSubmit: (event) => {
10391 event.preventDefault();
10392 setIsModalOpen(false);
10393 editPost({
10394 title,
10395 meta: {
10396 wp_pattern_sync_status: syncType
10397 }
10398 });
10399 },
10400 children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(Stack, { direction: "column", gap: "lg", children: [
10401 /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
10402 import_components3.TextControl,
10403 {
10404 label: (0, import_i18n4.__)("Name"),
10405 value: title,
10406 onChange: setTitle,
10407 placeholder: (0, import_i18n4.__)("My pattern"),
10408 className: "patterns-create-modal__name-input"
10409 }
10410 ),
10411 /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
10412 import_components3.ToggleControl,
10413 {
10414 label: (0, import_i18n4._x)("Synced", "pattern (singular)"),
10415 help: (0, import_i18n4.__)(
10416 "Sync this pattern across multiple locations."
10417 ),
10418 checked: !syncType,
10419 onChange: () => {
10420 setSyncType(!syncType ? "unsynced" : void 0);
10421 }
10422 }
10423 ),
10424 /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Stack, { justify: "end", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
10425 import_components3.Button,
10426 {
10427 __next40pxDefaultSize: true,
10428 variant: "primary",
10429 type: "submit",
10430 disabled: !title,
10431 accessibleWhenDisabled: true,
10432 children: (0, import_i18n4.__)("Create")
10433 }
10434 ) })
10435 ] })
10436 }
10437 )
10438 }
10439 );
10440 }
10441
10442 // packages/edit-post/build-module/components/browser-url/index.mjs
10443 var import_element21 = __toESM(require_element(), 1);
10444 var import_data9 = __toESM(require_data(), 1);
10445 var import_url2 = __toESM(require_url(), 1);
10446 var import_editor7 = __toESM(require_editor(), 1);
10447 function getPostEditURL(postId) {
10448 return (0, import_url2.addQueryArgs)("post.php", { post: postId, action: "edit" });
10449 }
10450 function BrowserURL() {
10451 const [historyId, setHistoryId] = (0, import_element21.useState)(null);
10452 const { postId, postStatus } = (0, import_data9.useSelect)((select3) => {
10453 const { getCurrentPost } = select3(import_editor7.store);
10454 const post = getCurrentPost();
10455 let { id, status, type } = post;
10456 const isTemplate = ["wp_template", "wp_template_part"].includes(
10457 type
10458 );
10459 if (isTemplate) {
10460 id = post.wp_id;
10461 }
10462 return {
10463 postId: id,
10464 postStatus: status
10465 };
10466 }, []);
10467 (0, import_element21.useEffect)(() => {
10468 if (postId && postId !== historyId && postStatus !== "auto-draft") {
10469 window.history.replaceState(
10470 { id: postId },
10471 "Post " + postId,
10472 getPostEditURL(postId)
10473 );
10474 setHistoryId(postId);
10475 }
10476 }, [postId, postStatus, historyId]);
10477 return null;
10478 }
10479
10480 // packages/edit-post/build-module/components/meta-boxes/index.mjs
10481 var import_data12 = __toESM(require_data(), 1);
10482
10483 // packages/edit-post/build-module/components/meta-boxes/meta-boxes-area/index.mjs
10484 var import_element22 = __toESM(require_element(), 1);
10485 var import_components4 = __toESM(require_components(), 1);
10486 var import_data10 = __toESM(require_data(), 1);
10487 var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1);
10488 function MetaBoxesArea({ location }) {
10489 const container = (0, import_element22.useRef)(null);
10490 const formRef = (0, import_element22.useRef)(null);
10491 (0, import_element22.useEffect)(() => {
10492 formRef.current = document.querySelector(
10493 ".metabox-location-" + location
10494 );
10495 if (formRef.current) {
10496 container.current.appendChild(formRef.current);
10497 }
10498 return () => {
10499 if (formRef.current) {
10500 document.querySelector("#metaboxes").appendChild(formRef.current);
10501 }
10502 };
10503 }, [location]);
10504 const isSaving = (0, import_data10.useSelect)((select3) => {
10505 return select3(store).isSavingMetaBoxes();
10506 }, []);
10507 const classes = clsx_default("edit-post-meta-boxes-area", `is-${location}`, {
10508 "is-loading": isSaving
10509 });
10510 return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: classes, children: [
10511 isSaving && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_components4.Spinner, { className: "edit-post-meta-boxes-area__spinner" }),
10512 /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
10513 "div",
10514 {
10515 className: "edit-post-meta-boxes-area__container",
10516 ref: container
10517 }
10518 ),
10519 /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "edit-post-meta-boxes-area__clear" })
10520 ] });
10521 }
10522 var meta_boxes_area_default = MetaBoxesArea;
10523
10524 // packages/edit-post/build-module/components/meta-boxes/meta-box-visibility.mjs
10525 var import_element23 = __toESM(require_element(), 1);
10526 var import_data11 = __toESM(require_data(), 1);
10527 var import_editor8 = __toESM(require_editor(), 1);
10528 function MetaBoxVisibility({ id }) {
10529 const isVisible = (0, import_data11.useSelect)(
10530 (select3) => {
10531 return select3(import_editor8.store).isEditorPanelEnabled(
10532 `meta-box-${id}`
10533 );
10534 },
10535 [id]
10536 );
10537 (0, import_element23.useEffect)(() => {
10538 const element = document.getElementById(id);
10539 if (!element) {
10540 return;
10541 }
10542 if (isVisible) {
10543 element.classList.remove("is-hidden");
10544 } else {
10545 element.classList.add("is-hidden");
10546 }
10547 }, [id, isVisible]);
10548 return null;
10549 }
10550
10551 // packages/edit-post/build-module/components/meta-boxes/index.mjs
10552 var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1);
10553 function MetaBoxes({ location }) {
10554 const metaBoxes2 = (0, import_data12.useSelect)(
10555 (select3) => select3(store).getMetaBoxesPerLocation(location),
10556 [location]
10557 );
10558 return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(import_jsx_runtime30.Fragment, { children: [
10559 (metaBoxes2 ?? []).map(({ id }) => /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(MetaBoxVisibility, { id }, id)),
10560 /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(meta_boxes_area_default, { location })
10561 ] });
10562 }
10563
10564 // packages/edit-post/build-module/components/more-menu/index.mjs
10565 var import_i18n10 = __toESM(require_i18n(), 1);
10566 var import_compose2 = __toESM(require_compose(), 1);
10567 var import_editor14 = __toESM(require_editor(), 1);
10568 var import_keycodes = __toESM(require_keycodes(), 1);
10569 var import_preferences8 = __toESM(require_preferences(), 1);
10570
10571 // packages/edit-post/build-module/components/more-menu/manage-patterns-menu-item.mjs
10572 var import_components5 = __toESM(require_components(), 1);
10573 var import_core_data5 = __toESM(require_core_data(), 1);
10574 var import_data13 = __toESM(require_data(), 1);
10575 var import_i18n5 = __toESM(require_i18n(), 1);
10576 var import_url3 = __toESM(require_url(), 1);
10577 var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1);
10578 function ManagePatternsMenuItem() {
10579 const url = (0, import_data13.useSelect)((select3) => {
10580 const { canUser } = select3(import_core_data5.store);
10581 const defaultUrl = (0, import_url3.addQueryArgs)("edit.php", {
10582 post_type: "wp_block"
10583 });
10584 const patternsUrl = (0, import_url3.addQueryArgs)("site-editor.php", {
10585 p: "/pattern"
10586 });
10587 return canUser("create", {
10588 kind: "postType",
10589 name: "wp_template"
10590 }) ? patternsUrl : defaultUrl;
10591 }, []);
10592 return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_components5.MenuItem, { role: "menuitem", href: url, children: (0, import_i18n5.__)("Manage patterns") });
10593 }
10594 var manage_patterns_menu_item_default = ManagePatternsMenuItem;
10595
10596 // packages/edit-post/build-module/components/more-menu/welcome-guide-menu-item.mjs
10597 var import_data14 = __toESM(require_data(), 1);
10598 var import_preferences3 = __toESM(require_preferences(), 1);
10599 var import_i18n6 = __toESM(require_i18n(), 1);
10600 var import_editor9 = __toESM(require_editor(), 1);
10601 var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
10602 function WelcomeGuideMenuItem() {
10603 const isEditingTemplate2 = (0, import_data14.useSelect)(
10604 (select3) => select3(import_editor9.store).getCurrentPostType() === "wp_template",
10605 []
10606 );
10607 return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
10608 import_preferences3.PreferenceToggleMenuItem,
10609 {
10610 scope: "core/edit-post",
10611 name: isEditingTemplate2 ? "welcomeGuideTemplate" : "welcomeGuide",
10612 label: (0, import_i18n6.__)("Welcome Guide")
10613 }
10614 );
10615 }
10616
10617 // packages/edit-post/build-module/components/preferences-modal/index.mjs
10618 var import_i18n9 = __toESM(require_i18n(), 1);
10619 var import_preferences7 = __toESM(require_preferences(), 1);
10620 var import_editor13 = __toESM(require_editor(), 1);
10621
10622 // packages/edit-post/build-module/components/preferences-modal/meta-boxes-section.mjs
10623 var import_i18n8 = __toESM(require_i18n(), 1);
10624 var import_data17 = __toESM(require_data(), 1);
10625 var import_editor12 = __toESM(require_editor(), 1);
10626 var import_preferences6 = __toESM(require_preferences(), 1);
10627
10628 // packages/edit-post/build-module/components/preferences-modal/enable-custom-fields.mjs
10629 var import_element24 = __toESM(require_element(), 1);
10630 var import_i18n7 = __toESM(require_i18n(), 1);
10631 var import_components6 = __toESM(require_components(), 1);
10632 var import_data15 = __toESM(require_data(), 1);
10633 var import_editor10 = __toESM(require_editor(), 1);
10634 var import_preferences4 = __toESM(require_preferences(), 1);
10635 var import_url4 = __toESM(require_url(), 1);
10636 var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1);
10637 var { PreferenceBaseOption } = unlock2(import_preferences4.privateApis);
10638 function submitCustomFieldsForm() {
10639 const customFieldsForm = document.getElementById(
10640 "toggle-custom-fields-form"
10641 );
10642 customFieldsForm.querySelector('[name="_wp_http_referer"]').setAttribute("value", (0, import_url4.getPathAndQueryString)(window.location.href));
10643 customFieldsForm.submit();
10644 }
10645 function CustomFieldsConfirmation({ willEnable }) {
10646 const [isReloading, setIsReloading] = (0, import_element24.useState)(false);
10647 return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_jsx_runtime33.Fragment, { children: [
10648 /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("p", { className: "edit-post-preferences-modal__custom-fields-confirmation-message", children: (0, import_i18n7.__)(
10649 "A page reload is required for this change. Make sure your content is saved before reloading."
10650 ) }),
10651 /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
10652 import_components6.Button,
10653 {
10654 __next40pxDefaultSize: true,
10655 variant: "secondary",
10656 isBusy: isReloading,
10657 accessibleWhenDisabled: true,
10658 disabled: isReloading,
10659 onClick: () => {
10660 setIsReloading(true);
10661 submitCustomFieldsForm();
10662 },
10663 children: willEnable ? (0, import_i18n7.__)("Show & Reload Page") : (0, import_i18n7.__)("Hide & Reload Page")
10664 }
10665 )
10666 ] });
10667 }
10668 function EnableCustomFieldsOption({ label }) {
10669 const areCustomFieldsEnabled = (0, import_data15.useSelect)((select3) => {
10670 return !!select3(import_editor10.store).getEditorSettings().enableCustomFields;
10671 }, []);
10672 const [isChecked, setIsChecked] = (0, import_element24.useState)(areCustomFieldsEnabled);
10673 return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
10674 PreferenceBaseOption,
10675 {
10676 label,
10677 isChecked,
10678 onChange: setIsChecked,
10679 children: isChecked !== areCustomFieldsEnabled && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(CustomFieldsConfirmation, { willEnable: isChecked })
10680 }
10681 );
10682 }
10683
10684 // packages/edit-post/build-module/components/preferences-modal/enable-panel.mjs
10685 var import_data16 = __toESM(require_data(), 1);
10686 var import_editor11 = __toESM(require_editor(), 1);
10687 var import_preferences5 = __toESM(require_preferences(), 1);
10688 var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
10689 var { PreferenceBaseOption: PreferenceBaseOption2 } = unlock2(import_preferences5.privateApis);
10690 function EnablePanelOption(props) {
10691 const { toggleEditorPanelEnabled: toggleEditorPanelEnabled2 } = (0, import_data16.useDispatch)(import_editor11.store);
10692 const { isChecked, isRemoved } = (0, import_data16.useSelect)(
10693 (select3) => {
10694 const { isEditorPanelEnabled: isEditorPanelEnabled2, isEditorPanelRemoved: isEditorPanelRemoved2 } = select3(import_editor11.store);
10695 return {
10696 isChecked: isEditorPanelEnabled2(props.panelName),
10697 isRemoved: isEditorPanelRemoved2(props.panelName)
10698 };
10699 },
10700 [props.panelName]
10701 );
10702 if (isRemoved) {
10703 return null;
10704 }
10705 return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
10706 PreferenceBaseOption2,
10707 {
10708 isChecked,
10709 onChange: () => toggleEditorPanelEnabled2(props.panelName),
10710 ...props
10711 }
10712 );
10713 }
10714
10715 // packages/edit-post/build-module/components/preferences-modal/meta-boxes-section.mjs
10716 var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1);
10717 var { PreferencesModalSection } = unlock2(import_preferences6.privateApis);
10718 function MetaBoxesSection(sectionProps) {
10719 const { areCustomFieldsRegistered, metaBoxes: metaBoxes2 } = (0, import_data17.useSelect)((select3) => {
10720 const { getEditorSettings } = select3(import_editor12.store);
10721 const { getAllMetaBoxes: getAllMetaBoxes2 } = select3(store);
10722 return {
10723 areCustomFieldsRegistered: getEditorSettings().enableCustomFields !== void 0,
10724 metaBoxes: getAllMetaBoxes2()
10725 };
10726 }, []);
10727 const thirdPartyMetaBoxes = metaBoxes2.filter(
10728 ({ id }) => id !== "postcustom"
10729 );
10730 if (!areCustomFieldsRegistered && thirdPartyMetaBoxes.length === 0) {
10731 return null;
10732 }
10733 return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(PreferencesModalSection, { ...sectionProps, children: [
10734 areCustomFieldsRegistered && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(EnableCustomFieldsOption, { label: (0, import_i18n8.__)("Custom fields") }),
10735 thirdPartyMetaBoxes.map(({ id, title }) => /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
10736 EnablePanelOption,
10737 {
10738 label: title,
10739 panelName: `meta-box-${id}`
10740 },
10741 id
10742 ))
10743 ] });
10744 }
10745
10746 // packages/edit-post/build-module/components/preferences-modal/index.mjs
10747 var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
10748 var { PreferenceToggleControl } = unlock2(import_preferences7.privateApis);
10749 var { PreferencesModal } = unlock2(import_editor13.privateApis);
10750 function EditPostPreferencesModal() {
10751 const extraSections = {
10752 general: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(MetaBoxesSection, { title: (0, import_i18n9.__)("Advanced") }),
10753 appearance: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
10754 PreferenceToggleControl,
10755 {
10756 scope: "core/edit-post",
10757 featureName: "themeStyles",
10758 help: (0, import_i18n9.__)("Make the editor look like your theme."),
10759 label: (0, import_i18n9.__)("Use theme styles")
10760 }
10761 )
10762 };
10763 return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(PreferencesModal, { extraSections });
10764 }
10765
10766 // packages/edit-post/build-module/components/more-menu/index.mjs
10767 var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1);
10768 var { ToolsMoreMenuGroup, ViewMoreMenuGroup } = unlock2(import_editor14.privateApis);
10769 var MoreMenu = () => {
10770 const isLargeViewport = (0, import_compose2.useViewportMatch)("large");
10771 return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(import_jsx_runtime37.Fragment, { children: [
10772 isLargeViewport && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(ViewMoreMenuGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
10773 import_preferences8.PreferenceToggleMenuItem,
10774 {
10775 scope: "core/edit-post",
10776 name: "fullscreenMode",
10777 label: (0, import_i18n10.__)("Fullscreen mode"),
10778 info: (0, import_i18n10.__)("Show and hide the admin user interface"),
10779 messageActivated: (0, import_i18n10.__)("Fullscreen mode activated."),
10780 messageDeactivated: (0, import_i18n10.__)(
10781 "Fullscreen mode deactivated."
10782 ),
10783 shortcut: import_keycodes.displayShortcut.secondary("f")
10784 }
10785 ) }),
10786 /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(ToolsMoreMenuGroup, { children: [
10787 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(manage_patterns_menu_item_default, {}),
10788 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(WelcomeGuideMenuItem, {})
10789 ] }),
10790 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(EditPostPreferencesModal, {})
10791 ] });
10792 };
10793 var more_menu_default = MoreMenu;
10794
10795 // packages/edit-post/build-module/components/welcome-guide/index.mjs
10796 var import_data20 = __toESM(require_data(), 1);
10797
10798 // packages/edit-post/build-module/components/welcome-guide/default.mjs
10799 var import_data18 = __toESM(require_data(), 1);
10800 var import_components7 = __toESM(require_components(), 1);
10801 var import_i18n11 = __toESM(require_i18n(), 1);
10802 var import_element25 = __toESM(require_element(), 1);
10803
10804 // packages/edit-post/build-module/components/welcome-guide/image.mjs
10805 var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1);
10806 function WelcomeGuideImage({ nonAnimatedSrc, animatedSrc }) {
10807 return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("picture", { className: "edit-post-welcome-guide__image", children: [
10808 /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
10809 "source",
10810 {
10811 srcSet: nonAnimatedSrc,
10812 media: "(prefers-reduced-motion: reduce)"
10813 }
10814 ),
10815 /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("img", { src: animatedSrc, width: "312", height: "240", alt: "" })
10816 ] });
10817 }
10818
10819 // packages/edit-post/build-module/components/welcome-guide/default.mjs
10820 var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
10821 function WelcomeGuideDefault() {
10822 const { toggleFeature: toggleFeature2 } = (0, import_data18.useDispatch)(store);
10823 return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
10824 import_components7.Guide,
10825 {
10826 className: "edit-post-welcome-guide",
10827 contentLabel: (0, import_i18n11.__)("Welcome to the editor"),
10828 finishButtonText: (0, import_i18n11.__)("Get started"),
10829 onFinish: () => toggleFeature2("welcomeGuide"),
10830 pages: [
10831 {
10832 image: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
10833 WelcomeGuideImage,
10834 {
10835 nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-canvas.svg",
10836 animatedSrc: "https://s.w.org/images/block-editor/welcome-canvas.gif"
10837 }
10838 ),
10839 content: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [
10840 /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("h1", { className: "edit-post-welcome-guide__heading", children: (0, import_i18n11.__)("Welcome to the editor") }),
10841 /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("p", { className: "edit-post-welcome-guide__text", children: (0, import_i18n11.__)(
10842 "In the WordPress editor, each paragraph, image, or video is presented as a distinct \u201Cblock\u201D of content."
10843 ) })
10844 ] })
10845 },
10846 {
10847 image: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
10848 WelcomeGuideImage,
10849 {
10850 nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-editor.svg",
10851 animatedSrc: "https://s.w.org/images/block-editor/welcome-editor.gif"
10852 }
10853 ),
10854 content: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [
10855 /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("h1", { className: "edit-post-welcome-guide__heading", children: (0, import_i18n11.__)("Customize each block") }),
10856 /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("p", { className: "edit-post-welcome-guide__text", children: (0, import_i18n11.__)(
10857 "Each block comes with its own set of controls for changing things like color, width, and alignment. These will show and hide automatically when you have a block selected."
10858 ) })
10859 ] })
10860 },
10861 {
10862 image: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
10863 WelcomeGuideImage,
10864 {
10865 nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-library.svg",
10866 animatedSrc: "https://s.w.org/images/block-editor/welcome-library.gif"
10867 }
10868 ),
10869 content: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [
10870 /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("h1", { className: "edit-post-welcome-guide__heading", children: (0, import_i18n11.__)("Explore all blocks") }),
10871 /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("p", { className: "edit-post-welcome-guide__text", children: (0, import_element25.createInterpolateElement)(
10872 (0, import_i18n11.__)(
10873 "All of the blocks available to you live in the block library. You\u2019ll find it wherever you see the <InserterIconImage /> icon."
10874 ),
10875 {
10876 InserterIconImage: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
10877 "img",
10878 {
10879 alt: (0, import_i18n11.__)("inserter"),
10880 src: "data:image/svg+xml,%3Csvg width='18' height='18' viewBox='0 0 18 18' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='18' height='18' rx='2' fill='%231E1E1E'/%3E%3Cpath d='M9.22727 4V14M4 8.77273H14' stroke='white' stroke-width='1.5'/%3E%3C/svg%3E%0A"
10881 }
10882 )
10883 }
10884 ) })
10885 ] })
10886 },
10887 {
10888 image: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
10889 WelcomeGuideImage,
10890 {
10891 nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-documentation.svg",
10892 animatedSrc: "https://s.w.org/images/block-editor/welcome-documentation.gif"
10893 }
10894 ),
10895 content: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [
10896 /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("h1", { className: "edit-post-welcome-guide__heading", children: (0, import_i18n11.__)("Learn more") }),
10897 /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("p", { className: "edit-post-welcome-guide__text", children: (0, import_element25.createInterpolateElement)(
10898 (0, import_i18n11.__)(
10899 "New to the block editor? Want to learn more about using it? <a>Here's a detailed guide.</a>"
10900 ),
10901 {
10902 a: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
10903 import_components7.ExternalLink,
10904 {
10905 href: (0, import_i18n11.__)(
10906 "https://wordpress.org/documentation/article/wordpress-block-editor/"
10907 )
10908 }
10909 )
10910 }
10911 ) })
10912 ] })
10913 }
10914 ]
10915 }
10916 );
10917 }
10918
10919 // packages/edit-post/build-module/components/welcome-guide/template.mjs
10920 var import_data19 = __toESM(require_data(), 1);
10921 var import_components8 = __toESM(require_components(), 1);
10922 var import_i18n12 = __toESM(require_i18n(), 1);
10923 var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1);
10924 function WelcomeGuideTemplate() {
10925 const { toggleFeature: toggleFeature2 } = (0, import_data19.useDispatch)(store);
10926 return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
10927 import_components8.Guide,
10928 {
10929 className: "edit-template-welcome-guide",
10930 contentLabel: (0, import_i18n12.__)("Welcome to the template editor"),
10931 finishButtonText: (0, import_i18n12.__)("Get started"),
10932 onFinish: () => toggleFeature2("welcomeGuideTemplate"),
10933 pages: [
10934 {
10935 image: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
10936 WelcomeGuideImage,
10937 {
10938 nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-template-editor.svg",
10939 animatedSrc: "https://s.w.org/images/block-editor/welcome-template-editor.gif"
10940 }
10941 ),
10942 content: /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(import_jsx_runtime40.Fragment, { children: [
10943 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("h1", { className: "edit-post-welcome-guide__heading", children: (0, import_i18n12.__)("Welcome to the template editor") }),
10944 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("p", { className: "edit-post-welcome-guide__text", children: (0, import_i18n12.__)(
10945 "Templates help define the layout of the site. You can customize all aspects of your posts and pages using blocks and patterns in this editor."
10946 ) })
10947 ] })
10948 }
10949 ]
10950 }
10951 );
10952 }
10953
10954 // packages/edit-post/build-module/components/welcome-guide/index.mjs
10955 var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);
10956 function WelcomeGuide({ postType }) {
10957 const { isActive, isEditingTemplate: isEditingTemplate2 } = (0, import_data20.useSelect)(
10958 (select3) => {
10959 const { isFeatureActive: isFeatureActive2 } = select3(store);
10960 const _isEditingTemplate = postType === "wp_template";
10961 const feature = _isEditingTemplate ? "welcomeGuideTemplate" : "welcomeGuide";
10962 return {
10963 isActive: isFeatureActive2(feature),
10964 isEditingTemplate: _isEditingTemplate
10965 };
10966 },
10967 [postType]
10968 );
10969 if (!isActive) {
10970 return null;
10971 }
10972 return isEditingTemplate2 ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(WelcomeGuideTemplate, {}) : /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(WelcomeGuideDefault, {});
10973 }
10974
10975 // packages/edit-post/build-module/commands/use-commands.mjs
10976 var import_data21 = __toESM(require_data(), 1);
10977 var import_i18n13 = __toESM(require_i18n(), 1);
10978 var import_commands = __toESM(require_commands(), 1);
10979 var import_preferences9 = __toESM(require_preferences(), 1);
10980 var import_notices2 = __toESM(require_notices(), 1);
10981 function useCommands() {
10982 const { isFullscreen } = (0, import_data21.useSelect)((select3) => {
10983 const { get } = select3(import_preferences9.store);
10984 return {
10985 isFullscreen: get("core/edit-post", "fullscreenMode")
10986 };
10987 }, []);
10988 const { toggle } = (0, import_data21.useDispatch)(import_preferences9.store);
10989 const { createInfoNotice } = (0, import_data21.useDispatch)(import_notices2.store);
10990 (0, import_commands.useCommand)({
10991 name: "core/toggle-fullscreen-mode",
10992 label: isFullscreen ? (0, import_i18n13.__)("Exit fullscreen") : (0, import_i18n13.__)("Enter fullscreen"),
10993 icon: fullscreen_default,
10994 category: "command",
10995 callback: ({ close }) => {
10996 toggle("core/edit-post", "fullscreenMode");
10997 close();
10998 createInfoNotice(
10999 isFullscreen ? (0, import_i18n13.__)("Fullscreen off.") : (0, import_i18n13.__)("Fullscreen on."),
11000 {
11001 id: "core/edit-post/toggle-fullscreen-mode/notice",
11002 type: "snackbar",
11003 actions: [
11004 {
11005 label: (0, import_i18n13.__)("Undo"),
11006 onClick: () => {
11007 toggle("core/edit-post", "fullscreenMode");
11008 }
11009 }
11010 ]
11011 }
11012 );
11013 }
11014 });
11015 }
11016
11017 // packages/edit-post/build-module/components/layout/use-should-iframe.mjs
11018 var import_editor15 = __toESM(require_editor(), 1);
11019 var import_data22 = __toESM(require_data(), 1);
11020 var import_blocks2 = __toESM(require_blocks(), 1);
11021 var import_block_editor = __toESM(require_block_editor(), 1);
11022 var isGutenbergPlugin = true ? true : false;
11023 function useShouldIframe() {
11024 return (0, import_data22.useSelect)((select3) => {
11025 const { getCurrentPostType, getDeviceType } = select3(import_editor15.store);
11026 const { getClientIdsWithDescendants, getBlockName } = select3(import_block_editor.store);
11027 const { getBlockType } = select3(import_blocks2.store);
11028 return (
11029 // If the Gutenberg plugin is active, we ALWAYS use the iframe for
11030 // consistency across the post and site editor. We plan on enforcing
11031 // the iframe in the future, so Gutenberg both serves as way for us
11032 // to warn plugin developers and for plugin developers to test their
11033 // blocks easily. Before GB v22.5, we only enforced it for
11034 // block-based themes (classic themes used the same rules as core).
11035 isGutenbergPlugin || // We also still want to iframe all the special
11036 // editor features and modes such as device previews, zoom out, and
11037 // template/pattern editing.
11038 getDeviceType() !== "Desktop" || ["wp_template", "wp_block"].includes(getCurrentPostType()) || unlock2(select3(import_block_editor.store)).isZoomOut() || // Finally, still iframe the editor if all present blocks are v3
11039 // (which means they are marked as iframe-compatible).
11040 [...new Set(getClientIdsWithDescendants().map(getBlockName))].map(getBlockType).filter(Boolean).every((blockType) => blockType.apiVersion >= 3)
11041 );
11042 }, []);
11043 }
11044
11045 // packages/edit-post/build-module/hooks/use-navigate-to-entity-record.mjs
11046 var import_element26 = __toESM(require_element(), 1);
11047 var import_data23 = __toESM(require_data(), 1);
11048 var import_editor16 = __toESM(require_editor(), 1);
11049 var import_core_data6 = __toESM(require_core_data(), 1);
11050 function useNavigateToEntityRecord(initialPostId, initialPostType, defaultRenderingMode) {
11051 const registry = (0, import_data23.useRegistry)();
11052 const [postHistory, dispatch2] = (0, import_element26.useReducer)(
11053 (historyState, { type, post: post2, previousRenderingMode: previousRenderingMode2, selectedBlockClientId }) => {
11054 if (type === "push") {
11055 const updatedHistory = [...historyState];
11056 const currentIndex = updatedHistory.length - 1;
11057 updatedHistory[currentIndex] = {
11058 ...updatedHistory[currentIndex],
11059 selectedBlockClientId
11060 };
11061 return [...updatedHistory, { post: post2, previousRenderingMode: previousRenderingMode2 }];
11062 }
11063 if (type === "pop") {
11064 if (historyState.length > 1) {
11065 return historyState.slice(0, -1);
11066 }
11067 }
11068 return historyState;
11069 },
11070 [
11071 {
11072 post: { postId: initialPostId, postType: initialPostType }
11073 }
11074 ]
11075 );
11076 const { post, previousRenderingMode } = postHistory[postHistory.length - 1];
11077 const { getRenderingMode } = (0, import_data23.useSelect)(import_editor16.store);
11078 const { setRenderingMode } = (0, import_data23.useDispatch)(import_editor16.store);
11079 const { editEntityRecord } = (0, import_data23.useDispatch)(import_core_data6.store);
11080 const onNavigateToEntityRecord = (0, import_element26.useCallback)(
11081 (params) => {
11082 const entityEdits = registry.select(import_core_data6.store).getEntityRecordEdits("postType", post.postType, post.postId);
11083 const externalClientId = entityEdits?.selection?.selectionStart?.clientId ?? null;
11084 dispatch2({
11085 type: "push",
11086 post: { postId: params.postId, postType: params.postType },
11087 // Save the current rendering mode so we can restore it when navigating back.
11088 previousRenderingMode: getRenderingMode(),
11089 selectedBlockClientId: externalClientId
11090 });
11091 setRenderingMode(defaultRenderingMode);
11092 },
11093 [
11094 registry,
11095 post.postType,
11096 post.postId,
11097 getRenderingMode,
11098 setRenderingMode,
11099 defaultRenderingMode
11100 ]
11101 );
11102 const onNavigateToPreviousEntityRecord = (0, import_element26.useCallback)(() => {
11103 if (postHistory.length > 1) {
11104 const previousItem = postHistory[postHistory.length - 2];
11105 if (previousItem.selectedBlockClientId) {
11106 editEntityRecord(
11107 "postType",
11108 previousItem.post.postType,
11109 previousItem.post.postId,
11110 {
11111 selection: {
11112 selectionStart: {
11113 clientId: previousItem.selectedBlockClientId
11114 },
11115 selectionEnd: {
11116 clientId: previousItem.selectedBlockClientId
11117 }
11118 }
11119 },
11120 { undoIgnore: true }
11121 );
11122 }
11123 }
11124 dispatch2({
11125 type: "pop"
11126 });
11127 if (previousRenderingMode) {
11128 setRenderingMode(previousRenderingMode);
11129 }
11130 }, [
11131 setRenderingMode,
11132 previousRenderingMode,
11133 postHistory,
11134 editEntityRecord
11135 ]);
11136 return {
11137 currentPost: post,
11138 onNavigateToEntityRecord,
11139 onNavigateToPreviousEntityRecord: postHistory.length > 1 ? onNavigateToPreviousEntityRecord : void 0
11140 };
11141 }
11142
11143 // packages/edit-post/build-module/components/meta-boxes/use-meta-box-initialization.mjs
11144 var import_data24 = __toESM(require_data(), 1);
11145 var import_editor17 = __toESM(require_editor(), 1);
11146 var import_core_data7 = __toESM(require_core_data(), 1);
11147 var import_element27 = __toESM(require_element(), 1);
11148 var useMetaBoxInitialization = (enabled) => {
11149 const {
11150 isEnabledAndEditorReady,
11151 isCollaborationEnabled,
11152 hasIncompatibleMetaBoxes,
11153 hasActiveMetaBoxes
11154 } = (0, import_data24.useSelect)(
11155 (select3) => {
11156 const {
11157 __unstableIsEditorReady,
11158 isCollaborationEnabledForCurrentPost
11159 } = unlock2(select3(import_editor17.store));
11160 return {
11161 isEnabledAndEditorReady: enabled && __unstableIsEditorReady(),
11162 isCollaborationEnabled: isCollaborationEnabledForCurrentPost(),
11163 hasIncompatibleMetaBoxes: enabled ? select3(store).getAllMetaBoxes().some((metaBox) => !metaBox.__rtc_compatible) : false,
11164 hasActiveMetaBoxes: enabled && select3(store).hasMetaBoxes()
11165 };
11166 },
11167 [enabled]
11168 );
11169 const { setCollaborationSupported } = unlock2((0, import_data24.useDispatch)(import_core_data7.store));
11170 const { updateEditorSettings } = (0, import_data24.useDispatch)(import_editor17.store);
11171 const { initializeMetaBoxes: initializeMetaBoxes2 } = (0, import_data24.useDispatch)(store);
11172 (0, import_element27.useEffect)(() => {
11173 if (isEnabledAndEditorReady) {
11174 initializeMetaBoxes2();
11175 if (isCollaborationEnabled && hasIncompatibleMetaBoxes) {
11176 setCollaborationSupported(false);
11177 }
11178 if (hasActiveMetaBoxes) {
11179 updateEditorSettings({ disableVisualRevisions: true });
11180 }
11181 }
11182 }, [
11183 isEnabledAndEditorReady,
11184 initializeMetaBoxes2,
11185 isCollaborationEnabled,
11186 setCollaborationSupported,
11187 hasIncompatibleMetaBoxes,
11188 hasActiveMetaBoxes,
11189 updateEditorSettings
11190 ]);
11191 };
11192
11193 // packages/edit-post/build-module/components/layout/index.mjs
11194 var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1);
11195 var { useCommandContext } = unlock2(import_commands2.privateApis);
11196 var { useDrag } = unlock2(import_components9.privateApis);
11197 var { Editor, FullscreenMode, UploadProgressSnackbar } = unlock2(import_editor18.privateApis);
11198 var { BlockKeyboardShortcuts } = unlock2(import_block_library.privateApis);
11199 var DESIGN_POST_TYPES = [
11200 "wp_template",
11201 "wp_template_part",
11202 "wp_block",
11203 "wp_navigation"
11204 ];
11205 function useEditorStyles(settings) {
11206 const { hasThemeStyleSupport } = (0, import_data25.useSelect)((select3) => {
11207 return {
11208 hasThemeStyleSupport: select3(store).isFeatureActive("themeStyles")
11209 };
11210 }, []);
11211 return (0, import_element28.useMemo)(() => {
11212 const presetStyles = settings.styles?.filter(
11213 (style) => style.__unstableType && style.__unstableType !== "theme"
11214 ) ?? [];
11215 const defaultEditorStyles = [
11216 ...settings?.defaultEditorStyles ?? [],
11217 ...presetStyles
11218 ];
11219 const hasThemeStyles = hasThemeStyleSupport && presetStyles.length !== (settings.styles?.length ?? 0);
11220 if (!settings.disableLayoutStyles && !hasThemeStyles) {
11221 defaultEditorStyles.push({
11222 css: getLayoutStyles({
11223 style: {},
11224 selector: "body",
11225 hasBlockGapSupport: false,
11226 hasFallbackGapSupport: true,
11227 fallbackGapValue: "0.5em"
11228 })
11229 });
11230 }
11231 return hasThemeStyles ? settings.styles ?? [] : defaultEditorStyles;
11232 }, [
11233 settings.defaultEditorStyles,
11234 settings.disableLayoutStyles,
11235 settings.styles,
11236 hasThemeStyleSupport
11237 ]);
11238 }
11239 function MetaBoxesMain({ isLegacy }) {
11240 const [isOpen, openHeight, hasAnyVisible] = (0, import_data25.useSelect)((select3) => {
11241 const { get } = select3(import_preferences10.store);
11242 const { isMetaBoxLocationVisible: isMetaBoxLocationVisible2 } = select3(store);
11243 return [
11244 !!get("core/edit-post", "metaBoxesMainIsOpen"),
11245 get("core/edit-post", "metaBoxesMainOpenHeight"),
11246 isMetaBoxLocationVisible2("normal") || isMetaBoxLocationVisible2("advanced") || isMetaBoxLocationVisible2("side")
11247 ];
11248 }, []);
11249 const { set: setPreference } = (0, import_data25.useDispatch)(import_preferences10.store);
11250 const isShort = (0, import_compose3.useMediaQuery)("(max-height: 549px)");
11251 const [{ min: min2 = 0, max: max2 }, setHeightConstraints] = (0, import_element28.useState)(() => ({}));
11252 const effectSizeConstraints = (0, import_compose3.useRefEffect)((node) => {
11253 const container = node.closest(
11254 ".interface-interface-skeleton__content"
11255 );
11256 if (!container) {
11257 return;
11258 }
11259 const noticeContainer = container.querySelector(
11260 ":scope > .notices-inline-notices-wrapper"
11261 );
11262 const resizeHandle = container.querySelector(
11263 ".edit-post-meta-boxes-main__presenter"
11264 );
11265 const deriveConstraints = () => {
11266 const fullHeight = container.offsetHeight;
11267 let nextMax = fullHeight;
11268 if (noticeContainer) {
11269 nextMax -= noticeContainer.offsetHeight;
11270 }
11271 const nextMin = resizeHandle?.offsetHeight ?? 0;
11272 setHeightConstraints({ min: nextMin, max: nextMax });
11273 };
11274 const observer = new window.ResizeObserver(deriveConstraints);
11275 observer.observe(container);
11276 if (noticeContainer) {
11277 observer.observe(noticeContainer);
11278 }
11279 return () => observer.disconnect();
11280 }, []);
11281 const metaBoxesMainRef = (0, import_element28.useRef)();
11282 const setMainRefs = (0, import_compose3.useMergeRefs)([
11283 metaBoxesMainRef,
11284 effectSizeConstraints
11285 ]);
11286 const separatorRef = (0, import_element28.useRef)();
11287 const separatorHelpId = (0, import_element28.useId)();
11288 const heightRef = (0, import_element28.useRef)();
11289 const getAriaValueNow = (height) => Math.round((height - min2) / (max2 - min2) * 100);
11290 const persistIsOpen = (to = !isOpen) => setPreference("core/edit-post", "metaBoxesMainIsOpen", to);
11291 const applyHeight = (candidateHeight = "auto", isPersistent) => {
11292 let styleHeight;
11293 if (candidateHeight === "auto") {
11294 isPersistent = false;
11295 styleHeight = candidateHeight;
11296 } else {
11297 candidateHeight = Math.min(max2, Math.max(min2, candidateHeight));
11298 heightRef.current = candidateHeight;
11299 styleHeight = `${candidateHeight}px`;
11300 }
11301 if (isPersistent) {
11302 setPreference(
11303 "core/edit-post",
11304 "metaBoxesMainOpenHeight",
11305 candidateHeight
11306 );
11307 } else {
11308 metaBoxesMainRef.current.style.height = styleHeight;
11309 if (!isShort) {
11310 separatorRef.current.ariaValueNow = getAriaValueNow(candidateHeight);
11311 }
11312 }
11313 };
11314 const bindDragGesture = useDrag(
11315 ({ movement, first, last, memo, tap, args }) => {
11316 const pane = metaBoxesMainRef.current;
11317 const [, yMovement] = movement;
11318 if (first) {
11319 pane.classList.add("is-resizing");
11320 let fromHeight = heightRef.current ?? pane.offsetHeight;
11321 if (isOpen) {
11322 if (fromHeight > max2) {
11323 fromHeight = max2;
11324 }
11325 } else {
11326 fromHeight = min2;
11327 }
11328 applyHeight(fromHeight - yMovement);
11329 return { fromHeight };
11330 }
11331 if (!first && !last && !tap) {
11332 applyHeight(memo.fromHeight - yMovement);
11333 return memo;
11334 }
11335 pane.classList.remove("is-resizing");
11336 if (tap) {
11337 const [onTap] = args;
11338 onTap?.();
11339 return;
11340 }
11341 const nextIsOpen = heightRef.current > min2;
11342 persistIsOpen(nextIsOpen);
11343 applyHeight(heightRef.current, nextIsOpen);
11344 },
11345 { keyboardDisplacement: 20, filterTaps: true }
11346 );
11347 if (!hasAnyVisible) {
11348 return;
11349 }
11350 const contents = /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
11351 "div",
11352 {
11353 className: "edit-post-layout__metaboxes edit-post-meta-boxes-main__liner",
11354 hidden: !isLegacy && !isOpen,
11355 children: [
11356 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(MetaBoxes, { location: "normal" }),
11357 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(MetaBoxes, { location: "advanced" })
11358 ]
11359 }
11360 );
11361 if (isLegacy) {
11362 return contents;
11363 }
11364 const isAutoHeight = openHeight === void 0;
11365 const usedOpenHeight = isShort ? "auto" : openHeight;
11366 const usedHeight = isOpen ? usedOpenHeight : min2;
11367 const usedAriaValueNow = max2 === void 0 || isAutoHeight ? 50 : getAriaValueNow(usedHeight);
11368 const paneLabel = (0, import_i18n14.__)("Meta Boxes");
11369 const toggle = /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
11370 "button",
11371 {
11372 "aria-expanded": isOpen,
11373 onClick: ({ detail }) => {
11374 if (isShort || !detail) {
11375 persistIsOpen();
11376 }
11377 },
11378 ...!isShort && bindDragGesture(persistIsOpen),
11379 children: [
11380 paneLabel,
11381 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_components9.Icon, { icon: isOpen ? chevron_up_default : chevron_down_default })
11382 ]
11383 }
11384 );
11385 const separator = !isShort && /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(import_jsx_runtime42.Fragment, { children: [
11386 /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(tooltip_exports.Root, { children: [
11387 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
11388 tooltip_exports.Trigger,
11389 {
11390 render: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
11391 "button",
11392 {
11393 ref: separatorRef,
11394 role: "separator",
11395 "aria-valuenow": usedAriaValueNow,
11396 "aria-label": (0, import_i18n14.__)("Drag to resize"),
11397 "aria-describedby": separatorHelpId,
11398 ...bindDragGesture()
11399 }
11400 )
11401 }
11402 ),
11403 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(tooltip_exports.Popup, { children: (0, import_i18n14.__)("Drag to resize") })
11404 ] }),
11405 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(VisuallyHidden, { id: separatorHelpId, children: (0, import_i18n14.__)(
11406 "Use up and down arrow keys to resize the meta box pane."
11407 ) })
11408 ] });
11409 return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
11410 navigable_region_default,
11411 {
11412 ariaLabel: paneLabel,
11413 ref: setMainRefs,
11414 className: clsx_default(
11415 "edit-post-meta-boxes-main",
11416 !isShort && "is-resizable"
11417 ),
11418 style: { height: usedHeight },
11419 children: [
11420 /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: "edit-post-meta-boxes-main__presenter", children: [
11421 toggle,
11422 separator
11423 ] }),
11424 contents
11425 ]
11426 }
11427 );
11428 }
11429 function Layout({
11430 postId: initialPostId,
11431 postType: initialPostType,
11432 settings,
11433 initialEdits
11434 }) {
11435 useCommands();
11436 const shouldIframe = useShouldIframe();
11437 const { createErrorNotice } = (0, import_data25.useDispatch)(import_notices3.store);
11438 const {
11439 currentPost: { postId: currentPostId, postType: currentPostType },
11440 onNavigateToEntityRecord,
11441 onNavigateToPreviousEntityRecord
11442 } = useNavigateToEntityRecord(
11443 initialPostId,
11444 initialPostType,
11445 "post-only"
11446 );
11447 const isEditingTemplate2 = currentPostType === "wp_template";
11448 const {
11449 mode,
11450 isFullscreenActive,
11451 hasResolvedMode,
11452 hasActiveMetaboxes,
11453 hasBlockSelected,
11454 showIconLabels,
11455 isDistractionFree,
11456 showMetaBoxes,
11457 isWelcomeGuideVisible,
11458 templateId
11459 } = (0, import_data25.useSelect)(
11460 (select3) => {
11461 const { get } = select3(import_preferences10.store);
11462 const { isFeatureActive: isFeatureActive2, hasMetaBoxes: hasMetaBoxes2 } = select3(store);
11463 const { canUser, getPostType, getTemplateId } = unlock2(
11464 select3(import_core_data8.store)
11465 );
11466 const supportsTemplateMode = settings.supportsTemplateMode;
11467 const isViewable = getPostType(currentPostType)?.viewable ?? false;
11468 const canViewTemplate = canUser("read", {
11469 kind: "postType",
11470 name: "wp_template"
11471 });
11472 const { getBlockSelectionStart, isZoomOut } = unlock2(
11473 select3(import_block_editor2.store)
11474 );
11475 const { getEditorMode: getEditorMode2, getDefaultRenderingMode } = unlock2(
11476 select3(import_editor18.store)
11477 );
11478 const isNotDesignPostType = !DESIGN_POST_TYPES.includes(currentPostType);
11479 const isDirectlyEditingPattern = currentPostType === "wp_block" && !onNavigateToPreviousEntityRecord;
11480 const _templateId = getTemplateId(currentPostType, currentPostId);
11481 const defaultMode = getDefaultRenderingMode(currentPostType);
11482 return {
11483 mode: getEditorMode2(),
11484 isFullscreenActive: isFeatureActive2("fullscreenMode"),
11485 hasActiveMetaboxes: hasMetaBoxes2(),
11486 hasResolvedMode: defaultMode === "template-locked" ? !!_templateId : defaultMode !== void 0,
11487 hasBlockSelected: !!getBlockSelectionStart(),
11488 showIconLabels: get("core", "showIconLabels"),
11489 isDistractionFree: get("core", "distractionFree"),
11490 showMetaBoxes: isNotDesignPostType && !isZoomOut() || isDirectlyEditingPattern,
11491 isWelcomeGuideVisible: isFeatureActive2("welcomeGuide"),
11492 templateId: supportsTemplateMode && isViewable && canViewTemplate && !isEditingTemplate2 ? _templateId : null
11493 };
11494 },
11495 [
11496 currentPostType,
11497 currentPostId,
11498 isEditingTemplate2,
11499 settings.supportsTemplateMode,
11500 onNavigateToPreviousEntityRecord
11501 ]
11502 );
11503 useMetaBoxInitialization(hasActiveMetaboxes && hasResolvedMode);
11504 const commandContext = hasBlockSelected ? "block-selection-edit" : "entity-edit";
11505 useCommandContext(commandContext);
11506 const styles = useEditorStyles(settings);
11507 const editorSettings = (0, import_element28.useMemo)(
11508 () => ({
11509 ...settings,
11510 styles,
11511 onNavigateToEntityRecord,
11512 onNavigateToPreviousEntityRecord
11513 }),
11514 [
11515 settings,
11516 styles,
11517 onNavigateToEntityRecord,
11518 onNavigateToPreviousEntityRecord
11519 ]
11520 );
11521 if (showIconLabels) {
11522 document.body.classList.add("show-icon-labels");
11523 } else {
11524 document.body.classList.remove("show-icon-labels");
11525 }
11526 const navigateRegionsProps = (0, import_components9.__unstableUseNavigateRegions)();
11527 const className = clsx_default("edit-post-layout", "is-mode-" + mode, {
11528 "has-metaboxes": hasActiveMetaboxes
11529 });
11530 function onPluginAreaError(name) {
11531 createErrorNotice(
11532 (0, import_i18n14.sprintf)(
11533 /* translators: %s: plugin name */
11534 (0, import_i18n14.__)(
11535 'The "%s" plugin has encountered an error and cannot be rendered.'
11536 ),
11537 name
11538 )
11539 );
11540 }
11541 const { createSuccessNotice } = (0, import_data25.useDispatch)(import_notices3.store);
11542 const onActionPerformed = (0, import_element28.useCallback)(
11543 (actionId, items) => {
11544 switch (actionId) {
11545 case "move-to-trash":
11546 {
11547 document.location.href = (0, import_url5.addQueryArgs)("edit.php", {
11548 trashed: 1,
11549 post_type: items[0].type,
11550 ids: items[0].id
11551 });
11552 }
11553 break;
11554 case "duplicate-post":
11555 {
11556 const newItem = items[0];
11557 const title = typeof newItem.title === "string" ? newItem.title : newItem.title?.rendered;
11558 createSuccessNotice(
11559 (0, import_i18n14.sprintf)(
11560 // translators: %s: Title of the created post or template, e.g: "Hello world".
11561 (0, import_i18n14.__)('"%s" successfully created.'),
11562 (0, import_html_entities.decodeEntities)(title) || (0, import_i18n14.__)("(no title)")
11563 ),
11564 {
11565 type: "snackbar",
11566 id: "duplicate-post-action",
11567 actions: [
11568 {
11569 label: (0, import_i18n14.__)("Edit"),
11570 onClick: () => {
11571 const postId = newItem.id;
11572 document.location.href = (0, import_url5.addQueryArgs)("post.php", {
11573 post: postId,
11574 action: "edit"
11575 });
11576 }
11577 }
11578 ]
11579 }
11580 );
11581 }
11582 break;
11583 }
11584 },
11585 [createSuccessNotice]
11586 );
11587 const initialPost = (0, import_element28.useMemo)(() => {
11588 return {
11589 type: initialPostType,
11590 id: initialPostId
11591 };
11592 }, [initialPostType, initialPostId]);
11593 const backButton = (0, import_compose3.useViewportMatch)("medium") && isFullscreenActive ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(back_button_default, { initialPost }) : null;
11594 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_components9.SlotFillProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(tooltip_exports.Provider, { children: /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(import_editor18.ErrorBoundary, { canCopyContent: true, children: [
11595 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(WelcomeGuide, { postType: currentPostType }),
11596 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { ...navigateRegionsProps, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
11597 Editor,
11598 {
11599 settings: editorSettings,
11600 initialEdits,
11601 postType: currentPostType,
11602 postId: currentPostId,
11603 templateId,
11604 className,
11605 forceIsDirty: hasActiveMetaboxes,
11606 disableIframe: !shouldIframe,
11607 autoFocus: !isWelcomeGuideVisible,
11608 onActionPerformed,
11609 extraSidebarPanels: showMetaBoxes && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(MetaBoxes, { location: "side" }),
11610 extraContent: !isDistractionFree && showMetaBoxes && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
11611 MetaBoxesMain,
11612 {
11613 isLegacy: !shouldIframe
11614 }
11615 ),
11616 children: [
11617 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_editor18.PostLockedModal, {}),
11618 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(EditorInitialization, {}),
11619 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(FullscreenMode, { isActive: isFullscreenActive }),
11620 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(BrowserURL, {}),
11621 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_editor18.UnsavedChangesWarning, {}),
11622 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_editor18.AutosaveMonitor, {}),
11623 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_editor18.LocalAutosaveMonitor, {}),
11624 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(keyboard_shortcuts_default, {}),
11625 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_editor18.EditorKeyboardShortcutsRegister, {}),
11626 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(BlockKeyboardShortcuts, {}),
11627 currentPostType === "wp_block" && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(InitPatternModal, {}),
11628 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_plugins.PluginArea, { onError: onPluginAreaError }),
11629 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(more_menu_default, {}),
11630 backButton,
11631 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_notices3.SnackbarNotices, { className: "edit-post-layout__snackbar" }),
11632 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(UploadProgressSnackbar, {})
11633 ]
11634 }
11635 ) })
11636 ] }) }) });
11637 }
11638 var layout_default = Layout;
11639
11640 // packages/edit-post/build-module/deprecated.mjs
11641 var import_editor19 = __toESM(require_editor(), 1);
11642 var import_url6 = __toESM(require_url(), 1);
11643 var import_deprecated3 = __toESM(require_deprecated(), 1);
11644 var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1);
11645 var { PluginPostExcerpt } = unlock2(import_editor19.privateApis);
11646 var isSiteEditor = (0, import_url6.getPath)(window.location.href)?.includes(
11647 "site-editor.php"
11648 );
11649 var deprecateSlot = (name) => {
11650 (0, import_deprecated3.default)(`wp.editPost.${name}`, {
11651 since: "6.6",
11652 alternative: `wp.editor.${name}`
11653 });
11654 };
11655 function PluginBlockSettingsMenuItem(props) {
11656 if (isSiteEditor) {
11657 return null;
11658 }
11659 deprecateSlot("PluginBlockSettingsMenuItem");
11660 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_editor19.PluginBlockSettingsMenuItem, { ...props });
11661 }
11662 function PluginDocumentSettingPanel(props) {
11663 if (isSiteEditor) {
11664 return null;
11665 }
11666 deprecateSlot("PluginDocumentSettingPanel");
11667 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_editor19.PluginDocumentSettingPanel, { ...props });
11668 }
11669 function PluginMoreMenuItem(props) {
11670 if (isSiteEditor) {
11671 return null;
11672 }
11673 deprecateSlot("PluginMoreMenuItem");
11674 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_editor19.PluginMoreMenuItem, { ...props });
11675 }
11676 function PluginPrePublishPanel(props) {
11677 if (isSiteEditor) {
11678 return null;
11679 }
11680 deprecateSlot("PluginPrePublishPanel");
11681 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_editor19.PluginPrePublishPanel, { ...props });
11682 }
11683 function PluginPostPublishPanel(props) {
11684 if (isSiteEditor) {
11685 return null;
11686 }
11687 deprecateSlot("PluginPostPublishPanel");
11688 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_editor19.PluginPostPublishPanel, { ...props });
11689 }
11690 function PluginPostStatusInfo(props) {
11691 if (isSiteEditor) {
11692 return null;
11693 }
11694 deprecateSlot("PluginPostStatusInfo");
11695 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_editor19.PluginPostStatusInfo, { ...props });
11696 }
11697 function PluginSidebar(props) {
11698 if (isSiteEditor) {
11699 return null;
11700 }
11701 deprecateSlot("PluginSidebar");
11702 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_editor19.PluginSidebar, { ...props });
11703 }
11704 function PluginSidebarMoreMenuItem(props) {
11705 if (isSiteEditor) {
11706 return null;
11707 }
11708 deprecateSlot("PluginSidebarMoreMenuItem");
11709 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_editor19.PluginSidebarMoreMenuItem, { ...props });
11710 }
11711 function __experimentalPluginPostExcerpt() {
11712 if (isSiteEditor) {
11713 return null;
11714 }
11715 (0, import_deprecated3.default)("wp.editPost.__experimentalPluginPostExcerpt", {
11716 since: "6.6",
11717 hint: "Core and custom panels can be access programmatically using their panel name.",
11718 link: "https://developer.wordpress.org/block-editor/reference-guides/slotfills/plugin-document-setting-panel/#accessing-a-panel-programmatically"
11719 });
11720 return PluginPostExcerpt;
11721 }
11722
11723 // packages/edit-post/build-module/index.mjs
11724 var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1);
11725 var {
11726 BackButton: __experimentalMainDashboardButton,
11727 registerCoreBlockBindingsSources
11728 } = unlock2(import_editor20.privateApis);
11729 var { enablePreloadMultiUse, clearPreloadedData } = unlock2(
11730 import_api_fetch2.default.privateApis
11731 );
11732 function initializeEditor(id, postType, postId, settings, initialEdits) {
11733 const isMediumOrBigger = window.matchMedia("(min-width: 782px)").matches;
11734 const target = document.getElementById(id);
11735 const root = (0, import_element29.createRoot)(target);
11736 (0, import_data26.dispatch)(import_preferences11.store).setDefaults("core/edit-post", {
11737 fullscreenMode: true,
11738 themeStyles: true,
11739 welcomeGuide: true,
11740 welcomeGuideTemplate: true
11741 });
11742 (0, import_data26.dispatch)(import_preferences11.store).setDefaults("core", {
11743 allowRightClickOverrides: true,
11744 editorMode: "visual",
11745 editorTool: "edit",
11746 fixedToolbar: false,
11747 hiddenBlockTypes: [],
11748 inactivePanels: [],
11749 openPanels: ["post-status"],
11750 showBlockBreadcrumbs: true,
11751 showIconLabels: false,
11752 showListViewByDefault: false,
11753 enableChoosePatternModal: true,
11754 isPublishSidebarEnabled: true,
11755 showCollaborationCursor: false,
11756 showCollaborationNotifications: true
11757 });
11758 if (window.__clientSideMediaProcessing) {
11759 (0, import_data26.dispatch)(import_preferences11.store).setDefaults("core/media", {
11760 requireApproval: true,
11761 optimizeOnUpload: true
11762 });
11763 }
11764 (0, import_data26.dispatch)(import_blocks3.store).reapplyBlockTypeFilters();
11765 if (isMediumOrBigger && (0, import_data26.select)(import_preferences11.store).get("core", "showListViewByDefault") && !(0, import_data26.select)(import_preferences11.store).get("core", "distractionFree")) {
11766 (0, import_data26.dispatch)(import_editor20.store).setIsListViewOpened(true);
11767 }
11768 (0, import_block_library2.registerCoreBlocks)();
11769 registerCoreBlockBindingsSources();
11770 (0, import_widgets.registerLegacyWidgetBlock)({ inserter: false });
11771 (0, import_widgets.registerWidgetGroupBlock)({ inserter: false });
11772 if (true) {
11773 (0, import_block_library2.__experimentalRegisterExperimentalCoreBlocks)({
11774 enableFSEBlocks: settings.__unstableEnableFullSiteEditingBlocks
11775 });
11776 }
11777 const documentMode = document.compatMode === "CSS1Compat" ? "Standards" : "Quirks";
11778 if (documentMode !== "Standards") {
11779 console.warn(
11780 "Your browser is using Quirks Mode. \nThis can cause rendering issues such as blocks overlaying meta boxes in the editor. Quirks Mode can be triggered by PHP errors or HTML code appearing before the opening <!DOCTYPE html>. Try checking the raw page source or your site's PHP error log and resolving errors there, removing any HTML before the doctype, or disabling plugins."
11781 );
11782 }
11783 const isIphone = window.navigator.userAgent.indexOf("iPhone") !== -1;
11784 if (isIphone) {
11785 window.addEventListener("scroll", (event) => {
11786 const editorScrollContainer = document.getElementsByClassName(
11787 "interface-interface-skeleton__body"
11788 )[0];
11789 if (event.target === document) {
11790 if (window.scrollY > 100) {
11791 editorScrollContainer.scrollTop = editorScrollContainer.scrollTop + window.scrollY;
11792 }
11793 if (document.getElementsByClassName("is-mode-visual")[0]) {
11794 window.scrollTo(0, 0);
11795 }
11796 }
11797 });
11798 }
11799 window.addEventListener("dragover", (e) => e.preventDefault(), false);
11800 window.addEventListener("drop", (e) => e.preventDefault(), false);
11801 enablePreloadMultiUse();
11802 const preloadedResolutions = preloadResolutions(postType, postId);
11803 preloadedResolutions.finally(() => {
11804 clearPreloadedData();
11805 if (postType && postId) {
11806 const post = (0, import_data26.select)(import_core_data9.store).getEntityRecord(
11807 "postType",
11808 postType,
11809 postId
11810 );
11811 if (post) {
11812 (0, import_data26.dispatch)(import_editor20.store).setupEditor(
11813 post,
11814 initialEdits,
11815 settings.template
11816 );
11817 }
11818 }
11819 root.render(
11820 /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_element29.StrictMode, { children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
11821 layout_default,
11822 {
11823 settings,
11824 postId,
11825 postType,
11826 initialEdits
11827 }
11828 ) })
11829 );
11830 });
11831 return root;
11832 }
11833 async function preloadResolutions(postType, postId) {
11834 const core = (0, import_data26.resolveSelect)(import_core_data9.store);
11835 const coreSelect = (0, import_data26.select)(import_core_data9.store);
11836 try {
11837 await Promise.all([
11838 core.getCurrentUser(),
11839 core.getEntitiesConfig("postType"),
11840 core.getEntitiesConfig("taxonomy"),
11841 core.getEntitiesConfig("root"),
11842 core.getEntityRecords("root", "taxonomy"),
11843 core.getCurrentTheme(),
11844 // Forward-resolver alias of `getCurrentTheme` with its own
11845 // resolution metadata, so it needs a separate kick.
11846 core.getThemeSupports(),
11847 core.getBlockPatternCategories(),
11848 core.__experimentalGetCurrentGlobalStylesId(),
11849 core.__experimentalGetCurrentThemeBaseGlobalStyles(),
11850 core.__experimentalGetCurrentThemeGlobalStylesVariations(),
11851 core.getEntityRecord("root", "__unstableBase"),
11852 core.getEntityRecord("root", "site"),
11853 core.canUser("read", { kind: "root", name: "site" }),
11854 core.canUser("create", { kind: "postType", name: "attachment" }),
11855 core.canUser("create", { kind: "postType", name: "page" }),
11856 core.canUser("create", { kind: "postType", name: "wp_block" }),
11857 core.canUser("create", {
11858 kind: "postType",
11859 name: "wp_template"
11860 }),
11861 // Per-post resolvers. `getPostType` and `getEditedEntityRecord`
11862 // are shorthand/forward-resolver aliases with their own
11863 // resolution metadata, so they need separate kicks.
11864 ...postType && postId ? [
11865 core.getPostType(postType),
11866 core.getEntityRecord("postType", postType, postId),
11867 core.getEditedEntityRecord(
11868 "postType",
11869 postType,
11870 postId
11871 ),
11872 core.getAutosaves(postType, postId),
11873 core.getDefaultTemplateId({ slug: "front-page" }),
11874 core.canUser("create", {
11875 kind: "postType",
11876 name: postType
11877 })
11878 ] : []
11879 ]);
11880 const tasks = [];
11881 const globalStylesId = coreSelect.__experimentalGetCurrentGlobalStylesId();
11882 if (globalStylesId) {
11883 tasks.push(
11884 core.getEntityRecord("root", "globalStyles", globalStylesId),
11885 core.canUser("read", {
11886 kind: "root",
11887 name: "globalStyles",
11888 id: globalStylesId
11889 })
11890 );
11891 }
11892 if (postType && postId) {
11893 const post = coreSelect.getEntityRecord(
11894 "postType",
11895 postType,
11896 postId
11897 );
11898 if (post) {
11899 let slug = "page" === postType ? "page" : "single-" + postType;
11900 if (post.slug) {
11901 slug += "-" + post.slug;
11902 }
11903 tasks.push(core.getDefaultTemplateId({ slug }));
11904 if (post.author) {
11905 tasks.push(
11906 core.getUser(post.author, {
11907 context: "view",
11908 _fields: "id,name"
11909 })
11910 );
11911 }
11912 }
11913 }
11914 if (tasks.length) {
11915 await Promise.all(tasks);
11916 }
11917 } catch {
11918 }
11919 }
11920 function reinitializeEditor() {
11921 (0, import_deprecated4.default)("wp.editPost.reinitializeEditor", {
11922 since: "6.2",
11923 version: "6.3"
11924 });
11925 }
11926 return __toCommonJS(index_exports);
11927 })();
11928 /*! Bundled license information:
11929
11930 use-sync-external-store/cjs/use-sync-external-store-shim.development.js:
11931 (**
11932 * @license React
11933 * use-sync-external-store-shim.development.js
11934 *
11935 * Copyright (c) Meta Platforms, Inc. and affiliates.
11936 *
11937 * This source code is licensed under the MIT license found in the
11938 * LICENSE file in the root directory of this source tree.
11939 *)
11940
11941 use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js:
11942 (**
11943 * @license React
11944 * use-sync-external-store-shim/with-selector.development.js
11945 *
11946 * Copyright (c) Meta Platforms, Inc. and affiliates.
11947 *
11948 * This source code is licensed under the MIT license found in the
11949 * LICENSE file in the root directory of this source tree.
11950 *)
11951 */
11952 //# sourceMappingURL=index.js.map
11953