PluginProbe
Gutenberg / 24.1.0
Gutenberg v24.1.0
24.1.0 24.0.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 All 404 releases
gutenberg / build / routes / media-editor / content.js

content.js in Gutenberg 24.1.0, at build/routes/media-editor/content.js

38,612 lines 1.4 MB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 var __create = Object.create;
2 var __defProp = Object.defineProperty;
3 var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4 var __getOwnPropNames = Object.getOwnPropertyNames;
5 var __getProtoOf = Object.getPrototypeOf;
6 var __hasOwnProp = Object.prototype.hasOwnProperty;
7 var __commonJS = (cb, mod) => function __require() {
8 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9 };
10 var __export = (target, all) => {
11 for (var name in all)
12 __defProp(target, name, { get: all[name], enumerable: true });
13 };
14 var __copyProps = (to, from, except, desc) => {
15 if (from && typeof from === "object" || typeof from === "function") {
16 for (let key of __getOwnPropNames(from))
17 if (!__hasOwnProp.call(to, key) && key !== except)
18 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19 }
20 return to;
21 };
22 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23 // If the importer is in node compatibility mode or this is not an ESM
24 // file that has been converted to a CommonJS file using a Babel-
25 // compatible transform (i.e. "__esModule" has not been set), then set
26 // "default" to the CommonJS "module.exports" for node compatibility.
27 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28 mod
29 ));
30
31 // package-external:@wordpress/i18n
32 var require_i18n = __commonJS({
33 "package-external:@wordpress/i18n"(exports, module) {
34 module.exports = window.wp.i18n;
35 }
36 });
37
38 // package-external:@wordpress/element
39 var require_element = __commonJS({
40 "package-external:@wordpress/element"(exports, module) {
41 module.exports = window.wp.element;
42 }
43 });
44
45 // vendor-external:react
46 var require_react = __commonJS({
47 "vendor-external:react"(exports, module) {
48 module.exports = window.React;
49 }
50 });
51
52 // vendor-external:react/jsx-runtime
53 var require_jsx_runtime = __commonJS({
54 "vendor-external:react/jsx-runtime"(exports, module) {
55 module.exports = window.ReactJSXRuntime;
56 }
57 });
58
59 // vendor-external:react-dom
60 var require_react_dom = __commonJS({
61 "vendor-external:react-dom"(exports, module) {
62 module.exports = window.ReactDOM;
63 }
64 });
65
66 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js
67 var require_use_sync_external_store_shim_development = __commonJS({
68 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports) {
69 "use strict";
70 (function() {
71 function is(x2, y2) {
72 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
73 }
74 function useSyncExternalStore$2(subscribe2, getSnapshot2) {
75 didWarnOld18Alpha || void 0 === React119.startTransition || (didWarnOld18Alpha = true, console.error(
76 "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."
77 ));
78 var value = getSnapshot2();
79 if (!didWarnUncachedGetSnapshot) {
80 var cachedValue = getSnapshot2();
81 objectIs(value, cachedValue) || (console.error(
82 "The result of getSnapshot should be cached to avoid an infinite loop"
83 ), didWarnUncachedGetSnapshot = true);
84 }
85 cachedValue = useState48({
86 inst: { value, getSnapshot: getSnapshot2 }
87 });
88 var inst = cachedValue[0].inst, forceUpdate = cachedValue[1];
89 useLayoutEffect7(
90 function() {
91 inst.value = value;
92 inst.getSnapshot = getSnapshot2;
93 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
94 },
95 [subscribe2, value, getSnapshot2]
96 );
97 useEffect41(
98 function() {
99 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
100 return subscribe2(function() {
101 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
102 });
103 },
104 [subscribe2]
105 );
106 useDebugValue2(value);
107 return value;
108 }
109 function checkIfSnapshotChanged(inst) {
110 var latestGetSnapshot = inst.getSnapshot;
111 inst = inst.value;
112 try {
113 var nextValue = latestGetSnapshot();
114 return !objectIs(inst, nextValue);
115 } catch (error2) {
116 return true;
117 }
118 }
119 function useSyncExternalStore$1(subscribe2, getSnapshot2) {
120 return getSnapshot2();
121 }
122 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
123 var React119 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is, useState48 = React119.useState, useEffect41 = React119.useEffect, useLayoutEffect7 = React119.useLayoutEffect, useDebugValue2 = React119.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
124 exports.useSyncExternalStore = void 0 !== React119.useSyncExternalStore ? React119.useSyncExternalStore : shim;
125 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
126 })();
127 }
128 });
129
130 // node_modules/use-sync-external-store/shim/index.js
131 var require_shim = __commonJS({
132 "node_modules/use-sync-external-store/shim/index.js"(exports, module) {
133 "use strict";
134 if (false) {
135 module.exports = null;
136 } else {
137 module.exports = require_use_sync_external_store_shim_development();
138 }
139 }
140 });
141
142 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js
143 var require_with_selector_development = __commonJS({
144 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js"(exports) {
145 "use strict";
146 (function() {
147 function is(x2, y2) {
148 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
149 }
150 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
151 var React119 = require_react(), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore4 = shim.useSyncExternalStore, useRef71 = React119.useRef, useEffect41 = React119.useEffect, useMemo54 = React119.useMemo, useDebugValue2 = React119.useDebugValue;
152 exports.useSyncExternalStoreWithSelector = function(subscribe2, getSnapshot2, getServerSnapshot2, selector, isEqual) {
153 var instRef = useRef71(null);
154 if (null === instRef.current) {
155 var inst = { hasValue: false, value: null };
156 instRef.current = inst;
157 } else inst = instRef.current;
158 instRef = useMemo54(
159 function() {
160 function memoizedSelector(nextSnapshot) {
161 if (!hasMemo) {
162 hasMemo = true;
163 memoizedSnapshot = nextSnapshot;
164 nextSnapshot = selector(nextSnapshot);
165 if (void 0 !== isEqual && inst.hasValue) {
166 var currentSelection = inst.value;
167 if (isEqual(currentSelection, nextSnapshot))
168 return memoizedSelection = currentSelection;
169 }
170 return memoizedSelection = nextSnapshot;
171 }
172 currentSelection = memoizedSelection;
173 if (objectIs(memoizedSnapshot, nextSnapshot))
174 return currentSelection;
175 var nextSelection = selector(nextSnapshot);
176 if (void 0 !== isEqual && isEqual(currentSelection, nextSelection))
177 return memoizedSnapshot = nextSnapshot, currentSelection;
178 memoizedSnapshot = nextSnapshot;
179 return memoizedSelection = nextSelection;
180 }
181 var hasMemo = false, memoizedSnapshot, memoizedSelection, maybeGetServerSnapshot = void 0 === getServerSnapshot2 ? null : getServerSnapshot2;
182 return [
183 function() {
184 return memoizedSelector(getSnapshot2());
185 },
186 null === maybeGetServerSnapshot ? void 0 : function() {
187 return memoizedSelector(maybeGetServerSnapshot());
188 }
189 ];
190 },
191 [getSnapshot2, getServerSnapshot2, selector, isEqual]
192 );
193 var value = useSyncExternalStore4(subscribe2, instRef[0], instRef[1]);
194 useEffect41(
195 function() {
196 inst.hasValue = true;
197 inst.value = value;
198 },
199 [value]
200 );
201 useDebugValue2(value);
202 return value;
203 };
204 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
205 })();
206 }
207 });
208
209 // node_modules/use-sync-external-store/shim/with-selector.js
210 var require_with_selector = __commonJS({
211 "node_modules/use-sync-external-store/shim/with-selector.js"(exports, module) {
212 "use strict";
213 if (false) {
214 module.exports = null;
215 } else {
216 module.exports = require_with_selector_development();
217 }
218 }
219 });
220
221 // package-external:@wordpress/compose
222 var require_compose = __commonJS({
223 "package-external:@wordpress/compose"(exports, module) {
224 module.exports = window.wp.compose;
225 }
226 });
227
228 // package-external:@wordpress/theme
229 var require_theme = __commonJS({
230 "package-external:@wordpress/theme"(exports, module) {
231 module.exports = window.wp.theme;
232 }
233 });
234
235 // package-external:@wordpress/private-apis
236 var require_private_apis = __commonJS({
237 "package-external:@wordpress/private-apis"(exports, module) {
238 module.exports = window.wp.privateApis;
239 }
240 });
241
242 // package-external:@wordpress/primitives
243 var require_primitives = __commonJS({
244 "package-external:@wordpress/primitives"(exports, module) {
245 module.exports = window.wp.primitives;
246 }
247 });
248
249 // package-external:@wordpress/components
250 var require_components = __commonJS({
251 "package-external:@wordpress/components"(exports, module) {
252 module.exports = window.wp.components;
253 }
254 });
255
256 // package-external:@wordpress/core-data
257 var require_core_data = __commonJS({
258 "package-external:@wordpress/core-data"(exports, module) {
259 module.exports = window.wp.coreData;
260 }
261 });
262
263 // package-external:@wordpress/data
264 var require_data = __commonJS({
265 "package-external:@wordpress/data"(exports, module) {
266 module.exports = window.wp.data;
267 }
268 });
269
270 // package-external:@wordpress/editor
271 var require_editor = __commonJS({
272 "package-external:@wordpress/editor"(exports, module) {
273 module.exports = window.wp.editor;
274 }
275 });
276
277 // package-external:@wordpress/html-entities
278 var require_html_entities = __commonJS({
279 "package-external:@wordpress/html-entities"(exports, module) {
280 module.exports = window.wp.htmlEntities;
281 }
282 });
283
284 // package-external:@wordpress/keycodes
285 var require_keycodes = __commonJS({
286 "package-external:@wordpress/keycodes"(exports, module) {
287 module.exports = window.wp.keycodes;
288 }
289 });
290
291 // node_modules/fast-deep-equal/es6/index.js
292 var require_es6 = __commonJS({
293 "node_modules/fast-deep-equal/es6/index.js"(exports, module) {
294 "use strict";
295 module.exports = function equal(a, b) {
296 if (a === b) return true;
297 if (a && b && typeof a == "object" && typeof b == "object") {
298 if (a.constructor !== b.constructor) return false;
299 var length2, i, keys;
300 if (Array.isArray(a)) {
301 length2 = a.length;
302 if (length2 != b.length) return false;
303 for (i = length2; i-- !== 0; )
304 if (!equal(a[i], b[i])) return false;
305 return true;
306 }
307 if (a instanceof Map && b instanceof Map) {
308 if (a.size !== b.size) return false;
309 for (i of a.entries())
310 if (!b.has(i[0])) return false;
311 for (i of a.entries())
312 if (!equal(i[1], b.get(i[0]))) return false;
313 return true;
314 }
315 if (a instanceof Set && b instanceof Set) {
316 if (a.size !== b.size) return false;
317 for (i of a.entries())
318 if (!b.has(i[0])) return false;
319 return true;
320 }
321 if (ArrayBuffer.isView(a) && ArrayBuffer.isView(b)) {
322 length2 = a.length;
323 if (length2 != b.length) return false;
324 for (i = length2; i-- !== 0; )
325 if (a[i] !== b[i]) return false;
326 return true;
327 }
328 if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
329 if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
330 if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
331 keys = Object.keys(a);
332 length2 = keys.length;
333 if (length2 !== Object.keys(b).length) return false;
334 for (i = length2; i-- !== 0; )
335 if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
336 for (i = length2; i-- !== 0; ) {
337 var key = keys[i];
338 if (!equal(a[key], b[key])) return false;
339 }
340 return true;
341 }
342 return a !== a && b !== b;
343 };
344 }
345 });
346
347 // package-external:@wordpress/date
348 var require_date = __commonJS({
349 "package-external:@wordpress/date"(exports, module) {
350 module.exports = window.wp.date;
351 }
352 });
353
354 // node_modules/deepmerge/dist/cjs.js
355 var require_cjs = __commonJS({
356 "node_modules/deepmerge/dist/cjs.js"(exports, module) {
357 "use strict";
358 var isMergeableObject = function isMergeableObject2(value) {
359 return isNonNullObject(value) && !isSpecial(value);
360 };
361 function isNonNullObject(value) {
362 return !!value && typeof value === "object";
363 }
364 function isSpecial(value) {
365 var stringValue = Object.prototype.toString.call(value);
366 return stringValue === "[object RegExp]" || stringValue === "[object Date]" || isReactElement(value);
367 }
368 var canUseSymbol = typeof Symbol === "function" && Symbol.for;
369 var REACT_ELEMENT_TYPE = canUseSymbol ? /* @__PURE__ */ Symbol.for("react.element") : 60103;
370 function isReactElement(value) {
371 return value.$$typeof === REACT_ELEMENT_TYPE;
372 }
373 function emptyTarget(val) {
374 return Array.isArray(val) ? [] : {};
375 }
376 function cloneUnlessOtherwiseSpecified(value, options) {
377 return options.clone !== false && options.isMergeableObject(value) ? deepmerge(emptyTarget(value), value, options) : value;
378 }
379 function defaultArrayMerge(target, source, options) {
380 return target.concat(source).map(function(element) {
381 return cloneUnlessOtherwiseSpecified(element, options);
382 });
383 }
384 function getMergeFunction(key, options) {
385 if (!options.customMerge) {
386 return deepmerge;
387 }
388 var customMerge = options.customMerge(key);
389 return typeof customMerge === "function" ? customMerge : deepmerge;
390 }
391 function getEnumerableOwnPropertySymbols(target) {
392 return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(target).filter(function(symbol) {
393 return Object.propertyIsEnumerable.call(target, symbol);
394 }) : [];
395 }
396 function getKeys(target) {
397 return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target));
398 }
399 function propertyIsOnObject(object, property) {
400 try {
401 return property in object;
402 } catch (_) {
403 return false;
404 }
405 }
406 function propertyIsUnsafe(target, key) {
407 return propertyIsOnObject(target, key) && !(Object.hasOwnProperty.call(target, key) && Object.propertyIsEnumerable.call(target, key));
408 }
409 function mergeObject(target, source, options) {
410 var destination = {};
411 if (options.isMergeableObject(target)) {
412 getKeys(target).forEach(function(key) {
413 destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
414 });
415 }
416 getKeys(source).forEach(function(key) {
417 if (propertyIsUnsafe(target, key)) {
418 return;
419 }
420 if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
421 destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
422 } else {
423 destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
424 }
425 });
426 return destination;
427 }
428 function deepmerge(target, source, options) {
429 options = options || {};
430 options.arrayMerge = options.arrayMerge || defaultArrayMerge;
431 options.isMergeableObject = options.isMergeableObject || isMergeableObject;
432 options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
433 var sourceIsArray = Array.isArray(source);
434 var targetIsArray = Array.isArray(target);
435 var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
436 if (!sourceAndTargetTypesMatch) {
437 return cloneUnlessOtherwiseSpecified(source, options);
438 } else if (sourceIsArray) {
439 return options.arrayMerge(target, source, options);
440 } else {
441 return mergeObject(target, source, options);
442 }
443 }
444 deepmerge.all = function deepmergeAll(array, options) {
445 if (!Array.isArray(array)) {
446 throw new Error("first argument should be an array");
447 }
448 return array.reduce(function(prev, next) {
449 return deepmerge(prev, next, options);
450 }, {});
451 };
452 var deepmerge_1 = deepmerge;
453 module.exports = deepmerge_1;
454 }
455 });
456
457 // package-external:@wordpress/keyboard-shortcuts
458 var require_keyboard_shortcuts = __commonJS({
459 "package-external:@wordpress/keyboard-shortcuts"(exports, module) {
460 module.exports = window.wp.keyboardShortcuts;
461 }
462 });
463
464 // package-external:@wordpress/notices
465 var require_notices = __commonJS({
466 "package-external:@wordpress/notices"(exports, module) {
467 module.exports = window.wp.notices;
468 }
469 });
470
471 // package-external:@wordpress/api-fetch
472 var require_api_fetch = __commonJS({
473 "package-external:@wordpress/api-fetch"(exports, module) {
474 module.exports = window.wp.apiFetch;
475 }
476 });
477
478 // packages/admin-ui/build-module/breadcrumbs/index.mjs
479 var import_i18n9 = __toESM(require_i18n(), 1);
480 import { Link as RouterLink } from "@wordpress/route";
481
482 // node_modules/clsx/dist/clsx.mjs
483 function r(e) {
484 var t, f, n = "";
485 if ("string" == typeof e || "number" == typeof e) n += e;
486 else if ("object" == typeof e) if (Array.isArray(e)) {
487 var o = e.length;
488 for (t = 0; t < o; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
489 } else for (f in e) e[f] && (n && (n += " "), n += f);
490 return n;
491 }
492 function clsx() {
493 for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
494 return n;
495 }
496 var clsx_default = clsx;
497
498 // packages/ui/build-module/badge/badge.mjs
499 var import_element11 = __toESM(require_element(), 1);
500
501 // node_modules/@base-ui/utils/useControlled.mjs
502 var React = __toESM(require_react(), 1);
503
504 // node_modules/@base-ui/utils/createLogOnce.mjs
505 var loggedMessages;
506 if (true) {
507 loggedMessages = /* @__PURE__ */ new Set();
508 }
509 function createLogOnce(severity, prefix) {
510 return function logOnce(...messages) {
511 if (true) {
512 const message2 = messages.join(" ");
513 const output = prefix ? `${prefix}: ${message2}` : message2;
514 const key = `${severity}:${output}`;
515 if (!loggedMessages.has(key)) {
516 loggedMessages.add(key);
517 if (severity === "warn") {
518 console.warn(output);
519 } else {
520 console.error(output);
521 }
522 }
523 }
524 };
525 }
526
527 // node_modules/@base-ui/utils/error.mjs
528 var error = createLogOnce("error", "Base UI");
529
530 // node_modules/@base-ui/utils/useControlled.mjs
531 function useControlled({
532 controlled,
533 default: defaultProp,
534 name,
535 state = "value"
536 }) {
537 const {
538 current: isControlled
539 } = React.useRef(controlled !== void 0);
540 const [valueState, setValue] = React.useState(defaultProp);
541 const value = isControlled && controlled !== void 0 ? controlled : valueState;
542 if (true) {
543 React.useEffect(() => {
544 if (isControlled !== (controlled !== void 0)) {
545 error([`A component is changing the ${isControlled ? "" : "un"}controlled ${state} state of ${name} to be ${isControlled ? "un" : ""}controlled.`, "Elements should not switch from uncontrolled to controlled (or vice versa).", `Decide between using a controlled or uncontrolled ${name} element for the lifetime of the component.`, "The nature of the state is determined during the first render. It's considered controlled if the value is not `undefined`.", "More info: https://fb.me/react-controlled-components"].join("\n"));
546 }
547 }, [state, name, controlled]);
548 const {
549 current: defaultValue
550 } = React.useRef(defaultProp);
551 React.useEffect(() => {
552 if (!isControlled && serializeToDevModeString(defaultValue) !== serializeToDevModeString(defaultProp)) {
553 error([`A component is changing the default ${state} state of an uncontrolled ${name} after being initialized. To suppress this warning opt to use a controlled ${name}.`].join("\n"));
554 }
555 }, [defaultProp]);
556 }
557 const setValueIfUncontrolled = React.useCallback((newValue) => {
558 if (!isControlled) {
559 setValue(newValue);
560 }
561 }, []);
562 return [value, setValueIfUncontrolled];
563 }
564 function serializeToDevModeString(input) {
565 let nextId = 0;
566 const seen = /* @__PURE__ */ new WeakMap();
567 try {
568 const result = JSON.stringify(input, function replacer(key, value) {
569 if (key === "_owner" && this != null && typeof this === "object" && "$$typeof" in this) {
570 return void 0;
571 }
572 if (typeof value === "bigint") {
573 return `__bigint__:${value}`;
574 }
575 if (value !== null && typeof value === "object") {
576 const id = seen.get(value);
577 if (id !== void 0) {
578 return `__object__:${id}`;
579 }
580 seen.set(value, nextId);
581 nextId += 1;
582 }
583 return value;
584 });
585 return result ?? `__top__:${typeof input}`;
586 } catch {
587 return "__unserializable__";
588 }
589 }
590
591 // node_modules/@base-ui/utils/safeReact.mjs
592 var React2 = __toESM(require_react(), 1);
593 var SafeReact = {
594 ...React2
595 };
596
597 // node_modules/@base-ui/utils/useRefWithInit.mjs
598 var React3 = __toESM(require_react(), 1);
599 var UNINITIALIZED = {};
600 function useRefWithInit(init, initArg) {
601 const ref = React3.useRef(UNINITIALIZED);
602 if (ref.current === UNINITIALIZED) {
603 ref.current = init(initArg);
604 }
605 return ref;
606 }
607
608 // node_modules/@base-ui/utils/useStableCallback.mjs
609 var useInsertionEffect = SafeReact.useInsertionEffect;
610 var useSafeInsertionEffect = (
611 // React 17 doesn't have useInsertionEffect.
612 useInsertionEffect && // Preact replaces useInsertionEffect with useLayoutEffect and fires too late.
613 useInsertionEffect !== SafeReact.useLayoutEffect ? useInsertionEffect : (fn) => fn()
614 );
615 function useStableCallback(callback) {
616 const stable = useRefWithInit(createStableCallback).current;
617 stable.next = callback;
618 useSafeInsertionEffect(stable.effect);
619 return stable.trampoline;
620 }
621 function createStableCallback() {
622 const stable = {
623 next: void 0,
624 callback: assertNotCalled,
625 trampoline: (...args) => stable.callback?.(...args),
626 effect: () => {
627 stable.callback = stable.next;
628 }
629 };
630 return stable;
631 }
632 function assertNotCalled() {
633 if (true) {
634 throw (
635 /* minify-error-disabled */
636 new Error("Base UI: Cannot call an event handler while rendering.")
637 );
638 }
639 }
640
641 // node_modules/@base-ui/utils/warn.mjs
642 var warn = createLogOnce("warn", "Base UI");
643
644 // node_modules/@base-ui/utils/empty.mjs
645 function NOOP() {
646 }
647 var EMPTY_ARRAY = Object.freeze([]);
648 var EMPTY_OBJECT = Object.freeze({});
649
650 // node_modules/@base-ui/react/internals/composite/list/CompositeList.mjs
651 var React6 = __toESM(require_react(), 1);
652
653 // node_modules/@base-ui/utils/useIsoLayoutEffect.mjs
654 var React4 = __toESM(require_react(), 1);
655 var noop = () => {
656 };
657 var useIsoLayoutEffect = typeof document !== "undefined" ? React4.useLayoutEffect : noop;
658
659 // node_modules/@base-ui/react/internals/composite/list/CompositeListContext.mjs
660 var React5 = __toESM(require_react(), 1);
661 var CompositeListContext = /* @__PURE__ */ React5.createContext({
662 register: () => {
663 },
664 unregister: () => {
665 },
666 subscribeMapChange: () => () => {
667 },
668 nextIndexRef: {
669 current: 0
670 }
671 });
672 if (true) CompositeListContext.displayName = "CompositeListContext";
673 function useCompositeListContext() {
674 return React5.useContext(CompositeListContext);
675 }
676
677 // node_modules/@base-ui/react/internals/composite/list/CompositeList.mjs
678 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
679 function CompositeList(props) {
680 const {
681 children,
682 elementsRef,
683 labelsRef,
684 onMapChange: onMapChangeProp
685 } = props;
686 const onMapChange = useStableCallback(onMapChangeProp);
687 const [, setMapTick] = React6.useState(false);
688 const listeners = useRefWithInit(createListeners).current;
689 const map = useRefWithInit(createMap).current;
690 const nextIndexRef = React6.useRef(0);
691 const isDirtyRef = React6.useRef(true);
692 const itemsRef = React6.useRef(null);
693 const mutationObserverRef = React6.useRef(null);
694 const scheduleMapUpdate = useStableCallback(() => {
695 if (isDirtyRef.current) {
696 return;
697 }
698 isDirtyRef.current = true;
699 setMapTick((tick) => !tick);
700 });
701 const register3 = useStableCallback((node, registration) => {
702 map.set(node, registration);
703 scheduleMapUpdate();
704 });
705 const unregister = useStableCallback((node) => {
706 map.delete(node);
707 scheduleMapUpdate();
708 });
709 const syncRefs = useStableCallback((items) => {
710 const nextMap = /* @__PURE__ */ new Map();
711 elementsRef.current.length = 0;
712 if (labelsRef) {
713 labelsRef.current.length = 0;
714 }
715 items.forEach((item) => {
716 nextMap.set(item.element, {
717 ...item.registration.metadata ?? {},
718 index: item.index
719 });
720 elementsRef.current[item.index] = item.element;
721 if (labelsRef) {
722 labelsRef.current[item.index] = item.registration.label !== void 0 ? item.registration.label : item.registration.textRef?.current?.textContent ?? item.element.textContent;
723 }
724 });
725 nextIndexRef.current = elementsRef.current.length;
726 return nextMap;
727 });
728 function observe(sortedNodes) {
729 mutationObserverRef.current?.disconnect();
730 mutationObserverRef.current = null;
731 if (typeof MutationObserver !== "function" || sortedNodes.length < 2) {
732 return;
733 }
734 const mutationObserver = new MutationObserver((entries) => {
735 if (!hasMovedNode(entries)) {
736 return;
737 }
738 let previousConnectedNode = null;
739 for (const node of sortedNodes) {
740 if (!node.isConnected) {
741 continue;
742 }
743 if (previousConnectedNode && sortByDocumentPosition(previousConnectedNode, node) > 0) {
744 mutationObserver.disconnect();
745 scheduleMapUpdate();
746 return;
747 }
748 previousConnectedNode = node;
749 }
750 });
751 mutationObserverRef.current = mutationObserver;
752 const roots = /* @__PURE__ */ new Set();
753 for (let i = 1; i < sortedNodes.length; i += 1) {
754 const root = getCommonAncestor(sortedNodes[i - 1], sortedNodes[i]);
755 if (root) {
756 roots.add(root);
757 }
758 }
759 roots.forEach((root) => mutationObserver.observe(root, {
760 childList: true
761 }));
762 }
763 const flush = useStableCallback(() => {
764 const [items, automaticNodes] = getCompositeListSnapshot(map);
765 const nextMap = syncRefs(items);
766 const previousItems = itemsRef.current;
767 const changed = !previousItems || previousItems.length !== items.length || items.some((item, index3) => {
768 const previousItem = previousItems[index3];
769 return item.index !== previousItem.index || item.element !== previousItem.element || item.registration.index !== previousItem.registration.index || item.registration.metadata !== previousItem.registration.metadata;
770 });
771 observe(automaticNodes);
772 itemsRef.current = items;
773 isDirtyRef.current = false;
774 if (!changed) {
775 return;
776 }
777 listeners.forEach((listener) => listener(nextMap));
778 onMapChange(nextMap);
779 });
780 useIsoLayoutEffect(() => {
781 if (!isDirtyRef.current && itemsRef.current) {
782 syncRefs(itemsRef.current);
783 }
784 return () => {
785 elementsRef.current = [];
786 if (labelsRef) {
787 labelsRef.current = [];
788 }
789 };
790 }, [elementsRef, labelsRef, syncRefs]);
791 useIsoLayoutEffect(() => {
792 if (isDirtyRef.current) {
793 flush();
794 }
795 });
796 useIsoLayoutEffect(() => {
797 return () => {
798 mutationObserverRef.current?.disconnect();
799 isDirtyRef.current = true;
800 };
801 }, []);
802 const subscribeMapChange = useStableCallback((fn) => {
803 listeners.add(fn);
804 return () => {
805 listeners.delete(fn);
806 };
807 });
808 const contextValue = React6.useMemo(() => ({
809 register: register3,
810 unregister,
811 subscribeMapChange,
812 nextIndexRef
813 }), [register3, unregister, subscribeMapChange, nextIndexRef]);
814 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CompositeListContext.Provider, {
815 value: contextValue,
816 children
817 });
818 }
819 function createMap() {
820 return /* @__PURE__ */ new Map();
821 }
822 function createListeners() {
823 return /* @__PURE__ */ new Set();
824 }
825 function getCompositeListSnapshot(map) {
826 const reservedIndices = /* @__PURE__ */ new Set();
827 const items = [];
828 const automaticItems = [];
829 map.forEach((registration, node) => {
830 if (!node.isConnected) {
831 return;
832 }
833 const index3 = registration.index;
834 const item = {
835 index: index3 ?? -1,
836 element: node,
837 registration
838 };
839 if (index3 === null) {
840 automaticItems.push(item);
841 } else if (index3 >= 0) {
842 reservedIndices.add(index3);
843 items.push(item);
844 }
845 });
846 let nextAutomaticIndex = 0;
847 automaticItems.sort((a, b) => sortByDocumentPosition(a.element, b.element));
848 automaticItems.forEach((item) => {
849 while (reservedIndices.has(nextAutomaticIndex)) {
850 nextAutomaticIndex += 1;
851 }
852 item.index = nextAutomaticIndex;
853 items.push(item);
854 nextAutomaticIndex += 1;
855 });
856 if (reservedIndices.size > 0) {
857 items.sort((a, b) => a.index - b.index);
858 }
859 return [items, automaticItems.map((item) => item.element)];
860 }
861 function getCommonAncestor(firstNode, lastNode) {
862 let ancestor = firstNode.parentElement;
863 while (ancestor && !ancestor.contains(lastNode)) {
864 ancestor = ancestor.parentElement;
865 }
866 return ancestor;
867 }
868 function hasMovedNode(entries) {
869 for (const entry of entries) {
870 for (let i = 0; i < entry.removedNodes.length; i += 1) {
871 if (entry.removedNodes[i].isConnected) {
872 return true;
873 }
874 }
875 }
876 return false;
877 }
878 function sortByDocumentPosition(a, b) {
879 return a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1;
880 }
881
882 // node_modules/@base-ui/react/internals/useRenderElement.mjs
883 var React9 = __toESM(require_react(), 1);
884
885 // node_modules/@base-ui/utils/useMergedRefs.mjs
886 function useMergedRefs(a, b, c2, d) {
887 const forkRef = useRefWithInit(createForkRef).current;
888 if (didChange(forkRef, a, b, c2, d)) {
889 update(forkRef, [a, b, c2, d]);
890 }
891 return forkRef.callback;
892 }
893 function useMergedRefsN(refs) {
894 const forkRef = useRefWithInit(createForkRef).current;
895 if (didChangeN(forkRef, refs)) {
896 update(forkRef, refs);
897 }
898 return forkRef.callback;
899 }
900 function createForkRef() {
901 return {
902 callback: null,
903 cleanup: null,
904 refs: []
905 };
906 }
907 function didChange(forkRef, a, b, c2, d) {
908 return forkRef.refs[0] !== a || forkRef.refs[1] !== b || forkRef.refs[2] !== c2 || forkRef.refs[3] !== d;
909 }
910 function didChangeN(forkRef, newRefs) {
911 return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index3) => ref !== newRefs[index3]);
912 }
913 function update(forkRef, refs) {
914 forkRef.refs = refs;
915 if (refs.every((ref) => ref == null)) {
916 forkRef.callback = null;
917 return;
918 }
919 forkRef.callback = (instance) => {
920 if (forkRef.cleanup) {
921 forkRef.cleanup();
922 forkRef.cleanup = null;
923 }
924 if (instance != null) {
925 const cleanupCallbacks = Array(refs.length).fill(null);
926 for (let i = 0; i < refs.length; i += 1) {
927 const ref = refs[i];
928 if (ref == null) {
929 continue;
930 }
931 switch (typeof ref) {
932 case "function": {
933 const refCleanup = ref(instance);
934 if (typeof refCleanup === "function") {
935 cleanupCallbacks[i] = refCleanup;
936 }
937 break;
938 }
939 case "object": {
940 ref.current = instance;
941 break;
942 }
943 default:
944 }
945 }
946 forkRef.cleanup = () => {
947 for (let i = 0; i < refs.length; i += 1) {
948 const ref = refs[i];
949 if (ref == null) {
950 continue;
951 }
952 switch (typeof ref) {
953 case "function": {
954 const cleanupCallback = cleanupCallbacks[i];
955 if (typeof cleanupCallback === "function") {
956 cleanupCallback();
957 } else {
958 void ref(null);
959 }
960 break;
961 }
962 case "object": {
963 ref.current = null;
964 break;
965 }
966 default:
967 }
968 }
969 };
970 }
971 };
972 }
973
974 // node_modules/@base-ui/utils/getReactElementRef.mjs
975 var React8 = __toESM(require_react(), 1);
976
977 // node_modules/@base-ui/utils/reactVersion.mjs
978 var React7 = __toESM(require_react(), 1);
979 var majorVersion = parseInt(React7.version, 10);
980 function isReactVersionAtLeast(reactVersionToCheck) {
981 return majorVersion >= reactVersionToCheck;
982 }
983
984 // node_modules/@base-ui/utils/getReactElementRef.mjs
985 function getReactElementRef(element) {
986 if (!/* @__PURE__ */ React8.isValidElement(element)) {
987 return null;
988 }
989 const reactElement = element;
990 const propsWithRef = reactElement.props;
991 return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
992 }
993
994 // node_modules/@base-ui/utils/mergeObjects.mjs
995 function mergeObjects(a, b) {
996 if (a && !b) {
997 return a;
998 }
999 if (!a && b) {
1000 return b;
1001 }
1002 if (a || b) {
1003 return {
1004 ...a,
1005 ...b
1006 };
1007 }
1008 return void 0;
1009 }
1010
1011 // node_modules/@base-ui/react/internals/getStateAttributesProps.mjs
1012 function getStateAttributesProps(state, customMapping) {
1013 const props = {};
1014 for (const key in state) {
1015 const value = state[key];
1016 if (customMapping?.hasOwnProperty(key)) {
1017 const customProps = customMapping[key](value);
1018 if (customProps != null) {
1019 Object.assign(props, customProps);
1020 }
1021 continue;
1022 }
1023 if (value === true) {
1024 props[`data-${key.toLowerCase()}`] = "";
1025 } else if (value) {
1026 props[`data-${key.toLowerCase()}`] = value.toString();
1027 }
1028 }
1029 return props;
1030 }
1031
1032 // node_modules/@base-ui/react/utils/resolveClassName.mjs
1033 function resolveClassName(className, state) {
1034 return typeof className === "function" ? className(state) : className;
1035 }
1036
1037 // node_modules/@base-ui/react/utils/resolveStyle.mjs
1038 function resolveStyle(style, state) {
1039 return typeof style === "function" ? style(state) : style;
1040 }
1041
1042 // node_modules/@base-ui/react/merge-props/mergeProps.mjs
1043 var EMPTY_PROPS = {};
1044 function mergeProps(a, b, c2, d, e) {
1045 if (!c2 && !d && !e && !a) {
1046 return createInitialMergedProps(b);
1047 }
1048 let merged = createInitialMergedProps(a);
1049 if (b) {
1050 merged = mergeInto(merged, b);
1051 }
1052 if (c2) {
1053 merged = mergeInto(merged, c2);
1054 }
1055 if (d) {
1056 merged = mergeInto(merged, d);
1057 }
1058 if (e) {
1059 merged = mergeInto(merged, e);
1060 }
1061 return merged;
1062 }
1063 function mergePropsN(props) {
1064 if (props.length === 0) {
1065 return EMPTY_PROPS;
1066 }
1067 if (props.length === 1) {
1068 return createInitialMergedProps(props[0]);
1069 }
1070 let merged = createInitialMergedProps(props[0]);
1071 for (let i = 1; i < props.length; i += 1) {
1072 merged = mergeInto(merged, props[i]);
1073 }
1074 return merged;
1075 }
1076 function createInitialMergedProps(inputProps) {
1077 if (isPropsGetter(inputProps)) {
1078 return {
1079 ...resolvePropsGetter(inputProps, EMPTY_PROPS)
1080 };
1081 }
1082 return copyInitialProps(inputProps);
1083 }
1084 function mergeInto(merged, inputProps) {
1085 if (isPropsGetter(inputProps)) {
1086 return resolvePropsGetter(inputProps, merged);
1087 }
1088 return mutablyMergeInto(merged, inputProps);
1089 }
1090 function copyInitialProps(inputProps) {
1091 const copiedProps = {
1092 ...inputProps
1093 };
1094 for (const propName in copiedProps) {
1095 const propValue = copiedProps[propName];
1096 if (isEventHandler(propName, propValue)) {
1097 copiedProps[propName] = wrapEventHandler(propValue);
1098 }
1099 }
1100 return copiedProps;
1101 }
1102 function mutablyMergeInto(mergedProps, externalProps) {
1103 if (!externalProps) {
1104 return mergedProps;
1105 }
1106 for (const propName in externalProps) {
1107 const externalPropValue = externalProps[propName];
1108 switch (propName) {
1109 case "style": {
1110 mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
1111 break;
1112 }
1113 case "className": {
1114 mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
1115 break;
1116 }
1117 default: {
1118 if (isEventHandler(propName, externalPropValue)) {
1119 mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
1120 } else {
1121 mergedProps[propName] = externalPropValue;
1122 }
1123 }
1124 }
1125 }
1126 return mergedProps;
1127 }
1128 function isEventHandler(key, value) {
1129 const code0 = key.charCodeAt(0);
1130 const code1 = key.charCodeAt(1);
1131 const code2 = key.charCodeAt(2);
1132 return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined");
1133 }
1134 function isPropsGetter(inputProps) {
1135 return typeof inputProps === "function";
1136 }
1137 function resolvePropsGetter(inputProps, previousProps) {
1138 if (isPropsGetter(inputProps)) {
1139 return inputProps(previousProps);
1140 }
1141 return inputProps ?? EMPTY_PROPS;
1142 }
1143 function mergeEventHandlers(ourHandler, theirHandler) {
1144 if (!theirHandler) {
1145 return ourHandler;
1146 }
1147 if (!ourHandler) {
1148 return wrapEventHandler(theirHandler);
1149 }
1150 return (...args) => {
1151 const event = args[0];
1152 if (isSyntheticEvent(event)) {
1153 const baseUIEvent = event;
1154 makeEventPreventable(baseUIEvent);
1155 const result2 = theirHandler(...args);
1156 if (!baseUIEvent.baseUIHandlerPrevented) {
1157 ourHandler?.(...args);
1158 }
1159 return result2;
1160 }
1161 const result = theirHandler(...args);
1162 ourHandler?.(...args);
1163 return result;
1164 };
1165 }
1166 function wrapEventHandler(handler) {
1167 if (!handler) {
1168 return handler;
1169 }
1170 return (...args) => {
1171 const event = args[0];
1172 if (isSyntheticEvent(event)) {
1173 makeEventPreventable(event);
1174 }
1175 return handler(...args);
1176 };
1177 }
1178 function makeEventPreventable(event) {
1179 event.preventBaseUIHandler = () => {
1180 event.baseUIHandlerPrevented = true;
1181 };
1182 return event;
1183 }
1184 function mergeClassNames(ourClassName, theirClassName) {
1185 if (theirClassName) {
1186 if (ourClassName) {
1187 return theirClassName + " " + ourClassName;
1188 }
1189 return theirClassName;
1190 }
1191 return ourClassName;
1192 }
1193 function isSyntheticEvent(event) {
1194 return event != null && typeof event === "object" && "nativeEvent" in event;
1195 }
1196
1197 // node_modules/@base-ui/react/internals/useRenderElement.mjs
1198 var import_react = __toESM(require_react(), 1);
1199 function useRenderElement(element, componentProps, params = {}) {
1200 let renderProp = componentProps.render;
1201 if (params.enabled !== false) {
1202 renderProp = unwrapLazyRenderProp(renderProp);
1203 }
1204 const outProps = useRenderElementProps(componentProps, params, renderProp);
1205 if (params.enabled === false) {
1206 return null;
1207 }
1208 const state = params.state ?? EMPTY_OBJECT;
1209 return evaluateRenderProp(element, renderProp, outProps, state);
1210 }
1211 function useRenderElementProps(componentProps, params, renderProp) {
1212 const {
1213 className: classNameProp,
1214 style: styleProp
1215 } = componentProps;
1216 const {
1217 state = EMPTY_OBJECT,
1218 ref,
1219 props,
1220 stateAttributesMapping: stateAttributesMapping5,
1221 enabled = true
1222 } = params;
1223 const className = enabled ? resolveClassName(classNameProp, state) : void 0;
1224 const style = enabled ? resolveStyle(styleProp, state) : void 0;
1225 const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping5) : EMPTY_OBJECT;
1226 const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0;
1227 const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT;
1228 if (typeof document !== "undefined") {
1229 if (!enabled) {
1230 void useMergedRefs(null, null);
1231 } else if (Array.isArray(ref)) {
1232 outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]);
1233 } else {
1234 outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
1235 }
1236 }
1237 if (!enabled) {
1238 return EMPTY_OBJECT;
1239 }
1240 if (className !== void 0) {
1241 outProps.className = mergeClassNames(outProps.className, className);
1242 }
1243 if (style !== void 0) {
1244 outProps.style = mergeObjects(outProps.style, style);
1245 }
1246 return outProps;
1247 }
1248 function resolveRenderFunctionProps(props) {
1249 if (Array.isArray(props)) {
1250 return mergePropsN(props);
1251 }
1252 return mergeProps(void 0, props);
1253 }
1254 var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
1255 var COMPONENT_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9$]*$/;
1256 var LOWERCASE_CHARACTER_PATTERN = /[a-z]/;
1257 function unwrapLazyRenderProp(render4) {
1258 if (render4?.$$typeof !== REACT_LAZY_TYPE) {
1259 return render4;
1260 }
1261 const unwrapped = React9.Children.toArray(render4)[0];
1262 return /* @__PURE__ */ React9.isValidElement(unwrapped) ? unwrapped : render4;
1263 }
1264 function evaluateRenderProp(element, render4, props, state) {
1265 if (render4) {
1266 if (typeof render4 === "function") {
1267 if (true) {
1268 warnIfRenderPropLooksLikeComponent(render4);
1269 }
1270 return render4(props, state);
1271 }
1272 const mergedProps = mergeProps(props, render4.props);
1273 mergedProps.ref = props.ref;
1274 if (true) {
1275 if (!/* @__PURE__ */ React9.isValidElement(render4)) {
1276 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"));
1277 }
1278 }
1279 return /* @__PURE__ */ React9.cloneElement(render4, mergedProps);
1280 }
1281 if (element) {
1282 if (typeof element === "string") {
1283 return renderTag(element, props);
1284 }
1285 }
1286 throw new Error(true ? "Base UI: Render element or function are not defined." : formatErrorMessage_default(8));
1287 }
1288 function warnIfRenderPropLooksLikeComponent(renderFn) {
1289 const functionName = renderFn.name;
1290 if (functionName.length === 0) {
1291 return;
1292 }
1293 if (!COMPONENT_IDENTIFIER_PATTERN.test(functionName)) {
1294 return;
1295 }
1296 if (!LOWERCASE_CHARACTER_PATTERN.test(functionName)) {
1297 return;
1298 }
1299 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");
1300 }
1301 function renderTag(Tag, props) {
1302 if (Tag === "button") {
1303 return /* @__PURE__ */ (0, import_react.createElement)("button", {
1304 type: "button",
1305 ...props,
1306 key: props.key
1307 });
1308 }
1309 if (Tag === "img") {
1310 return /* @__PURE__ */ (0, import_react.createElement)("img", {
1311 alt: "",
1312 ...props,
1313 key: props.key
1314 });
1315 }
1316 return /* @__PURE__ */ React9.createElement(Tag, props);
1317 }
1318
1319 // node_modules/@base-ui/utils/useId.mjs
1320 var React10 = __toESM(require_react(), 1);
1321 var globalId = 0;
1322 function useGlobalId(idOverride, prefix = "mui") {
1323 const [defaultId, setDefaultId] = React10.useState(idOverride);
1324 const id = idOverride || defaultId;
1325 React10.useEffect(() => {
1326 if (defaultId == null) {
1327 globalId += 1;
1328 setDefaultId(`${prefix}-${globalId}`);
1329 }
1330 }, [defaultId, prefix]);
1331 return id;
1332 }
1333 var maybeReactUseId = SafeReact.useId;
1334 function useId(idOverride, prefix) {
1335 if (maybeReactUseId !== void 0) {
1336 const reactId = maybeReactUseId();
1337 return idOverride ?? (prefix ? `${prefix}-${reactId}` : reactId);
1338 }
1339 return useGlobalId(idOverride, prefix);
1340 }
1341
1342 // node_modules/@base-ui/react/internals/useBaseUiId.mjs
1343 function useBaseUiId(idOverride) {
1344 return useId(idOverride, "base-ui");
1345 }
1346
1347 // node_modules/@base-ui/react/collapsible/root/useCollapsibleRoot.mjs
1348 var React13 = __toESM(require_react(), 1);
1349
1350 // node_modules/@base-ui/react/internals/reason-parts.mjs
1351 var reason_parts_exports = {};
1352 __export(reason_parts_exports, {
1353 cancelOpen: () => cancelOpen,
1354 chipRemovePress: () => chipRemovePress,
1355 clearPress: () => clearPress,
1356 closePress: () => closePress,
1357 closeWatcher: () => closeWatcher,
1358 decrementPress: () => decrementPress,
1359 disabled: () => disabled,
1360 drag: () => drag,
1361 escapeKey: () => escapeKey,
1362 focusOut: () => focusOut,
1363 imperativeAction: () => imperativeAction,
1364 incrementPress: () => incrementPress,
1365 initial: () => initial,
1366 inputBlur: () => inputBlur,
1367 inputChange: () => inputChange,
1368 inputClear: () => inputClear,
1369 inputPaste: () => inputPaste,
1370 inputPress: () => inputPress,
1371 itemPress: () => itemPress,
1372 keyboard: () => keyboard,
1373 linkPress: () => linkPress,
1374 listNavigation: () => listNavigation,
1375 missing: () => missing,
1376 none: () => none,
1377 outsidePress: () => outsidePress,
1378 pointer: () => pointer,
1379 scrub: () => scrub,
1380 siblingOpen: () => siblingOpen,
1381 swipe: () => swipe,
1382 trackPress: () => trackPress,
1383 triggerFocus: () => triggerFocus,
1384 triggerHover: () => triggerHover,
1385 triggerPress: () => triggerPress,
1386 wheel: () => wheel,
1387 windowResize: () => windowResize
1388 });
1389 var none = "none";
1390 var triggerPress = "trigger-press";
1391 var triggerHover = "trigger-hover";
1392 var triggerFocus = "trigger-focus";
1393 var outsidePress = "outside-press";
1394 var itemPress = "item-press";
1395 var closePress = "close-press";
1396 var linkPress = "link-press";
1397 var clearPress = "clear-press";
1398 var chipRemovePress = "chip-remove-press";
1399 var trackPress = "track-press";
1400 var incrementPress = "increment-press";
1401 var decrementPress = "decrement-press";
1402 var inputChange = "input-change";
1403 var inputClear = "input-clear";
1404 var inputBlur = "input-blur";
1405 var inputPaste = "input-paste";
1406 var inputPress = "input-press";
1407 var focusOut = "focus-out";
1408 var escapeKey = "escape-key";
1409 var closeWatcher = "close-watcher";
1410 var listNavigation = "list-navigation";
1411 var keyboard = "keyboard";
1412 var pointer = "pointer";
1413 var drag = "drag";
1414 var wheel = "wheel";
1415 var scrub = "scrub";
1416 var cancelOpen = "cancel-open";
1417 var siblingOpen = "sibling-open";
1418 var disabled = "disabled";
1419 var missing = "missing";
1420 var initial = "initial";
1421 var imperativeAction = "imperative-action";
1422 var swipe = "swipe";
1423 var windowResize = "window-resize";
1424
1425 // node_modules/@base-ui/react/internals/createBaseUIEventDetails.mjs
1426 function createChangeEventDetails(reason, event, trigger, customProperties) {
1427 let canceled = false;
1428 let allowPropagation = false;
1429 const custom = customProperties ?? EMPTY_OBJECT;
1430 const details = {
1431 reason,
1432 event: event ?? new Event("base-ui"),
1433 cancel() {
1434 canceled = true;
1435 },
1436 allowPropagation() {
1437 allowPropagation = true;
1438 },
1439 get isCanceled() {
1440 return canceled;
1441 },
1442 get isPropagationAllowed() {
1443 return allowPropagation;
1444 },
1445 trigger,
1446 ...custom
1447 };
1448 return details;
1449 }
1450
1451 // node_modules/@base-ui/react/internals/useTransitionStatus.mjs
1452 var React12 = __toESM(require_react(), 1);
1453
1454 // node_modules/@base-ui/utils/useOnMount.mjs
1455 var React11 = __toESM(require_react(), 1);
1456 function useOnMount(fn) {
1457 React11.useEffect(fn, EMPTY_ARRAY);
1458 }
1459
1460 // node_modules/@base-ui/utils/useAnimationFrame.mjs
1461 var EMPTY = null;
1462 var LAST_RAF = globalThis.requestAnimationFrame;
1463 var Scheduler = class {
1464 /* This implementation uses an array as a backing data-structure for frame callbacks.
1465 * It allows `O(1)` callback cancelling by inserting a `null` in the array, though it
1466 * never calls the native `cancelAnimationFrame` if there are no frames left. This can
1467 * be much more efficient if there is a call pattern that alterns as
1468 * "request-cancel-request-cancel-…".
1469 * But in the case of "request-request-…-cancel-cancel-…", it leaves the final animation
1470 * frame to run anyway. We turn that frame into a `O(1)` no-op via `callbacksCount`. */
1471 callbacks = [];
1472 callbacksCount = 0;
1473 nextId = 1;
1474 startId = 1;
1475 isScheduled = false;
1476 tick = (timestamp) => {
1477 this.isScheduled = false;
1478 const currentCallbacks = this.callbacks;
1479 const currentCallbacksCount = this.callbacksCount;
1480 this.callbacks = [];
1481 this.callbacksCount = 0;
1482 this.startId = this.nextId;
1483 if (currentCallbacksCount > 0) {
1484 for (let i = 0; i < currentCallbacks.length; i += 1) {
1485 currentCallbacks[i]?.(timestamp);
1486 }
1487 }
1488 };
1489 request(fn) {
1490 const id = this.nextId;
1491 this.nextId += 1;
1492 this.callbacks.push(fn);
1493 this.callbacksCount += 1;
1494 const didRAFChange = LAST_RAF !== requestAnimationFrame && (LAST_RAF = requestAnimationFrame, true);
1495 if (!this.isScheduled || didRAFChange) {
1496 requestAnimationFrame(this.tick);
1497 this.isScheduled = true;
1498 }
1499 return id;
1500 }
1501 cancel(id) {
1502 const index3 = id - this.startId;
1503 if (index3 < 0 || index3 >= this.callbacks.length) {
1504 return;
1505 }
1506 if (this.callbacks[index3] === null) {
1507 return;
1508 }
1509 this.callbacks[index3] = null;
1510 this.callbacksCount -= 1;
1511 }
1512 };
1513 var scheduler = new Scheduler();
1514 var AnimationFrame = class _AnimationFrame {
1515 static create() {
1516 return new _AnimationFrame();
1517 }
1518 static request(fn) {
1519 return scheduler.request(fn);
1520 }
1521 static cancel(id) {
1522 return scheduler.cancel(id);
1523 }
1524 currentId = EMPTY;
1525 /**
1526 * Executes `fn` after `delay`, clearing any previously scheduled call.
1527 */
1528 request(fn) {
1529 this.cancel();
1530 this.currentId = scheduler.request(() => {
1531 this.currentId = EMPTY;
1532 fn();
1533 });
1534 }
1535 cancel = () => {
1536 if (this.currentId !== EMPTY) {
1537 scheduler.cancel(this.currentId);
1538 this.currentId = EMPTY;
1539 }
1540 };
1541 disposeEffect = () => {
1542 return this.cancel;
1543 };
1544 };
1545 function useAnimationFrame() {
1546 const timeout = useRefWithInit(AnimationFrame.create).current;
1547 useOnMount(timeout.disposeEffect);
1548 return timeout;
1549 }
1550
1551 // node_modules/@base-ui/react/internals/useTransitionStatus.mjs
1552 function useTransitionStatus(open3, enableIdleState = false, deferEndingState = false, animateInitialOpen = false) {
1553 const [transitionStatus, setTransitionStatus] = React12.useState(open3 && enableIdleState ? "idle" : void 0);
1554 const [mounted, setMounted] = React12.useState(open3 && !animateInitialOpen);
1555 if (open3 && !mounted) {
1556 setMounted(true);
1557 setTransitionStatus("starting");
1558 }
1559 if (!open3 && mounted && transitionStatus !== "ending" && !deferEndingState) {
1560 setTransitionStatus("ending");
1561 }
1562 if (!open3 && !mounted && transitionStatus === "ending") {
1563 setTransitionStatus(void 0);
1564 }
1565 useIsoLayoutEffect(() => {
1566 if (!open3 && mounted && transitionStatus !== "ending" && deferEndingState) {
1567 const frame = AnimationFrame.request(() => {
1568 setTransitionStatus("ending");
1569 });
1570 return () => {
1571 AnimationFrame.cancel(frame);
1572 };
1573 }
1574 return void 0;
1575 }, [open3, mounted, transitionStatus, deferEndingState]);
1576 useIsoLayoutEffect(() => {
1577 if (!open3 || enableIdleState) {
1578 return void 0;
1579 }
1580 const frame = AnimationFrame.request(() => {
1581 setTransitionStatus(void 0);
1582 });
1583 return () => {
1584 AnimationFrame.cancel(frame);
1585 };
1586 }, [enableIdleState, open3]);
1587 useIsoLayoutEffect(() => {
1588 if (!open3 || !enableIdleState) {
1589 return void 0;
1590 }
1591 if (open3 && mounted && transitionStatus !== "idle") {
1592 setTransitionStatus("starting");
1593 }
1594 const frame = AnimationFrame.request(() => {
1595 setTransitionStatus("idle");
1596 });
1597 return () => {
1598 AnimationFrame.cancel(frame);
1599 };
1600 }, [enableIdleState, open3, mounted, transitionStatus]);
1601 return {
1602 mounted,
1603 setMounted,
1604 transitionStatus
1605 };
1606 }
1607
1608 // node_modules/@base-ui/react/collapsible/root/useCollapsibleRoot.mjs
1609 function useCollapsibleRoot(parameters) {
1610 const {
1611 open: openParam,
1612 defaultOpen = false,
1613 onOpenChange,
1614 disabled: disabled2
1615 } = parameters;
1616 const [open3, setOpen] = useControlled({
1617 controlled: openParam,
1618 default: defaultOpen,
1619 name: "Collapsible",
1620 state: "open"
1621 });
1622 const {
1623 mounted,
1624 setMounted,
1625 transitionStatus
1626 } = useTransitionStatus(open3, true, true);
1627 const defaultPanelId = useBaseUiId();
1628 const [registeredPanelId, setPanelIdState] = React13.useState();
1629 const panelId = registeredPanelId === null ? void 0 : registeredPanelId ?? defaultPanelId;
1630 const handleTrigger = useStableCallback((event) => {
1631 const nextOpen = !open3;
1632 const eventDetails = createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent);
1633 onOpenChange(nextOpen, eventDetails);
1634 if (eventDetails.isCanceled) {
1635 return;
1636 }
1637 setOpen(nextOpen);
1638 });
1639 return React13.useMemo(() => ({
1640 defaultPanelId,
1641 disabled: disabled2,
1642 handleTrigger,
1643 mounted,
1644 open: open3,
1645 panelId,
1646 setMounted,
1647 setOpen,
1648 setPanelIdState,
1649 transitionStatus
1650 }), [defaultPanelId, disabled2, handleTrigger, mounted, open3, panelId, setMounted, setOpen, setPanelIdState, transitionStatus]);
1651 }
1652
1653 // node_modules/@base-ui/react/collapsible/root/CollapsibleRootContext.mjs
1654 var React14 = __toESM(require_react(), 1);
1655 var CollapsibleRootContext = /* @__PURE__ */ React14.createContext(void 0);
1656 if (true) CollapsibleRootContext.displayName = "CollapsibleRootContext";
1657 function useCollapsibleRootContext() {
1658 const context = React14.useContext(CollapsibleRootContext);
1659 if (context === void 0) {
1660 throw new Error(true ? "Base UI: CollapsibleRootContext is missing. Collapsible parts must be placed within <Collapsible.Root>." : formatErrorMessage_default(15));
1661 }
1662 return context;
1663 }
1664
1665 // node_modules/@base-ui/react/internals/composite/list/useCompositeListItem.mjs
1666 var React15 = __toESM(require_react(), 1);
1667 function useCompositeListItem(params = {}) {
1668 const {
1669 guess,
1670 label,
1671 metadata,
1672 textRef,
1673 index: externalIndex
1674 } = params;
1675 const {
1676 register: register3,
1677 unregister,
1678 subscribeMapChange,
1679 nextIndexRef
1680 } = useCompositeListContext();
1681 const indexRef = React15.useRef(-1);
1682 const [internalIndex, setInternalIndex] = React15.useState(externalIndex == null && guess ? () => {
1683 if (indexRef.current === -1) {
1684 const newIndex = nextIndexRef.current;
1685 nextIndexRef.current += 1;
1686 indexRef.current = newIndex;
1687 }
1688 return indexRef.current;
1689 } : -1);
1690 const index3 = externalIndex ?? internalIndex;
1691 const componentRef = React15.useRef(null);
1692 const ref = React15.useCallback((node) => {
1693 const previousNode = componentRef.current;
1694 if (previousNode) {
1695 unregister(previousNode);
1696 }
1697 componentRef.current = node;
1698 if (node) {
1699 register3(node, {
1700 metadata: metadata ?? null,
1701 index: externalIndex ?? null,
1702 label,
1703 textRef
1704 });
1705 }
1706 }, [externalIndex, register3, unregister, metadata, label, textRef]);
1707 useIsoLayoutEffect(() => {
1708 if (externalIndex != null) {
1709 return void 0;
1710 }
1711 return subscribeMapChange((map) => {
1712 const i = componentRef.current ? map.get(componentRef.current)?.index : null;
1713 if (i != null) {
1714 setInternalIndex(i);
1715 }
1716 });
1717 }, [externalIndex, subscribeMapChange]);
1718 return {
1719 ref,
1720 index: index3
1721 };
1722 }
1723
1724 // node_modules/@base-ui/react/internals/TransitionStatusDataAttributes.mjs
1725 var TransitionStatusDataAttributes_exports = {};
1726 __export(TransitionStatusDataAttributes_exports, {
1727 endingStyle: () => endingStyle,
1728 startingStyle: () => startingStyle
1729 });
1730 var startingStyle = "data-starting-style";
1731 var endingStyle = "data-ending-style";
1732
1733 // node_modules/@base-ui/react/internals/stateAttributesMapping.mjs
1734 var STARTING_HOOK = {
1735 [startingStyle]: ""
1736 };
1737 var ENDING_HOOK = {
1738 [endingStyle]: ""
1739 };
1740 var transitionStatusMapping = {
1741 transitionStatus(value) {
1742 if (value === "starting") {
1743 return STARTING_HOOK;
1744 }
1745 if (value === "ending") {
1746 return ENDING_HOOK;
1747 }
1748 return null;
1749 }
1750 };
1751
1752 // node_modules/@base-ui/react/collapsible/panel/CollapsiblePanelDataAttributes.mjs
1753 var open = "data-open";
1754 var closed = "data-closed";
1755 var startingStyle2 = TransitionStatusDataAttributes_exports.startingStyle;
1756 var endingStyle2 = TransitionStatusDataAttributes_exports.endingStyle;
1757
1758 // node_modules/@base-ui/react/collapsible/trigger/CollapsibleTriggerDataAttributes.mjs
1759 var panelOpen = "data-panel-open";
1760
1761 // node_modules/@base-ui/react/utils/collapsibleOpenStateMapping.mjs
1762 var PANEL_OPEN_HOOK = {
1763 [open]: ""
1764 };
1765 var PANEL_CLOSED_HOOK = {
1766 [closed]: ""
1767 };
1768 var triggerOpenStateMapping = {
1769 open(value) {
1770 if (value) {
1771 return {
1772 [panelOpen]: ""
1773 };
1774 }
1775 return null;
1776 }
1777 };
1778 var collapsibleOpenStateMapping = {
1779 open(value) {
1780 if (value) {
1781 return PANEL_OPEN_HOOK;
1782 }
1783 return PANEL_CLOSED_HOOK;
1784 }
1785 };
1786
1787 // node_modules/@base-ui/react/internals/use-button/useButton.mjs
1788 var React18 = __toESM(require_react(), 1);
1789
1790 // node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
1791 function hasWindow() {
1792 return typeof window !== "undefined";
1793 }
1794 function getNodeName(node) {
1795 if (isNode(node)) {
1796 return (node.nodeName || "").toLowerCase();
1797 }
1798 return "#document";
1799 }
1800 function getWindow(node) {
1801 var _node$ownerDocument;
1802 return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
1803 }
1804 function getDocumentElement(node) {
1805 var _ref;
1806 return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
1807 }
1808 function isNode(value) {
1809 if (!hasWindow()) {
1810 return false;
1811 }
1812 return value instanceof Node || value instanceof getWindow(value).Node;
1813 }
1814 function isElement(value) {
1815 if (!hasWindow()) {
1816 return false;
1817 }
1818 return value instanceof Element || value instanceof getWindow(value).Element;
1819 }
1820 function isHTMLElement(value) {
1821 if (!hasWindow()) {
1822 return false;
1823 }
1824 return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
1825 }
1826 function isShadowRoot(value) {
1827 if (!hasWindow() || typeof ShadowRoot === "undefined") {
1828 return false;
1829 }
1830 return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
1831 }
1832 function isOverflowElement(element) {
1833 const {
1834 overflow,
1835 overflowX,
1836 overflowY,
1837 display
1838 } = getComputedStyle2(element);
1839 return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== "inline" && display !== "contents";
1840 }
1841 function isTableElement(element) {
1842 return /^(table|td|th)$/.test(getNodeName(element));
1843 }
1844 function isTopLayer(element) {
1845 try {
1846 if (element.matches(":popover-open")) {
1847 return true;
1848 }
1849 } catch (_e) {
1850 }
1851 try {
1852 return element.matches(":modal");
1853 } catch (_e) {
1854 return false;
1855 }
1856 }
1857 var willChangeRe = /transform|translate|scale|rotate|perspective|filter/;
1858 var containRe = /paint|layout|strict|content/;
1859 var isNotNone = (value) => !!value && value !== "none";
1860 var isWebKitValue;
1861 function isContainingBlock(elementOrCss) {
1862 const css = isElement(elementOrCss) ? getComputedStyle2(elementOrCss) : elementOrCss;
1863 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 || "");
1864 }
1865 function getContainingBlock(element) {
1866 let currentNode = getParentNode(element);
1867 while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
1868 if (isContainingBlock(currentNode)) {
1869 return currentNode;
1870 } else if (isTopLayer(currentNode)) {
1871 return null;
1872 }
1873 currentNode = getParentNode(currentNode);
1874 }
1875 return null;
1876 }
1877 function isWebKit() {
1878 if (isWebKitValue == null) {
1879 isWebKitValue = typeof CSS !== "undefined" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none");
1880 }
1881 return isWebKitValue;
1882 }
1883 function isLastTraversableNode(node) {
1884 return /^(html|body|#document)$/.test(getNodeName(node));
1885 }
1886 function getComputedStyle2(element) {
1887 return getWindow(element).getComputedStyle(element);
1888 }
1889 function getNodeScroll(element) {
1890 if (isElement(element)) {
1891 return {
1892 scrollLeft: element.scrollLeft,
1893 scrollTop: element.scrollTop
1894 };
1895 }
1896 return {
1897 scrollLeft: element.scrollX,
1898 scrollTop: element.scrollY
1899 };
1900 }
1901 function getParentNode(node) {
1902 if (getNodeName(node) === "html") {
1903 return node;
1904 }
1905 const result = (
1906 // Step into the shadow DOM of the parent of a slotted node.
1907 node.assignedSlot || // DOM Element detected.
1908 node.parentNode || // ShadowRoot detected.
1909 isShadowRoot(node) && node.host || // Fallback.
1910 getDocumentElement(node)
1911 );
1912 return isShadowRoot(result) ? result.host : result;
1913 }
1914 function getNearestOverflowAncestor(node) {
1915 const parentNode = getParentNode(node);
1916 if (isLastTraversableNode(parentNode)) {
1917 return (node.ownerDocument || node).body;
1918 }
1919 if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
1920 return parentNode;
1921 }
1922 return getNearestOverflowAncestor(parentNode);
1923 }
1924 function getOverflowAncestors(node, list, traverseIframes) {
1925 var _node$ownerDocument2;
1926 if (list === void 0) {
1927 list = [];
1928 }
1929 if (traverseIframes === void 0) {
1930 traverseIframes = true;
1931 }
1932 const scrollableAncestor = getNearestOverflowAncestor(node);
1933 const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
1934 const win = getWindow(scrollableAncestor);
1935 if (isBody) {
1936 const frameElement = getFrameElement(win);
1937 return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
1938 } else {
1939 return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
1940 }
1941 }
1942 function getFrameElement(win) {
1943 return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
1944 }
1945
1946 // node_modules/@base-ui/react/internals/composite/root/CompositeRootContext.mjs
1947 var React16 = __toESM(require_react(), 1);
1948 var CompositeRootContext = /* @__PURE__ */ React16.createContext(void 0);
1949 if (true) CompositeRootContext.displayName = "CompositeRootContext";
1950 function useCompositeRootContext(optional = false) {
1951 const context = React16.useContext(CompositeRootContext);
1952 if (context === void 0 && !optional) {
1953 throw new Error(true ? "Base UI: CompositeRootContext is missing. Composite parts must be placed within <Composite.Root>." : formatErrorMessage_default(16));
1954 }
1955 return context;
1956 }
1957
1958 // node_modules/@base-ui/react/utils/useFocusableWhenDisabled.mjs
1959 var React17 = __toESM(require_react(), 1);
1960 function useFocusableWhenDisabled(parameters) {
1961 const {
1962 focusableWhenDisabled,
1963 disabled: disabled2,
1964 composite = false,
1965 tabIndex: tabIndexProp = 0,
1966 isNativeButton
1967 } = parameters;
1968 const isFocusableComposite = composite && focusableWhenDisabled !== false;
1969 const isNonFocusableComposite = composite && focusableWhenDisabled === false;
1970 const props = React17.useMemo(() => {
1971 const additionalProps = {
1972 // allow Tabbing away from focusableWhenDisabled elements
1973 onKeyDown(event) {
1974 if (disabled2 && focusableWhenDisabled && event.key !== "Tab") {
1975 event.preventDefault();
1976 }
1977 }
1978 };
1979 if (!composite) {
1980 additionalProps.tabIndex = tabIndexProp;
1981 if (!isNativeButton && disabled2) {
1982 additionalProps.tabIndex = focusableWhenDisabled ? tabIndexProp : -1;
1983 }
1984 }
1985 if (isNativeButton && (focusableWhenDisabled || isFocusableComposite) || !isNativeButton && disabled2) {
1986 additionalProps["aria-disabled"] = disabled2;
1987 }
1988 if (isNativeButton && (!focusableWhenDisabled || isNonFocusableComposite)) {
1989 additionalProps.disabled = disabled2;
1990 }
1991 return additionalProps;
1992 }, [composite, disabled2, focusableWhenDisabled, isFocusableComposite, isNonFocusableComposite, isNativeButton, tabIndexProp]);
1993 return {
1994 props
1995 };
1996 }
1997
1998 // node_modules/@base-ui/utils/owner.mjs
1999 function ownerDocument(node) {
2000 return node?.ownerDocument || document;
2001 }
2002
2003 // node_modules/@base-ui/react/utils/dispatchClickWithModifiers.mjs
2004 function dispatchClickWithModifiers(target, sourceEvent, {
2005 detail = 0
2006 } = {}) {
2007 target.dispatchEvent(new (getWindow(target)).PointerEvent("click", {
2008 bubbles: true,
2009 cancelable: true,
2010 composed: true,
2011 detail,
2012 shiftKey: sourceEvent.shiftKey,
2013 ctrlKey: sourceEvent.ctrlKey,
2014 altKey: sourceEvent.altKey,
2015 metaKey: sourceEvent.metaKey
2016 }));
2017 }
2018
2019 // node_modules/@base-ui/react/internals/use-button/useButton.mjs
2020 function useButton(parameters = {}) {
2021 const {
2022 disabled: disabled2 = false,
2023 focusableWhenDisabled,
2024 tabIndex = 0,
2025 native: isNativeButton = true,
2026 composite: compositeProp
2027 } = parameters;
2028 const elementRef = React18.useRef(null);
2029 const compositeRootContext = useCompositeRootContext(true);
2030 const isCompositeItem = compositeProp ?? compositeRootContext !== void 0;
2031 const {
2032 props: focusableWhenDisabledProps
2033 } = useFocusableWhenDisabled({
2034 focusableWhenDisabled,
2035 disabled: disabled2,
2036 composite: isCompositeItem,
2037 tabIndex,
2038 isNativeButton
2039 });
2040 if (true) {
2041 React18.useEffect(() => {
2042 if (!elementRef.current) {
2043 return;
2044 }
2045 const isButtonTag = isButtonElement(elementRef.current);
2046 if (isNativeButton) {
2047 if (!isButtonTag) {
2048 const ownerStackMessage = SafeReact.captureOwnerStack?.() || "";
2049 const message2 = "A component that acts as a button expected a native <button> because the `nativeButton` prop is true. Rendering a non-<button> removes native button semantics, which can impact forms and accessibility. Use a real <button> in the `render` prop, or set `nativeButton` to `false`.";
2050 error(`${message2}${ownerStackMessage}`);
2051 }
2052 } else if (isButtonTag) {
2053 const ownerStackMessage = SafeReact.captureOwnerStack?.() || "";
2054 const message2 = "A component that acts as a button expected a non-<button> because the `nativeButton` prop is false. Rendering a <button> keeps native behavior while Base UI applies non-native attributes and handlers, which can add unintended extra attributes (such as `role` or `aria-disabled`). Use a non-<button> in the `render` prop, or set `nativeButton` to `true`.";
2055 error(`${message2}${ownerStackMessage}`);
2056 }
2057 }, [isNativeButton]);
2058 }
2059 const updateDisabled = React18.useCallback(() => {
2060 const element = elementRef.current;
2061 if (!isButtonElement(element)) {
2062 return;
2063 }
2064 if (isCompositeItem && disabled2 && focusableWhenDisabledProps.disabled === void 0 && element.disabled) {
2065 element.disabled = false;
2066 }
2067 }, [disabled2, focusableWhenDisabledProps.disabled, isCompositeItem]);
2068 useIsoLayoutEffect(updateDisabled, [updateDisabled]);
2069 const getButtonProps = React18.useCallback((externalProps = {}) => {
2070 const {
2071 onClick: externalOnClick,
2072 onMouseDown: externalOnMouseDown,
2073 onKeyUp: externalOnKeyUp,
2074 onKeyDown: externalOnKeyDown,
2075 onPointerDown: externalOnPointerDown,
2076 ...otherExternalProps
2077 } = externalProps;
2078 return mergeProps({
2079 onClick(event) {
2080 if (disabled2) {
2081 event.preventDefault();
2082 return;
2083 }
2084 externalOnClick?.(event);
2085 },
2086 onMouseDown(event) {
2087 if (!disabled2) {
2088 externalOnMouseDown?.(event);
2089 }
2090 },
2091 onKeyDown(event) {
2092 if (disabled2) {
2093 return;
2094 }
2095 makeEventPreventable(event);
2096 externalOnKeyDown?.(event);
2097 if (event.baseUIHandlerPrevented) {
2098 return;
2099 }
2100 const isCurrentTarget = event.target === event.currentTarget;
2101 const currentTarget = event.currentTarget;
2102 const isButton = isButtonElement(currentTarget);
2103 const isLink = !isNativeButton && isValidLinkElement(currentTarget);
2104 const shouldClick = isCurrentTarget && (isNativeButton ? isButton : !isLink);
2105 const isEnterKey = event.key === "Enter";
2106 const isSpaceKey = event.key === " ";
2107 const role = currentTarget.getAttribute("role");
2108 const isTextNavigationRole = role?.startsWith("menuitem") || role === "option" || role === "gridcell";
2109 if (isCurrentTarget && isCompositeItem && isSpaceKey) {
2110 if (event.defaultPrevented && isTextNavigationRole) {
2111 return;
2112 }
2113 event.preventDefault();
2114 if (!isNativeButton || isButton) {
2115 event.preventBaseUIHandler();
2116 dispatchClickWithModifiers(currentTarget, event);
2117 }
2118 return;
2119 }
2120 if (!shouldClick || isNativeButton || !isSpaceKey && !isEnterKey) {
2121 if (isCurrentTarget && isLink && isSpaceKey) {
2122 event.preventDefault();
2123 }
2124 return;
2125 }
2126 if (event.defaultPrevented) {
2127 return;
2128 }
2129 event.preventDefault();
2130 if (isEnterKey) {
2131 event.preventBaseUIHandler();
2132 dispatchClickWithModifiers(currentTarget, event);
2133 }
2134 },
2135 onKeyUp(event) {
2136 if (disabled2) {
2137 return;
2138 }
2139 makeEventPreventable(event);
2140 externalOnKeyUp?.(event);
2141 if (event.target === event.currentTarget && isNativeButton && isCompositeItem && isButtonElement(event.currentTarget) && event.key === " ") {
2142 event.preventDefault();
2143 return;
2144 }
2145 if (event.baseUIHandlerPrevented) {
2146 return;
2147 }
2148 if (event.target === event.currentTarget && !isNativeButton && !isCompositeItem && !event.defaultPrevented && event.key === " ") {
2149 event.preventBaseUIHandler();
2150 dispatchClickWithModifiers(event.currentTarget, event);
2151 }
2152 },
2153 onPointerDown(event) {
2154 if (disabled2) {
2155 event.preventDefault();
2156 return;
2157 }
2158 externalOnPointerDown?.(event);
2159 }
2160 }, isNativeButton ? {
2161 type: "button"
2162 } : {
2163 role: "button"
2164 }, focusableWhenDisabledProps, otherExternalProps);
2165 }, [disabled2, focusableWhenDisabledProps, isCompositeItem, isNativeButton]);
2166 const buttonRef = useStableCallback((element) => {
2167 elementRef.current = element;
2168 updateDisabled();
2169 });
2170 return {
2171 getButtonProps,
2172 buttonRef
2173 };
2174 }
2175 function isButtonElement(elem) {
2176 return isHTMLElement(elem) && elem.tagName === "BUTTON";
2177 }
2178 function isValidLinkElement(elem) {
2179 return isHTMLElement(elem) && elem.tagName === "A" && Boolean(elem.href);
2180 }
2181
2182 // node_modules/@base-ui/react/collapsible/panel/useCollapsiblePanel.mjs
2183 var React20 = __toESM(require_react(), 1);
2184
2185 // node_modules/@base-ui/utils/addEventListener.mjs
2186 function addEventListener(target, type, listener, options) {
2187 target.addEventListener(type, listener, options);
2188 return () => {
2189 target.removeEventListener(type, listener, options);
2190 };
2191 }
2192
2193 // node_modules/@base-ui/utils/useValueAsRef.mjs
2194 function useValueAsRef(value) {
2195 const latest = useRefWithInit(createLatestRef, value).current;
2196 latest.next = value;
2197 useIsoLayoutEffect(latest.effect);
2198 return latest;
2199 }
2200 function createLatestRef(value) {
2201 const latest = {
2202 current: value,
2203 next: value,
2204 effect: () => {
2205 latest.current = latest.next;
2206 }
2207 };
2208 return latest;
2209 }
2210
2211 // node_modules/@base-ui/react/internals/useOpenChangeComplete.mjs
2212 var React19 = __toESM(require_react(), 1);
2213
2214 // node_modules/@base-ui/react/internals/useAnimationsFinished.mjs
2215 var ReactDOM = __toESM(require_react_dom(), 1);
2216
2217 // node_modules/@base-ui/react/utils/resolveRef.mjs
2218 function resolveRef(maybeRef) {
2219 if (maybeRef == null) {
2220 return maybeRef;
2221 }
2222 return "current" in maybeRef ? maybeRef.current : maybeRef;
2223 }
2224
2225 // node_modules/@base-ui/react/internals/useAnimationsFinished.mjs
2226 var pendingCallbacks = null;
2227 function flushBeforePaint(fn) {
2228 if (!pendingCallbacks) {
2229 const callbacks = [];
2230 pendingCallbacks = callbacks;
2231 queueMicrotask(() => {
2232 pendingCallbacks = null;
2233 ReactDOM.flushSync(() => {
2234 for (const callback of callbacks) {
2235 callback();
2236 }
2237 });
2238 });
2239 }
2240 pendingCallbacks.push(fn);
2241 }
2242 function useAnimationsFinished(elementOrRef, waitForStartingStyleRemoved = false, batch = false) {
2243 const frame = useAnimationFrame();
2244 return useStableCallback((fnToExecute, signal = null) => {
2245 frame.cancel();
2246 const element = resolveRef(elementOrRef);
2247 if (element == null) {
2248 return;
2249 }
2250 const resolvedElement = element;
2251 const done = () => {
2252 if (!batch) {
2253 ReactDOM.flushSync(fnToExecute);
2254 return;
2255 }
2256 flushBeforePaint(() => {
2257 if (!signal?.aborted) {
2258 fnToExecute();
2259 }
2260 });
2261 };
2262 if (typeof resolvedElement.getAnimations !== "function" || globalThis.BASE_UI_ANIMATIONS_DISABLED) {
2263 fnToExecute();
2264 return;
2265 }
2266 function exec() {
2267 Promise.all(resolvedElement.getAnimations().map((animation) => animation.finished)).then(() => {
2268 if (!signal?.aborted) {
2269 done();
2270 }
2271 }, () => {
2272 if (signal?.aborted) {
2273 return;
2274 }
2275 const currentAnimations = resolvedElement.getAnimations();
2276 if (currentAnimations.some((animation) => animation.pending || animation.playState !== "finished")) {
2277 exec();
2278 return;
2279 }
2280 done();
2281 });
2282 }
2283 if (waitForStartingStyleRemoved) {
2284 const startingStyleAttribute = startingStyle;
2285 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
2286 frame.request(exec);
2287 return;
2288 }
2289 const attributeObserver = new MutationObserver(() => {
2290 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
2291 attributeObserver.disconnect();
2292 exec();
2293 }
2294 });
2295 attributeObserver.observe(resolvedElement, {
2296 attributes: true,
2297 attributeFilter: [startingStyleAttribute]
2298 });
2299 signal?.addEventListener("abort", () => attributeObserver.disconnect(), {
2300 once: true
2301 });
2302 return;
2303 }
2304 frame.request(exec);
2305 });
2306 }
2307
2308 // node_modules/@base-ui/react/internals/useOpenChangeComplete.mjs
2309 function useOpenChangeComplete(parameters) {
2310 const {
2311 enabled = true,
2312 open: open3,
2313 ref,
2314 batch = false,
2315 onComplete: onCompleteParam
2316 } = parameters;
2317 const onComplete = useStableCallback(onCompleteParam);
2318 const runOnceAnimationsFinish = useAnimationsFinished(ref, open3, batch);
2319 React19.useEffect(() => {
2320 if (!enabled) {
2321 return void 0;
2322 }
2323 const abortController = new AbortController();
2324 runOnceAnimationsFinish(onComplete, abortController.signal);
2325 return () => {
2326 abortController.abort();
2327 };
2328 }, [enabled, open3, onComplete, runOnceAnimationsFinish]);
2329 }
2330
2331 // node_modules/@base-ui/react/collapsible/panel/useCollapsiblePanel.mjs
2332 var EMPTY_DIMENSIONS = {
2333 height: void 0,
2334 width: void 0
2335 };
2336 function useCollapsiblePanel(parameters) {
2337 const {
2338 externalRef,
2339 hiddenUntilFound,
2340 id: idParam,
2341 keepMounted,
2342 mounted,
2343 onOpenChange,
2344 open: open3,
2345 setMounted,
2346 setOpen,
2347 transitionStatus
2348 } = parameters;
2349 const panelRef = React20.useRef(null);
2350 const animationTypeRef = React20.useRef(null);
2351 const [dimensions, setDimensionsUnwrapped] = React20.useState(EMPTY_DIMENSIONS);
2352 const lastMeasuredDimensionsRef = React20.useRef(EMPTY_DIMENSIONS);
2353 const shouldSkipNextOpenRef = React20.useRef(false);
2354 const shouldPreventMountAnimationRef = React20.useRef(open3);
2355 const shouldPreventActivityResumeAnimationRef = React20.useRef(false);
2356 const [forcePanelIdle, setForcePanelIdle] = React20.useState(false);
2357 const pendingTemporaryStyleRestoreRef = React20.useRef(null);
2358 const mergedPanelRef = useMergedRefs(externalRef, panelRef);
2359 const latestOpenRef = useValueAsRef(open3);
2360 const runOnceCloseAnimationsFinish = useAnimationsFinished(panelRef);
2361 const hidden = !open3 && !mounted;
2362 const panelTransitionStatus = forcePanelIdle ? "idle" : transitionStatus;
2363 const shouldPreventOpenAnimation = open3 && // These 2 refs are safe to read in render, they are only written from committed
2364 // layout/effect paths and gate one-shot motion suppression for the next open
2365 // lifecycle. They intentionally expose the last committed motion snapshot.
2366 (shouldPreventMountAnimationRef.current || shouldPreventActivityResumeAnimationRef.current);
2367 const renderedDimensions = !open3 && mounted && // These 2 refs are also safe to read in render, both hold the last committed
2368 // animation mode and measurement. This fallback only restores a previously
2369 // measured pixel size after the live dimensions state has been reset back to `auto`.
2370 animationTypeRef.current === "css-animation" && dimensions.height === void 0 && dimensions.width === void 0 ? lastMeasuredDimensionsRef.current : dimensions;
2371 const shouldPersistHiddenTransitionStyles = hiddenUntilFound && hidden && animationTypeRef.current !== "css-animation";
2372 const setDimensions = useStableCallback((nextDimensions, shouldCacheMeasurement = true) => {
2373 if (shouldCacheMeasurement) {
2374 lastMeasuredDimensionsRef.current = nextDimensions;
2375 }
2376 setDimensionsUnwrapped(nextDimensions);
2377 });
2378 const restorePendingTemporaryStyle = useStableCallback(() => {
2379 pendingTemporaryStyleRestoreRef.current?.();
2380 pendingTemporaryStyleRestoreRef.current = null;
2381 });
2382 const setPendingTemporaryStyleRestore = useStableCallback((restore) => {
2383 restorePendingTemporaryStyle();
2384 pendingTemporaryStyleRestoreRef.current = () => {
2385 pendingTemporaryStyleRestoreRef.current = null;
2386 restore();
2387 };
2388 });
2389 const markActivityResumeAnimationSuppressed = useStableCallback(() => {
2390 if (open3 && mounted && animationTypeRef.current === "css-animation") {
2391 shouldPreventActivityResumeAnimationRef.current = true;
2392 }
2393 });
2394 useIsoLayoutEffect(() => {
2395 if (!forcePanelIdle || transitionStatus === "starting") {
2396 return;
2397 }
2398 setForcePanelIdle(false);
2399 }, [forcePanelIdle, transitionStatus]);
2400 React20.useEffect(() => {
2401 return () => {
2402 markActivityResumeAnimationSuppressed();
2403 restorePendingTemporaryStyle();
2404 };
2405 }, [markActivityResumeAnimationSuppressed, restorePendingTemporaryStyle]);
2406 useIsoLayoutEffect(() => {
2407 const panel = panelRef.current;
2408 if (!panel) {
2409 return void 0;
2410 }
2411 if (!open3 && pendingTemporaryStyleRestoreRef.current) {
2412 restorePendingTemporaryStyle();
2413 }
2414 const animationType = getAnimationType(panel, shouldPreventOpenAnimation);
2415 animationTypeRef.current = animationType;
2416 if (open3 && transitionStatus === "idle" && shouldPreventMountAnimationRef.current && animationType === "css-animation") {
2417 lastMeasuredDimensionsRef.current = getDimensions(panel);
2418 return void 0;
2419 }
2420 if (open3 && transitionStatus === "starting") {
2421 const skipNextOpen = shouldSkipNextOpenRef.current;
2422 shouldSkipNextOpenRef.current = false;
2423 if (animationType === "none") {
2424 setDimensions(getDimensions(panel));
2425 setForcePanelIdle(true);
2426 return void 0;
2427 }
2428 if (animationType === "css-transition") {
2429 const restoreLayoutStyles = resetLayoutStyles(panel);
2430 setDimensions(getDimensions(panel));
2431 if (!skipNextOpen) {
2432 return restoreLayoutStyles;
2433 }
2434 const restoreTransitionDuration = setTemporaryStyle(panel, "transition-duration", "0s");
2435 setPendingTemporaryStyleRestore(restoreTransitionDuration);
2436 setForcePanelIdle(true);
2437 return restoreLayoutStyles;
2438 }
2439 setDimensions(getDimensions(panel));
2440 const restoreAnimationName = setTemporaryStyle(panel, "animation-name", "none");
2441 if (!skipNextOpen) {
2442 restoreAnimationName();
2443 return void 0;
2444 }
2445 const restoreAnimationDuration = setTemporaryStyle(panel, "animation-duration", "0s");
2446 restoreAnimationName();
2447 setPendingTemporaryStyleRestore(restoreAnimationDuration);
2448 setForcePanelIdle(true);
2449 return void 0;
2450 }
2451 if (!open3 && mounted && (transitionStatus === "idle" || transitionStatus === "starting")) {
2452 shouldPreventMountAnimationRef.current = false;
2453 shouldPreventActivityResumeAnimationRef.current = false;
2454 if (animationType === "none") {
2455 setDimensions(EMPTY_DIMENSIONS, false);
2456 setMounted(false);
2457 return void 0;
2458 }
2459 setDimensions(getDimensions(panel));
2460 return void 0;
2461 }
2462 if (transitionStatus !== "ending") {
2463 return void 0;
2464 }
2465 if (animationType === "none") {
2466 setMounted(false);
2467 return void 0;
2468 }
2469 const nextDimensions = getDimensions(panel);
2470 const hasMeasuredSize = nextDimensions.height > 0 || nextDimensions.width > 0;
2471 if (!hasMeasuredSize) {
2472 setMounted(false);
2473 return void 0;
2474 }
2475 setDimensions(nextDimensions);
2476 if (animationType === "css-animation") {
2477 const restoreAnimationName = setTemporaryStyle(panel, "animation-name", "none");
2478 restoreAnimationName();
2479 }
2480 return void 0;
2481 }, [mounted, open3, restorePendingTemporaryStyle, setDimensions, setMounted, setPendingTemporaryStyleRestore, shouldPreventOpenAnimation, transitionStatus]);
2482 useOpenChangeComplete({
2483 enabled: open3 && mounted && panelTransitionStatus === "idle",
2484 open: true,
2485 ref: panelRef,
2486 onComplete() {
2487 if (!open3) {
2488 return;
2489 }
2490 setDimensions(EMPTY_DIMENSIONS, false);
2491 }
2492 });
2493 React20.useEffect(() => {
2494 if (open3 || !mounted || panelTransitionStatus !== "ending") {
2495 return void 0;
2496 }
2497 const panel = panelRef.current;
2498 if (!panel) {
2499 return void 0;
2500 }
2501 const abortController = new AbortController();
2502 let endingStyleFrame = -1;
2503 function handleComplete() {
2504 if (latestOpenRef.current) {
2505 return;
2506 }
2507 setMounted(false);
2508 setDimensions(EMPTY_DIMENSIONS, false);
2509 }
2510 endingStyleFrame = AnimationFrame.request(() => {
2511 runOnceCloseAnimationsFinish(handleComplete, abortController.signal);
2512 });
2513 return () => {
2514 AnimationFrame.cancel(endingStyleFrame);
2515 abortController.abort();
2516 };
2517 }, [latestOpenRef, mounted, open3, panelTransitionStatus, runOnceCloseAnimationsFinish, setDimensions, setMounted]);
2518 useIsoLayoutEffect(() => {
2519 const panel = panelRef.current;
2520 if (!panel || !hiddenUntilFound || !hidden) {
2521 return;
2522 }
2523 panel.setAttribute("hidden", "until-found");
2524 }, [hidden, hiddenUntilFound]);
2525 React20.useEffect(function registerBeforeMatchListener() {
2526 const panel = panelRef.current;
2527 if (!panel) {
2528 return void 0;
2529 }
2530 function handleBeforeMatch(event) {
2531 const eventDetails = createChangeEventDetails(reason_parts_exports.none, event);
2532 onOpenChange(true, eventDetails);
2533 if (eventDetails.isCanceled) {
2534 return;
2535 }
2536 shouldSkipNextOpenRef.current = true;
2537 setOpen(true);
2538 }
2539 return addEventListener(panel, "beforematch", handleBeforeMatch);
2540 }, [onOpenChange, setOpen]);
2541 const shouldRender = keepMounted || hiddenUntilFound || mounted || open3;
2542 return {
2543 height: renderedDimensions.height,
2544 props: {
2545 ...shouldPersistHiddenTransitionStyles ? {
2546 [startingStyle2]: ""
2547 } : void 0,
2548 hidden,
2549 id: idParam
2550 },
2551 ref: mergedPanelRef,
2552 shouldPreventOpenAnimation,
2553 shouldRender,
2554 transitionStatus: panelTransitionStatus,
2555 width: renderedDimensions.width
2556 };
2557 }
2558 function getDimensions(element) {
2559 return {
2560 height: element.scrollHeight,
2561 width: element.scrollWidth
2562 };
2563 }
2564 function getAnimationType(element, hasSuppressedMountAnimation) {
2565 const panelStyles = getWindow(element).getComputedStyle(element);
2566 const hasAnimation = (panelStyles.animationName.split(",").map((name) => name.trim()).some((name) => name !== "" && name !== "none") || hasSuppressedMountAnimation) && hasNonZeroDuration(panelStyles.animationDuration);
2567 const hasTransition = hasNonZeroDuration(panelStyles.transitionDuration);
2568 if (hasAnimation && hasTransition) {
2569 if (true) {
2570 warn("CSS transitions and CSS animations both detected on Collapsible or Accordion panel.", "Only one of either animation type should be used.");
2571 }
2572 return "css-transition";
2573 }
2574 if (hasTransition) {
2575 return "css-transition";
2576 }
2577 if (hasAnimation) {
2578 return "css-animation";
2579 }
2580 return "none";
2581 }
2582 function hasNonZeroDuration(value) {
2583 return value.split(",").map((part) => part.trim()).some((part) => part !== "" && Number.parseFloat(part) > 0);
2584 }
2585 function setTemporaryStyle(element, property, value) {
2586 const previousValue = element.style.getPropertyValue(property);
2587 const previousPriority = element.style.getPropertyPriority(property);
2588 element.style.setProperty(property, value);
2589 return () => {
2590 if (previousValue === "") {
2591 element.style.removeProperty(property);
2592 return;
2593 }
2594 element.style.setProperty(property, previousValue, previousPriority);
2595 };
2596 }
2597 function resetLayoutStyles(element) {
2598 const originalLayoutStyles = {
2599 "justify-content": element.style.justifyContent,
2600 "align-items": element.style.alignItems,
2601 "align-content": element.style.alignContent,
2602 "justify-items": element.style.justifyItems
2603 };
2604 Object.keys(originalLayoutStyles).forEach((key) => {
2605 element.style.setProperty(key, "initial", "important");
2606 });
2607 function restoreLayoutStyles() {
2608 Object.entries(originalLayoutStyles).forEach(([key, value]) => {
2609 if (value === "") {
2610 element.style.removeProperty(key);
2611 return;
2612 }
2613 element.style.setProperty(key, value);
2614 });
2615 }
2616 const frame = AnimationFrame.request(restoreLayoutStyles);
2617 return () => {
2618 AnimationFrame.cancel(frame);
2619 restoreLayoutStyles();
2620 };
2621 }
2622
2623 // node_modules/@base-ui/utils/platform/parts.mjs
2624 var parts_exports = {};
2625 __export(parts_exports, {
2626 engine: () => engine_exports,
2627 env: () => env_exports,
2628 mediaQuery: () => media_query_exports,
2629 os: () => os_exports,
2630 screenReader: () => screen_reader_exports
2631 });
2632
2633 // node_modules/@base-ui/utils/platform/os.mjs
2634 var os_exports = {};
2635 __export(os_exports, {
2636 android: () => android,
2637 apple: () => apple,
2638 ios: () => ios,
2639 linux: () => linux,
2640 mac: () => mac,
2641 windows: () => windows
2642 });
2643
2644 // node_modules/@base-ui/utils/platform/shared.mjs
2645 function readRawData() {
2646 if (typeof navigator === "undefined") {
2647 return {
2648 userAgent: "",
2649 platform: "",
2650 maxTouchPoints: 0
2651 };
2652 }
2653 if (true) {
2654 const uaData = navigator.userAgentData;
2655 if (uaData && Array.isArray(uaData.brands)) {
2656 return {
2657 userAgent: uaData.brands.map(({
2658 brand,
2659 version: version2
2660 }) => `${brand}/${version2}`).join(" "),
2661 platform: uaData.platform ?? navigator.platform ?? "",
2662 maxTouchPoints: navigator.maxTouchPoints ?? 0
2663 };
2664 }
2665 }
2666 return {
2667 userAgent: navigator.userAgent,
2668 platform: navigator.platform ?? "",
2669 maxTouchPoints: navigator.maxTouchPoints ?? 0
2670 };
2671 }
2672 var {
2673 userAgent,
2674 platform,
2675 maxTouchPoints
2676 } = readRawData();
2677 var lowerUserAgent = userAgent.toLowerCase();
2678 var lowerPlatform = platform.toLowerCase();
2679
2680 // node_modules/@base-ui/utils/platform/os.mjs
2681 var ios = /^i(os$|p)/.test(lowerPlatform) || lowerPlatform === "macintel" && maxTouchPoints > 1;
2682 var ANDROID_STRING = "android";
2683 var android = lowerPlatform === ANDROID_STRING || lowerUserAgent.includes(ANDROID_STRING);
2684 var mac = !ios && lowerPlatform.startsWith("mac");
2685 var windows = lowerPlatform.startsWith("win");
2686 var linux = !android && /^(linux|chrome os)/.test(lowerPlatform);
2687 var apple = mac || ios;
2688
2689 // node_modules/@base-ui/utils/platform/engine.mjs
2690 var engine_exports = {};
2691 __export(engine_exports, {
2692 blink: () => blink,
2693 gecko: () => gecko,
2694 webkit: () => webkit
2695 });
2696 var webkit = typeof CSS !== "undefined" && !!CSS.supports?.("-webkit-backdrop-filter:none");
2697 var gecko = !webkit && lowerUserAgent.includes("firefox");
2698 var blink = !webkit && lowerUserAgent.includes("chrom");
2699
2700 // node_modules/@base-ui/utils/platform/screen-reader.mjs
2701 var screen_reader_exports = {};
2702 __export(screen_reader_exports, {
2703 voiceOver: () => voiceOver
2704 });
2705 var voiceOver = apple;
2706
2707 // node_modules/@base-ui/utils/platform/env.mjs
2708 var env_exports = {};
2709 __export(env_exports, {
2710 jsdom: () => jsdom
2711 });
2712 var jsdom = /jsdom|happydom/.test(lowerUserAgent);
2713
2714 // node_modules/@base-ui/utils/platform/media-query.mjs
2715 var media_query_exports = {};
2716 __export(media_query_exports, {
2717 iOS: () => iOS
2718 });
2719 var iOS = "@supports (-webkit-touch-callout: none)";
2720
2721 // node_modules/@base-ui/utils/useTimeout.mjs
2722 var EMPTY2 = 0;
2723 var Timeout = class _Timeout {
2724 static create() {
2725 return new _Timeout();
2726 }
2727 currentId = EMPTY2;
2728 /**
2729 * Executes `fn` after `delay`, clearing any previously scheduled call.
2730 */
2731 start(delay, fn) {
2732 this.clear();
2733 this.currentId = setTimeout(() => {
2734 this.currentId = EMPTY2;
2735 fn();
2736 }, delay);
2737 }
2738 isStarted() {
2739 return this.currentId !== EMPTY2;
2740 }
2741 clear = () => {
2742 if (this.currentId !== EMPTY2) {
2743 clearTimeout(this.currentId);
2744 this.currentId = EMPTY2;
2745 }
2746 };
2747 disposeEffect = () => {
2748 return this.clear;
2749 };
2750 };
2751 function useTimeout() {
2752 const timeout = useRefWithInit(Timeout.create).current;
2753 useOnMount(timeout.disposeEffect);
2754 return timeout;
2755 }
2756
2757 // node_modules/@base-ui/react/floating-ui-react/components/FloatingDelayGroup.mjs
2758 var React21 = __toESM(require_react(), 1);
2759
2760 // node_modules/@base-ui/react/floating-ui-react/utils/event.mjs
2761 function isReactEvent(event) {
2762 return "nativeEvent" in event;
2763 }
2764 function isVirtualClick(event) {
2765 if (event.pointerType === "" && event.isTrusted) {
2766 return true;
2767 }
2768 if (parts_exports.os.android && event.pointerType) {
2769 return event.type === "click" && event.buttons === 1;
2770 }
2771 return event.detail === 0 && !event.pointerType;
2772 }
2773 function isMouseLikePointerType(pointerType, strict) {
2774 const values = ["mouse", "pen"];
2775 if (!strict) {
2776 values.push("", void 0);
2777 }
2778 return values.includes(pointerType);
2779 }
2780 function isClickLikeEvent(event) {
2781 const type = event.type;
2782 return type === "click" || type === "mousedown" || type === "keydown" || type === "keyup";
2783 }
2784
2785 // node_modules/@base-ui/utils/shadowDom.mjs
2786 function activeElement(doc) {
2787 let element = doc.activeElement;
2788 while (element?.shadowRoot?.activeElement != null) {
2789 element = element.shadowRoot.activeElement;
2790 }
2791 return element;
2792 }
2793 function contains(parent, child) {
2794 if (!parent || !child) {
2795 return false;
2796 }
2797 const rootNode = child.getRootNode?.();
2798 if (parent.contains(child)) {
2799 return true;
2800 }
2801 if (rootNode && isShadowRoot(rootNode)) {
2802 let next = child;
2803 while (next) {
2804 if (parent === next) {
2805 return true;
2806 }
2807 next = next.parentNode || next.host;
2808 }
2809 }
2810 return false;
2811 }
2812 function getTarget(event) {
2813 if ("composedPath" in event) {
2814 return event.composedPath()[0] ?? event.target;
2815 }
2816 return event.target;
2817 }
2818
2819 // node_modules/@base-ui/react/floating-ui-react/utils/constants.mjs
2820 var FOCUSABLE_ATTRIBUTE = "data-base-ui-focusable";
2821 var TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
2822
2823 // node_modules/@base-ui/react/utils/CommonPopupDataAttributes.mjs
2824 var open2 = "data-open";
2825 var closed2 = "data-closed";
2826 var anchorHidden = "data-anchor-hidden";
2827
2828 // node_modules/@base-ui/react/utils/CommonTriggerDataAttributes.mjs
2829 var CommonTriggerDataAttributes_exports = {};
2830 __export(CommonTriggerDataAttributes_exports, {
2831 popupOpen: () => popupOpen,
2832 pressed: () => pressed
2833 });
2834 var popupOpen = "data-popup-open";
2835 var pressed = "data-pressed";
2836
2837 // node_modules/@base-ui/react/utils/popupStateMapping.mjs
2838 var TRIGGER_HOOK = {
2839 [popupOpen]: ""
2840 };
2841 var PRESSABLE_TRIGGER_HOOK = {
2842 [popupOpen]: "",
2843 [pressed]: ""
2844 };
2845 var POPUP_OPEN_HOOK = {
2846 [open2]: ""
2847 };
2848 var POPUP_CLOSED_HOOK = {
2849 [closed2]: ""
2850 };
2851 var ANCHOR_HIDDEN_HOOK = {
2852 [anchorHidden]: ""
2853 };
2854 var triggerOpenStateMapping2 = {
2855 open(value) {
2856 if (value) {
2857 return TRIGGER_HOOK;
2858 }
2859 return null;
2860 }
2861 };
2862 var popupStateMapping = {
2863 open(value) {
2864 if (value) {
2865 return POPUP_OPEN_HOOK;
2866 }
2867 return POPUP_CLOSED_HOOK;
2868 },
2869 anchorHidden(value) {
2870 if (value) {
2871 return ANCHOR_HIDDEN_HOOK;
2872 }
2873 return null;
2874 }
2875 };
2876 var popupTransitionStateMapping = {
2877 ...popupStateMapping,
2878 ...transitionStatusMapping
2879 };
2880
2881 // node_modules/@base-ui/react/tooltip/trigger/TooltipTriggerDataAttributes.mjs
2882 var popupOpen2 = CommonTriggerDataAttributes_exports.popupOpen;
2883 var triggerDisabled = "data-trigger-disabled";
2884
2885 // node_modules/@base-ui/react/floating-ui-react/utils/element.mjs
2886 function isTargetInsideEnabledTrigger(target, triggerElements) {
2887 if (!isElement(target)) {
2888 return false;
2889 }
2890 const targetElement = target;
2891 if (triggerElements.hasElement(targetElement)) {
2892 return !targetElement.hasAttribute(triggerDisabled);
2893 }
2894 for (const [, trigger] of triggerElements.entries()) {
2895 if (contains(trigger, targetElement)) {
2896 return !trigger.hasAttribute(triggerDisabled);
2897 }
2898 }
2899 return false;
2900 }
2901 function isEventTargetWithin(event, node) {
2902 if (node == null) {
2903 return false;
2904 }
2905 if ("composedPath" in event) {
2906 return event.composedPath().includes(node);
2907 }
2908 const eventAgain = event;
2909 return eventAgain.target != null && node.contains(eventAgain.target);
2910 }
2911 function isRootElement(element) {
2912 return element.matches("html,body");
2913 }
2914 function isTypeableElement(element) {
2915 return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR);
2916 }
2917 function isInteractiveElement(element) {
2918 return element?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${TYPEABLE_SELECTOR}`) != null;
2919 }
2920 function matchesFocusVisible(element) {
2921 if (!element || parts_exports.env.jsdom) {
2922 return true;
2923 }
2924 try {
2925 return element.matches(":focus-visible");
2926 } catch (_e) {
2927 return true;
2928 }
2929 }
2930
2931 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverShared.mjs
2932 function resolveValue(value, pointerType) {
2933 if (pointerType != null && !isMouseLikePointerType(pointerType)) {
2934 return 0;
2935 }
2936 if (typeof value === "function") {
2937 return value();
2938 }
2939 return value;
2940 }
2941 function getDelay(value, prop, pointerType) {
2942 const result = resolveValue(value, pointerType);
2943 if (typeof result === "number") {
2944 return result;
2945 }
2946 return result?.[prop];
2947 }
2948 function getRestMs(value) {
2949 if (typeof value === "function") {
2950 return value();
2951 }
2952 return value;
2953 }
2954 function isClickLikeOpenEvent(openEventType, interactedInside) {
2955 return interactedInside || openEventType === "click" || openEventType === "mousedown";
2956 }
2957 function isHoverOpenEvent(openEventType) {
2958 return openEventType?.includes("mouse") && openEventType !== "mousedown";
2959 }
2960
2961 // node_modules/@base-ui/react/floating-ui-react/components/FloatingDelayGroup.mjs
2962 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
2963 var FloatingDelayGroupContext = /* @__PURE__ */ React21.createContext({
2964 hasProvider: false,
2965 timeoutMs: 0,
2966 delayRef: {
2967 current: 0
2968 },
2969 initialDelayRef: {
2970 current: 0
2971 },
2972 timeout: new Timeout(),
2973 currentIdRef: {
2974 current: null
2975 },
2976 currentContextRef: {
2977 current: null
2978 }
2979 });
2980 if (true) FloatingDelayGroupContext.displayName = "FloatingDelayGroupContext";
2981 function resetDelayRef(delayRef, initialDelayRef) {
2982 delayRef.current = initialDelayRef.current;
2983 }
2984 function FloatingDelayGroup(props) {
2985 const {
2986 children,
2987 delay,
2988 timeoutMs = 0
2989 } = props;
2990 const delayRef = React21.useRef(delay);
2991 const initialDelayRef = React21.useRef(delay);
2992 const currentIdRef = React21.useRef(null);
2993 const currentContextRef = React21.useRef(null);
2994 const timeout = useTimeout();
2995 useIsoLayoutEffect(() => {
2996 initialDelayRef.current = delay;
2997 if (!currentIdRef.current) {
2998 delayRef.current = delay;
2999 return;
3000 }
3001 delayRef.current = {
3002 open: getDelay(delayRef.current, "open"),
3003 close: getDelay(delay, "close")
3004 };
3005 }, [delay, currentIdRef, delayRef, initialDelayRef]);
3006 return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(FloatingDelayGroupContext.Provider, {
3007 value: React21.useMemo(() => ({
3008 hasProvider: true,
3009 delayRef,
3010 initialDelayRef,
3011 currentIdRef,
3012 timeoutMs,
3013 currentContextRef,
3014 timeout
3015 }), [timeoutMs, timeout]),
3016 children
3017 });
3018 }
3019 function useDelayGroup(context, options = {
3020 open: false
3021 }) {
3022 const {
3023 open: open3
3024 } = options;
3025 const store2 = "rootStore" in context ? context.rootStore : context;
3026 const floatingId = store2.useState("floatingId");
3027 const groupContext = React21.useContext(FloatingDelayGroupContext);
3028 const {
3029 currentIdRef,
3030 delayRef,
3031 timeoutMs,
3032 initialDelayRef,
3033 currentContextRef,
3034 hasProvider,
3035 timeout
3036 } = groupContext;
3037 const [isInstantPhase, setIsInstantPhase] = React21.useState(false);
3038 const openRef = React21.useRef(open3);
3039 useIsoLayoutEffect(() => {
3040 openRef.current = open3;
3041 }, [open3]);
3042 useIsoLayoutEffect(() => {
3043 function unset() {
3044 currentContextRef.current?.setIsInstantPhase(false);
3045 currentIdRef.current = null;
3046 currentContextRef.current = null;
3047 delayRef.current = initialDelayRef.current;
3048 timeout.clear();
3049 }
3050 if (!currentIdRef.current) {
3051 return void 0;
3052 }
3053 if (!open3 && currentIdRef.current === floatingId) {
3054 setIsInstantPhase(false);
3055 if (timeoutMs) {
3056 const closingId = floatingId;
3057 timeout.start(timeoutMs, () => {
3058 if (store2.select("open") || currentIdRef.current && currentIdRef.current !== closingId) {
3059 return;
3060 }
3061 unset();
3062 });
3063 return () => {
3064 if (openRef.current || currentIdRef.current !== closingId) {
3065 timeout.clear();
3066 }
3067 };
3068 }
3069 unset();
3070 }
3071 return void 0;
3072 }, [open3, floatingId, currentIdRef, delayRef, timeoutMs, initialDelayRef, currentContextRef, timeout, store2]);
3073 useIsoLayoutEffect(() => {
3074 if (!open3) {
3075 return;
3076 }
3077 const prevContext = currentContextRef.current;
3078 const prevId = currentIdRef.current;
3079 timeout.clear();
3080 currentContextRef.current = {
3081 onOpenChange: store2.setOpen,
3082 setIsInstantPhase
3083 };
3084 currentIdRef.current = floatingId;
3085 delayRef.current = {
3086 open: 0,
3087 close: getDelay(initialDelayRef.current, "close")
3088 };
3089 if (prevId !== null && prevId !== floatingId) {
3090 setIsInstantPhase(true);
3091 prevContext?.setIsInstantPhase(true);
3092 prevContext?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.none));
3093 } else {
3094 setIsInstantPhase(false);
3095 prevContext?.setIsInstantPhase(false);
3096 }
3097 }, [open3, floatingId, store2, currentIdRef, delayRef, initialDelayRef, currentContextRef, timeout]);
3098 useIsoLayoutEffect(() => {
3099 return () => {
3100 if (currentIdRef.current === floatingId) {
3101 currentContextRef.current = null;
3102 if (!openRef.current) {
3103 return;
3104 }
3105 currentIdRef.current = null;
3106 resetDelayRef(delayRef, initialDelayRef);
3107 timeout.clear();
3108 }
3109 };
3110 }, [currentContextRef, currentIdRef, delayRef, floatingId, initialDelayRef, timeout]);
3111 return React21.useMemo(() => ({
3112 activeIdRef: currentIdRef,
3113 hasProvider,
3114 delayRef,
3115 isInstantPhase
3116 }), [currentIdRef, hasProvider, delayRef, isInstantPhase]);
3117 }
3118
3119 // node_modules/@base-ui/utils/mergeCleanups.mjs
3120 function mergeCleanups(...cleanups) {
3121 return () => {
3122 for (let i = 0; i < cleanups.length; i += 1) {
3123 const cleanup = cleanups[i];
3124 if (cleanup) {
3125 cleanup();
3126 }
3127 }
3128 };
3129 }
3130
3131 // node_modules/@base-ui/react/utils/FocusGuard.mjs
3132 var React22 = __toESM(require_react(), 1);
3133
3134 // node_modules/@base-ui/utils/visuallyHidden.mjs
3135 var visuallyHiddenBase = {
3136 clipPath: "inset(50%)",
3137 overflow: "hidden",
3138 whiteSpace: "nowrap",
3139 border: 0,
3140 padding: 0,
3141 width: 1,
3142 height: 1,
3143 margin: -1
3144 };
3145 var visuallyHidden = {
3146 ...visuallyHiddenBase,
3147 position: "fixed",
3148 top: 0,
3149 left: 0
3150 };
3151 var visuallyHiddenInput = {
3152 ...visuallyHiddenBase,
3153 position: "absolute"
3154 };
3155
3156 // node_modules/@base-ui/react/utils/FocusGuard.mjs
3157 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
3158 var FocusGuard = /* @__PURE__ */ React22.forwardRef(function FocusGuard2(props, ref) {
3159 const [role, setRole] = React22.useState();
3160 useIsoLayoutEffect(() => {
3161 if (parts_exports.screenReader.voiceOver && parts_exports.engine.webkit) {
3162 setRole("button");
3163 }
3164 }, []);
3165 const restProps = {
3166 tabIndex: 0,
3167 // Role is only for VoiceOver
3168 role
3169 };
3170 return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", {
3171 ...props,
3172 ref,
3173 style: visuallyHidden,
3174 "aria-hidden": role ? void 0 : true,
3175 ...restProps,
3176 "data-base-ui-focus-guard": ""
3177 });
3178 });
3179 if (true) FocusGuard.displayName = "FocusGuard";
3180
3181 // node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
3182 var min = Math.min;
3183 var max = Math.max;
3184 var round = Math.round;
3185 var floor = Math.floor;
3186 var createCoords = (v2) => ({
3187 x: v2,
3188 y: v2
3189 });
3190 var oppositeSideMap = {
3191 left: "right",
3192 right: "left",
3193 bottom: "top",
3194 top: "bottom"
3195 };
3196 function clamp(start, value, end) {
3197 return max(start, min(value, end));
3198 }
3199 function evaluate(value, param) {
3200 return typeof value === "function" ? value(param) : value;
3201 }
3202 function getSide(placement) {
3203 return placement.split("-")[0];
3204 }
3205 function getAlignment(placement) {
3206 return placement.split("-")[1];
3207 }
3208 function getOppositeAxis(axis) {
3209 return axis === "x" ? "y" : "x";
3210 }
3211 function getAxisLength(axis) {
3212 return axis === "y" ? "height" : "width";
3213 }
3214 function getSideAxis(placement) {
3215 const firstChar = placement[0];
3216 return firstChar === "t" || firstChar === "b" ? "y" : "x";
3217 }
3218 function getAlignmentAxis(placement) {
3219 return getOppositeAxis(getSideAxis(placement));
3220 }
3221 function getAlignmentSides(placement, rects, rtl) {
3222 if (rtl === void 0) {
3223 rtl = false;
3224 }
3225 const alignment = getAlignment(placement);
3226 const alignmentAxis = getAlignmentAxis(placement);
3227 const length2 = getAxisLength(alignmentAxis);
3228 let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
3229 if (rects.reference[length2] > rects.floating[length2]) {
3230 mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
3231 }
3232 return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
3233 }
3234 function getExpandedPlacements(placement) {
3235 const oppositePlacement = getOppositePlacement(placement);
3236 return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
3237 }
3238 function getOppositeAlignmentPlacement(placement) {
3239 return placement.includes("start") ? placement.replace("start", "end") : placement.replace("end", "start");
3240 }
3241 var lrPlacement = ["left", "right"];
3242 var rlPlacement = ["right", "left"];
3243 var tbPlacement = ["top", "bottom"];
3244 var btPlacement = ["bottom", "top"];
3245 function getSideList(side, isStart, rtl) {
3246 switch (side) {
3247 case "top":
3248 case "bottom":
3249 if (rtl) return isStart ? rlPlacement : lrPlacement;
3250 return isStart ? lrPlacement : rlPlacement;
3251 case "left":
3252 case "right":
3253 return isStart ? tbPlacement : btPlacement;
3254 default:
3255 return [];
3256 }
3257 }
3258 function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
3259 const alignment = getAlignment(placement);
3260 let list = getSideList(getSide(placement), direction === "start", rtl);
3261 if (alignment) {
3262 list = list.map((side) => side + "-" + alignment);
3263 if (flipAlignment) {
3264 list = list.concat(list.map(getOppositeAlignmentPlacement));
3265 }
3266 }
3267 return list;
3268 }
3269 function getOppositePlacement(placement) {
3270 const side = getSide(placement);
3271 return oppositeSideMap[side] + placement.slice(side.length);
3272 }
3273 function expandPaddingObject(padding) {
3274 var _padding$top, _padding$right, _padding$bottom, _padding$left;
3275 return {
3276 top: (_padding$top = padding.top) != null ? _padding$top : 0,
3277 right: (_padding$right = padding.right) != null ? _padding$right : 0,
3278 bottom: (_padding$bottom = padding.bottom) != null ? _padding$bottom : 0,
3279 left: (_padding$left = padding.left) != null ? _padding$left : 0
3280 };
3281 }
3282 function getPaddingObject(padding) {
3283 return typeof padding !== "number" ? expandPaddingObject(padding) : {
3284 top: padding,
3285 right: padding,
3286 bottom: padding,
3287 left: padding
3288 };
3289 }
3290 function rectToClientRect(rect) {
3291 const {
3292 x: x2,
3293 y: y2,
3294 width,
3295 height
3296 } = rect;
3297 return {
3298 width,
3299 height,
3300 top: y2,
3301 left: x2,
3302 right: x2 + width,
3303 bottom: y2 + height,
3304 x: x2,
3305 y: y2
3306 };
3307 }
3308
3309 // node_modules/@base-ui/react/floating-ui-react/utils/composite.mjs
3310 function isIndexOutOfListBounds(list, index3) {
3311 return index3 < 0 || index3 >= list.length;
3312 }
3313 function getMinListIndex(listRef, disabledIndices) {
3314 return findNonDisabledListIndex(listRef.current, {
3315 disabledIndices
3316 });
3317 }
3318 function getMaxListIndex(listRef, disabledIndices) {
3319 return findNonDisabledListIndex(listRef.current, {
3320 decrement: true,
3321 startingIndex: listRef.current.length,
3322 disabledIndices
3323 });
3324 }
3325 function findNonDisabledListIndex(list, {
3326 startingIndex = -1,
3327 decrement = false,
3328 disabledIndices,
3329 amount = 1
3330 } = {}) {
3331 let index3 = startingIndex;
3332 do {
3333 index3 += decrement ? -amount : amount;
3334 } while (index3 >= 0 && index3 <= list.length - 1 && isListIndexDisabled(list, index3, disabledIndices));
3335 return index3;
3336 }
3337 function isListIndexDisabled(list, index3, disabledIndices) {
3338 const isExplicitlyDisabled = typeof disabledIndices === "function" ? disabledIndices(index3) : disabledIndices?.includes(index3) ?? false;
3339 if (isExplicitlyDisabled) {
3340 return true;
3341 }
3342 const element = list[index3];
3343 if (!element) {
3344 return false;
3345 }
3346 if (!isElementVisible(element)) {
3347 return true;
3348 }
3349 if (element.matches(":disabled")) {
3350 return true;
3351 }
3352 return !disabledIndices && (element.hasAttribute("disabled") || element.getAttribute("aria-disabled") === "true");
3353 }
3354 function isHiddenByStyles(styles) {
3355 return styles.visibility === "hidden" || styles.visibility === "collapse";
3356 }
3357 function isElementVisible(element, styles = element ? getComputedStyle2(element) : null) {
3358 if (!element || !element.isConnected || !styles || isHiddenByStyles(styles)) {
3359 return false;
3360 }
3361 if (typeof element.checkVisibility === "function") {
3362 return element.checkVisibility();
3363 }
3364 return styles.display !== "none" && styles.display !== "contents";
3365 }
3366
3367 // node_modules/@base-ui/react/floating-ui-react/utils/tabbable.mjs
3368 var CANDIDATE_SELECTOR = 'a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';
3369 function getParentElement(element) {
3370 const assignedSlot = element.assignedSlot;
3371 if (assignedSlot) {
3372 return assignedSlot;
3373 }
3374 if (element.parentElement) {
3375 return element.parentElement;
3376 }
3377 const rootNode = element.getRootNode();
3378 return isShadowRoot(rootNode) ? rootNode.host : null;
3379 }
3380 function getDetailsSummary(details) {
3381 for (const child of Array.from(details.children)) {
3382 if (getNodeName(child) === "summary") {
3383 return child;
3384 }
3385 }
3386 return null;
3387 }
3388 function isWithinOpenDetailsSummary(element, details) {
3389 const summary = getDetailsSummary(details);
3390 return !!summary && (element === summary || contains(summary, element));
3391 }
3392 function isFocusableCandidate(element) {
3393 const nodeName = element ? getNodeName(element) : "";
3394 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");
3395 }
3396 function isFocusableElement(element) {
3397 if (!isFocusableCandidate(element) || !element.isConnected || element.matches(":disabled")) {
3398 return false;
3399 }
3400 for (let current = element; current; current = getParentElement(current)) {
3401 const isAncestor = current !== element;
3402 const isSlot = getNodeName(current) === "slot";
3403 if (current.hasAttribute("inert")) {
3404 return false;
3405 }
3406 if (isAncestor && getNodeName(current) === "details" && !current.open && !isWithinOpenDetailsSummary(element, current) || current.hasAttribute("hidden") || !isSlot && !isVisibleInTabbableTree(current, isAncestor)) {
3407 return false;
3408 }
3409 }
3410 return true;
3411 }
3412 function isVisibleInTabbableTree(element, isAncestor) {
3413 const styles = getComputedStyle2(element);
3414 if (!isAncestor) {
3415 return isElementVisible(element, styles);
3416 }
3417 return styles.display !== "none";
3418 }
3419 function getTabIndex(element) {
3420 const tabIndex = element.tabIndex;
3421 if (tabIndex < 0) {
3422 const nodeName = getNodeName(element);
3423 if (nodeName === "details" || nodeName === "audio" || nodeName === "video" || isHTMLElement(element) && element.isContentEditable) {
3424 return 0;
3425 }
3426 }
3427 return tabIndex;
3428 }
3429 function getNamedRadioInput(element) {
3430 if (getNodeName(element) !== "input") {
3431 return null;
3432 }
3433 const input = element;
3434 return input.type === "radio" && input.name !== "" ? input : null;
3435 }
3436 function isTabbableRadio(element, candidates) {
3437 const input = getNamedRadioInput(element);
3438 if (!input) {
3439 return true;
3440 }
3441 const checkedRadio = candidates.find((candidate) => {
3442 const radio = getNamedRadioInput(candidate);
3443 return radio?.name === input.name && radio.form === input.form && radio.checked;
3444 });
3445 if (checkedRadio) {
3446 return checkedRadio === input;
3447 }
3448 return candidates.find((candidate) => {
3449 const radio = getNamedRadioInput(candidate);
3450 return radio?.name === input.name && radio.form === input.form;
3451 }) === input;
3452 }
3453 function getComposedChildren(container) {
3454 if (isHTMLElement(container) && getNodeName(container) === "slot") {
3455 const assignedElements = container.assignedElements({
3456 flatten: true
3457 });
3458 if (assignedElements.length > 0) {
3459 return assignedElements;
3460 }
3461 }
3462 if (isHTMLElement(container) && container.shadowRoot) {
3463 return Array.from(container.shadowRoot.children);
3464 }
3465 return Array.from(container.children);
3466 }
3467 function appendCandidates(container, list) {
3468 getComposedChildren(container).forEach((child) => {
3469 if (isFocusableCandidate(child)) {
3470 list.push(child);
3471 }
3472 appendCandidates(child, list);
3473 });
3474 }
3475 function appendMatchingElements(container, selector, list) {
3476 getComposedChildren(container).forEach((child) => {
3477 if (isHTMLElement(child) && child.matches(selector)) {
3478 list.push(child);
3479 }
3480 appendMatchingElements(child, selector, list);
3481 });
3482 }
3483 function focusable(container) {
3484 const candidates = [];
3485 appendCandidates(container, candidates);
3486 return candidates.filter(isFocusableElement);
3487 }
3488 function tabbable(container) {
3489 const candidates = focusable(container);
3490 return candidates.filter((element) => getTabIndex(element) >= 0 && isTabbableRadio(element, candidates));
3491 }
3492 function getTabbableIn(container, dir) {
3493 const list = tabbable(container);
3494 const len2 = list.length;
3495 if (len2 === 0) {
3496 return void 0;
3497 }
3498 const active = activeElement(ownerDocument(container));
3499 const index3 = list.indexOf(active);
3500 const nextIndex = index3 === -1 ? dir === 1 ? 0 : len2 - 1 : index3 + dir;
3501 return list[nextIndex];
3502 }
3503 function getNextTabbable(referenceElement) {
3504 return getTabbableIn(ownerDocument(referenceElement).body, 1) || referenceElement;
3505 }
3506 function getPreviousTabbable(referenceElement) {
3507 return getTabbableIn(ownerDocument(referenceElement).body, -1) || referenceElement;
3508 }
3509 function isOutsideEvent(event, container) {
3510 const containerElement = container || event.currentTarget;
3511 const relatedTarget = event.relatedTarget;
3512 return !relatedTarget || !contains(containerElement, relatedTarget);
3513 }
3514 function disableFocusInside(container) {
3515 const tabbableElements = tabbable(container);
3516 tabbableElements.forEach((element) => {
3517 element.dataset.tabindex = element.getAttribute("tabindex") || "";
3518 element.setAttribute("tabindex", "-1");
3519 });
3520 }
3521 function enableFocusInside(container) {
3522 const elements = [];
3523 appendMatchingElements(container, "[data-tabindex]", elements);
3524 elements.forEach((element) => {
3525 const tabindex = element.dataset.tabindex;
3526 delete element.dataset.tabindex;
3527 if (tabindex) {
3528 element.setAttribute("tabindex", tabindex);
3529 } else {
3530 element.removeAttribute("tabindex");
3531 }
3532 });
3533 }
3534
3535 // node_modules/@base-ui/react/floating-ui-react/utils/nodes.mjs
3536 function getNodeChildren(nodes, id, onlyOpenChildren = true) {
3537 const directChildren = nodes.filter((node) => node.parentId === id);
3538 return directChildren.flatMap((child) => [...!onlyOpenChildren || child.context?.open ? [child] : [], ...getNodeChildren(nodes, child.id, onlyOpenChildren)]);
3539 }
3540
3541 // node_modules/@base-ui/react/floating-ui-react/utils/createAttribute.mjs
3542 function createAttribute(name) {
3543 return `data-base-ui-${name}`;
3544 }
3545
3546 // node_modules/@base-ui/react/floating-ui-react/components/FloatingPortal.mjs
3547 var React23 = __toESM(require_react(), 1);
3548 var ReactDOM2 = __toESM(require_react_dom(), 1);
3549
3550 // node_modules/@base-ui/react/internals/constants.mjs
3551 var DISABLED_TRANSITIONS_STYLE = {
3552 style: {
3553 transition: "none"
3554 }
3555 };
3556 var BASE_UI_SWIPE_IGNORE_ATTRIBUTE = "data-base-ui-swipe-ignore";
3557 var LEGACY_SWIPE_IGNORE_ATTRIBUTE = "data-swipe-ignore";
3558 var BASE_UI_SWIPE_IGNORE_SELECTOR = `[${BASE_UI_SWIPE_IGNORE_ATTRIBUTE}]`;
3559 var LEGACY_SWIPE_IGNORE_SELECTOR = `[${LEGACY_SWIPE_IGNORE_ATTRIBUTE}]`;
3560 var POPUP_COLLISION_AVOIDANCE = {
3561 fallbackAxisSide: "end"
3562 };
3563 var ownerVisuallyHidden = {
3564 clipPath: "inset(50%)",
3565 position: "fixed",
3566 top: 0,
3567 left: 0
3568 };
3569
3570 // node_modules/@base-ui/react/floating-ui-react/components/FloatingPortal.mjs
3571 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
3572 var PortalContext = /* @__PURE__ */ React23.createContext(null);
3573 if (true) PortalContext.displayName = "PortalContext";
3574 var usePortalContext = () => React23.useContext(PortalContext);
3575 var attr = createAttribute("portal");
3576 function useFloatingPortalNode(props = {}) {
3577 const {
3578 ref,
3579 container: containerProp,
3580 componentProps = EMPTY_OBJECT,
3581 elementProps
3582 } = props;
3583 const uniqueId = useId();
3584 const portalContext = usePortalContext();
3585 const parentPortalNode = portalContext?.portalNode;
3586 const [containerElement, setContainerElement] = React23.useState(null);
3587 const [portalNode, setPortalNode] = React23.useState(null);
3588 const setPortalNodeRef = useStableCallback((node) => {
3589 if (node !== null) {
3590 setPortalNode(node);
3591 }
3592 });
3593 const containerRef = React23.useRef(null);
3594 useIsoLayoutEffect(() => {
3595 if (containerProp === null) {
3596 if (containerRef.current) {
3597 containerRef.current = null;
3598 setPortalNode(null);
3599 setContainerElement(null);
3600 }
3601 return;
3602 }
3603 const resolvedContainer = (containerProp && (isNode(containerProp) ? containerProp : containerProp.current)) ?? parentPortalNode ?? document.body;
3604 if (resolvedContainer == null) {
3605 if (containerRef.current) {
3606 containerRef.current = null;
3607 setPortalNode(null);
3608 setContainerElement(null);
3609 }
3610 return;
3611 }
3612 if (containerRef.current !== resolvedContainer) {
3613 containerRef.current = resolvedContainer;
3614 setPortalNode(null);
3615 setContainerElement(resolvedContainer);
3616 }
3617 }, [containerProp, parentPortalNode]);
3618 const portalElement = useRenderElement("div", componentProps, {
3619 ref: [ref, setPortalNodeRef],
3620 props: [{
3621 id: uniqueId,
3622 [attr]: ""
3623 }, elementProps]
3624 });
3625 const portalSubtree = containerElement && portalElement ? /* @__PURE__ */ ReactDOM2.createPortal(portalElement, containerElement) : null;
3626 return {
3627 node: portalNode,
3628 // `id` and `render` props can override or remove the generated ID. Use the exact
3629 // rendered value so `aria-owns` never points at an ID absent from the DOM.
3630 nodeId: /* @__PURE__ */ React23.isValidElement(portalElement) ? portalElement.props.id : void 0,
3631 subtree: portalSubtree
3632 };
3633 }
3634 var FloatingPortal = /* @__PURE__ */ React23.forwardRef(function FloatingPortal2(componentProps, forwardedRef) {
3635 const {
3636 render: render4,
3637 className,
3638 style,
3639 children,
3640 container,
3641 portalOwnerRole,
3642 ...elementProps
3643 } = componentProps;
3644 const {
3645 node: portalNode,
3646 nodeId: portalNodeId,
3647 subtree: portalSubtree
3648 } = useFloatingPortalNode({
3649 container,
3650 ref: forwardedRef,
3651 componentProps,
3652 elementProps
3653 });
3654 const beforeOutsideRef = React23.useRef(null);
3655 const afterOutsideRef = React23.useRef(null);
3656 const beforeInsideRef = React23.useRef(null);
3657 const afterInsideRef = React23.useRef(null);
3658 const [focusManagerState, setFocusManagerState] = React23.useState(null);
3659 const focusInsideDisabledRef = React23.useRef(false);
3660 const modal = focusManagerState?.modal;
3661 const open3 = focusManagerState?.open;
3662 const shouldRenderGuards = !!focusManagerState && !focusManagerState.modal && focusManagerState.open && !!portalNode;
3663 React23.useEffect(() => {
3664 if (!portalNode || modal) {
3665 return void 0;
3666 }
3667 function onFocus(event) {
3668 if (portalNode && event.relatedTarget && isOutsideEvent(event)) {
3669 if (event.type === "focusin") {
3670 if (focusInsideDisabledRef.current) {
3671 enableFocusInside(portalNode);
3672 focusInsideDisabledRef.current = false;
3673 }
3674 } else {
3675 disableFocusInside(portalNode);
3676 focusInsideDisabledRef.current = true;
3677 }
3678 }
3679 }
3680 return mergeCleanups(addEventListener(portalNode, "focusin", onFocus, true), addEventListener(portalNode, "focusout", onFocus, true));
3681 }, [portalNode, modal]);
3682 useIsoLayoutEffect(() => {
3683 if (!portalNode || open3 !== true || !focusInsideDisabledRef.current) {
3684 return;
3685 }
3686 enableFocusInside(portalNode);
3687 focusInsideDisabledRef.current = false;
3688 }, [open3, portalNode]);
3689 const portalContextValue = React23.useMemo(() => ({
3690 beforeOutsideRef,
3691 afterOutsideRef,
3692 beforeInsideRef,
3693 afterInsideRef,
3694 portalNode,
3695 setFocusManagerState
3696 }), [portalNode]);
3697 return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(React23.Fragment, {
3698 children: [portalSubtree, /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(PortalContext.Provider, {
3699 value: portalContextValue,
3700 children: [shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(FocusGuard, {
3701 "data-type": "outside",
3702 ref: beforeOutsideRef,
3703 onFocus: (event) => {
3704 if (isOutsideEvent(event, portalNode)) {
3705 beforeInsideRef.current?.focus();
3706 } else {
3707 const domReference = focusManagerState ? focusManagerState.domReference : null;
3708 const prevTabbable = getPreviousTabbable(domReference);
3709 prevTabbable?.focus();
3710 }
3711 }
3712 }), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", {
3713 role: portalOwnerRole,
3714 "aria-owns": portalNodeId,
3715 style: ownerVisuallyHidden
3716 }), portalNode && /* @__PURE__ */ ReactDOM2.createPortal(children, portalNode), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(FocusGuard, {
3717 "data-type": "outside",
3718 ref: afterOutsideRef,
3719 onFocus: (event) => {
3720 if (isOutsideEvent(event, portalNode)) {
3721 afterInsideRef.current?.focus();
3722 } else {
3723 const domReference = focusManagerState ? focusManagerState.domReference : null;
3724 const nextTabbable = getNextTabbable(domReference);
3725 nextTabbable?.focus();
3726 if (focusManagerState?.closeOnFocusOut) {
3727 focusManagerState?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.focusOut, event.nativeEvent));
3728 }
3729 }
3730 }
3731 })]
3732 })]
3733 });
3734 });
3735 if (true) FloatingPortal.displayName = "FloatingPortal";
3736
3737 // node_modules/@base-ui/react/floating-ui-react/components/FloatingTree.mjs
3738 var React24 = __toESM(require_react(), 1);
3739
3740 // node_modules/@base-ui/react/floating-ui-react/utils/createEventEmitter.mjs
3741 function createEventEmitter() {
3742 const map = /* @__PURE__ */ new Map();
3743 return {
3744 emit(event, data) {
3745 map.get(event)?.forEach((listener) => listener(data));
3746 },
3747 on(event, listener) {
3748 if (!map.has(event)) {
3749 map.set(event, /* @__PURE__ */ new Set());
3750 }
3751 map.get(event).add(listener);
3752 },
3753 off(event, listener) {
3754 map.get(event)?.delete(listener);
3755 }
3756 };
3757 }
3758
3759 // node_modules/@base-ui/react/floating-ui-react/components/FloatingTree.mjs
3760 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
3761 var FloatingNodeContext = /* @__PURE__ */ React24.createContext(null);
3762 if (true) FloatingNodeContext.displayName = "FloatingNodeContext";
3763 var FloatingTreeContext = /* @__PURE__ */ React24.createContext(null);
3764 if (true) FloatingTreeContext.displayName = "FloatingTreeContext";
3765 var useFloatingParentNodeId = () => React24.useContext(FloatingNodeContext)?.id || null;
3766 var useFloatingTree = (externalTree) => {
3767 const contextTree = React24.useContext(FloatingTreeContext);
3768 return externalTree ?? contextTree;
3769 };
3770
3771 // node_modules/@base-ui/react/floating-ui-react/hooks/useClientPoint.mjs
3772 var React25 = __toESM(require_react(), 1);
3773 function createVirtualElement(domElement, data) {
3774 let offsetX = null;
3775 let offsetY = null;
3776 let isAutoUpdateEvent = false;
3777 return {
3778 contextElement: domElement || void 0,
3779 getBoundingClientRect() {
3780 const domRect = domElement?.getBoundingClientRect() || {
3781 width: 0,
3782 height: 0,
3783 x: 0,
3784 y: 0
3785 };
3786 const isXAxis = data.axis === "x" || data.axis === "both";
3787 const isYAxis = data.axis === "y" || data.axis === "both";
3788 const canTrackCursorOnAutoUpdate = ["mouseenter", "mousemove"].includes(data.dataRef.current.openEvent?.type || "") && data.pointerType !== "touch";
3789 let width = domRect.width;
3790 let height = domRect.height;
3791 let x2 = domRect.x;
3792 let y2 = domRect.y;
3793 if (offsetX == null && data.x && isXAxis) {
3794 offsetX = domRect.x - data.x;
3795 }
3796 if (offsetY == null && data.y && isYAxis) {
3797 offsetY = domRect.y - data.y;
3798 }
3799 x2 -= offsetX || 0;
3800 y2 -= offsetY || 0;
3801 width = 0;
3802 height = 0;
3803 if (!isAutoUpdateEvent || canTrackCursorOnAutoUpdate) {
3804 width = data.axis === "y" ? domRect.width : 0;
3805 height = data.axis === "x" ? domRect.height : 0;
3806 x2 = isXAxis && data.x != null ? data.x : x2;
3807 y2 = isYAxis && data.y != null ? data.y : y2;
3808 } else if (isAutoUpdateEvent && !canTrackCursorOnAutoUpdate) {
3809 height = data.axis === "x" ? domRect.height : height;
3810 width = data.axis === "y" ? domRect.width : width;
3811 }
3812 isAutoUpdateEvent = true;
3813 return {
3814 width,
3815 height,
3816 x: x2,
3817 y: y2,
3818 top: y2,
3819 right: x2 + width,
3820 bottom: y2 + height,
3821 left: x2
3822 };
3823 }
3824 };
3825 }
3826 function isMouseBasedEvent(event) {
3827 return event != null && event.clientX != null;
3828 }
3829 function useClientPoint(context, props = {}) {
3830 const {
3831 enabled = true,
3832 axis = "both"
3833 } = props;
3834 const store2 = "rootStore" in context ? context.rootStore : context;
3835 const open3 = store2.useState("open");
3836 const floating = store2.useState("floatingElement");
3837 const domReference = store2.useState("domReferenceElement");
3838 const dataRef = store2.context.dataRef;
3839 const initialRef = React25.useRef(false);
3840 const cleanupListenerRef = React25.useRef(null);
3841 const [pointerType, setPointerType] = React25.useState();
3842 const [reactive, setReactive] = React25.useState([]);
3843 const resetReference = useStableCallback((reference2) => {
3844 store2.set("positionReference", reference2);
3845 });
3846 const setReference = useStableCallback((newX, newY, referenceElement) => {
3847 if (initialRef.current) {
3848 return;
3849 }
3850 if (dataRef.current.openEvent && !isMouseBasedEvent(dataRef.current.openEvent)) {
3851 return;
3852 }
3853 store2.set("positionReference", createVirtualElement(referenceElement ?? domReference, {
3854 x: newX,
3855 y: newY,
3856 axis,
3857 dataRef,
3858 pointerType
3859 }));
3860 });
3861 const handleReferenceEnterOrMove = useStableCallback((event) => {
3862 if (!open3) {
3863 setReference(event.clientX, event.clientY, event.currentTarget);
3864 } else if (!cleanupListenerRef.current) {
3865 setReference(event.clientX, event.clientY, event.currentTarget);
3866 setReactive([]);
3867 }
3868 });
3869 const openCheck = isMouseLikePointerType(pointerType) ? floating : open3;
3870 React25.useEffect(() => {
3871 if (!enabled) {
3872 resetReference(domReference);
3873 return void 0;
3874 }
3875 if (!openCheck) {
3876 return void 0;
3877 }
3878 function cleanupListener() {
3879 cleanupListenerRef.current?.();
3880 cleanupListenerRef.current = null;
3881 }
3882 const win = getWindow(floating);
3883 function handleMouseMove(event) {
3884 const target = getTarget(event);
3885 if (!contains(floating, target)) {
3886 setReference(event.clientX, event.clientY);
3887 } else {
3888 cleanupListener();
3889 }
3890 }
3891 if (!dataRef.current.openEvent || isMouseBasedEvent(dataRef.current.openEvent)) {
3892 cleanupListenerRef.current = addEventListener(win, "mousemove", handleMouseMove);
3893 } else {
3894 resetReference(domReference);
3895 }
3896 return cleanupListener;
3897 }, [openCheck, enabled, floating, dataRef, domReference, store2, setReference, resetReference, reactive]);
3898 React25.useEffect(() => () => {
3899 store2.set("positionReference", null);
3900 }, [store2]);
3901 React25.useEffect(() => {
3902 if (enabled && !floating) {
3903 initialRef.current = false;
3904 }
3905 }, [enabled, floating]);
3906 React25.useEffect(() => {
3907 if (!enabled && open3) {
3908 initialRef.current = true;
3909 }
3910 }, [enabled, open3]);
3911 const reference = React25.useMemo(() => {
3912 function setPointerTypeRef(event) {
3913 setPointerType(event.pointerType);
3914 }
3915 return {
3916 onPointerDown: setPointerTypeRef,
3917 onPointerEnter: setPointerTypeRef,
3918 onMouseMove: handleReferenceEnterOrMove,
3919 onMouseEnter: handleReferenceEnterOrMove
3920 };
3921 }, [handleReferenceEnterOrMove]);
3922 return React25.useMemo(() => enabled ? {
3923 reference,
3924 trigger: reference
3925 } : {}, [enabled, reference]);
3926 }
3927
3928 // node_modules/@base-ui/react/floating-ui-react/hooks/useDismiss.mjs
3929 var React26 = __toESM(require_react(), 1);
3930 function alwaysFalse() {
3931 return false;
3932 }
3933 function normalizeProp(normalizable) {
3934 return {
3935 escapeKey: typeof normalizable === "boolean" ? normalizable : normalizable?.escapeKey ?? false,
3936 outsidePress: typeof normalizable === "boolean" ? normalizable : normalizable?.outsidePress ?? true
3937 };
3938 }
3939 function useDismiss(context, props = {}) {
3940 const {
3941 enabled = true,
3942 escapeKey: escapeKey2 = true,
3943 outsidePress: outsidePressProp = true,
3944 outsidePressEvent = "sloppy",
3945 referencePress = alwaysFalse,
3946 bubbles,
3947 externalTree
3948 } = props;
3949 const store2 = "rootStore" in context ? context.rootStore : context;
3950 const open3 = store2.useState("open");
3951 const floatingElement = store2.useState("floatingElement");
3952 const {
3953 dataRef,
3954 events
3955 } = store2.context;
3956 const tree = useFloatingTree(externalTree);
3957 const outsidePressFn = useStableCallback(typeof outsidePressProp === "function" ? outsidePressProp : () => false);
3958 const outsidePress2 = typeof outsidePressProp === "function" ? outsidePressFn : outsidePressProp;
3959 const outsidePressEnabled = outsidePress2 !== false;
3960 const getOutsidePressEventProp = useStableCallback(() => outsidePressEvent);
3961 const {
3962 escapeKey: escapeKeyBubbles,
3963 outsidePress: outsidePressBubbles
3964 } = normalizeProp(bubbles);
3965 const pressStartedInsideRef = React26.useRef(false);
3966 const pressStartPreventedRef = React26.useRef(false);
3967 const suppressNextOutsideClickRef = React26.useRef(false);
3968 const sawPressWhileOpenRef = React26.useRef(false);
3969 const isComposingRef = React26.useRef(false);
3970 const currentPointerTypeRef = React26.useRef("");
3971 const touchStateRef = React26.useRef(null);
3972 const cancelDismissOnEndTimeout = useTimeout();
3973 const clearInsideReactTreeTimeout = useTimeout();
3974 const clearInsideReactTree = useStableCallback(() => {
3975 clearInsideReactTreeTimeout.clear();
3976 dataRef.current.insideReactTree = false;
3977 });
3978 const hasBlockingChild = useStableCallback((bubbleKey) => {
3979 const nodeId = dataRef.current.floatingContext?.nodeId;
3980 const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : [];
3981 return children.some((child) => child.context?.open && !child.context.dataRef.current[bubbleKey]);
3982 });
3983 const isEventWithinOwnElements = useStableCallback((event) => {
3984 return isEventTargetWithin(event, store2.select("floatingElement")) || isEventTargetWithin(event, store2.select("domReferenceElement"));
3985 });
3986 const closeOnReferencePress = useStableCallback((event) => {
3987 if (!referencePress()) {
3988 return;
3989 }
3990 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent));
3991 });
3992 const closeOnEscapeKeyDown = useStableCallback((event) => {
3993 if (!open3 || !enabled || !escapeKey2 || event.key !== "Escape") {
3994 return;
3995 }
3996 if (isComposingRef.current) {
3997 return;
3998 }
3999 if (!escapeKeyBubbles && hasBlockingChild("__escapeKeyBubbles")) {
4000 return;
4001 }
4002 const native = isReactEvent(event) ? event.nativeEvent : event;
4003 const eventDetails = createChangeEventDetails(reason_parts_exports.escapeKey, native);
4004 store2.setOpen(false, eventDetails);
4005 if (!eventDetails.isCanceled) {
4006 event.preventDefault();
4007 }
4008 if (!escapeKeyBubbles && !eventDetails.isPropagationAllowed) {
4009 event.stopPropagation();
4010 }
4011 });
4012 const markInsideReactTree = useStableCallback(() => {
4013 dataRef.current.insideReactTree = true;
4014 clearInsideReactTreeTimeout.start(0, clearInsideReactTree);
4015 });
4016 const markPressStartedInsideReactTree = useStableCallback((event) => {
4017 if (!open3 || !enabled || event.button !== 0) {
4018 return;
4019 }
4020 const target = getTarget(event.nativeEvent);
4021 if (!contains(store2.select("floatingElement"), target)) {
4022 return;
4023 }
4024 if (!pressStartedInsideRef.current) {
4025 pressStartedInsideRef.current = true;
4026 pressStartPreventedRef.current = false;
4027 }
4028 });
4029 const markInsidePressStartPrevented = useStableCallback((event) => {
4030 if (!open3 || !enabled) {
4031 return;
4032 }
4033 if (!(event.defaultPrevented || event.nativeEvent.defaultPrevented)) {
4034 return;
4035 }
4036 if (pressStartedInsideRef.current) {
4037 pressStartPreventedRef.current = true;
4038 }
4039 });
4040 React26.useEffect(() => {
4041 function handleOpenChange(details) {
4042 if (!details.open) {
4043 sawPressWhileOpenRef.current = false;
4044 }
4045 }
4046 events.on("openchange", handleOpenChange);
4047 return () => {
4048 events.off("openchange", handleOpenChange);
4049 };
4050 }, [events]);
4051 React26.useEffect(() => {
4052 if (!open3 || !enabled) {
4053 if (!open3) {
4054 sawPressWhileOpenRef.current = false;
4055 }
4056 return clearInsideReactTree;
4057 }
4058 dataRef.current.__escapeKeyBubbles = escapeKeyBubbles;
4059 dataRef.current.__outsidePressBubbles = outsidePressBubbles;
4060 const compositionTimeout = new Timeout();
4061 const preventedPressSuppressionTimeout = new Timeout();
4062 const doc = ownerDocument(floatingElement);
4063 function handleCompositionStart() {
4064 compositionTimeout.clear();
4065 isComposingRef.current = true;
4066 }
4067 function handleCompositionEnd() {
4068 compositionTimeout.start(
4069 // 0ms or 1ms don't work in Safari. 5ms appears to consistently work.
4070 // Only apply to WebKit for the test to remain 0ms.
4071 parts_exports.engine.webkit ? 5 : 0,
4072 () => {
4073 isComposingRef.current = false;
4074 }
4075 );
4076 }
4077 function suppressImmediateOutsideClickAfterPreventedStart() {
4078 suppressNextOutsideClickRef.current = true;
4079 preventedPressSuppressionTimeout.start(0, () => {
4080 suppressNextOutsideClickRef.current = false;
4081 });
4082 }
4083 function resetPressStartState() {
4084 pressStartedInsideRef.current = false;
4085 pressStartPreventedRef.current = false;
4086 }
4087 function getOutsidePressEvent() {
4088 const type = currentPointerTypeRef.current;
4089 const computedType = type === "pen" || !type ? "mouse" : type;
4090 const outsidePressEventValue = getOutsidePressEventProp();
4091 const resolved = typeof outsidePressEventValue === "function" ? outsidePressEventValue() : outsidePressEventValue;
4092 if (typeof resolved === "string") {
4093 return resolved;
4094 }
4095 return resolved[computedType];
4096 }
4097 function shouldIgnoreEvent(event) {
4098 const computedOutsidePressEvent = getOutsidePressEvent();
4099 return computedOutsidePressEvent === "intentional" && event.type !== "click" || computedOutsidePressEvent === "sloppy" && event.type === "click";
4100 }
4101 function isEventWithinFloatingTree(event) {
4102 const nodeId = dataRef.current.floatingContext?.nodeId;
4103 const targetIsInsideChildren = tree && getNodeChildren(tree.nodesRef.current, nodeId).some((node) => isEventTargetWithin(event, node.context?.elements.floating));
4104 return isEventWithinOwnElements(event) || targetIsInsideChildren;
4105 }
4106 function closeOnPressOutside(event) {
4107 if (shouldIgnoreEvent(event)) {
4108 if (event.type !== "click" && !isEventWithinOwnElements(event)) {
4109 preventedPressSuppressionTimeout.clear();
4110 suppressNextOutsideClickRef.current = false;
4111 }
4112 clearInsideReactTree();
4113 return;
4114 }
4115 if (dataRef.current.insideReactTree) {
4116 clearInsideReactTree();
4117 return;
4118 }
4119 const target = getTarget(event);
4120 const inertSelector = `[${createAttribute("inert")}]`;
4121 const targetRoot = isElement(target) ? target.getRootNode() : null;
4122 const markers = Array.from((isShadowRoot(targetRoot) ? targetRoot : ownerDocument(store2.select("floatingElement"))).querySelectorAll(inertSelector));
4123 const triggers = store2.context.triggerElements;
4124 if (target && (triggers.hasElement(target) || triggers.hasMatchingElement((trigger) => contains(trigger, target)))) {
4125 return;
4126 }
4127 let targetRootAncestor = isElement(target) ? target : null;
4128 while (targetRootAncestor && !isLastTraversableNode(targetRootAncestor)) {
4129 const nextParent = getParentNode(targetRootAncestor);
4130 if (isLastTraversableNode(nextParent) || !isElement(nextParent)) {
4131 break;
4132 }
4133 targetRootAncestor = nextParent;
4134 }
4135 if (markers.length && isElement(target) && !isRootElement(target) && // Clicked on a direct ancestor (e.g. FloatingOverlay).
4136 !contains(target, store2.select("floatingElement")) && // If the target root element contains none of the markers, then the
4137 // element was injected after the floating element rendered.
4138 markers.every((marker) => !contains(targetRootAncestor, marker))) {
4139 return;
4140 }
4141 if (isHTMLElement(target) && !("touches" in event)) {
4142 const lastTraversableNode = isLastTraversableNode(target);
4143 const style = getComputedStyle2(target);
4144 const scrollRe = /auto|scroll/;
4145 const isScrollableX = lastTraversableNode || scrollRe.test(style.overflowX);
4146 const isScrollableY = lastTraversableNode || scrollRe.test(style.overflowY);
4147 const canScrollX = isScrollableX && target.clientWidth > 0 && target.scrollWidth > target.clientWidth;
4148 const canScrollY = isScrollableY && target.clientHeight > 0 && target.scrollHeight > target.clientHeight;
4149 const isRTL6 = style.direction === "rtl";
4150 const pressedVerticalScrollbar = canScrollY && (isRTL6 ? event.offsetX <= target.offsetWidth - target.clientWidth : event.offsetX > target.clientWidth);
4151 const pressedHorizontalScrollbar = canScrollX && event.offsetY > target.clientHeight;
4152 if (pressedVerticalScrollbar || pressedHorizontalScrollbar) {
4153 return;
4154 }
4155 }
4156 if (isEventWithinFloatingTree(event)) {
4157 return;
4158 }
4159 if (getOutsidePressEvent() === "intentional") {
4160 if (event.detail !== 0 && !isVirtualClick(event) && !sawPressWhileOpenRef.current) {
4161 return;
4162 }
4163 if (suppressNextOutsideClickRef.current) {
4164 preventedPressSuppressionTimeout.clear();
4165 suppressNextOutsideClickRef.current = false;
4166 return;
4167 }
4168 }
4169 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
4170 return;
4171 }
4172 if (hasBlockingChild("__outsidePressBubbles")) {
4173 return;
4174 }
4175 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.outsidePress, event));
4176 clearInsideReactTree();
4177 }
4178 function handlePointerDown(event) {
4179 if (getOutsidePressEvent() !== "sloppy" || event.pointerType === "touch" || !store2.select("open") || !enabled || isEventWithinOwnElements(event)) {
4180 return;
4181 }
4182 closeOnPressOutside(event);
4183 }
4184 function handleTouchStart(event) {
4185 if (getOutsidePressEvent() !== "sloppy" || !store2.select("open") || !enabled || isEventWithinOwnElements(event)) {
4186 return;
4187 }
4188 const touch = event.touches[0];
4189 if (touch) {
4190 touchStateRef.current = {
4191 startTime: Date.now(),
4192 startX: touch.clientX,
4193 startY: touch.clientY,
4194 dismissOnTouchEnd: false,
4195 dismissOnMouseDown: true
4196 };
4197 cancelDismissOnEndTimeout.start(1e3, () => {
4198 if (touchStateRef.current) {
4199 touchStateRef.current.dismissOnTouchEnd = false;
4200 touchStateRef.current.dismissOnMouseDown = false;
4201 }
4202 });
4203 }
4204 }
4205 function addTargetEventListenerOnce(event, listener) {
4206 const target = getTarget(event);
4207 if (!target) {
4208 return;
4209 }
4210 const unsubscribe2 = addEventListener(target, event.type, () => {
4211 listener(event);
4212 unsubscribe2();
4213 });
4214 }
4215 function handleTouchStartCapture(event) {
4216 currentPointerTypeRef.current = "touch";
4217 addTargetEventListenerOnce(event, handleTouchStart);
4218 }
4219 function closeOnPressOutsideCapture(event) {
4220 cancelDismissOnEndTimeout.clear();
4221 if (event.type === "pointerdown") {
4222 if (event.button === 0) {
4223 sawPressWhileOpenRef.current = true;
4224 }
4225 currentPointerTypeRef.current = event.pointerType;
4226 }
4227 if (event.type === "mousedown" && touchStateRef.current && !touchStateRef.current.dismissOnMouseDown) {
4228 return;
4229 }
4230 addTargetEventListenerOnce(event, (targetEvent) => {
4231 if (targetEvent.type === "pointerdown") {
4232 handlePointerDown(targetEvent);
4233 } else {
4234 closeOnPressOutside(targetEvent);
4235 }
4236 });
4237 }
4238 function handlePressEndCapture(event) {
4239 if (event.type === "pointercancel") {
4240 sawPressWhileOpenRef.current = false;
4241 }
4242 if (!pressStartedInsideRef.current) {
4243 return;
4244 }
4245 const pressStartedInsideDefaultPrevented = pressStartPreventedRef.current;
4246 resetPressStartState();
4247 if (getOutsidePressEvent() !== "intentional") {
4248 return;
4249 }
4250 if (event.type === "pointercancel") {
4251 if (pressStartedInsideDefaultPrevented) {
4252 suppressImmediateOutsideClickAfterPreventedStart();
4253 }
4254 return;
4255 }
4256 if (isEventWithinFloatingTree(event)) {
4257 return;
4258 }
4259 if (pressStartedInsideDefaultPrevented) {
4260 suppressImmediateOutsideClickAfterPreventedStart();
4261 return;
4262 }
4263 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
4264 return;
4265 }
4266 preventedPressSuppressionTimeout.clear();
4267 suppressNextOutsideClickRef.current = true;
4268 clearInsideReactTree();
4269 }
4270 function handleTouchMove(event) {
4271 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) {
4272 return;
4273 }
4274 const touch = event.touches[0];
4275 if (!touch) {
4276 return;
4277 }
4278 const deltaX = Math.abs(touch.clientX - touchStateRef.current.startX);
4279 const deltaY = Math.abs(touch.clientY - touchStateRef.current.startY);
4280 const distance2 = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
4281 if (distance2 > 5) {
4282 touchStateRef.current.dismissOnTouchEnd = true;
4283 }
4284 if (distance2 > 10) {
4285 closeOnPressOutside(event);
4286 cancelDismissOnEndTimeout.clear();
4287 touchStateRef.current = null;
4288 }
4289 }
4290 function handleTouchMoveCapture(event) {
4291 addTargetEventListenerOnce(event, handleTouchMove);
4292 }
4293 function handleTouchEnd(event) {
4294 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) {
4295 return;
4296 }
4297 if (touchStateRef.current.dismissOnTouchEnd) {
4298 closeOnPressOutside(event);
4299 }
4300 cancelDismissOnEndTimeout.clear();
4301 touchStateRef.current = null;
4302 }
4303 function handleTouchEndCapture(event) {
4304 addTargetEventListenerOnce(event, handleTouchEnd);
4305 }
4306 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, {
4307 capture: true,
4308 passive: true
4309 }), addEventListener(doc, "touchmove", handleTouchMoveCapture, {
4310 capture: true,
4311 passive: true
4312 }), addEventListener(doc, "touchend", handleTouchEndCapture, {
4313 capture: true,
4314 passive: true
4315 })));
4316 return () => {
4317 unsubscribe();
4318 compositionTimeout.clear();
4319 preventedPressSuppressionTimeout.clear();
4320 resetPressStartState();
4321 suppressNextOutsideClickRef.current = false;
4322 clearInsideReactTree();
4323 };
4324 }, [dataRef, floatingElement, escapeKey2, outsidePressEnabled, outsidePress2, open3, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, clearInsideReactTree, getOutsidePressEventProp, hasBlockingChild, isEventWithinOwnElements, tree, store2, cancelDismissOnEndTimeout]);
4325 const reference = React26.useMemo(() => ({
4326 onKeyDown: closeOnEscapeKeyDown,
4327 onPointerDown: closeOnReferencePress,
4328 onClick: closeOnReferencePress
4329 }), [closeOnEscapeKeyDown, closeOnReferencePress]);
4330 const floating = React26.useMemo(() => ({
4331 onKeyDown: closeOnEscapeKeyDown,
4332 // `onMouseDown` may be blocked if `event.preventDefault()` is called in
4333 // `onPointerDown`, such as with <NumberField.ScrubArea>.
4334 // See https://github.com/mui/base-ui/pull/3379
4335 onPointerDown: markInsidePressStartPrevented,
4336 onMouseDown: markInsidePressStartPrevented,
4337 onClickCapture: markInsideReactTree,
4338 onMouseDownCapture(event) {
4339 markInsideReactTree();
4340 markPressStartedInsideReactTree(event);
4341 },
4342 onPointerDownCapture(event) {
4343 markInsideReactTree();
4344 markPressStartedInsideReactTree(event);
4345 },
4346 onMouseUpCapture: markInsideReactTree,
4347 onTouchEndCapture: markInsideReactTree,
4348 onTouchMoveCapture: markInsideReactTree
4349 }), [closeOnEscapeKeyDown, markInsideReactTree, markPressStartedInsideReactTree, markInsidePressStartPrevented]);
4350 return React26.useMemo(() => enabled ? {
4351 reference,
4352 floating,
4353 trigger: reference
4354 } : {}, [enabled, reference, floating]);
4355 }
4356
4357 // node_modules/@base-ui/react/floating-ui-react/hooks/useFloating.mjs
4358 var React35 = __toESM(require_react(), 1);
4359
4360 // node_modules/@floating-ui/core/dist/floating-ui.core.mjs
4361 function computeCoordsFromPlacement(_ref, placement, rtl) {
4362 let {
4363 reference,
4364 floating
4365 } = _ref;
4366 const sideAxis = getSideAxis(placement);
4367 const alignmentAxis = getAlignmentAxis(placement);
4368 const alignLength = getAxisLength(alignmentAxis);
4369 const side = getSide(placement);
4370 const isVertical = sideAxis === "y";
4371 const commonX = reference.x + reference.width / 2 - floating.width / 2;
4372 const commonY = reference.y + reference.height / 2 - floating.height / 2;
4373 const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
4374 let coords;
4375 switch (side) {
4376 case "top":
4377 coords = {
4378 x: commonX,
4379 y: reference.y - floating.height
4380 };
4381 break;
4382 case "bottom":
4383 coords = {
4384 x: commonX,
4385 y: reference.y + reference.height
4386 };
4387 break;
4388 case "right":
4389 coords = {
4390 x: reference.x + reference.width,
4391 y: commonY
4392 };
4393 break;
4394 case "left":
4395 coords = {
4396 x: reference.x - floating.width,
4397 y: commonY
4398 };
4399 break;
4400 default:
4401 coords = {
4402 x: reference.x,
4403 y: reference.y
4404 };
4405 }
4406 const alignment = getAlignment(placement);
4407 if (alignment) {
4408 coords[alignmentAxis] += commonAlign * (alignment === "end" ? 1 : -1) * (rtl && isVertical ? -1 : 1);
4409 }
4410 return coords;
4411 }
4412 async function detectOverflow(state, options) {
4413 var _await$platform$isEle;
4414 if (options === void 0) {
4415 options = {};
4416 }
4417 const {
4418 x: x2,
4419 y: y2,
4420 platform: platform3,
4421 rects,
4422 elements,
4423 strategy
4424 } = state;
4425 const {
4426 boundary = "clippingAncestors",
4427 rootBoundary = "viewport",
4428 elementContext = "floating",
4429 altBoundary = false,
4430 padding = 0
4431 } = evaluate(options, state);
4432 const paddingObject = getPaddingObject(padding);
4433 const altContext = elementContext === "floating" ? "reference" : "floating";
4434 const element = elements[altBoundary ? altContext : elementContext];
4435 const clippingClientRect = rectToClientRect(await platform3.getClippingRect({
4436 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)),
4437 boundary,
4438 rootBoundary,
4439 strategy
4440 }));
4441 const rect = elementContext === "floating" ? {
4442 x: x2,
4443 y: y2,
4444 width: rects.floating.width,
4445 height: rects.floating.height
4446 } : rects.reference;
4447 const offsetParent = await (platform3.getOffsetParent == null ? void 0 : platform3.getOffsetParent(elements.floating));
4448 const offsetScale = await (platform3.isElement == null ? void 0 : platform3.isElement(offsetParent)) && await (platform3.getScale == null ? void 0 : platform3.getScale(offsetParent)) || {
4449 x: 1,
4450 y: 1
4451 };
4452 const elementClientRect = rectToClientRect(platform3.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform3.convertOffsetParentRelativeRectToViewportRelativeRect({
4453 elements,
4454 rect,
4455 offsetParent,
4456 strategy
4457 }) : rect);
4458 return {
4459 top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
4460 bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
4461 left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
4462 right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
4463 };
4464 }
4465 var MAX_RESET_COUNT = 50;
4466 var computePosition = async (reference, floating, config) => {
4467 const {
4468 placement = "bottom",
4469 strategy = "absolute",
4470 middleware = [],
4471 platform: platform3
4472 } = config;
4473 const platformWithDetectOverflow = platform3.detectOverflow ? platform3 : {
4474 ...platform3,
4475 detectOverflow
4476 };
4477 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(floating));
4478 let rects = await platform3.getElementRects({
4479 reference,
4480 floating,
4481 strategy
4482 });
4483 let {
4484 x: x2,
4485 y: y2
4486 } = computeCoordsFromPlacement(rects, placement, rtl);
4487 let statefulPlacement = placement;
4488 let resetCount = 0;
4489 const middlewareData = {};
4490 for (let i = 0; i < middleware.length; i++) {
4491 const currentMiddleware = middleware[i];
4492 if (!currentMiddleware) {
4493 continue;
4494 }
4495 const {
4496 name,
4497 fn
4498 } = currentMiddleware;
4499 const {
4500 x: nextX,
4501 y: nextY,
4502 data,
4503 reset
4504 } = await fn({
4505 x: x2,
4506 y: y2,
4507 initialPlacement: placement,
4508 placement: statefulPlacement,
4509 strategy,
4510 middlewareData,
4511 rects,
4512 platform: platformWithDetectOverflow,
4513 elements: {
4514 reference,
4515 floating
4516 }
4517 });
4518 x2 = nextX != null ? nextX : x2;
4519 y2 = nextY != null ? nextY : y2;
4520 middlewareData[name] = {
4521 ...middlewareData[name],
4522 ...data
4523 };
4524 if (reset && resetCount < MAX_RESET_COUNT) {
4525 resetCount++;
4526 if (typeof reset === "object") {
4527 if (reset.placement) {
4528 statefulPlacement = reset.placement;
4529 }
4530 if (reset.rects) {
4531 rects = reset.rects === true ? await platform3.getElementRects({
4532 reference,
4533 floating,
4534 strategy
4535 }) : reset.rects;
4536 }
4537 ({
4538 x: x2,
4539 y: y2
4540 } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
4541 }
4542 i = -1;
4543 }
4544 }
4545 return {
4546 x: x2,
4547 y: y2,
4548 placement: statefulPlacement,
4549 strategy,
4550 middlewareData
4551 };
4552 };
4553 var flip = function(options) {
4554 if (options === void 0) {
4555 options = {};
4556 }
4557 return {
4558 name: "flip",
4559 options,
4560 async fn(state) {
4561 var _middlewareData$arrow, _middlewareData$flip;
4562 const {
4563 placement,
4564 middlewareData,
4565 rects,
4566 initialPlacement,
4567 platform: platform3,
4568 elements
4569 } = state;
4570 const {
4571 mainAxis: checkMainAxis = true,
4572 crossAxis: checkCrossAxis = true,
4573 fallbackPlacements: specifiedFallbackPlacements,
4574 fallbackStrategy = "bestFit",
4575 fallbackAxisSideDirection = "none",
4576 flipAlignment = true,
4577 ...detectOverflowOptions
4578 } = evaluate(options, state);
4579 if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
4580 return {};
4581 }
4582 const side = getSide(placement);
4583 const initialSideAxis = getSideAxis(initialPlacement);
4584 const isBasePlacement = getSide(initialPlacement) === initialPlacement;
4585 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
4586 const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
4587 const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
4588 if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
4589 fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
4590 }
4591 const placements2 = [initialPlacement, ...fallbackPlacements];
4592 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4593 const overflows = [];
4594 let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
4595 if (checkMainAxis) {
4596 overflows.push(overflow[side]);
4597 }
4598 if (checkCrossAxis) {
4599 const sides2 = getAlignmentSides(placement, rects, rtl);
4600 overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
4601 }
4602 overflowsData = [...overflowsData, {
4603 placement,
4604 overflows
4605 }];
4606 if (!overflows.every((side2) => side2 <= 0)) {
4607 var _middlewareData$flip2, _overflowsData$filter;
4608 const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
4609 const nextPlacement = placements2[nextIndex];
4610 if (nextPlacement) {
4611 const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false;
4612 if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis
4613 // overflows the main axis.
4614 overflowsData.every((d) => getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) {
4615 return {
4616 data: {
4617 index: nextIndex,
4618 overflows: overflowsData
4619 },
4620 reset: {
4621 placement: nextPlacement
4622 }
4623 };
4624 }
4625 }
4626 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;
4627 if (!resetPlacement) {
4628 switch (fallbackStrategy) {
4629 case "bestFit": {
4630 var _overflowsData$filter2;
4631 const placement2 = (_overflowsData$filter2 = overflowsData.filter((d) => {
4632 if (hasFallbackAxisSideDirection) {
4633 const currentSideAxis = getSideAxis(d.placement);
4634 return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
4635 // reading directions favoring greater width.
4636 currentSideAxis === "y";
4637 }
4638 return true;
4639 }).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];
4640 if (placement2) {
4641 resetPlacement = placement2;
4642 }
4643 break;
4644 }
4645 case "initialPlacement":
4646 resetPlacement = initialPlacement;
4647 break;
4648 }
4649 }
4650 if (placement !== resetPlacement) {
4651 return {
4652 reset: {
4653 placement: resetPlacement
4654 }
4655 };
4656 }
4657 }
4658 return {};
4659 }
4660 };
4661 };
4662 var originSides = /* @__PURE__ */ new Set(["left", "top"]);
4663 async function convertValueToCoords(state, options) {
4664 const {
4665 placement,
4666 platform: platform3,
4667 elements
4668 } = state;
4669 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
4670 const side = getSide(placement);
4671 const alignment = getAlignment(placement);
4672 const isVertical = getSideAxis(placement) === "y";
4673 const mainAxisMulti = originSides.has(side) ? -1 : 1;
4674 const crossAxisMulti = rtl && isVertical ? -1 : 1;
4675 const rawValue = evaluate(options, state);
4676 let {
4677 mainAxis,
4678 crossAxis,
4679 alignmentAxis
4680 } = typeof rawValue === "number" ? {
4681 mainAxis: rawValue,
4682 crossAxis: 0,
4683 alignmentAxis: null
4684 } : {
4685 mainAxis: rawValue.mainAxis || 0,
4686 crossAxis: rawValue.crossAxis || 0,
4687 alignmentAxis: rawValue.alignmentAxis
4688 };
4689 if (alignment && typeof alignmentAxis === "number") {
4690 crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
4691 }
4692 return isVertical ? {
4693 x: crossAxis * crossAxisMulti,
4694 y: mainAxis * mainAxisMulti
4695 } : {
4696 x: mainAxis * mainAxisMulti,
4697 y: crossAxis * crossAxisMulti
4698 };
4699 }
4700 var offset = function(options) {
4701 if (options === void 0) {
4702 options = 0;
4703 }
4704 return {
4705 name: "offset",
4706 options,
4707 async fn(state) {
4708 var _middlewareData$offse, _middlewareData$arrow;
4709 const {
4710 x: x2,
4711 y: y2,
4712 placement,
4713 middlewareData
4714 } = state;
4715 const diffCoords = await convertValueToCoords(state, options);
4716 if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
4717 return {};
4718 }
4719 return {
4720 x: x2 + diffCoords.x,
4721 y: y2 + diffCoords.y,
4722 data: {
4723 ...diffCoords,
4724 placement
4725 }
4726 };
4727 }
4728 };
4729 };
4730 var shift = function(options) {
4731 if (options === void 0) {
4732 options = {};
4733 }
4734 return {
4735 name: "shift",
4736 options,
4737 async fn(state) {
4738 const {
4739 x: x2,
4740 y: y2,
4741 placement,
4742 platform: platform3
4743 } = state;
4744 const {
4745 mainAxis: checkMainAxis = true,
4746 crossAxis: checkCrossAxis = false,
4747 limiter = {
4748 fn: (_ref) => {
4749 let {
4750 x: x3,
4751 y: y3
4752 } = _ref;
4753 return {
4754 x: x3,
4755 y: y3
4756 };
4757 }
4758 },
4759 ...detectOverflowOptions
4760 } = evaluate(options, state);
4761 const coords = {
4762 x: x2,
4763 y: y2
4764 };
4765 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4766 const crossAxis = getSideAxis(placement);
4767 const mainAxis = getOppositeAxis(crossAxis);
4768 let mainAxisCoord = coords[mainAxis];
4769 let crossAxisCoord = coords[crossAxis];
4770 const clampCoord = (axis, coord) => clamp(coord + overflow[axis === "y" ? "top" : "left"], coord, coord - overflow[axis === "y" ? "bottom" : "right"]);
4771 if (checkMainAxis) {
4772 mainAxisCoord = clampCoord(mainAxis, mainAxisCoord);
4773 }
4774 if (checkCrossAxis) {
4775 crossAxisCoord = clampCoord(crossAxis, crossAxisCoord);
4776 }
4777 const limitedCoords = limiter.fn({
4778 ...state,
4779 [mainAxis]: mainAxisCoord,
4780 [crossAxis]: crossAxisCoord
4781 });
4782 return {
4783 ...limitedCoords,
4784 data: {
4785 x: limitedCoords.x - x2,
4786 y: limitedCoords.y - y2,
4787 enabled: {
4788 [mainAxis]: checkMainAxis,
4789 [crossAxis]: checkCrossAxis
4790 }
4791 }
4792 };
4793 }
4794 };
4795 };
4796 var limitShift = function(options) {
4797 if (options === void 0) {
4798 options = {};
4799 }
4800 return {
4801 options,
4802 fn(state) {
4803 var _rawOffset$mainAxis, _rawOffset$crossAxis;
4804 const {
4805 x: x2,
4806 y: y2,
4807 placement,
4808 rects,
4809 middlewareData
4810 } = state;
4811 const {
4812 offset: offset4 = 0,
4813 mainAxis: checkMainAxis = true,
4814 crossAxis: checkCrossAxis = true
4815 } = evaluate(options, state);
4816 const coords = {
4817 x: x2,
4818 y: y2
4819 };
4820 const crossAxis = getSideAxis(placement);
4821 const mainAxis = getOppositeAxis(crossAxis);
4822 let mainAxisCoord = coords[mainAxis];
4823 let crossAxisCoord = coords[crossAxis];
4824 const rawOffset = evaluate(offset4, state);
4825 const computedOffset = typeof rawOffset === "number" ? {
4826 mainAxis: rawOffset,
4827 crossAxis: 0
4828 } : {
4829 mainAxis: (_rawOffset$mainAxis = rawOffset.mainAxis) != null ? _rawOffset$mainAxis : 0,
4830 crossAxis: (_rawOffset$crossAxis = rawOffset.crossAxis) != null ? _rawOffset$crossAxis : 0
4831 };
4832 if (checkMainAxis) {
4833 const len2 = mainAxis === "y" ? "height" : "width";
4834 const limitMin = rects.reference[mainAxis] - rects.floating[len2] + computedOffset.mainAxis;
4835 const limitMax = rects.reference[mainAxis] + rects.reference[len2] - computedOffset.mainAxis;
4836 if (mainAxisCoord < limitMin) {
4837 mainAxisCoord = limitMin;
4838 } else if (mainAxisCoord > limitMax) {
4839 mainAxisCoord = limitMax;
4840 }
4841 }
4842 if (checkCrossAxis) {
4843 var _middlewareData$offse, _middlewareData$offse2;
4844 const len2 = mainAxis === "y" ? "width" : "height";
4845 const isOriginSide = originSides.has(getSide(placement));
4846 const limitMin = rects.reference[crossAxis] - rects.floating[len2] + (isOriginSide ? ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse[crossAxis]) || 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis);
4847 const limitMax = rects.reference[crossAxis] + rects.reference[len2] + (isOriginSide ? 0 : ((_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[crossAxis]) || 0) - (isOriginSide ? computedOffset.crossAxis : 0);
4848 if (crossAxisCoord < limitMin) {
4849 crossAxisCoord = limitMin;
4850 } else if (crossAxisCoord > limitMax) {
4851 crossAxisCoord = limitMax;
4852 }
4853 }
4854 return {
4855 [mainAxis]: mainAxisCoord,
4856 [crossAxis]: crossAxisCoord
4857 };
4858 }
4859 };
4860 };
4861 var size = function(options) {
4862 if (options === void 0) {
4863 options = {};
4864 }
4865 return {
4866 name: "size",
4867 options,
4868 async fn(state) {
4869 const {
4870 placement,
4871 rects,
4872 platform: platform3,
4873 elements
4874 } = state;
4875 const {
4876 apply = () => {
4877 },
4878 ...detectOverflowOptions
4879 } = evaluate(options, state);
4880 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4881 const side = getSide(placement);
4882 const alignment = getAlignment(placement);
4883 const isYAxis = getSideAxis(placement) === "y";
4884 const {
4885 width,
4886 height
4887 } = rects.floating;
4888 let heightSide;
4889 let widthSide;
4890 if (side === "top" || side === "bottom") {
4891 heightSide = side;
4892 widthSide = alignment === (await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
4893 } else {
4894 widthSide = side;
4895 heightSide = alignment === "end" ? "top" : "bottom";
4896 }
4897 const maximumClippingHeight = height - overflow.top - overflow.bottom;
4898 const maximumClippingWidth = width - overflow.left - overflow.right;
4899 const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
4900 const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
4901 const shiftData = state.middlewareData.shift;
4902 const noShift = !shiftData;
4903 let availableHeight2 = overflowAvailableHeight;
4904 let availableWidth2 = overflowAvailableWidth;
4905 if (shiftData != null && shiftData.enabled.x) {
4906 availableWidth2 = maximumClippingWidth;
4907 }
4908 if (shiftData != null && shiftData.enabled.y) {
4909 availableHeight2 = maximumClippingHeight;
4910 }
4911 if (noShift && !alignment) {
4912 if (isYAxis) {
4913 availableWidth2 = width - 2 * max(overflow.left, overflow.right);
4914 } else {
4915 availableHeight2 = height - 2 * max(overflow.top, overflow.bottom);
4916 }
4917 }
4918 await apply({
4919 ...state,
4920 availableWidth: availableWidth2,
4921 availableHeight: availableHeight2
4922 });
4923 const nextDimensions = await platform3.getDimensions(elements.floating);
4924 if (width !== nextDimensions.width || height !== nextDimensions.height) {
4925 return {
4926 reset: {
4927 rects: true
4928 }
4929 };
4930 }
4931 return {};
4932 }
4933 };
4934 };
4935
4936 // node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs
4937 function getCssDimensions(element) {
4938 const css = getComputedStyle2(element);
4939 let width = parseFloat(css.width) || 0;
4940 let height = parseFloat(css.height) || 0;
4941 const hasOffset = isHTMLElement(element);
4942 const offsetWidth = hasOffset ? element.offsetWidth : width;
4943 const offsetHeight = hasOffset ? element.offsetHeight : height;
4944 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
4945 if (shouldFallback) {
4946 width = offsetWidth;
4947 height = offsetHeight;
4948 }
4949 return {
4950 width,
4951 height,
4952 $: shouldFallback
4953 };
4954 }
4955 function unwrapElement(element) {
4956 return !isElement(element) ? element.contextElement : element;
4957 }
4958 function getScale(element) {
4959 const domElement = unwrapElement(element);
4960 if (!isHTMLElement(domElement)) {
4961 return createCoords(1);
4962 }
4963 const rect = domElement.getBoundingClientRect();
4964 const {
4965 width,
4966 height,
4967 $: $2
4968 } = getCssDimensions(domElement);
4969 let x2 = ($2 ? round(rect.width) : rect.width) / width;
4970 let y2 = ($2 ? round(rect.height) : rect.height) / height;
4971 if (!x2 || !Number.isFinite(x2)) {
4972 x2 = 1;
4973 }
4974 if (!y2 || !Number.isFinite(y2)) {
4975 y2 = 1;
4976 }
4977 return {
4978 x: x2,
4979 y: y2
4980 };
4981 }
4982 var noOffsets = /* @__PURE__ */ createCoords(0);
4983 function getVisualOffsets(element) {
4984 const win = getWindow(element);
4985 if (!isWebKit() || !win.visualViewport) {
4986 return noOffsets;
4987 }
4988 return {
4989 x: win.visualViewport.offsetLeft,
4990 y: win.visualViewport.offsetTop
4991 };
4992 }
4993 function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
4994 if (isFixed === void 0) {
4995 isFixed = false;
4996 }
4997 return !!floatingOffsetParent && isFixed && floatingOffsetParent === getWindow(element);
4998 }
4999 function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
5000 if (includeScale === void 0) {
5001 includeScale = false;
5002 }
5003 if (isFixedStrategy === void 0) {
5004 isFixedStrategy = false;
5005 }
5006 const clientRect = element.getBoundingClientRect();
5007 const domElement = unwrapElement(element);
5008 let scale3 = createCoords(1);
5009 if (includeScale) {
5010 if (offsetParent) {
5011 if (isElement(offsetParent)) {
5012 scale3 = getScale(offsetParent);
5013 }
5014 } else {
5015 scale3 = getScale(element);
5016 }
5017 }
5018 const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
5019 let x2 = (clientRect.left + visualOffsets.x) / scale3.x;
5020 let y2 = (clientRect.top + visualOffsets.y) / scale3.y;
5021 let width = clientRect.width / scale3.x;
5022 let height = clientRect.height / scale3.y;
5023 if (domElement && offsetParent) {
5024 const win = getWindow(domElement);
5025 const offsetWin = isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
5026 let currentWin = win;
5027 let currentIFrame = getFrameElement(currentWin);
5028 while (currentIFrame && offsetWin !== currentWin) {
5029 const iframeScale = getScale(currentIFrame);
5030 const iframeRect = currentIFrame.getBoundingClientRect();
5031 const css = getComputedStyle2(currentIFrame);
5032 const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
5033 const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
5034 x2 *= iframeScale.x;
5035 y2 *= iframeScale.y;
5036 width *= iframeScale.x;
5037 height *= iframeScale.y;
5038 x2 += left;
5039 y2 += top;
5040 currentWin = getWindow(currentIFrame);
5041 currentIFrame = getFrameElement(currentWin);
5042 }
5043 }
5044 return rectToClientRect({
5045 width,
5046 height,
5047 x: x2,
5048 y: y2
5049 });
5050 }
5051 function getWindowScrollBarX(element, rect) {
5052 const leftScroll = getNodeScroll(element).scrollLeft;
5053 if (!rect) {
5054 return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
5055 }
5056 return rect.left + leftScroll;
5057 }
5058 function getHTMLOffset(documentElement, scroll) {
5059 const htmlRect = documentElement.getBoundingClientRect();
5060 const x2 = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
5061 const y2 = htmlRect.top + scroll.scrollTop;
5062 return {
5063 x: x2,
5064 y: y2
5065 };
5066 }
5067 function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
5068 let {
5069 elements,
5070 rect,
5071 offsetParent,
5072 strategy
5073 } = _ref;
5074 const isFixed = strategy === "fixed";
5075 const documentElement = getDocumentElement(offsetParent);
5076 const topLayer = elements ? isTopLayer(elements.floating) : false;
5077 if (offsetParent === documentElement || topLayer && isFixed) {
5078 return rect;
5079 }
5080 let scroll = {
5081 scrollLeft: 0,
5082 scrollTop: 0
5083 };
5084 let scale3 = createCoords(1);
5085 const offsets = createCoords(0);
5086 const isOffsetParentAnElement = isHTMLElement(offsetParent);
5087 if (isOffsetParentAnElement || !isFixed) {
5088 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
5089 scroll = getNodeScroll(offsetParent);
5090 }
5091 if (isOffsetParentAnElement) {
5092 const offsetRect = getBoundingClientRect(offsetParent);
5093 scale3 = getScale(offsetParent);
5094 offsets.x = offsetRect.x + offsetParent.clientLeft;
5095 offsets.y = offsetRect.y + offsetParent.clientTop;
5096 }
5097 }
5098 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
5099 return {
5100 width: rect.width * scale3.x,
5101 height: rect.height * scale3.y,
5102 x: rect.x * scale3.x - scroll.scrollLeft * scale3.x + offsets.x + htmlOffset.x,
5103 y: rect.y * scale3.y - scroll.scrollTop * scale3.y + offsets.y + htmlOffset.y
5104 };
5105 }
5106 function getClientRects(element) {
5107 return element.getClientRects ? Array.from(element.getClientRects()) : [];
5108 }
5109 function getDocumentRect(html) {
5110 const scroll = getNodeScroll(html);
5111 const body = html.ownerDocument.body;
5112 const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
5113 const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
5114 let x2 = -scroll.scrollLeft + getWindowScrollBarX(html);
5115 const y2 = -scroll.scrollTop;
5116 if (getComputedStyle2(body).direction === "rtl") {
5117 x2 += max(html.clientWidth, body.clientWidth) - width;
5118 }
5119 return {
5120 width,
5121 height,
5122 x: x2,
5123 y: y2
5124 };
5125 }
5126 var SCROLLBAR_MAX = 25;
5127 function getViewportRect(element, strategy, rootBoundary) {
5128 if (rootBoundary === void 0) {
5129 rootBoundary = "viewport";
5130 }
5131 const isLayoutViewport = rootBoundary === "layoutViewport";
5132 const win = getWindow(element);
5133 const html = getDocumentElement(element);
5134 const visualViewport = win.visualViewport;
5135 let width = html.clientWidth;
5136 let height = html.clientHeight;
5137 let x2 = 0;
5138 let y2 = 0;
5139 if (visualViewport) {
5140 const layoutRelativeClientCoords = !isWebKit() || strategy === "fixed";
5141 if (isLayoutViewport) {
5142 if (!layoutRelativeClientCoords) {
5143 x2 = -visualViewport.offsetLeft;
5144 y2 = -visualViewport.offsetTop;
5145 }
5146 } else {
5147 width = visualViewport.width;
5148 height = visualViewport.height;
5149 if (layoutRelativeClientCoords) {
5150 x2 = visualViewport.offsetLeft;
5151 y2 = visualViewport.offsetTop;
5152 }
5153 }
5154 }
5155 const windowScrollbarX = getWindowScrollBarX(html);
5156 if (windowScrollbarX <= 0) {
5157 const doc = html.ownerDocument;
5158 const body = doc.body;
5159 const bodyStyles = getComputedStyle(body);
5160 const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
5161 const reservedWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
5162 const gutter = getComputedStyle(html).scrollbarGutter === "stable both-edges" ? reservedWidth / 2 : reservedWidth;
5163 if (gutter <= SCROLLBAR_MAX) {
5164 width -= gutter;
5165 }
5166 }
5167 return {
5168 width,
5169 height,
5170 x: x2,
5171 y: y2
5172 };
5173 }
5174 function getInnerBoundingClientRect(element, strategy) {
5175 const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
5176 const top = clientRect.top + element.clientTop;
5177 const left = clientRect.left + element.clientLeft;
5178 const scale3 = getScale(element);
5179 const width = element.clientWidth * scale3.x;
5180 const height = element.clientHeight * scale3.y;
5181 const x2 = left * scale3.x;
5182 const y2 = top * scale3.y;
5183 return {
5184 width,
5185 height,
5186 x: x2,
5187 y: y2
5188 };
5189 }
5190 function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
5191 let rect;
5192 if (clippingAncestor === "viewport" || clippingAncestor === "layoutViewport") {
5193 rect = getViewportRect(element, strategy, clippingAncestor);
5194 } else if (clippingAncestor === "document") {
5195 rect = getDocumentRect(getDocumentElement(element));
5196 } else if (isElement(clippingAncestor)) {
5197 rect = getInnerBoundingClientRect(clippingAncestor, strategy);
5198 } else {
5199 const visualOffsets = getVisualOffsets(element);
5200 rect = {
5201 x: clippingAncestor.x - visualOffsets.x,
5202 y: clippingAncestor.y - visualOffsets.y,
5203 width: clippingAncestor.width,
5204 height: clippingAncestor.height
5205 };
5206 }
5207 return rectToClientRect(rect);
5208 }
5209 function getClippingElementAncestors(element, cache) {
5210 const cachedResult = cache.get(element);
5211 if (cachedResult) {
5212 return cachedResult;
5213 }
5214 let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
5215 let lastKeptComputedStyle = null;
5216 const elementIsFixed = getComputedStyle2(element).position === "fixed";
5217 let currentNode = elementIsFixed ? getParentNode(element) : element;
5218 while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
5219 const computedStyle = getComputedStyle2(currentNode);
5220 const currentNodeIsContaining = isContainingBlock(currentNode);
5221 const lastPosition = lastKeptComputedStyle ? lastKeptComputedStyle.position : elementIsFixed ? "fixed" : "";
5222 const shouldDropCurrentNode = !currentNodeIsContaining && (lastPosition === "fixed" || lastPosition === "absolute" && computedStyle.position === "static");
5223 if (shouldDropCurrentNode) {
5224 result = result.filter((ancestor) => ancestor !== currentNode);
5225 } else {
5226 lastKeptComputedStyle = computedStyle;
5227 }
5228 currentNode = getParentNode(currentNode);
5229 }
5230 cache.set(element, result);
5231 return result;
5232 }
5233 function getClippingRect(_ref) {
5234 let {
5235 element,
5236 boundary,
5237 rootBoundary,
5238 strategy
5239 } = _ref;
5240 const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
5241 const clippingAncestors = [...elementClippingAncestors, rootBoundary];
5242 const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy);
5243 let top = firstRect.top;
5244 let right = firstRect.right;
5245 let bottom = firstRect.bottom;
5246 let left = firstRect.left;
5247 for (let i = 1; i < clippingAncestors.length; i++) {
5248 const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i], strategy);
5249 top = max(rect.top, top);
5250 right = min(rect.right, right);
5251 bottom = min(rect.bottom, bottom);
5252 left = max(rect.left, left);
5253 }
5254 return {
5255 width: right - left,
5256 height: bottom - top,
5257 x: left,
5258 y: top
5259 };
5260 }
5261 function getDimensions2(element) {
5262 const {
5263 width,
5264 height
5265 } = getCssDimensions(element);
5266 return {
5267 width,
5268 height
5269 };
5270 }
5271 function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
5272 const isOffsetParentAnElement = isHTMLElement(offsetParent);
5273 const documentElement = getDocumentElement(offsetParent);
5274 const isFixed = strategy === "fixed";
5275 const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
5276 let scroll = {
5277 scrollLeft: 0,
5278 scrollTop: 0
5279 };
5280 const offsets = createCoords(0);
5281 if (isOffsetParentAnElement || !isFixed) {
5282 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
5283 scroll = getNodeScroll(offsetParent);
5284 }
5285 if (isOffsetParentAnElement) {
5286 const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
5287 offsets.x = offsetRect.x + offsetParent.clientLeft;
5288 offsets.y = offsetRect.y + offsetParent.clientTop;
5289 }
5290 }
5291 if (!isOffsetParentAnElement && documentElement) {
5292 offsets.x = getWindowScrollBarX(documentElement);
5293 }
5294 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
5295 const x2 = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
5296 const y2 = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
5297 return {
5298 x: x2,
5299 y: y2,
5300 width: rect.width,
5301 height: rect.height
5302 };
5303 }
5304 function isStaticPositioned(element) {
5305 return getComputedStyle2(element).position === "static";
5306 }
5307 function getTrueOffsetParent(element, polyfill) {
5308 if (!isHTMLElement(element) || getComputedStyle2(element).position === "fixed") {
5309 return null;
5310 }
5311 if (polyfill) {
5312 return polyfill(element);
5313 }
5314 let rawOffsetParent = element.offsetParent;
5315 if (getDocumentElement(element) === rawOffsetParent) {
5316 rawOffsetParent = rawOffsetParent.ownerDocument.body;
5317 }
5318 return rawOffsetParent;
5319 }
5320 function getOffsetParent(element, polyfill) {
5321 const win = getWindow(element);
5322 if (isTopLayer(element)) {
5323 return win;
5324 }
5325 if (!isHTMLElement(element)) {
5326 let svgOffsetParent = getParentNode(element);
5327 while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
5328 if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
5329 return svgOffsetParent;
5330 }
5331 svgOffsetParent = getParentNode(svgOffsetParent);
5332 }
5333 return win;
5334 }
5335 let offsetParent = getTrueOffsetParent(element, polyfill);
5336 while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
5337 offsetParent = getTrueOffsetParent(offsetParent, polyfill);
5338 }
5339 if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
5340 return win;
5341 }
5342 return offsetParent || getContainingBlock(element) || win;
5343 }
5344 var getElementRects = async function(data) {
5345 const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
5346 const getDimensionsFn = this.getDimensions;
5347 const floatingDimensions = await getDimensionsFn(data.floating);
5348 return {
5349 reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
5350 floating: {
5351 x: 0,
5352 y: 0,
5353 width: floatingDimensions.width,
5354 height: floatingDimensions.height
5355 }
5356 };
5357 };
5358 function isRTL(element) {
5359 return getComputedStyle2(element).direction === "rtl";
5360 }
5361 var platform2 = {
5362 convertOffsetParentRelativeRectToViewportRelativeRect,
5363 getDocumentElement,
5364 getClippingRect,
5365 getOffsetParent,
5366 getElementRects,
5367 getClientRects,
5368 getDimensions: getDimensions2,
5369 getScale,
5370 isElement,
5371 isRTL
5372 };
5373 function rectsAreEqual(a, b) {
5374 return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
5375 }
5376 function observeMove(element, onMove, ancestorResize) {
5377 let io = null;
5378 let timeoutId;
5379 const root = getDocumentElement(element);
5380 function cleanup() {
5381 var _io;
5382 clearTimeout(timeoutId);
5383 (_io = io) == null || _io.disconnect();
5384 io = null;
5385 }
5386 function refresh(skip, threshold) {
5387 if (skip === void 0) {
5388 skip = false;
5389 }
5390 if (threshold === void 0) {
5391 threshold = 1;
5392 }
5393 cleanup();
5394 const elementRectForRootMargin = element.getBoundingClientRect();
5395 const {
5396 left,
5397 top,
5398 width,
5399 height
5400 } = elementRectForRootMargin;
5401 if (!skip) {
5402 onMove();
5403 }
5404 if (!width || !height) {
5405 return;
5406 }
5407 const insetTop = floor(top);
5408 const insetRight = floor(root.clientWidth - (left + width));
5409 const insetBottom = floor(root.clientHeight - (top + height));
5410 const insetLeft = floor(left);
5411 const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
5412 const options = {
5413 rootMargin,
5414 threshold: max(0, min(1, threshold)) || 1
5415 };
5416 let isFirstUpdate = true;
5417 function handleObserve(entries) {
5418 const ratio = entries[0].intersectionRatio;
5419 if (!rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
5420 return refresh();
5421 }
5422 if (ratio !== threshold) {
5423 if (!isFirstUpdate) {
5424 return refresh();
5425 }
5426 if (!ratio) {
5427 timeoutId = setTimeout(() => {
5428 refresh(false, 1e-7);
5429 }, 1e3);
5430 } else {
5431 refresh(false, ratio);
5432 }
5433 }
5434 isFirstUpdate = false;
5435 }
5436 try {
5437 io = new IntersectionObserver(handleObserve, {
5438 ...options,
5439 // Handle <iframe>s
5440 root: root.ownerDocument
5441 });
5442 } catch (_e) {
5443 io = new IntersectionObserver(handleObserve, options);
5444 }
5445 io.observe(element);
5446 }
5447 const win = getWindow(element);
5448 const handleResize = () => refresh(ancestorResize);
5449 win.addEventListener("resize", handleResize);
5450 refresh(true);
5451 return () => {
5452 win.removeEventListener("resize", handleResize);
5453 cleanup();
5454 };
5455 }
5456 function autoUpdate(reference, floating, update2, options) {
5457 if (options === void 0) {
5458 options = {};
5459 }
5460 const {
5461 ancestorScroll = true,
5462 ancestorResize = true,
5463 elementResize = typeof ResizeObserver === "function",
5464 layoutShift = typeof IntersectionObserver === "function",
5465 animationFrame = false
5466 } = options;
5467 const referenceEl = unwrapElement(reference);
5468 const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...floating ? getOverflowAncestors(floating) : []] : [];
5469 ancestors.forEach((ancestor) => {
5470 ancestorScroll && ancestor.addEventListener("scroll", update2);
5471 ancestorResize && ancestor.addEventListener("resize", update2);
5472 });
5473 const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update2, ancestorResize) : null;
5474 let reobserveFrame = -1;
5475 let resizeObserver = null;
5476 if (elementResize) {
5477 resizeObserver = new ResizeObserver((_ref) => {
5478 let [firstEntry] = _ref;
5479 if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) {
5480 resizeObserver.unobserve(floating);
5481 cancelAnimationFrame(reobserveFrame);
5482 reobserveFrame = requestAnimationFrame(() => {
5483 var _resizeObserver;
5484 (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
5485 });
5486 }
5487 update2();
5488 });
5489 if (referenceEl && !animationFrame) {
5490 resizeObserver.observe(referenceEl);
5491 }
5492 if (floating) {
5493 resizeObserver.observe(floating);
5494 }
5495 }
5496 let frameId;
5497 let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
5498 if (animationFrame) {
5499 frameLoop();
5500 }
5501 function frameLoop() {
5502 const nextRefRect = getBoundingClientRect(reference);
5503 if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
5504 update2();
5505 }
5506 prevRefRect = nextRefRect;
5507 frameId = requestAnimationFrame(frameLoop);
5508 }
5509 update2();
5510 return () => {
5511 var _resizeObserver2;
5512 ancestors.forEach((ancestor) => {
5513 ancestorScroll && ancestor.removeEventListener("scroll", update2);
5514 ancestorResize && ancestor.removeEventListener("resize", update2);
5515 });
5516 cleanupIo == null || cleanupIo();
5517 (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
5518 resizeObserver = null;
5519 if (animationFrame) {
5520 cancelAnimationFrame(frameId);
5521 }
5522 };
5523 }
5524 var offset2 = offset;
5525 var shift2 = shift;
5526 var flip2 = flip;
5527 var size2 = size;
5528 var limitShift2 = limitShift;
5529 var computePosition2 = (reference, floating, options) => {
5530 const cache = /* @__PURE__ */ new Map();
5531 const mergedOptions = options != null ? options : {};
5532 const platformWithCache = {
5533 ...platform2,
5534 ...mergedOptions.platform,
5535 _c: cache
5536 };
5537 return computePosition(reference, floating, {
5538 ...mergedOptions,
5539 platform: platformWithCache
5540 });
5541 };
5542
5543 // node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.mjs
5544 var React27 = __toESM(require_react(), 1);
5545 var import_react2 = __toESM(require_react(), 1);
5546 var ReactDOM3 = __toESM(require_react_dom(), 1);
5547 var isClient = typeof document !== "undefined";
5548 var noop2 = function noop3() {
5549 };
5550 var index = isClient ? import_react2.useLayoutEffect : noop2;
5551 function deepEqual(a, b) {
5552 if (a === b) {
5553 return true;
5554 }
5555 if (typeof a !== typeof b) {
5556 return false;
5557 }
5558 if (typeof a === "function" && a.toString() === b.toString()) {
5559 return true;
5560 }
5561 let length2;
5562 let i;
5563 let keys;
5564 if (a && b && typeof a === "object") {
5565 if (Array.isArray(a)) {
5566 length2 = a.length;
5567 if (length2 !== b.length) return false;
5568 for (i = length2; i-- !== 0; ) {
5569 if (!deepEqual(a[i], b[i])) {
5570 return false;
5571 }
5572 }
5573 return true;
5574 }
5575 keys = Object.keys(a);
5576 length2 = keys.length;
5577 if (length2 !== Object.keys(b).length) {
5578 return false;
5579 }
5580 for (i = length2; i-- !== 0; ) {
5581 if (!{}.hasOwnProperty.call(b, keys[i])) {
5582 return false;
5583 }
5584 }
5585 for (i = length2; i-- !== 0; ) {
5586 const key = keys[i];
5587 if (key === "_owner" && a.$$typeof) {
5588 continue;
5589 }
5590 if (!deepEqual(a[key], b[key])) {
5591 return false;
5592 }
5593 }
5594 return true;
5595 }
5596 return a !== a && b !== b;
5597 }
5598 function getDPR(element) {
5599 if (typeof window === "undefined") {
5600 return 1;
5601 }
5602 const win = element.ownerDocument.defaultView || window;
5603 return win.devicePixelRatio || 1;
5604 }
5605 function roundByDPR(element, value) {
5606 const dpr = getDPR(element);
5607 return Math.round(value * dpr) / dpr;
5608 }
5609 function useLatestRef(value) {
5610 const ref = React27.useRef(value);
5611 index(() => {
5612 ref.current = value;
5613 });
5614 return ref;
5615 }
5616 function useFloating(options) {
5617 if (options === void 0) {
5618 options = {};
5619 }
5620 const {
5621 placement = "bottom",
5622 strategy = "absolute",
5623 middleware = [],
5624 platform: platform3,
5625 elements: {
5626 reference: externalReference,
5627 floating: externalFloating
5628 } = {},
5629 transform = true,
5630 whileElementsMounted,
5631 open: open3
5632 } = options;
5633 const [data, setData] = React27.useState({
5634 x: 0,
5635 y: 0,
5636 strategy,
5637 placement,
5638 middlewareData: {},
5639 isPositioned: false
5640 });
5641 const [latestMiddleware, setLatestMiddleware] = React27.useState(middleware);
5642 if (!deepEqual(latestMiddleware, middleware)) {
5643 setLatestMiddleware(middleware);
5644 }
5645 const [_reference, _setReference] = React27.useState(null);
5646 const [_floating, _setFloating] = React27.useState(null);
5647 const setReference = React27.useCallback((node) => {
5648 if (node !== referenceRef.current) {
5649 referenceRef.current = node;
5650 _setReference(node);
5651 }
5652 }, []);
5653 const setFloating = React27.useCallback((node) => {
5654 if (node !== floatingRef.current) {
5655 floatingRef.current = node;
5656 _setFloating(node);
5657 }
5658 }, []);
5659 const referenceEl = externalReference || _reference;
5660 const floatingEl = externalFloating || _floating;
5661 const referenceRef = React27.useRef(null);
5662 const floatingRef = React27.useRef(null);
5663 const dataRef = React27.useRef(data);
5664 const hasWhileElementsMounted = whileElementsMounted != null;
5665 const whileElementsMountedRef = useLatestRef(whileElementsMounted);
5666 const platformRef = useLatestRef(platform3);
5667 const openRef = useLatestRef(open3);
5668 const update2 = React27.useCallback(() => {
5669 if (!referenceRef.current || !floatingRef.current) {
5670 return;
5671 }
5672 const config = {
5673 placement,
5674 strategy,
5675 middleware: latestMiddleware
5676 };
5677 if (platformRef.current) {
5678 config.platform = platformRef.current;
5679 }
5680 computePosition2(referenceRef.current, floatingRef.current, config).then((data2) => {
5681 const fullData = {
5682 ...data2,
5683 // The floating element's position may be recomputed while it's closed
5684 // but still mounted (such as when transitioning out). To ensure
5685 // `isPositioned` will be `false` initially on the next open, avoid
5686 // setting it to `true` when `open === false` (must be specified).
5687 isPositioned: openRef.current !== false
5688 };
5689 if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
5690 dataRef.current = fullData;
5691 ReactDOM3.flushSync(() => {
5692 setData(fullData);
5693 });
5694 }
5695 });
5696 }, [latestMiddleware, placement, strategy, platformRef, openRef]);
5697 index(() => {
5698 if (open3 === false && dataRef.current.isPositioned) {
5699 dataRef.current.isPositioned = false;
5700 setData((data2) => ({
5701 ...data2,
5702 isPositioned: false
5703 }));
5704 }
5705 }, [open3]);
5706 const isMountedRef = React27.useRef(false);
5707 index(() => {
5708 isMountedRef.current = true;
5709 return () => {
5710 isMountedRef.current = false;
5711 };
5712 }, []);
5713 index(() => {
5714 if (referenceEl) referenceRef.current = referenceEl;
5715 if (floatingEl) floatingRef.current = floatingEl;
5716 if (referenceEl && floatingEl) {
5717 if (whileElementsMountedRef.current) {
5718 return whileElementsMountedRef.current(referenceEl, floatingEl, update2);
5719 }
5720 update2();
5721 }
5722 }, [referenceEl, floatingEl, update2, whileElementsMountedRef, hasWhileElementsMounted]);
5723 const refs = React27.useMemo(() => ({
5724 reference: referenceRef,
5725 floating: floatingRef,
5726 setReference,
5727 setFloating
5728 }), [setReference, setFloating]);
5729 const elements = React27.useMemo(() => ({
5730 reference: referenceEl,
5731 floating: floatingEl
5732 }), [referenceEl, floatingEl]);
5733 const floatingStyles = React27.useMemo(() => {
5734 const initialStyles = {
5735 position: strategy,
5736 left: 0,
5737 top: 0
5738 };
5739 if (!elements.floating) {
5740 return initialStyles;
5741 }
5742 const x2 = roundByDPR(elements.floating, data.x);
5743 const y2 = roundByDPR(elements.floating, data.y);
5744 if (transform) {
5745 return {
5746 ...initialStyles,
5747 transform: "translate(" + x2 + "px, " + y2 + "px)",
5748 ...getDPR(elements.floating) >= 1.5 && {
5749 willChange: "transform"
5750 }
5751 };
5752 }
5753 return {
5754 position: strategy,
5755 left: x2,
5756 top: y2
5757 };
5758 }, [strategy, transform, elements.floating, data.x, data.y]);
5759 return React27.useMemo(() => ({
5760 ...data,
5761 update: update2,
5762 refs,
5763 elements,
5764 floatingStyles
5765 }), [data, update2, refs, elements, floatingStyles]);
5766 }
5767 var offset3 = (options, deps) => {
5768 const result = offset2(options);
5769 return {
5770 name: result.name,
5771 fn: result.fn,
5772 options: [options, deps]
5773 };
5774 };
5775 var shift3 = (options, deps) => {
5776 const result = shift2(options);
5777 return {
5778 name: result.name,
5779 fn: result.fn,
5780 options: [options, deps]
5781 };
5782 };
5783 var limitShift3 = (options, deps) => {
5784 const result = limitShift2(options);
5785 return {
5786 fn: result.fn,
5787 options: [options, deps]
5788 };
5789 };
5790 var flip3 = (options, deps) => {
5791 const result = flip2(options);
5792 return {
5793 name: result.name,
5794 fn: result.fn,
5795 options: [options, deps]
5796 };
5797 };
5798 var size3 = (options, deps) => {
5799 const result = size2(options);
5800 return {
5801 name: result.name,
5802 fn: result.fn,
5803 options: [options, deps]
5804 };
5805 };
5806
5807 // node_modules/@base-ui/react/utils/popups/popupHandle.mjs
5808 var BasePopupHandle = class {
5809 /**
5810 * Stores of every root currently using this handle, in attach order. A handle is meant to be used
5811 * by a single mounted root, but roots can transiently overlap (e.g. during an animated route
5812 * transition), so this stack lets `attachStore`'s cleanup restore the previous root instead of
5813 * leaving a still-mounted root uncontrollable when a newer overlapping root detaches first.
5814 */
5815 attachedStores = [];
5816 /**
5817 * Store of the root that currently controls the handle: the most recently attached one still
5818 * mounted, or `null` when no root is attached. Imperative methods are no-ops while this is `null`.
5819 */
5820 attachedStoreValue = null;
5821 /**
5822 * Listeners notified when `attachedStore` changes, so detached triggers can follow the store pointer.
5823 */
5824 storeListeners = /* @__PURE__ */ new Set();
5825 /**
5826 * Creates a handle backed by the store used while no root is attached.
5827 *
5828 * @param fallbackStore Inert, closed store handed to detached triggers while no root is attached,
5829 * so they can render and register without a mounted root. Triggers register into whichever store
5830 * `store` currently resolves to, so while detached they live in this store's trigger map and
5831 * migrate themselves to the root's store (and back) as it attaches/detaches.
5832 * @param componentName Component name used to prefix dev warnings, e.g. `'Menu'` produces
5833 * `MenuHandle.open()` in warning text.
5834 * @param throwOnMissingTrigger Whether `open(triggerId)` throws when no trigger with that id is
5835 * registered. Anchored popups (Menu, Popover, Tooltip, PreviewCard) need a trigger to anchor to,
5836 * so they throw; Dialog is not anchored and instead opens unassociated with a dev warning.
5837 */
5838 constructor(fallbackStore, componentName, throwOnMissingTrigger = true) {
5839 this.fallbackStore = fallbackStore;
5840 this.componentName = componentName;
5841 this.throwOnMissingTrigger = throwOnMissingTrigger;
5842 }
5843 get attachedStore() {
5844 return this.attachedStoreValue;
5845 }
5846 /**
5847 * Store that detached triggers read from: the attached root's store, or an inert fallback store
5848 * used while no root is attached.
5849 * @internal
5850 */
5851 get store() {
5852 return this.attachedStoreValue ?? this.fallbackStore;
5853 }
5854 /**
5855 * Stable fallback store used for server rendering and hydration. Root stores cannot be recorded on
5856 * the handle during render because a handle can be shared by concurrent server-rendered requests.
5857 * @internal
5858 */
5859 get serverStore() {
5860 return this.fallbackStore;
5861 }
5862 /**
5863 * Subscribes to changes of the attached store pointer so detached triggers re-render and re-bind
5864 * when a root attaches or detaches. Returns a function that removes the listener.
5865 * @internal
5866 */
5867 subscribeStore(listener) {
5868 this.storeListeners.add(listener);
5869 return () => {
5870 this.storeListeners.delete(listener);
5871 };
5872 }
5873 /**
5874 * Points the handle at a root's store and notifies subscribers so detached triggers re-render and
5875 * re-register into it (their registration effect migrates them when the store pointer changes).
5876 * Returns a cleanup function that detaches the store again.
5877 * @internal
5878 */
5879 attachStore(newStore) {
5880 this.attachedStores.push(newStore);
5881 this.setActiveStore(newStore);
5882 if (true) {
5883 if (this.attachedStores.length > 1) {
5884 const dev = this;
5885 (dev.overlapWarningFrame ??= AnimationFrame.create()).request(() => {
5886 if (this.attachedStores.length > 1) {
5887 console.warn("Base UI: A handle is attached to more than one mounted root at the same time. The most recently mounted root takes over and the previous one stops being controlled by the handle. A handle should be used by a single root that stays mounted for the lifetime of the handle.");
5888 }
5889 });
5890 }
5891 }
5892 return () => {
5893 const index3 = this.attachedStores.lastIndexOf(newStore);
5894 if (index3 !== -1) {
5895 this.attachedStores.splice(index3, 1);
5896 }
5897 this.setActiveStore(this.attachedStores[this.attachedStores.length - 1] ?? null);
5898 };
5899 }
5900 /**
5901 * Sets the store that currently controls the handle and notifies subscribers when it changes, so
5902 * detached triggers re-render and migrate their registration to the new store.
5903 */
5904 setActiveStore(store2) {
5905 if (this.attachedStoreValue !== store2) {
5906 this.attachedStoreValue = store2;
5907 this.storeListeners.forEach((listener) => {
5908 listener();
5909 });
5910 }
5911 }
5912 /**
5913 * Opens the attached root's store and associates it with the trigger with the given id, or a
5914 * no-op (with a dev warning) while no root is attached. Shared by every concrete handle's public
5915 * `open()` method, which only narrows the parameter type.
5916 *
5917 * When a trigger id is given but no matching trigger is registered, anchored popups throw (see
5918 * `throwOnMissingTrigger`); Dialog opens unassociated with a dev warning instead.
5919 *
5920 * This method should only be called in an event handler or an effect (not during rendering).
5921 *
5922 * @param triggerId ID of the trigger to associate with the popup, or `null`/`undefined` to open
5923 * without associating any trigger.
5924 */
5925 openByTrigger(triggerId) {
5926 const attachedStore = this.attachedStore;
5927 if (attachedStore === null) {
5928 if (true) {
5929 console.warn(`Base UI: ${this.componentName}Handle.open() was called while no root using this handle is mounted. The call was ignored; mount a root with this handle before opening it imperatively.`);
5930 }
5931 return;
5932 }
5933 let triggerElement;
5934 if (triggerId) {
5935 for (let i = this.attachedStores.length - 1; i >= 0 && !triggerElement; i -= 1) {
5936 triggerElement = this.attachedStores[i].context.triggerElements.getById(triggerId);
5937 }
5938 triggerElement ??= this.fallbackStore.context.triggerElements.getById(triggerId);
5939 }
5940 if (triggerId && !triggerElement) {
5941 if (this.throwOnMissingTrigger) {
5942 throw new Error(true ? `Base UI: ${this.componentName}Handle.open() was called with the trigger id "${triggerId}", but no matching trigger is registered with this handle. An anchored popup cannot open without a trigger to anchor to. Pass the id of a mounted ${this.componentName}.Trigger that has this handle set on its "handle" prop.` : formatErrorMessage_default(99, this.componentName, triggerId, this.componentName));
5943 }
5944 if (true) {
5945 console.warn(`Base UI: ${this.componentName}Handle.open: No trigger found with id "${triggerId}". The popup will open, but the trigger will not be associated with it.`);
5946 }
5947 }
5948 attachedStore.setOpen(true, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, triggerElement));
5949 }
5950 /**
5951 * Closes the popup by setting the attached root's store to closed, or a no-op (with a dev warning)
5952 * while no root is attached. Shared by every concrete handle's public `close()` method.
5953 *
5954 * This method should only be called in an event handler or an effect (not during rendering).
5955 */
5956 closePopup() {
5957 const attachedStore = this.attachedStore;
5958 if (attachedStore === null) {
5959 if (true) {
5960 console.warn(`Base UI: ${this.componentName}Handle.close() was called while no root using this handle is mounted. The call was ignored.`);
5961 }
5962 return;
5963 }
5964 attachedStore.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction));
5965 }
5966 };
5967
5968 // node_modules/@base-ui/react/utils/popups/popupStoreUtils.mjs
5969 var React33 = __toESM(require_react(), 1);
5970 var ReactDOM4 = __toESM(require_react_dom(), 1);
5971
5972 // node_modules/@base-ui/react/floating-ui-react/hooks/useSyncedFloatingRootContext.mjs
5973 var React32 = __toESM(require_react(), 1);
5974
5975 // node_modules/@base-ui/utils/store/useStore.mjs
5976 var React29 = __toESM(require_react(), 1);
5977 var import_shim = __toESM(require_shim(), 1);
5978 var import_with_selector = __toESM(require_with_selector(), 1);
5979
5980 // node_modules/@base-ui/utils/fastHooks.mjs
5981 var React28 = __toESM(require_react(), 1);
5982 var hooks = [];
5983 var currentInstance = void 0;
5984 function getInstance() {
5985 return currentInstance;
5986 }
5987 function register(hook) {
5988 hooks.push(hook);
5989 }
5990 function fastComponent(fn) {
5991 const FastComponent = (props, forwardedRef) => {
5992 const instance = useRefWithInit(createInstance).current;
5993 let result;
5994 try {
5995 currentInstance = instance;
5996 for (const hook of hooks) {
5997 hook.before(instance);
5998 }
5999 result = fn(props, forwardedRef);
6000 for (const hook of hooks) {
6001 hook.after(instance);
6002 }
6003 instance.didInitialize = true;
6004 } finally {
6005 currentInstance = void 0;
6006 }
6007 return result;
6008 };
6009 FastComponent.displayName = fn.displayName || fn.name;
6010 return FastComponent;
6011 }
6012 function fastComponentRef(fn) {
6013 return /* @__PURE__ */ React28.forwardRef(fastComponent(fn));
6014 }
6015 function createInstance() {
6016 return {
6017 didInitialize: false
6018 };
6019 }
6020
6021 // node_modules/@base-ui/utils/store/useStore.mjs
6022 var canUseRawUseSyncExternalStore = isReactVersionAtLeast(19);
6023 var useStoreImplementation = canUseRawUseSyncExternalStore ? useStoreFast : useStoreLegacy;
6024 function useStore(store2, selector, a1, a2, a3) {
6025 return useStoreImplementation(store2, selector, a1, a2, a3);
6026 }
6027 function useStoreR19(store2, selector, a1, a2, a3) {
6028 const getSelection = React29.useCallback(() => selector(store2.getSnapshot(), a1, a2, a3), [store2, selector, a1, a2, a3]);
6029 return (0, import_shim.useSyncExternalStore)(store2.subscribe, getSelection, getSelection);
6030 }
6031 register({
6032 before(instance) {
6033 instance.syncIndex = 0;
6034 if (!instance.didInitialize) {
6035 instance.syncTick = 1;
6036 instance.syncHooks = [];
6037 instance.didChangeStore = true;
6038 instance.getSnapshot = () => {
6039 let didChange2 = false;
6040 for (let i = 0; i < instance.syncHooks.length; i += 1) {
6041 const hook = instance.syncHooks[i];
6042 const value = hook.selector(hook.store.state, hook.a1, hook.a2, hook.a3);
6043 if (!Object.is(hook.value, value)) {
6044 didChange2 = true;
6045 hook.value = value;
6046 }
6047 }
6048 if (didChange2) {
6049 instance.syncTick += 1;
6050 }
6051 return instance.syncTick;
6052 };
6053 }
6054 },
6055 after(instance) {
6056 if (instance.syncHooks.length > 0) {
6057 if (instance.didChangeStore) {
6058 instance.didChangeStore = false;
6059 instance.subscribe = (onStoreChange) => {
6060 const stores = /* @__PURE__ */ new Set();
6061 for (const hook of instance.syncHooks) {
6062 stores.add(hook.store);
6063 }
6064 const unsubscribes = [];
6065 for (const store2 of stores) {
6066 unsubscribes.push(store2.subscribe(onStoreChange));
6067 }
6068 return () => {
6069 for (const unsubscribe of unsubscribes) {
6070 unsubscribe();
6071 }
6072 };
6073 };
6074 }
6075 (0, import_shim.useSyncExternalStore)(instance.subscribe, instance.getSnapshot, instance.getSnapshot);
6076 }
6077 }
6078 });
6079 function useStoreFast(store2, selector, a1, a2, a3) {
6080 const instance = getInstance();
6081 if (!instance) {
6082 return useStoreR19(store2, selector, a1, a2, a3);
6083 }
6084 const index3 = instance.syncIndex;
6085 instance.syncIndex += 1;
6086 let hook;
6087 if (!instance.didInitialize) {
6088 hook = {
6089 store: store2,
6090 selector,
6091 a1,
6092 a2,
6093 a3,
6094 value: selector(store2.getSnapshot(), a1, a2, a3)
6095 };
6096 instance.syncHooks.push(hook);
6097 } else {
6098 hook = instance.syncHooks[index3];
6099 if (hook.store !== store2 || hook.selector !== selector || !Object.is(hook.a1, a1) || !Object.is(hook.a2, a2) || !Object.is(hook.a3, a3)) {
6100 if (hook.store !== store2) {
6101 instance.didChangeStore = true;
6102 }
6103 hook.store = store2;
6104 hook.selector = selector;
6105 hook.a1 = a1;
6106 hook.a2 = a2;
6107 hook.a3 = a3;
6108 hook.value = selector(store2.getSnapshot(), a1, a2, a3);
6109 }
6110 }
6111 return hook.value;
6112 }
6113 function useStoreLegacy(store2, selector, a1, a2, a3) {
6114 return (0, import_with_selector.useSyncExternalStoreWithSelector)(store2.subscribe, store2.getSnapshot, store2.getSnapshot, (state) => selector(state, a1, a2, a3));
6115 }
6116
6117 // node_modules/@base-ui/utils/store/Store.mjs
6118 var Store = class {
6119 /**
6120 * Creates a store with the given initial state, constructing the class it is called on.
6121 * Calling it on a generic base class (e.g. `ReactStore.create(...)`) constructs that
6122 * class but degrades the inferred instance type to `Store`; use `new` there instead.
6123 */
6124 static create(state) {
6125 return new this(state);
6126 }
6127 /**
6128 * The current state of the store.
6129 * This property is updated immediately when the state changes as a result of calling {@link setState}, {@link update}, or {@link set}.
6130 * 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).
6131 * The values can be used directly (to avoid subscribing to the store) in effects or event handlers.
6132 *
6133 * Do not modify properties in state directly. Instead, use the provided methods to ensure proper state management and listener notification.
6134 */
6135 // Internal state to handle recursive `setState()` calls
6136 constructor(state) {
6137 this.state = state;
6138 this.listeners = /* @__PURE__ */ new Set();
6139 this.updateTick = 0;
6140 }
6141 /**
6142 * Registers a listener that will be called whenever the store's state changes.
6143 *
6144 * @param fn The listener function to be called on state changes.
6145 * @returns A function to unsubscribe the listener.
6146 */
6147 subscribe = (fn) => {
6148 this.listeners.add(fn);
6149 return () => {
6150 this.listeners.delete(fn);
6151 };
6152 };
6153 /**
6154 * Returns the current state of the store.
6155 */
6156 getSnapshot = () => {
6157 return this.state;
6158 };
6159 /**
6160 * Updates the entire store's state and notifies all registered listeners.
6161 *
6162 * @param newState The new state to set for the store.
6163 */
6164 setState(newState) {
6165 if (this.state === newState) {
6166 return;
6167 }
6168 this.state = newState;
6169 this.updateTick += 1;
6170 const currentTick = this.updateTick;
6171 for (const listener of this.listeners) {
6172 if (currentTick !== this.updateTick) {
6173 return;
6174 }
6175 listener(newState);
6176 }
6177 }
6178 /**
6179 * Merges the provided changes into the current state and notifies listeners if there are changes.
6180 * Each value must match its state key. Pass an exact known subset rather than a broad
6181 * `Partial<State>`, which may contain `undefined` for required state fields.
6182 *
6183 * @param changes An object containing the changes to apply to the current state.
6184 */
6185 update(changes) {
6186 for (const key in changes) {
6187 if (!Object.is(this.state[key], changes[key])) {
6188 this.setState({
6189 ...this.state,
6190 ...changes
6191 });
6192 return;
6193 }
6194 }
6195 }
6196 /**
6197 * Sets a specific key in the store's state to a new value and notifies listeners if the value has changed.
6198 *
6199 * @param key The key in the store's state to update.
6200 * @param value The new value to set for the specified key.
6201 */
6202 set(key, value) {
6203 if (!Object.is(this.state[key], value)) {
6204 this.setState({
6205 ...this.state,
6206 [key]: value
6207 });
6208 }
6209 }
6210 /**
6211 * Gives the state a new reference and updates all registered listeners.
6212 */
6213 notifyAll() {
6214 const newState = {
6215 ...this.state
6216 };
6217 this.setState(newState);
6218 }
6219 use(selector, a1, a2, a3) {
6220 return useStore(this, selector, a1, a2, a3);
6221 }
6222 };
6223
6224 // node_modules/@base-ui/utils/store/ReactStore.mjs
6225 var React30 = __toESM(require_react(), 1);
6226 var ReactStore = class extends Store {
6227 /**
6228 * Creates a new ReactStore instance.
6229 *
6230 * @param state Initial state of the store.
6231 * @param context Non-reactive context values.
6232 * @param selectors Optional selectors for use with `useState`.
6233 */
6234 constructor(state, context = {}, selectors3) {
6235 super(state);
6236 this.context = context;
6237 this.selectors = selectors3;
6238 }
6239 /**
6240 * Non-reactive values such as refs, callbacks, etc.
6241 */
6242 /**
6243 * Synchronizes a single external value into the store.
6244 *
6245 * Note that the while the value in `state` is updated immediately, the value returned
6246 * by `useState` is updated before the next render (similarly to React's `useState`).
6247 */
6248 useSyncedValue(key, value) {
6249 React30.useDebugValue(key);
6250 const store2 = this;
6251 useIsoLayoutEffect(() => {
6252 if (store2.state[key] !== value) {
6253 store2.set(key, value);
6254 }
6255 }, [store2, key, value]);
6256 }
6257 /**
6258 * Synchronizes a single external value into the store and
6259 * cleans it up (sets to `undefined`) on unmount.
6260 *
6261 * Note that the while the value in `state` is updated immediately, the value returned
6262 * by `useState` is updated before the next render (similarly to React's `useState`).
6263 */
6264 useSyncedValueWithCleanup(key, value) {
6265 const store2 = this;
6266 useIsoLayoutEffect(() => {
6267 if (store2.state[key] !== value) {
6268 store2.set(key, value);
6269 }
6270 return () => {
6271 store2.set(key, void 0);
6272 };
6273 }, [store2, key, value]);
6274 }
6275 /**
6276 * Synchronizes multiple external values into the store.
6277 * Each value must match its state key. Pass an exact known subset rather than a broad
6278 * `Partial<State>`, which may contain `undefined` for required state fields.
6279 *
6280 * Note that the while the values in `state` are updated immediately, the values returned
6281 * by `useState` are updated before the next render (similarly to React's `useState`).
6282 *
6283 * @param statePart An exact subset of state fields to synchronize. Unknown keys are not accepted.
6284 */
6285 useSyncedValues(statePart) {
6286 const store2 = this;
6287 if (true) {
6288 React30.useDebugValue(statePart, (p2) => Object.keys(p2));
6289 const keys = React30.useRef(Object.keys(statePart)).current;
6290 const nextKeys = Object.keys(statePart);
6291 if (keys.length !== nextKeys.length || keys.some((key, index3) => key !== nextKeys[index3])) {
6292 console.error("ReactStore.useSyncedValues expects the same prop keys on every render. Keys should be stable.");
6293 }
6294 }
6295 const dependencies = Object.values(statePart);
6296 useIsoLayoutEffect(() => {
6297 store2.update(statePart);
6298 }, [store2, ...dependencies]);
6299 }
6300 /**
6301 * Registers a controllable prop pair (`controlled`, `defaultValue`) for a specific key. If `controlled`
6302 * is non-undefined, the store's state at `key` is updated to match `controlled`.
6303 */
6304 useControlledProp(key, controlled) {
6305 React30.useDebugValue(key);
6306 const store2 = this;
6307 const isControlled = controlled !== void 0;
6308 useIsoLayoutEffect(() => {
6309 if (isControlled && !Object.is(store2.state[key], controlled)) {
6310 store2.setState({
6311 ...store2.state,
6312 [key]: controlled
6313 });
6314 }
6315 }, [store2, key, controlled, isControlled]);
6316 if (true) {
6317 const cache = this.controlledValues ??= /* @__PURE__ */ new Map();
6318 if (!cache.has(key)) {
6319 cache.set(key, isControlled);
6320 }
6321 const previouslyControlled = cache.get(key);
6322 if (previouslyControlled !== void 0 && previouslyControlled !== isControlled) {
6323 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).`);
6324 }
6325 }
6326 }
6327 /** Gets the current value from the store using a selector with the provided key.
6328 *
6329 * @param key Key of the selector to use.
6330 */
6331 select(key, a1, a2, a3) {
6332 const selector = this.selectors[key];
6333 return selector(this.state, a1, a2, a3);
6334 }
6335 /**
6336 * Returns a value from the store's state using a selector function.
6337 * Used to subscribe to specific parts of the state.
6338 * This methods causes a rerender whenever the selected state changes.
6339 *
6340 * @param key Key of the selector to use.
6341 */
6342 useState(key, a1, a2, a3) {
6343 React30.useDebugValue(key);
6344 return useStore(this, this.selectors[key], a1, a2, a3);
6345 }
6346 /**
6347 * Wraps a function with `useStableCallback` to ensure it has a stable reference
6348 * and assigns it to the context.
6349 *
6350 * @param key Key of the event callback. Must be a function in the context.
6351 * @param fn Function to assign.
6352 */
6353 useContextCallback(key, fn) {
6354 React30.useDebugValue(key);
6355 const stableFunction = useStableCallback(fn ?? NOOP);
6356 this.context[key] = stableFunction;
6357 }
6358 /**
6359 * Returns a stable setter function for a specific key in the store's state.
6360 * It's commonly used to pass as a ref callback to React elements.
6361 *
6362 * @param key Key of the state to set.
6363 */
6364 useStateSetter(key) {
6365 const ref = React30.useRef(void 0);
6366 if (ref.current === void 0) {
6367 ref.current = (value) => {
6368 this.set(key, value);
6369 };
6370 }
6371 return ref.current;
6372 }
6373 /**
6374 * Observes changes derived from the store's selectors and calls the listener when the selected value changes.
6375 *
6376 * @param key Key of the selector to observe.
6377 * @param listener Listener function called when the selector result changes.
6378 */
6379 observe(selector, listener) {
6380 let selectFn;
6381 if (typeof selector === "function") {
6382 selectFn = selector;
6383 } else {
6384 selectFn = this.selectors[selector];
6385 }
6386 let prevValue = selectFn(this.state);
6387 listener(prevValue, prevValue, this);
6388 return this.subscribe((nextState) => {
6389 const nextValue = selectFn(nextState);
6390 if (!Object.is(prevValue, nextValue)) {
6391 const oldValue = prevValue;
6392 prevValue = nextValue;
6393 listener(nextValue, oldValue, this);
6394 }
6395 });
6396 }
6397 };
6398
6399 // node_modules/@base-ui/utils/useForcedRerendering.mjs
6400 var React31 = __toESM(require_react(), 1);
6401 function useForcedRerendering() {
6402 const [, setState] = React31.useState({});
6403 return React31.useCallback(() => {
6404 setState({});
6405 }, []);
6406 }
6407
6408 // node_modules/@base-ui/react/floating-ui-react/components/FloatingRootStore.mjs
6409 var selectors = {
6410 open: (state) => state.open,
6411 transitionStatus: (state) => state.transitionStatus,
6412 domReferenceElement: (state) => state.domReferenceElement,
6413 referenceElement: (state) => state.positionReference ?? state.referenceElement,
6414 floatingElement: (state) => state.floatingElement,
6415 floatingId: (state) => state.floatingId
6416 };
6417 var FloatingRootStore = class extends ReactStore {
6418 constructor(options) {
6419 const {
6420 syncOnly,
6421 nested,
6422 onOpenChange,
6423 triggerElements,
6424 ...initialState
6425 } = options;
6426 super({
6427 ...initialState,
6428 positionReference: initialState.referenceElement,
6429 domReferenceElement: initialState.referenceElement
6430 }, {
6431 onOpenChange,
6432 dataRef: {
6433 current: {}
6434 },
6435 events: createEventEmitter(),
6436 nested,
6437 triggerElements
6438 }, selectors);
6439 this.syncOnly = syncOnly;
6440 }
6441 /**
6442 * Syncs the event used by hover logic to distinguish hover-open from click-like interaction.
6443 */
6444 syncOpenEvent = (newOpen, event) => {
6445 if (!newOpen || !this.state.open || // Prevent a pending hover-open from overwriting a click-open event, while allowing
6446 // click events to upgrade a hover-open.
6447 event != null && isClickLikeEvent(event)) {
6448 this.context.dataRef.current.openEvent = newOpen ? event : void 0;
6449 }
6450 };
6451 /**
6452 * Runs the root-owned side effects for an open state change.
6453 */
6454 dispatchOpenChange = (newOpen, eventDetails) => {
6455 this.syncOpenEvent(newOpen, eventDetails.event);
6456 const details = {
6457 open: newOpen,
6458 reason: eventDetails.reason,
6459 nativeEvent: eventDetails.event,
6460 nested: this.context.nested,
6461 triggerElement: eventDetails.trigger
6462 };
6463 this.context.events.emit("openchange", details);
6464 };
6465 /**
6466 * Emits the `openchange` event through the internal event emitter and calls the `onOpenChange` handler with the provided arguments.
6467 *
6468 * @param newOpen The new open state.
6469 * @param eventDetails Details about the event that triggered the open state change.
6470 */
6471 setOpen = (newOpen, eventDetails) => {
6472 if (this.syncOnly) {
6473 this.context.onOpenChange?.(newOpen, eventDetails);
6474 return;
6475 }
6476 this.dispatchOpenChange(newOpen, eventDetails);
6477 this.context.onOpenChange?.(newOpen, eventDetails);
6478 };
6479 };
6480
6481 // node_modules/@base-ui/react/floating-ui-react/hooks/useSyncedFloatingRootContext.mjs
6482 function useSyncedFloatingRootContext(options) {
6483 const {
6484 popupStore,
6485 treatPopupAsFloatingElement = false,
6486 floatingRootContext: floatingRootContextProp,
6487 floatingId,
6488 nested,
6489 onOpenChange
6490 } = options;
6491 const open3 = popupStore.useState("open");
6492 const referenceElement = popupStore.useState("activeTriggerElement");
6493 const floatingElement = popupStore.useState(treatPopupAsFloatingElement ? "popupElement" : "positionerElement");
6494 const triggerElements = popupStore.context.triggerElements;
6495 const handleOpenChange = onOpenChange;
6496 const internalStoreRef = React32.useRef(null);
6497 if (floatingRootContextProp === void 0 && internalStoreRef.current === null) {
6498 internalStoreRef.current = new FloatingRootStore({
6499 open: open3,
6500 transitionStatus: void 0,
6501 referenceElement,
6502 floatingElement,
6503 triggerElements,
6504 onOpenChange: handleOpenChange,
6505 floatingId,
6506 syncOnly: true,
6507 nested
6508 });
6509 }
6510 const store2 = floatingRootContextProp ?? internalStoreRef.current;
6511 popupStore.useSyncedValue("floatingId", floatingId);
6512 useIsoLayoutEffect(() => {
6513 const valuesToSync = {
6514 open: open3,
6515 floatingId,
6516 referenceElement,
6517 floatingElement
6518 };
6519 if (isElement(referenceElement)) {
6520 valuesToSync.domReferenceElement = referenceElement;
6521 }
6522 if (store2.state.positionReference === store2.state.referenceElement) {
6523 valuesToSync.positionReference = referenceElement;
6524 }
6525 store2.update(valuesToSync);
6526 }, [open3, floatingId, referenceElement, floatingElement, store2]);
6527 store2.context.onOpenChange = handleOpenChange;
6528 store2.context.nested = nested;
6529 return store2;
6530 }
6531
6532 // node_modules/@base-ui/react/utils/popups/popupStoreUtils.mjs
6533 var FOCUSABLE_POPUP_PROPS = {
6534 tabIndex: -1,
6535 [FOCUSABLE_ATTRIBUTE]: ""
6536 };
6537 function usePopupRootStore(createStore, treatPopupAsFloatingElement = false) {
6538 const floatingId = useId();
6539 const nested = useFloatingParentNodeId() != null;
6540 const store2 = useRefWithInit(() => createStore(floatingId, nested)).current;
6541 useSyncedFloatingRootContext({
6542 popupStore: store2,
6543 treatPopupAsFloatingElement,
6544 floatingRootContext: store2.state.floatingRootContext,
6545 floatingId,
6546 nested,
6547 onOpenChange: store2.setOpen
6548 });
6549 return store2;
6550 }
6551 function PopupHandleAttachment({
6552 handle,
6553 store: store2
6554 }) {
6555 useIsoLayoutEffect(() => {
6556 return handle.attachStore(store2);
6557 }, [handle, store2]);
6558 return null;
6559 }
6560 function syncTriggerCount(store2) {
6561 const triggerCount = store2.context.triggerElements.size;
6562 if (store2.select("open") && store2.state.triggerCount !== triggerCount) {
6563 store2.set("triggerCount", triggerCount);
6564 }
6565 }
6566 function useTriggerRegistration(id, store2) {
6567 const registrationRef = React33.useRef(null);
6568 return useStableCallback((element) => {
6569 const registration = registrationRef.current;
6570 if (registration !== null) {
6571 if (registration.element === element && registration.store === store2 && registration.id === id) {
6572 return;
6573 }
6574 registrationRef.current = null;
6575 const registeredStore = registration.store;
6576 if (registeredStore.context.triggerElements.getById(registration.id) === registration.element) {
6577 registeredStore.context.triggerElements.delete(registration.id);
6578 syncTriggerCount(registeredStore);
6579 }
6580 }
6581 if (element !== null && id !== void 0) {
6582 registrationRef.current = {
6583 store: store2,
6584 id,
6585 element
6586 };
6587 store2.context.triggerElements.add(id, element);
6588 syncTriggerCount(store2);
6589 }
6590 });
6591 }
6592 function createPopupOpenState(state, open3, trigger, preventUnmountOnClose = false) {
6593 let preventUnmountingOnClose = state.preventUnmountingOnClose;
6594 if (open3) {
6595 preventUnmountingOnClose = false;
6596 } else if (preventUnmountOnClose) {
6597 preventUnmountingOnClose = true;
6598 }
6599 const triggerId = trigger?.id ?? null;
6600 let activeTriggerId = state.activeTriggerId;
6601 let activeTriggerElement = state.activeTriggerElement;
6602 if (triggerId || open3) {
6603 activeTriggerId = triggerId;
6604 activeTriggerElement = trigger ?? null;
6605 }
6606 return {
6607 open: open3,
6608 preventUnmountingOnClose,
6609 activeTriggerId,
6610 activeTriggerElement
6611 };
6612 }
6613 function attachPreventUnmountOnClose(eventDetails) {
6614 let preventUnmountOnClose = false;
6615 eventDetails.preventUnmountOnClose = () => {
6616 preventUnmountOnClose = true;
6617 };
6618 return () => preventUnmountOnClose;
6619 }
6620 function applyPopupOpenChange(store2, nextOpen, eventDetails, options = {}) {
6621 const reason = eventDetails.reason;
6622 const isHover = reason === reason_parts_exports.triggerHover;
6623 const isFocusOpen = nextOpen && reason === reason_parts_exports.triggerFocus;
6624 const isDismissClose = !nextOpen && (reason === reason_parts_exports.triggerPress || reason === reason_parts_exports.escapeKey);
6625 const shouldPreventUnmountOnClose = attachPreventUnmountOnClose(eventDetails);
6626 store2.context.onOpenChange?.(nextOpen, eventDetails);
6627 if (eventDetails.isCanceled) {
6628 return;
6629 }
6630 options.onBeforeDispatch?.();
6631 store2.state.floatingRootContext.dispatchOpenChange(nextOpen, eventDetails);
6632 const changeState = () => {
6633 const popupOpenState = createPopupOpenState(store2.state, nextOpen, eventDetails.trigger, shouldPreventUnmountOnClose());
6634 const updatedState = {
6635 ...options.extraState,
6636 ...popupOpenState
6637 };
6638 if (isFocusOpen) {
6639 updatedState.instantType = "focus";
6640 } else if (isDismissClose) {
6641 updatedState.instantType = "dismiss";
6642 } else if (isHover) {
6643 updatedState.instantType = void 0;
6644 }
6645 store2.update(updatedState);
6646 };
6647 if (isHover) {
6648 ReactDOM4.flushSync(changeState);
6649 } else {
6650 changeState();
6651 }
6652 }
6653 function useTriggerDataForwarding(triggerId, triggerElementRef, store2, stateUpdates) {
6654 const isMountedByThisTrigger = store2.useState("isMountedByTrigger", triggerId);
6655 const baseRegisterTrigger = useTriggerRegistration(triggerId, store2);
6656 const applyTriggerData = useStableCallback((element) => {
6657 const open3 = store2.select("open");
6658 const activeTriggerId = store2.select("activeTriggerId");
6659 if (activeTriggerId === triggerId) {
6660 const changes = {
6661 activeTriggerElement: element,
6662 ...open3 ? stateUpdates : null
6663 };
6664 store2.update(changes);
6665 return;
6666 }
6667 if (activeTriggerId == null && open3) {
6668 const changes = {
6669 activeTriggerId: triggerId ?? null,
6670 activeTriggerElement: element,
6671 ...stateUpdates
6672 };
6673 store2.update(changes);
6674 }
6675 });
6676 const registerTrigger = useStableCallback((element) => {
6677 baseRegisterTrigger(element);
6678 if (element) {
6679 applyTriggerData(element);
6680 }
6681 });
6682 useIsoLayoutEffect(() => {
6683 registerTrigger(triggerElementRef.current);
6684 return () => registerTrigger(null);
6685 }, [registerTrigger, triggerElementRef, store2, triggerId]);
6686 useIsoLayoutEffect(() => {
6687 if (isMountedByThisTrigger) {
6688 const changes = {
6689 activeTriggerElement: triggerElementRef.current,
6690 ...stateUpdates
6691 };
6692 store2.update(changes);
6693 }
6694 }, [isMountedByThisTrigger, store2, triggerElementRef, ...Object.values(stateUpdates)]);
6695 return {
6696 registerTrigger,
6697 isMountedByThisTrigger
6698 };
6699 }
6700 function useImplicitActiveTrigger(store2, options = {}) {
6701 const {
6702 closeOnActiveTriggerUnmount = false
6703 } = options;
6704 const resolvedActiveTriggerIdRef = React33.useRef(null);
6705 const open3 = store2.useState("open");
6706 const reactiveTriggerCount = store2.useState("triggerCount");
6707 const activeTriggerId = store2.useState("activeTriggerId");
6708 const reactiveActiveTriggerElement = store2.useState("activeTriggerElement");
6709 useIsoLayoutEffect(() => {
6710 if (!open3) {
6711 resolvedActiveTriggerIdRef.current = null;
6712 if (store2.state.triggerCount !== 0) {
6713 store2.set("triggerCount", 0);
6714 }
6715 return;
6716 }
6717 const triggerCount = store2.context.triggerElements.size;
6718 const stateUpdates = {};
6719 if (store2.state.triggerCount !== triggerCount) {
6720 stateUpdates.triggerCount = triggerCount;
6721 }
6722 const currentActiveTriggerId = store2.select("activeTriggerId");
6723 let lostActiveTriggerId = null;
6724 if (currentActiveTriggerId) {
6725 const activeTriggerElement = store2.context.triggerElements.getById(currentActiveTriggerId);
6726 if (!activeTriggerElement) {
6727 for (const [triggerId, triggerElement] of store2.context.triggerElements.entries()) {
6728 if (triggerElement === store2.state.activeTriggerElement) {
6729 stateUpdates.activeTriggerId = triggerId;
6730 stateUpdates.activeTriggerElement = triggerElement;
6731 resolvedActiveTriggerIdRef.current = triggerId;
6732 break;
6733 }
6734 }
6735 if (stateUpdates.activeTriggerId === void 0) {
6736 if (resolvedActiveTriggerIdRef.current === currentActiveTriggerId) {
6737 lostActiveTriggerId = currentActiveTriggerId;
6738 } else {
6739 resolvedActiveTriggerIdRef.current = null;
6740 }
6741 }
6742 } else {
6743 resolvedActiveTriggerIdRef.current = currentActiveTriggerId;
6744 if (activeTriggerElement !== store2.state.activeTriggerElement) {
6745 stateUpdates.activeTriggerElement = activeTriggerElement;
6746 }
6747 }
6748 } else {
6749 resolvedActiveTriggerIdRef.current = null;
6750 }
6751 if (!lostActiveTriggerId && !currentActiveTriggerId && triggerCount === 1) {
6752 const iteratorResult = store2.context.triggerElements.entries().next();
6753 if (!iteratorResult.done) {
6754 const [implicitTriggerId, implicitTriggerElement] = iteratorResult.value;
6755 stateUpdates.activeTriggerId = implicitTriggerId;
6756 stateUpdates.activeTriggerElement = implicitTriggerElement;
6757 resolvedActiveTriggerIdRef.current = implicitTriggerId;
6758 }
6759 }
6760 if (stateUpdates.triggerCount !== void 0 || stateUpdates.activeTriggerId !== void 0 || stateUpdates.activeTriggerElement !== void 0) {
6761 store2.update(stateUpdates);
6762 }
6763 if (lostActiveTriggerId) {
6764 if (closeOnActiveTriggerUnmount) {
6765 queueMicrotask(() => {
6766 if (store2.select("open") && store2.select("activeTriggerId") === lostActiveTriggerId && !store2.context.triggerElements.getById(lostActiveTriggerId)) {
6767 const eventDetails = createChangeEventDetails(reason_parts_exports.none);
6768 store2.setOpen(false, eventDetails);
6769 if (!eventDetails.isCanceled) {
6770 store2.update({
6771 activeTriggerId: null,
6772 activeTriggerElement: null
6773 });
6774 }
6775 }
6776 });
6777 }
6778 }
6779 }, [open3, store2, reactiveTriggerCount, activeTriggerId, reactiveActiveTriggerElement, closeOnActiveTriggerUnmount]);
6780 }
6781 function useOpenStateTransitions(open3, store2, onUnmount, animateInitialOpen) {
6782 const {
6783 mounted,
6784 setMounted,
6785 transitionStatus
6786 } = useTransitionStatus(open3, false, false, animateInitialOpen);
6787 const preventUnmountingOnClose = store2.useState("preventUnmountingOnClose");
6788 const syncedPreventUnmountingOnClose = open3 ? false : preventUnmountingOnClose;
6789 store2.useSyncedValues({
6790 mounted,
6791 transitionStatus,
6792 preventUnmountingOnClose: syncedPreventUnmountingOnClose
6793 });
6794 const forceUnmount = useStableCallback(() => {
6795 setMounted(false);
6796 store2.update({
6797 activeTriggerId: null,
6798 activeTriggerElement: null,
6799 mounted: false,
6800 preventUnmountingOnClose: false
6801 });
6802 onUnmount?.();
6803 store2.context.onOpenChangeComplete?.(false);
6804 });
6805 useOpenChangeComplete({
6806 enabled: mounted && !open3 && !syncedPreventUnmountingOnClose,
6807 open: open3,
6808 ref: store2.context.popupRef,
6809 onComplete() {
6810 if (!open3) {
6811 forceUnmount();
6812 }
6813 }
6814 });
6815 return {
6816 forceUnmount,
6817 transitionStatus
6818 };
6819 }
6820 function usePopupInteractionProps(store2, statePart) {
6821 store2.useSyncedValues(statePart);
6822 useIsoLayoutEffect(() => () => {
6823 store2.update({
6824 activeTriggerProps: EMPTY_OBJECT,
6825 inactiveTriggerProps: EMPTY_OBJECT,
6826 popupProps: EMPTY_OBJECT
6827 });
6828 }, [store2]);
6829 }
6830
6831 // node_modules/@base-ui/react/utils/popups/popupTriggerMap.mjs
6832 var devElementIdsByMap;
6833 function getDevElementIds(map) {
6834 devElementIdsByMap ??= /* @__PURE__ */ new WeakMap();
6835 let elementIds = devElementIdsByMap.get(map);
6836 if (!elementIds) {
6837 elementIds = /* @__PURE__ */ new WeakMap();
6838 devElementIdsByMap.set(map, elementIds);
6839 }
6840 return elementIds;
6841 }
6842 var PopupTriggerMap = class {
6843 constructor() {
6844 this.idMap = /* @__PURE__ */ new Map();
6845 }
6846 /**
6847 * Adds a trigger element with the given ID.
6848 *
6849 * Note: The provided element is assumed to not be registered under multiple IDs.
6850 */
6851 add(id, element) {
6852 if (true) {
6853 const elementIds = getDevElementIds(this);
6854 const existingId = elementIds.get(element);
6855 if (existingId !== void 0 && existingId !== id) {
6856 throw new Error("Base UI: A trigger element cannot be registered under multiple IDs in PopupTriggerMap.");
6857 }
6858 const previousElement = this.idMap.get(id);
6859 if (previousElement !== void 0 && previousElement !== element) {
6860 elementIds.delete(previousElement);
6861 }
6862 elementIds.set(element, id);
6863 }
6864 this.idMap.set(id, element);
6865 }
6866 /**
6867 * Removes the trigger element with the given ID.
6868 */
6869 delete(id) {
6870 if (true) {
6871 const element = this.idMap.get(id);
6872 if (element !== void 0) {
6873 devElementIdsByMap?.get(this)?.delete(element);
6874 }
6875 }
6876 this.idMap.delete(id);
6877 }
6878 /**
6879 * Whether the given element is registered as a trigger.
6880 */
6881 hasElement(element) {
6882 for (const registered of this.idMap.values()) {
6883 if (registered === element) {
6884 return true;
6885 }
6886 }
6887 return false;
6888 }
6889 /**
6890 * Whether there is a registered trigger element matching the given predicate.
6891 */
6892 hasMatchingElement(predicate) {
6893 for (const element of this.idMap.values()) {
6894 if (predicate(element)) {
6895 return true;
6896 }
6897 }
6898 return false;
6899 }
6900 /**
6901 * Returns the trigger element associated with the given ID, or undefined if no such element exists.
6902 */
6903 getById(id) {
6904 return this.idMap.get(id);
6905 }
6906 /**
6907 * Returns an iterable of all registered trigger entries, where each entry is a tuple of [id, element].
6908 */
6909 entries() {
6910 return this.idMap.entries();
6911 }
6912 /**
6913 * Returns an iterable of all registered trigger elements.
6914 */
6915 elements() {
6916 return this.idMap.values();
6917 }
6918 /**
6919 * Returns the number of registered trigger elements.
6920 */
6921 get size() {
6922 return this.idMap.size;
6923 }
6924 };
6925
6926 // node_modules/@base-ui/react/utils/popups/store.mjs
6927 function createInitialPopupStoreState(triggerElements, floatingId, nested = false) {
6928 return {
6929 open: false,
6930 openProp: void 0,
6931 mounted: false,
6932 transitionStatus: void 0,
6933 floatingRootContext: new FloatingRootStore({
6934 open: false,
6935 transitionStatus: void 0,
6936 floatingElement: null,
6937 referenceElement: null,
6938 triggerElements,
6939 floatingId,
6940 syncOnly: true,
6941 nested,
6942 onOpenChange: void 0
6943 }),
6944 floatingId,
6945 triggerCount: 0,
6946 preventUnmountingOnClose: false,
6947 payload: void 0,
6948 activeTriggerId: null,
6949 activeTriggerElement: null,
6950 triggerIdProp: void 0,
6951 popupElement: null,
6952 positionerElement: null,
6953 activeTriggerProps: EMPTY_OBJECT,
6954 inactiveTriggerProps: EMPTY_OBJECT,
6955 popupProps: EMPTY_OBJECT
6956 };
6957 }
6958 var activeTriggerIdSelector = (state) => state.triggerIdProp ?? state.activeTriggerId;
6959 var openSelector = (state) => state.openProp ?? state.open;
6960 var popupIdSelector = (state) => {
6961 const popupId = state.popupElement?.id ?? state.floatingId;
6962 return popupId || void 0;
6963 };
6964 function triggerOwnsOpenPopup(state, triggerId) {
6965 return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) === triggerId;
6966 }
6967 function triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) {
6968 if (triggerOwnsOpenPopup(state, triggerId)) {
6969 return true;
6970 }
6971 return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) == null && state.triggerCount === 1;
6972 }
6973 var popupStoreSelectors = {
6974 open: openSelector,
6975 mounted: (state) => state.mounted,
6976 transitionStatus: (state) => state.transitionStatus,
6977 floatingRootContext: (state) => state.floatingRootContext,
6978 triggerCount: (state) => state.triggerCount,
6979 preventUnmountingOnClose: (state) => state.preventUnmountingOnClose,
6980 payload: (state) => state.payload,
6981 activeTriggerId: activeTriggerIdSelector,
6982 activeTriggerElement: (state) => state.mounted ? state.activeTriggerElement : null,
6983 popupId: popupIdSelector,
6984 /**
6985 * Whether the trigger with the given ID was used to open the popup.
6986 */
6987 isTriggerActive: (state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId,
6988 /**
6989 * Whether the popup is open and was activated by a trigger with the given ID.
6990 */
6991 isOpenedByTrigger: (state, triggerId) => triggerOwnsOpenPopup(state, triggerId),
6992 /**
6993 * Whether the popup is mounted and was activated by a trigger with the given ID.
6994 */
6995 isMountedByTrigger: (state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId && state.mounted,
6996 triggerProps: (state, isActive) => isActive ? state.activeTriggerProps : state.inactiveTriggerProps,
6997 /**
6998 * Popup id for the trigger that currently owns the open popup.
6999 */
7000 triggerPopupId: (state, triggerId) => triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) ? popupIdSelector(state) : void 0,
7001 popupProps: (state) => state.popupProps,
7002 popupElement: (state) => state.popupElement,
7003 positionerElement: (state) => state.positionerElement
7004 };
7005
7006 // node_modules/@base-ui/react/utils/popups/usePopupHandleStore.mjs
7007 var React34 = __toESM(require_react(), 1);
7008 var import_shim2 = __toESM(require_shim(), 1);
7009 function usePopupHandleStore(handle) {
7010 const subscribe2 = React34.useCallback((listener) => {
7011 if (handle === void 0) {
7012 return NOOP;
7013 }
7014 return handle.subscribeStore(listener);
7015 }, [handle]);
7016 const getSnapshot2 = React34.useCallback(() => {
7017 return handle === void 0 ? void 0 : handle.store;
7018 }, [handle]);
7019 return (0, import_shim2.useSyncExternalStore)(subscribe2, getSnapshot2, () => handle?.serverStore);
7020 }
7021
7022 // node_modules/@base-ui/react/floating-ui-react/hooks/useFloating.mjs
7023 function useBaseUIFloating(options) {
7024 return useFloatingWithStore(options, options.rootContext);
7025 }
7026 function useFloatingWithStore(options, store2) {
7027 const {
7028 nodeId,
7029 externalTree
7030 } = options;
7031 const referenceElement = store2.useState("referenceElement");
7032 const floatingElement = store2.useState("floatingElement");
7033 const domReferenceElement = store2.useState("domReferenceElement");
7034 const open3 = store2.useState("open");
7035 const floatingId = store2.useState("floatingId");
7036 const [positionReference, setPositionReferenceRaw] = React35.useState(null);
7037 const [localDomReference, setLocalDomReference] = React35.useState(void 0);
7038 const [localFloatingElement, setLocalFloatingElement] = React35.useState(void 0);
7039 const domReferenceRef = React35.useRef(null);
7040 const tree = useFloatingTree(externalTree);
7041 const storeElements = React35.useMemo(() => ({
7042 reference: referenceElement,
7043 floating: floatingElement,
7044 domReference: domReferenceElement
7045 }), [referenceElement, floatingElement, domReferenceElement]);
7046 const position = useFloating({
7047 ...options,
7048 elements: {
7049 ...storeElements,
7050 ...positionReference && {
7051 reference: positionReference
7052 }
7053 }
7054 });
7055 const localDomReferenceElement = isElement(localDomReference) ? localDomReference : null;
7056 const syncedFloatingElement = localFloatingElement === void 0 ? store2.state.floatingElement : localFloatingElement;
7057 store2.useSyncedValue("referenceElement", localDomReference ?? null);
7058 store2.useSyncedValue("domReferenceElement", localDomReference === void 0 ? domReferenceElement : localDomReferenceElement);
7059 store2.useSyncedValue("floatingElement", syncedFloatingElement);
7060 const setPositionReference = React35.useCallback((node) => {
7061 const computedPositionReference = isElement(node) ? {
7062 getBoundingClientRect: () => node.getBoundingClientRect(),
7063 getClientRects: () => node.getClientRects(),
7064 contextElement: node
7065 } : node;
7066 setPositionReferenceRaw(computedPositionReference);
7067 position.refs.setReference(computedPositionReference);
7068 }, [position.refs]);
7069 const setReference = React35.useCallback((node) => {
7070 if (isElement(node) || node === null) {
7071 domReferenceRef.current = node;
7072 setLocalDomReference(node);
7073 }
7074 if (isElement(position.refs.reference.current) || position.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
7075 // `null` to support `positionReference` + an unstable `reference`
7076 // callback ref.
7077 node !== null && !isElement(node)) {
7078 position.refs.setReference(node);
7079 }
7080 }, [position.refs, setLocalDomReference]);
7081 const setFloating = React35.useCallback((node) => {
7082 setLocalFloatingElement(node);
7083 position.refs.setFloating(node);
7084 }, [position.refs]);
7085 const refs = React35.useMemo(() => ({
7086 ...position.refs,
7087 setReference,
7088 setFloating,
7089 setPositionReference,
7090 domReference: domReferenceRef
7091 }), [position.refs, setReference, setFloating, setPositionReference]);
7092 const elements = React35.useMemo(() => ({
7093 ...position.elements,
7094 domReference: domReferenceElement
7095 }), [position.elements, domReferenceElement]);
7096 const context = React35.useMemo(() => ({
7097 ...position,
7098 dataRef: store2.context.dataRef,
7099 open: open3,
7100 onOpenChange: store2.setOpen,
7101 events: store2.context.events,
7102 floatingId,
7103 refs,
7104 elements,
7105 nodeId,
7106 rootStore: store2
7107 }), [position, refs, elements, nodeId, store2, open3, floatingId]);
7108 useIsoLayoutEffect(() => {
7109 if (domReferenceElement) {
7110 domReferenceRef.current = domReferenceElement;
7111 }
7112 }, [domReferenceElement]);
7113 useIsoLayoutEffect(() => {
7114 store2.context.dataRef.current.floatingContext = context;
7115 const node = tree?.nodesRef.current.find((n) => n.id === nodeId);
7116 if (node) {
7117 node.context = context;
7118 }
7119 });
7120 return React35.useMemo(() => ({
7121 ...position,
7122 context,
7123 refs,
7124 elements,
7125 rootStore: store2
7126 }), [position, refs, elements, context, store2]);
7127 }
7128
7129 // node_modules/@base-ui/react/floating-ui-react/hooks/useFocus.mjs
7130 var React36 = __toESM(require_react(), 1);
7131 var isMacSafari = parts_exports.os.mac && parts_exports.engine.webkit;
7132 function useFocus(context, props = {}) {
7133 const {
7134 enabled = true,
7135 delay
7136 } = props;
7137 const store2 = "rootStore" in context ? context.rootStore : context;
7138 const {
7139 events,
7140 dataRef
7141 } = store2.context;
7142 const blockFocusRef = React36.useRef(false);
7143 const blockedReferenceRef = React36.useRef(null);
7144 const keyboardModalityRef = React36.useRef(true);
7145 const timeout = useTimeout();
7146 React36.useEffect(() => {
7147 const domReference = store2.select("domReferenceElement");
7148 if (!enabled) {
7149 return void 0;
7150 }
7151 const win = getWindow(domReference);
7152 function onBlur() {
7153 const currentDomReference = store2.select("domReferenceElement");
7154 if (!store2.select("open") && isHTMLElement(currentDomReference) && currentDomReference === activeElement(ownerDocument(currentDomReference))) {
7155 blockFocusRef.current = true;
7156 blockedReferenceRef.current = currentDomReference;
7157 }
7158 }
7159 function onKeyDown() {
7160 keyboardModalityRef.current = true;
7161 }
7162 function onPointerDown() {
7163 keyboardModalityRef.current = false;
7164 }
7165 return mergeCleanups(addEventListener(win, "blur", onBlur), isMacSafari && addEventListener(win, "keydown", onKeyDown, true), isMacSafari && addEventListener(win, "pointerdown", onPointerDown, true));
7166 }, [store2, enabled]);
7167 React36.useEffect(() => {
7168 if (!enabled) {
7169 return void 0;
7170 }
7171 function onOpenChangeLocal(details) {
7172 if (details.reason === reason_parts_exports.triggerPress || details.reason === reason_parts_exports.escapeKey) {
7173 const referenceElement = store2.select("domReferenceElement");
7174 if (isElement(referenceElement)) {
7175 blockedReferenceRef.current = referenceElement;
7176 blockFocusRef.current = true;
7177 }
7178 }
7179 }
7180 events.on("openchange", onOpenChangeLocal);
7181 return () => {
7182 events.off("openchange", onOpenChangeLocal);
7183 };
7184 }, [events, enabled, store2]);
7185 const reference = React36.useMemo(() => {
7186 function resetBlockedFocus() {
7187 blockFocusRef.current = false;
7188 blockedReferenceRef.current = null;
7189 }
7190 return {
7191 onMouseLeave() {
7192 resetBlockedFocus();
7193 },
7194 onFocus(event) {
7195 const focusTarget = event.currentTarget;
7196 if (blockFocusRef.current) {
7197 if (blockedReferenceRef.current === focusTarget) {
7198 return;
7199 }
7200 resetBlockedFocus();
7201 }
7202 const target = getTarget(event.nativeEvent);
7203 if (isElement(target)) {
7204 if (isMacSafari && !event.relatedTarget) {
7205 if (!keyboardModalityRef.current && !isTypeableElement(target)) {
7206 return;
7207 }
7208 } else if (!matchesFocusVisible(target)) {
7209 return;
7210 }
7211 }
7212 const movedFromOtherEnabledTrigger = isTargetInsideEnabledTrigger(event.relatedTarget, store2.context.triggerElements);
7213 const {
7214 nativeEvent,
7215 currentTarget
7216 } = event;
7217 const delayValue = typeof delay === "function" ? delay() : delay;
7218 if (store2.select("open") && movedFromOtherEnabledTrigger || delayValue === 0 || delayValue === void 0) {
7219 store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
7220 return;
7221 }
7222 timeout.start(delayValue, () => {
7223 if (blockFocusRef.current) {
7224 return;
7225 }
7226 store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
7227 });
7228 },
7229 onBlur(event) {
7230 resetBlockedFocus();
7231 const relatedTarget = event.relatedTarget;
7232 const nativeEvent = event.nativeEvent;
7233 const movedToFocusGuard = isElement(relatedTarget) && relatedTarget.hasAttribute(createAttribute("focus-guard")) && relatedTarget.getAttribute("data-type") === "outside";
7234 timeout.start(0, () => {
7235 const domReference = store2.select("domReferenceElement");
7236 const activeEl = activeElement(ownerDocument(domReference));
7237 if (!relatedTarget && activeEl === domReference) {
7238 return;
7239 }
7240 if (contains(dataRef.current.floatingContext?.refs.floating.current, activeEl) || contains(domReference, activeEl) || movedToFocusGuard) {
7241 return;
7242 }
7243 const nextFocusedElement = relatedTarget ?? activeEl;
7244 if (isTargetInsideEnabledTrigger(nextFocusedElement, store2.context.triggerElements)) {
7245 return;
7246 }
7247 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent));
7248 });
7249 }
7250 };
7251 }, [dataRef, delay, store2, timeout]);
7252 return React36.useMemo(() => enabled ? {
7253 reference,
7254 trigger: reference
7255 } : {}, [enabled, reference]);
7256 }
7257
7258 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverFloatingInteraction.mjs
7259 var React37 = __toESM(require_react(), 1);
7260
7261 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverInteractionSharedState.mjs
7262 var HoverInteraction = class _HoverInteraction {
7263 constructor() {
7264 this.pointerType = void 0;
7265 this.interactedInside = false;
7266 this.handler = void 0;
7267 this.blockMouseMove = true;
7268 this.performedPointerEventsMutation = false;
7269 this.pointerEventsScopeElement = null;
7270 this.pointerEventsReferenceElement = null;
7271 this.pointerEventsFloatingElement = null;
7272 this.restTimeoutPending = false;
7273 this.openChangeTimeout = new Timeout();
7274 this.restTimeout = new Timeout();
7275 this.handleCloseOptions = void 0;
7276 }
7277 static create() {
7278 return new _HoverInteraction();
7279 }
7280 dispose = () => {
7281 this.openChangeTimeout.clear();
7282 this.restTimeout.clear();
7283 };
7284 disposeEffect = () => {
7285 return this.dispose;
7286 };
7287 };
7288 var pointerEventsMutationOwnerByScopeElement = /* @__PURE__ */ new WeakMap();
7289 function clearSafePolygonPointerEventsMutation(instance) {
7290 if (!instance.performedPointerEventsMutation) {
7291 return;
7292 }
7293 const scopeElement = instance.pointerEventsScopeElement;
7294 if (scopeElement && pointerEventsMutationOwnerByScopeElement.get(scopeElement) === instance) {
7295 instance.pointerEventsScopeElement?.style.removeProperty("pointer-events");
7296 instance.pointerEventsReferenceElement?.style.removeProperty("pointer-events");
7297 instance.pointerEventsFloatingElement?.style.removeProperty("pointer-events");
7298 pointerEventsMutationOwnerByScopeElement.delete(scopeElement);
7299 }
7300 instance.performedPointerEventsMutation = false;
7301 instance.pointerEventsScopeElement = null;
7302 instance.pointerEventsReferenceElement = null;
7303 instance.pointerEventsFloatingElement = null;
7304 }
7305 function applySafePolygonPointerEventsMutation(instance, options) {
7306 const {
7307 scopeElement,
7308 referenceElement,
7309 floatingElement
7310 } = options;
7311 const existingOwner = pointerEventsMutationOwnerByScopeElement.get(scopeElement);
7312 if (existingOwner && existingOwner !== instance) {
7313 clearSafePolygonPointerEventsMutation(existingOwner);
7314 }
7315 clearSafePolygonPointerEventsMutation(instance);
7316 instance.performedPointerEventsMutation = true;
7317 instance.pointerEventsScopeElement = scopeElement;
7318 instance.pointerEventsReferenceElement = referenceElement;
7319 instance.pointerEventsFloatingElement = floatingElement;
7320 pointerEventsMutationOwnerByScopeElement.set(scopeElement, instance);
7321 scopeElement.style.pointerEvents = "none";
7322 referenceElement.style.pointerEvents = "auto";
7323 floatingElement.style.pointerEvents = "auto";
7324 }
7325 function useHoverInteractionSharedState(store2) {
7326 const data = store2.context.dataRef.current;
7327 const instance = useRefWithInit(() => data.hoverInteractionState ?? HoverInteraction.create()).current;
7328 if (!data.hoverInteractionState) {
7329 data.hoverInteractionState = instance;
7330 }
7331 useOnMount(data.hoverInteractionState.disposeEffect);
7332 return data.hoverInteractionState;
7333 }
7334
7335 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverFloatingInteraction.mjs
7336 function useHoverFloatingInteraction(context, parameters = {}) {
7337 const {
7338 enabled = true,
7339 closeDelay: closeDelayProp = 0,
7340 nodeId: nodeIdProp
7341 } = parameters;
7342 const store2 = "rootStore" in context ? context.rootStore : context;
7343 const open3 = store2.useState("open");
7344 const floatingElement = store2.useState("floatingElement");
7345 const domReferenceElement = store2.useState("domReferenceElement");
7346 const {
7347 dataRef
7348 } = store2.context;
7349 const tree = useFloatingTree();
7350 const parentId = useFloatingParentNodeId();
7351 const instance = useHoverInteractionSharedState(store2);
7352 const childClosedTimeout = useTimeout();
7353 const isClickLikeOpenEvent2 = useStableCallback(() => {
7354 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
7355 });
7356 const isHoverOpen = useStableCallback(() => {
7357 return isHoverOpenEvent(dataRef.current.openEvent?.type);
7358 });
7359 const clearPointerEvents = useStableCallback(() => {
7360 clearSafePolygonPointerEventsMutation(instance);
7361 });
7362 useIsoLayoutEffect(() => {
7363 if (!open3) {
7364 instance.pointerType = void 0;
7365 instance.restTimeoutPending = false;
7366 instance.interactedInside = false;
7367 clearPointerEvents();
7368 }
7369 }, [open3, instance, clearPointerEvents]);
7370 React37.useEffect(() => {
7371 return clearPointerEvents;
7372 }, [clearPointerEvents]);
7373 useIsoLayoutEffect(() => {
7374 if (!enabled) {
7375 return void 0;
7376 }
7377 if (open3 && instance.handleCloseOptions?.blockPointerEvents && isHoverOpen() && isElement(domReferenceElement) && floatingElement) {
7378 const ref = domReferenceElement;
7379 const floatingEl = floatingElement;
7380 const doc = ownerDocument(floatingElement);
7381 const parentFloating = tree?.nodesRef.current.find((node) => node.id === parentId)?.context?.elements.floating;
7382 if (parentFloating) {
7383 parentFloating.style.pointerEvents = "";
7384 }
7385 const cachedScopeElement = instance.pointerEventsScopeElement !== floatingEl ? instance.pointerEventsScopeElement : null;
7386 const parentScopeElement = parentFloating !== floatingEl ? parentFloating : null;
7387 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? cachedScopeElement ?? parentScopeElement ?? ref.closest("[data-rootownerid]") ?? doc.body;
7388 applySafePolygonPointerEventsMutation(instance, {
7389 scopeElement,
7390 referenceElement: ref,
7391 floatingElement: floatingEl
7392 });
7393 return () => {
7394 clearPointerEvents();
7395 };
7396 }
7397 return void 0;
7398 }, [enabled, open3, domReferenceElement, floatingElement, instance, isHoverOpen, tree, parentId, clearPointerEvents]);
7399 React37.useEffect(() => {
7400 if (!enabled) {
7401 return void 0;
7402 }
7403 function hasParentChildren() {
7404 return !!(tree && parentId && getNodeChildren(tree.nodesRef.current, parentId).length > 0);
7405 }
7406 function closeWithDelay(event) {
7407 const closeDelay = getDelay(closeDelayProp, "close", instance.pointerType);
7408 const close = () => {
7409 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
7410 tree?.events.emit("floating.closed", event);
7411 };
7412 if (closeDelay) {
7413 instance.openChangeTimeout.start(closeDelay, close);
7414 } else {
7415 instance.openChangeTimeout.clear();
7416 close();
7417 }
7418 }
7419 function handleInteractInside(event) {
7420 const target = getTarget(event);
7421 if (!isInteractiveElement(target)) {
7422 instance.interactedInside = false;
7423 return;
7424 }
7425 instance.interactedInside = target?.closest("[aria-haspopup]") != null;
7426 }
7427 function onFloatingMouseEnter() {
7428 instance.openChangeTimeout.clear();
7429 childClosedTimeout.clear();
7430 tree?.events.off("floating.closed", onNodeClosed);
7431 clearPointerEvents();
7432 }
7433 function onFloatingMouseLeave(event) {
7434 if (hasParentChildren() && tree) {
7435 tree.events.on("floating.closed", onNodeClosed);
7436 return;
7437 }
7438 if (isTargetInsideEnabledTrigger(event.relatedTarget, store2.context.triggerElements)) {
7439 return;
7440 }
7441 const currentNodeId = dataRef.current.floatingContext?.nodeId ?? nodeIdProp;
7442 const relatedTarget = event.relatedTarget;
7443 const isMovingIntoDescendantFloating = tree && currentNodeId && isElement(relatedTarget) && getNodeChildren(tree.nodesRef.current, currentNodeId, false).some((node) => contains(node.context?.elements.floating, relatedTarget));
7444 if (isMovingIntoDescendantFloating) {
7445 return;
7446 }
7447 if (instance.handler) {
7448 instance.handler(event);
7449 return;
7450 }
7451 clearPointerEvents();
7452 if (isHoverOpen() && !isClickLikeOpenEvent2()) {
7453 closeWithDelay(event);
7454 }
7455 }
7456 function onNodeClosed(event) {
7457 if (!tree || !parentId || hasParentChildren()) {
7458 return;
7459 }
7460 childClosedTimeout.start(0, () => {
7461 tree.events.off("floating.closed", onNodeClosed);
7462 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
7463 tree.events.emit("floating.closed", event);
7464 });
7465 }
7466 const floating = floatingElement;
7467 return mergeCleanups(floating && addEventListener(floating, "mouseenter", onFloatingMouseEnter), floating && addEventListener(floating, "mouseleave", onFloatingMouseLeave), floating && addEventListener(floating, "pointerdown", handleInteractInside, true), () => {
7468 tree?.events.off("floating.closed", onNodeClosed);
7469 });
7470 }, [enabled, floatingElement, store2, dataRef, closeDelayProp, nodeIdProp, isHoverOpen, isClickLikeOpenEvent2, clearPointerEvents, instance, tree, parentId, childClosedTimeout]);
7471 }
7472
7473 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverReferenceInteraction.mjs
7474 var React38 = __toESM(require_react(), 1);
7475 var ReactDOM5 = __toESM(require_react_dom(), 1);
7476 var EMPTY_REF = {
7477 current: null
7478 };
7479 function useHoverReferenceInteraction(context, props = {}) {
7480 const {
7481 enabled = true,
7482 delay = 0,
7483 handleClose = null,
7484 mouseOnly = false,
7485 restMs = 0,
7486 move = true,
7487 triggerElementRef = EMPTY_REF,
7488 externalTree,
7489 isActiveTrigger = true,
7490 getHandleCloseContext,
7491 isClosing,
7492 shouldOpen: shouldOpenProp,
7493 guardStaleOpen = false
7494 } = props;
7495 const store2 = "rootStore" in context ? context.rootStore : context;
7496 const {
7497 dataRef,
7498 events
7499 } = store2.context;
7500 const tree = useFloatingTree(externalTree);
7501 const instance = useHoverInteractionSharedState(store2);
7502 const isHoverCloseActiveRef = React38.useRef(false);
7503 const handleCloseRef = useValueAsRef(handleClose);
7504 const delayRef = useValueAsRef(delay);
7505 const restMsRef = useValueAsRef(restMs);
7506 const enabledRef = useValueAsRef(enabled);
7507 const shouldOpenRef = useValueAsRef(shouldOpenProp);
7508 const isClosingRef = useValueAsRef(isClosing);
7509 const isClickLikeOpenEvent2 = useStableCallback(() => {
7510 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
7511 });
7512 const checkShouldOpen = useStableCallback(() => {
7513 return shouldOpenRef.current?.() !== false;
7514 });
7515 const isOverInactiveTrigger = useStableCallback((currentDomReference, currentTarget, target) => {
7516 const allTriggers = store2.context.triggerElements;
7517 if (allTriggers.hasElement(currentTarget)) {
7518 return !currentDomReference || !contains(currentDomReference, currentTarget);
7519 }
7520 if (!isElement(target)) {
7521 return false;
7522 }
7523 const targetElement = target;
7524 return allTriggers.hasMatchingElement((trigger) => contains(trigger, targetElement)) && (!currentDomReference || !contains(currentDomReference, targetElement));
7525 });
7526 const cleanupMouseMoveHandler = useStableCallback(() => {
7527 if (!instance.handler) {
7528 return;
7529 }
7530 const doc = ownerDocument(store2.select("domReferenceElement"));
7531 doc.removeEventListener("mousemove", instance.handler);
7532 instance.handler = void 0;
7533 });
7534 const clearPointerEvents = useStableCallback(() => {
7535 clearSafePolygonPointerEventsMutation(instance);
7536 });
7537 if (isActiveTrigger) {
7538 instance.handleCloseOptions = handleClose?.__options;
7539 }
7540 React38.useEffect(() => cleanupMouseMoveHandler, [cleanupMouseMoveHandler]);
7541 React38.useEffect(() => {
7542 if (!enabled) {
7543 return void 0;
7544 }
7545 function onOpenChangeLocal(details) {
7546 if (!details.open) {
7547 isHoverCloseActiveRef.current = details.reason === reason_parts_exports.triggerHover;
7548 cleanupMouseMoveHandler();
7549 instance.openChangeTimeout.clear();
7550 instance.restTimeout.clear();
7551 instance.blockMouseMove = true;
7552 instance.restTimeoutPending = false;
7553 } else {
7554 isHoverCloseActiveRef.current = false;
7555 }
7556 }
7557 events.on("openchange", onOpenChangeLocal);
7558 return () => {
7559 events.off("openchange", onOpenChangeLocal);
7560 };
7561 }, [enabled, events, instance, cleanupMouseMoveHandler]);
7562 React38.useEffect(() => {
7563 if (!enabled) {
7564 return void 0;
7565 }
7566 function closeWithDelay(event, runElseBranch = true) {
7567 const closeDelay = getDelay(delayRef.current, "close", instance.pointerType);
7568 if (closeDelay) {
7569 instance.openChangeTimeout.start(closeDelay, () => {
7570 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
7571 tree?.events.emit("floating.closed", event);
7572 });
7573 } else if (runElseBranch) {
7574 instance.openChangeTimeout.clear();
7575 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
7576 tree?.events.emit("floating.closed", event);
7577 }
7578 }
7579 const trigger = triggerElementRef.current ?? (isActiveTrigger ? store2.select("domReferenceElement") : null);
7580 if (!isElement(trigger)) {
7581 return void 0;
7582 }
7583 function onMouseEnter(event) {
7584 instance.openChangeTimeout.clear();
7585 instance.blockMouseMove = false;
7586 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
7587 return;
7588 }
7589 const restMsValue = getRestMs(restMsRef.current);
7590 const openDelay = getDelay(delayRef.current, "open", instance.pointerType);
7591 const eventTarget = getTarget(event);
7592 const currentTarget = event.currentTarget ?? null;
7593 const currentDomReference = store2.select("domReferenceElement");
7594 let triggerNode = currentTarget;
7595 if (isElement(eventTarget) && !store2.context.triggerElements.hasElement(eventTarget)) {
7596 for (const triggerElement of store2.context.triggerElements.elements()) {
7597 if (contains(triggerElement, eventTarget)) {
7598 triggerNode = triggerElement;
7599 break;
7600 }
7601 }
7602 }
7603 if (isElement(currentTarget) && isElement(currentDomReference) && !store2.context.triggerElements.hasElement(currentTarget) && contains(currentTarget, currentDomReference)) {
7604 triggerNode = currentDomReference;
7605 }
7606 const isOverInactive = triggerNode == null ? false : isOverInactiveTrigger(currentDomReference, triggerNode, eventTarget);
7607 const isOpen2 = store2.select("open");
7608 const isInClosingTransition = isClosingRef.current?.() ?? store2.select("transitionStatus") === "ending";
7609 const isHoverCloseTransition = !isOpen2 && isInClosingTransition && isHoverCloseActiveRef.current;
7610 const isReenteringSameTriggerDuringCloseTransition = !isOverInactive && isElement(triggerNode) && isElement(currentDomReference) && contains(currentDomReference, triggerNode) && isHoverCloseTransition;
7611 const isRestOnlyDelay = restMsValue > 0 && !openDelay;
7612 const shouldOpenImmediately = isOverInactive && (isOpen2 || isHoverCloseTransition) || isReenteringSameTriggerDuringCloseTransition;
7613 const shouldOpen = !isOpen2 || isOverInactive;
7614 if (shouldOpenImmediately) {
7615 if (checkShouldOpen()) {
7616 store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
7617 }
7618 return;
7619 }
7620 if (isRestOnlyDelay) {
7621 return;
7622 }
7623 if (openDelay) {
7624 instance.openChangeTimeout.start(openDelay, () => {
7625 if (shouldOpen && checkShouldOpen()) {
7626 store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
7627 }
7628 });
7629 } else if (shouldOpen) {
7630 if (checkShouldOpen()) {
7631 store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
7632 }
7633 }
7634 }
7635 function onMouseLeave(event) {
7636 if (isClickLikeOpenEvent2()) {
7637 clearPointerEvents();
7638 return;
7639 }
7640 cleanupMouseMoveHandler();
7641 const domReferenceElement = store2.select("domReferenceElement");
7642 const doc = ownerDocument(domReferenceElement);
7643 instance.restTimeout.clear();
7644 instance.restTimeoutPending = false;
7645 const handleCloseContextBase = dataRef.current.floatingContext ?? getHandleCloseContext?.();
7646 if (isTargetInsideEnabledTrigger(event.relatedTarget, store2.context.triggerElements)) {
7647 return;
7648 }
7649 if (handleCloseRef.current && handleCloseContextBase) {
7650 if (!store2.select("open")) {
7651 instance.openChangeTimeout.clear();
7652 }
7653 const currentTrigger = triggerElementRef.current;
7654 instance.handler = handleCloseRef.current({
7655 ...handleCloseContextBase,
7656 tree,
7657 x: event.clientX,
7658 y: event.clientY,
7659 onClose() {
7660 clearPointerEvents();
7661 cleanupMouseMoveHandler();
7662 if (enabledRef.current && !isClickLikeOpenEvent2() && currentTrigger === store2.select("domReferenceElement")) {
7663 closeWithDelay(event, true);
7664 }
7665 }
7666 });
7667 doc.addEventListener("mousemove", instance.handler);
7668 instance.handler(event);
7669 return;
7670 }
7671 const shouldClose = instance.pointerType === "touch" ? !contains(store2.select("floatingElement"), event.relatedTarget) : true;
7672 if (shouldClose) {
7673 closeWithDelay(event);
7674 }
7675 }
7676 function onMouseOut(event) {
7677 if (contains(trigger, event.relatedTarget)) {
7678 return;
7679 }
7680 instance.openChangeTimeout.clear();
7681 instance.restTimeout.clear();
7682 instance.restTimeoutPending = false;
7683 }
7684 const staleOpenGuard = guardStaleOpen ? addEventListener(trigger, "mouseout", onMouseOut) : void 0;
7685 if (move) {
7686 return mergeCleanups(addEventListener(trigger, "mousemove", onMouseEnter, {
7687 once: true
7688 }), addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave), staleOpenGuard);
7689 }
7690 return mergeCleanups(addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave), staleOpenGuard);
7691 }, [cleanupMouseMoveHandler, clearPointerEvents, dataRef, delayRef, store2, enabled, handleCloseRef, instance, isActiveTrigger, isOverInactiveTrigger, isClickLikeOpenEvent2, mouseOnly, move, restMsRef, triggerElementRef, tree, enabledRef, getHandleCloseContext, isClosingRef, checkShouldOpen, guardStaleOpen]);
7692 return React38.useMemo(() => {
7693 if (!enabled) {
7694 return void 0;
7695 }
7696 function setPointerRef(event) {
7697 instance.pointerType = event.pointerType;
7698 }
7699 return {
7700 onPointerDown: setPointerRef,
7701 onPointerEnter: setPointerRef,
7702 onMouseMove(event) {
7703 const {
7704 nativeEvent
7705 } = event;
7706 const trigger = event.currentTarget;
7707 const currentDomReference = store2.select("domReferenceElement");
7708 const currentOpen = store2.select("open");
7709 const isOverInactive = isOverInactiveTrigger(currentDomReference, trigger, event.target);
7710 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
7711 return;
7712 }
7713 if (currentOpen && isOverInactive && instance.handleCloseOptions?.blockPointerEvents) {
7714 const floatingElement = store2.select("floatingElement");
7715 if (floatingElement) {
7716 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? trigger.ownerDocument.body;
7717 applySafePolygonPointerEventsMutation(instance, {
7718 scopeElement,
7719 referenceElement: trigger,
7720 floatingElement
7721 });
7722 }
7723 }
7724 const restMsValue = getRestMs(restMsRef.current);
7725 if (currentOpen && !isOverInactive || restMsValue === 0) {
7726 return;
7727 }
7728 if (!isOverInactive && instance.restTimeoutPending && event.movementX ** 2 + event.movementY ** 2 < 2) {
7729 return;
7730 }
7731 instance.restTimeout.clear();
7732 function handleMouseMove() {
7733 instance.restTimeoutPending = false;
7734 if (isClickLikeOpenEvent2()) {
7735 return;
7736 }
7737 const latestOpen = store2.select("open");
7738 if (!instance.blockMouseMove && (!latestOpen || isOverInactive) && checkShouldOpen()) {
7739 store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, nativeEvent, trigger));
7740 }
7741 }
7742 if (instance.pointerType === "touch") {
7743 ReactDOM5.flushSync(() => {
7744 handleMouseMove();
7745 });
7746 } else if (isOverInactive && currentOpen) {
7747 handleMouseMove();
7748 } else {
7749 instance.restTimeoutPending = true;
7750 instance.restTimeout.start(restMsValue, handleMouseMove);
7751 }
7752 }
7753 };
7754 }, [enabled, instance, isClickLikeOpenEvent2, isOverInactiveTrigger, mouseOnly, store2, restMsRef, checkShouldOpen]);
7755 }
7756
7757 // node_modules/@base-ui/react/floating-ui-react/safePolygon.mjs
7758 var CURSOR_SPEED_THRESHOLD = 0.1;
7759 var CURSOR_SPEED_THRESHOLD_SQUARED = CURSOR_SPEED_THRESHOLD * CURSOR_SPEED_THRESHOLD;
7760 var POLYGON_BUFFER = 0.5;
7761 function hasIntersectingEdge(pointX, pointY, xi, yi, xj, yj) {
7762 return yi >= pointY !== yj >= pointY && pointX <= (xj - xi) * (pointY - yi) / (yj - yi) + xi;
7763 }
7764 function isPointInQuadrilateral(pointX, pointY, x1, y1, x2, y2, x3, y3, x4, y4) {
7765 let isInsideValue = false;
7766 if (hasIntersectingEdge(pointX, pointY, x1, y1, x2, y2)) {
7767 isInsideValue = !isInsideValue;
7768 }
7769 if (hasIntersectingEdge(pointX, pointY, x2, y2, x3, y3)) {
7770 isInsideValue = !isInsideValue;
7771 }
7772 if (hasIntersectingEdge(pointX, pointY, x3, y3, x4, y4)) {
7773 isInsideValue = !isInsideValue;
7774 }
7775 if (hasIntersectingEdge(pointX, pointY, x4, y4, x1, y1)) {
7776 isInsideValue = !isInsideValue;
7777 }
7778 return isInsideValue;
7779 }
7780 function isInsideRect(pointX, pointY, rect) {
7781 return pointX >= rect.x && pointX <= rect.x + rect.width && pointY >= rect.y && pointY <= rect.y + rect.height;
7782 }
7783 function isInsideAxisAlignedRect(pointX, pointY, x1, y1, x2, y2) {
7784 const minX = Math.min(x1, x2);
7785 const maxX = Math.max(x1, x2);
7786 const minY = Math.min(y1, y2);
7787 const maxY = Math.max(y1, y2);
7788 return pointX >= minX && pointX <= maxX && pointY >= minY && pointY <= maxY;
7789 }
7790 function safePolygon(options = {}) {
7791 const {
7792 blockPointerEvents = false
7793 } = options;
7794 const timeout = new Timeout();
7795 const fn = ({
7796 x: x2,
7797 y: y2,
7798 placement,
7799 elements,
7800 onClose,
7801 nodeId,
7802 tree
7803 }) => {
7804 const side = placement?.split("-")[0];
7805 let hasLanded = false;
7806 let lastX = null;
7807 let lastY = null;
7808 let lastCursorTime = typeof performance !== "undefined" ? performance.now() : 0;
7809 function isCursorMovingSlowly(nextX, nextY) {
7810 const currentTime = performance.now();
7811 const elapsedTime = currentTime - lastCursorTime;
7812 if (lastX === null || lastY === null || elapsedTime === 0) {
7813 lastX = nextX;
7814 lastY = nextY;
7815 lastCursorTime = currentTime;
7816 return false;
7817 }
7818 const deltaX = nextX - lastX;
7819 const deltaY = nextY - lastY;
7820 const distanceSquared = deltaX * deltaX + deltaY * deltaY;
7821 const thresholdSquared = elapsedTime * elapsedTime * CURSOR_SPEED_THRESHOLD_SQUARED;
7822 lastX = nextX;
7823 lastY = nextY;
7824 lastCursorTime = currentTime;
7825 return distanceSquared < thresholdSquared;
7826 }
7827 function close() {
7828 timeout.clear();
7829 onClose();
7830 }
7831 return function onMouseMove(event) {
7832 timeout.clear();
7833 const domReference = elements.domReference;
7834 const floating = elements.floating;
7835 if (!domReference || !floating || side == null || x2 == null || y2 == null) {
7836 return void 0;
7837 }
7838 const {
7839 clientX,
7840 clientY
7841 } = event;
7842 const target = getTarget(event);
7843 const isLeave = event.type === "mouseleave";
7844 const isOverFloatingEl = contains(floating, target);
7845 const isOverReferenceEl = contains(domReference, target);
7846 if (isOverFloatingEl) {
7847 hasLanded = true;
7848 if (!isLeave) {
7849 return void 0;
7850 }
7851 }
7852 if (isOverReferenceEl) {
7853 hasLanded = false;
7854 if (!isLeave) {
7855 hasLanded = true;
7856 return void 0;
7857 }
7858 }
7859 if (isLeave && isElement(event.relatedTarget) && contains(floating, event.relatedTarget)) {
7860 return void 0;
7861 }
7862 function hasOpenChildNode() {
7863 return Boolean(tree && getNodeChildren(tree.nodesRef.current, nodeId).length > 0);
7864 }
7865 function closeIfNoOpenChild() {
7866 if (!hasOpenChildNode()) {
7867 close();
7868 }
7869 }
7870 if (hasOpenChildNode()) {
7871 return void 0;
7872 }
7873 const refRect = domReference.getBoundingClientRect();
7874 const rect = floating.getBoundingClientRect();
7875 const cursorLeaveFromRight = x2 > rect.right - rect.width / 2;
7876 const cursorLeaveFromBottom = y2 > rect.bottom - rect.height / 2;
7877 const isFloatingWider = rect.width > refRect.width;
7878 const isFloatingTaller = rect.height > refRect.height;
7879 const left = (isFloatingWider ? refRect : rect).left;
7880 const right = (isFloatingWider ? refRect : rect).right;
7881 const top = (isFloatingTaller ? refRect : rect).top;
7882 const bottom = (isFloatingTaller ? refRect : rect).bottom;
7883 if (side === "top" && y2 >= refRect.bottom - 1 || side === "bottom" && y2 <= refRect.top + 1 || side === "left" && x2 >= refRect.right - 1 || side === "right" && x2 <= refRect.left + 1) {
7884 closeIfNoOpenChild();
7885 return void 0;
7886 }
7887 let isInsideTroughRect = false;
7888 switch (side) {
7889 case "top":
7890 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, refRect.top + 1, right, rect.bottom - 1);
7891 break;
7892 case "bottom":
7893 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, rect.top + 1, right, refRect.bottom - 1);
7894 break;
7895 case "left":
7896 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, rect.right - 1, bottom, refRect.left + 1, top);
7897 break;
7898 case "right":
7899 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, refRect.right - 1, bottom, rect.left + 1, top);
7900 break;
7901 default:
7902 }
7903 if (isInsideTroughRect) {
7904 return void 0;
7905 }
7906 if (hasLanded && !isInsideRect(clientX, clientY, refRect)) {
7907 closeIfNoOpenChild();
7908 return void 0;
7909 }
7910 if (!isLeave && isCursorMovingSlowly(clientX, clientY)) {
7911 closeIfNoOpenChild();
7912 return void 0;
7913 }
7914 let isInsidePolygon = false;
7915 switch (side) {
7916 case "top": {
7917 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7918 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7919 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7920 const cursorPointY = y2 + POLYGON_BUFFER + 1;
7921 const commonYLeft = cursorLeaveFromRight ? rect.bottom - POLYGON_BUFFER : isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top;
7922 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top : rect.bottom - POLYGON_BUFFER;
7923 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
7924 break;
7925 }
7926 case "bottom": {
7927 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7928 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7929 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7930 const cursorPointY = y2 - POLYGON_BUFFER;
7931 const commonYLeft = cursorLeaveFromRight ? rect.top + POLYGON_BUFFER : isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom;
7932 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom : rect.top + POLYGON_BUFFER;
7933 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
7934 break;
7935 }
7936 case "left": {
7937 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7938 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7939 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7940 const cursorPointX = x2 + POLYGON_BUFFER + 1;
7941 const commonXTop = cursorLeaveFromBottom ? rect.right - POLYGON_BUFFER : isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left;
7942 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left : rect.right - POLYGON_BUFFER;
7943 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, commonXTop, rect.top, commonXBottom, rect.bottom, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY);
7944 break;
7945 }
7946 case "right": {
7947 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7948 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7949 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7950 const cursorPointX = x2 - POLYGON_BUFFER;
7951 const commonXTop = cursorLeaveFromBottom ? rect.left + POLYGON_BUFFER : isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right;
7952 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right : rect.left + POLYGON_BUFFER;
7953 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY, commonXTop, rect.top, commonXBottom, rect.bottom);
7954 break;
7955 }
7956 default:
7957 }
7958 if (!isInsidePolygon) {
7959 closeIfNoOpenChild();
7960 } else if (!hasLanded) {
7961 timeout.start(40, closeIfNoOpenChild);
7962 }
7963 return void 0;
7964 };
7965 };
7966 fn.__options = {
7967 ...options,
7968 blockPointerEvents
7969 };
7970 return fn;
7971 }
7972
7973 // node_modules/@base-ui/react/utils/NullStore.mjs
7974 var NullStore = class extends ReactStore {
7975 // `update`/`set`/`notifyAll` funnel through `setState` in the base `Store`, so overriding
7976 // `setState` alone would neutralize them today. They are overridden explicitly so the store stays
7977 // inert even if a future base-class change stops routing a mutator through `setState`.
7978 setState(_newState) {
7979 }
7980 update(_changes) {
7981 }
7982 set(_key, _value) {
7983 }
7984 notifyAll() {
7985 }
7986 };
7987
7988 // node_modules/@base-ui/react/internals/composite/composite.mjs
7989 var ARROW_UP = "ArrowUp";
7990 var ARROW_DOWN = "ArrowDown";
7991 var ARROW_LEFT = "ArrowLeft";
7992 var ARROW_RIGHT = "ArrowRight";
7993 var HOME = "Home";
7994 var END = "End";
7995 var COMPOSITE_KEYS = /* @__PURE__ */ new Set([ARROW_UP, ARROW_DOWN, ARROW_LEFT, ARROW_RIGHT, HOME, END]);
7996 var SHIFT = "Shift";
7997 var MODIFIER_KEYS = [SHIFT, "Control", "Alt", "Meta"];
7998 function isInputElement(element) {
7999 return isHTMLElement(element) && element.tagName === "INPUT";
8000 }
8001 function isNativeInput(element) {
8002 if (isInputElement(element) && element.selectionStart != null) {
8003 return true;
8004 }
8005 if (isHTMLElement(element) && element.tagName === "TEXTAREA") {
8006 return true;
8007 }
8008 return false;
8009 }
8010 function scrollIntoViewIfNeeded(scrollContainer, element, direction, orientation) {
8011 if (!scrollContainer || !element || !element.scrollTo) {
8012 return;
8013 }
8014 let targetX = scrollContainer.scrollLeft;
8015 let targetY = scrollContainer.scrollTop;
8016 const isOverflowingX = scrollContainer.clientWidth < scrollContainer.scrollWidth;
8017 const isOverflowingY = scrollContainer.clientHeight < scrollContainer.scrollHeight;
8018 if (isOverflowingX && orientation !== "vertical") {
8019 const elementOffsetLeft = getOffset(scrollContainer, element, "left");
8020 const containerStyles = getStyles(scrollContainer);
8021 const elementStyles = getStyles(element);
8022 if (direction === "ltr") {
8023 if (elementOffsetLeft + element.offsetWidth + elementStyles.scrollMarginRight > scrollContainer.scrollLeft + scrollContainer.clientWidth - containerStyles.scrollPaddingRight) {
8024 targetX = elementOffsetLeft + element.offsetWidth + elementStyles.scrollMarginRight - scrollContainer.clientWidth + containerStyles.scrollPaddingRight;
8025 } else if (elementOffsetLeft - elementStyles.scrollMarginLeft < scrollContainer.scrollLeft + containerStyles.scrollPaddingLeft) {
8026 targetX = elementOffsetLeft - elementStyles.scrollMarginLeft - containerStyles.scrollPaddingLeft;
8027 }
8028 }
8029 if (direction === "rtl") {
8030 if (elementOffsetLeft - elementStyles.scrollMarginLeft < scrollContainer.scrollLeft + containerStyles.scrollPaddingLeft) {
8031 targetX = elementOffsetLeft - elementStyles.scrollMarginLeft - containerStyles.scrollPaddingLeft;
8032 } else if (elementOffsetLeft + element.offsetWidth + elementStyles.scrollMarginRight > scrollContainer.scrollLeft + scrollContainer.clientWidth - containerStyles.scrollPaddingRight) {
8033 targetX = elementOffsetLeft + element.offsetWidth + elementStyles.scrollMarginRight - scrollContainer.clientWidth + containerStyles.scrollPaddingRight;
8034 }
8035 }
8036 }
8037 if (isOverflowingY && orientation !== "horizontal") {
8038 const elementOffsetTop = getOffset(scrollContainer, element, "top");
8039 const containerStyles = getStyles(scrollContainer);
8040 const elementStyles = getStyles(element);
8041 if (elementOffsetTop - elementStyles.scrollMarginTop < scrollContainer.scrollTop + containerStyles.scrollPaddingTop) {
8042 targetY = elementOffsetTop - elementStyles.scrollMarginTop - containerStyles.scrollPaddingTop;
8043 } else if (elementOffsetTop + element.offsetHeight + elementStyles.scrollMarginBottom > scrollContainer.scrollTop + scrollContainer.clientHeight - containerStyles.scrollPaddingBottom) {
8044 targetY = elementOffsetTop + element.offsetHeight + elementStyles.scrollMarginBottom - scrollContainer.clientHeight + containerStyles.scrollPaddingBottom;
8045 }
8046 }
8047 scrollContainer.scrollTo({
8048 left: targetX,
8049 top: targetY,
8050 behavior: "auto"
8051 });
8052 }
8053 function getOffset(ancestor, element, side) {
8054 const propName = side === "left" ? "offsetLeft" : "offsetTop";
8055 let result = 0;
8056 while (element.offsetParent) {
8057 result += element[propName];
8058 if (element.offsetParent === ancestor) {
8059 break;
8060 }
8061 element = element.offsetParent;
8062 }
8063 return result;
8064 }
8065 function getStyles(element) {
8066 const styles = getComputedStyle(element);
8067 return {
8068 scrollMarginTop: parseFloat(styles.scrollMarginTop) || 0,
8069 scrollMarginRight: parseFloat(styles.scrollMarginRight) || 0,
8070 scrollMarginBottom: parseFloat(styles.scrollMarginBottom) || 0,
8071 scrollMarginLeft: parseFloat(styles.scrollMarginLeft) || 0,
8072 scrollPaddingTop: parseFloat(styles.scrollPaddingTop) || 0,
8073 scrollPaddingRight: parseFloat(styles.scrollPaddingRight) || 0,
8074 scrollPaddingBottom: parseFloat(styles.scrollPaddingBottom) || 0,
8075 scrollPaddingLeft: parseFloat(styles.scrollPaddingLeft) || 0
8076 };
8077 }
8078
8079 // node_modules/@base-ui/utils/inertValue.mjs
8080 function inertValue(value) {
8081 if (isReactVersionAtLeast(19)) {
8082 return value;
8083 }
8084 return value ? "true" : void 0;
8085 }
8086
8087 // node_modules/@base-ui/react/internals/useValueChanged.mjs
8088 var React39 = __toESM(require_react(), 1);
8089 function useValueChanged(value, onChange) {
8090 const valueRef = React39.useRef(value);
8091 const onChangeCallback = useStableCallback(onChange);
8092 useIsoLayoutEffect(() => {
8093 if (valueRef.current !== value) {
8094 onChangeCallback(valueRef.current);
8095 }
8096 valueRef.current = value;
8097 }, [value, onChangeCallback]);
8098 }
8099
8100 // node_modules/@base-ui/react/internals/field-root-context/FieldRootContext.mjs
8101 var React40 = __toESM(require_react(), 1);
8102
8103 // node_modules/@base-ui/react/field/control/FieldControlDataAttributes.mjs
8104 var valid = "data-valid";
8105 var invalid = "data-invalid";
8106
8107 // node_modules/@base-ui/react/internals/field-constants/constants.mjs
8108 var DEFAULT_VALIDITY_STATE = {
8109 badInput: false,
8110 customError: false,
8111 patternMismatch: false,
8112 rangeOverflow: false,
8113 rangeUnderflow: false,
8114 stepMismatch: false,
8115 tooLong: false,
8116 tooShort: false,
8117 typeMismatch: false,
8118 valid: null,
8119 valueMissing: false
8120 };
8121 var DEFAULT_FIELD_STATE_ATTRIBUTES = {
8122 valid: null,
8123 touched: false,
8124 dirty: false,
8125 filled: false,
8126 focused: false
8127 };
8128 var DEFAULT_FIELD_ROOT_STATE = {
8129 disabled: false,
8130 ...DEFAULT_FIELD_STATE_ATTRIBUTES
8131 };
8132 var fieldValidityMapping = {
8133 valid(value) {
8134 if (value === null) {
8135 return null;
8136 }
8137 if (value) {
8138 return {
8139 [valid]: ""
8140 };
8141 }
8142 return {
8143 [invalid]: ""
8144 };
8145 }
8146 };
8147
8148 // node_modules/@base-ui/react/internals/field-root-context/FieldRootContext.mjs
8149 var DEFAULT_FIELD_ROOT_CONTEXT = {
8150 invalid: void 0,
8151 name: void 0,
8152 validityData: {
8153 state: DEFAULT_VALIDITY_STATE,
8154 errors: [],
8155 error: "",
8156 value: "",
8157 initialValue: null
8158 },
8159 setValidityData: NOOP,
8160 disabled: void 0,
8161 setTouched: NOOP,
8162 setDirty: NOOP,
8163 setFilled: NOOP,
8164 setFocused: NOOP,
8165 validationMode: "onSubmit",
8166 shouldValidateOnChange: () => false,
8167 state: DEFAULT_FIELD_ROOT_STATE,
8168 registerFieldControl: NOOP,
8169 validation: {
8170 getValidationProps: (_disabled, props = EMPTY_OBJECT) => props,
8171 inputRef: {
8172 current: null
8173 },
8174 registeredInputs: /* @__PURE__ */ new Map(),
8175 registerInput: NOOP,
8176 getInputControl: () => null,
8177 commit: async () => {
8178 },
8179 change: NOOP
8180 }
8181 };
8182 var FieldRootContext = /* @__PURE__ */ React40.createContext(DEFAULT_FIELD_ROOT_CONTEXT);
8183 if (true) FieldRootContext.displayName = "FieldRootContext";
8184 function useFieldRootContext(optional = true) {
8185 const context = React40.useContext(FieldRootContext);
8186 if (context.setValidityData === NOOP && !optional) {
8187 throw new Error(true ? "Base UI: FieldRootContext is missing. Field parts must be placed within <Field.Root>." : formatErrorMessage_default(28));
8188 }
8189 return context;
8190 }
8191
8192 // node_modules/@base-ui/react/internals/field-register-control/useRegisterFieldControl.mjs
8193 function useRegisterFieldControl(controlRef, id, value, getFormValueOverride, enabled = true, name) {
8194 const {
8195 registerFieldControl
8196 } = useFieldRootContext();
8197 const sourceRef = useRefWithInit(() => /* @__PURE__ */ Symbol());
8198 useIsoLayoutEffect(() => {
8199 const source = sourceRef.current;
8200 if (!enabled) {
8201 registerFieldControl(source, void 0);
8202 return;
8203 }
8204 const registration = {
8205 controlRef,
8206 getValue: getFormValueOverride,
8207 id,
8208 name,
8209 value
8210 };
8211 registerFieldControl(source, registration);
8212 }, [controlRef, enabled, getFormValueOverride, id, name, registerFieldControl, sourceRef, value]);
8213 useIsoLayoutEffect(() => {
8214 const source = sourceRef.current;
8215 return () => {
8216 registerFieldControl(source, void 0);
8217 };
8218 }, [registerFieldControl, sourceRef]);
8219 }
8220
8221 // node_modules/@base-ui/react/internals/form-context/FormContext.mjs
8222 var React41 = __toESM(require_react(), 1);
8223 var FormContext = /* @__PURE__ */ React41.createContext({
8224 elementRef: {
8225 current: null
8226 },
8227 formRef: {
8228 current: {
8229 fields: /* @__PURE__ */ new Map()
8230 }
8231 },
8232 errors: {},
8233 clearErrors: NOOP,
8234 validationMode: "onSubmit",
8235 submitCountRef: {
8236 current: 0
8237 }
8238 });
8239 if (true) FormContext.displayName = "FormContext";
8240 function useFormContext() {
8241 return React41.useContext(FormContext);
8242 }
8243
8244 // node_modules/@base-ui/react/internals/labelable-provider/useLabelableId.mjs
8245 var React43 = __toESM(require_react(), 1);
8246
8247 // node_modules/@base-ui/react/internals/labelable-provider/LabelableContext.mjs
8248 var React42 = __toESM(require_react(), 1);
8249 var LabelableContext = /* @__PURE__ */ React42.createContext({
8250 controlId: void 0,
8251 registerControlId: NOOP,
8252 resetControlId: NOOP,
8253 labelId: void 0,
8254 setLabelId: NOOP,
8255 messageIds: [],
8256 setMessageIds: NOOP,
8257 getDescriptionProps: (externalProps) => externalProps
8258 });
8259 if (true) LabelableContext.displayName = "LabelableContext";
8260 function useLabelableContext() {
8261 return React42.useContext(LabelableContext);
8262 }
8263
8264 // node_modules/@base-ui/react/internals/labelable-provider/useLabelableId.mjs
8265 function useLabelableId(params = {}) {
8266 const {
8267 id,
8268 enabled = true
8269 } = params;
8270 const {
8271 controlId,
8272 registerControlId,
8273 resetControlId
8274 } = useLabelableContext();
8275 const defaultId = useBaseUiId();
8276 const controlSourceRef = useRefWithInit(() => /* @__PURE__ */ Symbol());
8277 const hasRegisteredRef = React43.useRef(false);
8278 const hadExplicitIdRef = React43.useRef(false);
8279 const unregisterControlId = useStableCallback(() => {
8280 if (!hasRegisteredRef.current || registerControlId === NOOP) {
8281 return;
8282 }
8283 hasRegisteredRef.current = false;
8284 registerControlId(controlSourceRef.current, void 0);
8285 });
8286 useIsoLayoutEffect(() => {
8287 if (!enabled || registerControlId === NOOP) {
8288 unregisterControlId();
8289 return void 0;
8290 }
8291 let nextId;
8292 if (id !== void 0) {
8293 hadExplicitIdRef.current = true;
8294 nextId = id;
8295 } else if (hadExplicitIdRef.current) {
8296 nextId = defaultId;
8297 } else {
8298 resetControlId();
8299 return void 0;
8300 }
8301 if (nextId === void 0) {
8302 unregisterControlId();
8303 return void 0;
8304 }
8305 hasRegisteredRef.current = true;
8306 registerControlId(controlSourceRef.current, nextId);
8307 return void 0;
8308 }, [id, enabled, registerControlId, resetControlId, defaultId, controlSourceRef, unregisterControlId]);
8309 useIsoLayoutEffect(() => {
8310 return unregisterControlId;
8311 }, [unregisterControlId]);
8312 return (enabled ? controlId : void 0) ?? id ?? defaultId;
8313 }
8314
8315 // node_modules/@base-ui/react/internals/direction-context/DirectionContext.mjs
8316 var React44 = __toESM(require_react(), 1);
8317 var DirectionContext = /* @__PURE__ */ React44.createContext(void 0);
8318 if (true) DirectionContext.displayName = "DirectionContext";
8319 function useDirection() {
8320 const context = React44.useContext(DirectionContext);
8321 return context?.direction ?? "ltr";
8322 }
8323
8324 // node_modules/@base-ui/react/internals/useAnchorPositioning.mjs
8325 var React45 = __toESM(require_react(), 1);
8326
8327 // node_modules/@base-ui/react/floating-ui-react/middleware/arrow.mjs
8328 var baseArrow = (options) => ({
8329 name: "arrow",
8330 options,
8331 async fn(state) {
8332 const {
8333 x: x2,
8334 y: y2,
8335 placement,
8336 rects,
8337 platform: platform3,
8338 elements,
8339 middlewareData
8340 } = state;
8341 const {
8342 element,
8343 padding = 0,
8344 offsetParent = "real"
8345 } = evaluate(options, state) || {};
8346 if (element == null) {
8347 return {};
8348 }
8349 const paddingObject = getPaddingObject(padding);
8350 const coords = {
8351 x: x2,
8352 y: y2
8353 };
8354 const axis = getAlignmentAxis(placement);
8355 const length2 = getAxisLength(axis);
8356 const arrowDimensions = await platform3.getDimensions(element);
8357 const isYAxis = axis === "y";
8358 const minProp = isYAxis ? "top" : "left";
8359 const maxProp = isYAxis ? "bottom" : "right";
8360 const clientProp = isYAxis ? "clientHeight" : "clientWidth";
8361 const endDiff = rects.reference[length2] + rects.reference[axis] - coords[axis] - rects.floating[length2];
8362 const startDiff = coords[axis] - rects.reference[axis];
8363 const arrowOffsetParent = offsetParent === "real" ? await platform3.getOffsetParent?.(element) : elements.floating;
8364 let clientSize = elements.floating[clientProp] || rects.floating[length2];
8365 if (!clientSize || !await platform3.isElement?.(arrowOffsetParent)) {
8366 clientSize = elements.floating[clientProp] || rects.floating[length2];
8367 }
8368 const centerToReference = endDiff / 2 - startDiff / 2;
8369 const largestPossiblePadding = clientSize / 2 - arrowDimensions[length2] / 2 - 1;
8370 const minPadding = Math.min(paddingObject[minProp], largestPossiblePadding);
8371 const maxPadding = Math.min(paddingObject[maxProp], largestPossiblePadding);
8372 const min4 = minPadding;
8373 const max4 = clientSize - arrowDimensions[length2] - maxPadding;
8374 const center = clientSize / 2 - arrowDimensions[length2] / 2 + centerToReference;
8375 const offset4 = clamp(min4, center, max4);
8376 const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset4 && rects.reference[length2] / 2 - (center < min4 ? minPadding : maxPadding) - arrowDimensions[length2] / 2 < 0;
8377 const alignmentOffset = shouldAddOffset ? center < min4 ? center - min4 : center - max4 : 0;
8378 return {
8379 [axis]: coords[axis] + alignmentOffset,
8380 data: {
8381 [axis]: offset4,
8382 centerOffset: center - offset4 - alignmentOffset,
8383 ...shouldAddOffset && {
8384 alignmentOffset
8385 }
8386 },
8387 reset: shouldAddOffset
8388 };
8389 }
8390 });
8391 var arrow4 = (options, deps) => {
8392 const {
8393 name,
8394 fn
8395 } = baseArrow(options);
8396 return {
8397 name,
8398 fn,
8399 options: [options, deps]
8400 };
8401 };
8402
8403 // node_modules/@base-ui/react/utils/hideMiddleware.mjs
8404 var hide4 = {
8405 name: "hide",
8406 async fn(state) {
8407 const {
8408 width,
8409 height,
8410 x: x2,
8411 y: y2
8412 } = state.rects.reference;
8413 const anchorHidden2 = width === 0 && height === 0 && x2 === 0 && y2 === 0;
8414 const overflow = await state.platform.detectOverflow(state, {
8415 elementContext: "reference"
8416 });
8417 const referenceHidden = overflow.top - height >= 0 || overflow.right - width >= 0 || overflow.bottom - height >= 0 || overflow.left - width >= 0;
8418 return {
8419 data: {
8420 referenceHidden: referenceHidden || anchorHidden2
8421 }
8422 };
8423 }
8424 };
8425
8426 // node_modules/@base-ui/react/utils/adaptiveOriginConstants.mjs
8427 var DEFAULT_SIDES = {
8428 sideX: "left",
8429 sideY: "top"
8430 };
8431
8432 // node_modules/@base-ui/react/utils/CommonPositionerCssVars.mjs
8433 var availableWidth = "--available-width";
8434 var availableHeight = "--available-height";
8435 var anchorWidth = "--anchor-width";
8436 var anchorHeight = "--anchor-height";
8437 var transformOrigin = "--transform-origin";
8438 var positionerWidth = "--positioner-width";
8439 var positionerHeight = "--positioner-height";
8440
8441 // node_modules/@base-ui/react/internals/useAnchorPositioning.mjs
8442 var AVAILABLE_WIDTH_VAR = availableWidth;
8443 var AVAILABLE_HEIGHT_VAR = availableHeight;
8444 function getLogicalSide(sideParam, renderedSide, isRtl) {
8445 const isLogicalSideParam = sideParam === "inline-start" || sideParam === "inline-end";
8446 const logicalRight = isRtl ? "inline-start" : "inline-end";
8447 const logicalLeft = isRtl ? "inline-end" : "inline-start";
8448 return {
8449 top: "top",
8450 right: isLogicalSideParam ? logicalRight : "right",
8451 bottom: "bottom",
8452 left: isLogicalSideParam ? logicalLeft : "left"
8453 }[renderedSide];
8454 }
8455 function getOffsetData(state, sideParam, isRtl) {
8456 const {
8457 rects,
8458 placement
8459 } = state;
8460 const data = {
8461 side: getLogicalSide(sideParam, getSide(placement), isRtl),
8462 align: getAlignment(placement) || "center",
8463 anchor: {
8464 width: rects.reference.width,
8465 height: rects.reference.height
8466 },
8467 positioner: {
8468 width: rects.floating.width,
8469 height: rects.floating.height
8470 }
8471 };
8472 return data;
8473 }
8474 function useAnchorPositioning(params) {
8475 return useAnchorPositioningWithHook(params, useBaseUIFloating);
8476 }
8477 function useAnchorPositioningWithHook(params, useFloatingHook) {
8478 const {
8479 // Public parameters
8480 anchor,
8481 positionMethod = "absolute",
8482 side: sideParam = "bottom",
8483 sideOffset = 0,
8484 align = "center",
8485 alignOffset = 0,
8486 collisionBoundary,
8487 collisionPadding: collisionPaddingParam = 5,
8488 sticky = false,
8489 arrowPadding = 5,
8490 disableAnchorTracking = false,
8491 inline: inlineMiddleware,
8492 // Private parameters
8493 keepMounted = false,
8494 floatingRootContext,
8495 mounted,
8496 collisionAvoidance,
8497 shift: shift4,
8498 nodeId,
8499 adaptiveOrigin: adaptiveOrigin2,
8500 lazyFlip = false,
8501 externalTree
8502 } = params;
8503 const [mountSide, setMountSide] = React45.useState(null);
8504 if (!mounted && mountSide !== null) {
8505 setMountSide(null);
8506 }
8507 const collisionAvoidanceSide = collisionAvoidance.side || "flip";
8508 const collisionAvoidanceAlign = collisionAvoidance.align || "flip";
8509 const collisionAvoidanceFallbackAxisSide = collisionAvoidance.fallbackAxisSide || "end";
8510 const shiftCrossAxis = shift4?.crossAxis ?? false;
8511 const shiftRootBoundary = shift4?.rootBoundary;
8512 const anchorFn = typeof anchor === "function" ? anchor : void 0;
8513 const anchorFnCallback = useStableCallback(anchorFn);
8514 const anchorDep = anchorFn ? anchorFnCallback : anchor;
8515 const anchorValueRef = useValueAsRef(anchor);
8516 const mountedRef = useValueAsRef(mounted);
8517 const direction = useDirection();
8518 const isRtl = direction === "rtl";
8519 const side = mountSide || {
8520 top: "top",
8521 right: "right",
8522 bottom: "bottom",
8523 left: "left",
8524 "inline-end": isRtl ? "left" : "right",
8525 "inline-start": isRtl ? "right" : "left"
8526 }[sideParam];
8527 const placement = align === "center" ? side : `${side}-${align}`;
8528 let collisionPadding = collisionPaddingParam;
8529 if (typeof collisionPadding === "number") {
8530 collisionPadding = {
8531 top: collisionPadding,
8532 right: collisionPadding,
8533 bottom: collisionPadding,
8534 left: collisionPadding
8535 };
8536 } else if (collisionPadding) {
8537 collisionPadding = {
8538 top: collisionPadding.top || 0,
8539 right: collisionPadding.right || 0,
8540 bottom: collisionPadding.bottom || 0,
8541 left: collisionPadding.left || 0
8542 };
8543 }
8544 const bias = 1;
8545 const biasTop = sideParam === "bottom" ? bias : 0;
8546 const biasBottom = sideParam === "top" ? bias : 0;
8547 const biasLeft = sideParam === "right" ? bias : 0;
8548 const biasRight = sideParam === "left" ? bias : 0;
8549 const commonCollisionProps = {
8550 boundary: collisionBoundary === "clipping-ancestors" ? "clippingAncestors" : collisionBoundary,
8551 padding: collisionPadding
8552 };
8553 const arrowRef = React45.useRef(null);
8554 const sideOffsetRef = useValueAsRef(sideOffset);
8555 const alignOffsetRef = useValueAsRef(alignOffset);
8556 const sideOffsetDep = typeof sideOffset !== "function" ? sideOffset : 0;
8557 const alignOffsetDep = typeof alignOffset !== "function" ? alignOffset : 0;
8558 const middleware = [];
8559 if (inlineMiddleware) {
8560 middleware.push(inlineMiddleware);
8561 }
8562 middleware.push(offset3((state) => {
8563 const data = getOffsetData(state, sideParam, isRtl);
8564 const sideAxis = typeof sideOffsetRef.current === "function" ? sideOffsetRef.current(data) : sideOffsetRef.current;
8565 const alignAxis = typeof alignOffsetRef.current === "function" ? alignOffsetRef.current(data) : alignOffsetRef.current;
8566 return {
8567 mainAxis: sideAxis,
8568 crossAxis: alignAxis,
8569 alignmentAxis: alignAxis
8570 };
8571 }, [sideOffsetDep, alignOffsetDep, isRtl, sideParam]));
8572 const shiftDisabled = collisionAvoidanceAlign === "none" && collisionAvoidanceSide !== "shift";
8573 const crossAxisShiftEnabled = !shiftDisabled && (sticky || shiftCrossAxis || collisionAvoidanceSide === "shift");
8574 const flipMiddleware = collisionAvoidanceSide === "none" ? null : flip3({
8575 ...commonCollisionProps,
8576 // Ensure the popup flips if it's been limited by its --available-height and it resizes.
8577 // Since the size() padding is smaller than the flip() padding, flip() will take precedence.
8578 padding: {
8579 top: collisionPadding.top + bias + biasTop,
8580 right: collisionPadding.right + bias + biasRight,
8581 bottom: collisionPadding.bottom + bias + biasBottom,
8582 left: collisionPadding.left + bias + biasLeft
8583 },
8584 mainAxis: !shiftCrossAxis && collisionAvoidanceSide === "flip",
8585 crossAxis: collisionAvoidanceAlign === "flip" ? "alignment" : false,
8586 fallbackAxisSideDirection: collisionAvoidanceFallbackAxisSide
8587 });
8588 const shiftMiddleware = shiftDisabled ? null : shift3({
8589 ...commonCollisionProps,
8590 // Use the Layout Viewport to avoid shifting around when pinch-zooming.
8591 rootBoundary: shiftRootBoundary,
8592 mainAxis: collisionAvoidanceAlign !== "none",
8593 crossAxis: crossAxisShiftEnabled,
8594 limiter: sticky || shiftCrossAxis ? void 0 : limitShift3((limitData) => {
8595 if (!arrowRef.current) {
8596 return {};
8597 }
8598 const {
8599 width,
8600 height
8601 } = arrowRef.current.getBoundingClientRect();
8602 const sideAxis = getSideAxis(getSide(limitData.placement));
8603 const arrowSize = sideAxis === "y" ? width : height;
8604 const offsetAmount = sideAxis === "y" ? collisionPadding.left + collisionPadding.right : collisionPadding.top + collisionPadding.bottom;
8605 return {
8606 offset: arrowSize / 2 + offsetAmount / 2
8607 };
8608 })
8609 }, [commonCollisionProps, sticky, shiftCrossAxis, shiftRootBoundary, collisionPadding, collisionAvoidanceAlign]);
8610 if (collisionAvoidanceSide === "shift" || collisionAvoidanceAlign === "shift" || align === "center") {
8611 middleware.push(shiftMiddleware, flipMiddleware);
8612 } else {
8613 middleware.push(flipMiddleware, shiftMiddleware);
8614 }
8615 middleware.push(size3({
8616 ...commonCollisionProps,
8617 apply({
8618 elements: {
8619 floating
8620 },
8621 availableWidth: availableWidth2,
8622 availableHeight: availableHeight2,
8623 rects
8624 }) {
8625 if (!mountedRef.current) {
8626 return;
8627 }
8628 const floatingStyle = floating.style;
8629 floatingStyle.setProperty(AVAILABLE_WIDTH_VAR, `${availableWidth2}px`);
8630 floatingStyle.setProperty(AVAILABLE_HEIGHT_VAR, `${availableHeight2}px`);
8631 const dpr = getWindow(floating).devicePixelRatio || 1;
8632 const {
8633 x: x3,
8634 y: y3,
8635 width,
8636 height
8637 } = rects.reference;
8638 const anchorWidth2 = (Math.round((x3 + width) * dpr) - Math.round(x3 * dpr)) / dpr;
8639 const anchorHeight2 = (Math.round((y3 + height) * dpr) - Math.round(y3 * dpr)) / dpr;
8640 floatingStyle.setProperty(anchorWidth, `${anchorWidth2}px`);
8641 floatingStyle.setProperty(anchorHeight, `${anchorHeight2}px`);
8642 }
8643 }), arrow4((state) => ({
8644 // `transform-origin` calculations rely on an element existing. If the arrow hasn't been set,
8645 // we'll create a fake element.
8646 element: arrowRef.current || ownerDocument(state.elements.floating).createElement("div"),
8647 // No padding for the fake arrow: it would displace aligned popups on narrow anchors.
8648 padding: arrowRef.current ? arrowPadding : 0,
8649 offsetParent: "floating"
8650 }), [arrowPadding]), {
8651 name: "transformOrigin",
8652 fn(state) {
8653 const {
8654 elements: {
8655 floating
8656 },
8657 middlewareData: middlewareData2,
8658 placement: renderedPlacement2,
8659 platform: platform3,
8660 rects,
8661 y: y3
8662 } = state;
8663 const renderedSide2 = getSide(renderedPlacement2);
8664 const renderedAlign2 = getAlignment(renderedPlacement2);
8665 const isVertical = getSideAxis(renderedSide2) === "y";
8666 const arrowEl = arrowRef.current;
8667 const sideOffsetValue = typeof sideOffset === "function" ? sideOffset(getOffsetData(state, sideParam, isRtl)) : sideOffset;
8668 let crossOrigin;
8669 if (!arrowEl && renderedAlign2 && Math.abs(isVertical ? middlewareData2.shift?.x || 0 : middlewareData2.shift?.y || 0) <= 1) {
8670 crossOrigin = renderedAlign2 === "start" === (isVertical && platform3.isRTL?.(floating) === true) ? "100%" : "0%";
8671 } else {
8672 const arrowOffset = isVertical ? middlewareData2.arrow?.x || 0 : middlewareData2.arrow?.y || 0;
8673 const arrowSize = isVertical ? arrowEl?.clientWidth || 0 : arrowEl?.clientHeight || 0;
8674 crossOrigin = `${arrowOffset + arrowSize / 2}px`;
8675 }
8676 let sideOrigin = renderedSide2 === "top" || renderedSide2 === "left" ? `calc(100% + ${sideOffsetValue}px)` : `${-sideOffsetValue}px`;
8677 if (crossAxisShiftEnabled && isVertical && Math.abs(middlewareData2.shift?.y || 0) > sideOffsetValue) {
8678 sideOrigin = `${rects.reference.y + rects.reference.height / 2 - y3}px`;
8679 }
8680 floating.style.setProperty(transformOrigin, isVertical ? `${crossOrigin} ${sideOrigin}` : `${sideOrigin} ${crossOrigin}`);
8681 return {};
8682 }
8683 }, hide4, adaptiveOrigin2);
8684 useIsoLayoutEffect(() => {
8685 if (!mounted && floatingRootContext) {
8686 floatingRootContext.update({
8687 referenceElement: null,
8688 floatingElement: null,
8689 domReferenceElement: null,
8690 positionReference: null
8691 });
8692 }
8693 }, [mounted, floatingRootContext]);
8694 const autoUpdateOptions = React45.useMemo(() => ({
8695 ancestorScroll: !disableAnchorTracking,
8696 elementResize: !disableAnchorTracking && typeof ResizeObserver !== "undefined",
8697 layoutShift: !disableAnchorTracking && typeof IntersectionObserver !== "undefined"
8698 }), [disableAnchorTracking]);
8699 const {
8700 refs,
8701 elements,
8702 x: x2,
8703 y: y2,
8704 middlewareData,
8705 update: update2,
8706 placement: renderedPlacement,
8707 context,
8708 isPositioned,
8709 floatingStyles: originalFloatingStyles
8710 } = useFloatingHook({
8711 rootContext: floatingRootContext,
8712 open: keepMounted ? mounted : void 0,
8713 placement,
8714 middleware,
8715 strategy: positionMethod,
8716 whileElementsMounted: keepMounted ? void 0 : (...args) => autoUpdate(...args, autoUpdateOptions),
8717 nodeId,
8718 externalTree
8719 });
8720 const {
8721 sideX,
8722 sideY
8723 } = middlewareData.adaptiveOrigin || DEFAULT_SIDES;
8724 const resolvedPosition = isPositioned ? positionMethod : "fixed";
8725 const floatingStyles = React45.useMemo(() => {
8726 let base;
8727 if (!isPositioned) {
8728 base = {
8729 position: resolvedPosition,
8730 top: 0,
8731 left: 0
8732 };
8733 } else if (adaptiveOrigin2) {
8734 base = {
8735 position: resolvedPosition,
8736 [sideX]: x2,
8737 [sideY]: y2
8738 };
8739 } else {
8740 base = {
8741 ...originalFloatingStyles,
8742 position: resolvedPosition
8743 };
8744 }
8745 base[AVAILABLE_WIDTH_VAR] = "100vw";
8746 base[AVAILABLE_HEIGHT_VAR] = "100vh";
8747 if (!isPositioned) {
8748 base.opacity = 0;
8749 }
8750 return base;
8751 }, [adaptiveOrigin2, resolvedPosition, sideX, x2, sideY, y2, originalFloatingStyles, isPositioned]);
8752 const registeredPositionReferenceRef = React45.useRef(null);
8753 useIsoLayoutEffect(() => {
8754 if (!mounted) {
8755 return;
8756 }
8757 const anchorValue = anchorValueRef.current;
8758 const resolvedAnchor = typeof anchorValue === "function" ? anchorValue() : anchorValue;
8759 const unwrappedElement = (isRef(resolvedAnchor) ? resolvedAnchor.current : resolvedAnchor) || null;
8760 const finalAnchor = unwrappedElement || null;
8761 if (finalAnchor !== registeredPositionReferenceRef.current) {
8762 refs.setPositionReference(finalAnchor);
8763 registeredPositionReferenceRef.current = finalAnchor;
8764 }
8765 }, [mounted, refs, anchorDep, anchorValueRef]);
8766 React45.useEffect(() => {
8767 if (!mounted) {
8768 return;
8769 }
8770 const anchorValue = anchorValueRef.current;
8771 if (typeof anchorValue === "function") {
8772 return;
8773 }
8774 if (isRef(anchorValue) && anchorValue.current !== registeredPositionReferenceRef.current) {
8775 refs.setPositionReference(anchorValue.current);
8776 registeredPositionReferenceRef.current = anchorValue.current;
8777 }
8778 }, [mounted, refs, anchorDep, anchorValueRef]);
8779 React45.useEffect(() => {
8780 if (keepMounted && mounted && elements.reference && elements.floating) {
8781 return autoUpdate(elements.reference, elements.floating, update2, autoUpdateOptions);
8782 }
8783 return void 0;
8784 }, [keepMounted, mounted, elements, update2, autoUpdateOptions]);
8785 const renderedSide = getSide(renderedPlacement);
8786 const logicalRenderedSide = getLogicalSide(sideParam, renderedSide, isRtl);
8787 const renderedAlign = getAlignment(renderedPlacement) || "center";
8788 const anchorHidden2 = Boolean(middlewareData.hide?.referenceHidden);
8789 useIsoLayoutEffect(() => {
8790 if (lazyFlip && mounted && isPositioned && renderedSide !== side) {
8791 setMountSide(renderedSide);
8792 }
8793 }, [lazyFlip, mounted, isPositioned, renderedSide, side]);
8794 const arrowStyles = React45.useMemo(() => ({
8795 position: "absolute",
8796 top: middlewareData.arrow?.y,
8797 left: middlewareData.arrow?.x
8798 }), [middlewareData.arrow]);
8799 const arrowUncentered = middlewareData.arrow?.centerOffset !== 0;
8800 return React45.useMemo(() => ({
8801 positionerStyles: floatingStyles,
8802 arrowStyles,
8803 arrowRef,
8804 arrowUncentered,
8805 side: logicalRenderedSide,
8806 align: renderedAlign,
8807 physicalSide: renderedSide,
8808 anchorHidden: anchorHidden2,
8809 refs,
8810 context,
8811 isPositioned,
8812 update: update2
8813 }), [floatingStyles, arrowStyles, arrowRef, arrowUncentered, logicalRenderedSide, renderedAlign, renderedSide, anchorHidden2, refs, context, isPositioned, update2]);
8814 }
8815 function isRef(param) {
8816 return param != null && "current" in param;
8817 }
8818
8819 // node_modules/@base-ui/react/internals/getDisabledMountTransitionStyles.mjs
8820 function getDisabledMountTransitionStyles(transitionStatus) {
8821 return transitionStatus === "starting" ? DISABLED_TRANSITIONS_STYLE : EMPTY_OBJECT;
8822 }
8823
8824 // node_modules/@base-ui/react/utils/usePositioner.mjs
8825 function usePositioner(componentProps, state, {
8826 styles,
8827 transitionStatus,
8828 props,
8829 refs,
8830 hidden,
8831 inert = false
8832 }) {
8833 const style = {
8834 ...styles
8835 };
8836 if (inert) {
8837 style.pointerEvents = "none";
8838 }
8839 return useRenderElement("div", componentProps, {
8840 state,
8841 ref: refs,
8842 props: [{
8843 role: "presentation",
8844 hidden,
8845 style
8846 }, getDisabledMountTransitionStyles(transitionStatus), props],
8847 stateAttributesMapping: popupStateMapping
8848 });
8849 }
8850
8851 // node_modules/@base-ui/react/button/Button.mjs
8852 var React46 = __toESM(require_react(), 1);
8853 var Button = /* @__PURE__ */ React46.forwardRef(function Button2(componentProps, forwardedRef) {
8854 const {
8855 render: render4,
8856 className,
8857 disabled: disabled2 = false,
8858 focusableWhenDisabled = false,
8859 nativeButton = true,
8860 style,
8861 ...elementProps
8862 } = componentProps;
8863 const {
8864 getButtonProps,
8865 buttonRef
8866 } = useButton({
8867 disabled: disabled2,
8868 focusableWhenDisabled,
8869 native: nativeButton
8870 });
8871 const state = {
8872 disabled: disabled2
8873 };
8874 return useRenderElement("button", componentProps, {
8875 state,
8876 ref: [forwardedRef, buttonRef],
8877 props: [elementProps, getButtonProps]
8878 });
8879 });
8880 if (true) Button.displayName = "Button";
8881
8882 // node_modules/@base-ui/react/field/item/FieldItemContext.mjs
8883 var React47 = __toESM(require_react(), 1);
8884 var FieldItemContext = /* @__PURE__ */ React47.createContext({
8885 disabled: false
8886 });
8887 if (true) FieldItemContext.displayName = "FieldItemContext";
8888 function useFieldItemContext() {
8889 const context = React47.useContext(FieldItemContext);
8890 return context;
8891 }
8892
8893 // node_modules/@base-ui/react/field/root/useFieldValidation.mjs
8894 var React48 = __toESM(require_react(), 1);
8895
8896 // node_modules/@base-ui/react/field/utils/getCombinedFieldValidityData.mjs
8897 function getCombinedFieldValidityData(validityData, invalid2) {
8898 return {
8899 ...validityData,
8900 state: {
8901 ...validityData.state,
8902 valid: !invalid2 && validityData.state.valid
8903 }
8904 };
8905 }
8906
8907 // node_modules/@base-ui/react/field/root/useFieldValidation.mjs
8908 var validityKeys = Object.keys(DEFAULT_VALIDITY_STATE);
8909 function isEligibleInput(input, formElement) {
8910 if (input.matches(":disabled")) {
8911 return false;
8912 }
8913 if (!formElement || input.form === formElement) {
8914 return true;
8915 }
8916 return input.form === null && !input.hasAttribute("form");
8917 }
8918 function findRepresentativeInput(inputs, formElement) {
8919 let fallback = null;
8920 for (const input of inputs.keys()) {
8921 if (!isEligibleInput(input, formElement)) {
8922 continue;
8923 }
8924 if (!input.validity.valid) {
8925 return input;
8926 }
8927 fallback ??= input;
8928 }
8929 return fallback;
8930 }
8931 function makeState(customError) {
8932 return {
8933 ...DEFAULT_VALIDITY_STATE,
8934 valid: !customError,
8935 customError
8936 };
8937 }
8938 function getNativeErrors(element) {
8939 return element && element.validationMessage ? [element.validationMessage] : [];
8940 }
8941 function useFieldValidation(params) {
8942 const {
8943 elementRef,
8944 formRef
8945 } = useFormContext();
8946 const {
8947 setValidityData,
8948 validate,
8949 validityData,
8950 validationDebounceTime,
8951 invalid: invalid2,
8952 markedDirtyRef,
8953 state,
8954 shouldValidateOnChange,
8955 validationMode,
8956 registeredFieldIdRef
8957 } = params;
8958 const {
8959 controlId,
8960 getDescriptionProps
8961 } = useLabelableContext();
8962 const timeout = useTimeout();
8963 const inputRef = React48.useRef(null);
8964 const registeredInputs = useRefWithInit(() => /* @__PURE__ */ new Map()).current;
8965 const validationCommitIdRef = React48.useRef(0);
8966 const customValidityRef = React48.useRef(null);
8967 const registerInput = React48.useCallback((element, registration) => {
8968 registeredInputs.set(element, registration);
8969 return () => {
8970 registeredInputs.delete(element);
8971 };
8972 }, [registeredInputs]);
8973 const getInputControl = useStableCallback(() => {
8974 const element = findRepresentativeInput(registeredInputs, elementRef.current);
8975 return element && registeredInputs.get(element)?.controlRef.current || null;
8976 });
8977 const commit = useStableCallback(async (value, revalidate = false) => {
8978 validationCommitIdRef.current += 1;
8979 const validationCommitId = validationCommitIdRef.current;
8980 function updateRegisteredFieldValidity(nextValidityData, externalInvalid = invalid2) {
8981 const fieldId = registeredFieldIdRef.current ?? controlId;
8982 if (fieldId == null) {
8983 return;
8984 }
8985 const currentFieldData = formRef.current.fields.get(fieldId);
8986 if (!currentFieldData) {
8987 return;
8988 }
8989 const validityDataWithFormErrors = getCombinedFieldValidityData(nextValidityData, externalInvalid);
8990 formRef.current.fields.set(fieldId, {
8991 ...currentFieldData,
8992 validityData: validityDataWithFormErrors
8993 });
8994 }
8995 function makeValidityData(validityState, errorMessages) {
8996 const errors = validityState.valid === false ? errorMessages : [];
8997 return {
8998 value,
8999 state: validityState,
9000 error: errors[0] ?? "",
9001 errors,
9002 initialValue: validityData.initialValue
9003 };
9004 }
9005 function setCustomValidity(element2, message2) {
9006 const displaced = element2.validity.customError ? element2.validationMessage : "";
9007 const ownedMessage = message2.replace(/\r\n?/g, "\n");
9008 element2.setCustomValidity(ownedMessage);
9009 customValidityRef.current = [element2, ownedMessage, displaced];
9010 }
9011 function clearCustomValidity() {
9012 const record = customValidityRef.current;
9013 customValidityRef.current = null;
9014 if (record && (!record[0].willValidate || record[0].validationMessage === record[1])) {
9015 record[0].setCustomValidity(record[2]);
9016 }
9017 }
9018 function publish(validityState, errorMessages, externalInvalid) {
9019 const nextValidityData = makeValidityData(validityState, errorMessages);
9020 updateRegisteredFieldValidity(nextValidityData, externalInvalid);
9021 setValidityData(nextValidityData);
9022 }
9023 function getState(el) {
9024 const computedState = validityKeys.reduce((acc, key) => {
9025 acc[key] = el.validity[key];
9026 return acc;
9027 }, {});
9028 let hasOnlyValueMissingError = false;
9029 for (const key of validityKeys) {
9030 if (key === "valid") {
9031 continue;
9032 }
9033 if (key === "valueMissing" && computedState[key]) {
9034 hasOnlyValueMissingError = true;
9035 } else if (computedState[key]) {
9036 return computedState;
9037 }
9038 }
9039 if (hasOnlyValueMissingError && !markedDirtyRef.current) {
9040 computedState.valid = true;
9041 computedState.valueMissing = false;
9042 }
9043 return computedState;
9044 }
9045 function resolveRepresentativeInput() {
9046 return registeredInputs.size > 0 ? findRepresentativeInput(registeredInputs, elementRef.current) : inputRef.current;
9047 }
9048 let element = resolveRepresentativeInput();
9049 function refreshState() {
9050 element = resolveRepresentativeInput();
9051 return element?.willValidate ? getState(element) : makeState(false);
9052 }
9053 if (revalidate) {
9054 if (state.valid !== false || !element) {
9055 return;
9056 }
9057 if (!element.validity.valueMissing) {
9058 clearCustomValidity();
9059 const currentElement = resolveRepresentativeInput();
9060 const foreign = currentElement?.validity.customError ? getNativeErrors(currentElement) : [];
9061 publish(makeState(foreign.length > 0), foreign, false);
9062 return;
9063 }
9064 for (const key of validityKeys) {
9065 if (key !== "valid" && key !== "valueMissing" && key !== "customError" && element.validity[key]) {
9066 return;
9067 }
9068 }
9069 }
9070 timeout.clear();
9071 clearCustomValidity();
9072 let nextState = refreshState();
9073 let validationErrors = getNativeErrors(element);
9074 const isValidatingOnChange = shouldValidateOnChange();
9075 if (validationErrors.length === 0 || isValidatingOnChange) {
9076 const formValues = Array.from(formRef.current.fields.values()).reduce((acc, field) => {
9077 if (field.name) {
9078 acc[field.name] = field.getValue();
9079 }
9080 return acc;
9081 }, {});
9082 const resultOrPromise = validate(value, formValues);
9083 let result;
9084 if (typeof resultOrPromise === "object" && resultOrPromise !== null && "then" in resultOrPromise) {
9085 if (nextState.valid === false) {
9086 publish(nextState, validationErrors);
9087 } else if (validationMode === "onSubmit" || !validityData.state.customError) {
9088 nextState.valid = null;
9089 publish(nextState, validationErrors);
9090 }
9091 result = await resultOrPromise;
9092 if (validationCommitId !== validationCommitIdRef.current) {
9093 return;
9094 }
9095 nextState = refreshState();
9096 } else {
9097 result = resultOrPromise;
9098 }
9099 validationErrors = result ? [].concat(result).filter(Boolean) : [];
9100 if (validationErrors.length > 0) {
9101 nextState.valid = false;
9102 nextState.customError = true;
9103 if (element?.willValidate) {
9104 setCustomValidity(element, validationErrors.join("\n"));
9105 }
9106 } else {
9107 validationErrors = getNativeErrors(element);
9108 }
9109 }
9110 publish(nextState, validationErrors);
9111 });
9112 const change = useStableCallback((value, cancelPending = false) => {
9113 timeout.clear();
9114 validationCommitIdRef.current += 1;
9115 if (cancelPending) {
9116 return;
9117 }
9118 const validateOnChange = shouldValidateOnChange();
9119 if (validateOnChange && value !== "" && validationDebounceTime) {
9120 timeout.start(validationDebounceTime, () => {
9121 commit(value);
9122 });
9123 } else {
9124 commit(value, !validateOnChange);
9125 }
9126 });
9127 const getValidationProps = React48.useCallback((disabled2, externalProps = {}) => mergeProps(getDescriptionProps(externalProps), state.valid === false && !state.disabled && !disabled2 ? {
9128 "aria-invalid": true
9129 } : EMPTY_OBJECT), [getDescriptionProps, state.disabled, state.valid]);
9130 return React48.useMemo(() => ({
9131 getValidationProps,
9132 inputRef,
9133 registeredInputs,
9134 registerInput,
9135 getInputControl,
9136 commit,
9137 change
9138 }), [getValidationProps, registeredInputs, registerInput, getInputControl, commit, change]);
9139 }
9140
9141 // node_modules/@base-ui/react/collapsible/index.parts.mjs
9142 var index_parts_exports = {};
9143 __export(index_parts_exports, {
9144 Panel: () => CollapsiblePanel,
9145 Root: () => CollapsibleRoot,
9146 Trigger: () => CollapsibleTrigger
9147 });
9148
9149 // node_modules/@base-ui/react/collapsible/root/CollapsibleRoot.mjs
9150 var React49 = __toESM(require_react(), 1);
9151
9152 // node_modules/@base-ui/react/collapsible/root/stateAttributesMapping.mjs
9153 var collapsibleStateAttributesMapping = {
9154 ...collapsibleOpenStateMapping,
9155 ...transitionStatusMapping
9156 };
9157
9158 // node_modules/@base-ui/react/collapsible/root/CollapsibleRoot.mjs
9159 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
9160 var CollapsibleRoot = /* @__PURE__ */ React49.forwardRef(function CollapsibleRoot2(componentProps, forwardedRef) {
9161 const {
9162 render: render4,
9163 className,
9164 defaultOpen = false,
9165 disabled: disabled2 = false,
9166 onOpenChange: onOpenChangeProp,
9167 open: open3,
9168 style,
9169 ...elementProps
9170 } = componentProps;
9171 const onOpenChange = useStableCallback(onOpenChangeProp);
9172 const collapsible = useCollapsibleRoot({
9173 open: open3,
9174 defaultOpen,
9175 onOpenChange,
9176 disabled: disabled2
9177 });
9178 const state = React49.useMemo(() => ({
9179 open: collapsible.open,
9180 disabled: collapsible.disabled,
9181 transitionStatus: collapsible.transitionStatus
9182 }), [collapsible.open, collapsible.disabled, collapsible.transitionStatus]);
9183 const contextValue = React49.useMemo(() => ({
9184 ...collapsible,
9185 onOpenChange,
9186 state
9187 }), [collapsible, onOpenChange, state]);
9188 const element = useRenderElement("div", componentProps, {
9189 state,
9190 ref: forwardedRef,
9191 props: elementProps,
9192 stateAttributesMapping: collapsibleStateAttributesMapping
9193 });
9194 return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CollapsibleRootContext.Provider, {
9195 value: contextValue,
9196 children: element
9197 });
9198 });
9199 if (true) CollapsibleRoot.displayName = "CollapsibleRoot";
9200
9201 // node_modules/@base-ui/react/collapsible/trigger/CollapsibleTrigger.mjs
9202 var React50 = __toESM(require_react(), 1);
9203 var stateAttributesMapping = {
9204 ...triggerOpenStateMapping,
9205 ...transitionStatusMapping
9206 };
9207 var CollapsibleTrigger = /* @__PURE__ */ React50.forwardRef(function CollapsibleTrigger2(componentProps, forwardedRef) {
9208 const {
9209 panelId,
9210 open: open3,
9211 handleTrigger,
9212 state,
9213 disabled: contextDisabled
9214 } = useCollapsibleRootContext();
9215 const {
9216 className,
9217 disabled: disabled2 = contextDisabled,
9218 render: render4,
9219 nativeButton = true,
9220 style,
9221 ...elementProps
9222 } = componentProps;
9223 const {
9224 getButtonProps,
9225 buttonRef
9226 } = useButton({
9227 disabled: disabled2,
9228 focusableWhenDisabled: true,
9229 native: nativeButton
9230 });
9231 const element = useRenderElement("button", componentProps, {
9232 state,
9233 ref: [forwardedRef, buttonRef],
9234 props: [{
9235 "aria-controls": open3 ? panelId : void 0,
9236 "aria-expanded": open3,
9237 onClick: handleTrigger
9238 }, elementProps, getButtonProps],
9239 stateAttributesMapping
9240 });
9241 return element;
9242 });
9243 if (true) CollapsibleTrigger.displayName = "CollapsibleTrigger";
9244
9245 // node_modules/@base-ui/react/collapsible/panel/CollapsiblePanel.mjs
9246 var React51 = __toESM(require_react(), 1);
9247
9248 // node_modules/@base-ui/react/collapsible/panel/CollapsiblePanelCssVars.mjs
9249 var collapsiblePanelHeight = "--collapsible-panel-height";
9250 var collapsiblePanelWidth = "--collapsible-panel-width";
9251
9252 // node_modules/@base-ui/react/collapsible/panel/CollapsiblePanel.mjs
9253 var CollapsiblePanel = /* @__PURE__ */ React51.forwardRef(function CollapsiblePanel2(componentProps, forwardedRef) {
9254 const {
9255 className,
9256 hiddenUntilFound: hiddenUntilFoundProp,
9257 keepMounted: keepMountedProp,
9258 render: render4,
9259 id: idProp,
9260 style,
9261 ...elementProps
9262 } = componentProps;
9263 if (true) {
9264 React51.useEffect(() => {
9265 if (hiddenUntilFoundProp && keepMountedProp === false) {
9266 warn("The `keepMounted={false}` prop on `Collapsible.Panel` is ignored when `hiddenUntilFound` is enabled, since the panel must remain mounted while closed.");
9267 }
9268 }, [hiddenUntilFoundProp, keepMountedProp]);
9269 }
9270 const {
9271 defaultPanelId,
9272 mounted,
9273 onOpenChange,
9274 open: open3,
9275 setMounted,
9276 setPanelIdState,
9277 setOpen,
9278 state,
9279 transitionStatus
9280 } = useCollapsibleRootContext();
9281 const hiddenUntilFound = hiddenUntilFoundProp ?? false;
9282 const keepMounted = keepMountedProp ?? false;
9283 const registeredId = idProp || void 0;
9284 const id = registeredId ?? defaultPanelId;
9285 useIsoLayoutEffect(() => {
9286 setPanelIdState((currentId) => registeredId ?? (currentId === null ? void 0 : currentId));
9287 return () => {
9288 setPanelIdState((currentId) => currentId === registeredId ? null : currentId);
9289 };
9290 }, [registeredId, setPanelIdState]);
9291 const {
9292 height,
9293 props,
9294 ref,
9295 shouldPreventOpenAnimation,
9296 shouldRender,
9297 transitionStatus: panelTransitionStatus,
9298 width
9299 } = useCollapsiblePanel({
9300 externalRef: forwardedRef,
9301 hiddenUntilFound,
9302 id,
9303 keepMounted,
9304 mounted,
9305 onOpenChange,
9306 open: open3,
9307 setMounted,
9308 setOpen,
9309 transitionStatus
9310 });
9311 const panelState = {
9312 ...state,
9313 transitionStatus: panelTransitionStatus
9314 };
9315 const resolvedStyle = resolveStyle(style, panelState);
9316 const element = useRenderElement("div", {
9317 ...componentProps,
9318 style: void 0
9319 }, {
9320 state: panelState,
9321 ref,
9322 props: [
9323 props,
9324 {
9325 style: {
9326 [collapsiblePanelHeight]: height === void 0 ? "auto" : `${height}px`,
9327 [collapsiblePanelWidth]: width === void 0 ? "auto" : `${width}px`
9328 }
9329 },
9330 elementProps,
9331 resolvedStyle ? {
9332 style: resolvedStyle
9333 } : void 0,
9334 // Resolve the public `style` prop so temporary `animationName: 'none'`
9335 // can still win after user's inline styles have been merged.
9336 shouldPreventOpenAnimation ? {
9337 style: {
9338 animationName: "none"
9339 }
9340 } : void 0
9341 ],
9342 stateAttributesMapping: collapsibleStateAttributesMapping
9343 });
9344 if (!shouldRender) {
9345 return null;
9346 }
9347 return element;
9348 });
9349 if (true) CollapsiblePanel.displayName = "CollapsiblePanel";
9350
9351 // node_modules/@base-ui/react/utils/useRegisteredLabelId.mjs
9352 function useRegisteredLabelId(idProp, setLabelId) {
9353 const id = useBaseUiId(idProp);
9354 useIsoLayoutEffect(() => {
9355 setLabelId(id);
9356 return () => {
9357 setLabelId((currentId) => currentId === id ? void 0 : currentId);
9358 };
9359 }, [id, setLabelId]);
9360 return id;
9361 }
9362
9363 // node_modules/@base-ui/react/internals/labelable-provider/useLabel.mjs
9364 function useLabel(params = {}) {
9365 const {
9366 id: idProp,
9367 fallbackControlId,
9368 native = false,
9369 setLabelId: setLabelIdProp,
9370 focusControl: focusControlProp
9371 } = params;
9372 const {
9373 controlId: contextControlId,
9374 setLabelId: setContextLabelId
9375 } = useLabelableContext();
9376 const syncLabelId = useStableCallback((nextLabelId) => {
9377 setContextLabelId(nextLabelId);
9378 setLabelIdProp?.(nextLabelId);
9379 });
9380 const id = useRegisteredLabelId(idProp, syncLabelId);
9381 const resolvedControlId = contextControlId ?? fallbackControlId;
9382 function focusControl(event) {
9383 if (focusControlProp) {
9384 focusControlProp(event, resolvedControlId);
9385 return;
9386 }
9387 if (!resolvedControlId) {
9388 return;
9389 }
9390 const controlElement = ownerDocument(event.currentTarget).getElementById(resolvedControlId);
9391 if (isHTMLElement(controlElement)) {
9392 focusElementWithVisible(controlElement);
9393 }
9394 }
9395 function handleInteraction(event) {
9396 const target = getTarget(event.nativeEvent);
9397 if (target?.closest("button,input,select,textarea")) {
9398 return;
9399 }
9400 if (!event.defaultPrevented && event.detail > 1) {
9401 event.preventDefault();
9402 }
9403 if (native) {
9404 return;
9405 }
9406 focusControl(event);
9407 }
9408 return native ? {
9409 id,
9410 htmlFor: resolvedControlId,
9411 onMouseDown: handleInteraction
9412 } : {
9413 id,
9414 onClick: handleInteraction,
9415 onPointerDown(event) {
9416 event.preventDefault();
9417 }
9418 };
9419 }
9420 function focusElementWithVisible(element) {
9421 element.focus({
9422 // Available from Chrome 144+ (January 2026).
9423 // Safari and Firefox already support it.
9424 focusVisible: true
9425 });
9426 }
9427
9428 // node_modules/@base-ui/react/internals/composite/item/useCompositeItem.mjs
9429 var React52 = __toESM(require_react(), 1);
9430 function useCompositeItem(params = {}) {
9431 const {
9432 highlightItemOnHover,
9433 highlightedIndex,
9434 onHighlightedIndexChange
9435 } = useCompositeRootContext();
9436 const {
9437 ref,
9438 index: index3
9439 } = useCompositeListItem(params);
9440 const isHighlighted = highlightedIndex === index3;
9441 const itemRef = React52.useRef(null);
9442 const mergedRef = useMergedRefs(ref, itemRef);
9443 const compositeProps = {
9444 tabIndex: isHighlighted ? 0 : -1,
9445 onFocus() {
9446 onHighlightedIndexChange(index3);
9447 },
9448 onMouseMove() {
9449 const item = itemRef.current;
9450 if (!highlightItemOnHover || !item) {
9451 return;
9452 }
9453 const disabled2 = item.hasAttribute("disabled") || item.ariaDisabled === "true";
9454 if (!isHighlighted && !disabled2) {
9455 item.focus();
9456 }
9457 }
9458 };
9459 return {
9460 compositeProps,
9461 compositeRef: mergedRef,
9462 index: index3
9463 };
9464 }
9465
9466 // node_modules/@base-ui/react/utils/usePopupViewport.mjs
9467 var React56 = __toESM(require_react(), 1);
9468 var ReactDOM6 = __toESM(require_react_dom(), 1);
9469
9470 // node_modules/@base-ui/utils/usePreviousValue.mjs
9471 var React53 = __toESM(require_react(), 1);
9472 function usePreviousValue(value) {
9473 const [state, setState] = React53.useState({
9474 current: value,
9475 previous: null
9476 });
9477 if (!Object.is(value, state.current)) {
9478 setState({
9479 current: value,
9480 previous: state.current
9481 });
9482 }
9483 return state.previous;
9484 }
9485
9486 // node_modules/@base-ui/react/utils/usePopupAutoResize.mjs
9487 var React54 = __toESM(require_react(), 1);
9488
9489 // node_modules/@base-ui/react/utils/getCssDimensions.mjs
9490 function getCssDimensions2(element) {
9491 const css = getComputedStyle2(element);
9492 let width = parseFloat(css.width) || 0;
9493 let height = parseFloat(css.height) || 0;
9494 const hasOffset = isHTMLElement(element);
9495 const offsetWidth = hasOffset ? element.offsetWidth : width;
9496 const offsetHeight = hasOffset ? element.offsetHeight : height;
9497 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
9498 if (shouldFallback) {
9499 width = offsetWidth;
9500 height = offsetHeight;
9501 }
9502 return {
9503 width,
9504 height
9505 };
9506 }
9507
9508 // node_modules/@base-ui/react/utils/CommonPopupCssVars.mjs
9509 var popupWidth = "--popup-width";
9510 var popupHeight = "--popup-height";
9511
9512 // node_modules/@base-ui/react/utils/usePopupAutoResize.mjs
9513 function usePopupAutoResize(parameters) {
9514 const {
9515 popupElement,
9516 positionerElement,
9517 content,
9518 mounted,
9519 onMeasureLayout: onMeasureLayoutParam,
9520 onMeasureLayoutComplete: onMeasureLayoutCompleteParam,
9521 side,
9522 direction
9523 } = parameters;
9524 const runOnceAnimationsFinish = useAnimationsFinished(popupElement, true);
9525 const animationFrame = useAnimationFrame();
9526 const committedDimensionsRef = React54.useRef(null);
9527 const isInitialRenderRef = React54.useRef(true);
9528 const restoreAnchoringStylesRef = React54.useRef(NOOP);
9529 const onMeasureLayout = useStableCallback(onMeasureLayoutParam);
9530 const onMeasureLayoutComplete = useStableCallback(onMeasureLayoutCompleteParam);
9531 const anchoringStyles = React54.useMemo(() => getPopupAnchoringStyles(side, direction), [side, direction]);
9532 useIsoLayoutEffect(() => {
9533 if (!mounted) {
9534 restoreAnchoringStylesRef.current = NOOP;
9535 isInitialRenderRef.current = true;
9536 committedDimensionsRef.current = null;
9537 return void 0;
9538 }
9539 if (!popupElement || !positionerElement) {
9540 return void 0;
9541 }
9542 restoreAnchoringStylesRef.current = applyElementStyles(popupElement, anchoringStyles);
9543 setPopupCssSize(popupElement, "auto");
9544 const restorePopupPosition = overrideElementStyle(popupElement, "position", "static");
9545 const restorePopupTransform = overrideElementStyle(popupElement, "transform", "none");
9546 const restorePopupScale = overrideElementStyle(popupElement, "scale", "1");
9547 const restorePositionerAvailableSize = applyElementStyles(positionerElement, {
9548 [availableWidth]: "max-content",
9549 [availableHeight]: "max-content"
9550 });
9551 function restoreMeasurementOverrides() {
9552 restorePopupPosition();
9553 restorePopupTransform();
9554 restorePositionerAvailableSize();
9555 }
9556 function restoreMeasurementOverridesIncludingScale() {
9557 restoreMeasurementOverrides();
9558 restorePopupScale();
9559 }
9560 onMeasureLayout?.();
9561 if (isInitialRenderRef.current || committedDimensionsRef.current === null) {
9562 setPositionerCssSize(positionerElement, "max-content");
9563 const dimensions = getCssDimensions2(popupElement);
9564 committedDimensionsRef.current = dimensions;
9565 setPositionerCssSize(positionerElement, dimensions);
9566 restoreMeasurementOverridesIncludingScale();
9567 onMeasureLayoutComplete?.(null, dimensions);
9568 isInitialRenderRef.current = false;
9569 return () => {
9570 restoreAnchoringStylesRef.current();
9571 restoreAnchoringStylesRef.current = NOOP;
9572 };
9573 }
9574 setPositionerCssSize(positionerElement, "max-content");
9575 const previousDimensions = committedDimensionsRef.current;
9576 const newDimensions = getCssDimensions2(popupElement);
9577 committedDimensionsRef.current = newDimensions;
9578 setPopupCssSize(popupElement, previousDimensions);
9579 restoreMeasurementOverridesIncludingScale();
9580 onMeasureLayoutComplete?.(previousDimensions, newDimensions);
9581 setPositionerCssSize(positionerElement, newDimensions);
9582 const abortController = new AbortController();
9583 animationFrame.request(() => {
9584 setPopupCssSize(popupElement, newDimensions);
9585 runOnceAnimationsFinish(() => {
9586 popupElement.style.setProperty(popupWidth, "auto");
9587 popupElement.style.setProperty(popupHeight, "auto");
9588 }, abortController.signal);
9589 });
9590 return () => {
9591 abortController.abort();
9592 animationFrame.cancel();
9593 restoreAnchoringStylesRef.current();
9594 restoreAnchoringStylesRef.current = NOOP;
9595 };
9596 }, [content, popupElement, positionerElement, runOnceAnimationsFinish, animationFrame, mounted, onMeasureLayout, onMeasureLayoutComplete, anchoringStyles]);
9597 }
9598 function getPopupAnchoringStyles(side, direction) {
9599 const isPhysicalTop = side === "top";
9600 const isPhysicalLeft = side === "left" || side === (direction === "rtl" ? "inline-end" : "inline-start");
9601 if (!isPhysicalTop && !isPhysicalLeft) {
9602 return EMPTY_OBJECT;
9603 }
9604 return {
9605 position: "absolute",
9606 [isPhysicalTop ? "bottom" : "top"]: "0",
9607 [isPhysicalLeft ? "right" : "left"]: "0"
9608 };
9609 }
9610 function overrideElementStyle(element, property, value) {
9611 const originalValue = element.style.getPropertyValue(property);
9612 element.style.setProperty(property, value);
9613 return () => {
9614 element.style.setProperty(property, originalValue);
9615 };
9616 }
9617 function applyElementStyles(element, styles) {
9618 const restorers = [];
9619 for (const [key, value] of Object.entries(styles)) {
9620 restorers.push(overrideElementStyle(element, key, value));
9621 }
9622 return restorers.length ? () => {
9623 restorers.forEach((restore) => restore());
9624 } : NOOP;
9625 }
9626 function setPopupCssSize(popupElement, size4) {
9627 const width = size4 === "auto" ? "auto" : `${size4.width}px`;
9628 const height = size4 === "auto" ? "auto" : `${size4.height}px`;
9629 popupElement.style.setProperty(popupWidth, width);
9630 popupElement.style.setProperty(popupHeight, height);
9631 }
9632 function setPositionerCssSize(positionerElement, size4) {
9633 const width = size4 === "max-content" ? "max-content" : `${size4.width}px`;
9634 const height = size4 === "max-content" ? "max-content" : `${size4.height}px`;
9635 positionerElement.style.setProperty(positionerWidth, width);
9636 positionerElement.style.setProperty(positionerHeight, height);
9637 }
9638
9639 // node_modules/@base-ui/react/direction-provider/DirectionProvider.mjs
9640 var React55 = __toESM(require_react(), 1);
9641 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
9642 var DirectionProvider = function DirectionProvider2(props) {
9643 const {
9644 direction = "ltr"
9645 } = props;
9646 const contextValue = React55.useMemo(() => ({
9647 direction
9648 }), [direction]);
9649 return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DirectionContext.Provider, {
9650 value: contextValue,
9651 children: props.children
9652 });
9653 };
9654 if (true) DirectionProvider.displayName = "DirectionProvider";
9655
9656 // node_modules/@base-ui/react/utils/adaptiveOriginMiddleware.mjs
9657 var adaptiveOrigin = {
9658 name: "adaptiveOrigin",
9659 async fn(state) {
9660 const {
9661 x: rawX,
9662 y: rawY,
9663 rects: {
9664 floating: floatRect
9665 },
9666 elements: {
9667 floating
9668 },
9669 platform: platform3,
9670 strategy,
9671 placement
9672 } = state;
9673 const win = getWindow(floating);
9674 const styles = win.getComputedStyle(floating);
9675 const hasTransition = styles.transitionDuration !== "0s" && styles.transitionDuration !== "";
9676 if (!hasTransition) {
9677 return {
9678 x: rawX,
9679 y: rawY,
9680 data: DEFAULT_SIDES
9681 };
9682 }
9683 const offsetParent = await platform3.getOffsetParent?.(floating);
9684 let offsetDimensions = {
9685 width: 0,
9686 height: 0
9687 };
9688 if (strategy === "fixed" && win?.visualViewport) {
9689 offsetDimensions = {
9690 width: win.visualViewport.width,
9691 height: win.visualViewport.height
9692 };
9693 } else if (offsetParent === win) {
9694 const doc = ownerDocument(floating);
9695 offsetDimensions = {
9696 width: doc.documentElement.clientWidth,
9697 height: doc.documentElement.clientHeight
9698 };
9699 } else if (await platform3.isElement?.(offsetParent)) {
9700 offsetDimensions = await platform3.getDimensions(offsetParent);
9701 }
9702 const currentSide = getSide(placement);
9703 let x2 = rawX;
9704 let y2 = rawY;
9705 if (currentSide === "left") {
9706 x2 = offsetDimensions.width - (rawX + floatRect.width);
9707 }
9708 if (currentSide === "top") {
9709 y2 = offsetDimensions.height - (rawY + floatRect.height);
9710 }
9711 const sideX = currentSide === "left" ? "right" : DEFAULT_SIDES.sideX;
9712 const sideY = currentSide === "top" ? "bottom" : DEFAULT_SIDES.sideY;
9713 return {
9714 x: x2,
9715 y: y2,
9716 data: {
9717 sideX,
9718 sideY
9719 }
9720 };
9721 }
9722 };
9723
9724 // node_modules/@base-ui/react/utils/CommonViewportDataAttributes.mjs
9725 var activationDirection = "data-activation-direction";
9726
9727 // node_modules/@base-ui/react/utils/usePopupViewport.mjs
9728 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
9729 var popupViewportStateMapping = {
9730 activationDirection: (value) => value ? {
9731 [activationDirection]: value
9732 } : null
9733 };
9734 function usePopupViewport(parameters) {
9735 const {
9736 store: store2,
9737 side,
9738 children
9739 } = parameters;
9740 const direction = useDirection();
9741 const activeTrigger = store2.useState("activeTriggerElement");
9742 const activeTriggerId = store2.useState("activeTriggerId");
9743 const open3 = store2.useState("open");
9744 const payload = store2.useState("payload");
9745 const mounted = store2.useState("mounted");
9746 const popupElement = store2.useState("popupElement");
9747 const positionerElement = store2.useState("positionerElement");
9748 const previousActiveTrigger = usePreviousValue(open3 ? activeTrigger : null);
9749 const currentContentKey = usePopupContentKey(activeTriggerId, payload);
9750 const capturedNodeRef = React56.useRef(null);
9751 const [previousContentNode, setPreviousContentNode] = React56.useState(null);
9752 const [newTriggerOffset, setNewTriggerOffset] = React56.useState(null);
9753 const currentContainerRef = React56.useRef(null);
9754 const previousContainerRef = React56.useRef(null);
9755 const onAnimationsFinished = useAnimationsFinished(currentContainerRef, true);
9756 const cleanupFrame = useAnimationFrame();
9757 const cleanupControllerRef = React56.useRef(null);
9758 const [previousContentDimensions, setPreviousContentDimensions] = React56.useState(null);
9759 const [showStartingStyleAttribute, setShowStartingStyleAttribute] = React56.useState(false);
9760 useIsoLayoutEffect(() => {
9761 store2.set("adaptiveOrigin", adaptiveOrigin);
9762 return () => {
9763 store2.set("adaptiveOrigin", void 0);
9764 };
9765 }, [store2]);
9766 const handleMeasureLayout = useStableCallback(() => {
9767 currentContainerRef.current?.style.setProperty("animation", "none");
9768 currentContainerRef.current?.style.setProperty("transition", "none");
9769 previousContainerRef.current?.style.setProperty("display", "none");
9770 });
9771 const handleMeasureLayoutComplete = useStableCallback((previousDimensions) => {
9772 currentContainerRef.current?.style.removeProperty("animation");
9773 currentContainerRef.current?.style.removeProperty("transition");
9774 previousContainerRef.current?.style.removeProperty("display");
9775 if (previousDimensions) {
9776 setPreviousContentDimensions(previousDimensions);
9777 }
9778 });
9779 const armViewportCleanup = useStableCallback(() => {
9780 cleanupControllerRef.current?.abort();
9781 const controller = new AbortController();
9782 cleanupControllerRef.current = controller;
9783 onAnimationsFinished(() => {
9784 setPreviousContentNode(null);
9785 setPreviousContentDimensions(null);
9786 capturedNodeRef.current = null;
9787 }, controller.signal);
9788 });
9789 const lastHandledTriggerRef = React56.useRef(null);
9790 useIsoLayoutEffect(() => {
9791 if (!open3 || !mounted) {
9792 lastHandledTriggerRef.current = null;
9793 }
9794 }, [open3, mounted]);
9795 useIsoLayoutEffect(() => {
9796 if (activeTrigger && previousActiveTrigger && activeTrigger !== previousActiveTrigger && lastHandledTriggerRef.current !== activeTrigger && capturedNodeRef.current) {
9797 setPreviousContentNode(capturedNodeRef.current);
9798 setShowStartingStyleAttribute(true);
9799 const offset4 = calculateRelativePosition(previousActiveTrigger, activeTrigger);
9800 setNewTriggerOffset(offset4);
9801 lastHandledTriggerRef.current = activeTrigger;
9802 }
9803 }, [activeTrigger, previousActiveTrigger]);
9804 useIsoLayoutEffect(() => {
9805 if (previousContentNode == null) {
9806 return;
9807 }
9808 cleanupControllerRef.current?.abort();
9809 setShowStartingStyleAttribute(true);
9810 cleanupFrame.request(() => {
9811 ReactDOM6.flushSync(() => {
9812 setShowStartingStyleAttribute(false);
9813 });
9814 armViewportCleanup();
9815 });
9816 }, [currentContentKey, previousContentNode, armViewportCleanup, cleanupFrame]);
9817 useIsoLayoutEffect(() => {
9818 const source = currentContainerRef.current;
9819 if (!source) {
9820 return;
9821 }
9822 const wrapper = ownerDocument(source).createElement("div");
9823 for (const child of Array.from(source.childNodes)) {
9824 wrapper.appendChild(child.cloneNode(true));
9825 }
9826 capturedNodeRef.current = wrapper;
9827 });
9828 const isTransitioning = previousContentNode != null;
9829 let childrenToRender;
9830 if (!isTransitioning) {
9831 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", {
9832 "data-current": true,
9833 ref: currentContainerRef,
9834 children
9835 }, currentContentKey);
9836 } else {
9837 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(React56.Fragment, {
9838 children: [/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", {
9839 "data-previous": true,
9840 inert: inertValue(true),
9841 ref: previousContainerRef,
9842 style: {
9843 ...previousContentDimensions ? {
9844 [popupWidth]: `${previousContentDimensions.width}px`,
9845 [popupHeight]: `${previousContentDimensions.height}px`
9846 } : null,
9847 position: "absolute"
9848 },
9849 "data-ending-style": showStartingStyleAttribute ? void 0 : ""
9850 }, "previous"), /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", {
9851 "data-current": true,
9852 ref: currentContainerRef,
9853 "data-starting-style": showStartingStyleAttribute ? "" : void 0,
9854 children
9855 }, currentContentKey)]
9856 });
9857 }
9858 useIsoLayoutEffect(() => {
9859 const container = previousContainerRef.current;
9860 if (!container || !previousContentNode) {
9861 return;
9862 }
9863 container.replaceChildren(...Array.from(previousContentNode.childNodes));
9864 }, [previousContentNode]);
9865 usePopupAutoResize({
9866 popupElement,
9867 positionerElement,
9868 mounted,
9869 content: payload,
9870 onMeasureLayout: handleMeasureLayout,
9871 onMeasureLayoutComplete: handleMeasureLayoutComplete,
9872 side,
9873 direction
9874 });
9875 const state = {
9876 activationDirection: getActivationDirection(newTriggerOffset),
9877 transitioning: isTransitioning
9878 };
9879 return {
9880 children: childrenToRender,
9881 state
9882 };
9883 }
9884 function getActivationDirection(offset4) {
9885 if (!offset4) {
9886 return void 0;
9887 }
9888 return `${getValueWithTolerance(offset4.horizontal, 5, "right", "left")} ${getValueWithTolerance(offset4.vertical, 5, "down", "up")}`;
9889 }
9890 function getValueWithTolerance(value, tolerance, positiveLabel, negativeLabel) {
9891 if (value > tolerance) {
9892 return positiveLabel;
9893 }
9894 if (value < -tolerance) {
9895 return negativeLabel;
9896 }
9897 return "";
9898 }
9899 function calculateRelativePosition(from, to) {
9900 const fromRect = from.getBoundingClientRect();
9901 const toRect = to.getBoundingClientRect();
9902 const fromCenter = {
9903 x: fromRect.left + fromRect.width / 2,
9904 y: fromRect.top + fromRect.height / 2
9905 };
9906 const toCenter = {
9907 x: toRect.left + toRect.width / 2,
9908 y: toRect.top + toRect.height / 2
9909 };
9910 return {
9911 horizontal: toCenter.x - fromCenter.x,
9912 vertical: toCenter.y - fromCenter.y
9913 };
9914 }
9915 function usePopupContentKey(activeTriggerId, payload) {
9916 const [contentKey, setContentKey] = React56.useState(0);
9917 const previousActiveTriggerIdRef = React56.useRef(activeTriggerId);
9918 const previousPayloadRef = React56.useRef(payload);
9919 const pendingPayloadUpdateRef = React56.useRef(false);
9920 useIsoLayoutEffect(() => {
9921 const previousActiveTriggerId = previousActiveTriggerIdRef.current;
9922 const previousPayload = previousPayloadRef.current;
9923 const triggerIdChanged = activeTriggerId !== previousActiveTriggerId;
9924 const payloadChanged = payload !== previousPayload;
9925 if (triggerIdChanged) {
9926 setContentKey((value) => value + 1);
9927 pendingPayloadUpdateRef.current = !payloadChanged;
9928 } else if (pendingPayloadUpdateRef.current && payloadChanged) {
9929 setContentKey((value) => value + 1);
9930 pendingPayloadUpdateRef.current = false;
9931 }
9932 previousActiveTriggerIdRef.current = activeTriggerId;
9933 previousPayloadRef.current = payload;
9934 }, [activeTriggerId, payload]);
9935 return `${activeTriggerId ?? "current"}-${contentKey}`;
9936 }
9937
9938 // node_modules/@base-ui/utils/isElementDisabled.mjs
9939 function isElementDisabled(element) {
9940 return element == null || element.hasAttribute("disabled") || element.getAttribute("aria-disabled") === "true";
9941 }
9942
9943 // node_modules/@base-ui/react/internals/csp-context/CSPContext.mjs
9944 var React57 = __toESM(require_react(), 1);
9945 var CSPContext = /* @__PURE__ */ React57.createContext(void 0);
9946 if (true) CSPContext.displayName = "CSPContext";
9947 var DEFAULT_CSP_CONTEXT_VALUE = {
9948 disableStyleElements: false
9949 };
9950 function useCSPContext() {
9951 return React57.useContext(CSPContext) ?? DEFAULT_CSP_CONTEXT_VALUE;
9952 }
9953
9954 // node_modules/@base-ui/react/utils/getElementTransform.mjs
9955 function getElementTransform(element, computedStyle) {
9956 const transform = (computedStyle ?? getWindow(element).getComputedStyle(element)).transform;
9957 let translateX = 0;
9958 let translateY = 0;
9959 let scale3 = 1;
9960 if (transform && transform !== "none") {
9961 const matrix = transform.match(/matrix(?:3d)?\(([^)]+)\)/);
9962 if (matrix) {
9963 const values = matrix[1].split(", ").map(parseFloat);
9964 if (values.length === 6) {
9965 translateX = values[4];
9966 translateY = values[5];
9967 scale3 = Math.sqrt(values[0] * values[0] + values[1] * values[1]);
9968 } else if (values.length === 16) {
9969 translateX = values[12];
9970 translateY = values[13];
9971 scale3 = values[0];
9972 }
9973 }
9974 }
9975 return {
9976 x: translateX,
9977 y: translateY,
9978 scale: scale3
9979 };
9980 }
9981
9982 // node_modules/@base-ui/react/field/index.parts.mjs
9983 var index_parts_exports2 = {};
9984 __export(index_parts_exports2, {
9985 Control: () => FieldControl,
9986 Description: () => FieldDescription,
9987 Error: () => FieldError,
9988 Item: () => FieldItem,
9989 Label: () => FieldLabel,
9990 Root: () => FieldRoot,
9991 Validity: () => FieldValidity
9992 });
9993
9994 // node_modules/@base-ui/react/field/root/FieldRoot.mjs
9995 var React61 = __toESM(require_react(), 1);
9996
9997 // node_modules/@base-ui/react/fieldset/root/FieldsetRootContext.mjs
9998 var React58 = __toESM(require_react(), 1);
9999 var FieldsetRootContext = /* @__PURE__ */ React58.createContext(void 0);
10000 if (true) FieldsetRootContext.displayName = "FieldsetRootContext";
10001 function useFieldsetRootContext(optional = false) {
10002 const context = React58.useContext(FieldsetRootContext);
10003 if (!context && !optional) {
10004 throw new Error(true ? "Base UI: FieldsetRootContext is missing. Fieldset parts must be placed within <Fieldset.Root>." : formatErrorMessage_default(86));
10005 }
10006 return context;
10007 }
10008
10009 // node_modules/@base-ui/react/internals/labelable-provider/LabelableProvider.mjs
10010 var React59 = __toESM(require_react(), 1);
10011 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
10012 var LabelableProvider = function LabelableProvider2(props) {
10013 const defaultId = useBaseUiId();
10014 const [controlIdState, setControlIdState] = React59.useState(defaultId);
10015 const [labelId, setLabelId] = React59.useState();
10016 const [messageIds, setMessageIds] = React59.useState([]);
10017 const controlId = controlIdState === void 0 ? defaultId : controlIdState;
10018 const registrationsRef = useRefWithInit(() => /* @__PURE__ */ new Map());
10019 const {
10020 messageIds: parentMessageIds
10021 } = useLabelableContext();
10022 const registerControlId = useStableCallback((source, nextId) => {
10023 const registrations = registrationsRef.current;
10024 if (nextId === void 0) {
10025 registrations.delete(source);
10026 } else {
10027 registrations.set(source, nextId);
10028 }
10029 setControlIdState((prev) => {
10030 if (registrations.size === 0) {
10031 return prev;
10032 }
10033 let nextControlId;
10034 for (const id of registrations.values()) {
10035 if (id === prev) {
10036 return prev;
10037 }
10038 if (nextControlId === void 0) {
10039 nextControlId = id;
10040 }
10041 }
10042 return nextControlId;
10043 });
10044 });
10045 const resetControlId = useStableCallback(() => {
10046 if (registrationsRef.current.size === 0) {
10047 setControlIdState(defaultId);
10048 }
10049 });
10050 const getDescriptionProps = React59.useCallback((externalProps) => {
10051 const ids = externalProps["aria-describedby"] ? externalProps["aria-describedby"].split(" ") : [];
10052 ids.push(...parentMessageIds, ...messageIds);
10053 return {
10054 ...externalProps,
10055 "aria-describedby": Array.from(new Set(ids)).join(" ") || void 0
10056 };
10057 }, [parentMessageIds, messageIds]);
10058 const contextValue = React59.useMemo(() => ({
10059 controlId,
10060 registerControlId,
10061 resetControlId,
10062 labelId,
10063 setLabelId,
10064 messageIds,
10065 setMessageIds,
10066 getDescriptionProps
10067 }), [controlId, registerControlId, resetControlId, labelId, setLabelId, messageIds, setMessageIds, getDescriptionProps]);
10068 return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(LabelableContext.Provider, {
10069 value: contextValue,
10070 children: props.children
10071 });
10072 };
10073 if (true) LabelableProvider.displayName = "LabelableProvider";
10074
10075 // node_modules/@base-ui/react/internals/field-register-control/useFieldControlRegistration.mjs
10076 var React60 = __toESM(require_react(), 1);
10077 function useFieldControlRegistration(params) {
10078 const {
10079 change,
10080 commit,
10081 invalid: invalid2,
10082 markedDirtyRef,
10083 name,
10084 setRegisteredFieldName,
10085 registeredFieldIdRef,
10086 setValidityData,
10087 validityData
10088 } = params;
10089 const {
10090 formRef
10091 } = useFormContext();
10092 const activeFieldControlSourceRef = React60.useRef(null);
10093 const registrationRef = React60.useRef(null);
10094 const initialValueCapturedRef = React60.useRef(false);
10095 const getValueForForm = useStableCallback(() => {
10096 const registration = registrationRef.current;
10097 if (!registration) {
10098 return void 0;
10099 }
10100 if (registration.getValue) {
10101 return registration.getValue();
10102 }
10103 return registration.value;
10104 });
10105 function getRegistrationValue(registration) {
10106 return registration.value === void 0 ? getValueForForm() : registration.value;
10107 }
10108 const validate = useStableCallback(() => {
10109 const registration = registrationRef.current;
10110 markedDirtyRef.current = true;
10111 if (!registration) {
10112 commit(validityData.value);
10113 return;
10114 }
10115 commit(getRegistrationValue(registration));
10116 });
10117 function refreshRegistration() {
10118 const registration = registrationRef.current;
10119 if (!registration || !registration.id) {
10120 return;
10121 }
10122 formRef.current.fields.set(registration.id, {
10123 getValue: getValueForForm,
10124 name: name ?? registration.name,
10125 controlRef: registration.controlRef,
10126 validityData: getCombinedFieldValidityData(validityData, invalid2),
10127 validate
10128 });
10129 }
10130 function deleteRegistration(id = registrationRef.current?.id) {
10131 if (id) {
10132 formRef.current.fields.delete(id);
10133 }
10134 }
10135 function captureInitialValue(registration) {
10136 if (initialValueCapturedRef.current) {
10137 return;
10138 }
10139 initialValueCapturedRef.current = true;
10140 const initialValue = getRegistrationValue(registration);
10141 setValidityData((prev) => prev.initialValue === initialValue ? prev : {
10142 ...prev,
10143 initialValue
10144 });
10145 }
10146 useIsoLayoutEffect(() => {
10147 const registration = registrationRef.current;
10148 if (!registration || !registration.id) {
10149 return;
10150 }
10151 setRegisteredFieldName(name ? void 0 : registration.name);
10152 formRef.current.fields.set(registration.id, {
10153 getValue: getValueForForm,
10154 name: name ?? registration.name,
10155 controlRef: registration.controlRef,
10156 validityData: getCombinedFieldValidityData(validityData, invalid2),
10157 validate
10158 });
10159 }, [formRef, getValueForForm, invalid2, name, setRegisteredFieldName, validate, validityData]);
10160 useIsoLayoutEffect(() => {
10161 const fields = formRef.current.fields;
10162 return () => {
10163 const id = registrationRef.current?.id;
10164 if (id) {
10165 fields.delete(id);
10166 }
10167 };
10168 }, [formRef]);
10169 const register3 = useStableCallback((source, registration) => {
10170 if (!registration) {
10171 if (activeFieldControlSourceRef.current === source) {
10172 activeFieldControlSourceRef.current = null;
10173 change(void 0, true);
10174 deleteRegistration();
10175 registrationRef.current = null;
10176 setRegisteredFieldName(void 0);
10177 registeredFieldIdRef.current = void 0;
10178 }
10179 return;
10180 }
10181 const previousId = registrationRef.current?.id;
10182 const previousSource = activeFieldControlSourceRef.current;
10183 if (previousSource && previousSource !== source) {
10184 change(void 0, true);
10185 }
10186 activeFieldControlSourceRef.current = source;
10187 registrationRef.current = registration;
10188 if (!name) {
10189 setRegisteredFieldName(registration.name);
10190 }
10191 registeredFieldIdRef.current = registration.id;
10192 if (previousId && previousId !== registration.id) {
10193 deleteRegistration(previousId);
10194 }
10195 captureInitialValue(registration);
10196 refreshRegistration();
10197 });
10198 return [validate, register3];
10199 }
10200
10201 // node_modules/@base-ui/react/field/root/FieldRoot.mjs
10202 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
10203 var FieldRootInner = /* @__PURE__ */ React61.forwardRef(function FieldRootInner2(componentProps, forwardedRef) {
10204 const {
10205 errors,
10206 validationMode: formValidationMode,
10207 submitCountRef
10208 } = useFormContext();
10209 const {
10210 render: render4,
10211 className,
10212 validate: validateProp,
10213 validationDebounceTime = 0,
10214 validationMode = formValidationMode,
10215 name,
10216 disabled: disabledProp = false,
10217 invalid: invalidProp,
10218 dirty: dirtyProp,
10219 touched: touchedProp,
10220 actionsRef,
10221 style,
10222 ...elementProps
10223 } = componentProps;
10224 const disabledFieldset = useFieldsetRootContext(true)?.disabled;
10225 const validate = useStableCallback(validateProp || (() => null));
10226 const disabled2 = disabledFieldset || disabledProp;
10227 const [touchedState, setTouchedUnwrapped] = React61.useState(false);
10228 const [dirtyState, setDirtyUnwrapped] = React61.useState(false);
10229 const [filled, setFilled] = React61.useState(false);
10230 const [focused, setFocused] = React61.useState(false);
10231 const dirty = dirtyProp ?? dirtyState;
10232 const touched = touchedProp ?? touchedState;
10233 const markedDirtyRef = React61.useRef(dirty);
10234 const registeredFieldIdRef = React61.useRef(void 0);
10235 const [registeredFieldName, setRegisteredFieldName] = React61.useState();
10236 const effectiveName = name ?? registeredFieldName;
10237 useIsoLayoutEffect(() => {
10238 if (dirtyProp !== void 0) {
10239 markedDirtyRef.current = dirtyProp;
10240 }
10241 }, [dirtyProp]);
10242 const setDirty = useStableCallback((value) => {
10243 if (dirtyProp !== void 0) {
10244 return;
10245 }
10246 if (value) {
10247 markedDirtyRef.current = true;
10248 }
10249 setDirtyUnwrapped(value);
10250 });
10251 const setTouched = useStableCallback((value) => {
10252 if (touchedProp !== void 0) {
10253 return;
10254 }
10255 setTouchedUnwrapped(value);
10256 });
10257 const shouldValidateOnChange = useStableCallback(() => validationMode === "onChange" || validationMode === "onSubmit" && submitCountRef.current > 0);
10258 const formError = effectiveName && Object.hasOwn(errors, effectiveName) ? errors[effectiveName] : null;
10259 const hasFormError = !!(Array.isArray(formError) ? formError.length : formError);
10260 const invalid2 = invalidProp === true || hasFormError;
10261 const [validityData, setValidityData] = React61.useState({
10262 state: DEFAULT_VALIDITY_STATE,
10263 error: "",
10264 errors: [],
10265 value: null,
10266 initialValue: null
10267 });
10268 const valid2 = !invalid2 && (disabled2 ? null : validityData.state.valid);
10269 const state = React61.useMemo(() => ({
10270 disabled: disabled2,
10271 touched,
10272 dirty,
10273 valid: valid2,
10274 filled,
10275 focused
10276 }), [disabled2, touched, dirty, valid2, filled, focused]);
10277 const validation = useFieldValidation({
10278 setValidityData,
10279 validate,
10280 validityData,
10281 validationDebounceTime,
10282 invalid: invalid2,
10283 markedDirtyRef,
10284 state,
10285 shouldValidateOnChange,
10286 validationMode,
10287 registeredFieldIdRef
10288 });
10289 const [validateFieldControl, registerFieldControl] = useFieldControlRegistration({
10290 change: validation.change,
10291 commit: validation.commit,
10292 invalid: invalid2,
10293 markedDirtyRef,
10294 name,
10295 setRegisteredFieldName,
10296 registeredFieldIdRef,
10297 setValidityData,
10298 validityData
10299 });
10300 React61.useImperativeHandle(actionsRef, () => ({
10301 validate: validateFieldControl
10302 }), [validateFieldControl]);
10303 const contextValue = React61.useMemo(() => ({
10304 invalid: invalid2,
10305 name: effectiveName,
10306 validityData,
10307 setValidityData,
10308 disabled: disabled2,
10309 setTouched,
10310 setDirty,
10311 setFilled,
10312 setFocused,
10313 validationMode,
10314 shouldValidateOnChange,
10315 state,
10316 registerFieldControl,
10317 validation
10318 }), [invalid2, effectiveName, validityData, disabled2, setTouched, setDirty, setFilled, setFocused, validationMode, shouldValidateOnChange, state, registerFieldControl, validation]);
10319 const element = useRenderElement("div", componentProps, {
10320 ref: forwardedRef,
10321 state,
10322 props: elementProps,
10323 stateAttributesMapping: fieldValidityMapping
10324 });
10325 return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(FieldRootContext.Provider, {
10326 value: contextValue,
10327 children: element
10328 });
10329 });
10330 if (true) FieldRootInner.displayName = "FieldRootInner";
10331 var FieldRoot = /* @__PURE__ */ React61.forwardRef(function FieldRoot2(componentProps, forwardedRef) {
10332 return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(LabelableProvider, {
10333 children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(FieldRootInner, {
10334 ...componentProps,
10335 ref: forwardedRef
10336 })
10337 });
10338 });
10339 if (true) FieldRoot.displayName = "FieldRoot";
10340
10341 // node_modules/@base-ui/react/field/label/FieldLabel.mjs
10342 var React62 = __toESM(require_react(), 1);
10343 var FieldLabel = /* @__PURE__ */ React62.forwardRef(function FieldLabel2(componentProps, forwardedRef) {
10344 const {
10345 render: render4,
10346 className,
10347 style,
10348 id: idProp,
10349 nativeLabel = true,
10350 ...elementProps
10351 } = componentProps;
10352 const fieldRootContext = useFieldRootContext(false);
10353 const fieldItemContext = useFieldItemContext();
10354 const {
10355 labelId
10356 } = useLabelableContext();
10357 const state = {
10358 ...fieldRootContext.state,
10359 disabled: fieldRootContext.disabled || fieldItemContext.disabled
10360 };
10361 const labelRef = React62.useRef(null);
10362 const labelProps = useLabel({
10363 id: labelId ?? idProp,
10364 native: nativeLabel
10365 });
10366 if (true) {
10367 React62.useEffect(() => {
10368 if (!labelRef.current) {
10369 return;
10370 }
10371 const isLabelTag = labelRef.current.tagName === "LABEL";
10372 if (nativeLabel) {
10373 if (!isLabelTag) {
10374 const ownerStackMessage = SafeReact.captureOwnerStack?.() || "";
10375 const message2 = "<Field.Label> expected a <label> element because the `nativeLabel` prop is true. Rendering a non-<label> disables native label association, so `htmlFor` will not work. Use a real <label> in the `render` prop, or set `nativeLabel` to `false`.";
10376 error(`${message2}${ownerStackMessage}`);
10377 }
10378 } else if (isLabelTag) {
10379 const ownerStackMessage = SafeReact.captureOwnerStack?.() || "";
10380 const message2 = "<Field.Label> expected a non-<label> element because the `nativeLabel` prop is false. Rendering a <label> assumes native label behavior while Base UI treats it as non-native, which can cause unexpected pointer behavior. Use a non-<label> in the `render` prop, or set `nativeLabel` to `true`.";
10381 error(`${message2}${ownerStackMessage}`);
10382 }
10383 }, [nativeLabel]);
10384 }
10385 const element = useRenderElement("label", componentProps, {
10386 ref: [forwardedRef, labelRef],
10387 state,
10388 props: [labelProps, elementProps],
10389 stateAttributesMapping: fieldValidityMapping
10390 });
10391 return element;
10392 });
10393 if (true) FieldLabel.displayName = "FieldLabel";
10394
10395 // node_modules/@base-ui/react/field/error/FieldError.mjs
10396 var React63 = __toESM(require_react(), 1);
10397 var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
10398 var stateAttributesMapping2 = {
10399 ...fieldValidityMapping,
10400 ...transitionStatusMapping
10401 };
10402 var FieldError = /* @__PURE__ */ React63.forwardRef(function FieldError2(componentProps, forwardedRef) {
10403 const {
10404 render: render4,
10405 id: idProp,
10406 className,
10407 match: match2,
10408 style,
10409 ...elementProps
10410 } = componentProps;
10411 const id = useBaseUiId(idProp);
10412 const {
10413 validityData,
10414 state: fieldState,
10415 name
10416 } = useFieldRootContext(false);
10417 const {
10418 setMessageIds
10419 } = useLabelableContext();
10420 const {
10421 errors
10422 } = useFormContext();
10423 const formError = name && Object.hasOwn(errors, name) ? errors[name] : null;
10424 const hasFormError = !!(Array.isArray(formError) ? formError.length : formError);
10425 const hasSpecificMatch = typeof match2 === "string";
10426 let rendered = false;
10427 if (match2 === true) {
10428 rendered = true;
10429 } else if (fieldState.disabled) {
10430 rendered = false;
10431 } else if (hasSpecificMatch) {
10432 rendered = Boolean(validityData.state[match2]);
10433 } else {
10434 rendered = hasFormError || validityData.state.valid === false;
10435 }
10436 const {
10437 mounted,
10438 transitionStatus,
10439 setMounted
10440 } = useTransitionStatus(rendered);
10441 useIsoLayoutEffect(() => {
10442 if (!rendered || !id) {
10443 return void 0;
10444 }
10445 setMessageIds((v2) => v2.concat(id));
10446 return () => {
10447 setMessageIds((v2) => v2.filter((item) => item !== id));
10448 };
10449 }, [rendered, id, setMessageIds]);
10450 const errorRef = React63.useRef(null);
10451 const [lastRenderedMessage, setLastRenderedMessage] = React63.useState(null);
10452 const [lastRenderedMessageKey, setLastRenderedMessageKey] = React63.useState(null);
10453 let error2 = validityData.error;
10454 if (!hasSpecificMatch && hasFormError) {
10455 error2 = formError;
10456 } else if (validityData.errors.length > 1) {
10457 error2 = validityData.errors;
10458 }
10459 let errorMessage = error2;
10460 if (Array.isArray(error2)) {
10461 errorMessage = error2.length > 1 ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("ul", {
10462 children: error2.map((message2) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("li", {
10463 children: message2
10464 }, message2))
10465 }) : error2[0];
10466 }
10467 const errorKey = Array.isArray(error2) ? JSON.stringify(error2) : error2;
10468 if (rendered && errorKey !== lastRenderedMessageKey) {
10469 setLastRenderedMessageKey(errorKey);
10470 setLastRenderedMessage(errorMessage);
10471 }
10472 useOpenChangeComplete({
10473 open: rendered,
10474 ref: errorRef,
10475 onComplete() {
10476 if (!rendered) {
10477 setMounted(false);
10478 }
10479 }
10480 });
10481 const state = {
10482 ...fieldState,
10483 transitionStatus
10484 };
10485 const element = useRenderElement("div", componentProps, {
10486 ref: [forwardedRef, errorRef],
10487 state,
10488 props: [{
10489 id,
10490 children: rendered ? errorMessage : lastRenderedMessage
10491 }, elementProps],
10492 stateAttributesMapping: stateAttributesMapping2,
10493 enabled: mounted
10494 });
10495 if (!mounted) {
10496 return null;
10497 }
10498 return element;
10499 });
10500 if (true) FieldError.displayName = "FieldError";
10501
10502 // node_modules/@base-ui/react/field/description/FieldDescription.mjs
10503 var React64 = __toESM(require_react(), 1);
10504 var FieldDescription = /* @__PURE__ */ React64.forwardRef(function FieldDescription2(componentProps, forwardedRef) {
10505 const {
10506 render: render4,
10507 id: idProp,
10508 className,
10509 style,
10510 ...elementProps
10511 } = componentProps;
10512 const id = useBaseUiId(idProp);
10513 const fieldRootContext = useFieldRootContext(false);
10514 const fieldItemContext = useFieldItemContext();
10515 const {
10516 setMessageIds
10517 } = useLabelableContext();
10518 const state = {
10519 ...fieldRootContext.state,
10520 disabled: fieldRootContext.disabled || fieldItemContext.disabled
10521 };
10522 useIsoLayoutEffect(() => {
10523 if (!id) {
10524 return void 0;
10525 }
10526 setMessageIds((v2) => v2.concat(id));
10527 return () => {
10528 setMessageIds((v2) => v2.filter((item) => item !== id));
10529 };
10530 }, [id, setMessageIds]);
10531 const element = useRenderElement("p", componentProps, {
10532 ref: forwardedRef,
10533 state,
10534 props: [{
10535 id
10536 }, elementProps],
10537 stateAttributesMapping: fieldValidityMapping
10538 });
10539 return element;
10540 });
10541 if (true) FieldDescription.displayName = "FieldDescription";
10542
10543 // node_modules/@base-ui/react/field/control/FieldControl.mjs
10544 var React65 = __toESM(require_react(), 1);
10545 var FieldControl = /* @__PURE__ */ React65.forwardRef(function FieldControl2(componentProps, forwardedRef) {
10546 const {
10547 render: render4,
10548 className,
10549 id: idProp,
10550 name: nameProp,
10551 value: valueProp,
10552 disabled: disabledProp = false,
10553 onValueChange,
10554 defaultValue,
10555 autoFocus = false,
10556 style,
10557 ...elementProps
10558 } = componentProps;
10559 const {
10560 state: fieldState,
10561 name: fieldName,
10562 disabled: fieldDisabled,
10563 setTouched,
10564 setDirty,
10565 validityData,
10566 setFocused,
10567 setFilled,
10568 validationMode,
10569 validation
10570 } = useFieldRootContext();
10571 const {
10572 clearErrors,
10573 elementRef: formElementRef,
10574 submitCountRef
10575 } = useFormContext();
10576 const disabled2 = fieldDisabled || disabledProp;
10577 const name = fieldName ?? nameProp;
10578 const state = {
10579 ...fieldState,
10580 disabled: disabled2
10581 };
10582 const {
10583 labelId
10584 } = useLabelableContext();
10585 const id = useLabelableId({
10586 id: idProp
10587 });
10588 const [valueUnwrapped] = useControlled({
10589 controlled: valueProp,
10590 default: defaultValue,
10591 name: "FieldControl",
10592 state: "value"
10593 });
10594 const isControlled = valueProp !== void 0;
10595 const value = isControlled ? valueUnwrapped : void 0;
10596 const serializedValue = value == null ? void 0 : String(value);
10597 const getValueFromInput = useStableCallback(() => validation.inputRef.current?.value);
10598 useRegisterFieldControl(validation.inputRef, id, serializedValue, getValueFromInput, !disabled2, nameProp);
10599 useIsoLayoutEffect(() => {
10600 const currentValue = serializedValue ?? validation.inputRef.current?.value;
10601 if (currentValue !== void 0) {
10602 setFilled(currentValue !== "");
10603 }
10604 }, [serializedValue, validation.inputRef, setFilled]);
10605 useValueChanged(serializedValue, () => {
10606 if (serializedValue === void 0) {
10607 return;
10608 }
10609 clearErrors(name);
10610 setDirty(serializedValue !== (validityData.initialValue ?? ""));
10611 validation.change(serializedValue);
10612 });
10613 const inputRef = React65.useRef(null);
10614 const enterValidationTimeout = useTimeout();
10615 useIsoLayoutEffect(() => {
10616 if (autoFocus && inputRef.current === activeElement(ownerDocument(inputRef.current))) {
10617 setFocused(true);
10618 }
10619 }, [autoFocus, setFocused]);
10620 const element = useRenderElement("input", componentProps, {
10621 ref: [forwardedRef, inputRef],
10622 state,
10623 props: [{
10624 id,
10625 disabled: disabled2,
10626 name,
10627 ref: validation.inputRef,
10628 "aria-labelledby": labelId,
10629 autoFocus,
10630 ...isControlled ? {
10631 value
10632 } : {
10633 defaultValue
10634 },
10635 onChange(event) {
10636 const inputValue = event.currentTarget.value;
10637 const details = createChangeEventDetails(reason_parts_exports.none, event.nativeEvent);
10638 onValueChange?.(inputValue, details);
10639 if (isControlled) {
10640 return;
10641 }
10642 setDirty(inputValue !== (validityData.initialValue ?? ""));
10643 setFilled(inputValue !== "");
10644 if (!event.nativeEvent.defaultPrevented && !details.isCanceled) {
10645 clearErrors(name);
10646 validation.change(inputValue);
10647 }
10648 },
10649 onFocus() {
10650 setFocused(true);
10651 },
10652 onBlur(event) {
10653 setTouched(true);
10654 setFocused(false);
10655 if (validationMode === "onBlur") {
10656 const inputValue = event.currentTarget.value;
10657 validation.commit(inputValue);
10658 if (isControlled) {
10659 queueMicrotask(() => {
10660 const nextValue = validation.inputRef.current?.value;
10661 if (nextValue !== void 0 && nextValue !== inputValue && nextValue !== (validityData.initialValue ?? "")) {
10662 validation.commit(nextValue);
10663 }
10664 });
10665 }
10666 }
10667 },
10668 onKeyDown(event) {
10669 if (event.currentTarget.tagName === "INPUT" && event.key === "Enter") {
10670 setTouched(true);
10671 const value2 = event.currentTarget.value;
10672 const form = event.currentTarget.form;
10673 if (form && form === formElementRef.current && !event.defaultPrevented) {
10674 const input = event.currentTarget;
10675 const submitCount = submitCountRef.current;
10676 enterValidationTimeout.start(0, () => {
10677 if (submitCountRef.current === submitCount) {
10678 validation.commit(input.value);
10679 }
10680 });
10681 } else {
10682 validation.commit(value2);
10683 }
10684 }
10685 }
10686 }, elementProps, (props) => validation.getValidationProps(disabled2, props)],
10687 stateAttributesMapping: fieldValidityMapping
10688 });
10689 return element;
10690 });
10691 if (true) FieldControl.displayName = "FieldControl";
10692
10693 // node_modules/@base-ui/react/field/validity/FieldValidity.mjs
10694 var React66 = __toESM(require_react(), 1);
10695 var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
10696 var FieldValidity = function FieldValidity2(props) {
10697 const {
10698 children
10699 } = props;
10700 const {
10701 validityData,
10702 invalid: invalid2
10703 } = useFieldRootContext(false);
10704 const combinedFieldValidityData = React66.useMemo(() => getCombinedFieldValidityData(validityData, invalid2), [validityData, invalid2]);
10705 const isInvalid = combinedFieldValidityData.state.valid === false;
10706 const {
10707 transitionStatus
10708 } = useTransitionStatus(isInvalid);
10709 const fieldValidityState = React66.useMemo(() => {
10710 return {
10711 ...combinedFieldValidityData,
10712 validity: combinedFieldValidityData.state,
10713 transitionStatus
10714 };
10715 }, [combinedFieldValidityData, transitionStatus]);
10716 return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(React66.Fragment, {
10717 children: children(fieldValidityState)
10718 });
10719 };
10720 if (true) FieldValidity.displayName = "FieldValidity";
10721
10722 // node_modules/@base-ui/react/field/item/FieldItem.mjs
10723 var React67 = __toESM(require_react(), 1);
10724 var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
10725 var FieldItem = /* @__PURE__ */ React67.forwardRef(function FieldItem2(componentProps, forwardedRef) {
10726 const {
10727 render: render4,
10728 className,
10729 style,
10730 disabled: disabledProp = false,
10731 ...elementProps
10732 } = componentProps;
10733 const {
10734 state: fieldState,
10735 disabled: rootDisabled
10736 } = useFieldRootContext(false);
10737 const disabled2 = rootDisabled || disabledProp;
10738 const state = {
10739 ...fieldState,
10740 disabled: disabled2
10741 };
10742 const fieldItemContext = React67.useMemo(() => ({
10743 disabled: disabled2
10744 }), [disabled2]);
10745 const element = useRenderElement("div", componentProps, {
10746 ref: forwardedRef,
10747 state,
10748 props: elementProps,
10749 stateAttributesMapping: fieldValidityMapping
10750 });
10751 return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(LabelableProvider, {
10752 children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(FieldItemContext.Provider, {
10753 value: fieldItemContext,
10754 children: element
10755 })
10756 });
10757 });
10758 if (true) FieldItem.displayName = "FieldItem";
10759
10760 // node_modules/@base-ui/react/input/Input.mjs
10761 var React68 = __toESM(require_react(), 1);
10762 var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
10763 var Input = /* @__PURE__ */ React68.forwardRef(function Input2(props, forwardedRef) {
10764 return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(index_parts_exports2.Control, {
10765 ref: forwardedRef,
10766 ...props
10767 });
10768 });
10769 if (true) Input.displayName = "Input";
10770
10771 // node_modules/@base-ui/react/internals/composite/root/CompositeRoot.mjs
10772 var React70 = __toESM(require_react(), 1);
10773
10774 // node_modules/@base-ui/react/internals/composite/root/useCompositeRoot.mjs
10775 var React69 = __toESM(require_react(), 1);
10776
10777 // node_modules/@base-ui/react/internals/composite/constants.mjs
10778 var ACTIVE_COMPOSITE_ITEM = "data-composite-item-active";
10779
10780 // node_modules/@base-ui/react/internals/composite/root/useCompositeRoot.mjs
10781 function useCompositeRoot(params) {
10782 const {
10783 loopFocus = true,
10784 orientation = "both",
10785 grid,
10786 onLoop,
10787 direction,
10788 highlightedIndex: externalHighlightedIndex,
10789 onHighlightedIndexChange: externalSetHighlightedIndex,
10790 rootRef: externalRef,
10791 enableHomeAndEndKeys = false,
10792 stopEventPropagation,
10793 disabledIndices,
10794 modifierKeys = EMPTY_ARRAY
10795 } = params;
10796 const [internalHighlightedIndex, internalSetHighlightedIndex] = React69.useState(0);
10797 const isGrid = grid != null;
10798 const rootRef = React69.useRef(null);
10799 const mergedRef = useMergedRefs(rootRef, externalRef);
10800 const elementsRef = React69.useRef([]);
10801 const hasSetDefaultIndexRef = React69.useRef(false);
10802 const highlightedElementRef = React69.useRef(null);
10803 const highlightedIndex = externalHighlightedIndex ?? internalHighlightedIndex;
10804 const onHighlightedIndexChange = useStableCallback((index3, shouldScrollIntoView = false) => {
10805 highlightedElementRef.current = elementsRef.current[index3] ?? null;
10806 (externalSetHighlightedIndex ?? internalSetHighlightedIndex)(index3);
10807 if (shouldScrollIntoView) {
10808 const newActiveItem = elementsRef.current[index3];
10809 scrollIntoViewIfNeeded(rootRef.current, newActiveItem, direction, orientation);
10810 }
10811 });
10812 const onMapChange = useStableCallback((map) => {
10813 if (map.size === 0) {
10814 return;
10815 }
10816 if (hasSetDefaultIndexRef.current) {
10817 const elements = elementsRef.current;
10818 const nextIndex = elements.indexOf(highlightedElementRef.current);
10819 if (nextIndex === -1) {
10820 const replacement = elements[highlightedIndex];
10821 if (!replacement || isListIndexDisabled(elements, highlightedIndex, disabledIndices)) {
10822 onHighlightedIndexChange(getFallbackIndex(elements, disabledIndices));
10823 } else {
10824 highlightedElementRef.current = replacement;
10825 }
10826 } else if (nextIndex !== highlightedIndex) {
10827 onHighlightedIndexChange(nextIndex);
10828 }
10829 return;
10830 }
10831 hasSetDefaultIndexRef.current = true;
10832 const sortedElements = Array.from(map.keys());
10833 const activeItem = sortedElements.find((compositeElement) => compositeElement?.hasAttribute(ACTIVE_COMPOSITE_ITEM)) ?? null;
10834 const activeIndex = activeItem ? map.get(activeItem)?.index ?? -1 : -1;
10835 if (activeIndex !== -1) {
10836 onHighlightedIndexChange(activeIndex);
10837 } else if (isListIndexDisabled(sortedElements, highlightedIndex, disabledIndices)) {
10838 const firstEnabledIndex = findNonDisabledListIndex(sortedElements, {
10839 disabledIndices
10840 });
10841 if (!isIndexOutOfListBounds(sortedElements, firstEnabledIndex)) {
10842 onHighlightedIndexChange(firstEnabledIndex);
10843 }
10844 }
10845 scrollIntoViewIfNeeded(rootRef.current, activeItem, direction, orientation);
10846 });
10847 useIsoLayoutEffect(() => {
10848 if (disabledIndices == null || externalHighlightedIndex != null || !hasSetDefaultIndexRef.current) {
10849 return;
10850 }
10851 const elements = elementsRef.current;
10852 if (isListIndexDisabled(elements, highlightedIndex, disabledIndices)) {
10853 const firstEnabledIndex = findNonDisabledListIndex(elements, {
10854 disabledIndices
10855 });
10856 if (!isIndexOutOfListBounds(elements, firstEnabledIndex)) {
10857 onHighlightedIndexChange(firstEnabledIndex);
10858 }
10859 }
10860 }, [disabledIndices, externalHighlightedIndex, highlightedIndex, elementsRef, onHighlightedIndexChange]);
10861 const wrappedOnLoop = useStableCallback((event, prevIndex, nextIndex) => {
10862 if (!onLoop) {
10863 return nextIndex;
10864 }
10865 return onLoop(event, prevIndex, nextIndex, elementsRef);
10866 });
10867 const onKeyDown = useStableCallback((event) => {
10868 const isHomeOrEnd = event.key === HOME || event.key === END;
10869 if (!COMPOSITE_KEYS.has(event.key) || !enableHomeAndEndKeys && isHomeOrEnd) {
10870 return;
10871 }
10872 if (isModifierKeySet(event, modifierKeys)) {
10873 return;
10874 }
10875 const element = rootRef.current;
10876 if (!element) {
10877 return;
10878 }
10879 const isRtl = direction === "rtl";
10880 const horizontalForwardKey = isRtl ? ARROW_LEFT : ARROW_RIGHT;
10881 const horizontalBackwardKey = isRtl ? ARROW_RIGHT : ARROW_LEFT;
10882 const forwardKey = orientation === "vertical" ? ARROW_DOWN : horizontalForwardKey;
10883 const backwardKey = orientation === "vertical" ? ARROW_UP : horizontalBackwardKey;
10884 const target = getTarget(event.nativeEvent);
10885 if (target != null && isNativeInput(target) && !isElementDisabled(target)) {
10886 const selectionStart = target.selectionStart;
10887 const selectionEnd = target.selectionEnd;
10888 const textContent = target.value;
10889 if (selectionStart == null || event.shiftKey || selectionStart !== selectionEnd) {
10890 return;
10891 }
10892 if (event.key !== backwardKey && selectionStart < textContent.length) {
10893 return;
10894 }
10895 if (event.key !== forwardKey && selectionStart > 0) {
10896 return;
10897 }
10898 }
10899 let nextIndex = highlightedIndex;
10900 const minIndex = getMinListIndex(elementsRef, disabledIndices);
10901 const maxIndex = getMaxListIndex(elementsRef, disabledIndices);
10902 if (grid != null) {
10903 nextIndex = grid({
10904 disabledIndices,
10905 elementsRef,
10906 event,
10907 highlightedIndex,
10908 loopFocus,
10909 maxIndex,
10910 minIndex,
10911 onLoop: wrappedOnLoop,
10912 orientation,
10913 rtl: isRtl
10914 });
10915 }
10916 const isForwardKey = orientation !== "vertical" && event.key === horizontalForwardKey || orientation !== "horizontal" && event.key === ARROW_DOWN;
10917 const isBackwardKey = orientation !== "vertical" && event.key === horizontalBackwardKey || orientation !== "horizontal" && event.key === ARROW_UP;
10918 if (enableHomeAndEndKeys) {
10919 if (event.key === HOME) {
10920 nextIndex = minIndex;
10921 } else if (event.key === END) {
10922 nextIndex = maxIndex;
10923 }
10924 }
10925 if (nextIndex === highlightedIndex && (isForwardKey || isBackwardKey)) {
10926 if (loopFocus && nextIndex === maxIndex && isForwardKey) {
10927 nextIndex = minIndex;
10928 if (onLoop) {
10929 nextIndex = onLoop(event, highlightedIndex, nextIndex, elementsRef);
10930 }
10931 } else if (loopFocus && nextIndex === minIndex && isBackwardKey) {
10932 nextIndex = maxIndex;
10933 if (onLoop) {
10934 nextIndex = onLoop(event, highlightedIndex, nextIndex, elementsRef);
10935 }
10936 } else {
10937 nextIndex = findNonDisabledListIndex(elementsRef.current, {
10938 startingIndex: nextIndex,
10939 decrement: isBackwardKey,
10940 disabledIndices
10941 });
10942 }
10943 }
10944 if (nextIndex !== highlightedIndex && !isIndexOutOfListBounds(elementsRef.current, nextIndex)) {
10945 if (stopEventPropagation) {
10946 event.stopPropagation();
10947 }
10948 if (isGrid || isHomeOrEnd || isForwardKey || isBackwardKey) {
10949 event.preventDefault();
10950 }
10951 onHighlightedIndexChange(nextIndex, true);
10952 queueMicrotask(() => {
10953 elementsRef.current[nextIndex]?.focus();
10954 });
10955 }
10956 });
10957 const props = {
10958 ref: mergedRef,
10959 onFocus(event) {
10960 const element = rootRef.current;
10961 const target = getTarget(event.nativeEvent);
10962 if (!element || target == null || !isNativeInput(target)) {
10963 return;
10964 }
10965 target.setSelectionRange(0, target.value.length);
10966 },
10967 onKeyDown
10968 };
10969 return {
10970 props,
10971 highlightedIndex,
10972 onHighlightedIndexChange,
10973 elementsRef,
10974 onMapChange,
10975 relayKeyboardEvent: onKeyDown
10976 };
10977 }
10978 function getFallbackIndex(elements, disabledIndices) {
10979 let fallbackIndex = -1;
10980 for (let index3 = 0; index3 < elements.length; index3 += 1) {
10981 const element = elements[index3];
10982 if (!element || isListIndexDisabled(elements, index3, disabledIndices)) {
10983 continue;
10984 }
10985 if (element.hasAttribute(ACTIVE_COMPOSITE_ITEM)) {
10986 return index3;
10987 }
10988 if (fallbackIndex === -1) {
10989 fallbackIndex = index3;
10990 }
10991 }
10992 return Math.max(fallbackIndex, 0);
10993 }
10994 function isModifierKeySet(event, ignoredModifierKeys) {
10995 for (const key of MODIFIER_KEYS) {
10996 if (ignoredModifierKeys.includes(key)) {
10997 continue;
10998 }
10999 if (event.getModifierState(key)) {
11000 return true;
11001 }
11002 }
11003 return false;
11004 }
11005
11006 // node_modules/@base-ui/react/internals/composite/root/CompositeRoot.mjs
11007 var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
11008 function CompositeRoot(componentProps) {
11009 const {
11010 render: render4,
11011 className,
11012 style,
11013 refs = EMPTY_ARRAY,
11014 props = EMPTY_ARRAY,
11015 state = EMPTY_OBJECT,
11016 stateAttributesMapping: stateAttributesMapping5,
11017 highlightedIndex: highlightedIndexProp,
11018 onHighlightedIndexChange: onHighlightedIndexChangeProp,
11019 orientation,
11020 grid,
11021 loopFocus,
11022 onLoop,
11023 enableHomeAndEndKeys,
11024 onMapChange: onMapChangeProp,
11025 stopEventPropagation = true,
11026 rootRef,
11027 disabledIndices,
11028 modifierKeys,
11029 highlightItemOnHover = false,
11030 tag = "div",
11031 ...elementProps
11032 } = componentProps;
11033 const direction = useDirection();
11034 const {
11035 props: defaultProps,
11036 highlightedIndex,
11037 onHighlightedIndexChange,
11038 elementsRef,
11039 onMapChange: onMapChangeUnwrapped,
11040 relayKeyboardEvent
11041 } = useCompositeRoot({
11042 grid,
11043 loopFocus,
11044 onLoop,
11045 orientation,
11046 highlightedIndex: highlightedIndexProp,
11047 onHighlightedIndexChange: onHighlightedIndexChangeProp,
11048 rootRef,
11049 stopEventPropagation,
11050 enableHomeAndEndKeys,
11051 direction,
11052 disabledIndices,
11053 modifierKeys
11054 });
11055 const element = useRenderElement(tag, componentProps, {
11056 state,
11057 ref: refs,
11058 props: [defaultProps, ...props, elementProps],
11059 stateAttributesMapping: stateAttributesMapping5
11060 });
11061 const contextValue = React70.useMemo(() => ({
11062 highlightedIndex,
11063 onHighlightedIndexChange,
11064 highlightItemOnHover,
11065 relayKeyboardEvent
11066 }), [highlightedIndex, onHighlightedIndexChange, highlightItemOnHover, relayKeyboardEvent]);
11067 return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(CompositeRootContext.Provider, {
11068 value: contextValue,
11069 children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(CompositeList, {
11070 elementsRef,
11071 onMapChange: (newMap) => {
11072 onMapChangeProp?.(newMap);
11073 onMapChangeUnwrapped(newMap);
11074 },
11075 children: element
11076 })
11077 });
11078 }
11079
11080 // node_modules/@base-ui/react/utils/FloatingPortalLite.mjs
11081 var React71 = __toESM(require_react(), 1);
11082 var ReactDOM7 = __toESM(require_react_dom(), 1);
11083 var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
11084 var FloatingPortalLite = /* @__PURE__ */ React71.forwardRef(function FloatingPortalLite2(componentProps, forwardedRef) {
11085 const {
11086 children,
11087 container,
11088 className,
11089 render: render4,
11090 style,
11091 ...elementProps
11092 } = componentProps;
11093 const {
11094 node: portalNode,
11095 subtree: portalSubtree
11096 } = useFloatingPortalNode({
11097 container,
11098 ref: forwardedRef,
11099 componentProps,
11100 elementProps
11101 });
11102 if (!portalSubtree && !portalNode) {
11103 return null;
11104 }
11105 return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(React71.Fragment, {
11106 children: [portalSubtree, portalNode && /* @__PURE__ */ ReactDOM7.createPortal(children, portalNode)]
11107 });
11108 });
11109 if (true) FloatingPortalLite.displayName = "FloatingPortalLite";
11110
11111 // node_modules/@base-ui/react/internals/prehydrationScript.stub.mjs
11112 var script = "";
11113
11114 // node_modules/@base-ui/react/utils/useIsHydrating.mjs
11115 var import_shim3 = __toESM(require_shim(), 1);
11116 function subscribe() {
11117 return NOOP;
11118 }
11119 function getSnapshot() {
11120 return false;
11121 }
11122 function getServerSnapshot() {
11123 return true;
11124 }
11125 function useIsHydrating() {
11126 return (0, import_shim3.useSyncExternalStore)(subscribe, getSnapshot, getServerSnapshot);
11127 }
11128
11129 // node_modules/@base-ui/react/internals/PrehydrationScript.mjs
11130 var React72 = __toESM(require_react(), 1);
11131 var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
11132 function PrehydrationScript(props) {
11133 const {
11134 script: script2
11135 } = props;
11136 const {
11137 nonce
11138 } = useCSPContext();
11139 const isHydrating = useIsHydrating();
11140 if (!isHydrating) {
11141 return null;
11142 }
11143 return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("script", {
11144 nonce,
11145 dangerouslySetInnerHTML: {
11146 __html: script2
11147 },
11148 suppressHydrationWarning: true
11149 });
11150 }
11151
11152 // node_modules/@base-ui/react/tabs/index.parts.mjs
11153 var index_parts_exports3 = {};
11154 __export(index_parts_exports3, {
11155 Indicator: () => TabsIndicator,
11156 List: () => TabsList,
11157 Panel: () => TabsPanel,
11158 Root: () => TabsRoot,
11159 Tab: () => TabsTab
11160 });
11161
11162 // node_modules/@base-ui/react/tabs/root/TabsRoot.mjs
11163 var React74 = __toESM(require_react(), 1);
11164
11165 // node_modules/@base-ui/react/tabs/root/TabsRootContext.mjs
11166 var React73 = __toESM(require_react(), 1);
11167 var TabsRootContext = /* @__PURE__ */ React73.createContext(void 0);
11168 if (true) TabsRootContext.displayName = "TabsRootContext";
11169 function useTabsRootContext() {
11170 const context = React73.useContext(TabsRootContext);
11171 if (context === void 0) {
11172 throw new Error(true ? "Base UI: TabsRootContext is missing. Tabs parts must be placed within <Tabs.Root>." : formatErrorMessage_default(64));
11173 }
11174 return context;
11175 }
11176
11177 // node_modules/@base-ui/react/tabs/root/TabsRootDataAttributes.mjs
11178 var activationDirection2 = "data-activation-direction";
11179
11180 // node_modules/@base-ui/react/tabs/root/stateAttributesMapping.mjs
11181 var tabsStateAttributesMapping = {
11182 tabActivationDirection: (dir) => ({
11183 [activationDirection2]: dir
11184 })
11185 };
11186
11187 // node_modules/@base-ui/react/tabs/root/TabsRoot.mjs
11188 var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
11189 var TabsRoot = /* @__PURE__ */ React74.forwardRef(function TabsRoot2(componentProps, forwardedRef) {
11190 const {
11191 className,
11192 defaultValue: defaultValueProp = 0,
11193 onValueChange: onValueChangeProp,
11194 orientation = "horizontal",
11195 render: render4,
11196 value: valueProp,
11197 style,
11198 ...elementProps
11199 } = componentProps;
11200 const hasExplicitDefaultValueProp = componentProps.defaultValue !== void 0;
11201 const tabPanelRefs = React74.useRef([]);
11202 const [mountedTabPanels, setMountedTabPanels] = React74.useState(() => /* @__PURE__ */ new Map());
11203 const [value, setValue] = useControlled({
11204 controlled: valueProp,
11205 default: defaultValueProp,
11206 name: "Tabs",
11207 state: "value"
11208 });
11209 const isControlled = valueProp !== void 0;
11210 const [tabMap, setTabMap] = React74.useState(() => /* @__PURE__ */ new Map());
11211 const lastKnownTabElementRef = React74.useRef(void 0);
11212 const getTabElementBySelectedValue = React74.useCallback((selectedValue) => findTabElement(tabMap, selectedValue), [tabMap]);
11213 const [activationDirectionState, setActivationDirectionState] = React74.useState(() => ({
11214 previousValue: value,
11215 tabActivationDirection: "none"
11216 }));
11217 const {
11218 previousValue,
11219 tabActivationDirection: committedTabActivationDirection
11220 } = activationDirectionState;
11221 let tabActivationDirection = committedTabActivationDirection;
11222 let directionComputationIncomplete = false;
11223 if (previousValue !== value) {
11224 tabActivationDirection = computeActivationDirection(previousValue, value, orientation, tabMap);
11225 directionComputationIncomplete = previousValue != null && value != null && getTabElementBySelectedValue(value) == null;
11226 }
11227 const nextPreviousValue = directionComputationIncomplete ? previousValue : value;
11228 const shouldSyncActivationDirectionState = previousValue !== nextPreviousValue || committedTabActivationDirection !== tabActivationDirection;
11229 useIsoLayoutEffect(() => {
11230 if (!shouldSyncActivationDirectionState) {
11231 return;
11232 }
11233 setActivationDirectionState({
11234 previousValue: nextPreviousValue,
11235 tabActivationDirection
11236 });
11237 }, [nextPreviousValue, shouldSyncActivationDirectionState, tabActivationDirection]);
11238 const onValueChange = useStableCallback((newValue, eventDetails) => {
11239 const activationDirection3 = computeActivationDirection(value, newValue, orientation, tabMap);
11240 eventDetails.activationDirection = activationDirection3;
11241 onValueChangeProp?.(newValue, eventDetails);
11242 if (eventDetails.isCanceled) {
11243 return;
11244 }
11245 setValue(newValue);
11246 });
11247 const notifyAutomaticValueChange = useStableCallback((nextValue, reason) => {
11248 onValueChangeProp?.(nextValue, createChangeEventDetails(reason, void 0, void 0, {
11249 activationDirection: "none"
11250 }));
11251 });
11252 const registerMountedTabPanel = useStableCallback((panelValue, panelId) => {
11253 setMountedTabPanels((prev) => {
11254 const next = new Map(prev);
11255 next.set(panelValue, panelId);
11256 return next;
11257 });
11258 return () => {
11259 setMountedTabPanels((prev) => {
11260 if (prev.get(panelValue) !== panelId) {
11261 return prev;
11262 }
11263 const next = new Map(prev);
11264 next.delete(panelValue);
11265 return next;
11266 });
11267 };
11268 });
11269 const getTabPanelIdByValue = React74.useCallback((tabValue) => {
11270 return mountedTabPanels.get(tabValue);
11271 }, [mountedTabPanels]);
11272 const getTabIdByPanelValue = React74.useCallback((tabPanelValue) => {
11273 for (const tabMetadata of tabMap.values()) {
11274 if (tabPanelValue === tabMetadata.value) {
11275 return tabMetadata.id;
11276 }
11277 }
11278 return void 0;
11279 }, [tabMap]);
11280 const tabsContextValue = React74.useMemo(() => ({
11281 getTabElementBySelectedValue,
11282 getTabIdByPanelValue,
11283 getTabPanelIdByValue,
11284 onValueChange,
11285 orientation,
11286 registerMountedTabPanel,
11287 setTabMap,
11288 tabActivationDirection,
11289 value
11290 }), [getTabElementBySelectedValue, getTabIdByPanelValue, getTabPanelIdByValue, onValueChange, orientation, registerMountedTabPanel, setTabMap, tabActivationDirection, value]);
11291 const selectedTabMetadata = React74.useMemo(() => {
11292 for (const tabMetadata of tabMap.values()) {
11293 if (tabMetadata.value === value) {
11294 return tabMetadata;
11295 }
11296 }
11297 return void 0;
11298 }, [tabMap, value]);
11299 const firstEnabledTabValue = React74.useMemo(() => {
11300 for (const tabMetadata of tabMap.values()) {
11301 if (!tabMetadata.disabled) {
11302 return tabMetadata.value;
11303 }
11304 }
11305 return void 0;
11306 }, [tabMap]);
11307 const shouldNotifyInitialValueChangeRef = React74.useRef(!hasExplicitDefaultValueProp);
11308 const initialDefaultValueRef = React74.useRef(defaultValueProp);
11309 const shouldHonorDisabledDefaultValueRef = React74.useRef(hasExplicitDefaultValueProp);
11310 const didRegisterTabsRef = React74.useRef(false);
11311 useIsoLayoutEffect(() => {
11312 if (isControlled) {
11313 return;
11314 }
11315 function commitAutomaticValueChange(fallbackValue, fallbackReason) {
11316 setValue(fallbackValue);
11317 setActivationDirectionState({
11318 previousValue: fallbackValue,
11319 tabActivationDirection: "none"
11320 });
11321 notifyAutomaticValueChange(fallbackValue, fallbackReason);
11322 shouldNotifyInitialValueChangeRef.current = false;
11323 }
11324 if (tabMap.size === 0) {
11325 if (didRegisterTabsRef.current && value !== null && !lastKnownTabElementRef.current?.isConnected) {
11326 commitAutomaticValueChange(null, reason_parts_exports.missing);
11327 }
11328 return;
11329 }
11330 didRegisterTabsRef.current = true;
11331 lastKnownTabElementRef.current = tabMap.keys().next().value;
11332 const selectionIsDisabled = selectedTabMetadata?.disabled;
11333 const selectionIsMissing = selectedTabMetadata == null && value !== null;
11334 if (!selectionIsDisabled && value === initialDefaultValueRef.current) {
11335 shouldHonorDisabledDefaultValueRef.current = false;
11336 }
11337 if (shouldHonorDisabledDefaultValueRef.current && selectionIsDisabled && value === initialDefaultValueRef.current) {
11338 return;
11339 }
11340 const shouldNotifyInitialValueChange = shouldNotifyInitialValueChangeRef.current;
11341 if (selectionIsDisabled || selectionIsMissing) {
11342 const fallbackValue = firstEnabledTabValue ?? null;
11343 if (value === fallbackValue) {
11344 shouldNotifyInitialValueChangeRef.current = false;
11345 return;
11346 }
11347 let fallbackReason = reason_parts_exports.missing;
11348 if (shouldNotifyInitialValueChange) {
11349 fallbackReason = reason_parts_exports.initial;
11350 } else if (selectionIsDisabled) {
11351 fallbackReason = reason_parts_exports.disabled;
11352 }
11353 commitAutomaticValueChange(fallbackValue, fallbackReason);
11354 return;
11355 }
11356 if (shouldNotifyInitialValueChange && selectedTabMetadata != null) {
11357 notifyAutomaticValueChange(value, reason_parts_exports.initial);
11358 shouldNotifyInitialValueChangeRef.current = false;
11359 }
11360 }, [firstEnabledTabValue, isControlled, notifyAutomaticValueChange, selectedTabMetadata, setValue, tabMap, value]);
11361 const state = {
11362 orientation,
11363 tabActivationDirection
11364 };
11365 const element = useRenderElement("div", componentProps, {
11366 state,
11367 ref: forwardedRef,
11368 props: elementProps,
11369 stateAttributesMapping: tabsStateAttributesMapping
11370 });
11371 return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(TabsRootContext.Provider, {
11372 value: tabsContextValue,
11373 children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(CompositeList, {
11374 elementsRef: tabPanelRefs,
11375 children: element
11376 })
11377 });
11378 });
11379 if (true) TabsRoot.displayName = "TabsRoot";
11380 function findTabElement(tabMap, value) {
11381 for (const [tabElement, tabMetadata] of tabMap.entries()) {
11382 if (value === tabMetadata.value) {
11383 return tabElement;
11384 }
11385 }
11386 return null;
11387 }
11388 function computeActivationDirection(oldValue, newValue, orientation, tabMap) {
11389 if (oldValue == null || newValue == null) {
11390 return "none";
11391 }
11392 const [positionProp, backward, forward] = orientation === "horizontal" ? ["left", "left", "right"] : ["top", "up", "down"];
11393 const oldTab = findTabElement(tabMap, oldValue);
11394 const newTab = findTabElement(tabMap, newValue);
11395 if (oldTab == null || newTab == null) {
11396 if (oldTab !== newTab && (typeof oldValue === "number" || typeof oldValue === "string") && typeof oldValue === typeof newValue) {
11397 return newValue > oldValue ? forward : backward;
11398 }
11399 return "none";
11400 }
11401 const oldPosition = oldTab.getBoundingClientRect()[positionProp];
11402 const newPosition = newTab.getBoundingClientRect()[positionProp];
11403 if (newPosition < oldPosition) {
11404 return backward;
11405 }
11406 if (newPosition > oldPosition) {
11407 return forward;
11408 }
11409 return "none";
11410 }
11411
11412 // node_modules/@base-ui/react/tabs/tab/TabsTab.mjs
11413 var React76 = __toESM(require_react(), 1);
11414
11415 // node_modules/@base-ui/react/tabs/list/TabsListContext.mjs
11416 var React75 = __toESM(require_react(), 1);
11417 var TabsListContext = /* @__PURE__ */ React75.createContext(void 0);
11418 if (true) TabsListContext.displayName = "TabsListContext";
11419 function useTabsListContext() {
11420 const context = React75.useContext(TabsListContext);
11421 if (context === void 0) {
11422 throw new Error(true ? "Base UI: TabsListContext is missing. TabsList parts must be placed within <Tabs.List>." : formatErrorMessage_default(65));
11423 }
11424 return context;
11425 }
11426
11427 // node_modules/@base-ui/react/tabs/tab/TabsTab.mjs
11428 var TabsTab = /* @__PURE__ */ React76.forwardRef(function TabsTab2(componentProps, forwardedRef) {
11429 const {
11430 className,
11431 disabled: disabled2 = false,
11432 render: render4,
11433 value,
11434 id: idProp,
11435 nativeButton = true,
11436 style,
11437 ...elementProps
11438 } = componentProps;
11439 const {
11440 value: activeTabValue,
11441 getTabPanelIdByValue,
11442 onValueChange,
11443 orientation,
11444 tabActivationDirection
11445 } = useTabsRootContext();
11446 const {
11447 activateOnFocus,
11448 registerTabResizeObserverElement,
11449 tabsListElement
11450 } = useTabsListContext();
11451 const {
11452 highlightedIndex,
11453 onHighlightedIndexChange
11454 } = useCompositeRootContext();
11455 const id = useBaseUiId(idProp);
11456 const tabMetadata = React76.useMemo(() => ({
11457 disabled: disabled2,
11458 id,
11459 value
11460 }), [disabled2, id, value]);
11461 const {
11462 compositeProps,
11463 compositeRef,
11464 index: index3
11465 // hook is used instead of the CompositeItem component
11466 // because the index is needed for Tab internals
11467 } = useCompositeItem({
11468 metadata: tabMetadata
11469 });
11470 const active = value === activeTabValue;
11471 const isNavigatingRef = React76.useRef(false);
11472 const unobserveTabElementRef = React76.useRef(null);
11473 const observeTabElement = useStableCallback((element2) => {
11474 unobserveTabElementRef.current?.();
11475 unobserveTabElementRef.current = element2 ? registerTabResizeObserverElement(element2) : null;
11476 });
11477 useIsoLayoutEffect(() => {
11478 if (isNavigatingRef.current) {
11479 isNavigatingRef.current = false;
11480 return;
11481 }
11482 if (!(active && index3 > -1 && highlightedIndex !== index3)) {
11483 return;
11484 }
11485 const listElement = tabsListElement;
11486 if (listElement != null) {
11487 const activeEl = activeElement(ownerDocument(listElement));
11488 if (activeEl && contains(listElement, activeEl)) {
11489 return;
11490 }
11491 }
11492 if (!disabled2) {
11493 onHighlightedIndexChange(index3);
11494 }
11495 }, [active, index3, highlightedIndex, onHighlightedIndexChange, disabled2, tabsListElement]);
11496 const {
11497 getButtonProps,
11498 buttonRef
11499 } = useButton({
11500 disabled: disabled2,
11501 native: nativeButton,
11502 focusableWhenDisabled: true
11503 });
11504 const tabPanelId = getTabPanelIdByValue(value);
11505 const isPressingRef = React76.useRef(false);
11506 const isMainButtonRef = React76.useRef(false);
11507 function activate(event) {
11508 onValueChange(value, createChangeEventDetails(reason_parts_exports.none, event.nativeEvent, void 0, {
11509 activationDirection: "none"
11510 }));
11511 }
11512 function onClick(event) {
11513 if (active || disabled2) {
11514 return;
11515 }
11516 activate(event);
11517 }
11518 function onFocus(event) {
11519 if (active || disabled2) {
11520 return;
11521 }
11522 if (activateOnFocus && (!isPressingRef.current || // keyboard or touch focus
11523 isMainButtonRef.current)) {
11524 activate(event);
11525 }
11526 }
11527 function onPointerDown(event) {
11528 if (active || disabled2) {
11529 return;
11530 }
11531 isPressingRef.current = true;
11532 isMainButtonRef.current = event.button === 0;
11533 const doc = ownerDocument(event.currentTarget);
11534 function handlePointerEnd() {
11535 isPressingRef.current = false;
11536 isMainButtonRef.current = false;
11537 doc.removeEventListener("pointerup", handlePointerEnd);
11538 doc.removeEventListener("pointercancel", handlePointerEnd);
11539 }
11540 doc.addEventListener("pointerup", handlePointerEnd);
11541 doc.addEventListener("pointercancel", handlePointerEnd);
11542 }
11543 const state = {
11544 disabled: disabled2,
11545 active,
11546 orientation,
11547 tabActivationDirection
11548 };
11549 const element = useRenderElement("button", componentProps, {
11550 state,
11551 ref: [forwardedRef, buttonRef, compositeRef, observeTabElement],
11552 props: [compositeProps, {
11553 role: "tab",
11554 "aria-controls": tabPanelId,
11555 "aria-selected": active,
11556 id,
11557 onClick,
11558 onFocus,
11559 onPointerDown,
11560 [ACTIVE_COMPOSITE_ITEM]: active ? "" : void 0,
11561 onKeyDownCapture() {
11562 isNavigatingRef.current = true;
11563 }
11564 }, elementProps, getButtonProps],
11565 stateAttributesMapping: tabsStateAttributesMapping
11566 });
11567 return element;
11568 });
11569 if (true) TabsTab.displayName = "TabsTab";
11570
11571 // node_modules/@base-ui/react/tabs/indicator/TabsIndicator.mjs
11572 var React77 = __toESM(require_react(), 1);
11573
11574 // node_modules/@base-ui/react/tabs/indicator/TabsIndicatorCssVars.mjs
11575 var activeTabLeft = "--active-tab-left";
11576 var activeTabRight = "--active-tab-right";
11577 var activeTabTop = "--active-tab-top";
11578 var activeTabBottom = "--active-tab-bottom";
11579 var activeTabWidth = "--active-tab-width";
11580 var activeTabHeight = "--active-tab-height";
11581
11582 // node_modules/@base-ui/react/tabs/indicator/TabsIndicator.mjs
11583 var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);
11584 var _PrehydrationScript;
11585 var stateAttributesMapping3 = {
11586 ...tabsStateAttributesMapping,
11587 activeTabPosition: () => null,
11588 activeTabSize: () => null
11589 };
11590 var MAX_LAYOUT_ROUNDING_ERROR = 2;
11591 var TabsIndicator = /* @__PURE__ */ React77.forwardRef(function TabsIndicator2(componentProps, forwardedRef) {
11592 const {
11593 className,
11594 render: render4,
11595 renderBeforeHydration = false,
11596 style: styleProp,
11597 ...elementProps
11598 } = componentProps;
11599 const {
11600 getTabElementBySelectedValue,
11601 orientation,
11602 tabActivationDirection,
11603 value
11604 } = useTabsRootContext();
11605 const {
11606 tabsListElement,
11607 registerIndicatorUpdateListener
11608 } = useTabsListContext();
11609 const rerender = useForcedRerendering();
11610 React77.useEffect(() => {
11611 return registerIndicatorUpdateListener(rerender);
11612 }, [registerIndicatorUpdateListener, rerender]);
11613 let left = 0;
11614 let right = 0;
11615 let top = 0;
11616 let bottom = 0;
11617 let width = 0;
11618 let height = 0;
11619 let isTabSelected = false;
11620 if (value != null && tabsListElement != null) {
11621 const activeTab = getTabElementBySelectedValue(value);
11622 if (activeTab != null) {
11623 isTabSelected = true;
11624 const {
11625 width: computedWidth,
11626 height: computedHeight
11627 } = getCssDimensions2(activeTab);
11628 const {
11629 width: tabListWidth,
11630 height: tabListHeight
11631 } = getCssDimensions2(tabsListElement);
11632 const tabRect = activeTab.getBoundingClientRect();
11633 const tabsListRect = tabsListElement.getBoundingClientRect();
11634 const scaleX = tabListWidth > 0 ? tabsListRect.width / tabListWidth : 1;
11635 const scaleY = tabListHeight > 0 ? tabsListRect.height / tabListHeight : 1;
11636 const layoutOffset = getLayoutOffset(activeTab, tabsListElement);
11637 left = layoutOffset.left;
11638 top = layoutOffset.top;
11639 const rectLeft = (tabRect.left - tabsListRect.left) / scaleX + tabsListElement.scrollLeft - tabsListElement.clientLeft;
11640 const rectTop = (tabRect.top - tabsListRect.top) / scaleY + tabsListElement.scrollTop - tabsListElement.clientTop;
11641 const tabTranslation = getActiveTabTranslation(activeTab);
11642 if (Math.abs(rectLeft - tabTranslation.x - left) <= MAX_LAYOUT_ROUNDING_ERROR && Math.abs(rectTop - tabTranslation.y - top) <= MAX_LAYOUT_ROUNDING_ERROR) {
11643 left = rectLeft;
11644 top = rectTop;
11645 }
11646 width = computedWidth;
11647 height = computedHeight;
11648 right = tabsListElement.scrollWidth - left - width;
11649 bottom = tabsListElement.scrollHeight - top - height;
11650 }
11651 }
11652 const activeTabPosition = isTabSelected ? {
11653 left,
11654 right,
11655 top,
11656 bottom
11657 } : null;
11658 const activeTabSize = isTabSelected ? {
11659 width,
11660 height
11661 } : null;
11662 const style = isTabSelected ? {
11663 [activeTabLeft]: `${left}px`,
11664 [activeTabRight]: `${right}px`,
11665 [activeTabTop]: `${top}px`,
11666 [activeTabBottom]: `${bottom}px`,
11667 [activeTabWidth]: `${width}px`,
11668 [activeTabHeight]: `${height}px`
11669 } : void 0;
11670 const displayIndicator = isTabSelected && width > 0 && height > 0;
11671 const state = {
11672 orientation,
11673 activeTabPosition,
11674 activeTabSize,
11675 tabActivationDirection
11676 };
11677 const element = useRenderElement("span", componentProps, {
11678 state,
11679 ref: forwardedRef,
11680 props: [{
11681 role: "presentation",
11682 style,
11683 hidden: !displayIndicator
11684 // do not display the indicator before the layout is settled
11685 }, elementProps, {
11686 suppressHydrationWarning: true
11687 }],
11688 stateAttributesMapping: stateAttributesMapping3
11689 });
11690 if (value == null) {
11691 return null;
11692 }
11693 return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(React77.Fragment, {
11694 children: [element, renderBeforeHydration && (_PrehydrationScript || (_PrehydrationScript = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(PrehydrationScript, {
11695 script
11696 })))]
11697 });
11698 });
11699 if (true) TabsIndicator.displayName = "TabsIndicator";
11700 function getLayoutOffset(element, ancestor) {
11701 const elementOffset = getCumulativeOffset(element);
11702 const ancestorOffset = getCumulativeOffset(ancestor);
11703 let left = elementOffset.left - ancestorOffset.left - ancestor.clientLeft;
11704 let top = elementOffset.top - ancestorOffset.top - ancestor.clientTop;
11705 let node = getParentNode(element);
11706 while (isHTMLElement(node) && node !== ancestor && !isLastTraversableNode(node)) {
11707 left -= node.scrollLeft;
11708 top -= node.scrollTop;
11709 node = getParentNode(node);
11710 }
11711 return {
11712 left,
11713 top
11714 };
11715 }
11716 function getCumulativeOffset(element) {
11717 let left = 0;
11718 let top = 0;
11719 let currentElement = element;
11720 while (currentElement != null) {
11721 left += currentElement.offsetLeft;
11722 top += currentElement.offsetTop;
11723 const offsetParent = currentElement.offsetParent;
11724 if (offsetParent != null) {
11725 left += offsetParent.clientLeft;
11726 top += offsetParent.clientTop;
11727 }
11728 currentElement = offsetParent;
11729 }
11730 return {
11731 left,
11732 top
11733 };
11734 }
11735 function getActiveTabTranslation(element) {
11736 const computedStyle = getWindow(element).getComputedStyle(element);
11737 const {
11738 x: x2,
11739 y: y2
11740 } = getElementTransform(element, computedStyle);
11741 let translateX = x2;
11742 let translateY = y2;
11743 const {
11744 translate: translate2
11745 } = computedStyle;
11746 if (translate2 && translate2 !== "none") {
11747 const parts = translate2.split(" ");
11748 translateX += resolveTranslateLength(parts[0], element.offsetWidth);
11749 translateY += resolveTranslateLength(parts[1], element.offsetHeight);
11750 }
11751 return {
11752 x: translateX,
11753 y: translateY
11754 };
11755 }
11756 function resolveTranslateLength(value, referenceSize) {
11757 if (!value) {
11758 return 0;
11759 }
11760 const numeric = parseFloat(value);
11761 if (!Number.isFinite(numeric)) {
11762 return 0;
11763 }
11764 return value.endsWith("%") ? numeric / 100 * referenceSize : numeric;
11765 }
11766
11767 // node_modules/@base-ui/react/tabs/panel/TabsPanel.mjs
11768 var React78 = __toESM(require_react(), 1);
11769
11770 // node_modules/@base-ui/react/tabs/panel/TabsPanelDataAttributes.mjs
11771 var index2 = "data-index";
11772 var startingStyle3 = TransitionStatusDataAttributes_exports.startingStyle;
11773 var endingStyle3 = TransitionStatusDataAttributes_exports.endingStyle;
11774
11775 // node_modules/@base-ui/react/tabs/panel/TabsPanel.mjs
11776 var stateAttributesMapping4 = {
11777 ...tabsStateAttributesMapping,
11778 ...transitionStatusMapping
11779 };
11780 var TabsPanel = /* @__PURE__ */ React78.forwardRef(function TabsPanel2(componentProps, forwardedRef) {
11781 const {
11782 className,
11783 value,
11784 render: render4,
11785 keepMounted = false,
11786 style,
11787 ...elementProps
11788 } = componentProps;
11789 const {
11790 value: selectedValue,
11791 getTabIdByPanelValue,
11792 orientation,
11793 tabActivationDirection,
11794 registerMountedTabPanel
11795 } = useTabsRootContext();
11796 const id = useBaseUiId();
11797 const {
11798 ref: listItemRef,
11799 index: index3
11800 } = useCompositeListItem();
11801 const open3 = value === selectedValue;
11802 const {
11803 mounted,
11804 transitionStatus,
11805 setMounted
11806 } = useTransitionStatus(open3);
11807 const hidden = !mounted;
11808 const correspondingTabId = getTabIdByPanelValue(value);
11809 const state = {
11810 hidden,
11811 orientation,
11812 tabActivationDirection,
11813 transitionStatus
11814 };
11815 const panelRef = React78.useRef(null);
11816 const element = useRenderElement("div", componentProps, {
11817 state,
11818 ref: [forwardedRef, listItemRef, panelRef],
11819 props: [{
11820 "aria-labelledby": correspondingTabId,
11821 hidden,
11822 id,
11823 role: "tabpanel",
11824 tabIndex: open3 ? 0 : -1,
11825 inert: inertValue(!open3),
11826 // Computed key: a plain literal key fails the DOM-props excess property check.
11827 [index2]: index3
11828 }, elementProps],
11829 stateAttributesMapping: stateAttributesMapping4
11830 });
11831 useOpenChangeComplete({
11832 open: open3,
11833 ref: panelRef,
11834 onComplete() {
11835 if (!open3) {
11836 setMounted(false);
11837 }
11838 }
11839 });
11840 useIsoLayoutEffect(() => {
11841 if (id == null || hidden && !keepMounted) {
11842 return void 0;
11843 }
11844 return registerMountedTabPanel(value, id);
11845 }, [hidden, keepMounted, value, id, registerMountedTabPanel]);
11846 const shouldRender = keepMounted || mounted;
11847 if (!shouldRender) {
11848 return null;
11849 }
11850 return element;
11851 });
11852 if (true) TabsPanel.displayName = "TabsPanel";
11853
11854 // node_modules/@base-ui/react/tabs/list/TabsList.mjs
11855 var React79 = __toESM(require_react(), 1);
11856 var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1);
11857 var TabsList = /* @__PURE__ */ React79.forwardRef(function TabsList2(componentProps, forwardedRef) {
11858 const {
11859 activateOnFocus = false,
11860 className,
11861 loopFocus = true,
11862 render: render4,
11863 style,
11864 ...elementProps
11865 } = componentProps;
11866 const {
11867 orientation,
11868 setTabMap,
11869 tabActivationDirection
11870 } = useTabsRootContext();
11871 const [highlightedTabIndex, setHighlightedTabIndex] = React79.useState(0);
11872 const [tabsListElement, setTabsListElement] = React79.useState(null);
11873 const indicatorUpdateListenersRef = React79.useRef(/* @__PURE__ */ new Set());
11874 const tabResizeObserverElementsRef = React79.useRef(/* @__PURE__ */ new Set());
11875 const resizeObserverRef = React79.useRef(null);
11876 useIsoLayoutEffect(() => {
11877 if (typeof ResizeObserver === "undefined") {
11878 return void 0;
11879 }
11880 const resizeObserver = new ResizeObserver(() => {
11881 indicatorUpdateListenersRef.current.forEach((listener) => {
11882 listener();
11883 });
11884 });
11885 resizeObserverRef.current = resizeObserver;
11886 if (tabsListElement) {
11887 resizeObserver.observe(tabsListElement);
11888 }
11889 tabResizeObserverElementsRef.current.forEach((element) => {
11890 resizeObserver.observe(element);
11891 });
11892 return () => {
11893 resizeObserver.disconnect();
11894 resizeObserverRef.current = null;
11895 };
11896 }, [tabsListElement]);
11897 const registerIndicatorUpdateListener = useStableCallback((listener) => {
11898 indicatorUpdateListenersRef.current.add(listener);
11899 return () => {
11900 indicatorUpdateListenersRef.current.delete(listener);
11901 };
11902 });
11903 const registerTabResizeObserverElement = useStableCallback((element) => {
11904 tabResizeObserverElementsRef.current.add(element);
11905 resizeObserverRef.current?.observe(element);
11906 return () => {
11907 tabResizeObserverElementsRef.current.delete(element);
11908 resizeObserverRef.current?.unobserve(element);
11909 };
11910 });
11911 const state = {
11912 orientation,
11913 tabActivationDirection
11914 };
11915 const defaultProps = {
11916 "aria-orientation": orientation === "vertical" ? "vertical" : void 0,
11917 role: "tablist"
11918 };
11919 const tabsListContextValue = React79.useMemo(() => ({
11920 activateOnFocus,
11921 registerIndicatorUpdateListener,
11922 registerTabResizeObserverElement,
11923 tabsListElement
11924 }), [activateOnFocus, registerIndicatorUpdateListener, registerTabResizeObserverElement, tabsListElement]);
11925 return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(TabsListContext.Provider, {
11926 value: tabsListContextValue,
11927 children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(CompositeRoot, {
11928 render: render4,
11929 className,
11930 style,
11931 state,
11932 refs: [forwardedRef, setTabsListElement],
11933 props: [defaultProps, elementProps],
11934 stateAttributesMapping: tabsStateAttributesMapping,
11935 highlightedIndex: highlightedTabIndex,
11936 enableHomeAndEndKeys: true,
11937 loopFocus,
11938 orientation,
11939 onHighlightedIndexChange: setHighlightedTabIndex,
11940 onMapChange: setTabMap,
11941 disabledIndices: EMPTY_ARRAY
11942 })
11943 });
11944 });
11945 if (true) TabsList.displayName = "TabsList";
11946
11947 // node_modules/@base-ui/react/tooltip/index.parts.mjs
11948 var index_parts_exports4 = {};
11949 __export(index_parts_exports4, {
11950 Arrow: () => TooltipArrow,
11951 Handle: () => TooltipHandle,
11952 Popup: () => TooltipPopup,
11953 Portal: () => TooltipPortal,
11954 Positioner: () => TooltipPositioner,
11955 Provider: () => TooltipProvider,
11956 Root: () => TooltipRoot,
11957 Trigger: () => TooltipTrigger,
11958 Viewport: () => TooltipViewport,
11959 createHandle: () => createTooltipHandle
11960 });
11961
11962 // node_modules/@base-ui/react/tooltip/root/TooltipRoot.mjs
11963 var React82 = __toESM(require_react(), 1);
11964
11965 // node_modules/@base-ui/react/tooltip/root/TooltipRootContext.mjs
11966 var React80 = __toESM(require_react(), 1);
11967 var TooltipRootContext = /* @__PURE__ */ React80.createContext(void 0);
11968 if (true) TooltipRootContext.displayName = "TooltipRootContext";
11969 function useTooltipRootContext(optional) {
11970 const context = React80.useContext(TooltipRootContext);
11971 if (context === void 0 && !optional) {
11972 throw new Error(true ? "Base UI: TooltipRootContext is missing. Tooltip parts must be placed within <Tooltip.Root>." : formatErrorMessage_default(72));
11973 }
11974 return context;
11975 }
11976
11977 // node_modules/@base-ui/react/tooltip/store/TooltipStore.mjs
11978 var React81 = __toESM(require_react(), 1);
11979 var selectors2 = {
11980 ...popupStoreSelectors,
11981 disabled: (state) => state.disabled,
11982 instantType: (state) => state.instantType,
11983 isInstantPhase: (state) => state.isInstantPhase,
11984 trackCursorAxis: (state) => state.trackCursorAxis,
11985 disableHoverablePopup: (state) => state.disableHoverablePopup,
11986 lastOpenChangeReason: (state) => state.openChangeReason,
11987 closeOnClick: (state) => state.closeOnClick,
11988 closeDelay: (state) => state.closeDelay,
11989 adaptiveOrigin: (state) => state.adaptiveOrigin
11990 };
11991 var TooltipStore = class extends ReactStore {
11992 constructor(initialState, floatingId, nested) {
11993 const triggerElements = new PopupTriggerMap();
11994 super(createInitialState(initialState, triggerElements, floatingId, nested), createInitialContext(triggerElements), selectors2);
11995 }
11996 setOpen = (nextOpen, eventDetails) => {
11997 applyPopupOpenChange(this, nextOpen, eventDetails, {
11998 extraState: {
11999 openChangeReason: eventDetails.reason
12000 }
12001 });
12002 };
12003 // Used by trigger clicks to clear a delayed hover open without reporting a public open-state change.
12004 cancelPendingOpen(event) {
12005 this.state.floatingRootContext.dispatchOpenChange(false, createChangeEventDetails(reason_parts_exports.triggerPress, event));
12006 }
12007 };
12008 function createNullTooltipStore() {
12009 const triggerElements = new PopupTriggerMap();
12010 const store2 = new NullStore(Object.freeze(createInitialState(void 0, triggerElements)), Object.freeze(createInitialContext(triggerElements)), selectors2);
12011 return Object.assign(store2, {
12012 setOpen: NOOP,
12013 cancelPendingOpen: NOOP
12014 });
12015 }
12016 function createInitialState(initialState, triggerElements, floatingId, nested = false) {
12017 const state = {
12018 ...createInitialPopupStoreState(triggerElements, floatingId, nested),
12019 disabled: false,
12020 instantType: void 0,
12021 isInstantPhase: false,
12022 trackCursorAxis: "none",
12023 disableHoverablePopup: false,
12024 openChangeReason: null,
12025 closeOnClick: true,
12026 closeDelay: 0,
12027 adaptiveOrigin: void 0,
12028 ...initialState
12029 };
12030 return state;
12031 }
12032 function createInitialContext(triggerElements) {
12033 return {
12034 popupRef: /* @__PURE__ */ React81.createRef(),
12035 onOpenChange: void 0,
12036 onOpenChangeComplete: void 0,
12037 triggerElements
12038 };
12039 }
12040
12041 // node_modules/@base-ui/react/tooltip/root/TooltipRoot.mjs
12042 var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1);
12043 var TooltipRoot = fastComponent(function TooltipRoot2(props) {
12044 const {
12045 disabled: disabled2 = false,
12046 defaultOpen = false,
12047 open: openProp,
12048 disableHoverablePopup = false,
12049 trackCursorAxis = "none",
12050 actionsRef,
12051 onOpenChange,
12052 onOpenChangeComplete,
12053 handle,
12054 triggerId: triggerIdProp,
12055 defaultTriggerId: defaultTriggerIdProp = null,
12056 children
12057 } = props;
12058 const store2 = usePopupRootStore((floatingId, nested) => new TooltipStore({
12059 open: defaultOpen,
12060 openProp,
12061 activeTriggerId: defaultTriggerIdProp,
12062 triggerIdProp
12063 }, floatingId, nested));
12064 store2.useControlledProp("openProp", openProp);
12065 store2.useControlledProp("triggerIdProp", triggerIdProp);
12066 store2.useContextCallback("onOpenChange", onOpenChange);
12067 store2.useContextCallback("onOpenChangeComplete", onOpenChangeComplete);
12068 const openState = store2.useState("open");
12069 const open3 = !disabled2 && openState;
12070 const activeTriggerId = store2.useState("activeTriggerId");
12071 const mounted = store2.useState("mounted");
12072 const payload = store2.useState("payload");
12073 store2.useSyncedValues({
12074 trackCursorAxis,
12075 disableHoverablePopup,
12076 disabled: disabled2
12077 });
12078 useImplicitActiveTrigger(store2, {
12079 closeOnActiveTriggerUnmount: true
12080 });
12081 const {
12082 forceUnmount,
12083 transitionStatus
12084 } = useOpenStateTransitions(open3, store2);
12085 const isInstantPhase = store2.useState("isInstantPhase");
12086 const instantType = store2.useState("instantType");
12087 const lastOpenChangeReason = store2.useState("lastOpenChangeReason");
12088 const previousInstantTypeRef = React82.useRef(null);
12089 useIsoLayoutEffect(() => {
12090 if (openState && disabled2) {
12091 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.disabled));
12092 }
12093 }, [openState, disabled2, store2]);
12094 useIsoLayoutEffect(() => {
12095 if (transitionStatus === "ending" && lastOpenChangeReason === reason_parts_exports.none || transitionStatus !== "ending" && isInstantPhase) {
12096 if (instantType !== "delay") {
12097 previousInstantTypeRef.current = instantType;
12098 }
12099 store2.set("instantType", "delay");
12100 } else if (previousInstantTypeRef.current !== null) {
12101 store2.set("instantType", previousInstantTypeRef.current);
12102 previousInstantTypeRef.current = null;
12103 }
12104 }, [transitionStatus, isInstantPhase, lastOpenChangeReason, instantType, store2]);
12105 useIsoLayoutEffect(() => {
12106 if (open3) {
12107 if (activeTriggerId == null) {
12108 store2.set("payload", void 0);
12109 }
12110 }
12111 }, [store2, activeTriggerId, open3]);
12112 React82.useImperativeHandle(actionsRef, () => ({
12113 unmount: forceUnmount,
12114 close: () => store2.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction))
12115 }), [forceUnmount, store2]);
12116 const shouldRenderInteractions = open3 || mounted || !disabled2 && trackCursorAxis !== "none";
12117 return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(TooltipRootContext.Provider, {
12118 value: store2,
12119 children: [handle && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(PopupHandleAttachment, {
12120 handle,
12121 store: store2
12122 }), shouldRenderInteractions && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(TooltipInteractions, {
12123 store: store2,
12124 disabled: disabled2,
12125 trackCursorAxis
12126 }), typeof children === "function" ? children({
12127 payload
12128 }) : children]
12129 });
12130 });
12131 if (true) TooltipRoot.displayName = "TooltipRoot";
12132 function TooltipInteractions({
12133 store: store2,
12134 disabled: disabled2,
12135 trackCursorAxis
12136 }) {
12137 const floatingRootContext = store2.useState("floatingRootContext");
12138 const dismiss = useDismiss(floatingRootContext, {
12139 enabled: !disabled2,
12140 referencePress: () => store2.select("closeOnClick")
12141 });
12142 const clientPoint = useClientPoint(floatingRootContext, {
12143 enabled: !disabled2 && trackCursorAxis !== "none",
12144 axis: trackCursorAxis === "none" ? void 0 : trackCursorAxis
12145 });
12146 const triggerProps = React82.useMemo(() => mergeProps(clientPoint.reference, dismiss.reference), [clientPoint.reference, dismiss.reference]);
12147 usePopupInteractionProps(store2, {
12148 activeTriggerProps: triggerProps,
12149 inactiveTriggerProps: triggerProps,
12150 popupProps: dismiss.floating ?? EMPTY_OBJECT
12151 });
12152 return null;
12153 }
12154
12155 // node_modules/@base-ui/react/tooltip/trigger/TooltipTrigger.mjs
12156 var React84 = __toESM(require_react(), 1);
12157
12158 // node_modules/@base-ui/react/tooltip/provider/TooltipProviderContext.mjs
12159 var React83 = __toESM(require_react(), 1);
12160 var TooltipProviderContext = /* @__PURE__ */ React83.createContext(void 0);
12161 if (true) TooltipProviderContext.displayName = "TooltipProviderContext";
12162 function useTooltipProviderContext() {
12163 return React83.useContext(TooltipProviderContext);
12164 }
12165
12166 // node_modules/@base-ui/react/tooltip/utils/constants.mjs
12167 var OPEN_DELAY = 600;
12168
12169 // node_modules/@base-ui/react/tooltip/trigger/TooltipTrigger.mjs
12170 var TOOLTIP_TRIGGER_IDENTIFIER = "data-base-ui-tooltip-trigger";
12171 function getTargetElement(event) {
12172 if ("composedPath" in event) {
12173 const path = event.composedPath();
12174 for (let i = 0; i < path.length; i += 1) {
12175 const element = path[i];
12176 if (isElement(element)) {
12177 return element;
12178 }
12179 }
12180 }
12181 const target = event.target;
12182 if (isElement(target)) {
12183 return target;
12184 }
12185 return null;
12186 }
12187 function closestEnabledTooltipTrigger(element) {
12188 let current = element;
12189 while (current) {
12190 const trigger = current.closest(`[${TOOLTIP_TRIGGER_IDENTIFIER}]`);
12191 if (trigger) {
12192 return trigger;
12193 }
12194 const root = current.getRootNode();
12195 current = "host" in root && isElement(root.host) ? root.host : null;
12196 }
12197 return null;
12198 }
12199 var TooltipTrigger = fastComponentRef(function TooltipTrigger2(componentProps, forwardedRef) {
12200 const {
12201 render: render4,
12202 className,
12203 style,
12204 handle,
12205 payload,
12206 disabled: disabledProp,
12207 delay,
12208 closeOnClick = true,
12209 closeDelay,
12210 id: idProp,
12211 ...elementProps
12212 } = componentProps;
12213 const rootContext = useTooltipRootContext(true);
12214 const handleStore = usePopupHandleStore(handle);
12215 const store2 = handleStore ?? rootContext;
12216 if (!store2) {
12217 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));
12218 }
12219 const thisTriggerId = useBaseUiId(idProp);
12220 const isTriggerActive = store2.useState("isTriggerActive", thisTriggerId);
12221 const isOpenedByThisTrigger = store2.useState("isOpenedByTrigger", thisTriggerId);
12222 const floatingRootContext = store2.useState("floatingRootContext");
12223 const triggerElementRef = React84.useRef(null);
12224 const closeDelayWithDefault = closeDelay ?? 0;
12225 const {
12226 registerTrigger,
12227 isMountedByThisTrigger
12228 } = useTriggerDataForwarding(thisTriggerId, triggerElementRef, store2, {
12229 payload,
12230 closeOnClick,
12231 closeDelay: closeDelayWithDefault
12232 });
12233 const providerDelay = useTooltipProviderContext();
12234 const {
12235 activeIdRef,
12236 delayRef,
12237 isInstantPhase,
12238 hasProvider
12239 } = useDelayGroup(floatingRootContext, {
12240 open: isOpenedByThisTrigger
12241 });
12242 const hoverInteraction = useHoverInteractionSharedState(floatingRootContext);
12243 store2.useSyncedValue("isInstantPhase", isInstantPhase);
12244 const rootDisabled = store2.useState("disabled");
12245 const disabled2 = disabledProp ?? rootDisabled;
12246 const disabledRef = useValueAsRef(disabled2);
12247 const trackCursorAxis = store2.useState("trackCursorAxis");
12248 const disableHoverablePopup = store2.useState("disableHoverablePopup");
12249 const isNestedTriggerHoveredRef = React84.useRef(false);
12250 const nestedTriggerOpenTimeout = useTimeout();
12251 const pointerTypeRef = React84.useRef(void 0);
12252 function getOpenDelay() {
12253 if (hasProvider && activeIdRef.current != null) {
12254 return 0;
12255 }
12256 return delay ?? providerDelay ?? OPEN_DELAY;
12257 }
12258 function isEnabledNestedTriggerTarget(target) {
12259 const triggerEl = triggerElementRef.current;
12260 if (!triggerEl || !target) {
12261 return false;
12262 }
12263 const nearestTrigger = closestEnabledTooltipTrigger(target);
12264 return nearestTrigger !== null && nearestTrigger !== triggerEl && contains(triggerEl, nearestTrigger);
12265 }
12266 function detectNestedTriggerHover(target) {
12267 const nestedTriggerHovered = isEnabledNestedTriggerTarget(target);
12268 isNestedTriggerHoveredRef.current = nestedTriggerHovered;
12269 if (nestedTriggerHovered) {
12270 hoverInteraction.openChangeTimeout.clear();
12271 hoverInteraction.restTimeout.clear();
12272 hoverInteraction.restTimeoutPending = false;
12273 nestedTriggerOpenTimeout.clear();
12274 }
12275 return nestedTriggerHovered;
12276 }
12277 const hoverProps = useHoverReferenceInteraction(floatingRootContext, {
12278 enabled: !disabled2,
12279 mouseOnly: true,
12280 move: false,
12281 handleClose: !disableHoverablePopup && trackCursorAxis !== "both" ? safePolygon() : null,
12282 restMs: getOpenDelay,
12283 delay() {
12284 if (closeDelay == null && hasProvider) {
12285 return {
12286 close: getDelay(delayRef.current, "close")
12287 };
12288 }
12289 return {
12290 close: closeDelayWithDefault
12291 };
12292 },
12293 triggerElementRef,
12294 isActiveTrigger: isTriggerActive,
12295 isClosing: () => store2.select("transitionStatus") === "ending",
12296 shouldOpen() {
12297 return !isNestedTriggerHoveredRef.current;
12298 }
12299 });
12300 const focusProps = useFocus(floatingRootContext, {
12301 enabled: !disabled2
12302 }).reference;
12303 const handleNestedTriggerHover = (event) => {
12304 const wasNestedTriggerHovered = isNestedTriggerHoveredRef.current;
12305 const target = getTargetElement(event);
12306 const nestedTriggerHovered = detectNestedTriggerHover(target);
12307 const triggerEl = triggerElementRef.current;
12308 const targetInsideTrigger = triggerEl && target && contains(triggerEl, target);
12309 if (nestedTriggerHovered && store2.select("open") && store2.select("lastOpenChangeReason") === reason_parts_exports.triggerHover) {
12310 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
12311 return;
12312 }
12313 if (wasNestedTriggerHovered && !nestedTriggerHovered && targetInsideTrigger && !disabledRef.current && !store2.select("open") && triggerEl && // Match the hover hook's non-strict mouse fallback for mouse-only event sequences.
12314 isMouseLikePointerType(pointerTypeRef.current)) {
12315 const open3 = () => {
12316 if (!isNestedTriggerHoveredRef.current && !disabledRef.current && !store2.select("open")) {
12317 store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerEl));
12318 }
12319 };
12320 const openDelay = getOpenDelay();
12321 if (openDelay === 0) {
12322 nestedTriggerOpenTimeout.clear();
12323 open3();
12324 } else {
12325 nestedTriggerOpenTimeout.start(openDelay, open3);
12326 }
12327 }
12328 };
12329 const rootTriggerProps = store2.useState("triggerProps", isMountedByThisTrigger);
12330 const shouldApplyRootTriggerProps = isMountedByThisTrigger || trackCursorAxis !== "none";
12331 const state = {
12332 open: isOpenedByThisTrigger
12333 };
12334 const element = useRenderElement("button", componentProps, {
12335 state,
12336 ref: [forwardedRef, registerTrigger, triggerElementRef],
12337 props: [hoverProps, focusProps, shouldApplyRootTriggerProps ? rootTriggerProps : void 0, {
12338 onMouseOver(event) {
12339 handleNestedTriggerHover(event.nativeEvent);
12340 },
12341 onFocus(event) {
12342 if (isEnabledNestedTriggerTarget(getTargetElement(event.nativeEvent))) {
12343 event.preventBaseUIHandler();
12344 }
12345 },
12346 onMouseLeave() {
12347 isNestedTriggerHoveredRef.current = false;
12348 nestedTriggerOpenTimeout.clear();
12349 pointerTypeRef.current = void 0;
12350 },
12351 onPointerEnter(event) {
12352 pointerTypeRef.current = event.pointerType;
12353 },
12354 onPointerDown(event) {
12355 pointerTypeRef.current = event.pointerType;
12356 store2.set("closeOnClick", closeOnClick);
12357 if (closeOnClick && !store2.select("open")) {
12358 store2.cancelPendingOpen(event.nativeEvent);
12359 }
12360 },
12361 onClick(event) {
12362 if (closeOnClick && !store2.select("open")) {
12363 store2.cancelPendingOpen(event.nativeEvent);
12364 }
12365 },
12366 id: thisTriggerId,
12367 [triggerDisabled]: disabled2 ? "" : void 0,
12368 [TOOLTIP_TRIGGER_IDENTIFIER]: disabled2 ? void 0 : ""
12369 }, elementProps],
12370 stateAttributesMapping: triggerOpenStateMapping2
12371 });
12372 return element;
12373 });
12374 if (true) TooltipTrigger.displayName = "TooltipTrigger";
12375
12376 // node_modules/@base-ui/react/tooltip/portal/TooltipPortal.mjs
12377 var React86 = __toESM(require_react(), 1);
12378
12379 // node_modules/@base-ui/react/tooltip/portal/TooltipPortalContext.mjs
12380 var React85 = __toESM(require_react(), 1);
12381 var TooltipPortalContext = /* @__PURE__ */ React85.createContext(void 0);
12382 if (true) TooltipPortalContext.displayName = "TooltipPortalContext";
12383 function useTooltipPortalContext() {
12384 const value = React85.useContext(TooltipPortalContext);
12385 if (value === void 0) {
12386 throw new Error(true ? "Base UI: <Tooltip.Portal> is missing." : formatErrorMessage_default(70));
12387 }
12388 return value;
12389 }
12390
12391 // node_modules/@base-ui/react/tooltip/portal/TooltipPortal.mjs
12392 var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1);
12393 var TooltipPortal = /* @__PURE__ */ React86.forwardRef(function TooltipPortal2(props, forwardedRef) {
12394 const {
12395 keepMounted = false,
12396 ...portalProps
12397 } = props;
12398 const store2 = useTooltipRootContext();
12399 const mounted = store2.useState("mounted");
12400 const shouldRender = mounted || keepMounted;
12401 if (!shouldRender) {
12402 return null;
12403 }
12404 return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(TooltipPortalContext.Provider, {
12405 value: keepMounted,
12406 children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(FloatingPortalLite, {
12407 ref: forwardedRef,
12408 ...portalProps
12409 })
12410 });
12411 });
12412 if (true) TooltipPortal.displayName = "TooltipPortal";
12413
12414 // node_modules/@base-ui/react/tooltip/positioner/TooltipPositioner.mjs
12415 var React88 = __toESM(require_react(), 1);
12416
12417 // node_modules/@base-ui/react/tooltip/positioner/TooltipPositionerContext.mjs
12418 var React87 = __toESM(require_react(), 1);
12419 var TooltipPositionerContext = /* @__PURE__ */ React87.createContext(void 0);
12420 if (true) TooltipPositionerContext.displayName = "TooltipPositionerContext";
12421 function useTooltipPositionerContext() {
12422 const context = React87.useContext(TooltipPositionerContext);
12423 if (context === void 0) {
12424 throw new Error(true ? "Base UI: TooltipPositionerContext is missing. TooltipPositioner parts must be placed within <Tooltip.Positioner>." : formatErrorMessage_default(71));
12425 }
12426 return context;
12427 }
12428
12429 // node_modules/@base-ui/react/tooltip/positioner/TooltipPositioner.mjs
12430 var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1);
12431 var TooltipPositioner = /* @__PURE__ */ React88.forwardRef(function TooltipPositioner2(componentProps, forwardedRef) {
12432 const {
12433 render: render4,
12434 className,
12435 anchor,
12436 positionMethod = "absolute",
12437 side = "top",
12438 align = "center",
12439 sideOffset = 0,
12440 alignOffset = 0,
12441 collisionBoundary = "clipping-ancestors",
12442 collisionPadding = 5,
12443 arrowPadding = 5,
12444 sticky = false,
12445 disableAnchorTracking = false,
12446 collisionAvoidance = POPUP_COLLISION_AVOIDANCE,
12447 style,
12448 ...elementProps
12449 } = componentProps;
12450 const store2 = useTooltipRootContext();
12451 const keepMounted = useTooltipPortalContext();
12452 const open3 = store2.useState("open");
12453 const mounted = store2.useState("mounted");
12454 const trackCursorAxis = store2.useState("trackCursorAxis");
12455 const disableHoverablePopup = store2.useState("disableHoverablePopup");
12456 const floatingRootContext = store2.useState("floatingRootContext");
12457 const instantType = store2.useState("instantType");
12458 const transitionStatus = store2.useState("transitionStatus");
12459 const adaptiveOrigin2 = store2.useState("adaptiveOrigin");
12460 const positioning = useAnchorPositioning({
12461 anchor,
12462 positionMethod,
12463 floatingRootContext,
12464 mounted,
12465 side,
12466 sideOffset,
12467 align,
12468 alignOffset,
12469 collisionBoundary,
12470 collisionPadding,
12471 sticky,
12472 arrowPadding,
12473 disableAnchorTracking,
12474 keepMounted,
12475 collisionAvoidance,
12476 adaptiveOrigin: adaptiveOrigin2
12477 });
12478 const state = React88.useMemo(() => ({
12479 open: open3,
12480 side: positioning.side,
12481 align: positioning.align,
12482 anchorHidden: positioning.anchorHidden,
12483 instant: trackCursorAxis !== "none" ? "tracking-cursor" : instantType
12484 }), [open3, positioning.side, positioning.align, positioning.anchorHidden, trackCursorAxis, instantType]);
12485 const element = usePositioner(componentProps, state, {
12486 styles: positioning.positionerStyles,
12487 transitionStatus,
12488 props: elementProps,
12489 refs: [forwardedRef, store2.useStateSetter("positionerElement")],
12490 hidden: !mounted,
12491 inert: !open3 || trackCursorAxis === "both" || disableHoverablePopup
12492 });
12493 return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(TooltipPositionerContext.Provider, {
12494 value: positioning,
12495 children: element
12496 });
12497 });
12498 if (true) TooltipPositioner.displayName = "TooltipPositioner";
12499
12500 // node_modules/@base-ui/react/tooltip/popup/TooltipPopup.mjs
12501 var React89 = __toESM(require_react(), 1);
12502 var TooltipPopup = /* @__PURE__ */ React89.forwardRef(function TooltipPopup2(componentProps, forwardedRef) {
12503 const {
12504 render: render4,
12505 className,
12506 style,
12507 ...elementProps
12508 } = componentProps;
12509 const store2 = useTooltipRootContext();
12510 const {
12511 side,
12512 align
12513 } = useTooltipPositionerContext();
12514 const open3 = store2.useState("open");
12515 const instantType = store2.useState("instantType");
12516 const transitionStatus = store2.useState("transitionStatus");
12517 const popupProps = store2.useState("popupProps");
12518 const floatingContext = store2.useState("floatingRootContext");
12519 const disabled2 = store2.useState("disabled");
12520 const closeDelay = store2.useState("closeDelay");
12521 useOpenChangeComplete({
12522 open: open3,
12523 ref: store2.context.popupRef,
12524 onComplete() {
12525 if (open3) {
12526 store2.context.onOpenChangeComplete?.(true);
12527 }
12528 }
12529 });
12530 useHoverFloatingInteraction(floatingContext, {
12531 enabled: !disabled2,
12532 closeDelay
12533 });
12534 const setPopupElement = store2.useStateSetter("popupElement");
12535 const state = {
12536 open: open3,
12537 side,
12538 align,
12539 instant: instantType,
12540 transitionStatus
12541 };
12542 const element = useRenderElement("div", componentProps, {
12543 state,
12544 ref: [forwardedRef, store2.context.popupRef, setPopupElement],
12545 props: [FOCUSABLE_POPUP_PROPS, popupProps, getDisabledMountTransitionStyles(transitionStatus), elementProps],
12546 stateAttributesMapping: popupTransitionStateMapping
12547 });
12548 return element;
12549 });
12550 if (true) TooltipPopup.displayName = "TooltipPopup";
12551
12552 // node_modules/@base-ui/react/tooltip/arrow/TooltipArrow.mjs
12553 var React90 = __toESM(require_react(), 1);
12554 var TooltipArrow = /* @__PURE__ */ React90.forwardRef(function TooltipArrow2(componentProps, forwardedRef) {
12555 const {
12556 render: render4,
12557 className,
12558 style,
12559 ...elementProps
12560 } = componentProps;
12561 const store2 = useTooltipRootContext();
12562 const {
12563 arrowRef,
12564 side,
12565 align,
12566 arrowUncentered,
12567 arrowStyles
12568 } = useTooltipPositionerContext();
12569 const open3 = store2.useState("open");
12570 const instantType = store2.useState("instantType");
12571 const state = {
12572 open: open3,
12573 side,
12574 align,
12575 uncentered: arrowUncentered,
12576 instant: instantType
12577 };
12578 const element = useRenderElement("div", componentProps, {
12579 state,
12580 ref: [forwardedRef, arrowRef],
12581 props: [{
12582 style: arrowStyles,
12583 "aria-hidden": true
12584 }, elementProps],
12585 stateAttributesMapping: popupStateMapping
12586 });
12587 return element;
12588 });
12589 if (true) TooltipArrow.displayName = "TooltipArrow";
12590
12591 // node_modules/@base-ui/react/tooltip/provider/TooltipProvider.mjs
12592 var React91 = __toESM(require_react(), 1);
12593 var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1);
12594 var TooltipProvider = function TooltipProvider2(props) {
12595 const {
12596 delay,
12597 closeDelay,
12598 timeout = 400
12599 } = props;
12600 const delayValue = React91.useMemo(() => ({
12601 open: delay,
12602 close: closeDelay
12603 }), [delay, closeDelay]);
12604 return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(TooltipProviderContext.Provider, {
12605 value: delay,
12606 children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(FloatingDelayGroup, {
12607 delay: delayValue,
12608 timeoutMs: timeout,
12609 children: props.children
12610 })
12611 });
12612 };
12613 if (true) TooltipProvider.displayName = "TooltipProvider";
12614
12615 // node_modules/@base-ui/react/tooltip/viewport/TooltipViewport.mjs
12616 var React92 = __toESM(require_react(), 1);
12617 var TooltipViewport = /* @__PURE__ */ React92.forwardRef(function TooltipViewport2(componentProps, forwardedRef) {
12618 const {
12619 render: render4,
12620 className,
12621 style,
12622 children,
12623 ...elementProps
12624 } = componentProps;
12625 const store2 = useTooltipRootContext();
12626 const positioner = useTooltipPositionerContext();
12627 const instantType = store2.useState("instantType");
12628 const {
12629 children: childrenToRender,
12630 state: viewportState
12631 } = usePopupViewport({
12632 store: store2,
12633 side: positioner.side,
12634 children
12635 });
12636 const state = {
12637 activationDirection: viewportState.activationDirection,
12638 transitioning: viewportState.transitioning,
12639 instant: instantType
12640 };
12641 return useRenderElement("div", componentProps, {
12642 state,
12643 ref: forwardedRef,
12644 props: [elementProps, {
12645 children: childrenToRender
12646 }],
12647 stateAttributesMapping: popupViewportStateMapping
12648 });
12649 });
12650 if (true) TooltipViewport.displayName = "TooltipViewport";
12651
12652 // node_modules/@base-ui/react/tooltip/store/TooltipHandle.mjs
12653 var TooltipHandle = class extends BasePopupHandle {
12654 constructor() {
12655 super(createNullTooltipStore(), "Tooltip");
12656 }
12657 /**
12658 * Opens the tooltip and associates it with the trigger with the given id.
12659 *
12660 * This method should only be called in an event handler or an effect (not during rendering).
12661 *
12662 * @param triggerId ID of the trigger to associate with the tooltip. The trigger must be a matching
12663 * `Tooltip.Trigger` with this handle passed as a prop.
12664 */
12665 open(triggerId) {
12666 this.openByTrigger(triggerId);
12667 }
12668 /**
12669 * Closes the tooltip.
12670 *
12671 * This method should only be called in an event handler or an effect (not during rendering).
12672 */
12673 close() {
12674 this.closePopup();
12675 }
12676 /**
12677 * Whether the tooltip is currently open. Returns `false` while no root is attached to the handle.
12678 */
12679 get isOpen() {
12680 return this.attachedStore?.select("open") ?? false;
12681 }
12682 };
12683 function createTooltipHandle() {
12684 return new TooltipHandle();
12685 }
12686
12687 // node_modules/@base-ui/react/use-render/useRender.mjs
12688 function useRender(params) {
12689 return useRenderElement(params.defaultTagName ?? "div", params, params);
12690 }
12691
12692 // packages/ui/build-module/text/text.mjs
12693 var import_element10 = __toESM(require_element(), 1);
12694 var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
12695 function getRuntime() {
12696 const globalScope = globalThis;
12697 if (globalScope.__wpStyleRuntime) {
12698 return globalScope.__wpStyleRuntime;
12699 }
12700 globalScope.__wpStyleRuntime = {
12701 documents: /* @__PURE__ */ new Map(),
12702 styles: /* @__PURE__ */ new Map(),
12703 injectedStyles: /* @__PURE__ */ new WeakMap()
12704 };
12705 if (typeof document !== "undefined") {
12706 registerDocument(document);
12707 }
12708 return globalScope.__wpStyleRuntime;
12709 }
12710 function documentContainsStyleHash(targetDocument, hash) {
12711 if (!targetDocument.head) {
12712 return false;
12713 }
12714 for (const style of targetDocument.head.querySelectorAll(
12715 `style[${STYLE_HASH_ATTRIBUTE}]`
12716 )) {
12717 if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
12718 return true;
12719 }
12720 }
12721 return false;
12722 }
12723 function injectStyle(targetDocument, hash, css) {
12724 if (!targetDocument.head) {
12725 return;
12726 }
12727 const runtime = getRuntime();
12728 let injectedStyles = runtime.injectedStyles.get(targetDocument);
12729 if (!injectedStyles) {
12730 injectedStyles = /* @__PURE__ */ new Set();
12731 runtime.injectedStyles.set(targetDocument, injectedStyles);
12732 }
12733 if (injectedStyles.has(hash)) {
12734 return;
12735 }
12736 if (documentContainsStyleHash(targetDocument, hash)) {
12737 injectedStyles.add(hash);
12738 return;
12739 }
12740 const style = targetDocument.createElement("style");
12741 style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
12742 style.appendChild(targetDocument.createTextNode(css));
12743 targetDocument.head.appendChild(style);
12744 injectedStyles.add(hash);
12745 }
12746 function registerDocument(targetDocument) {
12747 const runtime = getRuntime();
12748 runtime.documents.set(
12749 targetDocument,
12750 (runtime.documents.get(targetDocument) ?? 0) + 1
12751 );
12752 for (const [hash, css] of runtime.styles) {
12753 injectStyle(targetDocument, hash, css);
12754 }
12755 return () => {
12756 const count = runtime.documents.get(targetDocument);
12757 if (count === void 0) {
12758 return;
12759 }
12760 if (count <= 1) {
12761 runtime.documents.delete(targetDocument);
12762 return;
12763 }
12764 runtime.documents.set(targetDocument, count - 1);
12765 };
12766 }
12767 function registerStyle(hash, css) {
12768 const runtime = getRuntime();
12769 runtime.styles.set(hash, css);
12770 for (const targetDocument of runtime.documents.keys()) {
12771 injectStyle(targetDocument, hash, css);
12772 }
12773 }
12774 if (typeof process === "undefined" || true) {
12775 registerStyle("3167e7d116", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._83ed8a8da5dd50ea__text{text-wrap:pretty;margin:0}._14437cfb77831647__heading-2xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-2xl,32px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-emphasis,600);--_gcd-p-font-size:var(--wpds-typography-font-size-2xl,32px);--_gcd-p-line-height:var(--wpds-typography-line-height-2xl,40px);font-size:var(--wpds-typography-font-size-2xl,32px);line-height:var(--wpds-typography-line-height-2xl,40px)}._14437cfb77831647__heading-2xl,._3c78b7fa9b4072dd__heading-xl{font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-emphasis,600)}._3c78b7fa9b4072dd__heading-xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-emphasis,600);--_gcd-p-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-p-line-height:var(--wpds-typography-line-height-md,24px);font-size:var(--wpds-typography-font-size-xl,20px);line-height:var(--wpds-typography-line-height-md,24px)}.aa58f227716bcde2__heading-lg{--_gcd-heading-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-emphasis,600);--_gcd-p-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-lg,15px)}.aa58f227716bcde2__heading-lg,.fc4da56d8dfe52c4__heading-md{font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-emphasis,600);line-height:var(--wpds-typography-line-height-sm,20px)}.fc4da56d8dfe52c4__heading-md{--_gcd-heading-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-emphasis,600);--_gcd-p-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-md,13px)}.a9b78c7c82e8dff7__heading-sm{--_gcd-heading-font-size:var(--wpds-typography-font-size-xs,11px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-emphasis,600);--_gcd-p-font-size:var(--wpds-typography-font-size-xs,11px);--_gcd-p-line-height:var(--wpds-typography-line-height-xs,16px);font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-xs,11px);font-weight:var(--wpds-typography-font-weight-emphasis,600);line-height:var(--wpds-typography-line-height-xs,16px);text-transform:uppercase}._305ff559e52180d5__body-xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-default,400);--_gcd-p-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-p-line-height:var(--wpds-typography-line-height-xl,32px);font-size:var(--wpds-typography-font-size-xl,20px);line-height:var(--wpds-typography-line-height-xl,32px)}._305ff559e52180d5__body-xl,.ca1aa3fc2029e958__body-lg{font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-default,400)}.ca1aa3fc2029e958__body-lg{--_gcd-heading-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-default,400);--_gcd-p-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-p-line-height:var(--wpds-typography-line-height-md,24px);font-size:var(--wpds-typography-font-size-lg,15px);line-height:var(--wpds-typography-line-height-md,24px)}._131101940be12424__body-md{--_gcd-heading-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-default,400);--_gcd-p-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-md,13px);line-height:var(--wpds-typography-line-height-sm,20px)}._0e8d87a42c1f75fa__body-sm,._131101940be12424__body-md{font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-default,400)}._0e8d87a42c1f75fa__body-sm{--_gcd-heading-font-size:var(--wpds-typography-font-size-sm,12px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-default,400);--_gcd-p-font-size:var(--wpds-typography-font-size-sm,12px);--_gcd-p-line-height:var(--wpds-typography-line-height-xs,16px);font-size:var(--wpds-typography-font-size-sm,12px);line-height:var(--wpds-typography-line-height-xs,16px)}}}');
12776 }
12777 var style_default = { "text": "_83ed8a8da5dd50ea__text", "heading-2xl": "_14437cfb77831647__heading-2xl", "heading-xl": "_3c78b7fa9b4072dd__heading-xl", "heading-lg": "aa58f227716bcde2__heading-lg", "heading-md": "fc4da56d8dfe52c4__heading-md", "heading-sm": "a9b78c7c82e8dff7__heading-sm", "body-xl": "_305ff559e52180d5__body-xl", "body-lg": "ca1aa3fc2029e958__body-lg", "body-md": "_131101940be12424__body-md", "body-sm": "_0e8d87a42c1f75fa__body-sm" };
12778 if (typeof process === "undefined" || true) {
12779 registerStyle("e8e31009f5", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-foreground-interactive-neutral-weak,#707070))}&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,transparent);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 transparent);color:var(--_gcd-input-color,var(--wpds-color-foreground-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,transparent);border-color:var(--_gcd-input-border-color-disabled,transparent);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid transparent)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-foreground-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-emphasis,600));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid transparent);transition:var(--_gcd-a-transition,none)}.c59a0ebebd71fa4a__ol{list-style:var(--_gcd-ol-list-style,none);margin:var(--_gcd-ol-margin,0);padding-block:var(--_gcd-ol-padding-block,0);padding-inline:var(--_gcd-ol-padding-inline,0)}._46b5cb0c8e24e8c9__li{margin:var(--_gcd-li-margin,0)}");
12780 }
12781 var global_css_defense_default = { "button": "_6defc79820e382c6__button", "input": "d2cff2e5dea83bd1__input", "textarea": "_547d86373d02e108__textarea", "div": "_8c15fd0ed9f28ba4__div", "p": "_43cec3e1eec1066d__p", "heading": "e97669c6d9a38497__heading", "a": "_2c0831b0499dbd6e__a", "ol": "c59a0ebebd71fa4a__ol", "li": "_46b5cb0c8e24e8c9__li" };
12782 var Text = (0, import_element10.forwardRef)(function Text2({ variant = "body-md", render: render4, className, ...props }, ref) {
12783 const element = useRender({
12784 render: render4,
12785 defaultTagName: "span",
12786 ref,
12787 props: mergeProps(props, {
12788 className: clsx_default(
12789 style_default.text,
12790 global_css_defense_default.heading,
12791 global_css_defense_default.p,
12792 style_default[variant],
12793 className
12794 )
12795 })
12796 });
12797 return element;
12798 });
12799
12800 // packages/ui/build-module/badge/badge.mjs
12801 var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1);
12802 var STYLE_HASH_ATTRIBUTE2 = "data-wp-hash";
12803 function getRuntime2() {
12804 const globalScope = globalThis;
12805 if (globalScope.__wpStyleRuntime) {
12806 return globalScope.__wpStyleRuntime;
12807 }
12808 globalScope.__wpStyleRuntime = {
12809 documents: /* @__PURE__ */ new Map(),
12810 styles: /* @__PURE__ */ new Map(),
12811 injectedStyles: /* @__PURE__ */ new WeakMap()
12812 };
12813 if (typeof document !== "undefined") {
12814 registerDocument2(document);
12815 }
12816 return globalScope.__wpStyleRuntime;
12817 }
12818 function documentContainsStyleHash2(targetDocument, hash) {
12819 if (!targetDocument.head) {
12820 return false;
12821 }
12822 for (const style of targetDocument.head.querySelectorAll(
12823 `style[${STYLE_HASH_ATTRIBUTE2}]`
12824 )) {
12825 if (style.getAttribute(STYLE_HASH_ATTRIBUTE2) === hash) {
12826 return true;
12827 }
12828 }
12829 return false;
12830 }
12831 function injectStyle2(targetDocument, hash, css) {
12832 if (!targetDocument.head) {
12833 return;
12834 }
12835 const runtime = getRuntime2();
12836 let injectedStyles = runtime.injectedStyles.get(targetDocument);
12837 if (!injectedStyles) {
12838 injectedStyles = /* @__PURE__ */ new Set();
12839 runtime.injectedStyles.set(targetDocument, injectedStyles);
12840 }
12841 if (injectedStyles.has(hash)) {
12842 return;
12843 }
12844 if (documentContainsStyleHash2(targetDocument, hash)) {
12845 injectedStyles.add(hash);
12846 return;
12847 }
12848 const style = targetDocument.createElement("style");
12849 style.setAttribute(STYLE_HASH_ATTRIBUTE2, hash);
12850 style.appendChild(targetDocument.createTextNode(css));
12851 targetDocument.head.appendChild(style);
12852 injectedStyles.add(hash);
12853 }
12854 function registerDocument2(targetDocument) {
12855 const runtime = getRuntime2();
12856 runtime.documents.set(
12857 targetDocument,
12858 (runtime.documents.get(targetDocument) ?? 0) + 1
12859 );
12860 for (const [hash, css] of runtime.styles) {
12861 injectStyle2(targetDocument, hash, css);
12862 }
12863 return () => {
12864 const count = runtime.documents.get(targetDocument);
12865 if (count === void 0) {
12866 return;
12867 }
12868 if (count <= 1) {
12869 runtime.documents.delete(targetDocument);
12870 return;
12871 }
12872 runtime.documents.set(targetDocument, count - 1);
12873 };
12874 }
12875 function registerStyle2(hash, css) {
12876 const runtime = getRuntime2();
12877 runtime.styles.set(hash, css);
12878 for (const targetDocument of runtime.documents.keys()) {
12879 injectStyle2(targetDocument, hash, css);
12880 }
12881 }
12882 if (typeof process === "undefined" || true) {
12883 registerStyle2("40ea4a6382", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._96e6251aad1a6136__badge{border-radius:var(--wpds-border-radius-lg,8px);padding-block:var(--wpds-dimension-padding-xs,4px);padding-inline:var(--wpds-dimension-padding-sm,8px)}._99f7158cb520f750__is-high-intent{background-color:var(--wpds-color-background-surface-error,#fae5e1);color:var(--wpds-color-foreground-content-error,#470000)}.c20ebef2365bc8b7__is-medium-intent{background-color:var(--wpds-color-background-surface-warning,#fde6be);color:var(--wpds-color-foreground-content-warning,#2e1900)}._365e1626c6202e52__is-low-intent{background-color:var(--wpds-color-background-surface-caution,#fee995);color:var(--wpds-color-foreground-content-caution,#281d00)}._33f8198127ddf4ef__is-stable-intent{background-color:var(--wpds-color-background-surface-success,#c2f8ca);color:var(--wpds-color-foreground-content-success,#002900)}._04c1aca8fc449412__is-informational-intent{background-color:var(--wpds-color-background-surface-info,#deebfa);color:var(--wpds-color-foreground-content-info,#001b4f)}._90726e69d495ec19__is-draft-intent{background-color:var(--wpds-color-background-surface-neutral-weak,#f4f4f4);color:var(--wpds-color-foreground-content-neutral,#1e1e1e)}._898f4a544993bd39__is-none-intent{background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral,#dbdbdb);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);padding-block:calc(var(--wpds-dimension-padding-xs, 4px) - var(--wpds-border-width-xs, 1px));padding-inline:calc(var(--wpds-dimension-padding-sm, 8px) - var(--wpds-border-width-xs, 1px))}}}");
12884 }
12885 var style_default2 = { "badge": "_96e6251aad1a6136__badge", "is-high-intent": "_99f7158cb520f750__is-high-intent", "is-medium-intent": "c20ebef2365bc8b7__is-medium-intent", "is-low-intent": "_365e1626c6202e52__is-low-intent", "is-stable-intent": "_33f8198127ddf4ef__is-stable-intent", "is-informational-intent": "_04c1aca8fc449412__is-informational-intent", "is-draft-intent": "_90726e69d495ec19__is-draft-intent", "is-none-intent": "_898f4a544993bd39__is-none-intent" };
12886 var Badge = (0, import_element11.forwardRef)(function Badge2({ intent = "none", className, ...props }, ref) {
12887 return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
12888 Text,
12889 {
12890 ref,
12891 className: clsx_default(
12892 style_default2.badge,
12893 style_default2[`is-${intent}-intent`],
12894 className
12895 ),
12896 ...props,
12897 variant: "body-sm"
12898 }
12899 );
12900 });
12901
12902 // packages/ui/build-module/tooltip/popup.mjs
12903 var import_element15 = __toESM(require_element(), 1);
12904
12905 // packages/ui/build-module/tooltip/portal.mjs
12906 var import_element12 = __toESM(require_element(), 1);
12907
12908 // packages/ui/build-module/utils/wp-compat-overlay-slot.mjs
12909 var STYLE_HASH_ATTRIBUTE3 = "data-wp-hash";
12910 function getRuntime3() {
12911 const globalScope = globalThis;
12912 if (globalScope.__wpStyleRuntime) {
12913 return globalScope.__wpStyleRuntime;
12914 }
12915 globalScope.__wpStyleRuntime = {
12916 documents: /* @__PURE__ */ new Map(),
12917 styles: /* @__PURE__ */ new Map(),
12918 injectedStyles: /* @__PURE__ */ new WeakMap()
12919 };
12920 if (typeof document !== "undefined") {
12921 registerDocument3(document);
12922 }
12923 return globalScope.__wpStyleRuntime;
12924 }
12925 function documentContainsStyleHash3(targetDocument, hash) {
12926 if (!targetDocument.head) {
12927 return false;
12928 }
12929 for (const style of targetDocument.head.querySelectorAll(
12930 `style[${STYLE_HASH_ATTRIBUTE3}]`
12931 )) {
12932 if (style.getAttribute(STYLE_HASH_ATTRIBUTE3) === hash) {
12933 return true;
12934 }
12935 }
12936 return false;
12937 }
12938 function injectStyle3(targetDocument, hash, css) {
12939 if (!targetDocument.head) {
12940 return;
12941 }
12942 const runtime = getRuntime3();
12943 let injectedStyles = runtime.injectedStyles.get(targetDocument);
12944 if (!injectedStyles) {
12945 injectedStyles = /* @__PURE__ */ new Set();
12946 runtime.injectedStyles.set(targetDocument, injectedStyles);
12947 }
12948 if (injectedStyles.has(hash)) {
12949 return;
12950 }
12951 if (documentContainsStyleHash3(targetDocument, hash)) {
12952 injectedStyles.add(hash);
12953 return;
12954 }
12955 const style = targetDocument.createElement("style");
12956 style.setAttribute(STYLE_HASH_ATTRIBUTE3, hash);
12957 style.appendChild(targetDocument.createTextNode(css));
12958 targetDocument.head.appendChild(style);
12959 injectedStyles.add(hash);
12960 }
12961 function registerDocument3(targetDocument) {
12962 const runtime = getRuntime3();
12963 runtime.documents.set(
12964 targetDocument,
12965 (runtime.documents.get(targetDocument) ?? 0) + 1
12966 );
12967 for (const [hash, css] of runtime.styles) {
12968 injectStyle3(targetDocument, hash, css);
12969 }
12970 return () => {
12971 const count = runtime.documents.get(targetDocument);
12972 if (count === void 0) {
12973 return;
12974 }
12975 if (count <= 1) {
12976 runtime.documents.delete(targetDocument);
12977 return;
12978 }
12979 runtime.documents.set(targetDocument, count - 1);
12980 };
12981 }
12982 function registerStyle3(hash, css) {
12983 const runtime = getRuntime3();
12984 runtime.styles.set(hash, css);
12985 for (const targetDocument of runtime.documents.keys()) {
12986 injectStyle3(targetDocument, hash, css);
12987 }
12988 }
12989 if (typeof process === "undefined" || true) {
12990 registerStyle3("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}}}");
12991 }
12992 var wp_compat_overlay_slot_default = { "slot": "_11fc52b637ff8a7e__slot" };
12993 var WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE = "data-wp-compat-overlay-slot";
12994 function resolveOwnerDocument() {
12995 return typeof document === "undefined" ? null : document;
12996 }
12997 function isInWordPressEnvironment() {
12998 let topWp;
12999 try {
13000 topWp = window.top?.wp;
13001 } catch {
13002 }
13003 const wp = topWp ?? window.wp;
13004 return typeof wp?.components === "object" && wp.components !== null;
13005 }
13006 var cachedSlot = null;
13007 function ensureSlotIsAccessible(element) {
13008 element.setAttribute("aria-hidden", "false");
13009 return element;
13010 }
13011 function createSlot(ownerDocument2) {
13012 const element = ownerDocument2.createElement("div");
13013 element.setAttribute(WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE, "");
13014 if (wp_compat_overlay_slot_default.slot) {
13015 element.classList.add(wp_compat_overlay_slot_default.slot);
13016 }
13017 ownerDocument2.body.appendChild(element);
13018 return element;
13019 }
13020 function getWpCompatOverlaySlot() {
13021 if (typeof window === "undefined") {
13022 return void 0;
13023 }
13024 if (!isInWordPressEnvironment() && window.__wpUiCompatOverlaySlotEnabled !== true) {
13025 return void 0;
13026 }
13027 const ownerDocument2 = resolveOwnerDocument();
13028 if (!ownerDocument2 || !ownerDocument2.body) {
13029 return void 0;
13030 }
13031 if (cachedSlot && cachedSlot.ownerDocument === ownerDocument2 && cachedSlot.isConnected) {
13032 return ensureSlotIsAccessible(cachedSlot);
13033 }
13034 const existing = ownerDocument2.querySelector(
13035 `[${WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE}]`
13036 );
13037 if (existing instanceof HTMLDivElement) {
13038 cachedSlot = ensureSlotIsAccessible(existing);
13039 return cachedSlot;
13040 }
13041 if (cachedSlot?.isConnected) {
13042 cachedSlot.remove();
13043 }
13044 cachedSlot = ensureSlotIsAccessible(createSlot(ownerDocument2));
13045 return cachedSlot;
13046 }
13047
13048 // packages/ui/build-module/tooltip/portal.mjs
13049 var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1);
13050 var Portal = (0, import_element12.forwardRef)(
13051 function TooltipPortal3({ container, ...restProps }, ref) {
13052 return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
13053 index_parts_exports4.Portal,
13054 {
13055 container: container ?? getWpCompatOverlaySlot(),
13056 ...restProps,
13057 ref
13058 }
13059 );
13060 }
13061 );
13062
13063 // packages/ui/build-module/tooltip/positioner.mjs
13064 var import_element13 = __toESM(require_element(), 1);
13065 var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1);
13066 var STYLE_HASH_ATTRIBUTE4 = "data-wp-hash";
13067 function getRuntime4() {
13068 const globalScope = globalThis;
13069 if (globalScope.__wpStyleRuntime) {
13070 return globalScope.__wpStyleRuntime;
13071 }
13072 globalScope.__wpStyleRuntime = {
13073 documents: /* @__PURE__ */ new Map(),
13074 styles: /* @__PURE__ */ new Map(),
13075 injectedStyles: /* @__PURE__ */ new WeakMap()
13076 };
13077 if (typeof document !== "undefined") {
13078 registerDocument4(document);
13079 }
13080 return globalScope.__wpStyleRuntime;
13081 }
13082 function documentContainsStyleHash4(targetDocument, hash) {
13083 if (!targetDocument.head) {
13084 return false;
13085 }
13086 for (const style of targetDocument.head.querySelectorAll(
13087 `style[${STYLE_HASH_ATTRIBUTE4}]`
13088 )) {
13089 if (style.getAttribute(STYLE_HASH_ATTRIBUTE4) === hash) {
13090 return true;
13091 }
13092 }
13093 return false;
13094 }
13095 function injectStyle4(targetDocument, hash, css) {
13096 if (!targetDocument.head) {
13097 return;
13098 }
13099 const runtime = getRuntime4();
13100 let injectedStyles = runtime.injectedStyles.get(targetDocument);
13101 if (!injectedStyles) {
13102 injectedStyles = /* @__PURE__ */ new Set();
13103 runtime.injectedStyles.set(targetDocument, injectedStyles);
13104 }
13105 if (injectedStyles.has(hash)) {
13106 return;
13107 }
13108 if (documentContainsStyleHash4(targetDocument, hash)) {
13109 injectedStyles.add(hash);
13110 return;
13111 }
13112 const style = targetDocument.createElement("style");
13113 style.setAttribute(STYLE_HASH_ATTRIBUTE4, hash);
13114 style.appendChild(targetDocument.createTextNode(css));
13115 targetDocument.head.appendChild(style);
13116 injectedStyles.add(hash);
13117 }
13118 function registerDocument4(targetDocument) {
13119 const runtime = getRuntime4();
13120 runtime.documents.set(
13121 targetDocument,
13122 (runtime.documents.get(targetDocument) ?? 0) + 1
13123 );
13124 for (const [hash, css] of runtime.styles) {
13125 injectStyle4(targetDocument, hash, css);
13126 }
13127 return () => {
13128 const count = runtime.documents.get(targetDocument);
13129 if (count === void 0) {
13130 return;
13131 }
13132 if (count <= 1) {
13133 runtime.documents.delete(targetDocument);
13134 return;
13135 }
13136 runtime.documents.set(targetDocument, count - 1);
13137 };
13138 }
13139 function registerStyle4(hash, css) {
13140 const runtime = getRuntime4();
13141 runtime.styles.set(hash, css);
13142 for (const targetDocument of runtime.documents.keys()) {
13143 injectStyle4(targetDocument, hash, css);
13144 }
13145 }
13146 if (typeof process === "undefined" || true) {
13147 registerStyle4("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}");
13148 }
13149 var resets_default = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
13150 if (typeof process === "undefined" || true) {
13151 registerStyle4("19fcc06039", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{--_wp-ui-elevation-sm:0 1px 2px rgba(0,0,0,.05),0 2px 3px rgba(0,0,0,.04),0 6px 6px rgba(0,0,0,.03),0 8px 8px rgba(0,0,0,.02);background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-md,4px);box-shadow:var(--_wp-ui-elevation-sm);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-sm,12px);line-height:1.4;padding:var(--wpds-dimension-padding-xs,4px) var(--wpds-dimension-padding-sm,8px);@media (forced-colors:active){border-bottom-color:CanvasText;border-bottom-style:solid;border-bottom-width:1px;border-left-color:CanvasText;border-left-style:solid;border-left-width:1px;border-right-color:CanvasText;border-right-style:solid;border-right-width:1px;border-top-color:CanvasText;border-top-style:solid;border-top-width:1px}}}}');
13152 }
13153 var style_default3 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
13154 var Positioner = (0, import_element13.forwardRef)(
13155 function TooltipPositioner3({ align = "center", className, side = "top", sideOffset = 4, ...props }, ref) {
13156 return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
13157 index_parts_exports4.Positioner,
13158 {
13159 ref,
13160 align,
13161 side,
13162 sideOffset,
13163 ...props,
13164 className: clsx_default(
13165 resets_default["box-sizing"],
13166 style_default3.positioner,
13167 className
13168 )
13169 }
13170 );
13171 }
13172 );
13173
13174 // packages/ui/build-module/utils/render-slot-with-children.mjs
13175 var import_element14 = __toESM(require_element(), 1);
13176 function renderSlotWithChildren(slot, defaultSlot, children) {
13177 return (0, import_element14.cloneElement)(slot ?? defaultSlot, { children });
13178 }
13179
13180 // packages/ui/build-module/utils/theme-provider.mjs
13181 var theme = __toESM(require_theme(), 1);
13182
13183 // packages/ui/build-module/lock-unlock.mjs
13184 var import_private_apis = __toESM(require_private_apis(), 1);
13185 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
13186 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
13187 "@wordpress/ui"
13188 );
13189
13190 // packages/ui/build-module/utils/theme-provider.mjs
13191 function getThemeProvider() {
13192 const themePackage = theme;
13193 if (themePackage.ThemeProvider) {
13194 return themePackage.ThemeProvider;
13195 }
13196 if (!themePackage.privateApis) {
13197 throw new Error(
13198 "@wordpress/ui: @wordpress/theme must expose `ThemeProvider` or `privateApis.ThemeProvider`."
13199 );
13200 }
13201 return unlock(
13202 themePackage.privateApis
13203 ).ThemeProvider;
13204 }
13205 var ThemeProvider = getThemeProvider();
13206
13207 // packages/ui/build-module/tooltip/popup.mjs
13208 var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1);
13209 var STYLE_HASH_ATTRIBUTE5 = "data-wp-hash";
13210 function getRuntime5() {
13211 const globalScope = globalThis;
13212 if (globalScope.__wpStyleRuntime) {
13213 return globalScope.__wpStyleRuntime;
13214 }
13215 globalScope.__wpStyleRuntime = {
13216 documents: /* @__PURE__ */ new Map(),
13217 styles: /* @__PURE__ */ new Map(),
13218 injectedStyles: /* @__PURE__ */ new WeakMap()
13219 };
13220 if (typeof document !== "undefined") {
13221 registerDocument5(document);
13222 }
13223 return globalScope.__wpStyleRuntime;
13224 }
13225 function documentContainsStyleHash5(targetDocument, hash) {
13226 if (!targetDocument.head) {
13227 return false;
13228 }
13229 for (const style of targetDocument.head.querySelectorAll(
13230 `style[${STYLE_HASH_ATTRIBUTE5}]`
13231 )) {
13232 if (style.getAttribute(STYLE_HASH_ATTRIBUTE5) === hash) {
13233 return true;
13234 }
13235 }
13236 return false;
13237 }
13238 function injectStyle5(targetDocument, hash, css) {
13239 if (!targetDocument.head) {
13240 return;
13241 }
13242 const runtime = getRuntime5();
13243 let injectedStyles = runtime.injectedStyles.get(targetDocument);
13244 if (!injectedStyles) {
13245 injectedStyles = /* @__PURE__ */ new Set();
13246 runtime.injectedStyles.set(targetDocument, injectedStyles);
13247 }
13248 if (injectedStyles.has(hash)) {
13249 return;
13250 }
13251 if (documentContainsStyleHash5(targetDocument, hash)) {
13252 injectedStyles.add(hash);
13253 return;
13254 }
13255 const style = targetDocument.createElement("style");
13256 style.setAttribute(STYLE_HASH_ATTRIBUTE5, hash);
13257 style.appendChild(targetDocument.createTextNode(css));
13258 targetDocument.head.appendChild(style);
13259 injectedStyles.add(hash);
13260 }
13261 function registerDocument5(targetDocument) {
13262 const runtime = getRuntime5();
13263 runtime.documents.set(
13264 targetDocument,
13265 (runtime.documents.get(targetDocument) ?? 0) + 1
13266 );
13267 for (const [hash, css] of runtime.styles) {
13268 injectStyle5(targetDocument, hash, css);
13269 }
13270 return () => {
13271 const count = runtime.documents.get(targetDocument);
13272 if (count === void 0) {
13273 return;
13274 }
13275 if (count <= 1) {
13276 runtime.documents.delete(targetDocument);
13277 return;
13278 }
13279 runtime.documents.set(targetDocument, count - 1);
13280 };
13281 }
13282 function registerStyle5(hash, css) {
13283 const runtime = getRuntime5();
13284 runtime.styles.set(hash, css);
13285 for (const targetDocument of runtime.documents.keys()) {
13286 injectStyle5(targetDocument, hash, css);
13287 }
13288 }
13289 if (typeof process === "undefined" || true) {
13290 registerStyle5("19fcc06039", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{--_wp-ui-elevation-sm:0 1px 2px rgba(0,0,0,.05),0 2px 3px rgba(0,0,0,.04),0 6px 6px rgba(0,0,0,.03),0 8px 8px rgba(0,0,0,.02);background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-md,4px);box-shadow:var(--_wp-ui-elevation-sm);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-sm,12px);line-height:1.4;padding:var(--wpds-dimension-padding-xs,4px) var(--wpds-dimension-padding-sm,8px);@media (forced-colors:active){border-bottom-color:CanvasText;border-bottom-style:solid;border-bottom-width:1px;border-left-color:CanvasText;border-left-style:solid;border-left-width:1px;border-right-color:CanvasText;border-right-style:solid;border-right-width:1px;border-top-color:CanvasText;border-top-style:solid;border-top-width:1px}}}}');
13291 }
13292 var style_default4 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
13293 var POPUP_COLOR = { background: "#1e1e1e" };
13294 var Popup = (0, import_element15.forwardRef)(function TooltipPopup3({ portal, positioner, children, className, ...props }, ref) {
13295 const popupContent = /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(ThemeProvider, { color: POPUP_COLOR, children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
13296 index_parts_exports4.Popup,
13297 {
13298 ref,
13299 className: clsx_default(style_default4.popup, className),
13300 ...props,
13301 children
13302 }
13303 ) });
13304 const positionedPopup = renderSlotWithChildren(
13305 positioner,
13306 /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Positioner, {}),
13307 popupContent
13308 );
13309 return renderSlotWithChildren(portal, /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Portal, {}), positionedPopup);
13310 });
13311
13312 // packages/ui/build-module/tooltip/trigger.mjs
13313 var import_element16 = __toESM(require_element(), 1);
13314 var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1);
13315 var Trigger = (0, import_element16.forwardRef)(
13316 function TooltipTrigger3(props, ref) {
13317 return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(index_parts_exports4.Trigger, { ref, ...props });
13318 }
13319 );
13320
13321 // packages/ui/build-module/utils/direction-provider.mjs
13322 var import_i18n = __toESM(require_i18n(), 1);
13323 var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1);
13324 function DirectionProvider3({ children }) {
13325 return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(DirectionProvider, { direction: (0, import_i18n.isRTL)() ? "rtl" : "ltr", children });
13326 }
13327
13328 // packages/ui/build-module/tooltip/root.mjs
13329 var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1);
13330 function Root(props) {
13331 return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(DirectionProvider3, { children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(index_parts_exports4.Root, { ...props }) });
13332 }
13333
13334 // packages/ui/build-module/link/link.mjs
13335 var import_element17 = __toESM(require_element(), 1);
13336 var import_i18n2 = __toESM(require_i18n(), 1);
13337 var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
13338 var STYLE_HASH_ATTRIBUTE6 = "data-wp-hash";
13339 function getRuntime6() {
13340 const globalScope = globalThis;
13341 if (globalScope.__wpStyleRuntime) {
13342 return globalScope.__wpStyleRuntime;
13343 }
13344 globalScope.__wpStyleRuntime = {
13345 documents: /* @__PURE__ */ new Map(),
13346 styles: /* @__PURE__ */ new Map(),
13347 injectedStyles: /* @__PURE__ */ new WeakMap()
13348 };
13349 if (typeof document !== "undefined") {
13350 registerDocument6(document);
13351 }
13352 return globalScope.__wpStyleRuntime;
13353 }
13354 function documentContainsStyleHash6(targetDocument, hash) {
13355 if (!targetDocument.head) {
13356 return false;
13357 }
13358 for (const style of targetDocument.head.querySelectorAll(
13359 `style[${STYLE_HASH_ATTRIBUTE6}]`
13360 )) {
13361 if (style.getAttribute(STYLE_HASH_ATTRIBUTE6) === hash) {
13362 return true;
13363 }
13364 }
13365 return false;
13366 }
13367 function injectStyle6(targetDocument, hash, css) {
13368 if (!targetDocument.head) {
13369 return;
13370 }
13371 const runtime = getRuntime6();
13372 let injectedStyles = runtime.injectedStyles.get(targetDocument);
13373 if (!injectedStyles) {
13374 injectedStyles = /* @__PURE__ */ new Set();
13375 runtime.injectedStyles.set(targetDocument, injectedStyles);
13376 }
13377 if (injectedStyles.has(hash)) {
13378 return;
13379 }
13380 if (documentContainsStyleHash6(targetDocument, hash)) {
13381 injectedStyles.add(hash);
13382 return;
13383 }
13384 const style = targetDocument.createElement("style");
13385 style.setAttribute(STYLE_HASH_ATTRIBUTE6, hash);
13386 style.appendChild(targetDocument.createTextNode(css));
13387 targetDocument.head.appendChild(style);
13388 injectedStyles.add(hash);
13389 }
13390 function registerDocument6(targetDocument) {
13391 const runtime = getRuntime6();
13392 runtime.documents.set(
13393 targetDocument,
13394 (runtime.documents.get(targetDocument) ?? 0) + 1
13395 );
13396 for (const [hash, css] of runtime.styles) {
13397 injectStyle6(targetDocument, hash, css);
13398 }
13399 return () => {
13400 const count = runtime.documents.get(targetDocument);
13401 if (count === void 0) {
13402 return;
13403 }
13404 if (count <= 1) {
13405 runtime.documents.delete(targetDocument);
13406 return;
13407 }
13408 runtime.documents.set(targetDocument, count - 1);
13409 };
13410 }
13411 function registerStyle6(hash, css) {
13412 const runtime = getRuntime6();
13413 runtime.styles.set(hash, css);
13414 for (const targetDocument of runtime.documents.keys()) {
13415 injectStyle6(targetDocument, hash, css);
13416 }
13417 }
13418 if (typeof process === "undefined" || true) {
13419 registerStyle6("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}");
13420 }
13421 var resets_default2 = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
13422 if (typeof process === "undefined" || true) {
13423 registerStyle6("08122b3d53", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{.af79fb116edb0dd7__outset-ring--focus:focus,.dfcfdc28396e5d98__outset-ring--focus-visible:focus-visible,.e5cd9ee879f6403a__outset-ring--focus-within:focus-within,:focus-visible ._81935a08e952f267__outset-ring--focus-parent-visible{--_gcd-a-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--focus-color,var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9)));--_gcd-div-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--focus-color,var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9)));outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--focus-color,var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9)));outline-offset:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px))}._3c9f5ee9fc9c136d__outset-ring--focus-within-except-active:focus-within,.abc777e9713fa711__outset-ring--focus-except-active:focus{outline:none}._3c9f5ee9fc9c136d__outset-ring--focus-within-except-active:focus-within:not(:has(:active)),.abc777e9713fa711__outset-ring--focus-except-active:focus:not(:active){--_gcd-a-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--focus-color,var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9)));--_gcd-div-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--focus-color,var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9)));outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--focus-color,var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9)));outline-offset:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px))}}}");
13424 }
13425 var focus_module_default = { "outset-ring--focus": "af79fb116edb0dd7__outset-ring--focus", "outset-ring--focus-visible": "dfcfdc28396e5d98__outset-ring--focus-visible", "outset-ring--focus-within": "e5cd9ee879f6403a__outset-ring--focus-within", "outset-ring--focus-parent-visible": "_81935a08e952f267__outset-ring--focus-parent-visible", "outset-ring--focus-except-active": "abc777e9713fa711__outset-ring--focus-except-active", "outset-ring--focus-within-except-active": "_3c9f5ee9fc9c136d__outset-ring--focus-within-except-active" };
13426 if (typeof process === "undefined" || true) {
13427 registerStyle6("e8e6a9be37", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{.d4250949359b05ce__link{text-decoration-thickness:from-font;text-underline-offset:.2em}.c6055659b8e2cd2c__is-brand,.c6055659b8e2cd2c__is-brand:visited{--_gcd-a-color:var(--wpds-color-foreground-interactive-brand,var(--wp-admin-theme-color,#3858e9));color:var(--wpds-color-foreground-interactive-brand,var(--wp-admin-theme-color,#3858e9))}.c6055659b8e2cd2c__is-brand:active,.c6055659b8e2cd2c__is-brand:hover{--_gcd-a-color:var(--wpds-color-foreground-interactive-brand-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 52%,#000));color:var(--wpds-color-foreground-interactive-brand-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 52%,#000))}._92e0dfcaeee15b88__is-neutral,._92e0dfcaeee15b88__is-neutral:visited{--_gcd-a-color:var(--wpds-color-foreground-interactive-neutral,#1e1e1e);color:var(--wpds-color-foreground-interactive-neutral,#1e1e1e);text-decoration-color:var(--wpds-color-stroke-interactive-neutral,#8d8d8d)}._92e0dfcaeee15b88__is-neutral:active,._92e0dfcaeee15b88__is-neutral:hover{--_gcd-a-color:var(--wpds-color-foreground-interactive-neutral-active,#1e1e1e);color:var(--wpds-color-foreground-interactive-neutral-active,#1e1e1e)}.cf122a9bf1035d42__is-unstyled{--_gcd-a-color:inherit;color:inherit;text-decoration:none}._0cb411afac4c86c7__link-icon{display:inline-block;font-weight:var(--wpds-typography-font-weight-default,400);line-height:1;margin-inline-start:var(--wpds-dimension-padding-xs,4px);text-decoration:none}._0cb411afac4c86c7__link-icon:after{content:"\\2197"}._0cb411afac4c86c7__link-icon:dir(rtl):after{content:"\\2196"}}}');
13428 }
13429 var style_default5 = { "link": "d4250949359b05ce__link", "is-brand": "c6055659b8e2cd2c__is-brand", "is-neutral": "_92e0dfcaeee15b88__is-neutral", "is-unstyled": "cf122a9bf1035d42__is-unstyled", "link-icon": "_0cb411afac4c86c7__link-icon" };
13430 if (typeof process === "undefined" || true) {
13431 registerStyle6("e8e31009f5", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-foreground-interactive-neutral-weak,#707070))}&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,transparent);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 transparent);color:var(--_gcd-input-color,var(--wpds-color-foreground-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,transparent);border-color:var(--_gcd-input-border-color-disabled,transparent);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid transparent)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-foreground-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-emphasis,600));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid transparent);transition:var(--_gcd-a-transition,none)}.c59a0ebebd71fa4a__ol{list-style:var(--_gcd-ol-list-style,none);margin:var(--_gcd-ol-margin,0);padding-block:var(--_gcd-ol-padding-block,0);padding-inline:var(--_gcd-ol-padding-inline,0)}._46b5cb0c8e24e8c9__li{margin:var(--_gcd-li-margin,0)}");
13432 }
13433 var global_css_defense_default2 = { "button": "_6defc79820e382c6__button", "input": "d2cff2e5dea83bd1__input", "textarea": "_547d86373d02e108__textarea", "div": "_8c15fd0ed9f28ba4__div", "p": "_43cec3e1eec1066d__p", "heading": "e97669c6d9a38497__heading", "a": "_2c0831b0499dbd6e__a", "ol": "c59a0ebebd71fa4a__ol", "li": "_46b5cb0c8e24e8c9__li" };
13434 var Link = (0, import_element17.forwardRef)(function Link2({
13435 children,
13436 variant = "default",
13437 tone = "brand",
13438 openInNewTab = false,
13439 target,
13440 render: render4,
13441 className,
13442 ...props
13443 }, ref) {
13444 const shouldShowNewTabIndicator = openInNewTab || /^_blank$/i.test(target ?? "");
13445 const element = useRender({
13446 render: render4,
13447 defaultTagName: "a",
13448 ref,
13449 props: mergeProps(props, {
13450 className: clsx_default(
13451 global_css_defense_default2.a,
13452 resets_default2["box-sizing"],
13453 focus_module_default["outset-ring--focus-except-active"],
13454 variant !== "unstyled" && style_default5.link,
13455 variant !== "unstyled" && style_default5[`is-${tone}`],
13456 variant === "unstyled" && style_default5["is-unstyled"],
13457 className
13458 ),
13459 target: target ?? (openInNewTab ? "_blank" : void 0),
13460 children: /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(import_jsx_runtime32.Fragment, { children: [
13461 children,
13462 shouldShowNewTabIndicator && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
13463 "span",
13464 {
13465 className: style_default5["link-icon"],
13466 role: "img",
13467 "aria-label": (
13468 /* translators: accessibility text appended to link text */
13469 (0, import_i18n2.__)("(opens in a new tab)")
13470 )
13471 }
13472 )
13473 ] })
13474 })
13475 });
13476 return element;
13477 });
13478
13479 // packages/icons/build-module/library/aspect-ratio.mjs
13480 var import_primitives = __toESM(require_primitives(), 1);
13481 var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1);
13482 var aspect_ratio_default = /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_primitives.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", style: { fill: "none" }, stroke: "currentColor", strokeWidth: "1.5", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_primitives.Path, { d: "M7.25 12V9.25H10M16.75 12V14.75H14M5.5 17.75H18.5C19.1904 17.75 19.75 17.1904 19.75 16.5V7.5C19.75 6.80964 19.1904 6.25 18.5 6.25H5.5C4.80964 6.25 4.25 6.80964 4.25 7.5V16.5C4.25 17.1904 4.80964 17.75 5.5 17.75Z", vectorEffect: "non-scaling-stroke" }) });
13483
13484 // packages/icons/build-module/library/check.mjs
13485 var import_primitives2 = __toESM(require_primitives(), 1);
13486 var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
13487 var check_default = /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", style: { fill: "none" }, stroke: "currentColor", strokeWidth: "1.5", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_primitives2.Path, { d: "M7 12L10 15L17 8", vectorEffect: "non-scaling-stroke" }) });
13488
13489 // packages/icons/build-module/library/chevron-down.mjs
13490 var import_primitives3 = __toESM(require_primitives(), 1);
13491 var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1);
13492 var chevron_down_default = /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", style: { fill: "none" }, stroke: "currentColor", strokeWidth: "1.5", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_primitives3.Path, { d: "M7 11L12 15L17 11", vectorEffect: "non-scaling-stroke" }) });
13493
13494 // packages/icons/build-module/library/chevron-left.mjs
13495 var import_primitives4 = __toESM(require_primitives(), 1);
13496 var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
13497 var chevron_left_default = /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_primitives4.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", style: { fill: "none" }, stroke: "currentColor", strokeWidth: "1.5", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_primitives4.Path, { d: "M14 6.5L9 12L14 17.5", vectorEffect: "non-scaling-stroke" }) });
13498
13499 // packages/icons/build-module/library/chevron-right.mjs
13500 var import_primitives5 = __toESM(require_primitives(), 1);
13501 var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1);
13502 var chevron_right_default = /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_primitives5.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", style: { fill: "none" }, stroke: "currentColor", strokeWidth: "1.5", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_primitives5.Path, { d: "M10 6.5L15 12L10 17.5", vectorEffect: "non-scaling-stroke" }) });
13503
13504 // packages/icons/build-module/library/close-small.mjs
13505 var import_primitives6 = __toESM(require_primitives(), 1);
13506 var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1);
13507 var close_small_default = /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_primitives6.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", style: { fill: "none" }, stroke: "currentColor", strokeWidth: "1.5", children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_primitives6.Path, { d: "M7.75 16.25L16.25 7.75M16.25 16.25L7.75 7.75", vectorEffect: "non-scaling-stroke" }) });
13508
13509 // packages/icons/build-module/library/close.mjs
13510 var import_primitives7 = __toESM(require_primitives(), 1);
13511 var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
13512 var close_default = /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_primitives7.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", style: { fill: "none" }, stroke: "currentColor", strokeWidth: "1.5", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_primitives7.Path, { d: "M5 19L19 5M19 19L5 5", vectorEffect: "non-scaling-stroke" }) });
13513
13514 // packages/icons/build-module/library/drawer-right.mjs
13515 var import_primitives8 = __toESM(require_primitives(), 1);
13516 var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1);
13517 var drawer_right_default = /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_primitives8.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", style: { fill: "none" }, stroke: "currentColor", strokeWidth: "1.5", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_primitives8.Path, { d: "M14.25 19.25L18 19.25C18.6904 19.25 19.25 18.6904 19.25 18L19.25 6C19.25 5.30964 18.6904 4.75 18 4.75L14.25 4.75M14.25 19.25L6 19.25C5.30964 19.25 4.75 18.6904 4.75 18L4.75 6C4.75 5.30964 5.30965 4.75 6 4.75L14.25 4.75M14.25 19.25L14.25 4.75", vectorEffect: "non-scaling-stroke" }) });
13518
13519 // packages/icons/build-module/library/envelope.mjs
13520 var import_primitives9 = __toESM(require_primitives(), 1);
13521 var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);
13522 var envelope_default = /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_primitives9.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", style: { fill: "none" }, stroke: "currentColor", strokeWidth: "1.5", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_primitives9.Path, { d: "M20.25 8.5V7C20.25 6.30964 19.6904 5.75 19 5.75H5C4.30964 5.75 3.75 6.30964 3.75 7V8.5M20.25 8.5V17C20.25 17.6904 19.6904 18.25 19 18.25H5C4.30964 18.25 3.75 17.6904 3.75 17V8.5M20.25 8.5L12 14.5L3.75 8.5", vectorEffect: "non-scaling-stroke" }) });
13523
13524 // packages/icons/build-module/library/error.mjs
13525 var import_primitives10 = __toESM(require_primitives(), 1);
13526 var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1);
13527 var error_default = /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_primitives10.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", style: { fill: "none" }, stroke: "currentColor", strokeWidth: "1.5", children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_primitives10.Path, { d: "M12 9L12 14M12 15.5V17M11.1284 5.04947L3.83827 18.0097C3.46331 18.6763 3.94502 19.5 4.70985 19.5H19.2902C20.055 19.5 20.5367 18.6763 20.1617 18.0097L12.8716 5.04947C12.4893 4.36982 11.5107 4.36982 11.1284 5.04947Z", vectorEffect: "non-scaling-stroke" }) });
13528
13529 // packages/icons/build-module/library/flip-horizontal.mjs
13530 var import_primitives11 = __toESM(require_primitives(), 1);
13531 var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1);
13532 var flip_horizontal_default = /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_primitives11.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", style: { fill: "none" }, stroke: "currentColor", strokeWidth: "1.5", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_primitives11.Path, { d: "M9 19.25H6C5.30964 19.25 4.75 18.6904 4.75 18V6C4.75 5.30964 5.30964 4.75 6 4.75H9M15 4.75L16.5 4.75M15 19.25H16.5M12 22V2M19.25 16.5V14.5M19.25 13V11M19.25 9.5V7.5M18 4.75C18.6904 4.75 19.25 5.30964 19.25 6M18 19.25C18.6904 19.25 19.25 18.6904 19.25 18", vectorEffect: "non-scaling-stroke" }) });
13533
13534 // packages/icons/build-module/library/flip-vertical.mjs
13535 var import_primitives12 = __toESM(require_primitives(), 1);
13536 var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1);
13537 var flip_vertical_default = /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_primitives12.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", style: { fill: "none" }, stroke: "currentColor", strokeWidth: "1.5", children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_primitives12.Path, { d: "M4.75 9L4.75 6C4.75 5.30964 5.30964 4.75 6 4.75L18 4.75C18.6904 4.75 19.25 5.30964 19.25 6L19.25 9M19.25 15L19.25 16.5M4.75 15L4.75 16.5M2 12L22 12M7.5 19.25L9.5 19.25M11 19.25L13 19.25M14.5 19.25L16.5 19.25M19.25 18C19.25 18.6904 18.6904 19.25 18 19.25M4.75 18C4.75 18.6904 5.30964 19.25 6 19.25", vectorEffect: "non-scaling-stroke" }) });
13538
13539 // packages/icons/build-module/library/keyboard.mjs
13540 var import_primitives13 = __toESM(require_primitives(), 1);
13541 var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1);
13542 var keyboard_default = /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_primitives13.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", style: { fill: "none" }, stroke: "currentColor", strokeWidth: "1.5", children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_primitives13.Path, { d: "M6.5 9H8.5M8 15H16M6.5 12H8.5M9.5 9H11.5M9.5 12H11.5M12.5 9H14.5M12.5 12H14.5M15.5 9H17.5M15.5 12H17.5M5 18.25H19C19.6904 18.25 20.25 17.6904 20.25 17V7C20.25 6.30964 19.6904 5.75 19 5.75H5C4.30964 5.75 3.75 6.30964 3.75 7V17C3.75 17.6904 4.30964 18.25 5 18.25Z", vectorEffect: "non-scaling-stroke" }) });
13543
13544 // packages/icons/build-module/library/line-solid.mjs
13545 var import_primitives14 = __toESM(require_primitives(), 1);
13546 var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1);
13547 var line_solid_default = /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_primitives14.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", style: { fill: "none" }, stroke: "currentColor", strokeWidth: "1.5", children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_primitives14.Path, { d: "M5 12H19", vectorEffect: "non-scaling-stroke" }) });
13548
13549 // packages/icons/build-module/library/link.mjs
13550 var import_primitives15 = __toESM(require_primitives(), 1);
13551 var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1);
13552 var link_default = /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_primitives15.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", style: { fill: "none" }, stroke: "currentColor", strokeWidth: "1.5", children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_primitives15.Path, { d: "M9.5 12L14.5 12M10 7.75H8.25C5.90279 7.75 4 9.65279 4 12C4 14.3472 5.90279 16.25 8.25 16.25H10M14 16.25H15.75C18.0972 16.25 20 14.3472 20 12C20 9.65279 18.0972 7.75 15.75 7.75L14 7.75", vectorEffect: "non-scaling-stroke" }) });
13553
13554 // packages/icons/build-module/library/mobile.mjs
13555 var import_primitives16 = __toESM(require_primitives(), 1);
13556 var import_jsx_runtime48 = __toESM(require_jsx_runtime(), 1);
13557 var mobile_default = /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_primitives16.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", style: { fill: "none" }, stroke: "currentColor", strokeWidth: "1.5", children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_primitives16.Path, { d: "M11 16.5H13M16.25 18V6C16.25 5.30964 15.6904 4.75 15 4.75H9C8.30964 4.75 7.75 5.30964 7.75 6L7.75 18C7.75 18.6904 8.30964 19.25 9 19.25H15C15.6904 19.25 16.25 18.6904 16.25 18Z", vectorEffect: "non-scaling-stroke" }) });
13558
13559 // packages/icons/build-module/library/pencil.mjs
13560 var import_primitives17 = __toESM(require_primitives(), 1);
13561 var import_jsx_runtime49 = __toESM(require_jsx_runtime(), 1);
13562 var pencil_default = /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_primitives17.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", style: { fill: "none" }, stroke: "currentColor", strokeWidth: "1.5", children: [
13563 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_primitives17.Path, { d: "M5 19.25H12", vectorEffect: "non-scaling-stroke" }),
13564 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_primitives17.Path, { d: "M10 15L7.5 15.5L8 13L16 5L18 7L10 15Z", fill: "currentColor", vectorEffect: "non-scaling-stroke" })
13565 ] });
13566
13567 // packages/icons/build-module/library/plus.mjs
13568 var import_primitives18 = __toESM(require_primitives(), 1);
13569 var import_jsx_runtime50 = __toESM(require_jsx_runtime(), 1);
13570 var plus_default = /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_primitives18.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", style: { fill: "none" }, stroke: "currentColor", strokeWidth: "1.5", children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_primitives18.Path, { d: "M12 18V6M18 12H6", vectorEffect: "non-scaling-stroke" }) });
13571
13572 // packages/icons/build-module/library/published.mjs
13573 var import_primitives19 = __toESM(require_primitives(), 1);
13574 var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1);
13575 var published_default = /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(import_primitives19.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", style: { fill: "none" }, stroke: "currentColor", strokeWidth: "1.5", children: [
13576 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_primitives19.Path, { d: "M12 19.25C16.0041 19.25 19.25 16.0041 19.25 12C19.25 7.99594 16.0041 4.75 12 4.75C7.99594 4.75 4.75 7.99594 4.75 12C4.75 16.0041 7.99594 19.25 12 19.25Z", strokeLinejoin: "round", vectorEffect: "non-scaling-stroke" }),
13577 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_primitives19.Path, { d: "M9 12L11 14L15 10", vectorEffect: "non-scaling-stroke" })
13578 ] });
13579
13580 // packages/icons/build-module/library/redo.mjs
13581 var import_primitives20 = __toESM(require_primitives(), 1);
13582 var import_jsx_runtime52 = __toESM(require_jsx_runtime(), 1);
13583 var redo_default = /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_primitives20.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", style: { fill: "none" }, stroke: "currentColor", strokeWidth: "1.5", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_primitives20.Path, { d: "M15 15L18.5 11L15 7M18.5 11H8C5 11 4.75 13.8 4.75 17", vectorEffect: "non-scaling-stroke" }) });
13584
13585 // packages/icons/build-module/library/rotate-left.mjs
13586 var import_primitives21 = __toESM(require_primitives(), 1);
13587 var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1);
13588 var rotate_left_default = /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(import_primitives21.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", style: { fill: "none" }, stroke: "currentColor", strokeWidth: "1.5", children: [
13589 /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_primitives21.Path, { d: "M12 19.25C16.0041 19.25 19.25 16.0041 19.25 12C19.25 7.99594 16.0041 4.75 12 4.75L10 4.75M12 2L10 4.75L12 7.5", vectorEffect: "non-scaling-stroke" }),
13590 /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_primitives21.Path, { d: "M14.7745 18.6981C11.0752 20.2304 6.83418 18.4737 5.30189 14.7745C4.27391 12.2927 4.72622 9.56712 6.25229 7.57918", strokeLinejoin: "round", vectorEffect: "non-scaling-stroke" })
13591 ] });
13592
13593 // packages/icons/build-module/library/rotate-right.mjs
13594 var import_primitives22 = __toESM(require_primitives(), 1);
13595 var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1);
13596 var rotate_right_default = /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(import_primitives22.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", style: { fill: "none" }, stroke: "currentColor", strokeWidth: "1.5", children: [
13597 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_primitives22.Path, { d: "M12 19.25C7.99593 19.25 4.75 16.0041 4.75 12C4.75 7.99594 7.99593 4.75 12 4.75L14 4.75M12 2L14 4.75L12 7.5", vectorEffect: "non-scaling-stroke" }),
13598 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_primitives22.Path, { d: "M9.22553 18.6981C12.9248 20.2304 17.1658 18.4737 18.6981 14.7745C19.7261 12.2927 19.2738 9.56712 17.7477 7.57918", strokeLinejoin: "round", vectorEffect: "non-scaling-stroke" })
13599 ] });
13600
13601 // packages/icons/build-module/library/seen.mjs
13602 var import_primitives23 = __toESM(require_primitives(), 1);
13603 var import_jsx_runtime55 = __toESM(require_jsx_runtime(), 1);
13604 var seen_default = /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_primitives23.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", style: { fill: "none" }, stroke: "currentColor", strokeWidth: "1.5", children: [
13605 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_primitives23.Path, { d: "M20.0645 13C18.5918 10.0366 15.5337 8 12 8C8.46631 8 5.40825 10.0366 3.93555 13", vectorEffect: "non-scaling-stroke" }),
13606 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_primitives23.Circle, { cx: "12", cy: "12.5", r: "3", fill: "currentColor", vectorEffect: "non-scaling-stroke" })
13607 ] });
13608
13609 // packages/icons/build-module/library/undo.mjs
13610 var import_primitives24 = __toESM(require_primitives(), 1);
13611 var import_jsx_runtime56 = __toESM(require_jsx_runtime(), 1);
13612 var undo_default = /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_primitives24.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", style: { fill: "none" }, stroke: "currentColor", strokeWidth: "1.5", children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_primitives24.Path, { d: "M8.25 15L4.75 11L8.25 7M4.75 11H15.25C18.25 11 18.5 13.8 18.5 17", vectorEffect: "non-scaling-stroke" }) });
13613
13614 // packages/icons/build-module/library/unseen.mjs
13615 var import_primitives25 = __toESM(require_primitives(), 1);
13616 var import_jsx_runtime57 = __toESM(require_jsx_runtime(), 1);
13617 var unseen_default = /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(import_primitives25.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", style: { fill: "none" }, stroke: "currentColor", strokeWidth: "1.5", children: [
13618 /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(import_primitives25.Path, { d: "M8 21L10.6587 15.1842M13.1523 9.72929L13.8553 8.19144L16 3.5M20.0645 13C19.2118 11.2841 17.8276 9.87898 16.1272 9M3.93555 13C5.40825 10.0366 8.46631 8 12 8C12.636 8 13.2566 8.06597 13.8553 8.19144M13.1523 9.72929C12.7975 9.58156 12.4083 9.5 12 9.5C10.3431 9.5 9 10.8431 9 12.5C9 13.6747 9.67519 14.6917 10.6587 15.1842M13.1523 9.72929L10.6587 15.1842M13.1755 15.261C14.2481 14.8037 15 13.7397 15 12.5C15 12.1819 14.9505 11.8753 14.8587 11.5876", vectorEffect: "non-scaling-stroke" }),
13619 /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(import_primitives25.Path, { d: "M12 9.5C10.3431 9.5 9 10.8431 9 12.5C9 13.6747 9.67519 14.6917 10.6587 15.1842L13.1523 9.72929C12.7975 9.58156 12.4083 9.5 12 9.5Z", fill: "currentColor", vectorEffect: "non-scaling-stroke" })
13620 ] });
13621
13622 // packages/ui/build-module/icon/icon.mjs
13623 var import_element18 = __toESM(require_element(), 1);
13624 var import_primitives26 = __toESM(require_primitives(), 1);
13625 var import_jsx_runtime58 = __toESM(require_jsx_runtime(), 1);
13626 var Icon = (0, import_element18.forwardRef)(function Icon2({ icon, size: size4 = 24, style, ...restProps }, ref) {
13627 const mergedStyle = icon.props.style || style ? { ...icon.props.style, ...style } : void 0;
13628 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13629 import_primitives26.SVG,
13630 {
13631 ref,
13632 ...icon.props,
13633 ...restProps,
13634 ...mergedStyle ? { style: mergedStyle } : {},
13635 width: size4,
13636 height: size4
13637 }
13638 );
13639 });
13640
13641 // packages/ui/build-module/utils/keyboard-shortcut.mjs
13642 var import_element20 = __toESM(require_element(), 1);
13643 var import_i18n3 = __toESM(require_i18n(), 1);
13644
13645 // packages/ui/build-module/visually-hidden/visually-hidden.mjs
13646 var import_element19 = __toESM(require_element(), 1);
13647 var STYLE_HASH_ATTRIBUTE7 = "data-wp-hash";
13648 function getRuntime7() {
13649 const globalScope = globalThis;
13650 if (globalScope.__wpStyleRuntime) {
13651 return globalScope.__wpStyleRuntime;
13652 }
13653 globalScope.__wpStyleRuntime = {
13654 documents: /* @__PURE__ */ new Map(),
13655 styles: /* @__PURE__ */ new Map(),
13656 injectedStyles: /* @__PURE__ */ new WeakMap()
13657 };
13658 if (typeof document !== "undefined") {
13659 registerDocument7(document);
13660 }
13661 return globalScope.__wpStyleRuntime;
13662 }
13663 function documentContainsStyleHash7(targetDocument, hash) {
13664 if (!targetDocument.head) {
13665 return false;
13666 }
13667 for (const style of targetDocument.head.querySelectorAll(
13668 `style[${STYLE_HASH_ATTRIBUTE7}]`
13669 )) {
13670 if (style.getAttribute(STYLE_HASH_ATTRIBUTE7) === hash) {
13671 return true;
13672 }
13673 }
13674 return false;
13675 }
13676 function injectStyle7(targetDocument, hash, css) {
13677 if (!targetDocument.head) {
13678 return;
13679 }
13680 const runtime = getRuntime7();
13681 let injectedStyles = runtime.injectedStyles.get(targetDocument);
13682 if (!injectedStyles) {
13683 injectedStyles = /* @__PURE__ */ new Set();
13684 runtime.injectedStyles.set(targetDocument, injectedStyles);
13685 }
13686 if (injectedStyles.has(hash)) {
13687 return;
13688 }
13689 if (documentContainsStyleHash7(targetDocument, hash)) {
13690 injectedStyles.add(hash);
13691 return;
13692 }
13693 const style = targetDocument.createElement("style");
13694 style.setAttribute(STYLE_HASH_ATTRIBUTE7, hash);
13695 style.appendChild(targetDocument.createTextNode(css));
13696 targetDocument.head.appendChild(style);
13697 injectedStyles.add(hash);
13698 }
13699 function registerDocument7(targetDocument) {
13700 const runtime = getRuntime7();
13701 runtime.documents.set(
13702 targetDocument,
13703 (runtime.documents.get(targetDocument) ?? 0) + 1
13704 );
13705 for (const [hash, css] of runtime.styles) {
13706 injectStyle7(targetDocument, hash, css);
13707 }
13708 return () => {
13709 const count = runtime.documents.get(targetDocument);
13710 if (count === void 0) {
13711 return;
13712 }
13713 if (count <= 1) {
13714 runtime.documents.delete(targetDocument);
13715 return;
13716 }
13717 runtime.documents.set(targetDocument, count - 1);
13718 };
13719 }
13720 function registerStyle7(hash, css) {
13721 const runtime = getRuntime7();
13722 runtime.styles.set(hash, css);
13723 for (const targetDocument of runtime.documents.keys()) {
13724 injectStyle7(targetDocument, hash, css);
13725 }
13726 }
13727 if (typeof process === "undefined" || true) {
13728 registerStyle7("f4df7461e9", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{.f37b9e2e191ebd66__visually-hidden{border:0;clip-path:inset(50%);height:1px;margin:-1px;overflow:hidden;overflow-wrap:normal;padding:0;position:absolute;width:1px;word-break:normal}}}");
13729 }
13730 var style_default6 = { "visually-hidden": "f37b9e2e191ebd66__visually-hidden" };
13731 var VisuallyHidden = (0, import_element19.forwardRef)(
13732 function VisuallyHidden2({ render: render4, ...restProps }, ref) {
13733 const element = useRender({
13734 render: render4,
13735 ref,
13736 props: mergeProps(
13737 { className: style_default6["visually-hidden"] },
13738 restProps,
13739 {
13740 // @ts-expect-error Arbitrary data-* attributes aren't indexable on the typed div props. Kept hardcoded so consumers can't change or remove it.
13741 "data-visually-hidden": ""
13742 }
13743 )
13744 });
13745 return element;
13746 }
13747 );
13748
13749 // packages/ui/build-module/utils/keyboard-shortcut.mjs
13750 var import_jsx_runtime59 = __toESM(require_jsx_runtime(), 1);
13751 function useKeyboardShortcutProps({
13752 "aria-describedby": ariaDescribedBy,
13753 "aria-keyshortcuts": ariaKeyShortcuts,
13754 shortcut
13755 }) {
13756 const generatedDescriptionId = (0, import_element20.useId)();
13757 const descriptionId = shortcut ? generatedDescriptionId : void 0;
13758 const describedBy = [ariaDescribedBy, descriptionId].filter(Boolean).join(" ");
13759 return {
13760 descriptionId,
13761 targetProps: {
13762 "aria-describedby": describedBy || void 0,
13763 "aria-keyshortcuts": shortcut?.ariaKeyShortcut ?? ariaKeyShortcuts
13764 }
13765 };
13766 }
13767 var KeyboardShortcutDescription = (0, import_element20.forwardRef)(function KeyboardShortcutDescription2({ descriptionId, shortcut }, ref) {
13768 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13769 VisuallyHidden,
13770 {
13771 id: descriptionId,
13772 "aria-hidden": "true",
13773 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("span", { ref }),
13774 children: (0, import_i18n3.sprintf)(
13775 /* translators: %s: keyboard shortcut. */
13776 (0, import_i18n3.__)("Keyboard shortcut: %s"),
13777 shortcut.label ?? shortcut.ariaKeyShortcut
13778 )
13779 }
13780 );
13781 });
13782 var KeyboardShortcutDisplay = (0, import_element20.forwardRef)(function KeyboardShortcutDisplay2({ className, shortcut }, ref) {
13783 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("span", { ref, "aria-hidden": "true", className, dir: "ltr", children: shortcut.displayShortcut });
13784 });
13785
13786 // packages/ui/build-module/button/button.mjs
13787 var import_element21 = __toESM(require_element(), 1);
13788 var import_i18n4 = __toESM(require_i18n(), 1);
13789 var import_jsx_runtime60 = __toESM(require_jsx_runtime(), 1);
13790 import { speak } from "@wordpress/a11y";
13791 var STYLE_HASH_ATTRIBUTE8 = "data-wp-hash";
13792 function getRuntime8() {
13793 const globalScope = globalThis;
13794 if (globalScope.__wpStyleRuntime) {
13795 return globalScope.__wpStyleRuntime;
13796 }
13797 globalScope.__wpStyleRuntime = {
13798 documents: /* @__PURE__ */ new Map(),
13799 styles: /* @__PURE__ */ new Map(),
13800 injectedStyles: /* @__PURE__ */ new WeakMap()
13801 };
13802 if (typeof document !== "undefined") {
13803 registerDocument8(document);
13804 }
13805 return globalScope.__wpStyleRuntime;
13806 }
13807 function documentContainsStyleHash8(targetDocument, hash) {
13808 if (!targetDocument.head) {
13809 return false;
13810 }
13811 for (const style of targetDocument.head.querySelectorAll(
13812 `style[${STYLE_HASH_ATTRIBUTE8}]`
13813 )) {
13814 if (style.getAttribute(STYLE_HASH_ATTRIBUTE8) === hash) {
13815 return true;
13816 }
13817 }
13818 return false;
13819 }
13820 function injectStyle8(targetDocument, hash, css) {
13821 if (!targetDocument.head) {
13822 return;
13823 }
13824 const runtime = getRuntime8();
13825 let injectedStyles = runtime.injectedStyles.get(targetDocument);
13826 if (!injectedStyles) {
13827 injectedStyles = /* @__PURE__ */ new Set();
13828 runtime.injectedStyles.set(targetDocument, injectedStyles);
13829 }
13830 if (injectedStyles.has(hash)) {
13831 return;
13832 }
13833 if (documentContainsStyleHash8(targetDocument, hash)) {
13834 injectedStyles.add(hash);
13835 return;
13836 }
13837 const style = targetDocument.createElement("style");
13838 style.setAttribute(STYLE_HASH_ATTRIBUTE8, hash);
13839 style.appendChild(targetDocument.createTextNode(css));
13840 targetDocument.head.appendChild(style);
13841 injectedStyles.add(hash);
13842 }
13843 function registerDocument8(targetDocument) {
13844 const runtime = getRuntime8();
13845 runtime.documents.set(
13846 targetDocument,
13847 (runtime.documents.get(targetDocument) ?? 0) + 1
13848 );
13849 for (const [hash, css] of runtime.styles) {
13850 injectStyle8(targetDocument, hash, css);
13851 }
13852 return () => {
13853 const count = runtime.documents.get(targetDocument);
13854 if (count === void 0) {
13855 return;
13856 }
13857 if (count <= 1) {
13858 runtime.documents.delete(targetDocument);
13859 return;
13860 }
13861 runtime.documents.set(targetDocument, count - 1);
13862 };
13863 }
13864 function registerStyle8(hash, css) {
13865 const runtime = getRuntime8();
13866 runtime.styles.set(hash, css);
13867 for (const targetDocument of runtime.documents.keys()) {
13868 injectStyle8(targetDocument, hash, css);
13869 }
13870 }
13871 if (typeof process === "undefined" || true) {
13872 registerStyle8("effc4e3032", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._97b0fc33c028be1a__button,.abbb272e2ce49bd6__is-unstyled{appearance:none;padding:0}._97b0fc33c028be1a__button{--wp-ui-button-font-weight:var(--wpds-typography-font-weight-emphasis,600);--wp-ui-button-background-color:var(--wpds-color-background-interactive-brand-strong,var(--wp-admin-theme-color,#3858e9));--wp-ui-button-background-color-active:var(--wpds-color-background-interactive-brand-strong-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 93%,#000));--wp-ui-button-background-color-disabled:var(--wpds-color-background-interactive-brand-strong-disabled,#e6e6e6);--wp-ui-button-foreground-color:var(--wpds-color-foreground-interactive-brand-strong,#fff);--wp-ui-button-foreground-color-active:var(--wpds-color-foreground-interactive-brand-strong-active,#fff);--wp-ui-button-foreground-color-disabled:var(--wpds-color-foreground-interactive-brand-strong-disabled,#8d8d8d);--wp-ui-button-padding-block:var(--wpds-dimension-padding-xs,4px);--wp-ui-button-padding-inline:var(--wpds-dimension-padding-md,12px);--wp-ui-button-height:var(--wpds-dimension-size-lg,40px);--wp-ui-button-aspect-ratio:auto;--wp-ui-button-font-size:var(--wpds-typography-font-size-md,13px);--wp-ui-button-min-width:calc(4ch + var(--wp-ui-button-padding-inline)*2);--wp-ui-button-icon-margin:calc((var(--wpds-dimension-size-2xs, 16px) - var(--wpds-dimension-size-sm, 24px))/2);--wp-ui-button-border-color:var(--wp-ui-button-background-color);--wp-ui-button-border-color-active:var(--wp-ui-button-background-color-active);--wp-ui-button-border-color-disabled:var(--wp-ui-button-background-color-disabled);--_gcd-button-font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);--_gcd-button-font-size:var(--wp-ui-button-font-size);--_gcd-button-font-weight:var(--wp-ui-button-font-weight);align-items:center;aspect-ratio:var(--wp-ui-button-aspect-ratio);background-clip:border-box;background-color:var(--wp-ui-button-background-color);border-color:var(--wp-ui-button-border-color);border-radius:var(--wpds-border-radius-sm,2px);border-style:solid;border-width:1px;color:var(--wp-ui-button-foreground-color);display:inline-flex;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(--wp-ui-button-font-size);font-weight:var(--wp-ui-button-font-weight);gap:var(--wpds-dimension-gap-sm,8px);justify-content:center;line-height:var(--wpds-typography-line-height-sm,20px);max-width:100%;min-height:var(--wp-ui-button-height);min-width:var(--wp-ui-button-min-width);overflow-wrap:anywhere;padding-block:var(--wp-ui-button-padding-block);padding-inline:var(--wp-ui-button-padding-inline);position:relative;text-align:center;text-decoration:none;&:not([data-disabled]){cursor:var(--wpds-cursor-control,pointer)}@media not (prefers-reduced-motion){transition:color .1s ease-out;*{transition:opacity .1s ease-out}}&[href]{cursor:pointer}[href]{color:inherit;text-decoration:inherit}&:not([data-disabled]):is(:hover,:active,:focus){background-color:var(--wp-ui-button-background-color-active);border-color:var(--wp-ui-button-border-color-active);color:var(--wp-ui-button-foreground-color-active)}&[data-disabled]:not(._914b42f315c0e580__is-loading){background-color:var(--wp-ui-button-background-color-disabled);border-color:var(--wp-ui-button-border-color-disabled);color:var(--wp-ui-button-foreground-color-disabled);@media (forced-colors:active){border-bottom-color:GrayText;border-left-color:GrayText;border-right-color:GrayText;border-top-color:GrayText;color:GrayText}}&:before{aspect-ratio:1;border:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid;border-block-end-color:transparent;border-block-start-color:var(--wp-ui-button-foreground-color);border-inline-end-color:var(--wp-ui-button-foreground-color);border-inline-start-color:transparent;border-radius:50%;box-sizing:border-box;content:"";display:block;height:var(--wp-ui-button-font-size);left:50%;opacity:0;pointer-events:none;position:absolute;top:50%;transform:translate(-50%,-50%);@media not (prefers-reduced-motion){transition:opacity .1s ease-out}@media (forced-colors:active){border-block-end-style:none;border-bottom-color:ButtonText;border-inline-start-style:none;border-left-color:ButtonText;border-right-color:ButtonText;border-top-color:ButtonText}}}._908205475f9f2a92__is-small{--wp-ui-button-padding-block:0px;--wp-ui-button-padding-inline:var(--wpds-dimension-padding-sm,8px);--wp-ui-button-height:var(--wpds-dimension-size-sm,24px)}._9f6fc6553aeb36fe__icon{margin:var(--wp-ui-button-icon-margin)}.dd460c965226cc77__is-brand{&._62d5a778b7b258ee__is-outline,&.ad0619a3217c6a5b__is-minimal{--wp-ui-button-foreground-color:var(--wpds-color-foreground-interactive-brand,var(--wp-admin-theme-color,#3858e9));--wp-ui-button-foreground-color-active:var(--wpds-color-foreground-interactive-brand-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 52%,#000));--wp-ui-button-foreground-color-disabled:var(--wpds-color-foreground-interactive-brand-disabled,#8d8d8d)}&._62d5a778b7b258ee__is-outline{--wp-ui-button-background-color:var(--wpds-color-background-interactive-brand-weak,#0000);--wp-ui-button-background-color-active:var(--wpds-color-background-interactive-brand-weak-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 12%,#fff));--wp-ui-button-background-color-disabled:var(--wpds-color-background-interactive-brand-weak-disabled,#0000);--wp-ui-button-border-color:var(--wpds-color-stroke-interactive-brand,var(--wp-admin-theme-color,#3858e9));--wp-ui-button-border-color-active:var(--wpds-color-stroke-interactive-brand-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 85%,#000));--wp-ui-button-border-color-disabled:var(--wpds-color-stroke-interactive-brand-disabled,#dbdbdb)}&.ad0619a3217c6a5b__is-minimal{--wp-ui-button-background-color:var(--wpds-color-background-interactive-brand-weak,#0000);--wp-ui-button-background-color-active:var(--wpds-color-background-interactive-brand-weak-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 12%,#fff));--wp-ui-button-background-color-disabled:var(--wpds-color-background-interactive-brand-weak-disabled,#0000)}}.e722a8f96726aa99__is-neutral{&.ad0619a3217c6a5b__is-minimal[aria-pressed=true],&.b50b3358c5fb4d0b__is-solid{--wp-ui-button-background-color:var(--wpds-color-background-interactive-neutral-strong,#2d2d2d);--wp-ui-button-background-color-active:var(--wpds-color-background-interactive-neutral-strong-active,#1e1e1e);--wp-ui-button-background-color-disabled:var(--wpds-color-background-interactive-neutral-strong-disabled,#e6e6e6);--wp-ui-button-foreground-color:var(--wpds-color-foreground-interactive-neutral-strong,#f0f0f0);--wp-ui-button-foreground-color-active:var(--wpds-color-foreground-interactive-neutral-strong-active,#f0f0f0);--wp-ui-button-foreground-color-disabled:var(--wpds-color-foreground-interactive-neutral-strong-disabled,#8d8d8d)}&._62d5a778b7b258ee__is-outline,&.ad0619a3217c6a5b__is-minimal:not([aria-pressed=true]){--wp-ui-button-foreground-color:var(--wpds-color-foreground-interactive-neutral,#1e1e1e);--wp-ui-button-foreground-color-active:var(--wpds-color-foreground-interactive-neutral-active,#1e1e1e);--wp-ui-button-foreground-color-disabled:var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d)}&._62d5a778b7b258ee__is-outline{--wp-ui-button-background-color:var(--wpds-color-background-interactive-neutral-weak,#0000);--wp-ui-button-background-color-active:var(--wpds-color-background-interactive-neutral-weak-active,#ededed);--wp-ui-button-background-color-disabled:var(--wpds-color-background-interactive-neutral-weak-disabled,#0000);--wp-ui-button-border-color:var(--wpds-color-stroke-interactive-neutral,#8d8d8d);--wp-ui-button-border-color-active:var(--wpds-color-stroke-interactive-neutral-active,#6e6e6e);--wp-ui-button-border-color-disabled:var(--wpds-color-stroke-interactive-neutral-disabled,#dbdbdb)}&.ad0619a3217c6a5b__is-minimal:not([aria-pressed=true]){--wp-ui-button-background-color:var(--wpds-color-background-interactive-neutral-weak,#0000);--wp-ui-button-background-color-active:var(--wpds-color-background-interactive-neutral-weak-active,#ededed);--wp-ui-button-background-color-disabled:var(--wpds-color-background-interactive-neutral-weak-disabled,#0000)}}.abbb272e2ce49bd6__is-unstyled{background:none;border:none;min-width:unset}.cf59cf1b69629838__is-compact{--wp-ui-button-height:var(--wpds-dimension-size-md,32px)}._914b42f315c0e580__is-loading:not(.abbb272e2ce49bd6__is-unstyled){color:transparent;&:not([data-disabled]):is(:hover,:active,:focus){color:transparent}@media (forced-colors:active){color:ButtonFace}*{opacity:0}&:before{opacity:1;transition-delay:.05s;@media not (prefers-reduced-motion){animation:_5a1d53da6f830c8d__loading-animation 1s linear infinite}}}}@keyframes _5a1d53da6f830c8d__loading-animation{0%{transform:translate(-50%,-50%) rotate(0deg)}to{transform:translate(-50%,-50%) rotate(1turn)}}}');
13873 }
13874 var style_default7 = { "button": "_97b0fc33c028be1a__button", "is-unstyled": "abbb272e2ce49bd6__is-unstyled", "is-loading": "_914b42f315c0e580__is-loading", "is-small": "_908205475f9f2a92__is-small", "icon": "_9f6fc6553aeb36fe__icon", "is-brand": "dd460c965226cc77__is-brand", "is-outline": "_62d5a778b7b258ee__is-outline", "is-minimal": "ad0619a3217c6a5b__is-minimal", "is-neutral": "e722a8f96726aa99__is-neutral", "is-solid": "b50b3358c5fb4d0b__is-solid", "is-compact": "cf59cf1b69629838__is-compact", "loading-animation": "_5a1d53da6f830c8d__loading-animation" };
13875 if (typeof process === "undefined" || true) {
13876 registerStyle8("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}");
13877 }
13878 var resets_default3 = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
13879 if (typeof process === "undefined" || true) {
13880 registerStyle8("08122b3d53", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{.af79fb116edb0dd7__outset-ring--focus:focus,.dfcfdc28396e5d98__outset-ring--focus-visible:focus-visible,.e5cd9ee879f6403a__outset-ring--focus-within:focus-within,:focus-visible ._81935a08e952f267__outset-ring--focus-parent-visible{--_gcd-a-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--focus-color,var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9)));--_gcd-div-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--focus-color,var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9)));outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--focus-color,var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9)));outline-offset:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px))}._3c9f5ee9fc9c136d__outset-ring--focus-within-except-active:focus-within,.abc777e9713fa711__outset-ring--focus-except-active:focus{outline:none}._3c9f5ee9fc9c136d__outset-ring--focus-within-except-active:focus-within:not(:has(:active)),.abc777e9713fa711__outset-ring--focus-except-active:focus:not(:active){--_gcd-a-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--focus-color,var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9)));--_gcd-div-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--focus-color,var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9)));outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--focus-color,var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9)));outline-offset:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px))}}}");
13881 }
13882 var focus_module_default2 = { "outset-ring--focus": "af79fb116edb0dd7__outset-ring--focus", "outset-ring--focus-visible": "dfcfdc28396e5d98__outset-ring--focus-visible", "outset-ring--focus-within": "e5cd9ee879f6403a__outset-ring--focus-within", "outset-ring--focus-parent-visible": "_81935a08e952f267__outset-ring--focus-parent-visible", "outset-ring--focus-except-active": "abc777e9713fa711__outset-ring--focus-except-active", "outset-ring--focus-within-except-active": "_3c9f5ee9fc9c136d__outset-ring--focus-within-except-active" };
13883 if (typeof process === "undefined" || true) {
13884 registerStyle8("e8e31009f5", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-foreground-interactive-neutral-weak,#707070))}&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,transparent);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 transparent);color:var(--_gcd-input-color,var(--wpds-color-foreground-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,transparent);border-color:var(--_gcd-input-border-color-disabled,transparent);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid transparent)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-foreground-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-emphasis,600));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid transparent);transition:var(--_gcd-a-transition,none)}.c59a0ebebd71fa4a__ol{list-style:var(--_gcd-ol-list-style,none);margin:var(--_gcd-ol-margin,0);padding-block:var(--_gcd-ol-padding-block,0);padding-inline:var(--_gcd-ol-padding-inline,0)}._46b5cb0c8e24e8c9__li{margin:var(--_gcd-li-margin,0)}");
13885 }
13886 var global_css_defense_default3 = { "button": "_6defc79820e382c6__button", "input": "d2cff2e5dea83bd1__input", "textarea": "_547d86373d02e108__textarea", "div": "_8c15fd0ed9f28ba4__div", "p": "_43cec3e1eec1066d__p", "heading": "e97669c6d9a38497__heading", "a": "_2c0831b0499dbd6e__a", "ol": "c59a0ebebd71fa4a__ol", "li": "_46b5cb0c8e24e8c9__li" };
13887 var Button3 = (0, import_element21.forwardRef)(
13888 function Button22({
13889 tone = "brand",
13890 variant = "solid",
13891 size: size4 = "default",
13892 className,
13893 focusableWhenDisabled = true,
13894 disabled: disabled2,
13895 loading,
13896 loadingAnnouncement = (0, import_i18n4.__)("Loading"),
13897 children,
13898 ...props
13899 }, ref) {
13900 const mergedClassName = clsx_default(
13901 global_css_defense_default3.button,
13902 resets_default3["box-sizing"],
13903 focus_module_default2["outset-ring--focus-except-active"],
13904 variant !== "unstyled" && style_default7.button,
13905 style_default7[`is-${tone}`],
13906 style_default7[`is-${variant}`],
13907 style_default7[`is-${size4}`],
13908 loading && style_default7["is-loading"],
13909 className
13910 );
13911 (0, import_element21.useEffect)(() => {
13912 if (loading && loadingAnnouncement) {
13913 speak(loadingAnnouncement);
13914 }
13915 }, [loading, loadingAnnouncement]);
13916 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13917 Button,
13918 {
13919 ref,
13920 className: mergedClassName,
13921 focusableWhenDisabled,
13922 disabled: disabled2 ?? loading,
13923 ...props,
13924 children
13925 }
13926 );
13927 }
13928 );
13929
13930 // packages/ui/build-module/button/icon.mjs
13931 var import_element22 = __toESM(require_element(), 1);
13932 var import_jsx_runtime61 = __toESM(require_jsx_runtime(), 1);
13933 var STYLE_HASH_ATTRIBUTE9 = "data-wp-hash";
13934 function getRuntime9() {
13935 const globalScope = globalThis;
13936 if (globalScope.__wpStyleRuntime) {
13937 return globalScope.__wpStyleRuntime;
13938 }
13939 globalScope.__wpStyleRuntime = {
13940 documents: /* @__PURE__ */ new Map(),
13941 styles: /* @__PURE__ */ new Map(),
13942 injectedStyles: /* @__PURE__ */ new WeakMap()
13943 };
13944 if (typeof document !== "undefined") {
13945 registerDocument9(document);
13946 }
13947 return globalScope.__wpStyleRuntime;
13948 }
13949 function documentContainsStyleHash9(targetDocument, hash) {
13950 if (!targetDocument.head) {
13951 return false;
13952 }
13953 for (const style of targetDocument.head.querySelectorAll(
13954 `style[${STYLE_HASH_ATTRIBUTE9}]`
13955 )) {
13956 if (style.getAttribute(STYLE_HASH_ATTRIBUTE9) === hash) {
13957 return true;
13958 }
13959 }
13960 return false;
13961 }
13962 function injectStyle9(targetDocument, hash, css) {
13963 if (!targetDocument.head) {
13964 return;
13965 }
13966 const runtime = getRuntime9();
13967 let injectedStyles = runtime.injectedStyles.get(targetDocument);
13968 if (!injectedStyles) {
13969 injectedStyles = /* @__PURE__ */ new Set();
13970 runtime.injectedStyles.set(targetDocument, injectedStyles);
13971 }
13972 if (injectedStyles.has(hash)) {
13973 return;
13974 }
13975 if (documentContainsStyleHash9(targetDocument, hash)) {
13976 injectedStyles.add(hash);
13977 return;
13978 }
13979 const style = targetDocument.createElement("style");
13980 style.setAttribute(STYLE_HASH_ATTRIBUTE9, hash);
13981 style.appendChild(targetDocument.createTextNode(css));
13982 targetDocument.head.appendChild(style);
13983 injectedStyles.add(hash);
13984 }
13985 function registerDocument9(targetDocument) {
13986 const runtime = getRuntime9();
13987 runtime.documents.set(
13988 targetDocument,
13989 (runtime.documents.get(targetDocument) ?? 0) + 1
13990 );
13991 for (const [hash, css] of runtime.styles) {
13992 injectStyle9(targetDocument, hash, css);
13993 }
13994 return () => {
13995 const count = runtime.documents.get(targetDocument);
13996 if (count === void 0) {
13997 return;
13998 }
13999 if (count <= 1) {
14000 runtime.documents.delete(targetDocument);
14001 return;
14002 }
14003 runtime.documents.set(targetDocument, count - 1);
14004 };
14005 }
14006 function registerStyle9(hash, css) {
14007 const runtime = getRuntime9();
14008 runtime.styles.set(hash, css);
14009 for (const targetDocument of runtime.documents.keys()) {
14010 injectStyle9(targetDocument, hash, css);
14011 }
14012 }
14013 if (typeof process === "undefined" || true) {
14014 registerStyle9("effc4e3032", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._97b0fc33c028be1a__button,.abbb272e2ce49bd6__is-unstyled{appearance:none;padding:0}._97b0fc33c028be1a__button{--wp-ui-button-font-weight:var(--wpds-typography-font-weight-emphasis,600);--wp-ui-button-background-color:var(--wpds-color-background-interactive-brand-strong,var(--wp-admin-theme-color,#3858e9));--wp-ui-button-background-color-active:var(--wpds-color-background-interactive-brand-strong-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 93%,#000));--wp-ui-button-background-color-disabled:var(--wpds-color-background-interactive-brand-strong-disabled,#e6e6e6);--wp-ui-button-foreground-color:var(--wpds-color-foreground-interactive-brand-strong,#fff);--wp-ui-button-foreground-color-active:var(--wpds-color-foreground-interactive-brand-strong-active,#fff);--wp-ui-button-foreground-color-disabled:var(--wpds-color-foreground-interactive-brand-strong-disabled,#8d8d8d);--wp-ui-button-padding-block:var(--wpds-dimension-padding-xs,4px);--wp-ui-button-padding-inline:var(--wpds-dimension-padding-md,12px);--wp-ui-button-height:var(--wpds-dimension-size-lg,40px);--wp-ui-button-aspect-ratio:auto;--wp-ui-button-font-size:var(--wpds-typography-font-size-md,13px);--wp-ui-button-min-width:calc(4ch + var(--wp-ui-button-padding-inline)*2);--wp-ui-button-icon-margin:calc((var(--wpds-dimension-size-2xs, 16px) - var(--wpds-dimension-size-sm, 24px))/2);--wp-ui-button-border-color:var(--wp-ui-button-background-color);--wp-ui-button-border-color-active:var(--wp-ui-button-background-color-active);--wp-ui-button-border-color-disabled:var(--wp-ui-button-background-color-disabled);--_gcd-button-font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);--_gcd-button-font-size:var(--wp-ui-button-font-size);--_gcd-button-font-weight:var(--wp-ui-button-font-weight);align-items:center;aspect-ratio:var(--wp-ui-button-aspect-ratio);background-clip:border-box;background-color:var(--wp-ui-button-background-color);border-color:var(--wp-ui-button-border-color);border-radius:var(--wpds-border-radius-sm,2px);border-style:solid;border-width:1px;color:var(--wp-ui-button-foreground-color);display:inline-flex;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(--wp-ui-button-font-size);font-weight:var(--wp-ui-button-font-weight);gap:var(--wpds-dimension-gap-sm,8px);justify-content:center;line-height:var(--wpds-typography-line-height-sm,20px);max-width:100%;min-height:var(--wp-ui-button-height);min-width:var(--wp-ui-button-min-width);overflow-wrap:anywhere;padding-block:var(--wp-ui-button-padding-block);padding-inline:var(--wp-ui-button-padding-inline);position:relative;text-align:center;text-decoration:none;&:not([data-disabled]){cursor:var(--wpds-cursor-control,pointer)}@media not (prefers-reduced-motion){transition:color .1s ease-out;*{transition:opacity .1s ease-out}}&[href]{cursor:pointer}[href]{color:inherit;text-decoration:inherit}&:not([data-disabled]):is(:hover,:active,:focus){background-color:var(--wp-ui-button-background-color-active);border-color:var(--wp-ui-button-border-color-active);color:var(--wp-ui-button-foreground-color-active)}&[data-disabled]:not(._914b42f315c0e580__is-loading){background-color:var(--wp-ui-button-background-color-disabled);border-color:var(--wp-ui-button-border-color-disabled);color:var(--wp-ui-button-foreground-color-disabled);@media (forced-colors:active){border-bottom-color:GrayText;border-left-color:GrayText;border-right-color:GrayText;border-top-color:GrayText;color:GrayText}}&:before{aspect-ratio:1;border:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid;border-block-end-color:transparent;border-block-start-color:var(--wp-ui-button-foreground-color);border-inline-end-color:var(--wp-ui-button-foreground-color);border-inline-start-color:transparent;border-radius:50%;box-sizing:border-box;content:"";display:block;height:var(--wp-ui-button-font-size);left:50%;opacity:0;pointer-events:none;position:absolute;top:50%;transform:translate(-50%,-50%);@media not (prefers-reduced-motion){transition:opacity .1s ease-out}@media (forced-colors:active){border-block-end-style:none;border-bottom-color:ButtonText;border-inline-start-style:none;border-left-color:ButtonText;border-right-color:ButtonText;border-top-color:ButtonText}}}._908205475f9f2a92__is-small{--wp-ui-button-padding-block:0px;--wp-ui-button-padding-inline:var(--wpds-dimension-padding-sm,8px);--wp-ui-button-height:var(--wpds-dimension-size-sm,24px)}._9f6fc6553aeb36fe__icon{margin:var(--wp-ui-button-icon-margin)}.dd460c965226cc77__is-brand{&._62d5a778b7b258ee__is-outline,&.ad0619a3217c6a5b__is-minimal{--wp-ui-button-foreground-color:var(--wpds-color-foreground-interactive-brand,var(--wp-admin-theme-color,#3858e9));--wp-ui-button-foreground-color-active:var(--wpds-color-foreground-interactive-brand-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 52%,#000));--wp-ui-button-foreground-color-disabled:var(--wpds-color-foreground-interactive-brand-disabled,#8d8d8d)}&._62d5a778b7b258ee__is-outline{--wp-ui-button-background-color:var(--wpds-color-background-interactive-brand-weak,#0000);--wp-ui-button-background-color-active:var(--wpds-color-background-interactive-brand-weak-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 12%,#fff));--wp-ui-button-background-color-disabled:var(--wpds-color-background-interactive-brand-weak-disabled,#0000);--wp-ui-button-border-color:var(--wpds-color-stroke-interactive-brand,var(--wp-admin-theme-color,#3858e9));--wp-ui-button-border-color-active:var(--wpds-color-stroke-interactive-brand-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 85%,#000));--wp-ui-button-border-color-disabled:var(--wpds-color-stroke-interactive-brand-disabled,#dbdbdb)}&.ad0619a3217c6a5b__is-minimal{--wp-ui-button-background-color:var(--wpds-color-background-interactive-brand-weak,#0000);--wp-ui-button-background-color-active:var(--wpds-color-background-interactive-brand-weak-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 12%,#fff));--wp-ui-button-background-color-disabled:var(--wpds-color-background-interactive-brand-weak-disabled,#0000)}}.e722a8f96726aa99__is-neutral{&.ad0619a3217c6a5b__is-minimal[aria-pressed=true],&.b50b3358c5fb4d0b__is-solid{--wp-ui-button-background-color:var(--wpds-color-background-interactive-neutral-strong,#2d2d2d);--wp-ui-button-background-color-active:var(--wpds-color-background-interactive-neutral-strong-active,#1e1e1e);--wp-ui-button-background-color-disabled:var(--wpds-color-background-interactive-neutral-strong-disabled,#e6e6e6);--wp-ui-button-foreground-color:var(--wpds-color-foreground-interactive-neutral-strong,#f0f0f0);--wp-ui-button-foreground-color-active:var(--wpds-color-foreground-interactive-neutral-strong-active,#f0f0f0);--wp-ui-button-foreground-color-disabled:var(--wpds-color-foreground-interactive-neutral-strong-disabled,#8d8d8d)}&._62d5a778b7b258ee__is-outline,&.ad0619a3217c6a5b__is-minimal:not([aria-pressed=true]){--wp-ui-button-foreground-color:var(--wpds-color-foreground-interactive-neutral,#1e1e1e);--wp-ui-button-foreground-color-active:var(--wpds-color-foreground-interactive-neutral-active,#1e1e1e);--wp-ui-button-foreground-color-disabled:var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d)}&._62d5a778b7b258ee__is-outline{--wp-ui-button-background-color:var(--wpds-color-background-interactive-neutral-weak,#0000);--wp-ui-button-background-color-active:var(--wpds-color-background-interactive-neutral-weak-active,#ededed);--wp-ui-button-background-color-disabled:var(--wpds-color-background-interactive-neutral-weak-disabled,#0000);--wp-ui-button-border-color:var(--wpds-color-stroke-interactive-neutral,#8d8d8d);--wp-ui-button-border-color-active:var(--wpds-color-stroke-interactive-neutral-active,#6e6e6e);--wp-ui-button-border-color-disabled:var(--wpds-color-stroke-interactive-neutral-disabled,#dbdbdb)}&.ad0619a3217c6a5b__is-minimal:not([aria-pressed=true]){--wp-ui-button-background-color:var(--wpds-color-background-interactive-neutral-weak,#0000);--wp-ui-button-background-color-active:var(--wpds-color-background-interactive-neutral-weak-active,#ededed);--wp-ui-button-background-color-disabled:var(--wpds-color-background-interactive-neutral-weak-disabled,#0000)}}.abbb272e2ce49bd6__is-unstyled{background:none;border:none;min-width:unset}.cf59cf1b69629838__is-compact{--wp-ui-button-height:var(--wpds-dimension-size-md,32px)}._914b42f315c0e580__is-loading:not(.abbb272e2ce49bd6__is-unstyled){color:transparent;&:not([data-disabled]):is(:hover,:active,:focus){color:transparent}@media (forced-colors:active){color:ButtonFace}*{opacity:0}&:before{opacity:1;transition-delay:.05s;@media not (prefers-reduced-motion){animation:_5a1d53da6f830c8d__loading-animation 1s linear infinite}}}}@keyframes _5a1d53da6f830c8d__loading-animation{0%{transform:translate(-50%,-50%) rotate(0deg)}to{transform:translate(-50%,-50%) rotate(1turn)}}}');
14015 }
14016 var style_default8 = { "button": "_97b0fc33c028be1a__button", "is-unstyled": "abbb272e2ce49bd6__is-unstyled", "is-loading": "_914b42f315c0e580__is-loading", "is-small": "_908205475f9f2a92__is-small", "icon": "_9f6fc6553aeb36fe__icon", "is-brand": "dd460c965226cc77__is-brand", "is-outline": "_62d5a778b7b258ee__is-outline", "is-minimal": "ad0619a3217c6a5b__is-minimal", "is-neutral": "e722a8f96726aa99__is-neutral", "is-solid": "b50b3358c5fb4d0b__is-solid", "is-compact": "cf59cf1b69629838__is-compact", "loading-animation": "_5a1d53da6f830c8d__loading-animation" };
14017 var ButtonIcon = (0, import_element22.forwardRef)(
14018 function ButtonIcon2({ className, icon, ...props }, ref) {
14019 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
14020 Icon,
14021 {
14022 ref,
14023 icon,
14024 className: clsx_default(style_default8.icon, className),
14025 size: 24,
14026 ...props
14027 }
14028 );
14029 }
14030 );
14031
14032 // packages/ui/build-module/button/index.mjs
14033 ButtonIcon.displayName = "Button.Icon";
14034 var Button4 = Object.assign(Button3, {
14035 /**
14036 * An icon component specifically designed to work well when rendered inside
14037 * a `Button` component.
14038 */
14039 Icon: ButtonIcon
14040 });
14041
14042 // node_modules/@date-fns/tz/tzName/index.js
14043 function tzName(timeZone, date, format7 = "long") {
14044 return new Intl.DateTimeFormat("en-US", {
14045 // Enforces engine to render the time. Without the option JavaScriptCore omits it.
14046 hour: "numeric",
14047 timeZone,
14048 timeZoneName: format7
14049 }).format(date).split(/\s/g).slice(2).join(" ");
14050 }
14051
14052 // node_modules/@date-fns/tz/tzOffset/index.js
14053 var offsetFormatCache = {};
14054 var offsetCache = {};
14055 function tzOffset(timeZone, date) {
14056 try {
14057 const format7 = offsetFormatCache[timeZone] ||= new Intl.DateTimeFormat("en-US", {
14058 timeZone,
14059 timeZoneName: "longOffset"
14060 }).format;
14061 const offsetStr = format7(date).split("GMT")[1];
14062 if (offsetStr in offsetCache) return offsetCache[offsetStr];
14063 return calcOffset(offsetStr, offsetStr.split(":"));
14064 } catch {
14065 if (timeZone in offsetCache) return offsetCache[timeZone];
14066 const captures = timeZone?.match(offsetRe);
14067 if (captures) return calcOffset(timeZone, captures.slice(1));
14068 return NaN;
14069 }
14070 }
14071 var offsetRe = /([+-]\d\d):?(\d\d)?/;
14072 function calcOffset(cacheStr, values) {
14073 const hours = +(values[0] || 0);
14074 const minutes = +(values[1] || 0);
14075 const seconds = +(values[2] || 0) / 60;
14076 return offsetCache[cacheStr] = hours * 60 + minutes > 0 ? hours * 60 + minutes + seconds : hours * 60 - minutes - seconds;
14077 }
14078
14079 // node_modules/@date-fns/tz/date/mini.js
14080 var TZDateMini = class _TZDateMini extends Date {
14081 //#region static
14082 constructor(...args) {
14083 super();
14084 if (args.length > 1 && typeof args[args.length - 1] === "string") {
14085 this.timeZone = args.pop();
14086 }
14087 this.internal = /* @__PURE__ */ new Date();
14088 if (isNaN(tzOffset(this.timeZone, this))) {
14089 this.setTime(NaN);
14090 } else {
14091 if (!args.length) {
14092 this.setTime(Date.now());
14093 } else if (typeof args[0] === "number" && (args.length === 1 || args.length === 2 && typeof args[1] !== "number")) {
14094 this.setTime(args[0]);
14095 } else if (typeof args[0] === "string") {
14096 this.setTime(+new Date(args[0]));
14097 } else if (args[0] instanceof Date) {
14098 this.setTime(+args[0]);
14099 } else {
14100 this.setTime(+new Date(...args));
14101 adjustToSystemTZ(this, args);
14102 }
14103 }
14104 }
14105 static tz(tz, ...args) {
14106 return args.length ? new _TZDateMini(...args, tz) : new _TZDateMini(Date.now(), tz);
14107 }
14108 //#endregion
14109 //#region time zone
14110 withTimeZone(timeZone) {
14111 return new _TZDateMini(+this, timeZone);
14112 }
14113 getTimezoneOffset() {
14114 const offset4 = -tzOffset(this.timeZone, this);
14115 return offset4 > 0 ? Math.floor(offset4) : Math.ceil(offset4);
14116 }
14117 //#endregion
14118 //#region time
14119 setTime(_time) {
14120 Date.prototype.setTime.apply(this, arguments);
14121 syncToInternal(this);
14122 return +this;
14123 }
14124 //#endregion
14125 //#region date-fns integration
14126 [/* @__PURE__ */ Symbol.for("constructDateFrom")](date) {
14127 return new _TZDateMini(+new Date(date), this.timeZone);
14128 }
14129 //#endregion
14130 };
14131 var re = /^(get|set)(?!UTC)/;
14132 Object.getOwnPropertyNames(Date.prototype).forEach((method) => {
14133 if (!re.test(method)) return;
14134 const utcMethod = method.replace(re, "$1UTC");
14135 if (!TZDateMini.prototype[utcMethod]) return;
14136 if (method.startsWith("get")) {
14137 TZDateMini.prototype[method] = function() {
14138 return this.internal[utcMethod]();
14139 };
14140 } else {
14141 TZDateMini.prototype[method] = function() {
14142 Date.prototype[utcMethod].apply(this.internal, arguments);
14143 syncFromInternal(this);
14144 return +this;
14145 };
14146 TZDateMini.prototype[utcMethod] = function() {
14147 Date.prototype[utcMethod].apply(this, arguments);
14148 syncToInternal(this);
14149 return +this;
14150 };
14151 }
14152 });
14153 function syncToInternal(date) {
14154 date.internal.setTime(+date);
14155 date.internal.setUTCSeconds(date.internal.getUTCSeconds() - // Round after converting minutes to seconds to avoid fractional offset
14156 // precision errors from historical offsets.
14157 Math.round(-tzOffset(date.timeZone, date) * 60));
14158 }
14159 function syncFromInternal(date) {
14160 Date.prototype.setFullYear.call(date, date.internal.getUTCFullYear(), date.internal.getUTCMonth(), date.internal.getUTCDate());
14161 Date.prototype.setHours.call(date, date.internal.getUTCHours(), date.internal.getUTCMinutes(), date.internal.getUTCSeconds(), date.internal.getUTCMilliseconds());
14162 adjustToSystemTZ(date);
14163 }
14164 function adjustToSystemTZ(date, constructorArgs) {
14165 const expectedInternalTime = Array.isArray(constructorArgs) ? constructorArgsToInternalTime(constructorArgs) : +date.internal;
14166 const offsetWithSeconds = tzOffset(date.timeZone, date);
14167 const offset4 = offsetWithSeconds > 0 ? Math.floor(offsetWithSeconds) : Math.ceil(offsetWithSeconds);
14168 const prevHour = /* @__PURE__ */ new Date(+date);
14169 prevHour.setUTCHours(prevHour.getUTCHours() - 1);
14170 const systemOffset = -(/* @__PURE__ */ new Date(+date)).getTimezoneOffset();
14171 const prevHourSystemOffset = -(/* @__PURE__ */ new Date(+prevHour)).getTimezoneOffset();
14172 const systemDSTChange = systemOffset - prevHourSystemOffset;
14173 let systemOffsetForDiff = systemOffset;
14174 if (systemDSTChange && systemOffset !== offset4) {
14175 const systemHour = Date.prototype.getHours.apply(date);
14176 const expectedHour = Array.isArray(constructorArgs) ? constructorArgs[3] || 0 : date.internal.getUTCHours();
14177 if (systemHour !== expectedHour) {
14178 const testDate = /* @__PURE__ */ new Date(+date);
14179 const testOffsetDiff = systemOffset - offset4;
14180 if (testOffsetDiff) testDate.setUTCMinutes(testDate.getUTCMinutes() + testOffsetDiff);
14181 const testOffsetWithSeconds = tzOffset(date.timeZone, testDate);
14182 const testOffset = testOffsetWithSeconds > 0 ? Math.floor(testOffsetWithSeconds) : Math.ceil(testOffsetWithSeconds);
14183 if (testOffset === offset4) systemOffsetForDiff = prevHourSystemOffset;
14184 }
14185 }
14186 const offsetDiff = systemOffsetForDiff - offset4;
14187 if (offsetDiff)
14188 Date.prototype.setUTCMinutes.call(date, Date.prototype.getUTCMinutes.call(date) + offsetDiff);
14189 const systemDate = /* @__PURE__ */ new Date(+date);
14190 systemDate.setUTCSeconds(0);
14191 const systemSecondsOffset = systemOffset > 0 ? systemDate.getSeconds() : (systemDate.getSeconds() - 60) % 60;
14192 const secondsOffset = Math.round(-(tzOffset(date.timeZone, date) * 60)) % 60;
14193 if (secondsOffset || systemSecondsOffset)
14194 Date.prototype.setUTCSeconds.call(date, Date.prototype.getUTCSeconds.call(date) + secondsOffset + systemSecondsOffset);
14195 const postOffsetWithSeconds = tzOffset(date.timeZone, date);
14196 const postOffset = postOffsetWithSeconds > 0 ? Math.floor(postOffsetWithSeconds) : Math.ceil(postOffsetWithSeconds);
14197 const postSystemOffset = -(/* @__PURE__ */ new Date(+date)).getTimezoneOffset();
14198 const postOffsetDiff = postSystemOffset - postOffset;
14199 const offsetChanged = postOffset !== offset4;
14200 const postDiff = postOffsetDiff - offsetDiff;
14201 const targetDSTShift = postOffset - offset4;
14202 const postOffsetCandidate = expectedInternalTime - postOffset * 60 * 1e3;
14203 const normalizedTargetDSTGap = targetDSTShift > 0 && targetInternalTime(date) - expectedInternalTime === targetDSTShift * 60 * 1e3 && targetInternalTime(date, postOffsetCandidate) !== expectedInternalTime;
14204 if (offsetChanged && postDiff && !normalizedTargetDSTGap) {
14205 Date.prototype.setUTCMinutes.call(date, Date.prototype.getUTCMinutes.call(date) + postDiff);
14206 const newOffsetWithSeconds = tzOffset(date.timeZone, date);
14207 const newOffset = newOffsetWithSeconds > 0 ? Math.floor(newOffsetWithSeconds) : Math.ceil(newOffsetWithSeconds);
14208 const offsetChange = postOffset - newOffset;
14209 if (offsetChange && postDiff < 0) {
14210 Date.prototype.setUTCMinutes.call(date, Date.prototype.getUTCMinutes.call(date) + offsetChange);
14211 }
14212 }
14213 syncToInternal(date);
14214 const expectedTime = constructorArgs ? expectedInternalTime : expectedInternalTime + secondsOffset * 1e3;
14215 const drift = expectedTime - +date.internal;
14216 if (drift && Math.abs(drift) < 30 * 60 * 1e3) {
14217 Date.prototype.setTime.call(date, +date + drift);
14218 syncToInternal(date);
14219 }
14220 }
14221 function constructorArgsToInternalTime(args) {
14222 return Date.UTC(args[0], args.length > 1 ? args[1] : 0, args.length > 2 ? args[2] : 1, ...args.slice(3));
14223 }
14224 function targetInternalTime(date, time) {
14225 const internal = new Date(time ?? +date);
14226 internal.setUTCSeconds(internal.getUTCSeconds() - Math.round(-tzOffset(date.timeZone, internal) * 60));
14227 return +internal;
14228 }
14229
14230 // node_modules/@date-fns/tz/date/index.js
14231 var TZDate = class _TZDate extends TZDateMini {
14232 //#region static
14233 static tz(tz, ...args) {
14234 return args.length ? new _TZDate(...args, tz) : new _TZDate(Date.now(), tz);
14235 }
14236 //#endregion
14237 //#region representation
14238 toISOString() {
14239 const [sign, hours, minutes] = this.tzComponents();
14240 const tz = `${sign}${hours}:${minutes}`;
14241 return this.internal.toISOString().slice(0, -1) + tz;
14242 }
14243 toString() {
14244 return `${this.toDateString()} ${this.toTimeString()}`;
14245 }
14246 toDateString() {
14247 const [day, date, month, year] = this.internal.toUTCString().split(" ");
14248 return `${day?.slice(0, -1)} ${month} ${date} ${year}`;
14249 }
14250 toTimeString() {
14251 const time = this.internal.toUTCString().split(" ")[4];
14252 const [sign, hours, minutes] = this.tzComponents();
14253 return `${time} GMT${sign}${hours}${minutes} (${tzName(this.timeZone, this)})`;
14254 }
14255 toLocaleString(locales, options) {
14256 return Date.prototype.toLocaleString.call(this, locales, {
14257 ...options,
14258 timeZone: options?.timeZone || this.timeZone
14259 });
14260 }
14261 toLocaleDateString(locales, options) {
14262 return Date.prototype.toLocaleDateString.call(this, locales, {
14263 ...options,
14264 timeZone: options?.timeZone || this.timeZone
14265 });
14266 }
14267 toLocaleTimeString(locales, options) {
14268 return Date.prototype.toLocaleTimeString.call(this, locales, {
14269 ...options,
14270 timeZone: options?.timeZone || this.timeZone
14271 });
14272 }
14273 //#endregion
14274 //#region private
14275 tzComponents() {
14276 const offset4 = this.getTimezoneOffset();
14277 const sign = offset4 > 0 ? "-" : "+";
14278 const hours = String(Math.floor(Math.abs(offset4) / 60)).padStart(2, "0");
14279 const minutes = String(Math.abs(offset4) % 60).padStart(2, "0");
14280 return [sign, hours, minutes];
14281 }
14282 //#endregion
14283 withTimeZone(timeZone) {
14284 return new _TZDate(+this, timeZone);
14285 }
14286 //#region date-fns integration
14287 [/* @__PURE__ */ Symbol.for("constructDateFrom")](date) {
14288 return new _TZDate(+new Date(date), this.timeZone);
14289 }
14290 //#endregion
14291 };
14292
14293 // node_modules/date-fns/constants.js
14294 var daysInYear = 365.2425;
14295 var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3;
14296 var minTime = -maxTime;
14297 var millisecondsInWeek = 6048e5;
14298 var millisecondsInDay = 864e5;
14299 var millisecondsInMinute = 6e4;
14300 var millisecondsInHour = 36e5;
14301 var millisecondsInSecond = 1e3;
14302 var secondsInHour = 3600;
14303 var secondsInDay = secondsInHour * 24;
14304 var secondsInWeek = secondsInDay * 7;
14305 var secondsInYear = secondsInDay * daysInYear;
14306 var secondsInMonth = secondsInYear / 12;
14307 var secondsInQuarter = secondsInMonth * 3;
14308 var constructFromSymbol = /* @__PURE__ */ Symbol.for("constructDateFrom");
14309
14310 // node_modules/date-fns/constructFrom.js
14311 function constructFrom(date, value) {
14312 if (typeof date === "function") return date(value);
14313 if (date && typeof date === "object" && constructFromSymbol in date)
14314 return date[constructFromSymbol](value);
14315 if (date instanceof Date) return new date.constructor(value);
14316 return new Date(value);
14317 }
14318
14319 // node_modules/date-fns/toDate.js
14320 function toDate(argument, context) {
14321 return constructFrom(context || argument, argument);
14322 }
14323
14324 // node_modules/date-fns/addDays.js
14325 function addDays(date, amount, options) {
14326 const _date = toDate(date, options?.in);
14327 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
14328 if (!amount) return _date;
14329 _date.setDate(_date.getDate() + amount);
14330 return _date;
14331 }
14332
14333 // node_modules/date-fns/addMonths.js
14334 function addMonths(date, amount, options) {
14335 const _date = toDate(date, options?.in);
14336 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
14337 if (!amount) {
14338 return _date;
14339 }
14340 const dayOfMonth = _date.getDate();
14341 const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime());
14342 endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0);
14343 const daysInMonth = endOfDesiredMonth.getDate();
14344 if (dayOfMonth >= daysInMonth) {
14345 return endOfDesiredMonth;
14346 } else {
14347 _date.setFullYear(
14348 endOfDesiredMonth.getFullYear(),
14349 endOfDesiredMonth.getMonth(),
14350 dayOfMonth
14351 );
14352 return _date;
14353 }
14354 }
14355
14356 // node_modules/date-fns/_lib/defaultOptions.js
14357 var defaultOptions = {};
14358 function getDefaultOptions() {
14359 return defaultOptions;
14360 }
14361
14362 // node_modules/date-fns/startOfWeek.js
14363 function startOfWeek(date, options) {
14364 const defaultOptions2 = getDefaultOptions();
14365 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
14366 const _date = toDate(date, options?.in);
14367 const day = _date.getDay();
14368 const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
14369 _date.setDate(_date.getDate() - diff);
14370 _date.setHours(0, 0, 0, 0);
14371 return _date;
14372 }
14373
14374 // node_modules/date-fns/startOfISOWeek.js
14375 function startOfISOWeek(date, options) {
14376 return startOfWeek(date, { ...options, weekStartsOn: 1 });
14377 }
14378
14379 // node_modules/date-fns/getISOWeekYear.js
14380 function getISOWeekYear(date, options) {
14381 const _date = toDate(date, options?.in);
14382 const year = _date.getFullYear();
14383 const fourthOfJanuaryOfNextYear = constructFrom(_date, 0);
14384 fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4);
14385 fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0);
14386 const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear);
14387 const fourthOfJanuaryOfThisYear = constructFrom(_date, 0);
14388 fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4);
14389 fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0);
14390 const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear);
14391 if (_date.getTime() >= startOfNextYear.getTime()) {
14392 return year + 1;
14393 } else if (_date.getTime() >= startOfThisYear.getTime()) {
14394 return year;
14395 } else {
14396 return year - 1;
14397 }
14398 }
14399
14400 // node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js
14401 function getTimezoneOffsetInMilliseconds(date) {
14402 const _date = toDate(date);
14403 const utcDate = new Date(
14404 Date.UTC(
14405 _date.getFullYear(),
14406 _date.getMonth(),
14407 _date.getDate(),
14408 _date.getHours(),
14409 _date.getMinutes(),
14410 _date.getSeconds(),
14411 _date.getMilliseconds()
14412 )
14413 );
14414 utcDate.setUTCFullYear(_date.getFullYear());
14415 return +date - +utcDate;
14416 }
14417
14418 // node_modules/date-fns/_lib/normalizeDates.js
14419 function normalizeDates(context, ...dates) {
14420 const normalize2 = constructFrom.bind(
14421 null,
14422 context || dates.find((date) => typeof date === "object")
14423 );
14424 return dates.map(normalize2);
14425 }
14426
14427 // node_modules/date-fns/startOfDay.js
14428 function startOfDay(date, options) {
14429 const _date = toDate(date, options?.in);
14430 _date.setHours(0, 0, 0, 0);
14431 return _date;
14432 }
14433
14434 // node_modules/date-fns/differenceInCalendarDays.js
14435 function differenceInCalendarDays(laterDate, earlierDate, options) {
14436 const [laterDate_, earlierDate_] = normalizeDates(
14437 options?.in,
14438 laterDate,
14439 earlierDate
14440 );
14441 const laterStartOfDay = startOfDay(laterDate_);
14442 const earlierStartOfDay = startOfDay(earlierDate_);
14443 const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay);
14444 const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay);
14445 return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay);
14446 }
14447
14448 // node_modules/date-fns/startOfISOWeekYear.js
14449 function startOfISOWeekYear(date, options) {
14450 const year = getISOWeekYear(date, options);
14451 const fourthOfJanuary = constructFrom(options?.in || date, 0);
14452 fourthOfJanuary.setFullYear(year, 0, 4);
14453 fourthOfJanuary.setHours(0, 0, 0, 0);
14454 return startOfISOWeek(fourthOfJanuary);
14455 }
14456
14457 // node_modules/date-fns/addWeeks.js
14458 function addWeeks(date, amount, options) {
14459 return addDays(date, amount * 7, options);
14460 }
14461
14462 // node_modules/date-fns/addYears.js
14463 function addYears(date, amount, options) {
14464 return addMonths(date, amount * 12, options);
14465 }
14466
14467 // node_modules/date-fns/areIntervalsOverlapping.js
14468 function areIntervalsOverlapping(intervalLeft, intervalRight, options) {
14469 const [leftStartTime, leftEndTime] = [
14470 +toDate(intervalLeft.start, options?.in),
14471 +toDate(intervalLeft.end, options?.in)
14472 ].sort((a, b) => a - b);
14473 const [rightStartTime, rightEndTime] = [
14474 +toDate(intervalRight.start, options?.in),
14475 +toDate(intervalRight.end, options?.in)
14476 ].sort((a, b) => a - b);
14477 if (options?.inclusive)
14478 return leftStartTime <= rightEndTime && rightStartTime <= leftEndTime;
14479 return leftStartTime < rightEndTime && rightStartTime < leftEndTime;
14480 }
14481
14482 // node_modules/date-fns/max.js
14483 function max2(dates, options) {
14484 let result;
14485 let context = options?.in;
14486 dates.forEach((date) => {
14487 if (!context && typeof date === "object")
14488 context = constructFrom.bind(null, date);
14489 const date_ = toDate(date, context);
14490 if (!result || result < date_ || isNaN(+date_)) result = date_;
14491 });
14492 return constructFrom(context, result || NaN);
14493 }
14494
14495 // node_modules/date-fns/min.js
14496 function min2(dates, options) {
14497 let result;
14498 let context = options?.in;
14499 dates.forEach((date) => {
14500 if (!context && typeof date === "object")
14501 context = constructFrom.bind(null, date);
14502 const date_ = toDate(date, context);
14503 if (!result || result > date_ || isNaN(+date_)) result = date_;
14504 });
14505 return constructFrom(context, result || NaN);
14506 }
14507
14508 // node_modules/date-fns/isSameDay.js
14509 function isSameDay(laterDate, earlierDate, options) {
14510 const [dateLeft_, dateRight_] = normalizeDates(
14511 options?.in,
14512 laterDate,
14513 earlierDate
14514 );
14515 return +startOfDay(dateLeft_) === +startOfDay(dateRight_);
14516 }
14517
14518 // node_modules/date-fns/isDate.js
14519 function isDate(value) {
14520 return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]";
14521 }
14522
14523 // node_modules/date-fns/isValid.js
14524 function isValid(date) {
14525 return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date)));
14526 }
14527
14528 // node_modules/date-fns/differenceInCalendarMonths.js
14529 function differenceInCalendarMonths(laterDate, earlierDate, options) {
14530 const [laterDate_, earlierDate_] = normalizeDates(
14531 options?.in,
14532 laterDate,
14533 earlierDate
14534 );
14535 const yearsDiff = laterDate_.getFullYear() - earlierDate_.getFullYear();
14536 const monthsDiff = laterDate_.getMonth() - earlierDate_.getMonth();
14537 return yearsDiff * 12 + monthsDiff;
14538 }
14539
14540 // node_modules/date-fns/endOfMonth.js
14541 function endOfMonth(date, options) {
14542 const _date = toDate(date, options?.in);
14543 const month = _date.getMonth();
14544 _date.setFullYear(_date.getFullYear(), month + 1, 0);
14545 _date.setHours(23, 59, 59, 999);
14546 return _date;
14547 }
14548
14549 // node_modules/date-fns/_lib/normalizeInterval.js
14550 function normalizeInterval(context, interval) {
14551 const [start, end] = normalizeDates(context, interval.start, interval.end);
14552 return { start, end };
14553 }
14554
14555 // node_modules/date-fns/eachMonthOfInterval.js
14556 function eachMonthOfInterval(interval, options) {
14557 const { start, end } = normalizeInterval(options?.in, interval);
14558 let reversed = +start > +end;
14559 const endTime = reversed ? +start : +end;
14560 const date = reversed ? end : start;
14561 date.setHours(0, 0, 0, 0);
14562 date.setDate(1);
14563 let step = options?.step ?? 1;
14564 if (!step) return [];
14565 if (step < 0) {
14566 step = -step;
14567 reversed = !reversed;
14568 }
14569 const dates = [];
14570 while (+date <= endTime) {
14571 dates.push(constructFrom(start, date));
14572 date.setMonth(date.getMonth() + step);
14573 }
14574 return reversed ? dates.reverse() : dates;
14575 }
14576
14577 // node_modules/date-fns/startOfMonth.js
14578 function startOfMonth(date, options) {
14579 const _date = toDate(date, options?.in);
14580 _date.setDate(1);
14581 _date.setHours(0, 0, 0, 0);
14582 return _date;
14583 }
14584
14585 // node_modules/date-fns/endOfYear.js
14586 function endOfYear(date, options) {
14587 const _date = toDate(date, options?.in);
14588 const year = _date.getFullYear();
14589 _date.setFullYear(year + 1, 0, 0);
14590 _date.setHours(23, 59, 59, 999);
14591 return _date;
14592 }
14593
14594 // node_modules/date-fns/startOfYear.js
14595 function startOfYear(date, options) {
14596 const date_ = toDate(date, options?.in);
14597 date_.setFullYear(date_.getFullYear(), 0, 1);
14598 date_.setHours(0, 0, 0, 0);
14599 return date_;
14600 }
14601
14602 // node_modules/date-fns/eachYearOfInterval.js
14603 function eachYearOfInterval(interval, options) {
14604 const { start, end } = normalizeInterval(options?.in, interval);
14605 let reversed = +start > +end;
14606 const endTime = reversed ? +start : +end;
14607 const date = reversed ? end : start;
14608 date.setHours(0, 0, 0, 0);
14609 date.setMonth(0, 1);
14610 let step = options?.step ?? 1;
14611 if (!step) return [];
14612 if (step < 0) {
14613 step = -step;
14614 reversed = !reversed;
14615 }
14616 const dates = [];
14617 while (+date <= endTime) {
14618 dates.push(constructFrom(start, date));
14619 date.setFullYear(date.getFullYear() + step);
14620 }
14621 return reversed ? dates.reverse() : dates;
14622 }
14623
14624 // node_modules/date-fns/endOfWeek.js
14625 function endOfWeek(date, options) {
14626 const defaultOptions2 = getDefaultOptions();
14627 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
14628 const _date = toDate(date, options?.in);
14629 const day = _date.getDay();
14630 const diff = (day < weekStartsOn ? -7 : 0) + 6 - (day - weekStartsOn);
14631 _date.setDate(_date.getDate() + diff);
14632 _date.setHours(23, 59, 59, 999);
14633 return _date;
14634 }
14635
14636 // node_modules/date-fns/endOfISOWeek.js
14637 function endOfISOWeek(date, options) {
14638 return endOfWeek(date, { ...options, weekStartsOn: 1 });
14639 }
14640
14641 // node_modules/date-fns/locale/en-US/_lib/formatDistance.js
14642 var formatDistanceLocale = {
14643 lessThanXSeconds: {
14644 one: "less than a second",
14645 other: "less than {{count}} seconds"
14646 },
14647 xSeconds: {
14648 one: "1 second",
14649 other: "{{count}} seconds"
14650 },
14651 halfAMinute: "half a minute",
14652 lessThanXMinutes: {
14653 one: "less than a minute",
14654 other: "less than {{count}} minutes"
14655 },
14656 xMinutes: {
14657 one: "1 minute",
14658 other: "{{count}} minutes"
14659 },
14660 aboutXHours: {
14661 one: "about 1 hour",
14662 other: "about {{count}} hours"
14663 },
14664 xHours: {
14665 one: "1 hour",
14666 other: "{{count}} hours"
14667 },
14668 xDays: {
14669 one: "1 day",
14670 other: "{{count}} days"
14671 },
14672 aboutXWeeks: {
14673 one: "about 1 week",
14674 other: "about {{count}} weeks"
14675 },
14676 xWeeks: {
14677 one: "1 week",
14678 other: "{{count}} weeks"
14679 },
14680 aboutXMonths: {
14681 one: "about 1 month",
14682 other: "about {{count}} months"
14683 },
14684 xMonths: {
14685 one: "1 month",
14686 other: "{{count}} months"
14687 },
14688 aboutXYears: {
14689 one: "about 1 year",
14690 other: "about {{count}} years"
14691 },
14692 xYears: {
14693 one: "1 year",
14694 other: "{{count}} years"
14695 },
14696 overXYears: {
14697 one: "over 1 year",
14698 other: "over {{count}} years"
14699 },
14700 almostXYears: {
14701 one: "almost 1 year",
14702 other: "almost {{count}} years"
14703 }
14704 };
14705 var formatDistance = (token, count, options) => {
14706 let result;
14707 const tokenValue = formatDistanceLocale[token];
14708 if (typeof tokenValue === "string") {
14709 result = tokenValue;
14710 } else if (count === 1) {
14711 result = tokenValue.one;
14712 } else {
14713 result = tokenValue.other.replace("{{count}}", count.toString());
14714 }
14715 if (options?.addSuffix) {
14716 if (options.comparison && options.comparison > 0) {
14717 return "in " + result;
14718 } else {
14719 return result + " ago";
14720 }
14721 }
14722 return result;
14723 };
14724
14725 // node_modules/date-fns/locale/_lib/buildFormatLongFn.js
14726 function buildFormatLongFn(args) {
14727 return (options = {}) => {
14728 const width = options.width ? String(options.width) : args.defaultWidth;
14729 const format7 = args.formats[width] || args.formats[args.defaultWidth];
14730 return format7;
14731 };
14732 }
14733
14734 // node_modules/date-fns/locale/en-US/_lib/formatLong.js
14735 var dateFormats = {
14736 full: "EEEE, MMMM do, y",
14737 long: "MMMM do, y",
14738 medium: "MMM d, y",
14739 short: "MM/dd/yyyy"
14740 };
14741 var timeFormats = {
14742 full: "h:mm:ss a zzzz",
14743 long: "h:mm:ss a z",
14744 medium: "h:mm:ss a",
14745 short: "h:mm a"
14746 };
14747 var dateTimeFormats = {
14748 full: "{{date}} 'at' {{time}}",
14749 long: "{{date}} 'at' {{time}}",
14750 medium: "{{date}}, {{time}}",
14751 short: "{{date}}, {{time}}"
14752 };
14753 var formatLong = {
14754 date: buildFormatLongFn({
14755 formats: dateFormats,
14756 defaultWidth: "full"
14757 }),
14758 time: buildFormatLongFn({
14759 formats: timeFormats,
14760 defaultWidth: "full"
14761 }),
14762 dateTime: buildFormatLongFn({
14763 formats: dateTimeFormats,
14764 defaultWidth: "full"
14765 })
14766 };
14767
14768 // node_modules/date-fns/locale/en-US/_lib/formatRelative.js
14769 var formatRelativeLocale = {
14770 lastWeek: "'last' eeee 'at' p",
14771 yesterday: "'yesterday at' p",
14772 today: "'today at' p",
14773 tomorrow: "'tomorrow at' p",
14774 nextWeek: "eeee 'at' p",
14775 other: "P"
14776 };
14777 var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token];
14778
14779 // node_modules/date-fns/locale/_lib/buildLocalizeFn.js
14780 function buildLocalizeFn(args) {
14781 return (value, options) => {
14782 const context = options?.context ? String(options.context) : "standalone";
14783 let valuesArray;
14784 if (context === "formatting" && args.formattingValues) {
14785 const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
14786 const width = options?.width ? String(options.width) : defaultWidth;
14787 valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
14788 } else {
14789 const defaultWidth = args.defaultWidth;
14790 const width = options?.width ? String(options.width) : args.defaultWidth;
14791 valuesArray = args.values[width] || args.values[defaultWidth];
14792 }
14793 const index3 = args.argumentCallback ? args.argumentCallback(value) : value;
14794 return valuesArray[index3];
14795 };
14796 }
14797
14798 // node_modules/date-fns/locale/en-US/_lib/localize.js
14799 var eraValues = {
14800 narrow: ["B", "A"],
14801 abbreviated: ["BC", "AD"],
14802 wide: ["Before Christ", "Anno Domini"]
14803 };
14804 var quarterValues = {
14805 narrow: ["1", "2", "3", "4"],
14806 abbreviated: ["Q1", "Q2", "Q3", "Q4"],
14807 wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
14808 };
14809 var monthValues = {
14810 narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
14811 abbreviated: [
14812 "Jan",
14813 "Feb",
14814 "Mar",
14815 "Apr",
14816 "May",
14817 "Jun",
14818 "Jul",
14819 "Aug",
14820 "Sep",
14821 "Oct",
14822 "Nov",
14823 "Dec"
14824 ],
14825 wide: [
14826 "January",
14827 "February",
14828 "March",
14829 "April",
14830 "May",
14831 "June",
14832 "July",
14833 "August",
14834 "September",
14835 "October",
14836 "November",
14837 "December"
14838 ]
14839 };
14840 var dayValues = {
14841 narrow: ["S", "M", "T", "W", "T", "F", "S"],
14842 short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
14843 abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
14844 wide: [
14845 "Sunday",
14846 "Monday",
14847 "Tuesday",
14848 "Wednesday",
14849 "Thursday",
14850 "Friday",
14851 "Saturday"
14852 ]
14853 };
14854 var dayPeriodValues = {
14855 narrow: {
14856 am: "a",
14857 pm: "p",
14858 midnight: "mi",
14859 noon: "n",
14860 morning: "morning",
14861 afternoon: "afternoon",
14862 evening: "evening",
14863 night: "night"
14864 },
14865 abbreviated: {
14866 am: "AM",
14867 pm: "PM",
14868 midnight: "midnight",
14869 noon: "noon",
14870 morning: "morning",
14871 afternoon: "afternoon",
14872 evening: "evening",
14873 night: "night"
14874 },
14875 wide: {
14876 am: "a.m.",
14877 pm: "p.m.",
14878 midnight: "midnight",
14879 noon: "noon",
14880 morning: "morning",
14881 afternoon: "afternoon",
14882 evening: "evening",
14883 night: "night"
14884 }
14885 };
14886 var formattingDayPeriodValues = {
14887 narrow: {
14888 am: "a",
14889 pm: "p",
14890 midnight: "mi",
14891 noon: "n",
14892 morning: "in the morning",
14893 afternoon: "in the afternoon",
14894 evening: "in the evening",
14895 night: "at night"
14896 },
14897 abbreviated: {
14898 am: "AM",
14899 pm: "PM",
14900 midnight: "midnight",
14901 noon: "noon",
14902 morning: "in the morning",
14903 afternoon: "in the afternoon",
14904 evening: "in the evening",
14905 night: "at night"
14906 },
14907 wide: {
14908 am: "a.m.",
14909 pm: "p.m.",
14910 midnight: "midnight",
14911 noon: "noon",
14912 morning: "in the morning",
14913 afternoon: "in the afternoon",
14914 evening: "in the evening",
14915 night: "at night"
14916 }
14917 };
14918 var ordinalNumber = (dirtyNumber, _options) => {
14919 const number = Number(dirtyNumber);
14920 const rem100 = number % 100;
14921 if (rem100 > 20 || rem100 < 10) {
14922 switch (rem100 % 10) {
14923 case 1:
14924 return number + "st";
14925 case 2:
14926 return number + "nd";
14927 case 3:
14928 return number + "rd";
14929 }
14930 }
14931 return number + "th";
14932 };
14933 var localize = {
14934 ordinalNumber,
14935 era: buildLocalizeFn({
14936 values: eraValues,
14937 defaultWidth: "wide"
14938 }),
14939 quarter: buildLocalizeFn({
14940 values: quarterValues,
14941 defaultWidth: "wide",
14942 argumentCallback: (quarter) => quarter - 1
14943 }),
14944 month: buildLocalizeFn({
14945 values: monthValues,
14946 defaultWidth: "wide"
14947 }),
14948 day: buildLocalizeFn({
14949 values: dayValues,
14950 defaultWidth: "wide"
14951 }),
14952 dayPeriod: buildLocalizeFn({
14953 values: dayPeriodValues,
14954 defaultWidth: "wide",
14955 formattingValues: formattingDayPeriodValues,
14956 defaultFormattingWidth: "wide"
14957 })
14958 };
14959
14960 // node_modules/date-fns/locale/_lib/buildMatchFn.js
14961 function buildMatchFn(args) {
14962 return (string, options = {}) => {
14963 const width = options.width;
14964 const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
14965 const matchResult = string.match(matchPattern);
14966 if (!matchResult) {
14967 return null;
14968 }
14969 const matchedString = matchResult[0];
14970 const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
14971 const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : (
14972 // [TODO] -- I challenge you to fix the type
14973 findKey(parsePatterns, (pattern) => pattern.test(matchedString))
14974 );
14975 let value;
14976 value = args.valueCallback ? args.valueCallback(key) : key;
14977 value = options.valueCallback ? (
14978 // [TODO] -- I challenge you to fix the type
14979 options.valueCallback(value)
14980 ) : value;
14981 const rest = string.slice(matchedString.length);
14982 return { value, rest };
14983 };
14984 }
14985 function findKey(object, predicate) {
14986 for (const key in object) {
14987 if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) {
14988 return key;
14989 }
14990 }
14991 return void 0;
14992 }
14993 function findIndex(array, predicate) {
14994 for (let key = 0; key < array.length; key++) {
14995 if (predicate(array[key])) {
14996 return key;
14997 }
14998 }
14999 return void 0;
15000 }
15001
15002 // node_modules/date-fns/locale/_lib/buildMatchPatternFn.js
15003 function buildMatchPatternFn(args) {
15004 return (string, options = {}) => {
15005 const matchResult = string.match(args.matchPattern);
15006 if (!matchResult) return null;
15007 const matchedString = matchResult[0];
15008 const parseResult = string.match(args.parsePattern);
15009 if (!parseResult) return null;
15010 let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
15011 value = options.valueCallback ? options.valueCallback(value) : value;
15012 const rest = string.slice(matchedString.length);
15013 return { value, rest };
15014 };
15015 }
15016
15017 // node_modules/date-fns/locale/en-US/_lib/match.js
15018 var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
15019 var parseOrdinalNumberPattern = /\d+/i;
15020 var matchEraPatterns = {
15021 narrow: /^(b|a)/i,
15022 abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
15023 wide: /^(before christ|before common era|anno domini|common era)/i
15024 };
15025 var parseEraPatterns = {
15026 any: [/^b/i, /^(a|c)/i]
15027 };
15028 var matchQuarterPatterns = {
15029 narrow: /^[1234]/i,
15030 abbreviated: /^q[1234]/i,
15031 wide: /^[1234](th|st|nd|rd)? quarter/i
15032 };
15033 var parseQuarterPatterns = {
15034 any: [/1/i, /2/i, /3/i, /4/i]
15035 };
15036 var matchMonthPatterns = {
15037 narrow: /^[jfmasond]/i,
15038 abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
15039 wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
15040 };
15041 var parseMonthPatterns = {
15042 narrow: [
15043 /^j/i,
15044 /^f/i,
15045 /^m/i,
15046 /^a/i,
15047 /^m/i,
15048 /^j/i,
15049 /^j/i,
15050 /^a/i,
15051 /^s/i,
15052 /^o/i,
15053 /^n/i,
15054 /^d/i
15055 ],
15056 any: [
15057 /^ja/i,
15058 /^f/i,
15059 /^mar/i,
15060 /^ap/i,
15061 /^may/i,
15062 /^jun/i,
15063 /^jul/i,
15064 /^au/i,
15065 /^s/i,
15066 /^o/i,
15067 /^n/i,
15068 /^d/i
15069 ]
15070 };
15071 var matchDayPatterns = {
15072 narrow: /^[smtwf]/i,
15073 short: /^(su|mo|tu|we|th|fr|sa)/i,
15074 abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
15075 wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
15076 };
15077 var parseDayPatterns = {
15078 narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
15079 any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
15080 };
15081 var matchDayPeriodPatterns = {
15082 narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
15083 any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
15084 };
15085 var parseDayPeriodPatterns = {
15086 any: {
15087 am: /^a/i,
15088 pm: /^p/i,
15089 midnight: /^mi/i,
15090 noon: /^no/i,
15091 morning: /morning/i,
15092 afternoon: /afternoon/i,
15093 evening: /evening/i,
15094 night: /night/i
15095 }
15096 };
15097 var match = {
15098 ordinalNumber: buildMatchPatternFn({
15099 matchPattern: matchOrdinalNumberPattern,
15100 parsePattern: parseOrdinalNumberPattern,
15101 valueCallback: (value) => parseInt(value, 10)
15102 }),
15103 era: buildMatchFn({
15104 matchPatterns: matchEraPatterns,
15105 defaultMatchWidth: "wide",
15106 parsePatterns: parseEraPatterns,
15107 defaultParseWidth: "any"
15108 }),
15109 quarter: buildMatchFn({
15110 matchPatterns: matchQuarterPatterns,
15111 defaultMatchWidth: "wide",
15112 parsePatterns: parseQuarterPatterns,
15113 defaultParseWidth: "any",
15114 valueCallback: (index3) => index3 + 1
15115 }),
15116 month: buildMatchFn({
15117 matchPatterns: matchMonthPatterns,
15118 defaultMatchWidth: "wide",
15119 parsePatterns: parseMonthPatterns,
15120 defaultParseWidth: "any"
15121 }),
15122 day: buildMatchFn({
15123 matchPatterns: matchDayPatterns,
15124 defaultMatchWidth: "wide",
15125 parsePatterns: parseDayPatterns,
15126 defaultParseWidth: "any"
15127 }),
15128 dayPeriod: buildMatchFn({
15129 matchPatterns: matchDayPeriodPatterns,
15130 defaultMatchWidth: "any",
15131 parsePatterns: parseDayPeriodPatterns,
15132 defaultParseWidth: "any"
15133 })
15134 };
15135
15136 // node_modules/date-fns/locale/en-US.js
15137 var enUS = {
15138 code: "en-US",
15139 formatDistance,
15140 formatLong,
15141 formatRelative,
15142 localize,
15143 match,
15144 options: {
15145 weekStartsOn: 0,
15146 firstWeekContainsDate: 1
15147 }
15148 };
15149
15150 // node_modules/date-fns/getDayOfYear.js
15151 function getDayOfYear(date, options) {
15152 const _date = toDate(date, options?.in);
15153 const diff = differenceInCalendarDays(_date, startOfYear(_date));
15154 const dayOfYear = diff + 1;
15155 return dayOfYear;
15156 }
15157
15158 // node_modules/date-fns/getISOWeek.js
15159 function getISOWeek(date, options) {
15160 const _date = toDate(date, options?.in);
15161 const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date);
15162 return Math.round(diff / millisecondsInWeek) + 1;
15163 }
15164
15165 // node_modules/date-fns/getWeekYear.js
15166 function getWeekYear(date, options) {
15167 const _date = toDate(date, options?.in);
15168 const year = _date.getFullYear();
15169 const defaultOptions2 = getDefaultOptions();
15170 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
15171 const firstWeekOfNextYear = constructFrom(options?.in || date, 0);
15172 firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate);
15173 firstWeekOfNextYear.setHours(0, 0, 0, 0);
15174 const startOfNextYear = startOfWeek(firstWeekOfNextYear, options);
15175 const firstWeekOfThisYear = constructFrom(options?.in || date, 0);
15176 firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate);
15177 firstWeekOfThisYear.setHours(0, 0, 0, 0);
15178 const startOfThisYear = startOfWeek(firstWeekOfThisYear, options);
15179 if (+_date >= +startOfNextYear) {
15180 return year + 1;
15181 } else if (+_date >= +startOfThisYear) {
15182 return year;
15183 } else {
15184 return year - 1;
15185 }
15186 }
15187
15188 // node_modules/date-fns/startOfWeekYear.js
15189 function startOfWeekYear(date, options) {
15190 const defaultOptions2 = getDefaultOptions();
15191 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
15192 const year = getWeekYear(date, options);
15193 const firstWeek = constructFrom(options?.in || date, 0);
15194 firstWeek.setFullYear(year, 0, firstWeekContainsDate);
15195 firstWeek.setHours(0, 0, 0, 0);
15196 const _date = startOfWeek(firstWeek, options);
15197 return _date;
15198 }
15199
15200 // node_modules/date-fns/getWeek.js
15201 function getWeek(date, options) {
15202 const _date = toDate(date, options?.in);
15203 const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options);
15204 return Math.round(diff / millisecondsInWeek) + 1;
15205 }
15206
15207 // node_modules/date-fns/_lib/addLeadingZeros.js
15208 function addLeadingZeros(number, targetLength) {
15209 const sign = number < 0 ? "-" : "";
15210 const output = Math.abs(number).toString().padStart(targetLength, "0");
15211 return sign + output;
15212 }
15213
15214 // node_modules/date-fns/_lib/format/lightFormatters.js
15215 var lightFormatters = {
15216 // Year
15217 y(date, token) {
15218 const signedYear = date.getFullYear();
15219 const year = signedYear > 0 ? signedYear : 1 - signedYear;
15220 return addLeadingZeros(token === "yy" ? year % 100 : year, token.length);
15221 },
15222 // Month
15223 M(date, token) {
15224 const month = date.getMonth();
15225 return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2);
15226 },
15227 // Day of the month
15228 d(date, token) {
15229 return addLeadingZeros(date.getDate(), token.length);
15230 },
15231 // AM or PM
15232 a(date, token) {
15233 const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am";
15234 switch (token) {
15235 case "a":
15236 case "aa":
15237 return dayPeriodEnumValue.toUpperCase();
15238 case "aaa":
15239 return dayPeriodEnumValue;
15240 case "aaaaa":
15241 return dayPeriodEnumValue[0];
15242 case "aaaa":
15243 default:
15244 return dayPeriodEnumValue === "am" ? "a.m." : "p.m.";
15245 }
15246 },
15247 // Hour [1-12]
15248 h(date, token) {
15249 return addLeadingZeros(date.getHours() % 12 || 12, token.length);
15250 },
15251 // Hour [0-23]
15252 H(date, token) {
15253 return addLeadingZeros(date.getHours(), token.length);
15254 },
15255 // Minute
15256 m(date, token) {
15257 return addLeadingZeros(date.getMinutes(), token.length);
15258 },
15259 // Second
15260 s(date, token) {
15261 return addLeadingZeros(date.getSeconds(), token.length);
15262 },
15263 // Fraction of second
15264 S(date, token) {
15265 const numberOfDigits = token.length;
15266 const milliseconds = date.getMilliseconds();
15267 const fractionalSeconds = Math.trunc(
15268 milliseconds * Math.pow(10, numberOfDigits - 3)
15269 );
15270 return addLeadingZeros(fractionalSeconds, token.length);
15271 }
15272 };
15273
15274 // node_modules/date-fns/_lib/format/formatters.js
15275 var dayPeriodEnum = {
15276 am: "am",
15277 pm: "pm",
15278 midnight: "midnight",
15279 noon: "noon",
15280 morning: "morning",
15281 afternoon: "afternoon",
15282 evening: "evening",
15283 night: "night"
15284 };
15285 var formatters = {
15286 // Era
15287 G: function(date, token, localize2) {
15288 const era = date.getFullYear() > 0 ? 1 : 0;
15289 switch (token) {
15290 // AD, BC
15291 case "G":
15292 case "GG":
15293 case "GGG":
15294 return localize2.era(era, { width: "abbreviated" });
15295 // A, B
15296 case "GGGGG":
15297 return localize2.era(era, { width: "narrow" });
15298 // Anno Domini, Before Christ
15299 case "GGGG":
15300 default:
15301 return localize2.era(era, { width: "wide" });
15302 }
15303 },
15304 // Year
15305 y: function(date, token, localize2) {
15306 if (token === "yo") {
15307 const signedYear = date.getFullYear();
15308 const year = signedYear > 0 ? signedYear : 1 - signedYear;
15309 return localize2.ordinalNumber(year, { unit: "year" });
15310 }
15311 return lightFormatters.y(date, token);
15312 },
15313 // Local week-numbering year
15314 Y: function(date, token, localize2, options) {
15315 const signedWeekYear = getWeekYear(date, options);
15316 const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
15317 if (token === "YY") {
15318 const twoDigitYear = weekYear % 100;
15319 return addLeadingZeros(twoDigitYear, 2);
15320 }
15321 if (token === "Yo") {
15322 return localize2.ordinalNumber(weekYear, { unit: "year" });
15323 }
15324 return addLeadingZeros(weekYear, token.length);
15325 },
15326 // ISO week-numbering year
15327 R: function(date, token) {
15328 const isoWeekYear = getISOWeekYear(date);
15329 return addLeadingZeros(isoWeekYear, token.length);
15330 },
15331 // Extended year. This is a single number designating the year of this calendar system.
15332 // The main difference between `y` and `u` localizers are B.C. years:
15333 // | Year | `y` | `u` |
15334 // |------|-----|-----|
15335 // | AC 1 | 1 | 1 |
15336 // | BC 1 | 1 | 0 |
15337 // | BC 2 | 2 | -1 |
15338 // Also `yy` always returns the last two digits of a year,
15339 // while `uu` pads single digit years to 2 characters and returns other years unchanged.
15340 u: function(date, token) {
15341 const year = date.getFullYear();
15342 return addLeadingZeros(year, token.length);
15343 },
15344 // Quarter
15345 Q: function(date, token, localize2) {
15346 const quarter = Math.ceil((date.getMonth() + 1) / 3);
15347 switch (token) {
15348 // 1, 2, 3, 4
15349 case "Q":
15350 return String(quarter);
15351 // 01, 02, 03, 04
15352 case "QQ":
15353 return addLeadingZeros(quarter, 2);
15354 // 1st, 2nd, 3rd, 4th
15355 case "Qo":
15356 return localize2.ordinalNumber(quarter, { unit: "quarter" });
15357 // Q1, Q2, Q3, Q4
15358 case "QQQ":
15359 return localize2.quarter(quarter, {
15360 width: "abbreviated",
15361 context: "formatting"
15362 });
15363 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
15364 case "QQQQQ":
15365 return localize2.quarter(quarter, {
15366 width: "narrow",
15367 context: "formatting"
15368 });
15369 // 1st quarter, 2nd quarter, ...
15370 case "QQQQ":
15371 default:
15372 return localize2.quarter(quarter, {
15373 width: "wide",
15374 context: "formatting"
15375 });
15376 }
15377 },
15378 // Stand-alone quarter
15379 q: function(date, token, localize2) {
15380 const quarter = Math.ceil((date.getMonth() + 1) / 3);
15381 switch (token) {
15382 // 1, 2, 3, 4
15383 case "q":
15384 return String(quarter);
15385 // 01, 02, 03, 04
15386 case "qq":
15387 return addLeadingZeros(quarter, 2);
15388 // 1st, 2nd, 3rd, 4th
15389 case "qo":
15390 return localize2.ordinalNumber(quarter, { unit: "quarter" });
15391 // Q1, Q2, Q3, Q4
15392 case "qqq":
15393 return localize2.quarter(quarter, {
15394 width: "abbreviated",
15395 context: "standalone"
15396 });
15397 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
15398 case "qqqqq":
15399 return localize2.quarter(quarter, {
15400 width: "narrow",
15401 context: "standalone"
15402 });
15403 // 1st quarter, 2nd quarter, ...
15404 case "qqqq":
15405 default:
15406 return localize2.quarter(quarter, {
15407 width: "wide",
15408 context: "standalone"
15409 });
15410 }
15411 },
15412 // Month
15413 M: function(date, token, localize2) {
15414 const month = date.getMonth();
15415 switch (token) {
15416 case "M":
15417 case "MM":
15418 return lightFormatters.M(date, token);
15419 // 1st, 2nd, ..., 12th
15420 case "Mo":
15421 return localize2.ordinalNumber(month + 1, { unit: "month" });
15422 // Jan, Feb, ..., Dec
15423 case "MMM":
15424 return localize2.month(month, {
15425 width: "abbreviated",
15426 context: "formatting"
15427 });
15428 // J, F, ..., D
15429 case "MMMMM":
15430 return localize2.month(month, {
15431 width: "narrow",
15432 context: "formatting"
15433 });
15434 // January, February, ..., December
15435 case "MMMM":
15436 default:
15437 return localize2.month(month, { width: "wide", context: "formatting" });
15438 }
15439 },
15440 // Stand-alone month
15441 L: function(date, token, localize2) {
15442 const month = date.getMonth();
15443 switch (token) {
15444 // 1, 2, ..., 12
15445 case "L":
15446 return String(month + 1);
15447 // 01, 02, ..., 12
15448 case "LL":
15449 return addLeadingZeros(month + 1, 2);
15450 // 1st, 2nd, ..., 12th
15451 case "Lo":
15452 return localize2.ordinalNumber(month + 1, { unit: "month" });
15453 // Jan, Feb, ..., Dec
15454 case "LLL":
15455 return localize2.month(month, {
15456 width: "abbreviated",
15457 context: "standalone"
15458 });
15459 // J, F, ..., D
15460 case "LLLLL":
15461 return localize2.month(month, {
15462 width: "narrow",
15463 context: "standalone"
15464 });
15465 // January, February, ..., December
15466 case "LLLL":
15467 default:
15468 return localize2.month(month, { width: "wide", context: "standalone" });
15469 }
15470 },
15471 // Local week of year
15472 w: function(date, token, localize2, options) {
15473 const week = getWeek(date, options);
15474 if (token === "wo") {
15475 return localize2.ordinalNumber(week, { unit: "week" });
15476 }
15477 return addLeadingZeros(week, token.length);
15478 },
15479 // ISO week of year
15480 I: function(date, token, localize2) {
15481 const isoWeek = getISOWeek(date);
15482 if (token === "Io") {
15483 return localize2.ordinalNumber(isoWeek, { unit: "week" });
15484 }
15485 return addLeadingZeros(isoWeek, token.length);
15486 },
15487 // Day of the month
15488 d: function(date, token, localize2) {
15489 if (token === "do") {
15490 return localize2.ordinalNumber(date.getDate(), { unit: "date" });
15491 }
15492 return lightFormatters.d(date, token);
15493 },
15494 // Day of year
15495 D: function(date, token, localize2) {
15496 const dayOfYear = getDayOfYear(date);
15497 if (token === "Do") {
15498 return localize2.ordinalNumber(dayOfYear, { unit: "dayOfYear" });
15499 }
15500 return addLeadingZeros(dayOfYear, token.length);
15501 },
15502 // Day of week
15503 E: function(date, token, localize2) {
15504 const dayOfWeek = date.getDay();
15505 switch (token) {
15506 // Tue
15507 case "E":
15508 case "EE":
15509 case "EEE":
15510 return localize2.day(dayOfWeek, {
15511 width: "abbreviated",
15512 context: "formatting"
15513 });
15514 // T
15515 case "EEEEE":
15516 return localize2.day(dayOfWeek, {
15517 width: "narrow",
15518 context: "formatting"
15519 });
15520 // Tu
15521 case "EEEEEE":
15522 return localize2.day(dayOfWeek, {
15523 width: "short",
15524 context: "formatting"
15525 });
15526 // Tuesday
15527 case "EEEE":
15528 default:
15529 return localize2.day(dayOfWeek, {
15530 width: "wide",
15531 context: "formatting"
15532 });
15533 }
15534 },
15535 // Local day of week
15536 e: function(date, token, localize2, options) {
15537 const dayOfWeek = date.getDay();
15538 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
15539 switch (token) {
15540 // Numerical value (Nth day of week with current locale or weekStartsOn)
15541 case "e":
15542 return String(localDayOfWeek);
15543 // Padded numerical value
15544 case "ee":
15545 return addLeadingZeros(localDayOfWeek, 2);
15546 // 1st, 2nd, ..., 7th
15547 case "eo":
15548 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
15549 case "eee":
15550 return localize2.day(dayOfWeek, {
15551 width: "abbreviated",
15552 context: "formatting"
15553 });
15554 // T
15555 case "eeeee":
15556 return localize2.day(dayOfWeek, {
15557 width: "narrow",
15558 context: "formatting"
15559 });
15560 // Tu
15561 case "eeeeee":
15562 return localize2.day(dayOfWeek, {
15563 width: "short",
15564 context: "formatting"
15565 });
15566 // Tuesday
15567 case "eeee":
15568 default:
15569 return localize2.day(dayOfWeek, {
15570 width: "wide",
15571 context: "formatting"
15572 });
15573 }
15574 },
15575 // Stand-alone local day of week
15576 c: function(date, token, localize2, options) {
15577 const dayOfWeek = date.getDay();
15578 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
15579 switch (token) {
15580 // Numerical value (same as in `e`)
15581 case "c":
15582 return String(localDayOfWeek);
15583 // Padded numerical value
15584 case "cc":
15585 return addLeadingZeros(localDayOfWeek, token.length);
15586 // 1st, 2nd, ..., 7th
15587 case "co":
15588 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
15589 case "ccc":
15590 return localize2.day(dayOfWeek, {
15591 width: "abbreviated",
15592 context: "standalone"
15593 });
15594 // T
15595 case "ccccc":
15596 return localize2.day(dayOfWeek, {
15597 width: "narrow",
15598 context: "standalone"
15599 });
15600 // Tu
15601 case "cccccc":
15602 return localize2.day(dayOfWeek, {
15603 width: "short",
15604 context: "standalone"
15605 });
15606 // Tuesday
15607 case "cccc":
15608 default:
15609 return localize2.day(dayOfWeek, {
15610 width: "wide",
15611 context: "standalone"
15612 });
15613 }
15614 },
15615 // ISO day of week
15616 i: function(date, token, localize2) {
15617 const dayOfWeek = date.getDay();
15618 const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
15619 switch (token) {
15620 // 2
15621 case "i":
15622 return String(isoDayOfWeek);
15623 // 02
15624 case "ii":
15625 return addLeadingZeros(isoDayOfWeek, token.length);
15626 // 2nd
15627 case "io":
15628 return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" });
15629 // Tue
15630 case "iii":
15631 return localize2.day(dayOfWeek, {
15632 width: "abbreviated",
15633 context: "formatting"
15634 });
15635 // T
15636 case "iiiii":
15637 return localize2.day(dayOfWeek, {
15638 width: "narrow",
15639 context: "formatting"
15640 });
15641 // Tu
15642 case "iiiiii":
15643 return localize2.day(dayOfWeek, {
15644 width: "short",
15645 context: "formatting"
15646 });
15647 // Tuesday
15648 case "iiii":
15649 default:
15650 return localize2.day(dayOfWeek, {
15651 width: "wide",
15652 context: "formatting"
15653 });
15654 }
15655 },
15656 // AM or PM
15657 a: function(date, token, localize2) {
15658 const hours = date.getHours();
15659 const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
15660 switch (token) {
15661 case "a":
15662 case "aa":
15663 return localize2.dayPeriod(dayPeriodEnumValue, {
15664 width: "abbreviated",
15665 context: "formatting"
15666 });
15667 case "aaa":
15668 return localize2.dayPeriod(dayPeriodEnumValue, {
15669 width: "abbreviated",
15670 context: "formatting"
15671 }).toLowerCase();
15672 case "aaaaa":
15673 return localize2.dayPeriod(dayPeriodEnumValue, {
15674 width: "narrow",
15675 context: "formatting"
15676 });
15677 case "aaaa":
15678 default:
15679 return localize2.dayPeriod(dayPeriodEnumValue, {
15680 width: "wide",
15681 context: "formatting"
15682 });
15683 }
15684 },
15685 // AM, PM, midnight, noon
15686 b: function(date, token, localize2) {
15687 const hours = date.getHours();
15688 let dayPeriodEnumValue;
15689 if (hours === 12) {
15690 dayPeriodEnumValue = dayPeriodEnum.noon;
15691 } else if (hours === 0) {
15692 dayPeriodEnumValue = dayPeriodEnum.midnight;
15693 } else {
15694 dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
15695 }
15696 switch (token) {
15697 case "b":
15698 case "bb":
15699 return localize2.dayPeriod(dayPeriodEnumValue, {
15700 width: "abbreviated",
15701 context: "formatting"
15702 });
15703 case "bbb":
15704 return localize2.dayPeriod(dayPeriodEnumValue, {
15705 width: "abbreviated",
15706 context: "formatting"
15707 }).toLowerCase();
15708 case "bbbbb":
15709 return localize2.dayPeriod(dayPeriodEnumValue, {
15710 width: "narrow",
15711 context: "formatting"
15712 });
15713 case "bbbb":
15714 default:
15715 return localize2.dayPeriod(dayPeriodEnumValue, {
15716 width: "wide",
15717 context: "formatting"
15718 });
15719 }
15720 },
15721 // in the morning, in the afternoon, in the evening, at night
15722 B: function(date, token, localize2) {
15723 const hours = date.getHours();
15724 let dayPeriodEnumValue;
15725 if (hours >= 17) {
15726 dayPeriodEnumValue = dayPeriodEnum.evening;
15727 } else if (hours >= 12) {
15728 dayPeriodEnumValue = dayPeriodEnum.afternoon;
15729 } else if (hours >= 4) {
15730 dayPeriodEnumValue = dayPeriodEnum.morning;
15731 } else {
15732 dayPeriodEnumValue = dayPeriodEnum.night;
15733 }
15734 switch (token) {
15735 case "B":
15736 case "BB":
15737 case "BBB":
15738 return localize2.dayPeriod(dayPeriodEnumValue, {
15739 width: "abbreviated",
15740 context: "formatting"
15741 });
15742 case "BBBBB":
15743 return localize2.dayPeriod(dayPeriodEnumValue, {
15744 width: "narrow",
15745 context: "formatting"
15746 });
15747 case "BBBB":
15748 default:
15749 return localize2.dayPeriod(dayPeriodEnumValue, {
15750 width: "wide",
15751 context: "formatting"
15752 });
15753 }
15754 },
15755 // Hour [1-12]
15756 h: function(date, token, localize2) {
15757 if (token === "ho") {
15758 let hours = date.getHours() % 12;
15759 if (hours === 0) hours = 12;
15760 return localize2.ordinalNumber(hours, { unit: "hour" });
15761 }
15762 return lightFormatters.h(date, token);
15763 },
15764 // Hour [0-23]
15765 H: function(date, token, localize2) {
15766 if (token === "Ho") {
15767 return localize2.ordinalNumber(date.getHours(), { unit: "hour" });
15768 }
15769 return lightFormatters.H(date, token);
15770 },
15771 // Hour [0-11]
15772 K: function(date, token, localize2) {
15773 const hours = date.getHours() % 12;
15774 if (token === "Ko") {
15775 return localize2.ordinalNumber(hours, { unit: "hour" });
15776 }
15777 return addLeadingZeros(hours, token.length);
15778 },
15779 // Hour [1-24]
15780 k: function(date, token, localize2) {
15781 let hours = date.getHours();
15782 if (hours === 0) hours = 24;
15783 if (token === "ko") {
15784 return localize2.ordinalNumber(hours, { unit: "hour" });
15785 }
15786 return addLeadingZeros(hours, token.length);
15787 },
15788 // Minute
15789 m: function(date, token, localize2) {
15790 if (token === "mo") {
15791 return localize2.ordinalNumber(date.getMinutes(), { unit: "minute" });
15792 }
15793 return lightFormatters.m(date, token);
15794 },
15795 // Second
15796 s: function(date, token, localize2) {
15797 if (token === "so") {
15798 return localize2.ordinalNumber(date.getSeconds(), { unit: "second" });
15799 }
15800 return lightFormatters.s(date, token);
15801 },
15802 // Fraction of second
15803 S: function(date, token) {
15804 return lightFormatters.S(date, token);
15805 },
15806 // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
15807 X: function(date, token, _localize) {
15808 const timezoneOffset = date.getTimezoneOffset();
15809 if (timezoneOffset === 0) {
15810 return "Z";
15811 }
15812 switch (token) {
15813 // Hours and optional minutes
15814 case "X":
15815 return formatTimezoneWithOptionalMinutes(timezoneOffset);
15816 // Hours, minutes and optional seconds without `:` delimiter
15817 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
15818 // so this token always has the same output as `XX`
15819 case "XXXX":
15820 case "XX":
15821 return formatTimezone(timezoneOffset);
15822 // Hours, minutes and optional seconds with `:` delimiter
15823 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
15824 // so this token always has the same output as `XXX`
15825 case "XXXXX":
15826 case "XXX":
15827 // Hours and minutes with `:` delimiter
15828 default:
15829 return formatTimezone(timezoneOffset, ":");
15830 }
15831 },
15832 // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
15833 x: function(date, token, _localize) {
15834 const timezoneOffset = date.getTimezoneOffset();
15835 switch (token) {
15836 // Hours and optional minutes
15837 case "x":
15838 return formatTimezoneWithOptionalMinutes(timezoneOffset);
15839 // Hours, minutes and optional seconds without `:` delimiter
15840 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
15841 // so this token always has the same output as `xx`
15842 case "xxxx":
15843 case "xx":
15844 return formatTimezone(timezoneOffset);
15845 // Hours, minutes and optional seconds with `:` delimiter
15846 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
15847 // so this token always has the same output as `xxx`
15848 case "xxxxx":
15849 case "xxx":
15850 // Hours and minutes with `:` delimiter
15851 default:
15852 return formatTimezone(timezoneOffset, ":");
15853 }
15854 },
15855 // Timezone (GMT)
15856 O: function(date, token, _localize) {
15857 const timezoneOffset = date.getTimezoneOffset();
15858 switch (token) {
15859 // Short
15860 case "O":
15861 case "OO":
15862 case "OOO":
15863 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
15864 // Long
15865 case "OOOO":
15866 default:
15867 return "GMT" + formatTimezone(timezoneOffset, ":");
15868 }
15869 },
15870 // Timezone (specific non-location)
15871 z: function(date, token, _localize) {
15872 const timezoneOffset = date.getTimezoneOffset();
15873 switch (token) {
15874 // Short
15875 case "z":
15876 case "zz":
15877 case "zzz":
15878 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
15879 // Long
15880 case "zzzz":
15881 default:
15882 return "GMT" + formatTimezone(timezoneOffset, ":");
15883 }
15884 },
15885 // Seconds timestamp
15886 t: function(date, token, _localize) {
15887 const timestamp = Math.trunc(+date / 1e3);
15888 return addLeadingZeros(timestamp, token.length);
15889 },
15890 // Milliseconds timestamp
15891 T: function(date, token, _localize) {
15892 return addLeadingZeros(+date, token.length);
15893 }
15894 };
15895 function formatTimezoneShort(offset4, delimiter = "") {
15896 const sign = offset4 > 0 ? "-" : "+";
15897 const absOffset = Math.abs(offset4);
15898 const hours = Math.trunc(absOffset / 60);
15899 const minutes = absOffset % 60;
15900 if (minutes === 0) {
15901 return sign + String(hours);
15902 }
15903 return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
15904 }
15905 function formatTimezoneWithOptionalMinutes(offset4, delimiter) {
15906 if (offset4 % 60 === 0) {
15907 const sign = offset4 > 0 ? "-" : "+";
15908 return sign + addLeadingZeros(Math.abs(offset4) / 60, 2);
15909 }
15910 return formatTimezone(offset4, delimiter);
15911 }
15912 function formatTimezone(offset4, delimiter = "") {
15913 const sign = offset4 > 0 ? "-" : "+";
15914 const absOffset = Math.abs(offset4);
15915 const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2);
15916 const minutes = addLeadingZeros(absOffset % 60, 2);
15917 return sign + hours + delimiter + minutes;
15918 }
15919
15920 // node_modules/date-fns/_lib/format/longFormatters.js
15921 var dateLongFormatter = (pattern, formatLong2) => {
15922 switch (pattern) {
15923 case "P":
15924 return formatLong2.date({ width: "short" });
15925 case "PP":
15926 return formatLong2.date({ width: "medium" });
15927 case "PPP":
15928 return formatLong2.date({ width: "long" });
15929 case "PPPP":
15930 default:
15931 return formatLong2.date({ width: "full" });
15932 }
15933 };
15934 var timeLongFormatter = (pattern, formatLong2) => {
15935 switch (pattern) {
15936 case "p":
15937 return formatLong2.time({ width: "short" });
15938 case "pp":
15939 return formatLong2.time({ width: "medium" });
15940 case "ppp":
15941 return formatLong2.time({ width: "long" });
15942 case "pppp":
15943 default:
15944 return formatLong2.time({ width: "full" });
15945 }
15946 };
15947 var dateTimeLongFormatter = (pattern, formatLong2) => {
15948 const matchResult = pattern.match(/(P+)(p+)?/) || [];
15949 const datePattern = matchResult[1];
15950 const timePattern = matchResult[2];
15951 if (!timePattern) {
15952 return dateLongFormatter(pattern, formatLong2);
15953 }
15954 let dateTimeFormat;
15955 switch (datePattern) {
15956 case "P":
15957 dateTimeFormat = formatLong2.dateTime({ width: "short" });
15958 break;
15959 case "PP":
15960 dateTimeFormat = formatLong2.dateTime({ width: "medium" });
15961 break;
15962 case "PPP":
15963 dateTimeFormat = formatLong2.dateTime({ width: "long" });
15964 break;
15965 case "PPPP":
15966 default:
15967 dateTimeFormat = formatLong2.dateTime({ width: "full" });
15968 break;
15969 }
15970 return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2));
15971 };
15972 var longFormatters = {
15973 p: timeLongFormatter,
15974 P: dateTimeLongFormatter
15975 };
15976
15977 // node_modules/date-fns/_lib/protectedTokens.js
15978 var dayOfYearTokenRE = /^D+$/;
15979 var weekYearTokenRE = /^Y+$/;
15980 var throwTokens = ["D", "DD", "YY", "YYYY"];
15981 function isProtectedDayOfYearToken(token) {
15982 return dayOfYearTokenRE.test(token);
15983 }
15984 function isProtectedWeekYearToken(token) {
15985 return weekYearTokenRE.test(token);
15986 }
15987 function warnOrThrowProtectedError(token, format7, input) {
15988 const _message = message(token, format7, input);
15989 console.warn(_message);
15990 if (throwTokens.includes(token)) throw new RangeError(_message);
15991 }
15992 function message(token, format7, input) {
15993 const subject = token[0] === "Y" ? "years" : "days of the month";
15994 return `Use \`${token.toLowerCase()}\` instead of \`${token}\` (in \`${format7}\`) for formatting ${subject} to the input \`${input}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`;
15995 }
15996
15997 // node_modules/date-fns/format.js
15998 var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
15999 var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
16000 var escapedStringRegExp = /^'([^]*?)'?$/;
16001 var doubleQuoteRegExp = /''/g;
16002 var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
16003 function format(date, formatStr, options) {
16004 const defaultOptions2 = getDefaultOptions();
16005 const locale = options?.locale ?? defaultOptions2.locale ?? enUS;
16006 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
16007 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
16008 const originalDate = toDate(date, options?.in);
16009 if (!isValid(originalDate)) {
16010 throw new RangeError("Invalid time value");
16011 }
16012 let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => {
16013 const firstCharacter = substring[0];
16014 if (firstCharacter === "p" || firstCharacter === "P") {
16015 const longFormatter = longFormatters[firstCharacter];
16016 return longFormatter(substring, locale.formatLong);
16017 }
16018 return substring;
16019 }).join("").match(formattingTokensRegExp).map((substring) => {
16020 if (substring === "''") {
16021 return { isToken: false, value: "'" };
16022 }
16023 const firstCharacter = substring[0];
16024 if (firstCharacter === "'") {
16025 return { isToken: false, value: cleanEscapedString(substring) };
16026 }
16027 if (formatters[firstCharacter]) {
16028 return { isToken: true, value: substring };
16029 }
16030 if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
16031 throw new RangeError(
16032 "Format string contains an unescaped latin alphabet character `" + firstCharacter + "`"
16033 );
16034 }
16035 return { isToken: false, value: substring };
16036 });
16037 if (locale.localize.preprocessor) {
16038 parts = locale.localize.preprocessor(originalDate, parts);
16039 }
16040 const formatterOptions = {
16041 firstWeekContainsDate,
16042 weekStartsOn,
16043 locale
16044 };
16045 return parts.map((part) => {
16046 if (!part.isToken) return part.value;
16047 const token = part.value;
16048 if (!options?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token) || !options?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) {
16049 warnOrThrowProtectedError(token, formatStr, String(date));
16050 }
16051 const formatter = formatters[token[0]];
16052 return formatter(originalDate, token, locale.localize, formatterOptions);
16053 }).join("");
16054 }
16055 function cleanEscapedString(input) {
16056 const matched = input.match(escapedStringRegExp);
16057 if (!matched) {
16058 return input;
16059 }
16060 return matched[1].replace(doubleQuoteRegExp, "'");
16061 }
16062
16063 // node_modules/date-fns/getDaysInMonth.js
16064 function getDaysInMonth(date, options) {
16065 const _date = toDate(date, options?.in);
16066 const year = _date.getFullYear();
16067 const monthIndex = _date.getMonth();
16068 const lastDayOfMonth = constructFrom(_date, 0);
16069 lastDayOfMonth.setFullYear(year, monthIndex + 1, 0);
16070 lastDayOfMonth.setHours(0, 0, 0, 0);
16071 return lastDayOfMonth.getDate();
16072 }
16073
16074 // node_modules/date-fns/getDefaultOptions.js
16075 function getDefaultOptions2() {
16076 return Object.assign({}, getDefaultOptions());
16077 }
16078
16079 // node_modules/date-fns/getISODay.js
16080 function getISODay(date, options) {
16081 const day = toDate(date, options?.in).getDay();
16082 return day === 0 ? 7 : day;
16083 }
16084
16085 // node_modules/date-fns/getMonth.js
16086 function getMonth(date, options) {
16087 return toDate(date, options?.in).getMonth();
16088 }
16089
16090 // node_modules/date-fns/getYear.js
16091 function getYear(date, options) {
16092 return toDate(date, options?.in).getFullYear();
16093 }
16094
16095 // node_modules/date-fns/isAfter.js
16096 function isAfter(date, dateToCompare) {
16097 return +toDate(date) > +toDate(dateToCompare);
16098 }
16099
16100 // node_modules/date-fns/isBefore.js
16101 function isBefore(date, dateToCompare) {
16102 return +toDate(date) < +toDate(dateToCompare);
16103 }
16104
16105 // node_modules/date-fns/transpose.js
16106 function transpose(date, constructor) {
16107 const date_ = isConstructor(constructor) ? new constructor(0) : constructFrom(constructor, 0);
16108 date_.setFullYear(date.getFullYear(), date.getMonth(), date.getDate());
16109 date_.setHours(
16110 date.getHours(),
16111 date.getMinutes(),
16112 date.getSeconds(),
16113 date.getMilliseconds()
16114 );
16115 return date_;
16116 }
16117 function isConstructor(constructor) {
16118 return typeof constructor === "function" && constructor.prototype?.constructor === constructor;
16119 }
16120
16121 // node_modules/date-fns/parse/_lib/Setter.js
16122 var TIMEZONE_UNIT_PRIORITY = 10;
16123 var Setter = class {
16124 subPriority = 0;
16125 validate(_utcDate, _options) {
16126 return true;
16127 }
16128 };
16129 var ValueSetter = class extends Setter {
16130 constructor(value, validateValue, setValue, priority, subPriority) {
16131 super();
16132 this.value = value;
16133 this.validateValue = validateValue;
16134 this.setValue = setValue;
16135 this.priority = priority;
16136 if (subPriority) {
16137 this.subPriority = subPriority;
16138 }
16139 }
16140 validate(date, options) {
16141 return this.validateValue(date, this.value, options);
16142 }
16143 set(date, flags, options) {
16144 return this.setValue(date, flags, this.value, options);
16145 }
16146 };
16147 var DateTimezoneSetter = class extends Setter {
16148 priority = TIMEZONE_UNIT_PRIORITY;
16149 subPriority = -1;
16150 constructor(context, reference) {
16151 super();
16152 this.context = context || ((date) => constructFrom(reference, date));
16153 }
16154 set(date, flags) {
16155 if (flags.timestampIsSet) return date;
16156 return constructFrom(date, transpose(date, this.context));
16157 }
16158 };
16159
16160 // node_modules/date-fns/parse/_lib/Parser.js
16161 var Parser = class {
16162 run(dateString, token, match2, options) {
16163 const result = this.parse(dateString, token, match2, options);
16164 if (!result) {
16165 return null;
16166 }
16167 return {
16168 setter: new ValueSetter(
16169 result.value,
16170 this.validate,
16171 this.set,
16172 this.priority,
16173 this.subPriority
16174 ),
16175 rest: result.rest
16176 };
16177 }
16178 validate(_utcDate, _value, _options) {
16179 return true;
16180 }
16181 };
16182
16183 // node_modules/date-fns/parse/_lib/parsers/EraParser.js
16184 var EraParser = class extends Parser {
16185 priority = 140;
16186 parse(dateString, token, match2) {
16187 switch (token) {
16188 // AD, BC
16189 case "G":
16190 case "GG":
16191 case "GGG":
16192 return match2.era(dateString, { width: "abbreviated" }) || match2.era(dateString, { width: "narrow" });
16193 // A, B
16194 case "GGGGG":
16195 return match2.era(dateString, { width: "narrow" });
16196 // Anno Domini, Before Christ
16197 case "GGGG":
16198 default:
16199 return match2.era(dateString, { width: "wide" }) || match2.era(dateString, { width: "abbreviated" }) || match2.era(dateString, { width: "narrow" });
16200 }
16201 }
16202 set(date, flags, value) {
16203 flags.era = value;
16204 date.setFullYear(value, 0, 1);
16205 date.setHours(0, 0, 0, 0);
16206 return date;
16207 }
16208 incompatibleTokens = ["R", "u", "t", "T"];
16209 };
16210
16211 // node_modules/date-fns/parse/_lib/constants.js
16212 var numericPatterns = {
16213 month: /^(1[0-2]|0?\d)/,
16214 // 0 to 12
16215 date: /^(3[0-1]|[0-2]?\d)/,
16216 // 0 to 31
16217 dayOfYear: /^(36[0-6]|3[0-5]\d|[0-2]?\d?\d)/,
16218 // 0 to 366
16219 week: /^(5[0-3]|[0-4]?\d)/,
16220 // 0 to 53
16221 hour23h: /^(2[0-3]|[0-1]?\d)/,
16222 // 0 to 23
16223 hour24h: /^(2[0-4]|[0-1]?\d)/,
16224 // 0 to 24
16225 hour11h: /^(1[0-1]|0?\d)/,
16226 // 0 to 11
16227 hour12h: /^(1[0-2]|0?\d)/,
16228 // 0 to 12
16229 minute: /^[0-5]?\d/,
16230 // 0 to 59
16231 second: /^[0-5]?\d/,
16232 // 0 to 59
16233 singleDigit: /^\d/,
16234 // 0 to 9
16235 twoDigits: /^\d{1,2}/,
16236 // 0 to 99
16237 threeDigits: /^\d{1,3}/,
16238 // 0 to 999
16239 fourDigits: /^\d{1,4}/,
16240 // 0 to 9999
16241 anyDigitsSigned: /^-?\d+/,
16242 singleDigitSigned: /^-?\d/,
16243 // 0 to 9, -0 to -9
16244 twoDigitsSigned: /^-?\d{1,2}/,
16245 // 0 to 99, -0 to -99
16246 threeDigitsSigned: /^-?\d{1,3}/,
16247 // 0 to 999, -0 to -999
16248 fourDigitsSigned: /^-?\d{1,4}/
16249 // 0 to 9999, -0 to -9999
16250 };
16251 var timezonePatterns = {
16252 basicOptionalMinutes: /^([+-])(\d{2})(\d{2})?|Z/,
16253 basic: /^([+-])(\d{2})(\d{2})|Z/,
16254 basicOptionalSeconds: /^([+-])(\d{2})(\d{2})((\d{2}))?|Z/,
16255 extended: /^([+-])(\d{2}):(\d{2})|Z/,
16256 extendedOptionalSeconds: /^([+-])(\d{2}):(\d{2})(:(\d{2}))?|Z/
16257 };
16258
16259 // node_modules/date-fns/parse/_lib/utils.js
16260 function mapValue(parseFnResult, mapFn) {
16261 if (!parseFnResult) {
16262 return parseFnResult;
16263 }
16264 return {
16265 value: mapFn(parseFnResult.value),
16266 rest: parseFnResult.rest
16267 };
16268 }
16269 function parseNumericPattern(pattern, dateString) {
16270 const matchResult = dateString.match(pattern);
16271 if (!matchResult) {
16272 return null;
16273 }
16274 return {
16275 value: parseInt(matchResult[0], 10),
16276 rest: dateString.slice(matchResult[0].length)
16277 };
16278 }
16279 function parseTimezonePattern(pattern, dateString) {
16280 const matchResult = dateString.match(pattern);
16281 if (!matchResult) {
16282 return null;
16283 }
16284 if (matchResult[0] === "Z") {
16285 return {
16286 value: 0,
16287 rest: dateString.slice(1)
16288 };
16289 }
16290 const sign = matchResult[1] === "+" ? 1 : -1;
16291 const hours = matchResult[2] ? parseInt(matchResult[2], 10) : 0;
16292 const minutes = matchResult[3] ? parseInt(matchResult[3], 10) : 0;
16293 const seconds = matchResult[5] ? parseInt(matchResult[5], 10) : 0;
16294 return {
16295 value: sign * (hours * millisecondsInHour + minutes * millisecondsInMinute + seconds * millisecondsInSecond),
16296 rest: dateString.slice(matchResult[0].length)
16297 };
16298 }
16299 function parseAnyDigitsSigned(dateString) {
16300 return parseNumericPattern(numericPatterns.anyDigitsSigned, dateString);
16301 }
16302 function parseNDigits(n, dateString) {
16303 switch (n) {
16304 case 1:
16305 return parseNumericPattern(numericPatterns.singleDigit, dateString);
16306 case 2:
16307 return parseNumericPattern(numericPatterns.twoDigits, dateString);
16308 case 3:
16309 return parseNumericPattern(numericPatterns.threeDigits, dateString);
16310 case 4:
16311 return parseNumericPattern(numericPatterns.fourDigits, dateString);
16312 default:
16313 return parseNumericPattern(new RegExp("^\\d{1," + n + "}"), dateString);
16314 }
16315 }
16316 function parseNDigitsSigned(n, dateString) {
16317 switch (n) {
16318 case 1:
16319 return parseNumericPattern(numericPatterns.singleDigitSigned, dateString);
16320 case 2:
16321 return parseNumericPattern(numericPatterns.twoDigitsSigned, dateString);
16322 case 3:
16323 return parseNumericPattern(numericPatterns.threeDigitsSigned, dateString);
16324 case 4:
16325 return parseNumericPattern(numericPatterns.fourDigitsSigned, dateString);
16326 default:
16327 return parseNumericPattern(new RegExp("^-?\\d{1," + n + "}"), dateString);
16328 }
16329 }
16330 function dayPeriodEnumToHours(dayPeriod) {
16331 switch (dayPeriod) {
16332 case "morning":
16333 return 4;
16334 case "evening":
16335 return 17;
16336 case "pm":
16337 case "noon":
16338 case "afternoon":
16339 return 12;
16340 case "am":
16341 case "midnight":
16342 case "night":
16343 default:
16344 return 0;
16345 }
16346 }
16347 function normalizeTwoDigitYear(twoDigitYear, currentYear) {
16348 const isCommonEra = currentYear > 0;
16349 const absCurrentYear = isCommonEra ? currentYear : 1 - currentYear;
16350 let result;
16351 if (absCurrentYear <= 50) {
16352 result = twoDigitYear || 100;
16353 } else {
16354 const rangeEnd = absCurrentYear + 50;
16355 const rangeEndCentury = Math.trunc(rangeEnd / 100) * 100;
16356 const isPreviousCentury = twoDigitYear >= rangeEnd % 100;
16357 result = twoDigitYear + rangeEndCentury - (isPreviousCentury ? 100 : 0);
16358 }
16359 return isCommonEra ? result : 1 - result;
16360 }
16361 function isLeapYearIndex(year) {
16362 return year % 400 === 0 || year % 4 === 0 && year % 100 !== 0;
16363 }
16364
16365 // node_modules/date-fns/parse/_lib/parsers/YearParser.js
16366 var YearParser = class extends Parser {
16367 priority = 130;
16368 incompatibleTokens = ["Y", "R", "u", "w", "I", "i", "e", "c", "t", "T"];
16369 parse(dateString, token, match2) {
16370 const valueCallback = (year) => ({
16371 year,
16372 isTwoDigitYear: token === "yy"
16373 });
16374 switch (token) {
16375 case "y":
16376 return mapValue(parseNDigits(4, dateString), valueCallback);
16377 case "yo":
16378 return mapValue(
16379 match2.ordinalNumber(dateString, {
16380 unit: "year"
16381 }),
16382 valueCallback
16383 );
16384 default:
16385 return mapValue(parseNDigits(token.length, dateString), valueCallback);
16386 }
16387 }
16388 validate(_date, value) {
16389 return value.isTwoDigitYear || value.year > 0;
16390 }
16391 set(date, flags, value) {
16392 const currentYear = date.getFullYear();
16393 if (value.isTwoDigitYear) {
16394 const normalizedTwoDigitYear = normalizeTwoDigitYear(
16395 value.year,
16396 currentYear
16397 );
16398 date.setFullYear(normalizedTwoDigitYear, 0, 1);
16399 date.setHours(0, 0, 0, 0);
16400 return date;
16401 }
16402 const year = !("era" in flags) || flags.era === 1 ? value.year : 1 - value.year;
16403 date.setFullYear(year, 0, 1);
16404 date.setHours(0, 0, 0, 0);
16405 return date;
16406 }
16407 };
16408
16409 // node_modules/date-fns/parse/_lib/parsers/LocalWeekYearParser.js
16410 var LocalWeekYearParser = class extends Parser {
16411 priority = 130;
16412 parse(dateString, token, match2) {
16413 const valueCallback = (year) => ({
16414 year,
16415 isTwoDigitYear: token === "YY"
16416 });
16417 switch (token) {
16418 case "Y":
16419 return mapValue(parseNDigits(4, dateString), valueCallback);
16420 case "Yo":
16421 return mapValue(
16422 match2.ordinalNumber(dateString, {
16423 unit: "year"
16424 }),
16425 valueCallback
16426 );
16427 default:
16428 return mapValue(parseNDigits(token.length, dateString), valueCallback);
16429 }
16430 }
16431 validate(_date, value) {
16432 return value.isTwoDigitYear || value.year > 0;
16433 }
16434 set(date, flags, value, options) {
16435 const currentYear = getWeekYear(date, options);
16436 if (value.isTwoDigitYear) {
16437 const normalizedTwoDigitYear = normalizeTwoDigitYear(
16438 value.year,
16439 currentYear
16440 );
16441 date.setFullYear(
16442 normalizedTwoDigitYear,
16443 0,
16444 options.firstWeekContainsDate
16445 );
16446 date.setHours(0, 0, 0, 0);
16447 return startOfWeek(date, options);
16448 }
16449 const year = !("era" in flags) || flags.era === 1 ? value.year : 1 - value.year;
16450 date.setFullYear(year, 0, options.firstWeekContainsDate);
16451 date.setHours(0, 0, 0, 0);
16452 return startOfWeek(date, options);
16453 }
16454 incompatibleTokens = [
16455 "y",
16456 "R",
16457 "u",
16458 "Q",
16459 "q",
16460 "M",
16461 "L",
16462 "I",
16463 "d",
16464 "D",
16465 "i",
16466 "t",
16467 "T"
16468 ];
16469 };
16470
16471 // node_modules/date-fns/parse/_lib/parsers/ISOWeekYearParser.js
16472 var ISOWeekYearParser = class extends Parser {
16473 priority = 130;
16474 parse(dateString, token) {
16475 if (token === "R") {
16476 return parseNDigitsSigned(4, dateString);
16477 }
16478 return parseNDigitsSigned(token.length, dateString);
16479 }
16480 set(date, _flags, value) {
16481 const firstWeekOfYear = constructFrom(date, 0);
16482 firstWeekOfYear.setFullYear(value, 0, 4);
16483 firstWeekOfYear.setHours(0, 0, 0, 0);
16484 return startOfISOWeek(firstWeekOfYear);
16485 }
16486 incompatibleTokens = [
16487 "G",
16488 "y",
16489 "Y",
16490 "u",
16491 "Q",
16492 "q",
16493 "M",
16494 "L",
16495 "w",
16496 "d",
16497 "D",
16498 "e",
16499 "c",
16500 "t",
16501 "T"
16502 ];
16503 };
16504
16505 // node_modules/date-fns/parse/_lib/parsers/ExtendedYearParser.js
16506 var ExtendedYearParser = class extends Parser {
16507 priority = 130;
16508 parse(dateString, token) {
16509 if (token === "u") {
16510 return parseNDigitsSigned(4, dateString);
16511 }
16512 return parseNDigitsSigned(token.length, dateString);
16513 }
16514 set(date, _flags, value) {
16515 date.setFullYear(value, 0, 1);
16516 date.setHours(0, 0, 0, 0);
16517 return date;
16518 }
16519 incompatibleTokens = ["G", "y", "Y", "R", "w", "I", "i", "e", "c", "t", "T"];
16520 };
16521
16522 // node_modules/date-fns/parse/_lib/parsers/QuarterParser.js
16523 var QuarterParser = class extends Parser {
16524 priority = 120;
16525 parse(dateString, token, match2) {
16526 switch (token) {
16527 // 1, 2, 3, 4
16528 case "Q":
16529 case "QQ":
16530 return parseNDigits(token.length, dateString);
16531 // 1st, 2nd, 3rd, 4th
16532 case "Qo":
16533 return match2.ordinalNumber(dateString, { unit: "quarter" });
16534 // Q1, Q2, Q3, Q4
16535 case "QQQ":
16536 return match2.quarter(dateString, {
16537 width: "abbreviated",
16538 context: "formatting"
16539 }) || match2.quarter(dateString, {
16540 width: "narrow",
16541 context: "formatting"
16542 });
16543 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
16544 case "QQQQQ":
16545 return match2.quarter(dateString, {
16546 width: "narrow",
16547 context: "formatting"
16548 });
16549 // 1st quarter, 2nd quarter, ...
16550 case "QQQQ":
16551 default:
16552 return match2.quarter(dateString, {
16553 width: "wide",
16554 context: "formatting"
16555 }) || match2.quarter(dateString, {
16556 width: "abbreviated",
16557 context: "formatting"
16558 }) || match2.quarter(dateString, {
16559 width: "narrow",
16560 context: "formatting"
16561 });
16562 }
16563 }
16564 validate(_date, value) {
16565 return value >= 1 && value <= 4;
16566 }
16567 set(date, _flags, value) {
16568 date.setMonth((value - 1) * 3, 1);
16569 date.setHours(0, 0, 0, 0);
16570 return date;
16571 }
16572 incompatibleTokens = [
16573 "Y",
16574 "R",
16575 "q",
16576 "M",
16577 "L",
16578 "w",
16579 "I",
16580 "d",
16581 "D",
16582 "i",
16583 "e",
16584 "c",
16585 "t",
16586 "T"
16587 ];
16588 };
16589
16590 // node_modules/date-fns/parse/_lib/parsers/StandAloneQuarterParser.js
16591 var StandAloneQuarterParser = class extends Parser {
16592 priority = 120;
16593 parse(dateString, token, match2) {
16594 switch (token) {
16595 // 1, 2, 3, 4
16596 case "q":
16597 case "qq":
16598 return parseNDigits(token.length, dateString);
16599 // 1st, 2nd, 3rd, 4th
16600 case "qo":
16601 return match2.ordinalNumber(dateString, { unit: "quarter" });
16602 // Q1, Q2, Q3, Q4
16603 case "qqq":
16604 return match2.quarter(dateString, {
16605 width: "abbreviated",
16606 context: "standalone"
16607 }) || match2.quarter(dateString, {
16608 width: "narrow",
16609 context: "standalone"
16610 });
16611 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
16612 case "qqqqq":
16613 return match2.quarter(dateString, {
16614 width: "narrow",
16615 context: "standalone"
16616 });
16617 // 1st quarter, 2nd quarter, ...
16618 case "qqqq":
16619 default:
16620 return match2.quarter(dateString, {
16621 width: "wide",
16622 context: "standalone"
16623 }) || match2.quarter(dateString, {
16624 width: "abbreviated",
16625 context: "standalone"
16626 }) || match2.quarter(dateString, {
16627 width: "narrow",
16628 context: "standalone"
16629 });
16630 }
16631 }
16632 validate(_date, value) {
16633 return value >= 1 && value <= 4;
16634 }
16635 set(date, _flags, value) {
16636 date.setMonth((value - 1) * 3, 1);
16637 date.setHours(0, 0, 0, 0);
16638 return date;
16639 }
16640 incompatibleTokens = [
16641 "Y",
16642 "R",
16643 "Q",
16644 "M",
16645 "L",
16646 "w",
16647 "I",
16648 "d",
16649 "D",
16650 "i",
16651 "e",
16652 "c",
16653 "t",
16654 "T"
16655 ];
16656 };
16657
16658 // node_modules/date-fns/parse/_lib/parsers/MonthParser.js
16659 var MonthParser = class extends Parser {
16660 incompatibleTokens = [
16661 "Y",
16662 "R",
16663 "q",
16664 "Q",
16665 "L",
16666 "w",
16667 "I",
16668 "D",
16669 "i",
16670 "e",
16671 "c",
16672 "t",
16673 "T"
16674 ];
16675 priority = 110;
16676 parse(dateString, token, match2) {
16677 const valueCallback = (value) => value - 1;
16678 switch (token) {
16679 // 1, 2, ..., 12
16680 case "M":
16681 return mapValue(
16682 parseNumericPattern(numericPatterns.month, dateString),
16683 valueCallback
16684 );
16685 // 01, 02, ..., 12
16686 case "MM":
16687 return mapValue(parseNDigits(2, dateString), valueCallback);
16688 // 1st, 2nd, ..., 12th
16689 case "Mo":
16690 return mapValue(
16691 match2.ordinalNumber(dateString, {
16692 unit: "month"
16693 }),
16694 valueCallback
16695 );
16696 // Jan, Feb, ..., Dec
16697 case "MMM":
16698 return match2.month(dateString, {
16699 width: "abbreviated",
16700 context: "formatting"
16701 }) || match2.month(dateString, { width: "narrow", context: "formatting" });
16702 // J, F, ..., D
16703 case "MMMMM":
16704 return match2.month(dateString, {
16705 width: "narrow",
16706 context: "formatting"
16707 });
16708 // January, February, ..., December
16709 case "MMMM":
16710 default:
16711 return match2.month(dateString, { width: "wide", context: "formatting" }) || match2.month(dateString, {
16712 width: "abbreviated",
16713 context: "formatting"
16714 }) || match2.month(dateString, { width: "narrow", context: "formatting" });
16715 }
16716 }
16717 validate(_date, value) {
16718 return value >= 0 && value <= 11;
16719 }
16720 set(date, _flags, value) {
16721 date.setMonth(value, 1);
16722 date.setHours(0, 0, 0, 0);
16723 return date;
16724 }
16725 };
16726
16727 // node_modules/date-fns/parse/_lib/parsers/StandAloneMonthParser.js
16728 var StandAloneMonthParser = class extends Parser {
16729 priority = 110;
16730 parse(dateString, token, match2) {
16731 const valueCallback = (value) => value - 1;
16732 switch (token) {
16733 // 1, 2, ..., 12
16734 case "L":
16735 return mapValue(
16736 parseNumericPattern(numericPatterns.month, dateString),
16737 valueCallback
16738 );
16739 // 01, 02, ..., 12
16740 case "LL":
16741 return mapValue(parseNDigits(2, dateString), valueCallback);
16742 // 1st, 2nd, ..., 12th
16743 case "Lo":
16744 return mapValue(
16745 match2.ordinalNumber(dateString, {
16746 unit: "month"
16747 }),
16748 valueCallback
16749 );
16750 // Jan, Feb, ..., Dec
16751 case "LLL":
16752 return match2.month(dateString, {
16753 width: "abbreviated",
16754 context: "standalone"
16755 }) || match2.month(dateString, { width: "narrow", context: "standalone" });
16756 // J, F, ..., D
16757 case "LLLLL":
16758 return match2.month(dateString, {
16759 width: "narrow",
16760 context: "standalone"
16761 });
16762 // January, February, ..., December
16763 case "LLLL":
16764 default:
16765 return match2.month(dateString, { width: "wide", context: "standalone" }) || match2.month(dateString, {
16766 width: "abbreviated",
16767 context: "standalone"
16768 }) || match2.month(dateString, { width: "narrow", context: "standalone" });
16769 }
16770 }
16771 validate(_date, value) {
16772 return value >= 0 && value <= 11;
16773 }
16774 set(date, _flags, value) {
16775 date.setMonth(value, 1);
16776 date.setHours(0, 0, 0, 0);
16777 return date;
16778 }
16779 incompatibleTokens = [
16780 "Y",
16781 "R",
16782 "q",
16783 "Q",
16784 "M",
16785 "w",
16786 "I",
16787 "D",
16788 "i",
16789 "e",
16790 "c",
16791 "t",
16792 "T"
16793 ];
16794 };
16795
16796 // node_modules/date-fns/setWeek.js
16797 function setWeek(date, week, options) {
16798 const date_ = toDate(date, options?.in);
16799 const diff = getWeek(date_, options) - week;
16800 date_.setDate(date_.getDate() - diff * 7);
16801 return toDate(date_, options?.in);
16802 }
16803
16804 // node_modules/date-fns/parse/_lib/parsers/LocalWeekParser.js
16805 var LocalWeekParser = class extends Parser {
16806 priority = 100;
16807 parse(dateString, token, match2) {
16808 switch (token) {
16809 case "w":
16810 return parseNumericPattern(numericPatterns.week, dateString);
16811 case "wo":
16812 return match2.ordinalNumber(dateString, { unit: "week" });
16813 default:
16814 return parseNDigits(token.length, dateString);
16815 }
16816 }
16817 validate(_date, value) {
16818 return value >= 1 && value <= 53;
16819 }
16820 set(date, _flags, value, options) {
16821 return startOfWeek(setWeek(date, value, options), options);
16822 }
16823 incompatibleTokens = [
16824 "y",
16825 "R",
16826 "u",
16827 "q",
16828 "Q",
16829 "M",
16830 "L",
16831 "I",
16832 "d",
16833 "D",
16834 "i",
16835 "t",
16836 "T"
16837 ];
16838 };
16839
16840 // node_modules/date-fns/setISOWeek.js
16841 function setISOWeek(date, week, options) {
16842 const _date = toDate(date, options?.in);
16843 const diff = getISOWeek(_date, options) - week;
16844 _date.setDate(_date.getDate() - diff * 7);
16845 return _date;
16846 }
16847
16848 // node_modules/date-fns/parse/_lib/parsers/ISOWeekParser.js
16849 var ISOWeekParser = class extends Parser {
16850 priority = 100;
16851 parse(dateString, token, match2) {
16852 switch (token) {
16853 case "I":
16854 return parseNumericPattern(numericPatterns.week, dateString);
16855 case "Io":
16856 return match2.ordinalNumber(dateString, { unit: "week" });
16857 default:
16858 return parseNDigits(token.length, dateString);
16859 }
16860 }
16861 validate(_date, value) {
16862 return value >= 1 && value <= 53;
16863 }
16864 set(date, _flags, value) {
16865 return startOfISOWeek(setISOWeek(date, value));
16866 }
16867 incompatibleTokens = [
16868 "y",
16869 "Y",
16870 "u",
16871 "q",
16872 "Q",
16873 "M",
16874 "L",
16875 "w",
16876 "d",
16877 "D",
16878 "e",
16879 "c",
16880 "t",
16881 "T"
16882 ];
16883 };
16884
16885 // node_modules/date-fns/parse/_lib/parsers/DateParser.js
16886 var DAYS_IN_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
16887 var DAYS_IN_MONTH_LEAP_YEAR = [
16888 31,
16889 29,
16890 31,
16891 30,
16892 31,
16893 30,
16894 31,
16895 31,
16896 30,
16897 31,
16898 30,
16899 31
16900 ];
16901 var DateParser = class extends Parser {
16902 priority = 90;
16903 subPriority = 1;
16904 parse(dateString, token, match2) {
16905 switch (token) {
16906 case "d":
16907 return parseNumericPattern(numericPatterns.date, dateString);
16908 case "do":
16909 return match2.ordinalNumber(dateString, { unit: "date" });
16910 default:
16911 return parseNDigits(token.length, dateString);
16912 }
16913 }
16914 validate(date, value) {
16915 const year = date.getFullYear();
16916 const isLeapYear = isLeapYearIndex(year);
16917 const month = date.getMonth();
16918 if (isLeapYear) {
16919 return value >= 1 && value <= DAYS_IN_MONTH_LEAP_YEAR[month];
16920 } else {
16921 return value >= 1 && value <= DAYS_IN_MONTH[month];
16922 }
16923 }
16924 set(date, _flags, value) {
16925 date.setDate(value);
16926 date.setHours(0, 0, 0, 0);
16927 return date;
16928 }
16929 incompatibleTokens = [
16930 "Y",
16931 "R",
16932 "q",
16933 "Q",
16934 "w",
16935 "I",
16936 "D",
16937 "i",
16938 "e",
16939 "c",
16940 "t",
16941 "T"
16942 ];
16943 };
16944
16945 // node_modules/date-fns/parse/_lib/parsers/DayOfYearParser.js
16946 var DayOfYearParser = class extends Parser {
16947 priority = 90;
16948 subpriority = 1;
16949 parse(dateString, token, match2) {
16950 switch (token) {
16951 case "D":
16952 case "DD":
16953 return parseNumericPattern(numericPatterns.dayOfYear, dateString);
16954 case "Do":
16955 return match2.ordinalNumber(dateString, { unit: "date" });
16956 default:
16957 return parseNDigits(token.length, dateString);
16958 }
16959 }
16960 validate(date, value) {
16961 const year = date.getFullYear();
16962 const isLeapYear = isLeapYearIndex(year);
16963 if (isLeapYear) {
16964 return value >= 1 && value <= 366;
16965 } else {
16966 return value >= 1 && value <= 365;
16967 }
16968 }
16969 set(date, _flags, value) {
16970 date.setMonth(0, value);
16971 date.setHours(0, 0, 0, 0);
16972 return date;
16973 }
16974 incompatibleTokens = [
16975 "Y",
16976 "R",
16977 "q",
16978 "Q",
16979 "M",
16980 "L",
16981 "w",
16982 "I",
16983 "d",
16984 "E",
16985 "i",
16986 "e",
16987 "c",
16988 "t",
16989 "T"
16990 ];
16991 };
16992
16993 // node_modules/date-fns/setDay.js
16994 function setDay(date, day, options) {
16995 const defaultOptions2 = getDefaultOptions();
16996 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
16997 const date_ = toDate(date, options?.in);
16998 const currentDay = date_.getDay();
16999 const remainder = day % 7;
17000 const dayIndex = (remainder + 7) % 7;
17001 const delta = 7 - weekStartsOn;
17002 const diff = day < 0 || day > 6 ? day - (currentDay + delta) % 7 : (dayIndex + delta) % 7 - (currentDay + delta) % 7;
17003 return addDays(date_, diff, options);
17004 }
17005
17006 // node_modules/date-fns/parse/_lib/parsers/DayParser.js
17007 var DayParser = class extends Parser {
17008 priority = 90;
17009 parse(dateString, token, match2) {
17010 switch (token) {
17011 // Tue
17012 case "E":
17013 case "EE":
17014 case "EEE":
17015 return match2.day(dateString, {
17016 width: "abbreviated",
17017 context: "formatting"
17018 }) || match2.day(dateString, { width: "short", context: "formatting" }) || match2.day(dateString, { width: "narrow", context: "formatting" });
17019 // T
17020 case "EEEEE":
17021 return match2.day(dateString, {
17022 width: "narrow",
17023 context: "formatting"
17024 });
17025 // Tu
17026 case "EEEEEE":
17027 return match2.day(dateString, { width: "short", context: "formatting" }) || match2.day(dateString, { width: "narrow", context: "formatting" });
17028 // Tuesday
17029 case "EEEE":
17030 default:
17031 return match2.day(dateString, { width: "wide", context: "formatting" }) || match2.day(dateString, {
17032 width: "abbreviated",
17033 context: "formatting"
17034 }) || match2.day(dateString, { width: "short", context: "formatting" }) || match2.day(dateString, { width: "narrow", context: "formatting" });
17035 }
17036 }
17037 validate(_date, value) {
17038 return value >= 0 && value <= 6;
17039 }
17040 set(date, _flags, value, options) {
17041 date = setDay(date, value, options);
17042 date.setHours(0, 0, 0, 0);
17043 return date;
17044 }
17045 incompatibleTokens = ["D", "i", "e", "c", "t", "T"];
17046 };
17047
17048 // node_modules/date-fns/parse/_lib/parsers/LocalDayParser.js
17049 var LocalDayParser = class extends Parser {
17050 priority = 90;
17051 parse(dateString, token, match2, options) {
17052 const valueCallback = (value) => {
17053 const wholeWeekDays = Math.floor((value - 1) / 7) * 7;
17054 return (value + options.weekStartsOn + 6) % 7 + wholeWeekDays;
17055 };
17056 switch (token) {
17057 // 3
17058 case "e":
17059 case "ee":
17060 return mapValue(parseNDigits(token.length, dateString), valueCallback);
17061 // 3rd
17062 case "eo":
17063 return mapValue(
17064 match2.ordinalNumber(dateString, {
17065 unit: "day"
17066 }),
17067 valueCallback
17068 );
17069 // Tue
17070 case "eee":
17071 return match2.day(dateString, {
17072 width: "abbreviated",
17073 context: "formatting"
17074 }) || match2.day(dateString, { width: "short", context: "formatting" }) || match2.day(dateString, { width: "narrow", context: "formatting" });
17075 // T
17076 case "eeeee":
17077 return match2.day(dateString, {
17078 width: "narrow",
17079 context: "formatting"
17080 });
17081 // Tu
17082 case "eeeeee":
17083 return match2.day(dateString, { width: "short", context: "formatting" }) || match2.day(dateString, { width: "narrow", context: "formatting" });
17084 // Tuesday
17085 case "eeee":
17086 default:
17087 return match2.day(dateString, { width: "wide", context: "formatting" }) || match2.day(dateString, {
17088 width: "abbreviated",
17089 context: "formatting"
17090 }) || match2.day(dateString, { width: "short", context: "formatting" }) || match2.day(dateString, { width: "narrow", context: "formatting" });
17091 }
17092 }
17093 validate(_date, value) {
17094 return value >= 0 && value <= 6;
17095 }
17096 set(date, _flags, value, options) {
17097 date = setDay(date, value, options);
17098 date.setHours(0, 0, 0, 0);
17099 return date;
17100 }
17101 incompatibleTokens = [
17102 "y",
17103 "R",
17104 "u",
17105 "q",
17106 "Q",
17107 "M",
17108 "L",
17109 "I",
17110 "d",
17111 "D",
17112 "E",
17113 "i",
17114 "c",
17115 "t",
17116 "T"
17117 ];
17118 };
17119
17120 // node_modules/date-fns/parse/_lib/parsers/StandAloneLocalDayParser.js
17121 var StandAloneLocalDayParser = class extends Parser {
17122 priority = 90;
17123 parse(dateString, token, match2, options) {
17124 const valueCallback = (value) => {
17125 const wholeWeekDays = Math.floor((value - 1) / 7) * 7;
17126 return (value + options.weekStartsOn + 6) % 7 + wholeWeekDays;
17127 };
17128 switch (token) {
17129 // 3
17130 case "c":
17131 case "cc":
17132 return mapValue(parseNDigits(token.length, dateString), valueCallback);
17133 // 3rd
17134 case "co":
17135 return mapValue(
17136 match2.ordinalNumber(dateString, {
17137 unit: "day"
17138 }),
17139 valueCallback
17140 );
17141 // Tue
17142 case "ccc":
17143 return match2.day(dateString, {
17144 width: "abbreviated",
17145 context: "standalone"
17146 }) || match2.day(dateString, { width: "short", context: "standalone" }) || match2.day(dateString, { width: "narrow", context: "standalone" });
17147 // T
17148 case "ccccc":
17149 return match2.day(dateString, {
17150 width: "narrow",
17151 context: "standalone"
17152 });
17153 // Tu
17154 case "cccccc":
17155 return match2.day(dateString, { width: "short", context: "standalone" }) || match2.day(dateString, { width: "narrow", context: "standalone" });
17156 // Tuesday
17157 case "cccc":
17158 default:
17159 return match2.day(dateString, { width: "wide", context: "standalone" }) || match2.day(dateString, {
17160 width: "abbreviated",
17161 context: "standalone"
17162 }) || match2.day(dateString, { width: "short", context: "standalone" }) || match2.day(dateString, { width: "narrow", context: "standalone" });
17163 }
17164 }
17165 validate(_date, value) {
17166 return value >= 0 && value <= 6;
17167 }
17168 set(date, _flags, value, options) {
17169 date = setDay(date, value, options);
17170 date.setHours(0, 0, 0, 0);
17171 return date;
17172 }
17173 incompatibleTokens = [
17174 "y",
17175 "R",
17176 "u",
17177 "q",
17178 "Q",
17179 "M",
17180 "L",
17181 "I",
17182 "d",
17183 "D",
17184 "E",
17185 "i",
17186 "e",
17187 "t",
17188 "T"
17189 ];
17190 };
17191
17192 // node_modules/date-fns/setISODay.js
17193 function setISODay(date, day, options) {
17194 const date_ = toDate(date, options?.in);
17195 const currentDay = getISODay(date_, options);
17196 const diff = day - currentDay;
17197 return addDays(date_, diff, options);
17198 }
17199
17200 // node_modules/date-fns/parse/_lib/parsers/ISODayParser.js
17201 var ISODayParser = class extends Parser {
17202 priority = 90;
17203 parse(dateString, token, match2) {
17204 const valueCallback = (value) => {
17205 if (value === 0) {
17206 return 7;
17207 }
17208 return value;
17209 };
17210 switch (token) {
17211 // 2
17212 case "i":
17213 case "ii":
17214 return parseNDigits(token.length, dateString);
17215 // 2nd
17216 case "io":
17217 return match2.ordinalNumber(dateString, { unit: "day" });
17218 // Tue
17219 case "iii":
17220 return mapValue(
17221 match2.day(dateString, {
17222 width: "abbreviated",
17223 context: "formatting"
17224 }) || match2.day(dateString, {
17225 width: "short",
17226 context: "formatting"
17227 }) || match2.day(dateString, {
17228 width: "narrow",
17229 context: "formatting"
17230 }),
17231 valueCallback
17232 );
17233 // T
17234 case "iiiii":
17235 return mapValue(
17236 match2.day(dateString, {
17237 width: "narrow",
17238 context: "formatting"
17239 }),
17240 valueCallback
17241 );
17242 // Tu
17243 case "iiiiii":
17244 return mapValue(
17245 match2.day(dateString, {
17246 width: "short",
17247 context: "formatting"
17248 }) || match2.day(dateString, {
17249 width: "narrow",
17250 context: "formatting"
17251 }),
17252 valueCallback
17253 );
17254 // Tuesday
17255 case "iiii":
17256 default:
17257 return mapValue(
17258 match2.day(dateString, {
17259 width: "wide",
17260 context: "formatting"
17261 }) || match2.day(dateString, {
17262 width: "abbreviated",
17263 context: "formatting"
17264 }) || match2.day(dateString, {
17265 width: "short",
17266 context: "formatting"
17267 }) || match2.day(dateString, {
17268 width: "narrow",
17269 context: "formatting"
17270 }),
17271 valueCallback
17272 );
17273 }
17274 }
17275 validate(_date, value) {
17276 return value >= 1 && value <= 7;
17277 }
17278 set(date, _flags, value) {
17279 date = setISODay(date, value);
17280 date.setHours(0, 0, 0, 0);
17281 return date;
17282 }
17283 incompatibleTokens = [
17284 "y",
17285 "Y",
17286 "u",
17287 "q",
17288 "Q",
17289 "M",
17290 "L",
17291 "w",
17292 "d",
17293 "D",
17294 "E",
17295 "e",
17296 "c",
17297 "t",
17298 "T"
17299 ];
17300 };
17301
17302 // node_modules/date-fns/parse/_lib/parsers/AMPMParser.js
17303 var AMPMParser = class extends Parser {
17304 priority = 80;
17305 parse(dateString, token, match2) {
17306 switch (token) {
17307 case "a":
17308 case "aa":
17309 case "aaa":
17310 return match2.dayPeriod(dateString, {
17311 width: "abbreviated",
17312 context: "formatting"
17313 }) || match2.dayPeriod(dateString, {
17314 width: "narrow",
17315 context: "formatting"
17316 });
17317 case "aaaaa":
17318 return match2.dayPeriod(dateString, {
17319 width: "narrow",
17320 context: "formatting"
17321 });
17322 case "aaaa":
17323 default:
17324 return match2.dayPeriod(dateString, {
17325 width: "wide",
17326 context: "formatting"
17327 }) || match2.dayPeriod(dateString, {
17328 width: "abbreviated",
17329 context: "formatting"
17330 }) || match2.dayPeriod(dateString, {
17331 width: "narrow",
17332 context: "formatting"
17333 });
17334 }
17335 }
17336 set(date, _flags, value) {
17337 date.setHours(dayPeriodEnumToHours(value), 0, 0, 0);
17338 return date;
17339 }
17340 incompatibleTokens = ["b", "B", "H", "k", "t", "T"];
17341 };
17342
17343 // node_modules/date-fns/parse/_lib/parsers/AMPMMidnightParser.js
17344 var AMPMMidnightParser = class extends Parser {
17345 priority = 80;
17346 parse(dateString, token, match2) {
17347 switch (token) {
17348 case "b":
17349 case "bb":
17350 case "bbb":
17351 return match2.dayPeriod(dateString, {
17352 width: "abbreviated",
17353 context: "formatting"
17354 }) || match2.dayPeriod(dateString, {
17355 width: "narrow",
17356 context: "formatting"
17357 });
17358 case "bbbbb":
17359 return match2.dayPeriod(dateString, {
17360 width: "narrow",
17361 context: "formatting"
17362 });
17363 case "bbbb":
17364 default:
17365 return match2.dayPeriod(dateString, {
17366 width: "wide",
17367 context: "formatting"
17368 }) || match2.dayPeriod(dateString, {
17369 width: "abbreviated",
17370 context: "formatting"
17371 }) || match2.dayPeriod(dateString, {
17372 width: "narrow",
17373 context: "formatting"
17374 });
17375 }
17376 }
17377 set(date, _flags, value) {
17378 date.setHours(dayPeriodEnumToHours(value), 0, 0, 0);
17379 return date;
17380 }
17381 incompatibleTokens = ["a", "B", "H", "k", "t", "T"];
17382 };
17383
17384 // node_modules/date-fns/parse/_lib/parsers/DayPeriodParser.js
17385 var DayPeriodParser = class extends Parser {
17386 priority = 80;
17387 parse(dateString, token, match2) {
17388 switch (token) {
17389 case "B":
17390 case "BB":
17391 case "BBB":
17392 return match2.dayPeriod(dateString, {
17393 width: "abbreviated",
17394 context: "formatting"
17395 }) || match2.dayPeriod(dateString, {
17396 width: "narrow",
17397 context: "formatting"
17398 });
17399 case "BBBBB":
17400 return match2.dayPeriod(dateString, {
17401 width: "narrow",
17402 context: "formatting"
17403 });
17404 case "BBBB":
17405 default:
17406 return match2.dayPeriod(dateString, {
17407 width: "wide",
17408 context: "formatting"
17409 }) || match2.dayPeriod(dateString, {
17410 width: "abbreviated",
17411 context: "formatting"
17412 }) || match2.dayPeriod(dateString, {
17413 width: "narrow",
17414 context: "formatting"
17415 });
17416 }
17417 }
17418 set(date, _flags, value) {
17419 date.setHours(dayPeriodEnumToHours(value), 0, 0, 0);
17420 return date;
17421 }
17422 incompatibleTokens = ["a", "b", "t", "T"];
17423 };
17424
17425 // node_modules/date-fns/parse/_lib/parsers/Hour1to12Parser.js
17426 var Hour1to12Parser = class extends Parser {
17427 priority = 70;
17428 parse(dateString, token, match2) {
17429 switch (token) {
17430 case "h":
17431 return parseNumericPattern(numericPatterns.hour12h, dateString);
17432 case "ho":
17433 return match2.ordinalNumber(dateString, { unit: "hour" });
17434 default:
17435 return parseNDigits(token.length, dateString);
17436 }
17437 }
17438 validate(_date, value) {
17439 return value >= 1 && value <= 12;
17440 }
17441 set(date, _flags, value) {
17442 const isPM = date.getHours() >= 12;
17443 if (isPM && value < 12) {
17444 date.setHours(value + 12, 0, 0, 0);
17445 } else if (!isPM && value === 12) {
17446 date.setHours(0, 0, 0, 0);
17447 } else {
17448 date.setHours(value, 0, 0, 0);
17449 }
17450 return date;
17451 }
17452 incompatibleTokens = ["H", "K", "k", "t", "T"];
17453 };
17454
17455 // node_modules/date-fns/parse/_lib/parsers/Hour0to23Parser.js
17456 var Hour0to23Parser = class extends Parser {
17457 priority = 70;
17458 parse(dateString, token, match2) {
17459 switch (token) {
17460 case "H":
17461 return parseNumericPattern(numericPatterns.hour23h, dateString);
17462 case "Ho":
17463 return match2.ordinalNumber(dateString, { unit: "hour" });
17464 default:
17465 return parseNDigits(token.length, dateString);
17466 }
17467 }
17468 validate(_date, value) {
17469 return value >= 0 && value <= 23;
17470 }
17471 set(date, _flags, value) {
17472 date.setHours(value, 0, 0, 0);
17473 return date;
17474 }
17475 incompatibleTokens = ["a", "b", "h", "K", "k", "t", "T"];
17476 };
17477
17478 // node_modules/date-fns/parse/_lib/parsers/Hour0To11Parser.js
17479 var Hour0To11Parser = class extends Parser {
17480 priority = 70;
17481 parse(dateString, token, match2) {
17482 switch (token) {
17483 case "K":
17484 return parseNumericPattern(numericPatterns.hour11h, dateString);
17485 case "Ko":
17486 return match2.ordinalNumber(dateString, { unit: "hour" });
17487 default:
17488 return parseNDigits(token.length, dateString);
17489 }
17490 }
17491 validate(_date, value) {
17492 return value >= 0 && value <= 11;
17493 }
17494 set(date, _flags, value) {
17495 const isPM = date.getHours() >= 12;
17496 if (isPM && value < 12) {
17497 date.setHours(value + 12, 0, 0, 0);
17498 } else {
17499 date.setHours(value, 0, 0, 0);
17500 }
17501 return date;
17502 }
17503 incompatibleTokens = ["h", "H", "k", "t", "T"];
17504 };
17505
17506 // node_modules/date-fns/parse/_lib/parsers/Hour1To24Parser.js
17507 var Hour1To24Parser = class extends Parser {
17508 priority = 70;
17509 parse(dateString, token, match2) {
17510 switch (token) {
17511 case "k":
17512 return parseNumericPattern(numericPatterns.hour24h, dateString);
17513 case "ko":
17514 return match2.ordinalNumber(dateString, { unit: "hour" });
17515 default:
17516 return parseNDigits(token.length, dateString);
17517 }
17518 }
17519 validate(_date, value) {
17520 return value >= 1 && value <= 24;
17521 }
17522 set(date, _flags, value) {
17523 const hours = value <= 24 ? value % 24 : value;
17524 date.setHours(hours, 0, 0, 0);
17525 return date;
17526 }
17527 incompatibleTokens = ["a", "b", "h", "H", "K", "t", "T"];
17528 };
17529
17530 // node_modules/date-fns/parse/_lib/parsers/MinuteParser.js
17531 var MinuteParser = class extends Parser {
17532 priority = 60;
17533 parse(dateString, token, match2) {
17534 switch (token) {
17535 case "m":
17536 return parseNumericPattern(numericPatterns.minute, dateString);
17537 case "mo":
17538 return match2.ordinalNumber(dateString, { unit: "minute" });
17539 default:
17540 return parseNDigits(token.length, dateString);
17541 }
17542 }
17543 validate(_date, value) {
17544 return value >= 0 && value <= 59;
17545 }
17546 set(date, _flags, value) {
17547 date.setMinutes(value, 0, 0);
17548 return date;
17549 }
17550 incompatibleTokens = ["t", "T"];
17551 };
17552
17553 // node_modules/date-fns/parse/_lib/parsers/SecondParser.js
17554 var SecondParser = class extends Parser {
17555 priority = 50;
17556 parse(dateString, token, match2) {
17557 switch (token) {
17558 case "s":
17559 return parseNumericPattern(numericPatterns.second, dateString);
17560 case "so":
17561 return match2.ordinalNumber(dateString, { unit: "second" });
17562 default:
17563 return parseNDigits(token.length, dateString);
17564 }
17565 }
17566 validate(_date, value) {
17567 return value >= 0 && value <= 59;
17568 }
17569 set(date, _flags, value) {
17570 date.setSeconds(value, 0);
17571 return date;
17572 }
17573 incompatibleTokens = ["t", "T"];
17574 };
17575
17576 // node_modules/date-fns/parse/_lib/parsers/FractionOfSecondParser.js
17577 var FractionOfSecondParser = class extends Parser {
17578 priority = 30;
17579 parse(dateString, token) {
17580 const valueCallback = (value) => Math.trunc(value * Math.pow(10, -token.length + 3));
17581 return mapValue(parseNDigits(token.length, dateString), valueCallback);
17582 }
17583 set(date, _flags, value) {
17584 date.setMilliseconds(value);
17585 return date;
17586 }
17587 incompatibleTokens = ["t", "T"];
17588 };
17589
17590 // node_modules/date-fns/parse/_lib/parsers/ISOTimezoneWithZParser.js
17591 var ISOTimezoneWithZParser = class extends Parser {
17592 priority = 10;
17593 parse(dateString, token) {
17594 switch (token) {
17595 case "X":
17596 return parseTimezonePattern(
17597 timezonePatterns.basicOptionalMinutes,
17598 dateString
17599 );
17600 case "XX":
17601 return parseTimezonePattern(timezonePatterns.basic, dateString);
17602 case "XXXX":
17603 return parseTimezonePattern(
17604 timezonePatterns.basicOptionalSeconds,
17605 dateString
17606 );
17607 case "XXXXX":
17608 return parseTimezonePattern(
17609 timezonePatterns.extendedOptionalSeconds,
17610 dateString
17611 );
17612 case "XXX":
17613 default:
17614 return parseTimezonePattern(timezonePatterns.extended, dateString);
17615 }
17616 }
17617 set(date, flags, value) {
17618 if (flags.timestampIsSet) return date;
17619 return constructFrom(
17620 date,
17621 date.getTime() - getTimezoneOffsetInMilliseconds(date) - value
17622 );
17623 }
17624 incompatibleTokens = ["t", "T", "x"];
17625 };
17626
17627 // node_modules/date-fns/parse/_lib/parsers/ISOTimezoneParser.js
17628 var ISOTimezoneParser = class extends Parser {
17629 priority = 10;
17630 parse(dateString, token) {
17631 switch (token) {
17632 case "x":
17633 return parseTimezonePattern(
17634 timezonePatterns.basicOptionalMinutes,
17635 dateString
17636 );
17637 case "xx":
17638 return parseTimezonePattern(timezonePatterns.basic, dateString);
17639 case "xxxx":
17640 return parseTimezonePattern(
17641 timezonePatterns.basicOptionalSeconds,
17642 dateString
17643 );
17644 case "xxxxx":
17645 return parseTimezonePattern(
17646 timezonePatterns.extendedOptionalSeconds,
17647 dateString
17648 );
17649 case "xxx":
17650 default:
17651 return parseTimezonePattern(timezonePatterns.extended, dateString);
17652 }
17653 }
17654 set(date, flags, value) {
17655 if (flags.timestampIsSet) return date;
17656 return constructFrom(
17657 date,
17658 date.getTime() - getTimezoneOffsetInMilliseconds(date) - value
17659 );
17660 }
17661 incompatibleTokens = ["t", "T", "X"];
17662 };
17663
17664 // node_modules/date-fns/parse/_lib/parsers/TimestampSecondsParser.js
17665 var TimestampSecondsParser = class extends Parser {
17666 priority = 40;
17667 parse(dateString) {
17668 return parseAnyDigitsSigned(dateString);
17669 }
17670 set(date, _flags, value) {
17671 return [constructFrom(date, value * 1e3), { timestampIsSet: true }];
17672 }
17673 incompatibleTokens = "*";
17674 };
17675
17676 // node_modules/date-fns/parse/_lib/parsers/TimestampMillisecondsParser.js
17677 var TimestampMillisecondsParser = class extends Parser {
17678 priority = 20;
17679 parse(dateString) {
17680 return parseAnyDigitsSigned(dateString);
17681 }
17682 set(date, _flags, value) {
17683 return [constructFrom(date, value), { timestampIsSet: true }];
17684 }
17685 incompatibleTokens = "*";
17686 };
17687
17688 // node_modules/date-fns/parse/_lib/parsers.js
17689 var parsers = {
17690 G: new EraParser(),
17691 y: new YearParser(),
17692 Y: new LocalWeekYearParser(),
17693 R: new ISOWeekYearParser(),
17694 u: new ExtendedYearParser(),
17695 Q: new QuarterParser(),
17696 q: new StandAloneQuarterParser(),
17697 M: new MonthParser(),
17698 L: new StandAloneMonthParser(),
17699 w: new LocalWeekParser(),
17700 I: new ISOWeekParser(),
17701 d: new DateParser(),
17702 D: new DayOfYearParser(),
17703 E: new DayParser(),
17704 e: new LocalDayParser(),
17705 c: new StandAloneLocalDayParser(),
17706 i: new ISODayParser(),
17707 a: new AMPMParser(),
17708 b: new AMPMMidnightParser(),
17709 B: new DayPeriodParser(),
17710 h: new Hour1to12Parser(),
17711 H: new Hour0to23Parser(),
17712 K: new Hour0To11Parser(),
17713 k: new Hour1To24Parser(),
17714 m: new MinuteParser(),
17715 s: new SecondParser(),
17716 S: new FractionOfSecondParser(),
17717 X: new ISOTimezoneWithZParser(),
17718 x: new ISOTimezoneParser(),
17719 t: new TimestampSecondsParser(),
17720 T: new TimestampMillisecondsParser()
17721 };
17722
17723 // node_modules/date-fns/parse.js
17724 var formattingTokensRegExp2 = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
17725 var longFormattingTokensRegExp2 = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
17726 var escapedStringRegExp2 = /^'([^]*?)'?$/;
17727 var doubleQuoteRegExp2 = /''/g;
17728 var notWhitespaceRegExp = /\S/;
17729 var unescapedLatinCharacterRegExp2 = /[a-zA-Z]/;
17730 function parse(dateStr, formatStr, referenceDate, options) {
17731 const invalidDate = () => constructFrom(options?.in || referenceDate, NaN);
17732 const defaultOptions2 = getDefaultOptions2();
17733 const locale = options?.locale ?? defaultOptions2.locale ?? enUS;
17734 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
17735 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
17736 if (!formatStr)
17737 return dateStr ? invalidDate() : toDate(referenceDate, options?.in);
17738 const subFnOptions = {
17739 firstWeekContainsDate,
17740 weekStartsOn,
17741 locale
17742 };
17743 const setters = [new DateTimezoneSetter(options?.in, referenceDate)];
17744 const tokens = formatStr.match(longFormattingTokensRegExp2).map((substring) => {
17745 const firstCharacter = substring[0];
17746 if (firstCharacter in longFormatters) {
17747 const longFormatter = longFormatters[firstCharacter];
17748 return longFormatter(substring, locale.formatLong);
17749 }
17750 return substring;
17751 }).join("").match(formattingTokensRegExp2);
17752 const usedTokens = [];
17753 for (let token of tokens) {
17754 if (!options?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token)) {
17755 warnOrThrowProtectedError(token, formatStr, dateStr);
17756 }
17757 if (!options?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) {
17758 warnOrThrowProtectedError(token, formatStr, dateStr);
17759 }
17760 const firstCharacter = token[0];
17761 const parser = parsers[firstCharacter];
17762 if (parser) {
17763 const { incompatibleTokens } = parser;
17764 if (Array.isArray(incompatibleTokens)) {
17765 const incompatibleToken = usedTokens.find(
17766 (usedToken) => incompatibleTokens.includes(usedToken.token) || usedToken.token === firstCharacter
17767 );
17768 if (incompatibleToken) {
17769 throw new RangeError(
17770 `The format string mustn't contain \`${incompatibleToken.fullToken}\` and \`${token}\` at the same time`
17771 );
17772 }
17773 } else if (parser.incompatibleTokens === "*" && usedTokens.length > 0) {
17774 throw new RangeError(
17775 `The format string mustn't contain \`${token}\` and any other token at the same time`
17776 );
17777 }
17778 usedTokens.push({ token: firstCharacter, fullToken: token });
17779 const parseResult = parser.run(
17780 dateStr,
17781 token,
17782 locale.match,
17783 subFnOptions
17784 );
17785 if (!parseResult) {
17786 return invalidDate();
17787 }
17788 setters.push(parseResult.setter);
17789 dateStr = parseResult.rest;
17790 } else {
17791 if (firstCharacter.match(unescapedLatinCharacterRegExp2)) {
17792 throw new RangeError(
17793 "Format string contains an unescaped latin alphabet character `" + firstCharacter + "`"
17794 );
17795 }
17796 if (token === "''") {
17797 token = "'";
17798 } else if (firstCharacter === "'") {
17799 token = cleanEscapedString2(token);
17800 }
17801 if (dateStr.indexOf(token) === 0) {
17802 dateStr = dateStr.slice(token.length);
17803 } else {
17804 return invalidDate();
17805 }
17806 }
17807 }
17808 if (dateStr.length > 0 && notWhitespaceRegExp.test(dateStr)) {
17809 return invalidDate();
17810 }
17811 const uniquePrioritySetters = setters.map((setter) => setter.priority).sort((a, b) => b - a).filter((priority, index3, array) => array.indexOf(priority) === index3).map(
17812 (priority) => setters.filter((setter) => setter.priority === priority).sort((a, b) => b.subPriority - a.subPriority)
17813 ).map((setterArray) => setterArray[0]);
17814 let date = toDate(referenceDate, options?.in);
17815 if (isNaN(+date)) return invalidDate();
17816 const flags = {};
17817 for (const setter of uniquePrioritySetters) {
17818 if (!setter.validate(date, subFnOptions)) {
17819 return invalidDate();
17820 }
17821 const result = setter.set(date, flags, subFnOptions);
17822 if (Array.isArray(result)) {
17823 date = result[0];
17824 Object.assign(flags, result[1]);
17825 } else {
17826 date = result;
17827 }
17828 }
17829 return date;
17830 }
17831 function cleanEscapedString2(input) {
17832 return input.match(escapedStringRegExp2)[1].replace(doubleQuoteRegExp2, "'");
17833 }
17834
17835 // node_modules/date-fns/isSameMonth.js
17836 function isSameMonth(laterDate, earlierDate, options) {
17837 const [laterDate_, earlierDate_] = normalizeDates(
17838 options?.in,
17839 laterDate,
17840 earlierDate
17841 );
17842 return laterDate_.getFullYear() === earlierDate_.getFullYear() && laterDate_.getMonth() === earlierDate_.getMonth();
17843 }
17844
17845 // node_modules/date-fns/isSameYear.js
17846 function isSameYear(laterDate, earlierDate, options) {
17847 const [laterDate_, earlierDate_] = normalizeDates(
17848 options?.in,
17849 laterDate,
17850 earlierDate
17851 );
17852 return laterDate_.getFullYear() === earlierDate_.getFullYear();
17853 }
17854
17855 // node_modules/date-fns/subDays.js
17856 function subDays(date, amount, options) {
17857 return addDays(date, -amount, options);
17858 }
17859
17860 // node_modules/date-fns/parseISO.js
17861 function parseISO(argument, options) {
17862 const invalidDate = () => constructFrom(options?.in, NaN);
17863 const additionalDigits = options?.additionalDigits ?? 2;
17864 const dateStrings = splitDateString(argument);
17865 let date;
17866 if (dateStrings.date) {
17867 const parseYearResult = parseYear(dateStrings.date, additionalDigits);
17868 date = parseDate(parseYearResult.restDateString, parseYearResult.year);
17869 }
17870 if (!date || isNaN(+date)) return invalidDate();
17871 const timestamp = +date;
17872 let time = 0;
17873 let offset4;
17874 if (dateStrings.time) {
17875 time = parseTime(dateStrings.time);
17876 if (isNaN(time)) return invalidDate();
17877 }
17878 if (dateStrings.timezone) {
17879 offset4 = parseTimezone(dateStrings.timezone);
17880 if (isNaN(offset4)) return invalidDate();
17881 } else {
17882 const tmpDate = new Date(timestamp + time);
17883 const result = toDate(0, options?.in);
17884 result.setFullYear(
17885 tmpDate.getUTCFullYear(),
17886 tmpDate.getUTCMonth(),
17887 tmpDate.getUTCDate()
17888 );
17889 result.setHours(
17890 tmpDate.getUTCHours(),
17891 tmpDate.getUTCMinutes(),
17892 tmpDate.getUTCSeconds(),
17893 tmpDate.getUTCMilliseconds()
17894 );
17895 return result;
17896 }
17897 return toDate(timestamp + time + offset4, options?.in);
17898 }
17899 var patterns = {
17900 dateTimeDelimiter: /[T ]/,
17901 timeZoneDelimiter: /[Z ]/i,
17902 timezone: /([Z+-].*)$/
17903 };
17904 var dateRegex = /^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/;
17905 var timeRegex = /^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/;
17906 var timezoneRegex = /^([+-])(\d{2})(?::?(\d{2}))?$/;
17907 function splitDateString(dateString) {
17908 const dateStrings = {};
17909 const array = dateString.split(patterns.dateTimeDelimiter);
17910 let timeString;
17911 if (array.length > 2) {
17912 return dateStrings;
17913 }
17914 if (/:/.test(array[0])) {
17915 timeString = array[0];
17916 } else {
17917 dateStrings.date = array[0];
17918 timeString = array[1];
17919 if (patterns.timeZoneDelimiter.test(dateStrings.date)) {
17920 dateStrings.date = dateString.split(patterns.timeZoneDelimiter)[0];
17921 timeString = dateString.substr(
17922 dateStrings.date.length,
17923 dateString.length
17924 );
17925 }
17926 }
17927 if (timeString) {
17928 const token = patterns.timezone.exec(timeString);
17929 if (token) {
17930 dateStrings.time = timeString.replace(token[1], "");
17931 dateStrings.timezone = token[1];
17932 } else {
17933 dateStrings.time = timeString;
17934 }
17935 }
17936 return dateStrings;
17937 }
17938 function parseYear(dateString, additionalDigits) {
17939 const regex = new RegExp(
17940 "^(?:(\\d{4}|[+-]\\d{" + (4 + additionalDigits) + "})|(\\d{2}|[+-]\\d{" + (2 + additionalDigits) + "})$)"
17941 );
17942 const captures = dateString.match(regex);
17943 if (!captures) return { year: NaN, restDateString: "" };
17944 const year = captures[1] ? parseInt(captures[1]) : null;
17945 const century = captures[2] ? parseInt(captures[2]) : null;
17946 return {
17947 year: century === null ? year : century * 100,
17948 restDateString: dateString.slice((captures[1] || captures[2]).length)
17949 };
17950 }
17951 function parseDate(dateString, year) {
17952 if (year === null) return /* @__PURE__ */ new Date(NaN);
17953 const captures = dateString.match(dateRegex);
17954 if (!captures) return /* @__PURE__ */ new Date(NaN);
17955 const isWeekDate = !!captures[4];
17956 const dayOfYear = parseDateUnit(captures[1]);
17957 const month = parseDateUnit(captures[2]) - 1;
17958 const day = parseDateUnit(captures[3]);
17959 const week = parseDateUnit(captures[4]);
17960 const dayOfWeek = parseDateUnit(captures[5]) - 1;
17961 if (isWeekDate) {
17962 if (!validateWeekDate(year, week, dayOfWeek)) {
17963 return /* @__PURE__ */ new Date(NaN);
17964 }
17965 return dayOfISOWeekYear(year, week, dayOfWeek);
17966 } else {
17967 const date = /* @__PURE__ */ new Date(0);
17968 if (!validateDate(year, month, day) || !validateDayOfYearDate(year, dayOfYear)) {
17969 return /* @__PURE__ */ new Date(NaN);
17970 }
17971 date.setUTCFullYear(year, month, Math.max(dayOfYear, day));
17972 return date;
17973 }
17974 }
17975 function parseDateUnit(value) {
17976 return value ? parseInt(value) : 1;
17977 }
17978 function parseTime(timeString) {
17979 const captures = timeString.match(timeRegex);
17980 if (!captures) return NaN;
17981 const hours = parseTimeUnit(captures[1]);
17982 const minutes = parseTimeUnit(captures[2]);
17983 const seconds = parseTimeUnit(captures[3]);
17984 if (!validateTime(hours, minutes, seconds)) {
17985 return NaN;
17986 }
17987 return hours * millisecondsInHour + minutes * millisecondsInMinute + seconds * 1e3;
17988 }
17989 function parseTimeUnit(value) {
17990 return value && parseFloat(value.replace(",", ".")) || 0;
17991 }
17992 function parseTimezone(timezoneString) {
17993 if (timezoneString === "Z") return 0;
17994 const captures = timezoneString.match(timezoneRegex);
17995 if (!captures) return 0;
17996 const sign = captures[1] === "+" ? -1 : 1;
17997 const hours = parseInt(captures[2]);
17998 const minutes = captures[3] && parseInt(captures[3]) || 0;
17999 if (!validateTimezone(hours, minutes)) {
18000 return NaN;
18001 }
18002 return sign * (hours * millisecondsInHour + minutes * millisecondsInMinute);
18003 }
18004 function dayOfISOWeekYear(isoWeekYear, week, day) {
18005 const date = /* @__PURE__ */ new Date(0);
18006 date.setUTCFullYear(isoWeekYear, 0, 4);
18007 const fourthOfJanuaryDay = date.getUTCDay() || 7;
18008 const diff = (week - 1) * 7 + day + 1 - fourthOfJanuaryDay;
18009 date.setUTCDate(date.getUTCDate() + diff);
18010 return date;
18011 }
18012 var daysInMonths = [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
18013 function isLeapYearIndex2(year) {
18014 return year % 400 === 0 || year % 4 === 0 && year % 100 !== 0;
18015 }
18016 function validateDate(year, month, date) {
18017 return month >= 0 && month <= 11 && date >= 1 && date <= (daysInMonths[month] || (isLeapYearIndex2(year) ? 29 : 28));
18018 }
18019 function validateDayOfYearDate(year, dayOfYear) {
18020 return dayOfYear >= 1 && dayOfYear <= (isLeapYearIndex2(year) ? 366 : 365);
18021 }
18022 function validateWeekDate(_year, week, day) {
18023 return week >= 1 && week <= 53 && day >= 0 && day <= 6;
18024 }
18025 function validateTime(hours, minutes, seconds) {
18026 if (hours === 24) {
18027 return minutes === 0 && seconds === 0;
18028 }
18029 return seconds >= 0 && seconds < 60 && minutes >= 0 && minutes < 60 && hours >= 0 && hours < 25;
18030 }
18031 function validateTimezone(_hours, minutes) {
18032 return minutes >= 0 && minutes <= 59;
18033 }
18034
18035 // node_modules/date-fns/setMonth.js
18036 function setMonth(date, month, options) {
18037 const _date = toDate(date, options?.in);
18038 const year = _date.getFullYear();
18039 const day = _date.getDate();
18040 const midMonth = constructFrom(options?.in || date, 0);
18041 midMonth.setFullYear(year, month, 15);
18042 midMonth.setHours(0, 0, 0, 0);
18043 const daysInMonth = getDaysInMonth(midMonth);
18044 _date.setMonth(month, Math.min(day, daysInMonth));
18045 return _date;
18046 }
18047
18048 // node_modules/date-fns/setYear.js
18049 function setYear(date, year, options) {
18050 const date_ = toDate(date, options?.in);
18051 if (isNaN(+date_)) return constructFrom(options?.in || date, NaN);
18052 date_.setFullYear(year);
18053 return date_;
18054 }
18055
18056 // node_modules/date-fns/subMonths.js
18057 function subMonths(date, amount, options) {
18058 return addMonths(date, -amount, options);
18059 }
18060
18061 // node_modules/date-fns/subWeeks.js
18062 function subWeeks(date, amount, options) {
18063 return addWeeks(date, -amount, options);
18064 }
18065
18066 // node_modules/date-fns/subYears.js
18067 function subYears(date, amount, options) {
18068 return addYears(date, -amount, options);
18069 }
18070
18071 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/helpers/getBroadcastWeeksInMonth.js
18072 var FIVE_WEEKS = 5;
18073 var FOUR_WEEKS = 4;
18074 function getBroadcastWeeksInMonth(month, dateLib) {
18075 const firstDayOfMonth = dateLib.startOfMonth(month);
18076 const firstDayOfWeek = firstDayOfMonth.getDay() > 0 ? firstDayOfMonth.getDay() : 7;
18077 const broadcastStartDate = dateLib.addDays(month, -firstDayOfWeek + 1);
18078 const lastDateOfLastWeek = dateLib.addDays(broadcastStartDate, FIVE_WEEKS * 7 - 1);
18079 const numberOfWeeks = dateLib.getMonth(month) === dateLib.getMonth(lastDateOfLastWeek) ? FIVE_WEEKS : FOUR_WEEKS;
18080 return numberOfWeeks;
18081 }
18082
18083 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/helpers/startOfBroadcastWeek.js
18084 function startOfBroadcastWeek(date, dateLib) {
18085 const firstOfMonth = dateLib.startOfMonth(date);
18086 const dayOfWeek = firstOfMonth.getDay();
18087 if (dayOfWeek === 1) {
18088 return firstOfMonth;
18089 } else if (dayOfWeek === 0) {
18090 return dateLib.addDays(firstOfMonth, -1 * 6);
18091 } else {
18092 return dateLib.addDays(firstOfMonth, -1 * (dayOfWeek - 1));
18093 }
18094 }
18095
18096 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/helpers/endOfBroadcastWeek.js
18097 function endOfBroadcastWeek(date, dateLib) {
18098 const startDate = startOfBroadcastWeek(date, dateLib);
18099 const numberOfWeeks = getBroadcastWeeksInMonth(date, dateLib);
18100 const endDate = dateLib.addDays(startDate, numberOfWeeks * 7 - 1);
18101 return endDate;
18102 }
18103
18104 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/locale/en-US.js
18105 var enUS2 = {
18106 ...enUS,
18107 labels: {
18108 labelDayButton: (date, modifiers, options, dateLib) => {
18109 let formatDate2;
18110 if (dateLib && typeof dateLib.format === "function") {
18111 formatDate2 = dateLib.format.bind(dateLib);
18112 } else {
18113 formatDate2 = (d, pattern) => format(d, pattern, { locale: enUS, ...options });
18114 }
18115 let label = formatDate2(date, "PPPP");
18116 if (modifiers.today)
18117 label = `Today, ${label}`;
18118 if (modifiers.selected)
18119 label = `${label}, selected`;
18120 return label;
18121 },
18122 labelMonthDropdown: "Choose the Month",
18123 labelNext: "Go to the Next Month",
18124 labelPrevious: "Go to the Previous Month",
18125 labelWeekNumber: (weekNumber) => `Week ${weekNumber}`,
18126 labelYearDropdown: "Choose the Year",
18127 labelGrid: (date, options, dateLib) => {
18128 let formatDate2;
18129 if (dateLib && typeof dateLib.format === "function") {
18130 formatDate2 = dateLib.format.bind(dateLib);
18131 } else {
18132 formatDate2 = (d, pattern) => format(d, pattern, { locale: enUS, ...options });
18133 }
18134 return formatDate2(date, "LLLL yyyy");
18135 },
18136 labelGridcell: (date, modifiers, options, dateLib) => {
18137 let formatDate2;
18138 if (dateLib && typeof dateLib.format === "function") {
18139 formatDate2 = dateLib.format.bind(dateLib);
18140 } else {
18141 formatDate2 = (d, pattern) => format(d, pattern, { locale: enUS, ...options });
18142 }
18143 let label = formatDate2(date, "PPPP");
18144 if (modifiers?.today) {
18145 label = `Today, ${label}`;
18146 }
18147 return label;
18148 },
18149 labelNav: "Navigation bar",
18150 labelWeekNumberHeader: "Week Number",
18151 labelWeekday: (date, options, dateLib) => {
18152 let formatDate2;
18153 if (dateLib && typeof dateLib.format === "function") {
18154 formatDate2 = dateLib.format.bind(dateLib);
18155 } else {
18156 formatDate2 = (d, pattern) => format(d, pattern, { locale: enUS, ...options });
18157 }
18158 return formatDate2(date, "cccc");
18159 }
18160 }
18161 };
18162
18163 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/classes/DateLib.js
18164 var DateLib = class _DateLib {
18165 /**
18166 * Creates an instance of `DateLib`.
18167 *
18168 * @param options Configuration options for the date library.
18169 * @param overrides Custom overrides for the date library functions.
18170 */
18171 constructor(options, overrides) {
18172 this.today = () => {
18173 if (this.overrides?.today) {
18174 return this.overrides.today();
18175 }
18176 if (this.options.timeZone) {
18177 return TZDate.tz(this.options.timeZone);
18178 }
18179 const DateCtor = this.options.Date ?? Date;
18180 return new DateCtor();
18181 };
18182 this.newDate = (year, monthIndex, date) => {
18183 if (this.overrides?.newDate) {
18184 return this.overrides.newDate(year, monthIndex, date);
18185 }
18186 if (this.options.timeZone) {
18187 return new TZDate(year, monthIndex, date, this.options.timeZone);
18188 }
18189 return new Date(year, monthIndex, date);
18190 };
18191 this.addDays = (date, amount) => {
18192 return this.overrides?.addDays ? this.overrides.addDays(date, amount) : addDays(date, amount);
18193 };
18194 this.addMonths = (date, amount) => {
18195 return this.overrides?.addMonths ? this.overrides.addMonths(date, amount) : addMonths(date, amount);
18196 };
18197 this.addWeeks = (date, amount) => {
18198 return this.overrides?.addWeeks ? this.overrides.addWeeks(date, amount) : addWeeks(date, amount);
18199 };
18200 this.addYears = (date, amount) => {
18201 return this.overrides?.addYears ? this.overrides.addYears(date, amount) : addYears(date, amount);
18202 };
18203 this.differenceInCalendarDays = (dateLeft, dateRight) => {
18204 return this.overrides?.differenceInCalendarDays ? this.overrides.differenceInCalendarDays(dateLeft, dateRight) : differenceInCalendarDays(dateLeft, dateRight);
18205 };
18206 this.differenceInCalendarMonths = (dateLeft, dateRight) => {
18207 return this.overrides?.differenceInCalendarMonths ? this.overrides.differenceInCalendarMonths(dateLeft, dateRight) : differenceInCalendarMonths(dateLeft, dateRight);
18208 };
18209 this.eachMonthOfInterval = (interval) => {
18210 return this.overrides?.eachMonthOfInterval ? this.overrides.eachMonthOfInterval(interval) : eachMonthOfInterval(interval);
18211 };
18212 this.eachYearOfInterval = (interval) => {
18213 const years = this.overrides?.eachYearOfInterval ? this.overrides.eachYearOfInterval(interval) : eachYearOfInterval(interval);
18214 const uniqueYears = new Set(years.map((d) => this.getYear(d)));
18215 if (uniqueYears.size === years.length) {
18216 return years;
18217 }
18218 const yearsArray = [];
18219 uniqueYears.forEach((y2) => {
18220 yearsArray.push(new Date(y2, 0, 1));
18221 });
18222 return yearsArray;
18223 };
18224 this.endOfBroadcastWeek = (date) => {
18225 return this.overrides?.endOfBroadcastWeek ? this.overrides.endOfBroadcastWeek(date) : endOfBroadcastWeek(date, this);
18226 };
18227 this.endOfISOWeek = (date) => {
18228 return this.overrides?.endOfISOWeek ? this.overrides.endOfISOWeek(date) : endOfISOWeek(date);
18229 };
18230 this.endOfMonth = (date) => {
18231 return this.overrides?.endOfMonth ? this.overrides.endOfMonth(date) : endOfMonth(date);
18232 };
18233 this.endOfWeek = (date, options2) => {
18234 return this.overrides?.endOfWeek ? this.overrides.endOfWeek(date, options2) : endOfWeek(date, this.options);
18235 };
18236 this.endOfYear = (date) => {
18237 return this.overrides?.endOfYear ? this.overrides.endOfYear(date) : endOfYear(date);
18238 };
18239 this.format = (date, formatStr, _options) => {
18240 const formatted = this.overrides?.format ? this.overrides.format(date, formatStr, this.options) : format(date, formatStr, this.options);
18241 if (this.options.numerals && this.options.numerals !== "latn") {
18242 return this.replaceDigits(formatted);
18243 }
18244 return formatted;
18245 };
18246 this.getISOWeek = (date) => {
18247 return this.overrides?.getISOWeek ? this.overrides.getISOWeek(date) : getISOWeek(date);
18248 };
18249 this.getMonth = (date, _options) => {
18250 return this.overrides?.getMonth ? this.overrides.getMonth(date, this.options) : getMonth(date, this.options);
18251 };
18252 this.getYear = (date, _options) => {
18253 return this.overrides?.getYear ? this.overrides.getYear(date, this.options) : getYear(date, this.options);
18254 };
18255 this.getWeek = (date, _options) => {
18256 return this.overrides?.getWeek ? this.overrides.getWeek(date, this.options) : getWeek(date, this.options);
18257 };
18258 this.isAfter = (date, dateToCompare) => {
18259 return this.overrides?.isAfter ? this.overrides.isAfter(date, dateToCompare) : isAfter(date, dateToCompare);
18260 };
18261 this.isBefore = (date, dateToCompare) => {
18262 return this.overrides?.isBefore ? this.overrides.isBefore(date, dateToCompare) : isBefore(date, dateToCompare);
18263 };
18264 this.isDate = (value) => {
18265 return this.overrides?.isDate ? this.overrides.isDate(value) : isDate(value);
18266 };
18267 this.isSameDay = (dateLeft, dateRight) => {
18268 return this.overrides?.isSameDay ? this.overrides.isSameDay(dateLeft, dateRight) : isSameDay(dateLeft, dateRight);
18269 };
18270 this.isSameMonth = (dateLeft, dateRight) => {
18271 return this.overrides?.isSameMonth ? this.overrides.isSameMonth(dateLeft, dateRight) : isSameMonth(dateLeft, dateRight);
18272 };
18273 this.isSameYear = (dateLeft, dateRight) => {
18274 return this.overrides?.isSameYear ? this.overrides.isSameYear(dateLeft, dateRight) : isSameYear(dateLeft, dateRight);
18275 };
18276 this.max = (dates) => {
18277 return this.overrides?.max ? this.overrides.max(dates) : max2(dates);
18278 };
18279 this.min = (dates) => {
18280 return this.overrides?.min ? this.overrides.min(dates) : min2(dates);
18281 };
18282 this.setMonth = (date, month) => {
18283 return this.overrides?.setMonth ? this.overrides.setMonth(date, month) : setMonth(date, month);
18284 };
18285 this.setYear = (date, year) => {
18286 return this.overrides?.setYear ? this.overrides.setYear(date, year) : setYear(date, year);
18287 };
18288 this.startOfBroadcastWeek = (date, _dateLib) => {
18289 return this.overrides?.startOfBroadcastWeek ? this.overrides.startOfBroadcastWeek(date, this) : startOfBroadcastWeek(date, this);
18290 };
18291 this.startOfDay = (date) => {
18292 return this.overrides?.startOfDay ? this.overrides.startOfDay(date) : startOfDay(date);
18293 };
18294 this.startOfISOWeek = (date) => {
18295 return this.overrides?.startOfISOWeek ? this.overrides.startOfISOWeek(date) : startOfISOWeek(date);
18296 };
18297 this.startOfMonth = (date) => {
18298 return this.overrides?.startOfMonth ? this.overrides.startOfMonth(date) : startOfMonth(date);
18299 };
18300 this.startOfWeek = (date, _options) => {
18301 return this.overrides?.startOfWeek ? this.overrides.startOfWeek(date, this.options) : startOfWeek(date, this.options);
18302 };
18303 this.startOfYear = (date) => {
18304 return this.overrides?.startOfYear ? this.overrides.startOfYear(date) : startOfYear(date);
18305 };
18306 this.options = { locale: enUS2, ...options };
18307 this.overrides = overrides;
18308 }
18309 /**
18310 * Generates a mapping of Arabic digits (0-9) to the target numbering system
18311 * digits.
18312 *
18313 * @since 9.5.0
18314 * @returns A record mapping Arabic digits to the target numerals.
18315 */
18316 getDigitMap() {
18317 const { numerals = "latn" } = this.options;
18318 const formatter = new Intl.NumberFormat("en-US", {
18319 numberingSystem: numerals
18320 });
18321 const digitMap = {};
18322 for (let i = 0; i < 10; i++) {
18323 digitMap[i.toString()] = formatter.format(i);
18324 }
18325 return digitMap;
18326 }
18327 /**
18328 * Replaces Arabic digits in a string with the target numbering system digits.
18329 *
18330 * @since 9.5.0
18331 * @param input The string containing Arabic digits.
18332 * @returns The string with digits replaced.
18333 */
18334 replaceDigits(input) {
18335 const digitMap = this.getDigitMap();
18336 return input.replace(/\d/g, (digit) => digitMap[digit] || digit);
18337 }
18338 /**
18339 * Formats a number using the configured numbering system.
18340 *
18341 * @since 9.5.0
18342 * @param value The number to format.
18343 * @returns The formatted number as a string.
18344 */
18345 formatNumber(value) {
18346 return this.replaceDigits(value.toString());
18347 }
18348 /**
18349 * Returns the preferred ordering for month and year labels for the current
18350 * locale.
18351 */
18352 getMonthYearOrder() {
18353 const code = this.options.locale?.code;
18354 if (!code) {
18355 return "month-first";
18356 }
18357 return _DateLib.yearFirstLocales.has(code) ? "year-first" : "month-first";
18358 }
18359 /**
18360 * Formats the month/year pair respecting locale conventions.
18361 *
18362 * @since 9.11.0
18363 */
18364 formatMonthYear(date) {
18365 const { locale, timeZone, numerals } = this.options;
18366 const localeCode = locale?.code;
18367 if (localeCode && _DateLib.yearFirstLocales.has(localeCode)) {
18368 try {
18369 const intl = new Intl.DateTimeFormat(localeCode, {
18370 month: "long",
18371 year: "numeric",
18372 timeZone,
18373 numberingSystem: numerals
18374 });
18375 const formatted = intl.format(date);
18376 return formatted;
18377 } catch {
18378 }
18379 }
18380 const pattern = this.getMonthYearOrder() === "year-first" ? "y LLLL" : "LLLL y";
18381 return this.format(date, pattern);
18382 }
18383 };
18384 DateLib.yearFirstLocales = /* @__PURE__ */ new Set([
18385 "eu",
18386 "hu",
18387 "ja",
18388 "ja-Hira",
18389 "ja-JP",
18390 "ko",
18391 "ko-KR",
18392 "lt",
18393 "lt-LT",
18394 "lv",
18395 "lv-LV",
18396 "mn",
18397 "mn-MN",
18398 "zh",
18399 "zh-CN",
18400 "zh-HK",
18401 "zh-TW"
18402 ]);
18403 var defaultDateLib = new DateLib();
18404
18405 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/classes/CalendarDay.js
18406 var CalendarDay = class {
18407 constructor(date, displayMonth, dateLib = defaultDateLib) {
18408 this.date = date;
18409 this.displayMonth = displayMonth;
18410 this.outside = Boolean(displayMonth && !dateLib.isSameMonth(date, displayMonth));
18411 this.dateLib = dateLib;
18412 this.isoDate = dateLib.format(date, "yyyy-MM-dd");
18413 this.displayMonthId = dateLib.format(displayMonth, "yyyy-MM");
18414 this.dateMonthId = dateLib.format(date, "yyyy-MM");
18415 }
18416 /**
18417 * Checks if this day is equal to another `CalendarDay`, considering both the
18418 * date and the displayed month.
18419 *
18420 * @param day The `CalendarDay` to compare with.
18421 * @returns `true` if the days are equal, otherwise `false`.
18422 */
18423 isEqualTo(day) {
18424 return this.dateLib.isSameDay(day.date, this.date) && this.dateLib.isSameMonth(day.displayMonth, this.displayMonth);
18425 }
18426 };
18427
18428 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/classes/CalendarMonth.js
18429 var CalendarMonth = class {
18430 constructor(month, weeks) {
18431 this.date = month;
18432 this.weeks = weeks;
18433 }
18434 };
18435
18436 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/classes/CalendarWeek.js
18437 var CalendarWeek = class {
18438 constructor(weekNumber, days) {
18439 this.days = days;
18440 this.weekNumber = weekNumber;
18441 }
18442 };
18443
18444 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/components/custom-components.js
18445 var custom_components_exports = {};
18446 __export(custom_components_exports, {
18447 CaptionLabel: () => CaptionLabel,
18448 Chevron: () => Chevron,
18449 Day: () => Day,
18450 DayButton: () => DayButton,
18451 Dropdown: () => Dropdown,
18452 DropdownNav: () => DropdownNav,
18453 Footer: () => Footer,
18454 Month: () => Month,
18455 MonthCaption: () => MonthCaption,
18456 MonthGrid: () => MonthGrid,
18457 Months: () => Months,
18458 MonthsDropdown: () => MonthsDropdown,
18459 Nav: () => Nav,
18460 NextMonthButton: () => NextMonthButton,
18461 Option: () => Option,
18462 PreviousMonthButton: () => PreviousMonthButton,
18463 Root: () => Root2,
18464 Select: () => Select,
18465 Week: () => Week,
18466 WeekNumber: () => WeekNumber,
18467 WeekNumberHeader: () => WeekNumberHeader,
18468 Weekday: () => Weekday,
18469 Weekdays: () => Weekdays,
18470 Weeks: () => Weeks,
18471 YearsDropdown: () => YearsDropdown
18472 });
18473
18474 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/components/CaptionLabel.js
18475 var import_react6 = __toESM(require_react(), 1);
18476 function CaptionLabel(props) {
18477 return import_react6.default.createElement("span", { ...props });
18478 }
18479
18480 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/components/Chevron.js
18481 var import_react7 = __toESM(require_react(), 1);
18482 function Chevron(props) {
18483 const { size: size4 = 24, orientation = "left", className, style } = props;
18484 return import_react7.default.createElement(
18485 "svg",
18486 { className, style, width: size4, height: size4, viewBox: "0 0 24 24" },
18487 orientation === "up" && import_react7.default.createElement("polygon", { points: "6.77 17 12.5 11.43 18.24 17 20 15.28 12.5 8 5 15.28" }),
18488 orientation === "down" && import_react7.default.createElement("polygon", { points: "6.77 8 12.5 13.57 18.24 8 20 9.72 12.5 17 5 9.72" }),
18489 orientation === "left" && import_react7.default.createElement("polygon", { points: "16 18.112 9.81111111 12 16 5.87733333 14.0888889 4 6 12 14.0888889 20" }),
18490 orientation === "right" && import_react7.default.createElement("polygon", { points: "8 18.112 14.18888889 12 8 5.87733333 9.91111111 4 18 12 9.91111111 20" })
18491 );
18492 }
18493
18494 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/components/Day.js
18495 var import_react8 = __toESM(require_react(), 1);
18496 function Day(props) {
18497 const { day, modifiers, ...tdProps } = props;
18498 return import_react8.default.createElement("td", { ...tdProps });
18499 }
18500
18501 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/components/DayButton.js
18502 var import_react9 = __toESM(require_react(), 1);
18503 function DayButton(props) {
18504 const { day, modifiers, ...buttonProps } = props;
18505 const ref = import_react9.default.useRef(null);
18506 import_react9.default.useEffect(() => {
18507 if (modifiers.focused)
18508 ref.current?.focus();
18509 }, [modifiers.focused]);
18510 return import_react9.default.createElement("button", { ref, ...buttonProps });
18511 }
18512
18513 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/components/Dropdown.js
18514 var import_react11 = __toESM(require_react(), 1);
18515
18516 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/UI.js
18517 var UI;
18518 (function(UI2) {
18519 UI2["Root"] = "root";
18520 UI2["Chevron"] = "chevron";
18521 UI2["Day"] = "day";
18522 UI2["DayButton"] = "day_button";
18523 UI2["CaptionLabel"] = "caption_label";
18524 UI2["Dropdowns"] = "dropdowns";
18525 UI2["Dropdown"] = "dropdown";
18526 UI2["DropdownRoot"] = "dropdown_root";
18527 UI2["Footer"] = "footer";
18528 UI2["MonthGrid"] = "month_grid";
18529 UI2["MonthCaption"] = "month_caption";
18530 UI2["MonthsDropdown"] = "months_dropdown";
18531 UI2["Month"] = "month";
18532 UI2["Months"] = "months";
18533 UI2["Nav"] = "nav";
18534 UI2["NextMonthButton"] = "button_next";
18535 UI2["PreviousMonthButton"] = "button_previous";
18536 UI2["Week"] = "week";
18537 UI2["Weeks"] = "weeks";
18538 UI2["Weekday"] = "weekday";
18539 UI2["Weekdays"] = "weekdays";
18540 UI2["WeekNumber"] = "week_number";
18541 UI2["WeekNumberHeader"] = "week_number_header";
18542 UI2["YearsDropdown"] = "years_dropdown";
18543 })(UI || (UI = {}));
18544 var DayFlag;
18545 (function(DayFlag2) {
18546 DayFlag2["disabled"] = "disabled";
18547 DayFlag2["hidden"] = "hidden";
18548 DayFlag2["outside"] = "outside";
18549 DayFlag2["focused"] = "focused";
18550 DayFlag2["today"] = "today";
18551 })(DayFlag || (DayFlag = {}));
18552 var SelectionState;
18553 (function(SelectionState2) {
18554 SelectionState2["range_end"] = "range_end";
18555 SelectionState2["range_middle"] = "range_middle";
18556 SelectionState2["range_start"] = "range_start";
18557 SelectionState2["selected"] = "selected";
18558 })(SelectionState || (SelectionState = {}));
18559 var Animation;
18560 (function(Animation2) {
18561 Animation2["weeks_before_enter"] = "weeks_before_enter";
18562 Animation2["weeks_before_exit"] = "weeks_before_exit";
18563 Animation2["weeks_after_enter"] = "weeks_after_enter";
18564 Animation2["weeks_after_exit"] = "weeks_after_exit";
18565 Animation2["caption_after_enter"] = "caption_after_enter";
18566 Animation2["caption_after_exit"] = "caption_after_exit";
18567 Animation2["caption_before_enter"] = "caption_before_enter";
18568 Animation2["caption_before_exit"] = "caption_before_exit";
18569 })(Animation || (Animation = {}));
18570
18571 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/useDayPicker.js
18572 var import_react10 = __toESM(require_react(), 1);
18573 var dayPickerContext = (0, import_react10.createContext)(void 0);
18574 function useDayPicker() {
18575 const context = (0, import_react10.useContext)(dayPickerContext);
18576 if (context === void 0) {
18577 throw new Error("useDayPicker() must be used within a custom component.");
18578 }
18579 return context;
18580 }
18581
18582 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/components/Dropdown.js
18583 function Dropdown(props) {
18584 const { options, className, ...selectProps } = props;
18585 const { classNames, components, styles } = useDayPicker();
18586 const cssClassSelect = [classNames[UI.Dropdown], className].join(" ");
18587 const selectedOption = options?.find(({ value }) => value === selectProps.value);
18588 return import_react11.default.createElement(
18589 "span",
18590 { "data-disabled": selectProps.disabled, className: classNames[UI.DropdownRoot], style: styles?.[UI.DropdownRoot] },
18591 import_react11.default.createElement(components.Select, { className: cssClassSelect, ...selectProps }, options?.map(({ value, label, disabled: disabled2 }) => import_react11.default.createElement(components.Option, { key: value, value, disabled: disabled2 }, label))),
18592 import_react11.default.createElement(
18593 "span",
18594 { className: classNames[UI.CaptionLabel], style: styles?.[UI.CaptionLabel], "aria-hidden": true },
18595 selectedOption?.label,
18596 import_react11.default.createElement(components.Chevron, { orientation: "down", size: 18, className: classNames[UI.Chevron], style: styles?.[UI.Chevron] })
18597 )
18598 );
18599 }
18600
18601 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/components/DropdownNav.js
18602 var import_react12 = __toESM(require_react(), 1);
18603 function DropdownNav(props) {
18604 return import_react12.default.createElement("div", { ...props });
18605 }
18606
18607 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/components/Footer.js
18608 var import_react13 = __toESM(require_react(), 1);
18609 function Footer(props) {
18610 return import_react13.default.createElement("div", { ...props });
18611 }
18612
18613 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/components/Month.js
18614 var import_react14 = __toESM(require_react(), 1);
18615 function Month(props) {
18616 const { calendarMonth, displayIndex, ...divProps } = props;
18617 return import_react14.default.createElement("div", { ...divProps }, props.children);
18618 }
18619
18620 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/components/MonthCaption.js
18621 var import_react15 = __toESM(require_react(), 1);
18622 function MonthCaption(props) {
18623 const { calendarMonth, displayIndex, ...divProps } = props;
18624 return import_react15.default.createElement("div", { ...divProps });
18625 }
18626
18627 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/components/MonthGrid.js
18628 var import_react16 = __toESM(require_react(), 1);
18629 function MonthGrid(props) {
18630 return import_react16.default.createElement("table", { ...props });
18631 }
18632
18633 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/components/Months.js
18634 var import_react17 = __toESM(require_react(), 1);
18635 function Months(props) {
18636 return import_react17.default.createElement("div", { ...props });
18637 }
18638
18639 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/components/MonthsDropdown.js
18640 var import_react18 = __toESM(require_react(), 1);
18641 function MonthsDropdown(props) {
18642 const { components } = useDayPicker();
18643 return import_react18.default.createElement(components.Dropdown, { ...props });
18644 }
18645
18646 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/components/Nav.js
18647 var import_react19 = __toESM(require_react(), 1);
18648 function Nav(props) {
18649 const { onPreviousClick, onNextClick, previousMonth, nextMonth, ...navProps } = props;
18650 const { components, classNames, styles, labels: { labelPrevious: labelPrevious2, labelNext: labelNext2 } } = useDayPicker();
18651 const handleNextClick = (0, import_react19.useCallback)((e) => {
18652 if (nextMonth) {
18653 onNextClick?.(e);
18654 }
18655 }, [nextMonth, onNextClick]);
18656 const handlePreviousClick = (0, import_react19.useCallback)((e) => {
18657 if (previousMonth) {
18658 onPreviousClick?.(e);
18659 }
18660 }, [previousMonth, onPreviousClick]);
18661 return import_react19.default.createElement(
18662 "nav",
18663 { ...navProps },
18664 import_react19.default.createElement(
18665 components.PreviousMonthButton,
18666 { type: "button", className: classNames[UI.PreviousMonthButton], style: styles?.[UI.PreviousMonthButton], tabIndex: previousMonth ? void 0 : -1, "aria-disabled": previousMonth ? void 0 : true, "aria-label": labelPrevious2(previousMonth), onClick: handlePreviousClick },
18667 import_react19.default.createElement(components.Chevron, { disabled: previousMonth ? void 0 : true, className: classNames[UI.Chevron], style: styles?.[UI.Chevron], orientation: "left" })
18668 ),
18669 import_react19.default.createElement(
18670 components.NextMonthButton,
18671 { type: "button", className: classNames[UI.NextMonthButton], style: styles?.[UI.NextMonthButton], tabIndex: nextMonth ? void 0 : -1, "aria-disabled": nextMonth ? void 0 : true, "aria-label": labelNext2(nextMonth), onClick: handleNextClick },
18672 import_react19.default.createElement(components.Chevron, { disabled: nextMonth ? void 0 : true, orientation: "right", className: classNames[UI.Chevron], style: styles?.[UI.Chevron] })
18673 )
18674 );
18675 }
18676
18677 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/components/NextMonthButton.js
18678 var import_react20 = __toESM(require_react(), 1);
18679 function NextMonthButton(props) {
18680 return import_react20.default.createElement("button", { ...props });
18681 }
18682
18683 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/components/Option.js
18684 var import_react21 = __toESM(require_react(), 1);
18685 function Option(props) {
18686 return import_react21.default.createElement("option", { ...props });
18687 }
18688
18689 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/components/PreviousMonthButton.js
18690 var import_react22 = __toESM(require_react(), 1);
18691 function PreviousMonthButton(props) {
18692 return import_react22.default.createElement("button", { ...props });
18693 }
18694
18695 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/components/Root.js
18696 var import_react23 = __toESM(require_react(), 1);
18697 function Root2(props) {
18698 const { rootRef, ...rest } = props;
18699 return import_react23.default.createElement("div", { ...rest, ref: rootRef });
18700 }
18701
18702 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/components/Select.js
18703 var import_react24 = __toESM(require_react(), 1);
18704 function Select(props) {
18705 return import_react24.default.createElement("select", { ...props });
18706 }
18707
18708 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/components/Week.js
18709 var import_react25 = __toESM(require_react(), 1);
18710 function Week(props) {
18711 const { week, ...trProps } = props;
18712 return import_react25.default.createElement("tr", { ...trProps });
18713 }
18714
18715 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/components/Weekday.js
18716 var import_react26 = __toESM(require_react(), 1);
18717 function Weekday(props) {
18718 return import_react26.default.createElement("th", { ...props });
18719 }
18720
18721 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/components/Weekdays.js
18722 var import_react27 = __toESM(require_react(), 1);
18723 function Weekdays(props) {
18724 return import_react27.default.createElement(
18725 "thead",
18726 { "aria-hidden": true },
18727 import_react27.default.createElement("tr", { ...props })
18728 );
18729 }
18730
18731 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/components/WeekNumber.js
18732 var import_react28 = __toESM(require_react(), 1);
18733 function WeekNumber(props) {
18734 const { week, ...thProps } = props;
18735 return import_react28.default.createElement("th", { ...thProps });
18736 }
18737
18738 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/components/WeekNumberHeader.js
18739 var import_react29 = __toESM(require_react(), 1);
18740 function WeekNumberHeader(props) {
18741 return import_react29.default.createElement("th", { ...props });
18742 }
18743
18744 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/components/Weeks.js
18745 var import_react30 = __toESM(require_react(), 1);
18746 function Weeks(props) {
18747 return import_react30.default.createElement("tbody", { ...props });
18748 }
18749
18750 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/components/YearsDropdown.js
18751 var import_react31 = __toESM(require_react(), 1);
18752 function YearsDropdown(props) {
18753 const { components } = useDayPicker();
18754 return import_react31.default.createElement(components.Dropdown, { ...props });
18755 }
18756
18757 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/DayPicker.js
18758 var import_react36 = __toESM(require_react(), 1);
18759
18760 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/utils/rangeIncludesDate.js
18761 function rangeIncludesDate(range, date, excludeEnds = false, dateLib = defaultDateLib) {
18762 let { from, to } = range;
18763 const { differenceInCalendarDays: differenceInCalendarDays2, isSameDay: isSameDay2 } = dateLib;
18764 if (from && to) {
18765 const isRangeInverted = differenceInCalendarDays2(to, from) < 0;
18766 if (isRangeInverted) {
18767 [from, to] = [to, from];
18768 }
18769 const isInRange = differenceInCalendarDays2(date, from) >= (excludeEnds ? 1 : 0) && differenceInCalendarDays2(to, date) >= (excludeEnds ? 1 : 0);
18770 return isInRange;
18771 }
18772 if (!excludeEnds && to) {
18773 return isSameDay2(to, date);
18774 }
18775 if (!excludeEnds && from) {
18776 return isSameDay2(from, date);
18777 }
18778 return false;
18779 }
18780
18781 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/utils/typeguards.js
18782 function isDateInterval(matcher) {
18783 return Boolean(matcher && typeof matcher === "object" && "before" in matcher && "after" in matcher);
18784 }
18785 function isDateRange(value) {
18786 return Boolean(value && typeof value === "object" && "from" in value);
18787 }
18788 function isDateAfterType(value) {
18789 return Boolean(value && typeof value === "object" && "after" in value);
18790 }
18791 function isDateBeforeType(value) {
18792 return Boolean(value && typeof value === "object" && "before" in value);
18793 }
18794 function isDayOfWeekType(value) {
18795 return Boolean(value && typeof value === "object" && "dayOfWeek" in value);
18796 }
18797 function isDatesArray(value, dateLib) {
18798 return Array.isArray(value) && value.every(dateLib.isDate);
18799 }
18800
18801 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/utils/dateMatchModifiers.js
18802 function dateMatchModifiers(date, matchers, dateLib = defaultDateLib) {
18803 const matchersArr = !Array.isArray(matchers) ? [matchers] : matchers;
18804 const { isSameDay: isSameDay2, differenceInCalendarDays: differenceInCalendarDays2, isAfter: isAfter2 } = dateLib;
18805 return matchersArr.some((matcher) => {
18806 if (typeof matcher === "boolean") {
18807 return matcher;
18808 }
18809 if (dateLib.isDate(matcher)) {
18810 return isSameDay2(date, matcher);
18811 }
18812 if (isDatesArray(matcher, dateLib)) {
18813 return matcher.some((matcherDate) => isSameDay2(date, matcherDate));
18814 }
18815 if (isDateRange(matcher)) {
18816 return rangeIncludesDate(matcher, date, false, dateLib);
18817 }
18818 if (isDayOfWeekType(matcher)) {
18819 if (!Array.isArray(matcher.dayOfWeek)) {
18820 return matcher.dayOfWeek === date.getDay();
18821 }
18822 return matcher.dayOfWeek.includes(date.getDay());
18823 }
18824 if (isDateInterval(matcher)) {
18825 const diffBefore = differenceInCalendarDays2(matcher.before, date);
18826 const diffAfter = differenceInCalendarDays2(matcher.after, date);
18827 const isDayBefore = diffBefore > 0;
18828 const isDayAfter = diffAfter < 0;
18829 const isClosedInterval = isAfter2(matcher.before, matcher.after);
18830 if (isClosedInterval) {
18831 return isDayAfter && isDayBefore;
18832 } else {
18833 return isDayBefore || isDayAfter;
18834 }
18835 }
18836 if (isDateAfterType(matcher)) {
18837 return differenceInCalendarDays2(date, matcher.after) > 0;
18838 }
18839 if (isDateBeforeType(matcher)) {
18840 return differenceInCalendarDays2(matcher.before, date) > 0;
18841 }
18842 if (typeof matcher === "function") {
18843 return matcher(date);
18844 }
18845 return false;
18846 });
18847 }
18848
18849 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/helpers/createGetModifiers.js
18850 function createGetModifiers(days, props, navStart, navEnd, dateLib) {
18851 const { disabled: disabled2, hidden, modifiers, showOutsideDays, broadcastCalendar, today = dateLib.today() } = props;
18852 const { isSameDay: isSameDay2, isSameMonth: isSameMonth2, startOfMonth: startOfMonth2, isBefore: isBefore2, endOfMonth: endOfMonth2, isAfter: isAfter2 } = dateLib;
18853 const computedNavStart = navStart && startOfMonth2(navStart);
18854 const computedNavEnd = navEnd && endOfMonth2(navEnd);
18855 const internalModifiersMap = {
18856 [DayFlag.focused]: [],
18857 [DayFlag.outside]: [],
18858 [DayFlag.disabled]: [],
18859 [DayFlag.hidden]: [],
18860 [DayFlag.today]: []
18861 };
18862 const customModifiersMap = {};
18863 for (const day of days) {
18864 const { date, displayMonth } = day;
18865 const isOutside = Boolean(displayMonth && !isSameMonth2(date, displayMonth));
18866 const isBeforeNavStart = Boolean(computedNavStart && isBefore2(date, computedNavStart));
18867 const isAfterNavEnd = Boolean(computedNavEnd && isAfter2(date, computedNavEnd));
18868 const isDisabled = Boolean(disabled2 && dateMatchModifiers(date, disabled2, dateLib));
18869 const isHidden = Boolean(hidden && dateMatchModifiers(date, hidden, dateLib)) || isBeforeNavStart || isAfterNavEnd || // Broadcast calendar will show outside days as default
18870 !broadcastCalendar && !showOutsideDays && isOutside || broadcastCalendar && showOutsideDays === false && isOutside;
18871 const isToday = isSameDay2(date, today);
18872 if (isOutside)
18873 internalModifiersMap.outside.push(day);
18874 if (isDisabled)
18875 internalModifiersMap.disabled.push(day);
18876 if (isHidden)
18877 internalModifiersMap.hidden.push(day);
18878 if (isToday)
18879 internalModifiersMap.today.push(day);
18880 if (modifiers) {
18881 Object.keys(modifiers).forEach((name) => {
18882 const modifierValue = modifiers?.[name];
18883 const isMatch = modifierValue ? dateMatchModifiers(date, modifierValue, dateLib) : false;
18884 if (!isMatch)
18885 return;
18886 if (customModifiersMap[name]) {
18887 customModifiersMap[name].push(day);
18888 } else {
18889 customModifiersMap[name] = [day];
18890 }
18891 });
18892 }
18893 }
18894 return (day) => {
18895 const dayFlags = {
18896 [DayFlag.focused]: false,
18897 [DayFlag.disabled]: false,
18898 [DayFlag.hidden]: false,
18899 [DayFlag.outside]: false,
18900 [DayFlag.today]: false
18901 };
18902 const customModifiers = {};
18903 for (const name in internalModifiersMap) {
18904 const days2 = internalModifiersMap[name];
18905 dayFlags[name] = days2.some((d) => d === day);
18906 }
18907 for (const name in customModifiersMap) {
18908 customModifiers[name] = customModifiersMap[name].some((d) => d === day);
18909 }
18910 return {
18911 ...dayFlags,
18912 // custom modifiers should override all the previous ones
18913 ...customModifiers
18914 };
18915 };
18916 }
18917
18918 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/helpers/getClassNamesForModifiers.js
18919 function getClassNamesForModifiers(modifiers, classNames, modifiersClassNames = {}) {
18920 const modifierClassNames = Object.entries(modifiers).filter(([, active]) => active === true).reduce((previousValue, [key]) => {
18921 if (modifiersClassNames[key]) {
18922 previousValue.push(modifiersClassNames[key]);
18923 } else if (classNames[DayFlag[key]]) {
18924 previousValue.push(classNames[DayFlag[key]]);
18925 } else if (classNames[SelectionState[key]]) {
18926 previousValue.push(classNames[SelectionState[key]]);
18927 }
18928 return previousValue;
18929 }, [classNames[UI.Day]]);
18930 return modifierClassNames;
18931 }
18932
18933 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/helpers/getComponents.js
18934 function getComponents(customComponents) {
18935 return {
18936 ...custom_components_exports,
18937 ...customComponents
18938 };
18939 }
18940
18941 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/helpers/getDataAttributes.js
18942 function getDataAttributes(props) {
18943 const dataAttributes = {
18944 "data-mode": props.mode ?? void 0,
18945 "data-required": "required" in props ? props.required : void 0,
18946 "data-multiple-months": props.numberOfMonths && props.numberOfMonths > 1 || void 0,
18947 "data-week-numbers": props.showWeekNumber || void 0,
18948 "data-broadcast-calendar": props.broadcastCalendar || void 0,
18949 "data-nav-layout": props.navLayout || void 0
18950 };
18951 Object.entries(props).forEach(([key, val]) => {
18952 if (key.startsWith("data-")) {
18953 dataAttributes[key] = val;
18954 }
18955 });
18956 return dataAttributes;
18957 }
18958
18959 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/helpers/getDefaultClassNames.js
18960 function getDefaultClassNames() {
18961 const classNames = {};
18962 for (const key in UI) {
18963 classNames[UI[key]] = `rdp-${UI[key]}`;
18964 }
18965 for (const key in DayFlag) {
18966 classNames[DayFlag[key]] = `rdp-${DayFlag[key]}`;
18967 }
18968 for (const key in SelectionState) {
18969 classNames[SelectionState[key]] = `rdp-${SelectionState[key]}`;
18970 }
18971 for (const key in Animation) {
18972 classNames[Animation[key]] = `rdp-${Animation[key]}`;
18973 }
18974 return classNames;
18975 }
18976
18977 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/formatters/index.js
18978 var formatters_exports = {};
18979 __export(formatters_exports, {
18980 formatCaption: () => formatCaption,
18981 formatDay: () => formatDay,
18982 formatMonthDropdown: () => formatMonthDropdown,
18983 formatWeekNumber: () => formatWeekNumber,
18984 formatWeekNumberHeader: () => formatWeekNumberHeader,
18985 formatWeekdayName: () => formatWeekdayName,
18986 formatYearDropdown: () => formatYearDropdown
18987 });
18988
18989 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/formatters/formatCaption.js
18990 function formatCaption(month, options, dateLib) {
18991 const lib = dateLib ?? new DateLib(options);
18992 return lib.formatMonthYear(month);
18993 }
18994
18995 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/formatters/formatDay.js
18996 function formatDay(date, options, dateLib) {
18997 return (dateLib ?? new DateLib(options)).format(date, "d");
18998 }
18999
19000 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/formatters/formatMonthDropdown.js
19001 function formatMonthDropdown(month, dateLib = defaultDateLib) {
19002 return dateLib.format(month, "LLLL");
19003 }
19004
19005 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/formatters/formatWeekdayName.js
19006 function formatWeekdayName(weekday, options, dateLib) {
19007 return (dateLib ?? new DateLib(options)).format(weekday, "cccccc");
19008 }
19009
19010 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/formatters/formatWeekNumber.js
19011 function formatWeekNumber(weekNumber, dateLib = defaultDateLib) {
19012 if (weekNumber < 10) {
19013 return dateLib.formatNumber(`0${weekNumber.toLocaleString()}`);
19014 }
19015 return dateLib.formatNumber(`${weekNumber.toLocaleString()}`);
19016 }
19017
19018 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/formatters/formatWeekNumberHeader.js
19019 function formatWeekNumberHeader() {
19020 return ``;
19021 }
19022
19023 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/formatters/formatYearDropdown.js
19024 function formatYearDropdown(year, dateLib = defaultDateLib) {
19025 return dateLib.format(year, "yyyy");
19026 }
19027
19028 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/helpers/getFormatters.js
19029 function getFormatters(customFormatters) {
19030 return {
19031 ...formatters_exports,
19032 ...customFormatters
19033 };
19034 }
19035
19036 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/labels/index.js
19037 var labels_exports = {};
19038 __export(labels_exports, {
19039 labelDayButton: () => labelDayButton,
19040 labelGrid: () => labelGrid,
19041 labelGridcell: () => labelGridcell,
19042 labelMonthDropdown: () => labelMonthDropdown,
19043 labelNav: () => labelNav,
19044 labelNext: () => labelNext,
19045 labelPrevious: () => labelPrevious,
19046 labelWeekNumber: () => labelWeekNumber,
19047 labelWeekNumberHeader: () => labelWeekNumberHeader,
19048 labelWeekday: () => labelWeekday,
19049 labelYearDropdown: () => labelYearDropdown
19050 });
19051
19052 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/labels/labelDayButton.js
19053 function labelDayButton(date, modifiers, options, dateLib) {
19054 let label = (dateLib ?? new DateLib(options)).format(date, "PPPP");
19055 if (modifiers.today)
19056 label = `Today, ${label}`;
19057 if (modifiers.selected)
19058 label = `${label}, selected`;
19059 return label;
19060 }
19061
19062 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/labels/labelGrid.js
19063 function labelGrid(date, options, dateLib) {
19064 const lib = dateLib ?? new DateLib(options);
19065 return lib.formatMonthYear(date);
19066 }
19067
19068 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/labels/labelGridcell.js
19069 function labelGridcell(date, modifiers, options, dateLib) {
19070 let label = (dateLib ?? new DateLib(options)).format(date, "PPPP");
19071 if (modifiers?.today) {
19072 label = `Today, ${label}`;
19073 }
19074 return label;
19075 }
19076
19077 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/labels/labelMonthDropdown.js
19078 function labelMonthDropdown(_options) {
19079 return "Choose the Month";
19080 }
19081
19082 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/labels/labelNav.js
19083 function labelNav() {
19084 return "";
19085 }
19086
19087 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/labels/labelNext.js
19088 var defaultLabel = "Go to the Next Month";
19089 function labelNext(_month, _options) {
19090 return defaultLabel;
19091 }
19092
19093 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/labels/labelPrevious.js
19094 function labelPrevious(_month) {
19095 return "Go to the Previous Month";
19096 }
19097
19098 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/labels/labelWeekday.js
19099 function labelWeekday(date, options, dateLib) {
19100 return (dateLib ?? new DateLib(options)).format(date, "cccc");
19101 }
19102
19103 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/labels/labelWeekNumber.js
19104 function labelWeekNumber(weekNumber, _options) {
19105 return `Week ${weekNumber}`;
19106 }
19107
19108 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/labels/labelWeekNumberHeader.js
19109 function labelWeekNumberHeader(_options) {
19110 return "Week Number";
19111 }
19112
19113 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/labels/labelYearDropdown.js
19114 function labelYearDropdown(_options) {
19115 return "Choose the Year";
19116 }
19117
19118 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/helpers/getLabels.js
19119 var resolveLabel = (defaultLabel2, customLabel, localeLabel) => {
19120 if (customLabel)
19121 return customLabel;
19122 if (localeLabel) {
19123 return typeof localeLabel === "function" ? localeLabel : (..._args) => localeLabel;
19124 }
19125 return defaultLabel2;
19126 };
19127 function getLabels(customLabels, options) {
19128 const localeLabels = options.locale?.labels ?? {};
19129 return {
19130 ...labels_exports,
19131 ...customLabels ?? {},
19132 labelDayButton: resolveLabel(labelDayButton, customLabels?.labelDayButton, localeLabels.labelDayButton),
19133 labelMonthDropdown: resolveLabel(labelMonthDropdown, customLabels?.labelMonthDropdown, localeLabels.labelMonthDropdown),
19134 labelNext: resolveLabel(labelNext, customLabels?.labelNext, localeLabels.labelNext),
19135 labelPrevious: resolveLabel(labelPrevious, customLabels?.labelPrevious, localeLabels.labelPrevious),
19136 labelWeekNumber: resolveLabel(labelWeekNumber, customLabels?.labelWeekNumber, localeLabels.labelWeekNumber),
19137 labelYearDropdown: resolveLabel(labelYearDropdown, customLabels?.labelYearDropdown, localeLabels.labelYearDropdown),
19138 labelGrid: resolveLabel(labelGrid, customLabels?.labelGrid, localeLabels.labelGrid),
19139 labelGridcell: resolveLabel(labelGridcell, customLabels?.labelGridcell, localeLabels.labelGridcell),
19140 labelNav: resolveLabel(labelNav, customLabels?.labelNav, localeLabels.labelNav),
19141 labelWeekNumberHeader: resolveLabel(labelWeekNumberHeader, customLabels?.labelWeekNumberHeader, localeLabels.labelWeekNumberHeader),
19142 labelWeekday: resolveLabel(labelWeekday, customLabels?.labelWeekday, localeLabels.labelWeekday)
19143 };
19144 }
19145
19146 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/helpers/getMonthOptions.js
19147 function getMonthOptions(displayMonth, navStart, navEnd, formatters2, dateLib) {
19148 const { startOfMonth: startOfMonth2, startOfYear: startOfYear2, endOfYear: endOfYear2, eachMonthOfInterval: eachMonthOfInterval2, getMonth: getMonth2 } = dateLib;
19149 const months = eachMonthOfInterval2({
19150 start: startOfYear2(displayMonth),
19151 end: endOfYear2(displayMonth)
19152 });
19153 const options = months.map((month) => {
19154 const label = formatters2.formatMonthDropdown(month, dateLib);
19155 const value = getMonth2(month);
19156 const disabled2 = navStart && month < startOfMonth2(navStart) || navEnd && month > startOfMonth2(navEnd) || false;
19157 return { value, label, disabled: disabled2 };
19158 });
19159 return options;
19160 }
19161
19162 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/helpers/getStyleForModifiers.js
19163 function getStyleForModifiers(dayModifiers, styles = {}, modifiersStyles = {}) {
19164 let style = { ...styles?.[UI.Day] };
19165 Object.entries(dayModifiers).filter(([, active]) => active === true).forEach(([modifier]) => {
19166 style = {
19167 ...style,
19168 ...modifiersStyles?.[modifier]
19169 };
19170 });
19171 return style;
19172 }
19173
19174 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/helpers/getWeekdays.js
19175 function getWeekdays(dateLib, ISOWeek, broadcastCalendar, today) {
19176 const referenceToday = today ?? dateLib.today();
19177 const start = broadcastCalendar ? dateLib.startOfBroadcastWeek(referenceToday, dateLib) : ISOWeek ? dateLib.startOfISOWeek(referenceToday) : dateLib.startOfWeek(referenceToday);
19178 const days = [];
19179 for (let i = 0; i < 7; i++) {
19180 const day = dateLib.addDays(start, i);
19181 days.push(day);
19182 }
19183 return days;
19184 }
19185
19186 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/helpers/getYearOptions.js
19187 function getYearOptions(navStart, navEnd, formatters2, dateLib, reverse = false) {
19188 if (!navStart)
19189 return void 0;
19190 if (!navEnd)
19191 return void 0;
19192 const { startOfYear: startOfYear2, endOfYear: endOfYear2, eachYearOfInterval: eachYearOfInterval2, getYear: getYear2 } = dateLib;
19193 const firstNavYear = startOfYear2(navStart);
19194 const lastNavYear = endOfYear2(navEnd);
19195 const years = eachYearOfInterval2({ start: firstNavYear, end: lastNavYear });
19196 if (reverse)
19197 years.reverse();
19198 return years.map((year) => {
19199 const label = formatters2.formatYearDropdown(year, dateLib);
19200 return {
19201 value: getYear2(year),
19202 label,
19203 disabled: false
19204 };
19205 });
19206 }
19207
19208 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/noonDateLib.js
19209 function createNoonOverrides(timeZone, options = {}) {
19210 const { weekStartsOn, locale } = options;
19211 const fallbackWeekStartsOn = weekStartsOn ?? locale?.options?.weekStartsOn ?? 0;
19212 const toNoonTZDate = (date) => {
19213 const normalizedDate = typeof date === "number" || typeof date === "string" ? new Date(date) : date;
19214 return new TZDate(normalizedDate.getFullYear(), normalizedDate.getMonth(), normalizedDate.getDate(), 12, 0, 0, timeZone);
19215 };
19216 const toCalendarDate2 = (date) => {
19217 const zoned = toNoonTZDate(date);
19218 return new Date(zoned.getFullYear(), zoned.getMonth(), zoned.getDate(), 0, 0, 0, 0);
19219 };
19220 return {
19221 today: () => {
19222 return toNoonTZDate(TZDate.tz(timeZone));
19223 },
19224 newDate: (year, monthIndex, date) => {
19225 return new TZDate(year, monthIndex, date, 12, 0, 0, timeZone);
19226 },
19227 startOfDay: (date) => {
19228 return toNoonTZDate(date);
19229 },
19230 startOfWeek: (date, options2) => {
19231 const base = toNoonTZDate(date);
19232 const weekStartsOnValue = options2?.weekStartsOn ?? fallbackWeekStartsOn;
19233 const diff = (base.getDay() - weekStartsOnValue + 7) % 7;
19234 base.setDate(base.getDate() - diff);
19235 return base;
19236 },
19237 startOfISOWeek: (date) => {
19238 const base = toNoonTZDate(date);
19239 const diff = (base.getDay() - 1 + 7) % 7;
19240 base.setDate(base.getDate() - diff);
19241 return base;
19242 },
19243 startOfMonth: (date) => {
19244 const base = toNoonTZDate(date);
19245 base.setDate(1);
19246 return base;
19247 },
19248 startOfYear: (date) => {
19249 const base = toNoonTZDate(date);
19250 base.setMonth(0, 1);
19251 return base;
19252 },
19253 endOfWeek: (date, options2) => {
19254 const base = toNoonTZDate(date);
19255 const weekStartsOnValue = options2?.weekStartsOn ?? fallbackWeekStartsOn;
19256 const endDow = (weekStartsOnValue + 6) % 7;
19257 const diff = (endDow - base.getDay() + 7) % 7;
19258 base.setDate(base.getDate() + diff);
19259 return base;
19260 },
19261 endOfISOWeek: (date) => {
19262 const base = toNoonTZDate(date);
19263 const diff = (7 - base.getDay()) % 7;
19264 base.setDate(base.getDate() + diff);
19265 return base;
19266 },
19267 endOfMonth: (date) => {
19268 const base = toNoonTZDate(date);
19269 base.setMonth(base.getMonth() + 1, 0);
19270 return base;
19271 },
19272 endOfYear: (date) => {
19273 const base = toNoonTZDate(date);
19274 base.setMonth(11, 31);
19275 return base;
19276 },
19277 eachMonthOfInterval: (interval) => {
19278 const start = toNoonTZDate(interval.start);
19279 const end = toNoonTZDate(interval.end);
19280 const result = [];
19281 const cursor = new TZDate(start.getFullYear(), start.getMonth(), 1, 12, 0, 0, timeZone);
19282 const endKey = end.getFullYear() * 12 + end.getMonth();
19283 while (cursor.getFullYear() * 12 + cursor.getMonth() <= endKey) {
19284 result.push(new TZDate(cursor, timeZone));
19285 cursor.setMonth(cursor.getMonth() + 1, 1);
19286 }
19287 return result;
19288 },
19289 // Normalize to noon once before arithmetic (avoid DST/midnight edge cases),
19290 // mutate the same TZDate, and return it.
19291 addDays: (date, amount) => {
19292 const base = toNoonTZDate(date);
19293 base.setDate(base.getDate() + amount);
19294 return base;
19295 },
19296 addWeeks: (date, amount) => {
19297 const base = toNoonTZDate(date);
19298 base.setDate(base.getDate() + amount * 7);
19299 return base;
19300 },
19301 addMonths: (date, amount) => {
19302 const base = toNoonTZDate(date);
19303 base.setMonth(base.getMonth() + amount);
19304 return base;
19305 },
19306 addYears: (date, amount) => {
19307 const base = toNoonTZDate(date);
19308 base.setFullYear(base.getFullYear() + amount);
19309 return base;
19310 },
19311 eachYearOfInterval: (interval) => {
19312 const start = toNoonTZDate(interval.start);
19313 const end = toNoonTZDate(interval.end);
19314 const years = [];
19315 const cursor = new TZDate(start.getFullYear(), 0, 1, 12, 0, 0, timeZone);
19316 while (cursor.getFullYear() <= end.getFullYear()) {
19317 years.push(new TZDate(cursor, timeZone));
19318 cursor.setFullYear(cursor.getFullYear() + 1, 0, 1);
19319 }
19320 return years;
19321 },
19322 getWeek: (date, options2) => {
19323 const base = toCalendarDate2(date);
19324 return getWeek(base, {
19325 weekStartsOn: options2?.weekStartsOn ?? fallbackWeekStartsOn,
19326 firstWeekContainsDate: options2?.firstWeekContainsDate ?? locale?.options?.firstWeekContainsDate ?? 1
19327 });
19328 },
19329 getISOWeek: (date) => {
19330 const base = toCalendarDate2(date);
19331 return getISOWeek(base);
19332 },
19333 differenceInCalendarDays: (dateLeft, dateRight) => {
19334 const left = toCalendarDate2(dateLeft);
19335 const right = toCalendarDate2(dateRight);
19336 return differenceInCalendarDays(left, right);
19337 },
19338 differenceInCalendarMonths: (dateLeft, dateRight) => {
19339 const left = toCalendarDate2(dateLeft);
19340 const right = toCalendarDate2(dateRight);
19341 return differenceInCalendarMonths(left, right);
19342 }
19343 };
19344 }
19345
19346 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/useAnimation.js
19347 var import_react32 = __toESM(require_react(), 1);
19348 var asHtmlElement = (element) => {
19349 if (element instanceof HTMLElement)
19350 return element;
19351 return null;
19352 };
19353 var queryMonthEls = (element) => [
19354 ...element.querySelectorAll("[data-animated-month]") ?? []
19355 ];
19356 var queryMonthEl = (element) => asHtmlElement(element.querySelector("[data-animated-month]"));
19357 var queryCaptionEl = (element) => asHtmlElement(element.querySelector("[data-animated-caption]"));
19358 var queryWeeksEl = (element) => asHtmlElement(element.querySelector("[data-animated-weeks]"));
19359 var queryNavEl = (element) => asHtmlElement(element.querySelector("[data-animated-nav]"));
19360 var queryWeekdaysEl = (element) => asHtmlElement(element.querySelector("[data-animated-weekdays]"));
19361 function useAnimation(rootElRef, enabled, { classNames, months, focused, dateLib }) {
19362 const previousRootElSnapshotRef = (0, import_react32.useRef)(null);
19363 const previousMonthsRef = (0, import_react32.useRef)(months);
19364 const animatingRef = (0, import_react32.useRef)(false);
19365 (0, import_react32.useLayoutEffect)(() => {
19366 const previousMonths = previousMonthsRef.current;
19367 previousMonthsRef.current = months;
19368 if (!enabled || !rootElRef.current || // safety check because the ref can be set to anything by consumers
19369 !(rootElRef.current instanceof HTMLElement) || // validation required for the animation to work as expected
19370 months.length === 0 || previousMonths.length === 0 || months.length !== previousMonths.length) {
19371 return;
19372 }
19373 const isSameMonth2 = dateLib.isSameMonth(months[0].date, previousMonths[0].date);
19374 const isAfterPreviousMonth = dateLib.isAfter(months[0].date, previousMonths[0].date);
19375 const captionAnimationClass = isAfterPreviousMonth ? classNames[Animation.caption_after_enter] : classNames[Animation.caption_before_enter];
19376 const weeksAnimationClass = isAfterPreviousMonth ? classNames[Animation.weeks_after_enter] : classNames[Animation.weeks_before_enter];
19377 const previousRootElSnapshot = previousRootElSnapshotRef.current;
19378 const rootElSnapshot = rootElRef.current.cloneNode(true);
19379 if (rootElSnapshot instanceof HTMLElement) {
19380 const currentMonthElsSnapshot = queryMonthEls(rootElSnapshot);
19381 currentMonthElsSnapshot.forEach((currentMonthElSnapshot) => {
19382 if (!(currentMonthElSnapshot instanceof HTMLElement))
19383 return;
19384 const previousMonthElSnapshot = queryMonthEl(currentMonthElSnapshot);
19385 if (previousMonthElSnapshot && currentMonthElSnapshot.contains(previousMonthElSnapshot)) {
19386 currentMonthElSnapshot.removeChild(previousMonthElSnapshot);
19387 }
19388 const captionEl = queryCaptionEl(currentMonthElSnapshot);
19389 if (captionEl) {
19390 captionEl.classList.remove(captionAnimationClass);
19391 }
19392 const weeksEl = queryWeeksEl(currentMonthElSnapshot);
19393 if (weeksEl) {
19394 weeksEl.classList.remove(weeksAnimationClass);
19395 }
19396 });
19397 previousRootElSnapshotRef.current = rootElSnapshot;
19398 } else {
19399 previousRootElSnapshotRef.current = null;
19400 }
19401 if (animatingRef.current || isSameMonth2 || // skip animation if a day is focused because it can cause issues to the animation and is better for a11y
19402 focused) {
19403 return;
19404 }
19405 const previousMonthEls = previousRootElSnapshot instanceof HTMLElement ? queryMonthEls(previousRootElSnapshot) : [];
19406 const currentMonthEls = queryMonthEls(rootElRef.current);
19407 if (currentMonthEls?.every((el) => el instanceof HTMLElement) && previousMonthEls?.every((el) => el instanceof HTMLElement)) {
19408 animatingRef.current = true;
19409 const cleanUpFunctions = [];
19410 rootElRef.current.style.isolation = "isolate";
19411 const navEl = queryNavEl(rootElRef.current);
19412 if (navEl) {
19413 navEl.style.zIndex = "1";
19414 }
19415 currentMonthEls.forEach((currentMonthEl, index3) => {
19416 const previousMonthEl = previousMonthEls[index3];
19417 if (!previousMonthEl) {
19418 return;
19419 }
19420 currentMonthEl.style.position = "relative";
19421 currentMonthEl.style.overflow = "hidden";
19422 const captionEl = queryCaptionEl(currentMonthEl);
19423 if (captionEl) {
19424 captionEl.classList.add(captionAnimationClass);
19425 }
19426 const weeksEl = queryWeeksEl(currentMonthEl);
19427 if (weeksEl) {
19428 weeksEl.classList.add(weeksAnimationClass);
19429 }
19430 const cleanUp = () => {
19431 animatingRef.current = false;
19432 if (rootElRef.current) {
19433 rootElRef.current.style.isolation = "";
19434 }
19435 if (navEl) {
19436 navEl.style.zIndex = "";
19437 }
19438 if (captionEl) {
19439 captionEl.classList.remove(captionAnimationClass);
19440 }
19441 if (weeksEl) {
19442 weeksEl.classList.remove(weeksAnimationClass);
19443 }
19444 currentMonthEl.style.position = "";
19445 currentMonthEl.style.overflow = "";
19446 if (currentMonthEl.contains(previousMonthEl)) {
19447 currentMonthEl.removeChild(previousMonthEl);
19448 }
19449 };
19450 cleanUpFunctions.push(cleanUp);
19451 previousMonthEl.style.pointerEvents = "none";
19452 previousMonthEl.style.position = "absolute";
19453 previousMonthEl.style.overflow = "hidden";
19454 previousMonthEl.setAttribute("aria-hidden", "true");
19455 const previousWeekdaysEl = queryWeekdaysEl(previousMonthEl);
19456 if (previousWeekdaysEl) {
19457 previousWeekdaysEl.style.opacity = "0";
19458 }
19459 const previousCaptionEl = queryCaptionEl(previousMonthEl);
19460 if (previousCaptionEl) {
19461 previousCaptionEl.classList.add(isAfterPreviousMonth ? classNames[Animation.caption_before_exit] : classNames[Animation.caption_after_exit]);
19462 previousCaptionEl.addEventListener("animationend", cleanUp);
19463 }
19464 const previousWeeksEl = queryWeeksEl(previousMonthEl);
19465 if (previousWeeksEl) {
19466 previousWeeksEl.classList.add(isAfterPreviousMonth ? classNames[Animation.weeks_before_exit] : classNames[Animation.weeks_after_exit]);
19467 }
19468 currentMonthEl.insertBefore(previousMonthEl, currentMonthEl.firstChild);
19469 });
19470 }
19471 });
19472 }
19473
19474 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/useCalendar.js
19475 var import_react34 = __toESM(require_react(), 1);
19476
19477 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/helpers/getDates.js
19478 function getDates(displayMonths, maxDate, props, dateLib) {
19479 const firstMonth = displayMonths[0];
19480 const lastMonth = displayMonths[displayMonths.length - 1];
19481 const { ISOWeek, fixedWeeks, broadcastCalendar } = props ?? {};
19482 const { addDays: addDays2, differenceInCalendarDays: differenceInCalendarDays2, differenceInCalendarMonths: differenceInCalendarMonths2, endOfBroadcastWeek: endOfBroadcastWeek2, endOfISOWeek: endOfISOWeek2, endOfMonth: endOfMonth2, endOfWeek: endOfWeek2, isAfter: isAfter2, startOfBroadcastWeek: startOfBroadcastWeek2, startOfISOWeek: startOfISOWeek2, startOfWeek: startOfWeek2 } = dateLib;
19483 const startWeekFirstDate = broadcastCalendar ? startOfBroadcastWeek2(firstMonth, dateLib) : ISOWeek ? startOfISOWeek2(firstMonth) : startOfWeek2(firstMonth);
19484 const displayMonthsWeekEnd = broadcastCalendar ? endOfBroadcastWeek2(lastMonth) : ISOWeek ? endOfISOWeek2(endOfMonth2(lastMonth)) : endOfWeek2(endOfMonth2(lastMonth));
19485 const constraintWeekEnd = maxDate && (broadcastCalendar ? endOfBroadcastWeek2(maxDate) : ISOWeek ? endOfISOWeek2(maxDate) : endOfWeek2(maxDate));
19486 const gridEndDate = constraintWeekEnd && isAfter2(displayMonthsWeekEnd, constraintWeekEnd) ? constraintWeekEnd : displayMonthsWeekEnd;
19487 const nOfDays = differenceInCalendarDays2(gridEndDate, startWeekFirstDate);
19488 const nOfMonths = differenceInCalendarMonths2(lastMonth, firstMonth) + 1;
19489 const dates = [];
19490 for (let i = 0; i <= nOfDays; i++) {
19491 const date = addDays2(startWeekFirstDate, i);
19492 dates.push(date);
19493 }
19494 const nrOfDaysWithFixedWeeks = broadcastCalendar ? 35 : 42;
19495 const extraDates = nrOfDaysWithFixedWeeks * nOfMonths;
19496 if (fixedWeeks && dates.length < extraDates) {
19497 const daysToAdd = extraDates - dates.length;
19498 for (let i = 0; i < daysToAdd; i++) {
19499 const date = addDays2(dates[dates.length - 1], 1);
19500 dates.push(date);
19501 }
19502 }
19503 return dates;
19504 }
19505
19506 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/helpers/getDays.js
19507 function getDays(calendarMonths) {
19508 const initialDays = [];
19509 return calendarMonths.reduce((days, month) => {
19510 const weekDays = month.weeks.reduce((weekDays2, week) => {
19511 return weekDays2.concat(week.days.slice());
19512 }, initialDays.slice());
19513 return days.concat(weekDays.slice());
19514 }, initialDays.slice());
19515 }
19516
19517 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/helpers/getDisplayMonths.js
19518 function getDisplayMonths(firstDisplayedMonth, calendarEndMonth, props, dateLib) {
19519 const { numberOfMonths = 1 } = props;
19520 const months = [];
19521 for (let i = 0; i < numberOfMonths; i++) {
19522 const month = dateLib.addMonths(firstDisplayedMonth, i);
19523 if (calendarEndMonth && month > calendarEndMonth) {
19524 break;
19525 }
19526 months.push(month);
19527 }
19528 return months;
19529 }
19530
19531 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/helpers/getInitialMonth.js
19532 function getInitialMonth(props, navStart, navEnd, dateLib) {
19533 const { month, defaultMonth, today = dateLib.today(), numberOfMonths = 1 } = props;
19534 let initialMonth = month || defaultMonth || today;
19535 const { differenceInCalendarMonths: differenceInCalendarMonths2, addMonths: addMonths2, startOfMonth: startOfMonth2 } = dateLib;
19536 if (navEnd && differenceInCalendarMonths2(navEnd, initialMonth) < numberOfMonths - 1) {
19537 const offset4 = -1 * (numberOfMonths - 1);
19538 initialMonth = addMonths2(navEnd, offset4);
19539 }
19540 if (navStart && differenceInCalendarMonths2(initialMonth, navStart) < 0) {
19541 initialMonth = navStart;
19542 }
19543 return startOfMonth2(initialMonth);
19544 }
19545
19546 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/helpers/getMonths.js
19547 function getMonths(displayMonths, dates, props, dateLib) {
19548 const { addDays: addDays2, endOfBroadcastWeek: endOfBroadcastWeek2, endOfISOWeek: endOfISOWeek2, endOfMonth: endOfMonth2, endOfWeek: endOfWeek2, getISOWeek: getISOWeek2, getWeek: getWeek2, startOfBroadcastWeek: startOfBroadcastWeek2, startOfISOWeek: startOfISOWeek2, startOfWeek: startOfWeek2 } = dateLib;
19549 const dayPickerMonths = displayMonths.reduce((months, month) => {
19550 const firstDateOfFirstWeek = props.broadcastCalendar ? startOfBroadcastWeek2(month, dateLib) : props.ISOWeek ? startOfISOWeek2(month) : startOfWeek2(month);
19551 const lastDateOfLastWeek = props.broadcastCalendar ? endOfBroadcastWeek2(month) : props.ISOWeek ? endOfISOWeek2(endOfMonth2(month)) : endOfWeek2(endOfMonth2(month));
19552 const monthDates = dates.filter((date) => {
19553 return date >= firstDateOfFirstWeek && date <= lastDateOfLastWeek;
19554 });
19555 const nrOfDaysWithFixedWeeks = props.broadcastCalendar ? 35 : 42;
19556 if (props.fixedWeeks && monthDates.length < nrOfDaysWithFixedWeeks) {
19557 const extraDates = dates.filter((date) => {
19558 const daysToAdd = nrOfDaysWithFixedWeeks - monthDates.length;
19559 return date > lastDateOfLastWeek && date <= addDays2(lastDateOfLastWeek, daysToAdd);
19560 });
19561 monthDates.push(...extraDates);
19562 }
19563 const weeks = monthDates.reduce((weeks2, date) => {
19564 const weekNumber = props.ISOWeek ? getISOWeek2(date) : getWeek2(date);
19565 const week = weeks2.find((week2) => week2.weekNumber === weekNumber);
19566 const day = new CalendarDay(date, month, dateLib);
19567 if (!week) {
19568 weeks2.push(new CalendarWeek(weekNumber, [day]));
19569 } else {
19570 week.days.push(day);
19571 }
19572 return weeks2;
19573 }, []);
19574 const dayPickerMonth = new CalendarMonth(month, weeks);
19575 months.push(dayPickerMonth);
19576 return months;
19577 }, []);
19578 if (!props.reverseMonths) {
19579 return dayPickerMonths;
19580 } else {
19581 return dayPickerMonths.reverse();
19582 }
19583 }
19584
19585 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/helpers/getNavMonth.js
19586 function getNavMonths(props, dateLib) {
19587 let { startMonth, endMonth } = props;
19588 const { startOfYear: startOfYear2, startOfDay: startOfDay2, startOfMonth: startOfMonth2, endOfMonth: endOfMonth2, addYears: addYears2, endOfYear: endOfYear2, today } = dateLib;
19589 const hasYearDropdown = props.captionLayout === "dropdown" || props.captionLayout === "dropdown-years";
19590 if (startMonth) {
19591 startMonth = startOfMonth2(startMonth);
19592 } else if (!startMonth && hasYearDropdown) {
19593 startMonth = startOfYear2(addYears2(props.today ?? today(), -100));
19594 }
19595 if (endMonth) {
19596 endMonth = endOfMonth2(endMonth);
19597 } else if (!endMonth && hasYearDropdown) {
19598 endMonth = endOfYear2(props.today ?? today());
19599 }
19600 return [
19601 startMonth ? startOfDay2(startMonth) : startMonth,
19602 endMonth ? startOfDay2(endMonth) : endMonth
19603 ];
19604 }
19605
19606 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/helpers/getNextMonth.js
19607 function getNextMonth(firstDisplayedMonth, calendarEndMonth, options, dateLib) {
19608 if (options.disableNavigation) {
19609 return void 0;
19610 }
19611 const { pagedNavigation, numberOfMonths = 1 } = options;
19612 const { startOfMonth: startOfMonth2, addMonths: addMonths2, differenceInCalendarMonths: differenceInCalendarMonths2 } = dateLib;
19613 const offset4 = pagedNavigation ? numberOfMonths : 1;
19614 const month = startOfMonth2(firstDisplayedMonth);
19615 if (!calendarEndMonth) {
19616 return addMonths2(month, offset4);
19617 }
19618 const monthsDiff = differenceInCalendarMonths2(calendarEndMonth, firstDisplayedMonth);
19619 if (monthsDiff < numberOfMonths) {
19620 return void 0;
19621 }
19622 return addMonths2(month, offset4);
19623 }
19624
19625 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/helpers/getPreviousMonth.js
19626 function getPreviousMonth(firstDisplayedMonth, calendarStartMonth, options, dateLib) {
19627 if (options.disableNavigation) {
19628 return void 0;
19629 }
19630 const { pagedNavigation, numberOfMonths } = options;
19631 const { startOfMonth: startOfMonth2, addMonths: addMonths2, differenceInCalendarMonths: differenceInCalendarMonths2 } = dateLib;
19632 const offset4 = pagedNavigation ? numberOfMonths ?? 1 : 1;
19633 const month = startOfMonth2(firstDisplayedMonth);
19634 if (!calendarStartMonth) {
19635 return addMonths2(month, -offset4);
19636 }
19637 const monthsDiff = differenceInCalendarMonths2(month, calendarStartMonth);
19638 if (monthsDiff <= 0) {
19639 return void 0;
19640 }
19641 return addMonths2(month, -offset4);
19642 }
19643
19644 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/helpers/getWeeks.js
19645 function getWeeks(months) {
19646 const initialWeeks = [];
19647 return months.reduce((weeks, month) => {
19648 return weeks.concat(month.weeks.slice());
19649 }, initialWeeks.slice());
19650 }
19651
19652 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/helpers/useControlledValue.js
19653 var import_react33 = __toESM(require_react(), 1);
19654 function useControlledValue(defaultValue, controlledValue) {
19655 const [uncontrolledValue, setValue] = (0, import_react33.useState)(defaultValue);
19656 const value = controlledValue === void 0 ? uncontrolledValue : controlledValue;
19657 return [value, setValue];
19658 }
19659
19660 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/useCalendar.js
19661 function useCalendar(props, dateLib) {
19662 const [navStart, navEnd] = getNavMonths(props, dateLib);
19663 const { startOfMonth: startOfMonth2, endOfMonth: endOfMonth2 } = dateLib;
19664 const initialMonth = getInitialMonth(props, navStart, navEnd, dateLib);
19665 const [firstMonth, setFirstMonth] = useControlledValue(
19666 initialMonth,
19667 // initialMonth is always computed from props.month if provided
19668 props.month ? initialMonth : void 0
19669 );
19670 (0, import_react34.useEffect)(() => {
19671 const newInitialMonth = getInitialMonth(props, navStart, navEnd, dateLib);
19672 setFirstMonth(newInitialMonth);
19673 }, [props.timeZone]);
19674 const { months, weeks, days, previousMonth, nextMonth } = (0, import_react34.useMemo)(() => {
19675 const displayMonths = getDisplayMonths(firstMonth, navEnd, { numberOfMonths: props.numberOfMonths }, dateLib);
19676 const dates = getDates(displayMonths, props.endMonth ? endOfMonth2(props.endMonth) : void 0, {
19677 ISOWeek: props.ISOWeek,
19678 fixedWeeks: props.fixedWeeks,
19679 broadcastCalendar: props.broadcastCalendar
19680 }, dateLib);
19681 const months2 = getMonths(displayMonths, dates, {
19682 broadcastCalendar: props.broadcastCalendar,
19683 fixedWeeks: props.fixedWeeks,
19684 ISOWeek: props.ISOWeek,
19685 reverseMonths: props.reverseMonths
19686 }, dateLib);
19687 const weeks2 = getWeeks(months2);
19688 const days2 = getDays(months2);
19689 const previousMonth2 = getPreviousMonth(firstMonth, navStart, props, dateLib);
19690 const nextMonth2 = getNextMonth(firstMonth, navEnd, props, dateLib);
19691 return {
19692 months: months2,
19693 weeks: weeks2,
19694 days: days2,
19695 previousMonth: previousMonth2,
19696 nextMonth: nextMonth2
19697 };
19698 }, [
19699 dateLib,
19700 firstMonth.getTime(),
19701 navEnd?.getTime(),
19702 navStart?.getTime(),
19703 props.disableNavigation,
19704 props.broadcastCalendar,
19705 props.endMonth?.getTime(),
19706 props.fixedWeeks,
19707 props.ISOWeek,
19708 props.numberOfMonths,
19709 props.pagedNavigation,
19710 props.reverseMonths
19711 ]);
19712 const { disableNavigation, onMonthChange } = props;
19713 const isDayInCalendar = (day) => weeks.some((week) => week.days.some((d) => d.isEqualTo(day)));
19714 const goToMonth = (date) => {
19715 if (disableNavigation) {
19716 return;
19717 }
19718 let newMonth = startOfMonth2(date);
19719 if (navStart && newMonth < startOfMonth2(navStart)) {
19720 newMonth = startOfMonth2(navStart);
19721 }
19722 if (navEnd && newMonth > startOfMonth2(navEnd)) {
19723 newMonth = startOfMonth2(navEnd);
19724 }
19725 setFirstMonth(newMonth);
19726 onMonthChange?.(newMonth);
19727 };
19728 const goToDay = (day) => {
19729 if (isDayInCalendar(day)) {
19730 return;
19731 }
19732 goToMonth(day.date);
19733 };
19734 const calendar = {
19735 months,
19736 weeks,
19737 days,
19738 navStart,
19739 navEnd,
19740 previousMonth,
19741 nextMonth,
19742 goToMonth,
19743 goToDay
19744 };
19745 return calendar;
19746 }
19747
19748 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/useFocus.js
19749 var import_react35 = __toESM(require_react(), 1);
19750
19751 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/helpers/calculateFocusTarget.js
19752 var FocusTargetPriority;
19753 (function(FocusTargetPriority2) {
19754 FocusTargetPriority2[FocusTargetPriority2["Today"] = 0] = "Today";
19755 FocusTargetPriority2[FocusTargetPriority2["Selected"] = 1] = "Selected";
19756 FocusTargetPriority2[FocusTargetPriority2["LastFocused"] = 2] = "LastFocused";
19757 FocusTargetPriority2[FocusTargetPriority2["FocusedModifier"] = 3] = "FocusedModifier";
19758 })(FocusTargetPriority || (FocusTargetPriority = {}));
19759 function isFocusableDay(modifiers) {
19760 return !modifiers[DayFlag.disabled] && !modifiers[DayFlag.hidden] && !modifiers[DayFlag.outside];
19761 }
19762 function calculateFocusTarget(days, getModifiers, isSelected, lastFocused) {
19763 let focusTarget;
19764 let foundFocusTargetPriority = -1;
19765 for (const day of days) {
19766 const modifiers = getModifiers(day);
19767 if (isFocusableDay(modifiers)) {
19768 if (modifiers[DayFlag.focused] && foundFocusTargetPriority < FocusTargetPriority.FocusedModifier) {
19769 focusTarget = day;
19770 foundFocusTargetPriority = FocusTargetPriority.FocusedModifier;
19771 } else if (lastFocused?.isEqualTo(day) && foundFocusTargetPriority < FocusTargetPriority.LastFocused) {
19772 focusTarget = day;
19773 foundFocusTargetPriority = FocusTargetPriority.LastFocused;
19774 } else if (isSelected(day.date) && foundFocusTargetPriority < FocusTargetPriority.Selected) {
19775 focusTarget = day;
19776 foundFocusTargetPriority = FocusTargetPriority.Selected;
19777 } else if (modifiers[DayFlag.today] && foundFocusTargetPriority < FocusTargetPriority.Today) {
19778 focusTarget = day;
19779 foundFocusTargetPriority = FocusTargetPriority.Today;
19780 }
19781 }
19782 }
19783 if (!focusTarget) {
19784 focusTarget = days.find((day) => isFocusableDay(getModifiers(day)));
19785 }
19786 return focusTarget;
19787 }
19788
19789 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/helpers/getFocusableDate.js
19790 function getFocusableDate(moveBy, moveDir, refDate, navStart, navEnd, props, dateLib) {
19791 const { ISOWeek, broadcastCalendar } = props;
19792 const { addDays: addDays2, addMonths: addMonths2, addWeeks: addWeeks2, addYears: addYears2, endOfBroadcastWeek: endOfBroadcastWeek2, endOfISOWeek: endOfISOWeek2, endOfWeek: endOfWeek2, max: max4, min: min4, startOfBroadcastWeek: startOfBroadcastWeek2, startOfISOWeek: startOfISOWeek2, startOfWeek: startOfWeek2 } = dateLib;
19793 const moveFns = {
19794 day: addDays2,
19795 week: addWeeks2,
19796 month: addMonths2,
19797 year: addYears2,
19798 startOfWeek: (date) => broadcastCalendar ? startOfBroadcastWeek2(date, dateLib) : ISOWeek ? startOfISOWeek2(date) : startOfWeek2(date),
19799 endOfWeek: (date) => broadcastCalendar ? endOfBroadcastWeek2(date) : ISOWeek ? endOfISOWeek2(date) : endOfWeek2(date)
19800 };
19801 let focusableDate = moveFns[moveBy](refDate, moveDir === "after" ? 1 : -1);
19802 if (moveDir === "before" && navStart) {
19803 focusableDate = max4([navStart, focusableDate]);
19804 } else if (moveDir === "after" && navEnd) {
19805 focusableDate = min4([navEnd, focusableDate]);
19806 }
19807 return focusableDate;
19808 }
19809
19810 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/helpers/getNextFocus.js
19811 function getNextFocus(moveBy, moveDir, refDay, calendarStartMonth, calendarEndMonth, props, dateLib, attempt = 0) {
19812 if (attempt > 365) {
19813 return void 0;
19814 }
19815 const focusableDate = getFocusableDate(moveBy, moveDir, refDay.date, calendarStartMonth, calendarEndMonth, props, dateLib);
19816 const isDisabled = Boolean(props.disabled && dateMatchModifiers(focusableDate, props.disabled, dateLib));
19817 const isHidden = Boolean(props.hidden && dateMatchModifiers(focusableDate, props.hidden, dateLib));
19818 const targetMonth = focusableDate;
19819 const focusDay = new CalendarDay(focusableDate, targetMonth, dateLib);
19820 if (!isDisabled && !isHidden) {
19821 return focusDay;
19822 }
19823 return getNextFocus(moveBy, moveDir, focusDay, calendarStartMonth, calendarEndMonth, props, dateLib, attempt + 1);
19824 }
19825
19826 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/useFocus.js
19827 function useFocus2(props, calendar, getModifiers, isSelected, dateLib) {
19828 const { autoFocus } = props;
19829 const [lastFocused, setLastFocused] = (0, import_react35.useState)();
19830 const focusTarget = calculateFocusTarget(calendar.days, getModifiers, isSelected || (() => false), lastFocused);
19831 const [focusedDay, setFocused] = (0, import_react35.useState)(autoFocus ? focusTarget : void 0);
19832 const blur = () => {
19833 setLastFocused(focusedDay);
19834 setFocused(void 0);
19835 };
19836 const moveFocus = (moveBy, moveDir) => {
19837 if (!focusedDay)
19838 return;
19839 const nextFocus = getNextFocus(moveBy, moveDir, focusedDay, calendar.navStart, calendar.navEnd, props, dateLib);
19840 if (!nextFocus)
19841 return;
19842 if (props.disableNavigation) {
19843 const isNextInCalendar = calendar.days.some((day) => day.isEqualTo(nextFocus));
19844 if (!isNextInCalendar) {
19845 return;
19846 }
19847 }
19848 calendar.goToDay(nextFocus);
19849 setFocused(nextFocus);
19850 };
19851 const isFocusTarget = (day) => {
19852 return Boolean(focusTarget?.isEqualTo(day));
19853 };
19854 const useFocus3 = {
19855 isFocusTarget,
19856 setFocused,
19857 focused: focusedDay,
19858 blur,
19859 moveFocus
19860 };
19861 return useFocus3;
19862 }
19863
19864 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/selection/useMulti.js
19865 function useMulti(props, dateLib) {
19866 const { selected: initiallySelected, required, onSelect } = props;
19867 const [internallySelected, setSelected] = useControlledValue(initiallySelected, onSelect ? initiallySelected : void 0);
19868 const selected = !onSelect ? internallySelected : initiallySelected;
19869 const { isSameDay: isSameDay2 } = dateLib;
19870 const isSelected = (date) => {
19871 return selected?.some((d) => isSameDay2(d, date)) ?? false;
19872 };
19873 const { min: min4, max: max4 } = props;
19874 const select = (triggerDate, modifiers, e) => {
19875 let newDates = [...selected ?? []];
19876 if (isSelected(triggerDate)) {
19877 if (selected?.length === min4) {
19878 return;
19879 }
19880 if (required && selected?.length === 1) {
19881 return;
19882 }
19883 newDates = selected?.filter((d) => !isSameDay2(d, triggerDate));
19884 } else {
19885 if (selected?.length === max4) {
19886 newDates = [triggerDate];
19887 } else {
19888 newDates = [...newDates, triggerDate];
19889 }
19890 }
19891 if (!onSelect) {
19892 setSelected(newDates);
19893 }
19894 onSelect?.(newDates, triggerDate, modifiers, e);
19895 return newDates;
19896 };
19897 return {
19898 selected,
19899 select,
19900 isSelected
19901 };
19902 }
19903
19904 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/utils/addToRange.js
19905 function addToRange(date, initialRange, min4 = 0, max4 = 0, required = false, dateLib = defaultDateLib) {
19906 const { from, to } = initialRange || {};
19907 const { isSameDay: isSameDay2, isAfter: isAfter2, isBefore: isBefore2 } = dateLib;
19908 let range;
19909 if (!from && !to) {
19910 range = { from: date, to: min4 > 0 ? void 0 : date };
19911 } else if (from && !to) {
19912 if (isSameDay2(from, date)) {
19913 if (min4 === 0) {
19914 range = { from, to: date };
19915 } else if (required) {
19916 range = { from, to: void 0 };
19917 } else {
19918 range = void 0;
19919 }
19920 } else if (isBefore2(date, from)) {
19921 range = { from: date, to: from };
19922 } else {
19923 range = { from, to: date };
19924 }
19925 } else if (from && to) {
19926 if (isSameDay2(from, date) && isSameDay2(to, date)) {
19927 if (required) {
19928 range = { from, to };
19929 } else {
19930 range = void 0;
19931 }
19932 } else if (isSameDay2(from, date)) {
19933 range = { from, to: min4 > 0 ? void 0 : date };
19934 } else if (isSameDay2(to, date)) {
19935 range = { from: date, to: min4 > 0 ? void 0 : date };
19936 } else if (isBefore2(date, from)) {
19937 range = { from: date, to };
19938 } else if (isAfter2(date, from)) {
19939 range = { from, to: date };
19940 } else if (isAfter2(date, to)) {
19941 range = { from, to: date };
19942 } else {
19943 throw new Error("Invalid range");
19944 }
19945 }
19946 if (range?.from && range?.to) {
19947 const diff = dateLib.differenceInCalendarDays(range.to, range.from);
19948 if (max4 > 0 && diff > max4) {
19949 range = { from: date, to: void 0 };
19950 } else if (min4 > 1 && diff < min4) {
19951 range = { from: date, to: void 0 };
19952 }
19953 }
19954 return range;
19955 }
19956
19957 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/utils/rangeContainsDayOfWeek.js
19958 function rangeContainsDayOfWeek(range, dayOfWeek, dateLib = defaultDateLib) {
19959 const dayOfWeekArr = !Array.isArray(dayOfWeek) ? [dayOfWeek] : dayOfWeek;
19960 let date = range.from;
19961 const totalDays = dateLib.differenceInCalendarDays(range.to, range.from);
19962 const totalDaysLimit = Math.min(totalDays, 6);
19963 for (let i = 0; i <= totalDaysLimit; i++) {
19964 if (dayOfWeekArr.includes(date.getDay())) {
19965 return true;
19966 }
19967 date = dateLib.addDays(date, 1);
19968 }
19969 return false;
19970 }
19971
19972 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/utils/rangeOverlaps.js
19973 function rangeOverlaps(rangeLeft, rangeRight, dateLib = defaultDateLib) {
19974 return rangeIncludesDate(rangeLeft, rangeRight.from, false, dateLib) || rangeIncludesDate(rangeLeft, rangeRight.to, false, dateLib) || rangeIncludesDate(rangeRight, rangeLeft.from, false, dateLib) || rangeIncludesDate(rangeRight, rangeLeft.to, false, dateLib);
19975 }
19976
19977 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/utils/rangeContainsModifiers.js
19978 function rangeContainsModifiers(range, modifiers, dateLib = defaultDateLib) {
19979 const matchers = Array.isArray(modifiers) ? modifiers : [modifiers];
19980 const nonFunctionMatchers = matchers.filter((matcher) => typeof matcher !== "function");
19981 const nonFunctionMatchersResult = nonFunctionMatchers.some((matcher) => {
19982 if (typeof matcher === "boolean")
19983 return matcher;
19984 if (dateLib.isDate(matcher)) {
19985 return rangeIncludesDate(range, matcher, false, dateLib);
19986 }
19987 if (isDatesArray(matcher, dateLib)) {
19988 return matcher.some((date) => rangeIncludesDate(range, date, false, dateLib));
19989 }
19990 if (isDateRange(matcher)) {
19991 if (matcher.from && matcher.to) {
19992 return rangeOverlaps(range, { from: matcher.from, to: matcher.to }, dateLib);
19993 }
19994 return false;
19995 }
19996 if (isDayOfWeekType(matcher)) {
19997 return rangeContainsDayOfWeek(range, matcher.dayOfWeek, dateLib);
19998 }
19999 if (isDateInterval(matcher)) {
20000 const isClosedInterval = dateLib.isAfter(matcher.before, matcher.after);
20001 if (isClosedInterval) {
20002 return rangeOverlaps(range, {
20003 from: dateLib.addDays(matcher.after, 1),
20004 to: dateLib.addDays(matcher.before, -1)
20005 }, dateLib);
20006 }
20007 return dateMatchModifiers(range.from, matcher, dateLib) || dateMatchModifiers(range.to, matcher, dateLib);
20008 }
20009 if (isDateAfterType(matcher) || isDateBeforeType(matcher)) {
20010 return dateMatchModifiers(range.from, matcher, dateLib) || dateMatchModifiers(range.to, matcher, dateLib);
20011 }
20012 return false;
20013 });
20014 if (nonFunctionMatchersResult) {
20015 return true;
20016 }
20017 const functionMatchers = matchers.filter((matcher) => typeof matcher === "function");
20018 if (functionMatchers.length) {
20019 let date = range.from;
20020 const totalDays = dateLib.differenceInCalendarDays(range.to, range.from);
20021 for (let i = 0; i <= totalDays; i++) {
20022 if (functionMatchers.some((matcher) => matcher(date))) {
20023 return true;
20024 }
20025 date = dateLib.addDays(date, 1);
20026 }
20027 }
20028 return false;
20029 }
20030
20031 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/selection/useRange.js
20032 function useRange(props, dateLib) {
20033 const { disabled: disabled2, excludeDisabled, resetOnSelect, selected: initiallySelected, required, onSelect } = props;
20034 const [internallySelected, setSelected] = useControlledValue(initiallySelected, onSelect ? initiallySelected : void 0);
20035 const selected = !onSelect ? internallySelected : initiallySelected;
20036 const isSelected = (date) => selected && rangeIncludesDate(selected, date, false, dateLib);
20037 const select = (triggerDate, modifiers, e) => {
20038 const { min: min4, max: max4 } = props;
20039 let newRange;
20040 if (triggerDate) {
20041 const selectedFrom = selected?.from;
20042 const selectedTo = selected?.to;
20043 const hasFullRange = !!selectedFrom && !!selectedTo;
20044 const isClickingSingleDayRange = !!selectedFrom && !!selectedTo && dateLib.isSameDay(selectedFrom, selectedTo) && dateLib.isSameDay(triggerDate, selectedFrom);
20045 if (resetOnSelect && (hasFullRange || !selected?.from)) {
20046 if (!required && isClickingSingleDayRange) {
20047 newRange = void 0;
20048 } else {
20049 newRange = { from: triggerDate, to: void 0 };
20050 }
20051 } else {
20052 newRange = addToRange(triggerDate, selected, min4, max4, required, dateLib);
20053 }
20054 }
20055 if (excludeDisabled && disabled2 && newRange?.from && newRange.to) {
20056 if (rangeContainsModifiers({ from: newRange.from, to: newRange.to }, disabled2, dateLib)) {
20057 newRange.from = triggerDate;
20058 newRange.to = void 0;
20059 }
20060 }
20061 if (!onSelect) {
20062 setSelected(newRange);
20063 }
20064 onSelect?.(newRange, triggerDate, modifiers, e);
20065 return newRange;
20066 };
20067 return {
20068 selected,
20069 select,
20070 isSelected
20071 };
20072 }
20073
20074 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/selection/useSingle.js
20075 function useSingle(props, dateLib) {
20076 const { selected: initiallySelected, required, onSelect } = props;
20077 const [internallySelected, setSelected] = useControlledValue(initiallySelected, onSelect ? initiallySelected : void 0);
20078 const selected = !onSelect ? internallySelected : initiallySelected;
20079 const { isSameDay: isSameDay2 } = dateLib;
20080 const isSelected = (compareDate) => {
20081 return selected ? isSameDay2(selected, compareDate) : false;
20082 };
20083 const select = (triggerDate, modifiers, e) => {
20084 let newDate = triggerDate;
20085 if (!required && selected && selected && isSameDay2(triggerDate, selected)) {
20086 newDate = void 0;
20087 }
20088 if (!onSelect) {
20089 setSelected(newDate);
20090 }
20091 if (required) {
20092 onSelect?.(newDate, triggerDate, modifiers, e);
20093 } else {
20094 onSelect?.(newDate, triggerDate, modifiers, e);
20095 }
20096 return newDate;
20097 };
20098 return {
20099 selected,
20100 select,
20101 isSelected
20102 };
20103 }
20104
20105 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/useSelection.js
20106 function useSelection(props, dateLib) {
20107 const single = useSingle(props, dateLib);
20108 const multi = useMulti(props, dateLib);
20109 const range = useRange(props, dateLib);
20110 switch (props.mode) {
20111 case "single":
20112 return single;
20113 case "multiple":
20114 return multi;
20115 case "range":
20116 return range;
20117 default:
20118 return void 0;
20119 }
20120 }
20121
20122 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/utils/toTimeZone.js
20123 function toTimeZone(date, timeZone) {
20124 if (date instanceof TZDate && date.timeZone === timeZone) {
20125 return date;
20126 }
20127 return new TZDate(date, timeZone);
20128 }
20129
20130 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/utils/convertMatchersToTimeZone.js
20131 function toZoneNoon(date, timeZone, noonSafe) {
20132 if (!noonSafe)
20133 return toTimeZone(date, timeZone);
20134 const zoned = toTimeZone(date, timeZone);
20135 const noonZoned = new TZDate(zoned.getFullYear(), zoned.getMonth(), zoned.getDate(), 12, 0, 0, timeZone);
20136 return new Date(noonZoned.getTime());
20137 }
20138 function convertMatcher(matcher, timeZone, noonSafe) {
20139 if (typeof matcher === "boolean" || typeof matcher === "function") {
20140 return matcher;
20141 }
20142 if (matcher instanceof Date) {
20143 return toZoneNoon(matcher, timeZone, noonSafe);
20144 }
20145 if (Array.isArray(matcher)) {
20146 return matcher.map((value) => value instanceof Date ? toZoneNoon(value, timeZone, noonSafe) : value);
20147 }
20148 if (isDateRange(matcher)) {
20149 return {
20150 ...matcher,
20151 from: matcher.from ? toTimeZone(matcher.from, timeZone) : matcher.from,
20152 to: matcher.to ? toTimeZone(matcher.to, timeZone) : matcher.to
20153 };
20154 }
20155 if (isDateInterval(matcher)) {
20156 return {
20157 before: toZoneNoon(matcher.before, timeZone, noonSafe),
20158 after: toZoneNoon(matcher.after, timeZone, noonSafe)
20159 };
20160 }
20161 if (isDateAfterType(matcher)) {
20162 return {
20163 after: toZoneNoon(matcher.after, timeZone, noonSafe)
20164 };
20165 }
20166 if (isDateBeforeType(matcher)) {
20167 return {
20168 before: toZoneNoon(matcher.before, timeZone, noonSafe)
20169 };
20170 }
20171 return matcher;
20172 }
20173 function convertMatchersToTimeZone(matchers, timeZone, noonSafe) {
20174 if (!matchers) {
20175 return matchers;
20176 }
20177 if (Array.isArray(matchers)) {
20178 return matchers.map((matcher) => convertMatcher(matcher, timeZone, noonSafe));
20179 }
20180 return convertMatcher(matchers, timeZone, noonSafe);
20181 }
20182
20183 // node_modules/@daypicker/react/node_modules/react-day-picker/dist/esm/DayPicker.js
20184 function DayPicker(initialProps) {
20185 let props = initialProps;
20186 const timeZone = props.timeZone;
20187 if (timeZone) {
20188 props = {
20189 ...initialProps,
20190 timeZone
20191 };
20192 if (props.today) {
20193 props.today = toTimeZone(props.today, timeZone);
20194 }
20195 if (props.month) {
20196 props.month = toTimeZone(props.month, timeZone);
20197 }
20198 if (props.defaultMonth) {
20199 props.defaultMonth = toTimeZone(props.defaultMonth, timeZone);
20200 }
20201 if (props.startMonth) {
20202 props.startMonth = toTimeZone(props.startMonth, timeZone);
20203 }
20204 if (props.endMonth) {
20205 props.endMonth = toTimeZone(props.endMonth, timeZone);
20206 }
20207 if (props.mode === "single" && props.selected) {
20208 props.selected = toTimeZone(props.selected, timeZone);
20209 } else if (props.mode === "multiple" && props.selected) {
20210 props.selected = props.selected?.map((date) => toTimeZone(date, timeZone));
20211 } else if (props.mode === "range" && props.selected) {
20212 props.selected = {
20213 from: props.selected.from ? toTimeZone(props.selected.from, timeZone) : props.selected.from,
20214 to: props.selected.to ? toTimeZone(props.selected.to, timeZone) : props.selected.to
20215 };
20216 }
20217 if (props.disabled !== void 0) {
20218 props.disabled = convertMatchersToTimeZone(props.disabled, timeZone);
20219 }
20220 if (props.hidden !== void 0) {
20221 props.hidden = convertMatchersToTimeZone(props.hidden, timeZone);
20222 }
20223 if (props.modifiers) {
20224 const nextModifiers = {};
20225 Object.keys(props.modifiers).forEach((key) => {
20226 nextModifiers[key] = convertMatchersToTimeZone(props.modifiers?.[key], timeZone);
20227 });
20228 props.modifiers = nextModifiers;
20229 }
20230 }
20231 const { components, formatters: formatters2, labels, dateLib, locale, classNames } = (0, import_react36.useMemo)(() => {
20232 const locale2 = { ...enUS2, ...props.locale };
20233 const weekStartsOn = props.broadcastCalendar ? 1 : props.weekStartsOn;
20234 const noonOverrides = props.noonSafe && props.timeZone ? createNoonOverrides(props.timeZone, {
20235 weekStartsOn,
20236 locale: locale2
20237 }) : void 0;
20238 const overrides = props.dateLib && noonOverrides ? { ...noonOverrides, ...props.dateLib } : props.dateLib ?? noonOverrides;
20239 const dateLib2 = new DateLib({
20240 locale: locale2,
20241 weekStartsOn,
20242 firstWeekContainsDate: props.firstWeekContainsDate,
20243 useAdditionalWeekYearTokens: props.useAdditionalWeekYearTokens,
20244 useAdditionalDayOfYearTokens: props.useAdditionalDayOfYearTokens,
20245 timeZone: props.timeZone,
20246 numerals: props.numerals
20247 }, overrides);
20248 return {
20249 dateLib: dateLib2,
20250 components: getComponents(props.components),
20251 formatters: getFormatters(props.formatters),
20252 labels: getLabels(props.labels, dateLib2.options),
20253 locale: locale2,
20254 classNames: { ...getDefaultClassNames(), ...props.classNames }
20255 };
20256 }, [
20257 props.locale,
20258 props.broadcastCalendar,
20259 props.weekStartsOn,
20260 props.firstWeekContainsDate,
20261 props.useAdditionalWeekYearTokens,
20262 props.useAdditionalDayOfYearTokens,
20263 props.timeZone,
20264 props.numerals,
20265 props.dateLib,
20266 props.noonSafe,
20267 props.components,
20268 props.formatters,
20269 props.labels,
20270 props.classNames
20271 ]);
20272 if (!props.today) {
20273 props = { ...props, today: dateLib.today() };
20274 }
20275 const { captionLayout, mode, navLayout, numberOfMonths = 1, onDayBlur, onDayClick, onDayFocus, onDayKeyDown, onDayMouseEnter, onDayMouseLeave, onNextClick, onPrevClick, showWeekNumber, styles } = props;
20276 const { formatCaption: formatCaption2, formatDay: formatDay2, formatMonthDropdown: formatMonthDropdown2, formatWeekNumber: formatWeekNumber2, formatWeekNumberHeader: formatWeekNumberHeader2, formatWeekdayName: formatWeekdayName2, formatYearDropdown: formatYearDropdown2 } = formatters2;
20277 const calendar = useCalendar(props, dateLib);
20278 const { days, months, navStart, navEnd, previousMonth, nextMonth, goToMonth } = calendar;
20279 const getModifiers = createGetModifiers(days, props, navStart, navEnd, dateLib);
20280 const { isSelected, select, selected: selectedValue } = useSelection(props, dateLib) ?? {};
20281 const { blur, focused, isFocusTarget, moveFocus, setFocused } = useFocus2(props, calendar, getModifiers, isSelected ?? (() => false), dateLib);
20282 const { labelDayButton: labelDayButton2, labelGridcell: labelGridcell2, labelGrid: labelGrid2, labelMonthDropdown: labelMonthDropdown2, labelNav: labelNav2, labelPrevious: labelPrevious2, labelNext: labelNext2, labelWeekday: labelWeekday2, labelWeekNumber: labelWeekNumber2, labelWeekNumberHeader: labelWeekNumberHeader2, labelYearDropdown: labelYearDropdown2 } = labels;
20283 const weekdays = (0, import_react36.useMemo)(() => getWeekdays(dateLib, props.ISOWeek, props.broadcastCalendar, props.today), [dateLib, props.ISOWeek, props.broadcastCalendar, props.today]);
20284 const isInteractive = mode !== void 0 || onDayClick !== void 0;
20285 const handlePreviousClick = (0, import_react36.useCallback)(() => {
20286 if (!previousMonth)
20287 return;
20288 goToMonth(previousMonth);
20289 onPrevClick?.(previousMonth);
20290 }, [previousMonth, goToMonth, onPrevClick]);
20291 const handleNextClick = (0, import_react36.useCallback)(() => {
20292 if (!nextMonth)
20293 return;
20294 goToMonth(nextMonth);
20295 onNextClick?.(nextMonth);
20296 }, [goToMonth, nextMonth, onNextClick]);
20297 const handleDayClick = (0, import_react36.useCallback)((day, m2) => (e) => {
20298 e.preventDefault();
20299 e.stopPropagation();
20300 setFocused(day);
20301 if (m2.disabled) {
20302 return;
20303 }
20304 select?.(day.date, m2, e);
20305 onDayClick?.(day.date, m2, e);
20306 }, [select, onDayClick, setFocused]);
20307 const handleDayFocus = (0, import_react36.useCallback)((day, m2) => (e) => {
20308 setFocused(day);
20309 onDayFocus?.(day.date, m2, e);
20310 }, [onDayFocus, setFocused]);
20311 const handleDayBlur = (0, import_react36.useCallback)((day, m2) => (e) => {
20312 blur();
20313 onDayBlur?.(day.date, m2, e);
20314 }, [blur, onDayBlur]);
20315 const handleDayKeyDown = (0, import_react36.useCallback)((day, modifiers) => (e) => {
20316 const keyMap = {
20317 ArrowLeft: [
20318 e.shiftKey ? "month" : "day",
20319 props.dir === "rtl" ? "after" : "before"
20320 ],
20321 ArrowRight: [
20322 e.shiftKey ? "month" : "day",
20323 props.dir === "rtl" ? "before" : "after"
20324 ],
20325 ArrowDown: [e.shiftKey ? "year" : "week", "after"],
20326 ArrowUp: [e.shiftKey ? "year" : "week", "before"],
20327 PageUp: [e.shiftKey ? "year" : "month", "before"],
20328 PageDown: [e.shiftKey ? "year" : "month", "after"],
20329 Home: ["startOfWeek", "before"],
20330 End: ["endOfWeek", "after"]
20331 };
20332 if (keyMap[e.key]) {
20333 e.preventDefault();
20334 e.stopPropagation();
20335 const [moveBy, moveDir] = keyMap[e.key];
20336 moveFocus(moveBy, moveDir);
20337 }
20338 onDayKeyDown?.(day.date, modifiers, e);
20339 }, [moveFocus, onDayKeyDown, props.dir]);
20340 const handleDayMouseEnter = (0, import_react36.useCallback)((day, modifiers) => (e) => {
20341 onDayMouseEnter?.(day.date, modifiers, e);
20342 }, [onDayMouseEnter]);
20343 const handleDayMouseLeave = (0, import_react36.useCallback)((day, modifiers) => (e) => {
20344 onDayMouseLeave?.(day.date, modifiers, e);
20345 }, [onDayMouseLeave]);
20346 const handleMonthChange = (0, import_react36.useCallback)((date, monthOffset) => (e) => {
20347 const selectedMonth = Number(e.target.value);
20348 const month = dateLib.setMonth(dateLib.startOfMonth(date), selectedMonth);
20349 goToMonth(dateLib.addMonths(month, -monthOffset));
20350 }, [dateLib, goToMonth]);
20351 const handleYearChange = (0, import_react36.useCallback)((date, monthOffset) => (e) => {
20352 const selectedYear = Number(e.target.value);
20353 const month = dateLib.setYear(dateLib.startOfMonth(date), selectedYear);
20354 goToMonth(dateLib.addMonths(month, -monthOffset));
20355 }, [dateLib, goToMonth]);
20356 const { className, style } = (0, import_react36.useMemo)(() => ({
20357 className: [classNames[UI.Root], props.className].filter(Boolean).join(" "),
20358 style: { ...styles?.[UI.Root], ...props.style }
20359 }), [classNames, props.className, props.style, styles]);
20360 const dataAttributes = getDataAttributes(props);
20361 const getDropdownStyle = (dropdown) => {
20362 const dropdownStyle = styles?.[UI.Dropdown];
20363 const specificDropdownStyle = styles?.[dropdown];
20364 if (!dropdownStyle && !specificDropdownStyle) {
20365 return void 0;
20366 }
20367 return {
20368 ...dropdownStyle,
20369 ...specificDropdownStyle
20370 };
20371 };
20372 const rootElRef = (0, import_react36.useRef)(null);
20373 useAnimation(rootElRef, Boolean(props.animate), {
20374 classNames,
20375 months,
20376 focused,
20377 dateLib
20378 });
20379 const contextValue = {
20380 dayPickerProps: props,
20381 selected: selectedValue,
20382 select,
20383 isSelected,
20384 months,
20385 nextMonth,
20386 previousMonth,
20387 goToMonth,
20388 getModifiers,
20389 components,
20390 classNames,
20391 styles,
20392 labels,
20393 formatters: formatters2
20394 };
20395 return import_react36.default.createElement(
20396 dayPickerContext.Provider,
20397 { value: contextValue },
20398 import_react36.default.createElement(
20399 components.Root,
20400 { rootRef: props.animate ? rootElRef : void 0, className, style, dir: props.dir, id: props.id, lang: props.lang ?? locale.code, nonce: props.nonce, title: props.title, role: props.role, "aria-label": props["aria-label"], "aria-labelledby": props["aria-labelledby"], ...dataAttributes },
20401 import_react36.default.createElement(
20402 components.Months,
20403 { className: classNames[UI.Months], style: styles?.[UI.Months] },
20404 !props.hideNavigation && !navLayout && import_react36.default.createElement(components.Nav, { "data-animated-nav": props.animate ? "true" : void 0, className: classNames[UI.Nav], style: styles?.[UI.Nav], "aria-label": labelNav2(), onPreviousClick: handlePreviousClick, onNextClick: handleNextClick, previousMonth, nextMonth }),
20405 months.map((calendarMonth, displayIndex) => {
20406 const monthOffset = props.reverseMonths ? months.length - 1 - displayIndex : displayIndex;
20407 return import_react36.default.createElement(
20408 components.Month,
20409 {
20410 "data-animated-month": props.animate ? "true" : void 0,
20411 className: classNames[UI.Month],
20412 style: styles?.[UI.Month],
20413 // biome-ignore lint/suspicious/noArrayIndexKey: breaks animation
20414 key: displayIndex,
20415 displayIndex,
20416 calendarMonth
20417 },
20418 navLayout === "around" && !props.hideNavigation && displayIndex === 0 && import_react36.default.createElement(
20419 components.PreviousMonthButton,
20420 { type: "button", className: classNames[UI.PreviousMonthButton], style: styles?.[UI.PreviousMonthButton], tabIndex: previousMonth ? void 0 : -1, "aria-disabled": previousMonth ? void 0 : true, "aria-label": labelPrevious2(previousMonth), onClick: handlePreviousClick, "data-animated-button": props.animate ? "true" : void 0 },
20421 import_react36.default.createElement(components.Chevron, { disabled: previousMonth ? void 0 : true, className: classNames[UI.Chevron], style: styles?.[UI.Chevron], orientation: props.dir === "rtl" ? "right" : "left" })
20422 ),
20423 import_react36.default.createElement(components.MonthCaption, { "data-animated-caption": props.animate ? "true" : void 0, className: classNames[UI.MonthCaption], style: styles?.[UI.MonthCaption], calendarMonth, displayIndex }, captionLayout?.startsWith("dropdown") ? import_react36.default.createElement(
20424 components.DropdownNav,
20425 { className: classNames[UI.Dropdowns], style: styles?.[UI.Dropdowns] },
20426 (() => {
20427 const monthControl = captionLayout === "dropdown" || captionLayout === "dropdown-months" ? import_react36.default.createElement(components.MonthsDropdown, { key: "month", className: classNames[UI.MonthsDropdown], "aria-label": labelMonthDropdown2(), disabled: Boolean(props.disableNavigation), onChange: handleMonthChange(calendarMonth.date, monthOffset), options: getMonthOptions(calendarMonth.date, navStart, navEnd, formatters2, dateLib), style: getDropdownStyle(UI.MonthsDropdown), value: dateLib.getMonth(calendarMonth.date) }) : import_react36.default.createElement("span", { key: "month" }, formatMonthDropdown2(calendarMonth.date, dateLib));
20428 const yearControl = captionLayout === "dropdown" || captionLayout === "dropdown-years" ? import_react36.default.createElement(components.YearsDropdown, { key: "year", className: classNames[UI.YearsDropdown], "aria-label": labelYearDropdown2(dateLib.options), disabled: Boolean(props.disableNavigation), onChange: handleYearChange(calendarMonth.date, monthOffset), options: getYearOptions(navStart, navEnd, formatters2, dateLib, Boolean(props.reverseYears)), style: getDropdownStyle(UI.YearsDropdown), value: dateLib.getYear(calendarMonth.date) }) : import_react36.default.createElement("span", { key: "year" }, formatYearDropdown2(calendarMonth.date, dateLib));
20429 const controls = dateLib.getMonthYearOrder() === "year-first" ? [yearControl, monthControl] : [monthControl, yearControl];
20430 return controls;
20431 })(),
20432 import_react36.default.createElement("span", { role: "status", "aria-live": "polite", style: {
20433 border: 0,
20434 clip: "rect(0 0 0 0)",
20435 height: "1px",
20436 margin: "-1px",
20437 overflow: "hidden",
20438 padding: 0,
20439 position: "absolute",
20440 width: "1px",
20441 whiteSpace: "nowrap",
20442 wordWrap: "normal"
20443 } }, formatCaption2(calendarMonth.date, dateLib.options, dateLib))
20444 ) : import_react36.default.createElement(components.CaptionLabel, { className: classNames[UI.CaptionLabel], style: styles?.[UI.CaptionLabel], role: "status", "aria-live": "polite" }, formatCaption2(calendarMonth.date, dateLib.options, dateLib))),
20445 navLayout === "around" && !props.hideNavigation && displayIndex === numberOfMonths - 1 && import_react36.default.createElement(
20446 components.NextMonthButton,
20447 { type: "button", className: classNames[UI.NextMonthButton], style: styles?.[UI.NextMonthButton], tabIndex: nextMonth ? void 0 : -1, "aria-disabled": nextMonth ? void 0 : true, "aria-label": labelNext2(nextMonth), onClick: handleNextClick, "data-animated-button": props.animate ? "true" : void 0 },
20448 import_react36.default.createElement(components.Chevron, { disabled: nextMonth ? void 0 : true, className: classNames[UI.Chevron], style: styles?.[UI.Chevron], orientation: props.dir === "rtl" ? "left" : "right" })
20449 ),
20450 displayIndex === numberOfMonths - 1 && navLayout === "after" && !props.hideNavigation && import_react36.default.createElement(components.Nav, { "data-animated-nav": props.animate ? "true" : void 0, className: classNames[UI.Nav], style: styles?.[UI.Nav], "aria-label": labelNav2(), onPreviousClick: handlePreviousClick, onNextClick: handleNextClick, previousMonth, nextMonth }),
20451 import_react36.default.createElement(
20452 components.MonthGrid,
20453 { role: "grid", "aria-multiselectable": mode === "multiple" || mode === "range", "aria-label": labelGrid2(calendarMonth.date, dateLib.options, dateLib) || void 0, className: classNames[UI.MonthGrid], style: styles?.[UI.MonthGrid] },
20454 !props.hideWeekdays && import_react36.default.createElement(
20455 components.Weekdays,
20456 { "data-animated-weekdays": props.animate ? "true" : void 0, className: classNames[UI.Weekdays], style: styles?.[UI.Weekdays] },
20457 showWeekNumber && import_react36.default.createElement(components.WeekNumberHeader, { "aria-label": labelWeekNumberHeader2(dateLib.options), className: classNames[UI.WeekNumberHeader], style: styles?.[UI.WeekNumberHeader], scope: "col" }, formatWeekNumberHeader2()),
20458 weekdays.map((weekday) => import_react36.default.createElement(components.Weekday, { "aria-label": labelWeekday2(weekday, dateLib.options, dateLib), className: classNames[UI.Weekday], key: String(weekday), style: styles?.[UI.Weekday], scope: "col" }, formatWeekdayName2(weekday, dateLib.options, dateLib)))
20459 ),
20460 import_react36.default.createElement(components.Weeks, { "data-animated-weeks": props.animate ? "true" : void 0, className: classNames[UI.Weeks], style: styles?.[UI.Weeks] }, calendarMonth.weeks.map((week) => {
20461 return import_react36.default.createElement(
20462 components.Week,
20463 { className: classNames[UI.Week], key: week.weekNumber, style: styles?.[UI.Week], week },
20464 showWeekNumber && import_react36.default.createElement(components.WeekNumber, { week, style: styles?.[UI.WeekNumber], "aria-label": labelWeekNumber2(week.weekNumber, {
20465 locale
20466 }), className: classNames[UI.WeekNumber], scope: "row", role: "rowheader" }, formatWeekNumber2(week.weekNumber, dateLib)),
20467 week.days.map((day) => {
20468 const { date } = day;
20469 const modifiers = getModifiers(day);
20470 modifiers[DayFlag.focused] = !modifiers.hidden && Boolean(focused?.isEqualTo(day));
20471 modifiers[SelectionState.selected] = isSelected?.(date) || modifiers.selected;
20472 if (isDateRange(selectedValue)) {
20473 const { from, to } = selectedValue;
20474 modifiers[SelectionState.range_start] = Boolean(from && to && dateLib.isSameDay(date, from));
20475 modifiers[SelectionState.range_end] = Boolean(from && to && dateLib.isSameDay(date, to));
20476 modifiers[SelectionState.range_middle] = rangeIncludesDate(selectedValue, date, true, dateLib);
20477 }
20478 const style2 = getStyleForModifiers(modifiers, styles, props.modifiersStyles);
20479 const className2 = getClassNamesForModifiers(modifiers, classNames, props.modifiersClassNames);
20480 const ariaLabel = !isInteractive && !modifiers.hidden ? labelGridcell2(date, modifiers, dateLib.options, dateLib) : void 0;
20481 return import_react36.default.createElement(components.Day, { key: `${day.isoDate}_${day.displayMonthId}`, day, modifiers, className: className2.join(" "), style: style2, role: "gridcell", "aria-selected": modifiers.selected || void 0, "aria-label": ariaLabel, "data-day": day.isoDate, "data-month": day.outside ? day.dateMonthId : void 0, "data-selected": modifiers.selected || void 0, "data-disabled": modifiers.disabled || void 0, "data-hidden": modifiers.hidden || void 0, "data-outside": day.outside || void 0, "data-focused": modifiers.focused || void 0, "data-today": modifiers.today || void 0 }, !modifiers.hidden && isInteractive ? import_react36.default.createElement(components.DayButton, { className: classNames[UI.DayButton], style: styles?.[UI.DayButton], type: "button", day, modifiers, disabled: !modifiers.focused && modifiers.disabled || void 0, "aria-disabled": modifiers.focused && modifiers.disabled || void 0, tabIndex: isFocusTarget(day) ? 0 : -1, "aria-label": labelDayButton2(date, modifiers, dateLib.options, dateLib), onClick: handleDayClick(day, modifiers), onBlur: handleDayBlur(day, modifiers), onFocus: handleDayFocus(day, modifiers), onKeyDown: handleDayKeyDown(day, modifiers), onMouseEnter: handleDayMouseEnter(day, modifiers), onMouseLeave: handleDayMouseLeave(day, modifiers) }, formatDay2(date, dateLib.options, dateLib)) : !modifiers.hidden && formatDay2(day.date, dateLib.options, dateLib));
20482 })
20483 );
20484 }))
20485 )
20486 );
20487 })
20488 ),
20489 props.footer && import_react36.default.createElement(components.Footer, { className: classNames[UI.Footer], style: styles?.[UI.Footer], role: "status", "aria-live": "polite" }, props.footer)
20490 )
20491 );
20492 }
20493
20494 // packages/ui/build-module/calendar/calendar.mjs
20495 var import_element29 = __toESM(require_element(), 1);
20496
20497 // packages/ui/build-module/calendar/utils/components.mjs
20498 var import_element25 = __toESM(require_element(), 1);
20499 var import_compose = __toESM(require_compose(), 1);
20500 var import_i18n5 = __toESM(require_i18n(), 1);
20501
20502 // packages/ui/build-module/icon-button/icon-button.mjs
20503 var import_element23 = __toESM(require_element(), 1);
20504 var import_jsx_runtime62 = __toESM(require_jsx_runtime(), 1);
20505 var STYLE_HASH_ATTRIBUTE10 = "data-wp-hash";
20506 function getRuntime10() {
20507 const globalScope = globalThis;
20508 if (globalScope.__wpStyleRuntime) {
20509 return globalScope.__wpStyleRuntime;
20510 }
20511 globalScope.__wpStyleRuntime = {
20512 documents: /* @__PURE__ */ new Map(),
20513 styles: /* @__PURE__ */ new Map(),
20514 injectedStyles: /* @__PURE__ */ new WeakMap()
20515 };
20516 if (typeof document !== "undefined") {
20517 registerDocument10(document);
20518 }
20519 return globalScope.__wpStyleRuntime;
20520 }
20521 function documentContainsStyleHash10(targetDocument, hash) {
20522 if (!targetDocument.head) {
20523 return false;
20524 }
20525 for (const style of targetDocument.head.querySelectorAll(
20526 `style[${STYLE_HASH_ATTRIBUTE10}]`
20527 )) {
20528 if (style.getAttribute(STYLE_HASH_ATTRIBUTE10) === hash) {
20529 return true;
20530 }
20531 }
20532 return false;
20533 }
20534 function injectStyle10(targetDocument, hash, css) {
20535 if (!targetDocument.head) {
20536 return;
20537 }
20538 const runtime = getRuntime10();
20539 let injectedStyles = runtime.injectedStyles.get(targetDocument);
20540 if (!injectedStyles) {
20541 injectedStyles = /* @__PURE__ */ new Set();
20542 runtime.injectedStyles.set(targetDocument, injectedStyles);
20543 }
20544 if (injectedStyles.has(hash)) {
20545 return;
20546 }
20547 if (documentContainsStyleHash10(targetDocument, hash)) {
20548 injectedStyles.add(hash);
20549 return;
20550 }
20551 const style = targetDocument.createElement("style");
20552 style.setAttribute(STYLE_HASH_ATTRIBUTE10, hash);
20553 style.appendChild(targetDocument.createTextNode(css));
20554 targetDocument.head.appendChild(style);
20555 injectedStyles.add(hash);
20556 }
20557 function registerDocument10(targetDocument) {
20558 const runtime = getRuntime10();
20559 runtime.documents.set(
20560 targetDocument,
20561 (runtime.documents.get(targetDocument) ?? 0) + 1
20562 );
20563 for (const [hash, css] of runtime.styles) {
20564 injectStyle10(targetDocument, hash, css);
20565 }
20566 return () => {
20567 const count = runtime.documents.get(targetDocument);
20568 if (count === void 0) {
20569 return;
20570 }
20571 if (count <= 1) {
20572 runtime.documents.delete(targetDocument);
20573 return;
20574 }
20575 runtime.documents.set(targetDocument, count - 1);
20576 };
20577 }
20578 function registerStyle10(hash, css) {
20579 const runtime = getRuntime10();
20580 runtime.styles.set(hash, css);
20581 for (const targetDocument of runtime.documents.keys()) {
20582 injectStyle10(targetDocument, hash, css);
20583 }
20584 }
20585 if (typeof process === "undefined" || true) {
20586 registerStyle10("c5cdafb1bc", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer compositions{._28cfdc260e755391__icon-button{--wp-ui-button-aspect-ratio:1;--wp-ui-button-padding-inline:0px;--wp-ui-button-min-width:unset}.f1c70d719989a85a__icon{margin:-1px}}}");
20587 }
20588 var style_default9 = { "icon-button": "_28cfdc260e755391__icon-button", "icon": "f1c70d719989a85a__icon" };
20589 var IconButton = (0, import_element23.forwardRef)(
20590 function IconButton2({
20591 label,
20592 className,
20593 // Prevent accidental forwarding of `children`
20594 children: _children,
20595 disabled: disabled2,
20596 focusableWhenDisabled = true,
20597 icon,
20598 size: size4,
20599 shortcut,
20600 positioner,
20601 "aria-describedby": ariaDescribedBy,
20602 "aria-keyshortcuts": ariaKeyShortcuts,
20603 ...restProps
20604 }, ref) {
20605 const classes = clsx_default(style_default9["icon-button"], className);
20606 const { descriptionId, targetProps } = useKeyboardShortcutProps({
20607 "aria-describedby": ariaDescribedBy,
20608 "aria-keyshortcuts": ariaKeyShortcuts,
20609 shortcut
20610 });
20611 return /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(Root, { children: [
20612 /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
20613 Trigger,
20614 {
20615 ref,
20616 ...targetProps,
20617 disabled: disabled2 && !focusableWhenDisabled,
20618 render: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
20619 Button4,
20620 {
20621 ...restProps,
20622 size: size4,
20623 "aria-label": label,
20624 disabled: disabled2,
20625 focusableWhenDisabled
20626 }
20627 ),
20628 className: classes,
20629 children: [
20630 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(Icon, { icon, size: 24, className: style_default9.icon }),
20631 shortcut && descriptionId && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
20632 KeyboardShortcutDescription,
20633 {
20634 descriptionId,
20635 shortcut
20636 }
20637 )
20638 ]
20639 }
20640 ),
20641 /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(Popup, { positioner, children: [
20642 label,
20643 shortcut && /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(import_jsx_runtime62.Fragment, { children: [
20644 " ",
20645 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(KeyboardShortcutDisplay, { shortcut })
20646 ] })
20647 ] })
20648 ] });
20649 }
20650 );
20651
20652 // packages/ui/build-module/calendar/utils/root-context.mjs
20653 var import_element24 = __toESM(require_element(), 1);
20654 var RootContext = (0, import_element24.createContext)({});
20655
20656 // packages/ui/build-module/calendar/utils/components.mjs
20657 var import_jsx_runtime63 = __toESM(require_jsx_runtime(), 1);
20658 var PreviewDashStartAndEnd = () => {
20659 return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
20660 "svg",
20661 {
20662 viewBox: "0 0 32 32",
20663 xmlns: "http://www.w3.org/2000/svg",
20664 fill: "none",
20665 stroke: "currentColor",
20666 strokeDasharray: "3.7677",
20667 strokeDashoffset: "3.2",
20668 strokeWidth: "1",
20669 children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("path", { d: "M29.5,0.5 h-27 a2,2 0 0 0 -2,2 v27 a2,2 0 0 0 2,2 h27 a2,2 0 0 0 2,-2 v-27 a2,2 0 0 0 -2,-2" })
20670 }
20671 );
20672 };
20673 var PreviewDashStart = () => {
20674 return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
20675 "svg",
20676 {
20677 viewBox: "0 0 32 32",
20678 xmlns: "http://www.w3.org/2000/svg",
20679 fill: "none",
20680 stroke: "currentColor",
20681 strokeDasharray: "3.84516",
20682 strokeDashoffset: "1.9226",
20683 strokeWidth: "1",
20684 children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("path", { d: "M32,0.5 h-29.5 a2,2 0 0 0 -2,2 v27 a2,2 0 0 0 2,2 h30" })
20685 }
20686 );
20687 };
20688 var PreviewDashMiddle = () => {
20689 return /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(
20690 "svg",
20691 {
20692 viewBox: "0 0 32 32",
20693 xmlns: "http://www.w3.org/2000/svg",
20694 fill: "none",
20695 stroke: "currentColor",
20696 strokeDasharray: "3.9 4",
20697 strokeDashoffset: "2",
20698 strokeWidth: "1",
20699 children: [
20700 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("line", { x1: "0", y1: "0.5", x2: "100", y2: "0.5" }),
20701 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("line", { x1: "0", y1: "31.5", x2: "100", y2: "31.5" })
20702 ]
20703 }
20704 );
20705 };
20706 var PreviewDashEnd = () => {
20707 return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
20708 "svg",
20709 {
20710 viewBox: "0 0 32 32",
20711 xmlns: "http://www.w3.org/2000/svg",
20712 fill: "none",
20713 stroke: "currentColor",
20714 strokeDasharray: "3.84516",
20715 strokeDashoffset: "1.9226",
20716 strokeWidth: "1",
20717 children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("path", { d: "M0,0.5 h29.5 a2,2 0 0 1 2,2 v27 a2,2 0 0 1 -2,2 h-29.5" })
20718 }
20719 );
20720 };
20721 function Day2(props) {
20722 const { day, modifiers, children, ...tdProps } = props;
20723 let PreviewDash;
20724 if (modifiers.preview_start && modifiers.preview_end) {
20725 PreviewDash = PreviewDashStartAndEnd;
20726 } else if (modifiers.preview_start) {
20727 PreviewDash = PreviewDashStart;
20728 } else if (modifiers.preview_end) {
20729 PreviewDash = PreviewDashEnd;
20730 } else if (modifiers.preview) {
20731 PreviewDash = PreviewDashMiddle;
20732 }
20733 return /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("td", { ...tdProps, children: [
20734 PreviewDash && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(PreviewDash, {}),
20735 children
20736 ] });
20737 }
20738 function Root3({ rootRef, ...props }) {
20739 const { render: render4, ref, role, defaultAriaLabel } = (0, import_element25.useContext)(RootContext);
20740 const { months, labels } = useDayPicker();
20741 const hasExplicitLabel = props["aria-label"] !== void 0 || props["aria-labelledby"] !== void 0;
20742 let ariaLabel = props["aria-label"];
20743 if (!hasExplicitLabel && defaultAriaLabel && role === "application") {
20744 const currentMonth = months[0];
20745 ariaLabel = currentMonth ? (0, import_i18n5.sprintf)(
20746 // translators: 1: Calendar type. 2: Current month and year.
20747 (0, import_i18n5.__)("%1$s, %2$s"),
20748 defaultAriaLabel,
20749 labels.labelGrid(currentMonth.date)
20750 ) : defaultAriaLabel;
20751 }
20752 const mergedRef = (0, import_compose.useMergeRefs)([rootRef ?? null, ref ?? null]);
20753 return useRender({
20754 render: render4,
20755 defaultTagName: "div",
20756 ref: mergedRef,
20757 props: { ...props, role, "aria-label": ariaLabel }
20758 });
20759 }
20760 function NavButton({
20761 icon,
20762 className,
20763 children: _children,
20764 "aria-label": label,
20765 "aria-disabled": ariaDisabled,
20766 ...props
20767 }) {
20768 return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
20769 IconButton,
20770 {
20771 ...props,
20772 className,
20773 label,
20774 icon,
20775 variant: "minimal",
20776 tone: "neutral",
20777 size: "compact",
20778 disabled: ariaDisabled === true || ariaDisabled === "true",
20779 focusableWhenDisabled: true
20780 }
20781 );
20782 }
20783 function PreviousMonthButton2(props) {
20784 return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(NavButton, { ...props, icon: chevron_left_default });
20785 }
20786 function NextMonthButton2(props) {
20787 return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(NavButton, { ...props, icon: chevron_right_default });
20788 }
20789
20790 // packages/ui/build-module/calendar/utils/constants.mjs
20791 var STYLE_HASH_ATTRIBUTE11 = "data-wp-hash";
20792 function getRuntime11() {
20793 const globalScope = globalThis;
20794 if (globalScope.__wpStyleRuntime) {
20795 return globalScope.__wpStyleRuntime;
20796 }
20797 globalScope.__wpStyleRuntime = {
20798 documents: /* @__PURE__ */ new Map(),
20799 styles: /* @__PURE__ */ new Map(),
20800 injectedStyles: /* @__PURE__ */ new WeakMap()
20801 };
20802 if (typeof document !== "undefined") {
20803 registerDocument11(document);
20804 }
20805 return globalScope.__wpStyleRuntime;
20806 }
20807 function documentContainsStyleHash11(targetDocument, hash) {
20808 if (!targetDocument.head) {
20809 return false;
20810 }
20811 for (const style of targetDocument.head.querySelectorAll(
20812 `style[${STYLE_HASH_ATTRIBUTE11}]`
20813 )) {
20814 if (style.getAttribute(STYLE_HASH_ATTRIBUTE11) === hash) {
20815 return true;
20816 }
20817 }
20818 return false;
20819 }
20820 function injectStyle11(targetDocument, hash, css) {
20821 if (!targetDocument.head) {
20822 return;
20823 }
20824 const runtime = getRuntime11();
20825 let injectedStyles = runtime.injectedStyles.get(targetDocument);
20826 if (!injectedStyles) {
20827 injectedStyles = /* @__PURE__ */ new Set();
20828 runtime.injectedStyles.set(targetDocument, injectedStyles);
20829 }
20830 if (injectedStyles.has(hash)) {
20831 return;
20832 }
20833 if (documentContainsStyleHash11(targetDocument, hash)) {
20834 injectedStyles.add(hash);
20835 return;
20836 }
20837 const style = targetDocument.createElement("style");
20838 style.setAttribute(STYLE_HASH_ATTRIBUTE11, hash);
20839 style.appendChild(targetDocument.createTextNode(css));
20840 targetDocument.head.appendChild(style);
20841 injectedStyles.add(hash);
20842 }
20843 function registerDocument11(targetDocument) {
20844 const runtime = getRuntime11();
20845 runtime.documents.set(
20846 targetDocument,
20847 (runtime.documents.get(targetDocument) ?? 0) + 1
20848 );
20849 for (const [hash, css] of runtime.styles) {
20850 injectStyle11(targetDocument, hash, css);
20851 }
20852 return () => {
20853 const count = runtime.documents.get(targetDocument);
20854 if (count === void 0) {
20855 return;
20856 }
20857 if (count <= 1) {
20858 runtime.documents.delete(targetDocument);
20859 return;
20860 }
20861 runtime.documents.set(targetDocument, count - 1);
20862 };
20863 }
20864 function registerStyle11(hash, css) {
20865 const runtime = getRuntime11();
20866 runtime.styles.set(hash, css);
20867 for (const targetDocument of runtime.documents.keys()) {
20868 injectStyle11(targetDocument, hash, css);
20869 }
20870 }
20871 if (typeof process === "undefined" || true) {
20872 registerStyle11("9d2212290a", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._2c7ac60ba97b3411__root{--wp-ui-calendar-cell-size:var(--wpds-dimension-size-md,32px);background-color:var(--wpds-color-background-surface-neutral-strong,#fff);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:inline-block;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-md,13px);font-weight:var(--wpds-typography-font-weight-default,400);position:relative;z-index:0}._172c492625235710__day{color:var(--wpds-color-foreground-interactive-neutral,#1e1e1e);padding:0;position:relative;&:has(._1b64226e315835f8__day-button:disabled){color:var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d)}&:has(._1b64226e315835f8__day-button:focus-visible),&:has(._1b64226e315835f8__day-button:hover:not(:disabled)){color:var(--wpds-color-foreground-interactive-neutral-active,#1e1e1e)}}._1b64226e315835f8__day-button{align-items:center;background:none;border:none;border-radius:var(--wpds-border-radius-sm,2px);color:inherit;cursor:var(--wpds-cursor-control,pointer);display:flex;font:inherit;font-variant-numeric:tabular-nums;height:var(--wp-ui-calendar-cell-size);justify-content:center;margin:0;padding:0;position:relative;width:var(--wp-ui-calendar-cell-size);&:before{background-color:var(--wpds-color-background-interactive-neutral-weak,#0000);border:none;border-radius:var(--wpds-border-radius-sm,2px);z-index:-1}&:after,&:before{content:"";inset:0;position:absolute}&:after{pointer-events:none;z-index:1}&:disabled{cursor:revert;&:before{background-color:var(--wpds-color-background-interactive-neutral-weak-disabled,#0000)}@media (forced-colors:active){text-decoration:line-through}}&:focus-visible:before,&:hover:not(:disabled):before{background-color:var(--wpds-color-background-interactive-neutral-weak-active,#ededed)}}._66b9a8120581fd4b__caption-label{align-items:center;border:0;display:inline-flex;position:relative;text-transform:capitalize;white-space:nowrap;z-index:1}._2c7ac60ba97b3411__root[dir=rtl] ._395a75bb1930f57e__nav-button{transform:rotate(180deg);transform-origin:50%}._337e5337d49b7f3d__month-caption{align-content:center;display:flex;height:var(--wp-ui-calendar-cell-size);justify-content:center;margin-bottom:var(--wpds-dimension-gap-md,12px)}._110e46230c68e498__months{display:flex;flex-wrap:wrap;gap:var(--wpds-dimension-gap-lg,16px);justify-content:center;max-width:fit-content;position:relative}._92915239fedb1fea__month-grid{border-collapse:separate;border-spacing:0 var(--wpds-dimension-gap-xs,4px)}._66b1d4a7b488b496__nav{align-items:center;display:flex;height:var(--wp-ui-calendar-cell-size);inset-block-start:0;inset-inline-end:0;inset-inline-start:0;justify-content:space-between;position:absolute}._7207199709ca5776__weekday{color:var(--wpds-color-foreground-content-neutral-weak,#707070);font-weight:var(--wpds-typography-font-weight-default,400);height:var(--wp-ui-calendar-cell-size);padding:0;text-align:center;text-transform:uppercase;width:var(--wp-ui-calendar-cell-size)}._058175f0f9c495e0__today:after{border:2px solid;border-radius:50%;content:"";height:0;inset-block-start:2px;inset-inline-end:2px;position:absolute;width:0;z-index:1}.acb642920fb0bef5__selected:not(._165d91a726feca9c__range-middle){&:has(._1b64226e315835f8__day-button,._1b64226e315835f8__day-button:hover:not(:disabled)){color:var(--wpds-color-foreground-interactive-neutral-strong,#f0f0f0)}&:has(._1b64226e315835f8__day-button:disabled){color:var(--wpds-color-foreground-interactive-neutral-strong-disabled,#8d8d8d)}._1b64226e315835f8__day-button{&:before{background-color:var(--wpds-color-background-interactive-neutral-strong,#2d2d2d);border:1px solid transparent}&:disabled:before{background-color:var(--wpds-color-background-interactive-neutral-strong-disabled,#e6e6e6)}&:hover:not(:disabled):before{background-color:var(--wpds-color-background-interactive-neutral-strong-active,#1e1e1e)}}}.c259c5c255fda10f__outside{color:var(--wpds-color-foreground-interactive-neutral-weak,#707070)}._4d8957a0ca4ec8f0__hidden{visibility:hidden}.f2523033db055ffe__range-start:not(.c04a453de7b11520__range-end) ._1b64226e315835f8__day-button{&,&:before{border-end-end-radius:0;border-start-end-radius:0}}._165d91a726feca9c__range-middle ._1b64226e315835f8__day-button{&:before{background-color:var(--wpds-color-background-interactive-neutral-weak-active,#ededed);border-color:transparent;border-radius:0;border-style:solid;border-width:1px 0}}.c04a453de7b11520__range-end:not(.f2523033db055ffe__range-start) ._1b64226e315835f8__day-button{&,&:before{border-end-start-radius:0;border-start-start-radius:0}}._81b244e7c541d95e__preview svg{color:var(--wpds-color-stroke-interactive-neutral,#8d8d8d);inset:0;pointer-events:none;position:absolute;@media (forced-colors:active){color:inherit}}._81b244e7c541d95e__preview.acb642920fb0bef5__selected:not(._165d91a726feca9c__range-middle) svg{display:none}._2c7ac60ba97b3411__root[dir=rtl] ._81b244e7c541d95e__preview svg{transform:scaleX(-1)}._81b244e7c541d95e__preview._165d91a726feca9c__range-middle ._1b64226e315835f8__day-button:before{border:none}@keyframes _255a1a462a5377db__slide-in-left{0%{transform:translateX(-100%)}to{transform:translateX(0)}}@keyframes c21e45f616d6db39__slide-in-right{0%{transform:translateX(100%)}to{transform:translateX(0)}}@keyframes aed80001de9ae226__slide-out-left{0%{transform:translateX(0)}to{transform:translateX(-100%)}}@keyframes _7d4779a7f29408f2__slide-out-right{0%{transform:translateX(0)}to{transform:translateX(100%)}}@keyframes _83ba6321b055d687__fade-in{0%{opacity:0}to{opacity:1}}@keyframes _96fbead71248d210__fade-out{0%{opacity:1}to{opacity:0}}._1563bccb09e39c30__caption-after-enter,._60ac2a7fc3208801__weeks-before-exit,._735dacf9052adecd__caption-before-exit,._7f73a6ab85101202__weeks-after-exit,._805d698b56ba4a29__weeks-after-enter,._9721326fbc23a5fb__weeks-before-enter,.c7a3082839155d29__caption-after-exit,.cb8a5ec82ad0885e__caption-before-enter{animation-duration:0s;animation-fill-mode:forwards;animation-timing-function:var(--wpds-motion-easing-balanced,cubic-bezier(.4,0,.2,1));@media not (prefers-reduced-motion){animation-duration:var(--wpds-motion-duration-lg,.3s)}}._2c7ac60ba97b3411__root[dir=rtl] ._805d698b56ba4a29__weeks-after-enter,._9721326fbc23a5fb__weeks-before-enter{animation-name:_255a1a462a5377db__slide-in-left}._2c7ac60ba97b3411__root[dir=rtl] ._7f73a6ab85101202__weeks-after-exit,._60ac2a7fc3208801__weeks-before-exit{animation-name:aed80001de9ae226__slide-out-left}._2c7ac60ba97b3411__root[dir=rtl] ._9721326fbc23a5fb__weeks-before-enter,._805d698b56ba4a29__weeks-after-enter{animation-name:c21e45f616d6db39__slide-in-right}._2c7ac60ba97b3411__root[dir=rtl] ._60ac2a7fc3208801__weeks-before-exit,._7f73a6ab85101202__weeks-after-exit{animation-name:_7d4779a7f29408f2__slide-out-right}._1563bccb09e39c30__caption-after-enter,.cb8a5ec82ad0885e__caption-before-enter{animation-name:_83ba6321b055d687__fade-in}._735dacf9052adecd__caption-before-exit,.c7a3082839155d29__caption-after-exit{animation-name:_96fbead71248d210__fade-out}}}');
20873 }
20874 var style_default10 = { "root": "_2c7ac60ba97b3411__root", "day": "_172c492625235710__day", "day-button": "_1b64226e315835f8__day-button", "caption-label": "_66b9a8120581fd4b__caption-label", "nav-button": "_395a75bb1930f57e__nav-button", "month-caption": "_337e5337d49b7f3d__month-caption", "months": "_110e46230c68e498__months", "month-grid": "_92915239fedb1fea__month-grid", "nav": "_66b1d4a7b488b496__nav", "weekday": "_7207199709ca5776__weekday", "today": "_058175f0f9c495e0__today", "selected": "acb642920fb0bef5__selected", "range-middle": "_165d91a726feca9c__range-middle", "outside": "c259c5c255fda10f__outside", "hidden": "_4d8957a0ca4ec8f0__hidden", "range-start": "f2523033db055ffe__range-start", "range-end": "c04a453de7b11520__range-end", "preview": "_81b244e7c541d95e__preview", "weeks-before-enter": "_9721326fbc23a5fb__weeks-before-enter", "weeks-before-exit": "_60ac2a7fc3208801__weeks-before-exit", "weeks-after-enter": "_805d698b56ba4a29__weeks-after-enter", "weeks-after-exit": "_7f73a6ab85101202__weeks-after-exit", "caption-after-enter": "_1563bccb09e39c30__caption-after-enter", "caption-after-exit": "c7a3082839155d29__caption-after-exit", "caption-before-enter": "cb8a5ec82ad0885e__caption-before-enter", "caption-before-exit": "_735dacf9052adecd__caption-before-exit", "slide-in-left": "_255a1a462a5377db__slide-in-left", "slide-out-left": "aed80001de9ae226__slide-out-left", "slide-in-right": "c21e45f616d6db39__slide-in-right", "slide-out-right": "_7d4779a7f29408f2__slide-out-right", "fade-in": "_83ba6321b055d687__fade-in", "fade-out": "_96fbead71248d210__fade-out" };
20875 if (typeof process === "undefined" || true) {
20876 registerStyle11("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}");
20877 }
20878 var resets_default4 = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
20879 if (typeof process === "undefined" || true) {
20880 registerStyle11("08122b3d53", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{.af79fb116edb0dd7__outset-ring--focus:focus,.dfcfdc28396e5d98__outset-ring--focus-visible:focus-visible,.e5cd9ee879f6403a__outset-ring--focus-within:focus-within,:focus-visible ._81935a08e952f267__outset-ring--focus-parent-visible{--_gcd-a-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--focus-color,var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9)));--_gcd-div-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--focus-color,var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9)));outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--focus-color,var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9)));outline-offset:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px))}._3c9f5ee9fc9c136d__outset-ring--focus-within-except-active:focus-within,.abc777e9713fa711__outset-ring--focus-except-active:focus{outline:none}._3c9f5ee9fc9c136d__outset-ring--focus-within-except-active:focus-within:not(:has(:active)),.abc777e9713fa711__outset-ring--focus-except-active:focus:not(:active){--_gcd-a-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--focus-color,var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9)));--_gcd-div-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--focus-color,var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9)));outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--focus-color,var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9)));outline-offset:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px))}}}");
20881 }
20882 var focus_module_default3 = { "outset-ring--focus": "af79fb116edb0dd7__outset-ring--focus", "outset-ring--focus-visible": "dfcfdc28396e5d98__outset-ring--focus-visible", "outset-ring--focus-within": "e5cd9ee879f6403a__outset-ring--focus-within", "outset-ring--focus-parent-visible": "_81935a08e952f267__outset-ring--focus-parent-visible", "outset-ring--focus-except-active": "abc777e9713fa711__outset-ring--focus-except-active", "outset-ring--focus-within-except-active": "_3c9f5ee9fc9c136d__outset-ring--focus-within-except-active" };
20883 if (typeof process === "undefined" || true) {
20884 registerStyle11("e8e31009f5", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-foreground-interactive-neutral-weak,#707070))}&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,transparent);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 transparent);color:var(--_gcd-input-color,var(--wpds-color-foreground-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,transparent);border-color:var(--_gcd-input-border-color-disabled,transparent);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid transparent)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-foreground-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-emphasis,600));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid transparent);transition:var(--_gcd-a-transition,none)}.c59a0ebebd71fa4a__ol{list-style:var(--_gcd-ol-list-style,none);margin:var(--_gcd-ol-margin,0);padding-block:var(--_gcd-ol-padding-block,0);padding-inline:var(--_gcd-ol-padding-inline,0)}._46b5cb0c8e24e8c9__li{margin:var(--_gcd-li-margin,0)}");
20885 }
20886 var global_css_defense_default4 = { "button": "_6defc79820e382c6__button", "input": "d2cff2e5dea83bd1__input", "textarea": "_547d86373d02e108__textarea", "div": "_8c15fd0ed9f28ba4__div", "p": "_43cec3e1eec1066d__p", "heading": "e97669c6d9a38497__heading", "a": "_2c0831b0499dbd6e__a", "ol": "c59a0ebebd71fa4a__ol", "li": "_46b5cb0c8e24e8c9__li" };
20887 var CLASSNAMES = {
20888 root: clsx_default(style_default10.root, resets_default4["box-sizing"]),
20889 day: style_default10.day,
20890 day_button: clsx_default(
20891 style_default10["day-button"],
20892 global_css_defense_default4.button,
20893 focus_module_default3["outset-ring--focus-visible"]
20894 ),
20895 outside: style_default10.outside,
20896 caption_label: style_default10["caption-label"],
20897 button_next: style_default10["nav-button"],
20898 button_previous: style_default10["nav-button"],
20899 nav: style_default10.nav,
20900 month_caption: style_default10["month-caption"],
20901 months: style_default10.months,
20902 month_grid: style_default10["month-grid"],
20903 weekday: style_default10.weekday,
20904 today: style_default10.today,
20905 selected: style_default10.selected,
20906 /*
20907 * Disabled days are styled through `:has(.day-button:disabled)` rather than
20908 * a modifier class on the cell, because the two are not equivalent: the
20909 * focused day keeps its button enabled so it stays reachable. Mapped to
20910 * `undefined` on purpose, so `@daypicker/react` doesn't fall back to its
20911 * own `rdp-disabled` class for a modifier we don't style.
20912 */
20913 disabled: void 0,
20914 hidden: style_default10.hidden,
20915 range_start: style_default10["range-start"],
20916 range_end: style_default10["range-end"],
20917 range_middle: style_default10["range-middle"],
20918 weeks_before_enter: style_default10["weeks-before-enter"],
20919 weeks_before_exit: style_default10["weeks-before-exit"],
20920 weeks_after_enter: style_default10["weeks-after-enter"],
20921 weeks_after_exit: style_default10["weeks-after-exit"],
20922 caption_after_enter: style_default10["caption-after-enter"],
20923 caption_after_exit: style_default10["caption-after-exit"],
20924 caption_before_enter: style_default10["caption-before-enter"],
20925 caption_before_exit: style_default10["caption-before-exit"]
20926 };
20927 var MODIFIER_CLASSNAMES = {
20928 preview: style_default10.preview
20929 };
20930 var COMMON_PROPS = {
20931 animate: true,
20932 // Only show days in the current month
20933 showOutsideDays: false,
20934 // Hide week number column
20935 showWeekNumber: false,
20936 // Show weekdays row
20937 hideWeekdays: false,
20938 // Month and year caption are not interactive
20939 captionLayout: "label",
20940 // Show a variable number of weeks depending on the month
20941 fixedWeeks: false,
20942 // Show navigation buttons
20943 hideNavigation: false,
20944 // Class names
20945 classNames: CLASSNAMES,
20946 components: {
20947 Day: Day2,
20948 Root: Root3,
20949 PreviousMonthButton: PreviousMonthButton2,
20950 NextMonthButton: NextMonthButton2
20951 }
20952 };
20953
20954 // packages/ui/build-module/calendar/utils/misc.mjs
20955 function clampNumberOfMonths(numberOfMonths) {
20956 return Math.min(3, Math.max(1, numberOfMonths));
20957 }
20958
20959 // packages/ui/build-module/calendar/utils/use-controlled-value.mjs
20960 var import_element26 = __toESM(require_element(), 1);
20961 function useControlledValue2({
20962 defaultValue,
20963 onChange,
20964 value: valueProp
20965 }) {
20966 const hasValue = typeof valueProp !== "undefined";
20967 const initialValue = hasValue ? valueProp : defaultValue;
20968 const [state, setState] = (0, import_element26.useState)(initialValue);
20969 const value = hasValue ? valueProp : state;
20970 const uncontrolledSetValue = (0, import_element26.useCallback)(
20971 (nextValue, ...args) => {
20972 setState(nextValue);
20973 onChange?.(nextValue, ...args);
20974 },
20975 [onChange]
20976 );
20977 let setValue;
20978 if (hasValue && typeof onChange === "function") {
20979 setValue = onChange;
20980 } else if (!hasValue && typeof onChange === "function") {
20981 setValue = uncontrolledSetValue;
20982 } else {
20983 setValue = setState;
20984 }
20985 return [value, setValue];
20986 }
20987
20988 // packages/ui/build-module/calendar/utils/use-localization-props.mjs
20989 var import_i18n6 = __toESM(require_i18n(), 1);
20990 var import_element27 = __toESM(require_element(), 1);
20991 function isLocaleRTL(locale) {
20992 const direction = (locale.getTextInfo?.() ?? locale.textInfo)?.direction;
20993 if (direction) {
20994 return direction === "rtl";
20995 }
20996 return [
20997 "ar",
20998 // Arabic
20999 "he",
21000 // Hebrew
21001 "fa",
21002 // Persian (Farsi)
21003 "ur",
21004 // Urdu
21005 "ps",
21006 // Pashto
21007 "syr",
21008 // Syriac
21009 "dv",
21010 // Divehi
21011 "ku",
21012 // Kurdish (Sorani)
21013 "ckb",
21014 // Central Kurdish (Sorani)
21015 "ug",
21016 // Uyghur
21017 "yi"
21018 // Yiddish
21019 ].includes(locale.language);
21020 }
21021 function getSupportedLocaleCode(localeCode) {
21022 if (!localeCode) {
21023 return;
21024 }
21025 let supportedLocaleCode;
21026 try {
21027 supportedLocaleCode = Intl.DateTimeFormat.supportedLocalesOf([
21028 localeCode
21029 ])[0];
21030 } catch {
21031 }
21032 return supportedLocaleCode;
21033 }
21034 function getWeekStartsOn(locale) {
21035 const firstDay = (locale.getWeekInfo?.() ?? locale.weekInfo)?.firstDay;
21036 if (firstDay === void 0 || firstDay < 1 || firstDay > 7) {
21037 return;
21038 }
21039 return firstDay % 7;
21040 }
21041 var useLocalizationProps = ({
21042 locale,
21043 timeZone,
21044 mode
21045 }) => {
21046 return (0, import_element27.useMemo)(() => {
21047 const isLocaleString = typeof locale === "string";
21048 const dateFnsLocale = isLocaleString || locale === void 0 ? enUS : locale;
21049 const supportedLocaleCode = getSupportedLocaleCode(
21050 isLocaleString ? locale : locale?.code
21051 );
21052 const localeCode = supportedLocaleCode ?? "en-US";
21053 const intlLocale = new Intl.Locale(localeCode);
21054 const isRightToLeft = supportedLocaleCode !== void 0 ? isLocaleRTL(intlLocale) : (0, import_i18n6.isRTL)();
21055 const weekStartsOn = isLocaleString || supportedLocaleCode !== void 0 ? getWeekStartsOn(intlLocale) : void 0;
21056 const monthNameFormatter = new Intl.DateTimeFormat(localeCode, {
21057 calendar: "gregory",
21058 year: "numeric",
21059 month: "long",
21060 timeZone
21061 });
21062 const weekdayNarrowFormatter = new Intl.DateTimeFormat(localeCode, {
21063 calendar: "gregory",
21064 weekday: "narrow",
21065 timeZone
21066 });
21067 const weekdayLongFormatter = new Intl.DateTimeFormat(localeCode, {
21068 calendar: "gregory",
21069 weekday: "long",
21070 timeZone
21071 });
21072 const fullDateFormatter = new Intl.DateTimeFormat(localeCode, {
21073 calendar: "gregory",
21074 weekday: "long",
21075 year: "numeric",
21076 month: "long",
21077 day: "numeric",
21078 timeZone
21079 });
21080 const dayNumberFormatter = new Intl.DateTimeFormat(localeCode, {
21081 calendar: "gregory",
21082 day: "numeric",
21083 timeZone
21084 });
21085 return {
21086 "aria-label": mode === "single" ? (0, import_i18n6.__)("Date calendar") : (0, import_i18n6.__)("Date range calendar"),
21087 labels: {
21088 /** The label for the navigation toolbar. */
21089 labelNav: () => (0, import_i18n6.__)("Navigation bar"),
21090 /**
21091 * The label for the month grid.
21092 * @param date
21093 */
21094 labelGrid: monthNameFormatter.format,
21095 /**
21096 * The label for the gridcell, when the calendar is not interactive.
21097 * @param date
21098 * @param modifiers
21099 */
21100 labelGridcell: (date, modifiers) => {
21101 const formattedDate = fullDateFormatter.format(date);
21102 let label = formattedDate;
21103 if (modifiers?.today) {
21104 label = (0, import_i18n6.sprintf)(
21105 // translators: %s is the full date (e.g. "Monday, April 29, 2025")
21106 (0, import_i18n6.__)("Today, %s"),
21107 formattedDate
21108 );
21109 }
21110 return label;
21111 },
21112 /** The label for the "next month" button. */
21113 labelNext: () => (0, import_i18n6.__)("Next month"),
21114 /** The label for the "previous month" button. */
21115 labelPrevious: () => (0, import_i18n6.__)("Previous month"),
21116 /**
21117 * The label for the day button.
21118 * @param date
21119 * @param modifiers
21120 */
21121 labelDayButton: (date, modifiers) => {
21122 const formattedDate = fullDateFormatter.format(date);
21123 let label = formattedDate;
21124 if (modifiers?.today && modifiers?.selected) {
21125 return (0, import_i18n6.sprintf)(
21126 // translators: %s is the full date (e.g. "Monday, April 29, 2025")
21127 (0, import_i18n6.__)("Today, %s, selected"),
21128 formattedDate
21129 );
21130 }
21131 if (modifiers?.today) {
21132 label = (0, import_i18n6.sprintf)(
21133 // translators: %s is the full date (e.g. "Monday, April 29, 2025")
21134 (0, import_i18n6.__)("Today, %s"),
21135 formattedDate
21136 );
21137 }
21138 if (modifiers?.selected) {
21139 label = (0, import_i18n6.sprintf)(
21140 // translators: %s is the full date (e.g. "Monday, April 29, 2025")
21141 (0, import_i18n6.__)("%s, selected"),
21142 formattedDate
21143 );
21144 }
21145 return label;
21146 },
21147 /**
21148 * The label for the weekday.
21149 * @param date
21150 */
21151 labelWeekday: weekdayLongFormatter.format
21152 },
21153 locale: dateFnsLocale,
21154 lang: localeCode,
21155 dir: isRightToLeft ? "rtl" : "ltr",
21156 ...weekStartsOn === void 0 ? {} : { weekStartsOn },
21157 formatters: {
21158 formatDay: dayNumberFormatter.format,
21159 formatWeekdayName: weekdayNarrowFormatter.format,
21160 formatCaption: monthNameFormatter.format
21161 },
21162 timeZone
21163 };
21164 }, [locale, timeZone, mode]);
21165 };
21166
21167 // packages/ui/build-module/calendar/utils/use-preserve-day-focus.mjs
21168 var import_compose2 = __toESM(require_compose(), 1);
21169 var import_element28 = __toESM(require_element(), 1);
21170 function usePreserveDayFocus(forwardedRef, month) {
21171 const rootRef = (0, import_element28.useRef)(null);
21172 const hadDayFocusRef = (0, import_element28.useRef)(false);
21173 const mergedRef = (0, import_compose2.useMergeRefs)([rootRef, forwardedRef]);
21174 const monthIndex = month ? month.getFullYear() * 12 + month.getMonth() : void 0;
21175 const onDayFocus = (0, import_element28.useCallback)(() => {
21176 hadDayFocusRef.current = true;
21177 }, []);
21178 const onDayBlur = (0, import_element28.useCallback)(() => {
21179 hadDayFocusRef.current = false;
21180 }, []);
21181 (0, import_element28.useEffect)(() => {
21182 if (!hadDayFocusRef.current) {
21183 return;
21184 }
21185 const root = rootRef.current;
21186 if (!root) {
21187 return;
21188 }
21189 const { activeElement: activeElement2, body } = root.ownerDocument;
21190 if (activeElement2 !== body) {
21191 const grid = activeElement2?.closest('[role="grid"]');
21192 hadDayFocusRef.current = !!grid && root.contains(grid);
21193 return;
21194 }
21195 hadDayFocusRef.current = false;
21196 const focusTarget = root.querySelector(
21197 '[role="grid"] button[tabindex="0"]:not(:disabled)'
21198 );
21199 const enabledControl = root.querySelector(
21200 'button:not(:disabled):not([aria-disabled="true"])'
21201 );
21202 const focusableControl = root.querySelector(
21203 "button:not(:disabled)"
21204 );
21205 (focusTarget ?? enabledControl ?? focusableControl)?.focus();
21206 }, [monthIndex]);
21207 return { ref: mergedRef, onDayFocus, onDayBlur };
21208 }
21209
21210 // packages/ui/build-module/calendar/calendar.mjs
21211 var import_jsx_runtime64 = __toESM(require_jsx_runtime(), 1);
21212 var Calendar = (0, import_element29.forwardRef)(
21213 function Calendar2({
21214 defaultValue,
21215 value: valueProp,
21216 onValueChange,
21217 numberOfMonths = 1,
21218 locale,
21219 timeZone,
21220 month,
21221 render: render4,
21222 role = "application",
21223 "aria-label": ariaLabel,
21224 labels: customLabels,
21225 ...props
21226 }, ref) {
21227 const { "aria-label": defaultAriaLabel, ...localizationProps } = useLocalizationProps({
21228 locale,
21229 timeZone,
21230 mode: "single"
21231 });
21232 const labels = (0, import_element29.useMemo)(
21233 () => customLabels ? { ...localizationProps.labels, ...customLabels } : localizationProps.labels,
21234 [localizationProps.labels, customLabels]
21235 );
21236 const onChange = (0, import_element29.useCallback)(
21237 (selected2, triggerDate, modifiers, e) => {
21238 onValueChange?.(
21239 selected2 ?? null,
21240 triggerDate,
21241 modifiers,
21242 e
21243 );
21244 },
21245 [onValueChange]
21246 );
21247 const [selected, setSelected] = useControlledValue2({
21248 defaultValue,
21249 value: valueProp,
21250 onChange
21251 });
21252 const dayFocusProps = usePreserveDayFocus(ref, month);
21253 const rootContextValue = (0, import_element29.useMemo)(
21254 () => ({
21255 render: render4,
21256 ref: dayFocusProps.ref,
21257 role,
21258 defaultAriaLabel
21259 }),
21260 [render4, dayFocusProps.ref, role, defaultAriaLabel]
21261 );
21262 return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(RootContext.Provider, { value: rootContextValue, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
21263 DayPicker,
21264 {
21265 ...COMMON_PROPS,
21266 ...localizationProps,
21267 ...props,
21268 "aria-label": ariaLabel,
21269 mode: "single",
21270 month,
21271 numberOfMonths: clampNumberOfMonths(numberOfMonths),
21272 labels,
21273 selected: selected ?? void 0,
21274 onSelect: setSelected,
21275 onDayFocus: dayFocusProps.onDayFocus,
21276 onDayBlur: dayFocusProps.onDayBlur
21277 }
21278 ) });
21279 }
21280 );
21281
21282 // packages/ui/build-module/calendar/range-calendar.mjs
21283 var import_element30 = __toESM(require_element(), 1);
21284 var import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1);
21285 function usePreviewRange({
21286 value,
21287 hoveredDate,
21288 excludeDisabled,
21289 resetOnSelect,
21290 min: min4,
21291 max: max4,
21292 disabled: disabled2
21293 }) {
21294 return (0, import_element30.useMemo)(() => {
21295 if (!hoveredDate || !value?.from) {
21296 return;
21297 }
21298 if (resetOnSelect && value.to) {
21299 return {
21300 from: hoveredDate,
21301 to: hoveredDate
21302 };
21303 }
21304 let previewHighlight;
21305 let potentialNewRange;
21306 if (hoveredDate < value.from) {
21307 previewHighlight = {
21308 from: hoveredDate,
21309 to: value.from
21310 };
21311 potentialNewRange = {
21312 from: hoveredDate,
21313 to: value.to ?? value.from
21314 };
21315 } else if (value.to && hoveredDate > value.from && hoveredDate < value.to) {
21316 previewHighlight = {
21317 from: value.from,
21318 to: hoveredDate
21319 };
21320 potentialNewRange = {
21321 from: value.from,
21322 to: hoveredDate
21323 };
21324 } else if (hoveredDate > value.from) {
21325 previewHighlight = {
21326 from: value.to ?? value.from,
21327 to: hoveredDate
21328 };
21329 potentialNewRange = {
21330 from: value.from,
21331 to: hoveredDate
21332 };
21333 }
21334 if (min4 !== void 0 && min4 > 0 && potentialNewRange && differenceInCalendarDays(
21335 potentialNewRange.to,
21336 potentialNewRange.from
21337 ) < min4) {
21338 previewHighlight = {
21339 from: hoveredDate,
21340 to: hoveredDate
21341 };
21342 }
21343 if (max4 !== void 0 && max4 > 0 && potentialNewRange && differenceInCalendarDays(
21344 potentialNewRange.to,
21345 potentialNewRange.from
21346 ) > max4) {
21347 previewHighlight = {
21348 from: hoveredDate,
21349 to: hoveredDate
21350 };
21351 }
21352 if (excludeDisabled && disabled2 && potentialNewRange && rangeContainsModifiers(potentialNewRange, disabled2)) {
21353 previewHighlight = {
21354 from: hoveredDate,
21355 to: hoveredDate
21356 };
21357 }
21358 return previewHighlight;
21359 }, [
21360 value,
21361 hoveredDate,
21362 excludeDisabled,
21363 resetOnSelect,
21364 min4,
21365 max4,
21366 disabled2
21367 ]);
21368 }
21369 var RangeCalendar = (0, import_element30.forwardRef)(
21370 function RangeCalendar2({
21371 defaultValue,
21372 value: valueProp,
21373 onValueChange,
21374 numberOfMonths = 1,
21375 excludeDisabled,
21376 resetOnSelect = true,
21377 min: min4,
21378 max: max4,
21379 disabled: disabled2,
21380 locale,
21381 timeZone,
21382 month,
21383 render: render4,
21384 role = "application",
21385 "aria-label": ariaLabel,
21386 labels: customLabels,
21387 ...props
21388 }, ref) {
21389 const { "aria-label": defaultAriaLabel, ...localizationProps } = useLocalizationProps({
21390 locale,
21391 timeZone,
21392 mode: "range"
21393 });
21394 const labels = (0, import_element30.useMemo)(
21395 () => customLabels ? { ...localizationProps.labels, ...customLabels } : localizationProps.labels,
21396 [localizationProps.labels, customLabels]
21397 );
21398 const onChange = (0, import_element30.useCallback)(
21399 (selected2, triggerDate, modifiers2, e) => {
21400 onValueChange?.(
21401 selected2 ?? null,
21402 triggerDate,
21403 modifiers2,
21404 e
21405 );
21406 },
21407 [onValueChange]
21408 );
21409 const [selected, setSelected] = useControlledValue2({
21410 defaultValue,
21411 value: valueProp,
21412 onChange
21413 });
21414 const dayFocusProps = usePreserveDayFocus(ref, month);
21415 const [hoveredDate, setHoveredDate] = (0, import_element30.useState)(
21416 void 0
21417 );
21418 const previewRange = usePreviewRange({
21419 value: selected,
21420 hoveredDate,
21421 excludeDisabled,
21422 resetOnSelect,
21423 min: min4,
21424 max: max4,
21425 disabled: disabled2
21426 });
21427 const modifiers = (0, import_element30.useMemo)(() => {
21428 return {
21429 preview: previewRange,
21430 preview_start: previewRange?.from,
21431 preview_end: previewRange?.to
21432 };
21433 }, [previewRange]);
21434 const rootContextValue = (0, import_element30.useMemo)(
21435 () => ({
21436 render: render4,
21437 ref: dayFocusProps.ref,
21438 role,
21439 defaultAriaLabel
21440 }),
21441 [render4, dayFocusProps.ref, role, defaultAriaLabel]
21442 );
21443 return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(RootContext.Provider, { value: rootContextValue, children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
21444 DayPicker,
21445 {
21446 ...COMMON_PROPS,
21447 ...localizationProps,
21448 ...props,
21449 "aria-label": ariaLabel,
21450 mode: "range",
21451 month,
21452 numberOfMonths: clampNumberOfMonths(numberOfMonths),
21453 disabled: disabled2,
21454 excludeDisabled,
21455 resetOnSelect,
21456 min: min4,
21457 max: max4,
21458 labels,
21459 selected: selected ?? void 0,
21460 onSelect: setSelected,
21461 onDayFocus: dayFocusProps.onDayFocus,
21462 onDayBlur: dayFocusProps.onDayBlur,
21463 onDayMouseEnter: (date) => setHoveredDate(date),
21464 onDayMouseLeave: () => setHoveredDate(void 0),
21465 modifiers,
21466 modifiersClassNames: MODIFIER_CLASSNAMES
21467 }
21468 ) });
21469 }
21470 );
21471
21472 // packages/ui/build-module/card/index.mjs
21473 var card_exports = {};
21474 __export(card_exports, {
21475 Content: () => Content,
21476 FullBleed: () => FullBleed,
21477 Header: () => Header,
21478 Root: () => Root4,
21479 Title: () => Title
21480 });
21481
21482 // packages/ui/build-module/card/root.mjs
21483 var import_element31 = __toESM(require_element(), 1);
21484 var STYLE_HASH_ATTRIBUTE12 = "data-wp-hash";
21485 function getRuntime12() {
21486 const globalScope = globalThis;
21487 if (globalScope.__wpStyleRuntime) {
21488 return globalScope.__wpStyleRuntime;
21489 }
21490 globalScope.__wpStyleRuntime = {
21491 documents: /* @__PURE__ */ new Map(),
21492 styles: /* @__PURE__ */ new Map(),
21493 injectedStyles: /* @__PURE__ */ new WeakMap()
21494 };
21495 if (typeof document !== "undefined") {
21496 registerDocument12(document);
21497 }
21498 return globalScope.__wpStyleRuntime;
21499 }
21500 function documentContainsStyleHash12(targetDocument, hash) {
21501 if (!targetDocument.head) {
21502 return false;
21503 }
21504 for (const style of targetDocument.head.querySelectorAll(
21505 `style[${STYLE_HASH_ATTRIBUTE12}]`
21506 )) {
21507 if (style.getAttribute(STYLE_HASH_ATTRIBUTE12) === hash) {
21508 return true;
21509 }
21510 }
21511 return false;
21512 }
21513 function injectStyle12(targetDocument, hash, css) {
21514 if (!targetDocument.head) {
21515 return;
21516 }
21517 const runtime = getRuntime12();
21518 let injectedStyles = runtime.injectedStyles.get(targetDocument);
21519 if (!injectedStyles) {
21520 injectedStyles = /* @__PURE__ */ new Set();
21521 runtime.injectedStyles.set(targetDocument, injectedStyles);
21522 }
21523 if (injectedStyles.has(hash)) {
21524 return;
21525 }
21526 if (documentContainsStyleHash12(targetDocument, hash)) {
21527 injectedStyles.add(hash);
21528 return;
21529 }
21530 const style = targetDocument.createElement("style");
21531 style.setAttribute(STYLE_HASH_ATTRIBUTE12, hash);
21532 style.appendChild(targetDocument.createTextNode(css));
21533 targetDocument.head.appendChild(style);
21534 injectedStyles.add(hash);
21535 }
21536 function registerDocument12(targetDocument) {
21537 const runtime = getRuntime12();
21538 runtime.documents.set(
21539 targetDocument,
21540 (runtime.documents.get(targetDocument) ?? 0) + 1
21541 );
21542 for (const [hash, css] of runtime.styles) {
21543 injectStyle12(targetDocument, hash, css);
21544 }
21545 return () => {
21546 const count = runtime.documents.get(targetDocument);
21547 if (count === void 0) {
21548 return;
21549 }
21550 if (count <= 1) {
21551 runtime.documents.delete(targetDocument);
21552 return;
21553 }
21554 runtime.documents.set(targetDocument, count - 1);
21555 };
21556 }
21557 function registerStyle12(hash, css) {
21558 const runtime = getRuntime12();
21559 runtime.styles.set(hash, css);
21560 for (const targetDocument of runtime.documents.keys()) {
21561 injectStyle12(targetDocument, hash, css);
21562 }
21563 }
21564 if (typeof process === "undefined" || true) {
21565 registerStyle12("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}");
21566 }
21567 var resets_default5 = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
21568 if (typeof process === "undefined" || true) {
21569 registerStyle12("cb866dcef6", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._02872bf298eadc43__root{--wp-ui-card-padding:var(--wpds-dimension-padding-2xl,24px);--wp-ui-card-header-content-gap:var(--wpds-dimension-gap-xl,24px);--wp-ui-card-header-content-margin:calc(var(--wp-ui-card-header-content-gap) - var(--wp-ui-card-padding));background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border:1px solid var(--wpds-color-stroke-surface-neutral,#dbdbdb);border-radius:var(--wpds-border-radius-lg,8px);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:flex;flex-direction:column;overflow:clip}._5dffdaf2a6e669ac__content,.bbccc92e6ba5662d__header{padding:var(--wp-ui-card-padding);&:not(:first-child):not(:last-child){padding-block-end:0}}.bbccc92e6ba5662d__header+._5dffdaf2a6e669ac__content{margin-block-start:var(--wp-ui-card-header-content-margin);padding-block-start:0}.c1fa192587e1b4a6__fullbleed{margin-inline:calc(var(--wp-ui-card-padding)*-1);width:calc(100% + var(--wp-ui-card-padding)*2)}._02872bf298eadc43__root>:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):first-child>.c1fa192587e1b4a6__fullbleed:first-child{margin-block-start:calc(var(--wp-ui-card-padding)*-1)}:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):last-child>.c1fa192587e1b4a6__fullbleed:last-child{margin-block-end:calc(var(--wp-ui-card-padding)*-1)}}}");
21570 }
21571 var style_default11 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" };
21572 var Root4 = (0, import_element31.forwardRef)(function Card({ render: render4, ...restProps }, ref) {
21573 const mergedClassName = clsx_default(style_default11.root, resets_default5["box-sizing"]);
21574 const element = useRender({
21575 defaultTagName: "div",
21576 render: render4,
21577 ref,
21578 props: mergeProps({ className: mergedClassName }, restProps)
21579 });
21580 return element;
21581 });
21582
21583 // packages/ui/build-module/card/header.mjs
21584 var import_element32 = __toESM(require_element(), 1);
21585 var STYLE_HASH_ATTRIBUTE13 = "data-wp-hash";
21586 function getRuntime13() {
21587 const globalScope = globalThis;
21588 if (globalScope.__wpStyleRuntime) {
21589 return globalScope.__wpStyleRuntime;
21590 }
21591 globalScope.__wpStyleRuntime = {
21592 documents: /* @__PURE__ */ new Map(),
21593 styles: /* @__PURE__ */ new Map(),
21594 injectedStyles: /* @__PURE__ */ new WeakMap()
21595 };
21596 if (typeof document !== "undefined") {
21597 registerDocument13(document);
21598 }
21599 return globalScope.__wpStyleRuntime;
21600 }
21601 function documentContainsStyleHash13(targetDocument, hash) {
21602 if (!targetDocument.head) {
21603 return false;
21604 }
21605 for (const style of targetDocument.head.querySelectorAll(
21606 `style[${STYLE_HASH_ATTRIBUTE13}]`
21607 )) {
21608 if (style.getAttribute(STYLE_HASH_ATTRIBUTE13) === hash) {
21609 return true;
21610 }
21611 }
21612 return false;
21613 }
21614 function injectStyle13(targetDocument, hash, css) {
21615 if (!targetDocument.head) {
21616 return;
21617 }
21618 const runtime = getRuntime13();
21619 let injectedStyles = runtime.injectedStyles.get(targetDocument);
21620 if (!injectedStyles) {
21621 injectedStyles = /* @__PURE__ */ new Set();
21622 runtime.injectedStyles.set(targetDocument, injectedStyles);
21623 }
21624 if (injectedStyles.has(hash)) {
21625 return;
21626 }
21627 if (documentContainsStyleHash13(targetDocument, hash)) {
21628 injectedStyles.add(hash);
21629 return;
21630 }
21631 const style = targetDocument.createElement("style");
21632 style.setAttribute(STYLE_HASH_ATTRIBUTE13, hash);
21633 style.appendChild(targetDocument.createTextNode(css));
21634 targetDocument.head.appendChild(style);
21635 injectedStyles.add(hash);
21636 }
21637 function registerDocument13(targetDocument) {
21638 const runtime = getRuntime13();
21639 runtime.documents.set(
21640 targetDocument,
21641 (runtime.documents.get(targetDocument) ?? 0) + 1
21642 );
21643 for (const [hash, css] of runtime.styles) {
21644 injectStyle13(targetDocument, hash, css);
21645 }
21646 return () => {
21647 const count = runtime.documents.get(targetDocument);
21648 if (count === void 0) {
21649 return;
21650 }
21651 if (count <= 1) {
21652 runtime.documents.delete(targetDocument);
21653 return;
21654 }
21655 runtime.documents.set(targetDocument, count - 1);
21656 };
21657 }
21658 function registerStyle13(hash, css) {
21659 const runtime = getRuntime13();
21660 runtime.styles.set(hash, css);
21661 for (const targetDocument of runtime.documents.keys()) {
21662 injectStyle13(targetDocument, hash, css);
21663 }
21664 }
21665 if (typeof process === "undefined" || true) {
21666 registerStyle13("cb866dcef6", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._02872bf298eadc43__root{--wp-ui-card-padding:var(--wpds-dimension-padding-2xl,24px);--wp-ui-card-header-content-gap:var(--wpds-dimension-gap-xl,24px);--wp-ui-card-header-content-margin:calc(var(--wp-ui-card-header-content-gap) - var(--wp-ui-card-padding));background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border:1px solid var(--wpds-color-stroke-surface-neutral,#dbdbdb);border-radius:var(--wpds-border-radius-lg,8px);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:flex;flex-direction:column;overflow:clip}._5dffdaf2a6e669ac__content,.bbccc92e6ba5662d__header{padding:var(--wp-ui-card-padding);&:not(:first-child):not(:last-child){padding-block-end:0}}.bbccc92e6ba5662d__header+._5dffdaf2a6e669ac__content{margin-block-start:var(--wp-ui-card-header-content-margin);padding-block-start:0}.c1fa192587e1b4a6__fullbleed{margin-inline:calc(var(--wp-ui-card-padding)*-1);width:calc(100% + var(--wp-ui-card-padding)*2)}._02872bf298eadc43__root>:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):first-child>.c1fa192587e1b4a6__fullbleed:first-child{margin-block-start:calc(var(--wp-ui-card-padding)*-1)}:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):last-child>.c1fa192587e1b4a6__fullbleed:last-child{margin-block-end:calc(var(--wp-ui-card-padding)*-1)}}}");
21667 }
21668 var style_default12 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" };
21669 var Header = (0, import_element32.forwardRef)(
21670 function CardHeader({ render: render4, ...props }, ref) {
21671 const element = useRender({
21672 defaultTagName: "div",
21673 render: render4,
21674 ref,
21675 props: mergeProps({ className: style_default12.header }, props)
21676 });
21677 return element;
21678 }
21679 );
21680
21681 // packages/ui/build-module/card/content.mjs
21682 var import_element33 = __toESM(require_element(), 1);
21683 var STYLE_HASH_ATTRIBUTE14 = "data-wp-hash";
21684 function getRuntime14() {
21685 const globalScope = globalThis;
21686 if (globalScope.__wpStyleRuntime) {
21687 return globalScope.__wpStyleRuntime;
21688 }
21689 globalScope.__wpStyleRuntime = {
21690 documents: /* @__PURE__ */ new Map(),
21691 styles: /* @__PURE__ */ new Map(),
21692 injectedStyles: /* @__PURE__ */ new WeakMap()
21693 };
21694 if (typeof document !== "undefined") {
21695 registerDocument14(document);
21696 }
21697 return globalScope.__wpStyleRuntime;
21698 }
21699 function documentContainsStyleHash14(targetDocument, hash) {
21700 if (!targetDocument.head) {
21701 return false;
21702 }
21703 for (const style of targetDocument.head.querySelectorAll(
21704 `style[${STYLE_HASH_ATTRIBUTE14}]`
21705 )) {
21706 if (style.getAttribute(STYLE_HASH_ATTRIBUTE14) === hash) {
21707 return true;
21708 }
21709 }
21710 return false;
21711 }
21712 function injectStyle14(targetDocument, hash, css) {
21713 if (!targetDocument.head) {
21714 return;
21715 }
21716 const runtime = getRuntime14();
21717 let injectedStyles = runtime.injectedStyles.get(targetDocument);
21718 if (!injectedStyles) {
21719 injectedStyles = /* @__PURE__ */ new Set();
21720 runtime.injectedStyles.set(targetDocument, injectedStyles);
21721 }
21722 if (injectedStyles.has(hash)) {
21723 return;
21724 }
21725 if (documentContainsStyleHash14(targetDocument, hash)) {
21726 injectedStyles.add(hash);
21727 return;
21728 }
21729 const style = targetDocument.createElement("style");
21730 style.setAttribute(STYLE_HASH_ATTRIBUTE14, hash);
21731 style.appendChild(targetDocument.createTextNode(css));
21732 targetDocument.head.appendChild(style);
21733 injectedStyles.add(hash);
21734 }
21735 function registerDocument14(targetDocument) {
21736 const runtime = getRuntime14();
21737 runtime.documents.set(
21738 targetDocument,
21739 (runtime.documents.get(targetDocument) ?? 0) + 1
21740 );
21741 for (const [hash, css] of runtime.styles) {
21742 injectStyle14(targetDocument, hash, css);
21743 }
21744 return () => {
21745 const count = runtime.documents.get(targetDocument);
21746 if (count === void 0) {
21747 return;
21748 }
21749 if (count <= 1) {
21750 runtime.documents.delete(targetDocument);
21751 return;
21752 }
21753 runtime.documents.set(targetDocument, count - 1);
21754 };
21755 }
21756 function registerStyle14(hash, css) {
21757 const runtime = getRuntime14();
21758 runtime.styles.set(hash, css);
21759 for (const targetDocument of runtime.documents.keys()) {
21760 injectStyle14(targetDocument, hash, css);
21761 }
21762 }
21763 if (typeof process === "undefined" || true) {
21764 registerStyle14("cb866dcef6", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._02872bf298eadc43__root{--wp-ui-card-padding:var(--wpds-dimension-padding-2xl,24px);--wp-ui-card-header-content-gap:var(--wpds-dimension-gap-xl,24px);--wp-ui-card-header-content-margin:calc(var(--wp-ui-card-header-content-gap) - var(--wp-ui-card-padding));background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border:1px solid var(--wpds-color-stroke-surface-neutral,#dbdbdb);border-radius:var(--wpds-border-radius-lg,8px);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:flex;flex-direction:column;overflow:clip}._5dffdaf2a6e669ac__content,.bbccc92e6ba5662d__header{padding:var(--wp-ui-card-padding);&:not(:first-child):not(:last-child){padding-block-end:0}}.bbccc92e6ba5662d__header+._5dffdaf2a6e669ac__content{margin-block-start:var(--wp-ui-card-header-content-margin);padding-block-start:0}.c1fa192587e1b4a6__fullbleed{margin-inline:calc(var(--wp-ui-card-padding)*-1);width:calc(100% + var(--wp-ui-card-padding)*2)}._02872bf298eadc43__root>:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):first-child>.c1fa192587e1b4a6__fullbleed:first-child{margin-block-start:calc(var(--wp-ui-card-padding)*-1)}:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):last-child>.c1fa192587e1b4a6__fullbleed:last-child{margin-block-end:calc(var(--wp-ui-card-padding)*-1)}}}");
21765 }
21766 var style_default13 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" };
21767 var Content = (0, import_element33.forwardRef)(
21768 function CardContent({ render: render4, ...props }, ref) {
21769 const element = useRender({
21770 defaultTagName: "div",
21771 render: render4,
21772 ref,
21773 props: mergeProps({ className: style_default13.content }, props)
21774 });
21775 return element;
21776 }
21777 );
21778
21779 // packages/ui/build-module/card/full-bleed.mjs
21780 var import_element34 = __toESM(require_element(), 1);
21781 var STYLE_HASH_ATTRIBUTE15 = "data-wp-hash";
21782 function getRuntime15() {
21783 const globalScope = globalThis;
21784 if (globalScope.__wpStyleRuntime) {
21785 return globalScope.__wpStyleRuntime;
21786 }
21787 globalScope.__wpStyleRuntime = {
21788 documents: /* @__PURE__ */ new Map(),
21789 styles: /* @__PURE__ */ new Map(),
21790 injectedStyles: /* @__PURE__ */ new WeakMap()
21791 };
21792 if (typeof document !== "undefined") {
21793 registerDocument15(document);
21794 }
21795 return globalScope.__wpStyleRuntime;
21796 }
21797 function documentContainsStyleHash15(targetDocument, hash) {
21798 if (!targetDocument.head) {
21799 return false;
21800 }
21801 for (const style of targetDocument.head.querySelectorAll(
21802 `style[${STYLE_HASH_ATTRIBUTE15}]`
21803 )) {
21804 if (style.getAttribute(STYLE_HASH_ATTRIBUTE15) === hash) {
21805 return true;
21806 }
21807 }
21808 return false;
21809 }
21810 function injectStyle15(targetDocument, hash, css) {
21811 if (!targetDocument.head) {
21812 return;
21813 }
21814 const runtime = getRuntime15();
21815 let injectedStyles = runtime.injectedStyles.get(targetDocument);
21816 if (!injectedStyles) {
21817 injectedStyles = /* @__PURE__ */ new Set();
21818 runtime.injectedStyles.set(targetDocument, injectedStyles);
21819 }
21820 if (injectedStyles.has(hash)) {
21821 return;
21822 }
21823 if (documentContainsStyleHash15(targetDocument, hash)) {
21824 injectedStyles.add(hash);
21825 return;
21826 }
21827 const style = targetDocument.createElement("style");
21828 style.setAttribute(STYLE_HASH_ATTRIBUTE15, hash);
21829 style.appendChild(targetDocument.createTextNode(css));
21830 targetDocument.head.appendChild(style);
21831 injectedStyles.add(hash);
21832 }
21833 function registerDocument15(targetDocument) {
21834 const runtime = getRuntime15();
21835 runtime.documents.set(
21836 targetDocument,
21837 (runtime.documents.get(targetDocument) ?? 0) + 1
21838 );
21839 for (const [hash, css] of runtime.styles) {
21840 injectStyle15(targetDocument, hash, css);
21841 }
21842 return () => {
21843 const count = runtime.documents.get(targetDocument);
21844 if (count === void 0) {
21845 return;
21846 }
21847 if (count <= 1) {
21848 runtime.documents.delete(targetDocument);
21849 return;
21850 }
21851 runtime.documents.set(targetDocument, count - 1);
21852 };
21853 }
21854 function registerStyle15(hash, css) {
21855 const runtime = getRuntime15();
21856 runtime.styles.set(hash, css);
21857 for (const targetDocument of runtime.documents.keys()) {
21858 injectStyle15(targetDocument, hash, css);
21859 }
21860 }
21861 if (typeof process === "undefined" || true) {
21862 registerStyle15("cb866dcef6", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._02872bf298eadc43__root{--wp-ui-card-padding:var(--wpds-dimension-padding-2xl,24px);--wp-ui-card-header-content-gap:var(--wpds-dimension-gap-xl,24px);--wp-ui-card-header-content-margin:calc(var(--wp-ui-card-header-content-gap) - var(--wp-ui-card-padding));background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border:1px solid var(--wpds-color-stroke-surface-neutral,#dbdbdb);border-radius:var(--wpds-border-radius-lg,8px);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:flex;flex-direction:column;overflow:clip}._5dffdaf2a6e669ac__content,.bbccc92e6ba5662d__header{padding:var(--wp-ui-card-padding);&:not(:first-child):not(:last-child){padding-block-end:0}}.bbccc92e6ba5662d__header+._5dffdaf2a6e669ac__content{margin-block-start:var(--wp-ui-card-header-content-margin);padding-block-start:0}.c1fa192587e1b4a6__fullbleed{margin-inline:calc(var(--wp-ui-card-padding)*-1);width:calc(100% + var(--wp-ui-card-padding)*2)}._02872bf298eadc43__root>:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):first-child>.c1fa192587e1b4a6__fullbleed:first-child{margin-block-start:calc(var(--wp-ui-card-padding)*-1)}:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):last-child>.c1fa192587e1b4a6__fullbleed:last-child{margin-block-end:calc(var(--wp-ui-card-padding)*-1)}}}");
21863 }
21864 var style_default14 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" };
21865 var FullBleed = (0, import_element34.forwardRef)(
21866 function CardFullBleed({ render: render4, ...props }, ref) {
21867 const element = useRender({
21868 defaultTagName: "div",
21869 render: render4,
21870 ref,
21871 props: mergeProps(
21872 { className: style_default14.fullbleed },
21873 props
21874 )
21875 });
21876 return element;
21877 }
21878 );
21879
21880 // packages/ui/build-module/card/title.mjs
21881 var import_element35 = __toESM(require_element(), 1);
21882 var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1);
21883 var DEFAULT_TAG = /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", {});
21884 var Title = (0, import_element35.forwardRef)(
21885 function CardTitle({ render: render4 = DEFAULT_TAG, children, ...props }, ref) {
21886 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
21887 Text,
21888 {
21889 ref,
21890 variant: "heading-lg",
21891 render: render4,
21892 ...props,
21893 children
21894 }
21895 );
21896 }
21897 );
21898
21899 // packages/ui/build-module/collapsible/panel.mjs
21900 var import_element36 = __toESM(require_element(), 1);
21901 var import_jsx_runtime67 = __toESM(require_jsx_runtime(), 1);
21902 var Panel = (0, import_element36.forwardRef)(
21903 function CollapsiblePanel3(props, forwardedRef) {
21904 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(index_parts_exports.Panel, { ref: forwardedRef, ...props });
21905 }
21906 );
21907
21908 // packages/ui/build-module/collapsible/root.mjs
21909 var import_element37 = __toESM(require_element(), 1);
21910 var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1);
21911 var Root5 = (0, import_element37.forwardRef)(
21912 function CollapsibleRoot3(props, forwardedRef) {
21913 return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(index_parts_exports.Root, { ref: forwardedRef, ...props });
21914 }
21915 );
21916
21917 // packages/ui/build-module/collapsible/trigger.mjs
21918 var import_element38 = __toESM(require_element(), 1);
21919 var import_jsx_runtime69 = __toESM(require_jsx_runtime(), 1);
21920 var Trigger2 = (0, import_element38.forwardRef)(
21921 function CollapsibleTrigger3(props, forwardedRef) {
21922 return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(index_parts_exports.Trigger, { ref: forwardedRef, ...props });
21923 }
21924 );
21925
21926 // packages/ui/build-module/collapsible-card/index.mjs
21927 var collapsible_card_exports = {};
21928 __export(collapsible_card_exports, {
21929 Content: () => Content2,
21930 Header: () => Header2,
21931 HeaderDescription: () => HeaderDescription,
21932 Root: () => Root32
21933 });
21934
21935 // packages/ui/build-module/collapsible-card/root.mjs
21936 var import_element39 = __toESM(require_element(), 1);
21937 var import_jsx_runtime70 = __toESM(require_jsx_runtime(), 1);
21938 var Root32 = (0, import_element39.forwardRef)(
21939 function CollapsibleCardRoot({ render: render4, ...restProps }, ref) {
21940 return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
21941 Root5,
21942 {
21943 ref,
21944 render: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Root4, { render: render4 }),
21945 ...restProps
21946 }
21947 );
21948 }
21949 );
21950
21951 // packages/ui/build-module/collapsible-card/header.mjs
21952 var import_compose3 = __toESM(require_compose(), 1);
21953 var import_element41 = __toESM(require_element(), 1);
21954
21955 // packages/ui/build-module/collapsible-card/context.mjs
21956 var import_element40 = __toESM(require_element(), 1);
21957 var HeaderDescriptionIdContext = (0, import_element40.createContext)(null);
21958
21959 // packages/ui/build-module/collapsible-card/header.mjs
21960 var import_jsx_runtime71 = __toESM(require_jsx_runtime(), 1);
21961 var STYLE_HASH_ATTRIBUTE16 = "data-wp-hash";
21962 function getRuntime16() {
21963 const globalScope = globalThis;
21964 if (globalScope.__wpStyleRuntime) {
21965 return globalScope.__wpStyleRuntime;
21966 }
21967 globalScope.__wpStyleRuntime = {
21968 documents: /* @__PURE__ */ new Map(),
21969 styles: /* @__PURE__ */ new Map(),
21970 injectedStyles: /* @__PURE__ */ new WeakMap()
21971 };
21972 if (typeof document !== "undefined") {
21973 registerDocument16(document);
21974 }
21975 return globalScope.__wpStyleRuntime;
21976 }
21977 function documentContainsStyleHash16(targetDocument, hash) {
21978 if (!targetDocument.head) {
21979 return false;
21980 }
21981 for (const style of targetDocument.head.querySelectorAll(
21982 `style[${STYLE_HASH_ATTRIBUTE16}]`
21983 )) {
21984 if (style.getAttribute(STYLE_HASH_ATTRIBUTE16) === hash) {
21985 return true;
21986 }
21987 }
21988 return false;
21989 }
21990 function injectStyle16(targetDocument, hash, css) {
21991 if (!targetDocument.head) {
21992 return;
21993 }
21994 const runtime = getRuntime16();
21995 let injectedStyles = runtime.injectedStyles.get(targetDocument);
21996 if (!injectedStyles) {
21997 injectedStyles = /* @__PURE__ */ new Set();
21998 runtime.injectedStyles.set(targetDocument, injectedStyles);
21999 }
22000 if (injectedStyles.has(hash)) {
22001 return;
22002 }
22003 if (documentContainsStyleHash16(targetDocument, hash)) {
22004 injectedStyles.add(hash);
22005 return;
22006 }
22007 const style = targetDocument.createElement("style");
22008 style.setAttribute(STYLE_HASH_ATTRIBUTE16, hash);
22009 style.appendChild(targetDocument.createTextNode(css));
22010 targetDocument.head.appendChild(style);
22011 injectedStyles.add(hash);
22012 }
22013 function registerDocument16(targetDocument) {
22014 const runtime = getRuntime16();
22015 runtime.documents.set(
22016 targetDocument,
22017 (runtime.documents.get(targetDocument) ?? 0) + 1
22018 );
22019 for (const [hash, css] of runtime.styles) {
22020 injectStyle16(targetDocument, hash, css);
22021 }
22022 return () => {
22023 const count = runtime.documents.get(targetDocument);
22024 if (count === void 0) {
22025 return;
22026 }
22027 if (count <= 1) {
22028 runtime.documents.delete(targetDocument);
22029 return;
22030 }
22031 runtime.documents.set(targetDocument, count - 1);
22032 };
22033 }
22034 function registerStyle16(hash, css) {
22035 const runtime = getRuntime16();
22036 runtime.styles.set(hash, css);
22037 for (const targetDocument of runtime.documents.keys()) {
22038 injectStyle16(targetDocument, hash, css);
22039 }
22040 }
22041 if (typeof process === "undefined" || true) {
22042 registerStyle16("64bdb4d46e", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._626190151275d6d3__heading-wrapper{--_gcd-heading-color:inherit;--_gcd-heading-font-size:inherit;--_gcd-heading-font-weight:inherit;--_gcd-heading-margin:0;font-family:inherit;line-height:inherit}.cab17c7a373cb60d__header-content{flex:1;min-width:0}._92ebbaa30c8a1d05__header-description{color:var(--wpds-color-foreground-content-neutral-weak,#707070)}.dd89d27c4f15912d__header-trigger-positioner{align-self:flex-start;flex-shrink:0;margin-block-start:calc(var(--wpds-typography-line-height-sm, 20px)/2);max-height:0;overflow:visible}.bcfab5f2448bafef__header-trigger-wrapper{border-radius:var(--wpds-border-radius-sm,2px);display:flex;translate:0 -50%}._3106f8d2b0330faa__header-trigger{@media not (prefers-reduced-motion){transition:rotate .15s ease-out}}._5d2dfcb4085c6d0f__header[data-panel-open] ._3106f8d2b0330faa__header-trigger{rotate:180deg}._5d2dfcb4085c6d0f__header[data-disabled] ._3106f8d2b0330faa__header-trigger{color:var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d)}.e34cf37ccd0d81e0__content{height:var(--collapsible-panel-height);margin-block-start:var(--wp-ui-card-header-content-margin);overflow:hidden;&._03cfdbcd710393c9__overflow-visible{overflow:visible}&[hidden]:not([hidden=until-found]){display:none}&[data-ending-style],&[data-starting-style]{height:0}@media not (prefers-reduced-motion){transition:all .15s ease-out}}}@layer compositions{._41bfdbf7b6c087c2__content-inner{padding-block-start:0}._5d2dfcb4085c6d0f__header{align-items:stretch;display:flex;flex-direction:row;gap:var(--wpds-dimension-gap-sm,8px);outline:none;&:not([data-disabled]){cursor:var(--wpds-cursor-control,pointer)}}}}");
22043 }
22044 var style_default15 = { "heading-wrapper": "_626190151275d6d3__heading-wrapper", "header-content": "cab17c7a373cb60d__header-content", "header-description": "_92ebbaa30c8a1d05__header-description", "header-trigger-positioner": "dd89d27c4f15912d__header-trigger-positioner", "header-trigger-wrapper": "bcfab5f2448bafef__header-trigger-wrapper", "header-trigger": "_3106f8d2b0330faa__header-trigger", "header": "_5d2dfcb4085c6d0f__header", "content": "e34cf37ccd0d81e0__content", "overflow-visible": "_03cfdbcd710393c9__overflow-visible", "content-inner": "_41bfdbf7b6c087c2__content-inner" };
22045 if (typeof process === "undefined" || true) {
22046 registerStyle16("e8e31009f5", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-foreground-interactive-neutral-weak,#707070))}&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,transparent);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 transparent);color:var(--_gcd-input-color,var(--wpds-color-foreground-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,transparent);border-color:var(--_gcd-input-border-color-disabled,transparent);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid transparent)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-foreground-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-emphasis,600));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid transparent);transition:var(--_gcd-a-transition,none)}.c59a0ebebd71fa4a__ol{list-style:var(--_gcd-ol-list-style,none);margin:var(--_gcd-ol-margin,0);padding-block:var(--_gcd-ol-padding-block,0);padding-inline:var(--_gcd-ol-padding-inline,0)}._46b5cb0c8e24e8c9__li{margin:var(--_gcd-li-margin,0)}");
22047 }
22048 var global_css_defense_default5 = { "button": "_6defc79820e382c6__button", "input": "d2cff2e5dea83bd1__input", "textarea": "_547d86373d02e108__textarea", "div": "_8c15fd0ed9f28ba4__div", "p": "_43cec3e1eec1066d__p", "heading": "e97669c6d9a38497__heading", "a": "_2c0831b0499dbd6e__a", "ol": "c59a0ebebd71fa4a__ol", "li": "_46b5cb0c8e24e8c9__li" };
22049 if (typeof process === "undefined" || true) {
22050 registerStyle16("08122b3d53", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{.af79fb116edb0dd7__outset-ring--focus:focus,.dfcfdc28396e5d98__outset-ring--focus-visible:focus-visible,.e5cd9ee879f6403a__outset-ring--focus-within:focus-within,:focus-visible ._81935a08e952f267__outset-ring--focus-parent-visible{--_gcd-a-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--focus-color,var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9)));--_gcd-div-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--focus-color,var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9)));outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--focus-color,var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9)));outline-offset:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px))}._3c9f5ee9fc9c136d__outset-ring--focus-within-except-active:focus-within,.abc777e9713fa711__outset-ring--focus-except-active:focus{outline:none}._3c9f5ee9fc9c136d__outset-ring--focus-within-except-active:focus-within:not(:has(:active)),.abc777e9713fa711__outset-ring--focus-except-active:focus:not(:active){--_gcd-a-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--focus-color,var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9)));--_gcd-div-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--focus-color,var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9)));outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--focus-color,var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9)));outline-offset:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px))}}}");
22051 }
22052 var focus_module_default4 = { "outset-ring--focus": "af79fb116edb0dd7__outset-ring--focus", "outset-ring--focus-visible": "dfcfdc28396e5d98__outset-ring--focus-visible", "outset-ring--focus-within": "e5cd9ee879f6403a__outset-ring--focus-within", "outset-ring--focus-parent-visible": "_81935a08e952f267__outset-ring--focus-parent-visible", "outset-ring--focus-except-active": "abc777e9713fa711__outset-ring--focus-except-active", "outset-ring--focus-within-except-active": "_3c9f5ee9fc9c136d__outset-ring--focus-within-except-active" };
22053 var Header2 = (0, import_element41.forwardRef)(
22054 function CollapsibleCardHeader({
22055 children,
22056 className,
22057 render: render4,
22058 "aria-describedby": ariaDescribedByProp,
22059 ...restProps
22060 }, ref) {
22061 const [descriptionIds, setDescriptionIds] = (0, import_element41.useState)(
22062 []
22063 );
22064 const [orderedDescriptionIds, setOrderedDescriptionIds] = (0, import_element41.useState)([]);
22065 const headerContentRef = (0, import_element41.useRef)(null);
22066 const registerDescriptionId = (0, import_element41.useCallback)((id) => {
22067 setDescriptionIds((currentDescriptionIds) => {
22068 if (currentDescriptionIds.includes(id)) {
22069 return currentDescriptionIds;
22070 }
22071 return [...currentDescriptionIds, id];
22072 });
22073 return () => {
22074 setDescriptionIds(
22075 (currentDescriptionIds) => currentDescriptionIds.filter(
22076 (descriptionId) => descriptionId !== id
22077 )
22078 );
22079 };
22080 }, []);
22081 const contextValue = (0, import_element41.useMemo)(
22082 () => ({ registerDescriptionId }),
22083 [registerDescriptionId]
22084 );
22085 (0, import_compose3.useIsomorphicLayoutEffect)(() => {
22086 const registeredDescriptionIds = new Set(descriptionIds);
22087 const nextDescriptionIds = Array.from(
22088 headerContentRef.current?.querySelectorAll("[id]") ?? []
22089 ).map((element) => element.id).filter((id) => registeredDescriptionIds.has(id));
22090 setOrderedDescriptionIds((currentDescriptionIds) => {
22091 if (currentDescriptionIds.length === nextDescriptionIds.length && currentDescriptionIds.every(
22092 (id, index3) => id === nextDescriptionIds[index3]
22093 )) {
22094 return currentDescriptionIds;
22095 }
22096 return nextDescriptionIds;
22097 });
22098 });
22099 const ariaDescribedBy = Array.from(
22100 /* @__PURE__ */ new Set([
22101 ...ariaDescribedByProp?.split(/\s+/).filter(Boolean) ?? [],
22102 ...orderedDescriptionIds
22103 ])
22104 ).join(" ") || void 0;
22105 return useRender({
22106 defaultTagName: "div",
22107 render: render4,
22108 ref,
22109 props: mergeProps(restProps, {
22110 className: clsx_default(
22111 global_css_defense_default5.heading,
22112 style_default15["heading-wrapper"],
22113 className
22114 ),
22115 children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(HeaderDescriptionIdContext.Provider, { value: contextValue, children: /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(
22116 Trigger2,
22117 {
22118 className: style_default15.header,
22119 render: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(Header, {}),
22120 nativeButton: false,
22121 "aria-describedby": ariaDescribedBy,
22122 children: [
22123 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
22124 "div",
22125 {
22126 ref: headerContentRef,
22127 className: style_default15["header-content"],
22128 children
22129 }
22130 ),
22131 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
22132 "div",
22133 {
22134 className: clsx_default(
22135 style_default15["header-trigger-positioner"]
22136 ),
22137 children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
22138 "div",
22139 {
22140 className: clsx_default(
22141 style_default15["header-trigger-wrapper"],
22142 global_css_defense_default5.div,
22143 // While the interactive trigger element is the whole header,
22144 // the focus ring will be displayed only on the icon to visually
22145 // emulate it being the button.
22146 focus_module_default4["outset-ring--focus-parent-visible"]
22147 ),
22148 children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
22149 Icon,
22150 {
22151 icon: chevron_down_default,
22152 className: style_default15["header-trigger"]
22153 }
22154 )
22155 }
22156 )
22157 }
22158 )
22159 ]
22160 }
22161 ) })
22162 })
22163 });
22164 }
22165 );
22166
22167 // packages/ui/build-module/collapsible-card/header-description.mjs
22168 var import_element42 = __toESM(require_element(), 1);
22169 var import_jsx_runtime72 = __toESM(require_jsx_runtime(), 1);
22170 var STYLE_HASH_ATTRIBUTE17 = "data-wp-hash";
22171 function getRuntime17() {
22172 const globalScope = globalThis;
22173 if (globalScope.__wpStyleRuntime) {
22174 return globalScope.__wpStyleRuntime;
22175 }
22176 globalScope.__wpStyleRuntime = {
22177 documents: /* @__PURE__ */ new Map(),
22178 styles: /* @__PURE__ */ new Map(),
22179 injectedStyles: /* @__PURE__ */ new WeakMap()
22180 };
22181 if (typeof document !== "undefined") {
22182 registerDocument17(document);
22183 }
22184 return globalScope.__wpStyleRuntime;
22185 }
22186 function documentContainsStyleHash17(targetDocument, hash) {
22187 if (!targetDocument.head) {
22188 return false;
22189 }
22190 for (const style of targetDocument.head.querySelectorAll(
22191 `style[${STYLE_HASH_ATTRIBUTE17}]`
22192 )) {
22193 if (style.getAttribute(STYLE_HASH_ATTRIBUTE17) === hash) {
22194 return true;
22195 }
22196 }
22197 return false;
22198 }
22199 function injectStyle17(targetDocument, hash, css) {
22200 if (!targetDocument.head) {
22201 return;
22202 }
22203 const runtime = getRuntime17();
22204 let injectedStyles = runtime.injectedStyles.get(targetDocument);
22205 if (!injectedStyles) {
22206 injectedStyles = /* @__PURE__ */ new Set();
22207 runtime.injectedStyles.set(targetDocument, injectedStyles);
22208 }
22209 if (injectedStyles.has(hash)) {
22210 return;
22211 }
22212 if (documentContainsStyleHash17(targetDocument, hash)) {
22213 injectedStyles.add(hash);
22214 return;
22215 }
22216 const style = targetDocument.createElement("style");
22217 style.setAttribute(STYLE_HASH_ATTRIBUTE17, hash);
22218 style.appendChild(targetDocument.createTextNode(css));
22219 targetDocument.head.appendChild(style);
22220 injectedStyles.add(hash);
22221 }
22222 function registerDocument17(targetDocument) {
22223 const runtime = getRuntime17();
22224 runtime.documents.set(
22225 targetDocument,
22226 (runtime.documents.get(targetDocument) ?? 0) + 1
22227 );
22228 for (const [hash, css] of runtime.styles) {
22229 injectStyle17(targetDocument, hash, css);
22230 }
22231 return () => {
22232 const count = runtime.documents.get(targetDocument);
22233 if (count === void 0) {
22234 return;
22235 }
22236 if (count <= 1) {
22237 runtime.documents.delete(targetDocument);
22238 return;
22239 }
22240 runtime.documents.set(targetDocument, count - 1);
22241 };
22242 }
22243 function registerStyle17(hash, css) {
22244 const runtime = getRuntime17();
22245 runtime.styles.set(hash, css);
22246 for (const targetDocument of runtime.documents.keys()) {
22247 injectStyle17(targetDocument, hash, css);
22248 }
22249 }
22250 if (typeof process === "undefined" || true) {
22251 registerStyle17("64bdb4d46e", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._626190151275d6d3__heading-wrapper{--_gcd-heading-color:inherit;--_gcd-heading-font-size:inherit;--_gcd-heading-font-weight:inherit;--_gcd-heading-margin:0;font-family:inherit;line-height:inherit}.cab17c7a373cb60d__header-content{flex:1;min-width:0}._92ebbaa30c8a1d05__header-description{color:var(--wpds-color-foreground-content-neutral-weak,#707070)}.dd89d27c4f15912d__header-trigger-positioner{align-self:flex-start;flex-shrink:0;margin-block-start:calc(var(--wpds-typography-line-height-sm, 20px)/2);max-height:0;overflow:visible}.bcfab5f2448bafef__header-trigger-wrapper{border-radius:var(--wpds-border-radius-sm,2px);display:flex;translate:0 -50%}._3106f8d2b0330faa__header-trigger{@media not (prefers-reduced-motion){transition:rotate .15s ease-out}}._5d2dfcb4085c6d0f__header[data-panel-open] ._3106f8d2b0330faa__header-trigger{rotate:180deg}._5d2dfcb4085c6d0f__header[data-disabled] ._3106f8d2b0330faa__header-trigger{color:var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d)}.e34cf37ccd0d81e0__content{height:var(--collapsible-panel-height);margin-block-start:var(--wp-ui-card-header-content-margin);overflow:hidden;&._03cfdbcd710393c9__overflow-visible{overflow:visible}&[hidden]:not([hidden=until-found]){display:none}&[data-ending-style],&[data-starting-style]{height:0}@media not (prefers-reduced-motion){transition:all .15s ease-out}}}@layer compositions{._41bfdbf7b6c087c2__content-inner{padding-block-start:0}._5d2dfcb4085c6d0f__header{align-items:stretch;display:flex;flex-direction:row;gap:var(--wpds-dimension-gap-sm,8px);outline:none;&:not([data-disabled]){cursor:var(--wpds-cursor-control,pointer)}}}}");
22252 }
22253 var style_default16 = { "heading-wrapper": "_626190151275d6d3__heading-wrapper", "header-content": "cab17c7a373cb60d__header-content", "header-description": "_92ebbaa30c8a1d05__header-description", "header-trigger-positioner": "dd89d27c4f15912d__header-trigger-positioner", "header-trigger-wrapper": "bcfab5f2448bafef__header-trigger-wrapper", "header-trigger": "_3106f8d2b0330faa__header-trigger", "header": "_5d2dfcb4085c6d0f__header", "content": "e34cf37ccd0d81e0__content", "overflow-visible": "_03cfdbcd710393c9__overflow-visible", "content-inner": "_41bfdbf7b6c087c2__content-inner" };
22254 var DEFAULT_TAG2 = /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("div", {});
22255 var HeaderDescription = (0, import_element42.forwardRef)(function CollapsibleCardHeaderDescription({ children, className, id: idProp, render: render4 = DEFAULT_TAG2, ...restProps }, ref) {
22256 const generatedId = (0, import_element42.useId)();
22257 const descriptionId = idProp ?? generatedId;
22258 const context = (0, import_element42.useContext)(HeaderDescriptionIdContext);
22259 if (!context) {
22260 throw new Error(
22261 "CollapsibleCard.HeaderDescription: Missing parent <CollapsibleCard.Header>. Render <CollapsibleCard.HeaderDescription> inside <CollapsibleCard.Header>."
22262 );
22263 }
22264 (0, import_element42.useEffect)(() => {
22265 return context?.registerDescriptionId(descriptionId);
22266 }, [context, descriptionId]);
22267 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
22268 Text,
22269 {
22270 ref,
22271 variant: "body-md",
22272 render: render4,
22273 id: descriptionId,
22274 "aria-hidden": "true",
22275 className: clsx_default(style_default16["header-description"], className),
22276 ...restProps,
22277 children
22278 }
22279 );
22280 });
22281
22282 // packages/ui/build-module/collapsible-card/content.mjs
22283 var import_element43 = __toESM(require_element(), 1);
22284 var import_jsx_runtime73 = __toESM(require_jsx_runtime(), 1);
22285 var STYLE_HASH_ATTRIBUTE18 = "data-wp-hash";
22286 function getRuntime18() {
22287 const globalScope = globalThis;
22288 if (globalScope.__wpStyleRuntime) {
22289 return globalScope.__wpStyleRuntime;
22290 }
22291 globalScope.__wpStyleRuntime = {
22292 documents: /* @__PURE__ */ new Map(),
22293 styles: /* @__PURE__ */ new Map(),
22294 injectedStyles: /* @__PURE__ */ new WeakMap()
22295 };
22296 if (typeof document !== "undefined") {
22297 registerDocument18(document);
22298 }
22299 return globalScope.__wpStyleRuntime;
22300 }
22301 function documentContainsStyleHash18(targetDocument, hash) {
22302 if (!targetDocument.head) {
22303 return false;
22304 }
22305 for (const style of targetDocument.head.querySelectorAll(
22306 `style[${STYLE_HASH_ATTRIBUTE18}]`
22307 )) {
22308 if (style.getAttribute(STYLE_HASH_ATTRIBUTE18) === hash) {
22309 return true;
22310 }
22311 }
22312 return false;
22313 }
22314 function injectStyle18(targetDocument, hash, css) {
22315 if (!targetDocument.head) {
22316 return;
22317 }
22318 const runtime = getRuntime18();
22319 let injectedStyles = runtime.injectedStyles.get(targetDocument);
22320 if (!injectedStyles) {
22321 injectedStyles = /* @__PURE__ */ new Set();
22322 runtime.injectedStyles.set(targetDocument, injectedStyles);
22323 }
22324 if (injectedStyles.has(hash)) {
22325 return;
22326 }
22327 if (documentContainsStyleHash18(targetDocument, hash)) {
22328 injectedStyles.add(hash);
22329 return;
22330 }
22331 const style = targetDocument.createElement("style");
22332 style.setAttribute(STYLE_HASH_ATTRIBUTE18, hash);
22333 style.appendChild(targetDocument.createTextNode(css));
22334 targetDocument.head.appendChild(style);
22335 injectedStyles.add(hash);
22336 }
22337 function registerDocument18(targetDocument) {
22338 const runtime = getRuntime18();
22339 runtime.documents.set(
22340 targetDocument,
22341 (runtime.documents.get(targetDocument) ?? 0) + 1
22342 );
22343 for (const [hash, css] of runtime.styles) {
22344 injectStyle18(targetDocument, hash, css);
22345 }
22346 return () => {
22347 const count = runtime.documents.get(targetDocument);
22348 if (count === void 0) {
22349 return;
22350 }
22351 if (count <= 1) {
22352 runtime.documents.delete(targetDocument);
22353 return;
22354 }
22355 runtime.documents.set(targetDocument, count - 1);
22356 };
22357 }
22358 function registerStyle18(hash, css) {
22359 const runtime = getRuntime18();
22360 runtime.styles.set(hash, css);
22361 for (const targetDocument of runtime.documents.keys()) {
22362 injectStyle18(targetDocument, hash, css);
22363 }
22364 }
22365 if (typeof process === "undefined" || true) {
22366 registerStyle18("64bdb4d46e", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._626190151275d6d3__heading-wrapper{--_gcd-heading-color:inherit;--_gcd-heading-font-size:inherit;--_gcd-heading-font-weight:inherit;--_gcd-heading-margin:0;font-family:inherit;line-height:inherit}.cab17c7a373cb60d__header-content{flex:1;min-width:0}._92ebbaa30c8a1d05__header-description{color:var(--wpds-color-foreground-content-neutral-weak,#707070)}.dd89d27c4f15912d__header-trigger-positioner{align-self:flex-start;flex-shrink:0;margin-block-start:calc(var(--wpds-typography-line-height-sm, 20px)/2);max-height:0;overflow:visible}.bcfab5f2448bafef__header-trigger-wrapper{border-radius:var(--wpds-border-radius-sm,2px);display:flex;translate:0 -50%}._3106f8d2b0330faa__header-trigger{@media not (prefers-reduced-motion){transition:rotate .15s ease-out}}._5d2dfcb4085c6d0f__header[data-panel-open] ._3106f8d2b0330faa__header-trigger{rotate:180deg}._5d2dfcb4085c6d0f__header[data-disabled] ._3106f8d2b0330faa__header-trigger{color:var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d)}.e34cf37ccd0d81e0__content{height:var(--collapsible-panel-height);margin-block-start:var(--wp-ui-card-header-content-margin);overflow:hidden;&._03cfdbcd710393c9__overflow-visible{overflow:visible}&[hidden]:not([hidden=until-found]){display:none}&[data-ending-style],&[data-starting-style]{height:0}@media not (prefers-reduced-motion){transition:all .15s ease-out}}}@layer compositions{._41bfdbf7b6c087c2__content-inner{padding-block-start:0}._5d2dfcb4085c6d0f__header{align-items:stretch;display:flex;flex-direction:row;gap:var(--wpds-dimension-gap-sm,8px);outline:none;&:not([data-disabled]){cursor:var(--wpds-cursor-control,pointer)}}}}");
22367 }
22368 var style_default17 = { "heading-wrapper": "_626190151275d6d3__heading-wrapper", "header-content": "cab17c7a373cb60d__header-content", "header-description": "_92ebbaa30c8a1d05__header-description", "header-trigger-positioner": "dd89d27c4f15912d__header-trigger-positioner", "header-trigger-wrapper": "bcfab5f2448bafef__header-trigger-wrapper", "header-trigger": "_3106f8d2b0330faa__header-trigger", "header": "_5d2dfcb4085c6d0f__header", "content": "e34cf37ccd0d81e0__content", "overflow-visible": "_03cfdbcd710393c9__overflow-visible", "content-inner": "_41bfdbf7b6c087c2__content-inner" };
22369 var Content2 = (0, import_element43.forwardRef)(
22370 function CollapsibleCardContent({ className, render: render4, children, hiddenUntilFound = true, ...restProps }, ref) {
22371 return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
22372 Panel,
22373 {
22374 ref,
22375 className: (state) => clsx_default(
22376 style_default17.content,
22377 state.open && state.transitionStatus === "idle" && style_default17["overflow-visible"],
22378 className
22379 ),
22380 hiddenUntilFound,
22381 ...restProps,
22382 children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
22383 Content,
22384 {
22385 className: style_default17["content-inner"],
22386 render: render4,
22387 children
22388 }
22389 )
22390 }
22391 );
22392 }
22393 );
22394
22395 // packages/ui/build-module/stack/stack.mjs
22396 var import_element44 = __toESM(require_element(), 1);
22397 var STYLE_HASH_ATTRIBUTE19 = "data-wp-hash";
22398 function getRuntime19() {
22399 const globalScope = globalThis;
22400 if (globalScope.__wpStyleRuntime) {
22401 return globalScope.__wpStyleRuntime;
22402 }
22403 globalScope.__wpStyleRuntime = {
22404 documents: /* @__PURE__ */ new Map(),
22405 styles: /* @__PURE__ */ new Map(),
22406 injectedStyles: /* @__PURE__ */ new WeakMap()
22407 };
22408 if (typeof document !== "undefined") {
22409 registerDocument19(document);
22410 }
22411 return globalScope.__wpStyleRuntime;
22412 }
22413 function documentContainsStyleHash19(targetDocument, hash) {
22414 if (!targetDocument.head) {
22415 return false;
22416 }
22417 for (const style of targetDocument.head.querySelectorAll(
22418 `style[${STYLE_HASH_ATTRIBUTE19}]`
22419 )) {
22420 if (style.getAttribute(STYLE_HASH_ATTRIBUTE19) === hash) {
22421 return true;
22422 }
22423 }
22424 return false;
22425 }
22426 function injectStyle19(targetDocument, hash, css) {
22427 if (!targetDocument.head) {
22428 return;
22429 }
22430 const runtime = getRuntime19();
22431 let injectedStyles = runtime.injectedStyles.get(targetDocument);
22432 if (!injectedStyles) {
22433 injectedStyles = /* @__PURE__ */ new Set();
22434 runtime.injectedStyles.set(targetDocument, injectedStyles);
22435 }
22436 if (injectedStyles.has(hash)) {
22437 return;
22438 }
22439 if (documentContainsStyleHash19(targetDocument, hash)) {
22440 injectedStyles.add(hash);
22441 return;
22442 }
22443 const style = targetDocument.createElement("style");
22444 style.setAttribute(STYLE_HASH_ATTRIBUTE19, hash);
22445 style.appendChild(targetDocument.createTextNode(css));
22446 targetDocument.head.appendChild(style);
22447 injectedStyles.add(hash);
22448 }
22449 function registerDocument19(targetDocument) {
22450 const runtime = getRuntime19();
22451 runtime.documents.set(
22452 targetDocument,
22453 (runtime.documents.get(targetDocument) ?? 0) + 1
22454 );
22455 for (const [hash, css] of runtime.styles) {
22456 injectStyle19(targetDocument, hash, css);
22457 }
22458 return () => {
22459 const count = runtime.documents.get(targetDocument);
22460 if (count === void 0) {
22461 return;
22462 }
22463 if (count <= 1) {
22464 runtime.documents.delete(targetDocument);
22465 return;
22466 }
22467 runtime.documents.set(targetDocument, count - 1);
22468 };
22469 }
22470 function registerStyle19(hash, css) {
22471 const runtime = getRuntime19();
22472 runtime.styles.set(hash, css);
22473 for (const targetDocument of runtime.documents.keys()) {
22474 injectStyle19(targetDocument, hash, css);
22475 }
22476 }
22477 if (typeof process === "undefined" || true) {
22478 registerStyle19("32aba35fe1", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._19ce0419607e1896__stack{display:flex}}}");
22479 }
22480 var style_default18 = { "stack": "_19ce0419607e1896__stack" };
22481 var gapTokens = {
22482 xs: "var(--wpds-dimension-gap-xs, 4px)",
22483 sm: "var(--wpds-dimension-gap-sm, 8px)",
22484 md: "var(--wpds-dimension-gap-md, 12px)",
22485 lg: "var(--wpds-dimension-gap-lg, 16px)",
22486 xl: "var(--wpds-dimension-gap-xl, 24px)",
22487 "2xl": "var(--wpds-dimension-gap-2xl, 32px)",
22488 "3xl": "var(--wpds-dimension-gap-3xl, 40px)"
22489 };
22490 var Stack = (0, import_element44.forwardRef)(function Stack2({ direction, gap, align, justify, wrap, render: render4, ...props }, ref) {
22491 const style = {
22492 gap: gap && gapTokens[gap],
22493 alignItems: align,
22494 justifyContent: justify,
22495 flexDirection: direction,
22496 flexWrap: wrap
22497 };
22498 const element = useRender({
22499 render: render4,
22500 ref,
22501 props: mergeProps(props, { style, className: style_default18.stack })
22502 });
22503 return element;
22504 });
22505
22506 // packages/ui/build-module/utils/use-schedule-validation.mjs
22507 var import_compose4 = __toESM(require_compose(), 1);
22508 var import_element45 = __toESM(require_element(), 1);
22509 function useScheduleValidation(validate) {
22510 const validateEvent = (0, import_compose4.useEvent)(validate);
22511 const timerRef = (0, import_element45.useRef)(null);
22512 const unmountedRef = (0, import_element45.useRef)(false);
22513 const scheduleValidation = (0, import_element45.useCallback)(() => {
22514 if (unmountedRef.current) {
22515 return;
22516 }
22517 if (timerRef.current) {
22518 clearTimeout(timerRef.current);
22519 }
22520 timerRef.current = setTimeout(() => {
22521 validateEvent();
22522 timerRef.current = null;
22523 }, 0);
22524 }, [validateEvent]);
22525 (0, import_element45.useEffect)(() => {
22526 unmountedRef.current = false;
22527 return () => {
22528 unmountedRef.current = true;
22529 if (timerRef.current) {
22530 clearTimeout(timerRef.current);
22531 }
22532 };
22533 }, []);
22534 return scheduleValidation;
22535 }
22536
22537 // packages/ui/build-module/form/primitives/input/input.mjs
22538 var import_element48 = __toESM(require_element(), 1);
22539
22540 // packages/ui/build-module/form/primitives/input-layout/input-layout.mjs
22541 var import_element46 = __toESM(require_element(), 1);
22542 var import_jsx_runtime74 = __toESM(require_jsx_runtime(), 1);
22543 var STYLE_HASH_ATTRIBUTE20 = "data-wp-hash";
22544 function getRuntime20() {
22545 const globalScope = globalThis;
22546 if (globalScope.__wpStyleRuntime) {
22547 return globalScope.__wpStyleRuntime;
22548 }
22549 globalScope.__wpStyleRuntime = {
22550 documents: /* @__PURE__ */ new Map(),
22551 styles: /* @__PURE__ */ new Map(),
22552 injectedStyles: /* @__PURE__ */ new WeakMap()
22553 };
22554 if (typeof document !== "undefined") {
22555 registerDocument20(document);
22556 }
22557 return globalScope.__wpStyleRuntime;
22558 }
22559 function documentContainsStyleHash20(targetDocument, hash) {
22560 if (!targetDocument.head) {
22561 return false;
22562 }
22563 for (const style of targetDocument.head.querySelectorAll(
22564 `style[${STYLE_HASH_ATTRIBUTE20}]`
22565 )) {
22566 if (style.getAttribute(STYLE_HASH_ATTRIBUTE20) === hash) {
22567 return true;
22568 }
22569 }
22570 return false;
22571 }
22572 function injectStyle20(targetDocument, hash, css) {
22573 if (!targetDocument.head) {
22574 return;
22575 }
22576 const runtime = getRuntime20();
22577 let injectedStyles = runtime.injectedStyles.get(targetDocument);
22578 if (!injectedStyles) {
22579 injectedStyles = /* @__PURE__ */ new Set();
22580 runtime.injectedStyles.set(targetDocument, injectedStyles);
22581 }
22582 if (injectedStyles.has(hash)) {
22583 return;
22584 }
22585 if (documentContainsStyleHash20(targetDocument, hash)) {
22586 injectedStyles.add(hash);
22587 return;
22588 }
22589 const style = targetDocument.createElement("style");
22590 style.setAttribute(STYLE_HASH_ATTRIBUTE20, hash);
22591 style.appendChild(targetDocument.createTextNode(css));
22592 targetDocument.head.appendChild(style);
22593 injectedStyles.add(hash);
22594 }
22595 function registerDocument20(targetDocument) {
22596 const runtime = getRuntime20();
22597 runtime.documents.set(
22598 targetDocument,
22599 (runtime.documents.get(targetDocument) ?? 0) + 1
22600 );
22601 for (const [hash, css] of runtime.styles) {
22602 injectStyle20(targetDocument, hash, css);
22603 }
22604 return () => {
22605 const count = runtime.documents.get(targetDocument);
22606 if (count === void 0) {
22607 return;
22608 }
22609 if (count <= 1) {
22610 runtime.documents.delete(targetDocument);
22611 return;
22612 }
22613 runtime.documents.set(targetDocument, count - 1);
22614 };
22615 }
22616 function registerStyle20(hash, css) {
22617 const runtime = getRuntime20();
22618 runtime.styles.set(hash, css);
22619 for (const targetDocument of runtime.documents.keys()) {
22620 injectStyle20(targetDocument, hash, css);
22621 }
22622 }
22623 if (typeof process === "undefined" || true) {
22624 registerStyle20("e8e31009f5", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-foreground-interactive-neutral-weak,#707070))}&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,transparent);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 transparent);color:var(--_gcd-input-color,var(--wpds-color-foreground-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,transparent);border-color:var(--_gcd-input-border-color-disabled,transparent);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid transparent)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-foreground-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-emphasis,600));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid transparent);transition:var(--_gcd-a-transition,none)}.c59a0ebebd71fa4a__ol{list-style:var(--_gcd-ol-list-style,none);margin:var(--_gcd-ol-margin,0);padding-block:var(--_gcd-ol-padding-block,0);padding-inline:var(--_gcd-ol-padding-inline,0)}._46b5cb0c8e24e8c9__li{margin:var(--_gcd-li-margin,0)}");
22625 }
22626 var global_css_defense_default6 = { "button": "_6defc79820e382c6__button", "input": "d2cff2e5dea83bd1__input", "textarea": "_547d86373d02e108__textarea", "div": "_8c15fd0ed9f28ba4__div", "p": "_43cec3e1eec1066d__p", "heading": "e97669c6d9a38497__heading", "a": "_2c0831b0499dbd6e__a", "ol": "c59a0ebebd71fa4a__ol", "li": "_46b5cb0c8e24e8c9__li" };
22627 if (typeof process === "undefined" || true) {
22628 registerStyle20("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}");
22629 }
22630 var resets_default6 = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
22631 if (typeof process === "undefined" || true) {
22632 registerStyle20("e4f4f9600b", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{.cb2baafdc08746bb__input-layout{--wp-ui-input-layout-padding-inline:var(--wpds-dimension-padding-md,12px);background-color:var(--wpds-color-background-interactive-neutral,var(--wpds-color-background-surface-neutral-strong,#fff));border-color:var(--wpds-color-stroke-interactive-neutral,#8d8d8d);border-radius:var(--wpds-border-radius-sm,2px);border-style:solid;border-width:var(--wpds-border-width-xs,1px);color:var(--wpds-color-foreground-interactive-neutral,#1e1e1e);display:flex;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:max(var(--wpds-typography-font-size-md,13px),16px);height:var(--wpds-dimension-size-lg,40px);line-height:1;@media (min-width:600px){font-size:var(--wpds-typography-font-size-md,13px)}&._0c807a84cbb94e0c__is-size-compact{height:var(--wpds-dimension-size-md,32px)}&._0c807a84cbb94e0c__is-size-compact,&.ed67cda122dc1e7b__is-size-small{--wp-ui-input-layout-padding-inline:var(--wpds-dimension-padding-sm,8px)}&.ed67cda122dc1e7b__is-size-small{height:var(--wpds-dimension-size-sm,24px)}&._6fb7104732387680__is-disabled,&:has([data-can-disable-input-layout][data-disabled]){color:var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d);@media (forced-colors:active){color:GrayText}&:not(._8097270636ca6100__is-borderless){background-color:var(--wpds-color-background-interactive-neutral-disabled,var(--wpds-color-background-surface-neutral-strong,#fff));border-color:var(--wpds-color-stroke-interactive-neutral-disabled,#dbdbdb);@media (forced-colors:active){border-bottom-color:GrayText;border-left-color:GrayText;border-right-color:GrayText;border-top-color:GrayText}}}&._8097270636ca6100__is-borderless{background-color:var(--wpds-color-background-interactive-neutral-weak,#0000);border-color:transparent}&:has(._0d7afad74a057888__input-layout-slot:focus-within){--_gcd-div-outline:none;outline:none}&:hover:not(._6fb7104732387680__is-disabled,:has([data-can-disable-input-layout][data-disabled]),._8097270636ca6100__is-borderless){background-color:var(--wpds-color-background-interactive-neutral-active,var(--wpds-color-background-surface-neutral-strong,#fff));border-color:var(--wpds-color-stroke-interactive-neutral-active,#6e6e6e)}&:has(:invalid[data-validity-visible]){--focus-color:var(--wpds-color-stroke-interactive-error,#cc1818);border-color:var(--wpds-color-stroke-interactive-error,#cc1818);&:hover{border-color:var(--wpds-color-stroke-interactive-error-active,#9d0000)}}}.c192b41a12b4387b__slot-wrapper{display:contents}._0d7afad74a057888__input-layout-slot{align-items:center;display:flex;&._0c952682762ca288__is-padding-minimal{--wp-ui-input-layout-prefix-padding-start:calc(var(--wp-ui-input-layout-padding-inline) - var(--wpds-dimension-padding-xs, 4px));--wp-ui-input-layout-suffix-padding-end:calc(var(--wp-ui-input-layout-padding-inline) - var(--wpds-dimension-padding-xs, 4px))}[data-slot-type=prefix] &{padding-inline-start:var(--wp-ui-input-layout-prefix-padding-start,var(--wp-ui-input-layout-padding-inline))}[data-slot-type=suffix] &{padding-inline-end:var(--wp-ui-input-layout-suffix-padding-end,var(--wp-ui-input-layout-padding-inline))}}}}');
22633 }
22634 var style_default19 = { "input-layout": "cb2baafdc08746bb__input-layout", "is-size-compact": "_0c807a84cbb94e0c__is-size-compact", "is-size-small": "ed67cda122dc1e7b__is-size-small", "is-disabled": "_6fb7104732387680__is-disabled", "is-borderless": "_8097270636ca6100__is-borderless", "input-layout-slot": "_0d7afad74a057888__input-layout-slot", "slot-wrapper": "c192b41a12b4387b__slot-wrapper", "is-padding-minimal": "_0c952682762ca288__is-padding-minimal" };
22635 var InputLayout = (0, import_element46.forwardRef)(
22636 function InputLayout2({
22637 className,
22638 children,
22639 visuallyDisabled,
22640 size: size4 = "default",
22641 isBorderless,
22642 prefix,
22643 suffix,
22644 ...restProps
22645 }, ref) {
22646 return /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)(
22647 "div",
22648 {
22649 ref,
22650 className: clsx_default(
22651 global_css_defense_default6.div,
22652 resets_default6["box-sizing"],
22653 style_default19["input-layout"],
22654 style_default19[`is-size-${size4}`],
22655 visuallyDisabled && style_default19["is-disabled"],
22656 isBorderless && style_default19["is-borderless"],
22657 className
22658 ),
22659 ...restProps,
22660 children: [
22661 import_element46.Children.count(prefix) > 0 && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
22662 "div",
22663 {
22664 className: style_default19["slot-wrapper"],
22665 "data-slot-type": "prefix",
22666 children: prefix
22667 }
22668 ),
22669 children,
22670 import_element46.Children.count(suffix) > 0 && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
22671 "div",
22672 {
22673 className: style_default19["slot-wrapper"],
22674 "data-slot-type": "suffix",
22675 children: suffix
22676 }
22677 )
22678 ]
22679 }
22680 );
22681 }
22682 );
22683
22684 // packages/ui/build-module/form/primitives/input-layout/slot.mjs
22685 var import_element47 = __toESM(require_element(), 1);
22686 var import_jsx_runtime75 = __toESM(require_jsx_runtime(), 1);
22687 var STYLE_HASH_ATTRIBUTE21 = "data-wp-hash";
22688 function getRuntime21() {
22689 const globalScope = globalThis;
22690 if (globalScope.__wpStyleRuntime) {
22691 return globalScope.__wpStyleRuntime;
22692 }
22693 globalScope.__wpStyleRuntime = {
22694 documents: /* @__PURE__ */ new Map(),
22695 styles: /* @__PURE__ */ new Map(),
22696 injectedStyles: /* @__PURE__ */ new WeakMap()
22697 };
22698 if (typeof document !== "undefined") {
22699 registerDocument21(document);
22700 }
22701 return globalScope.__wpStyleRuntime;
22702 }
22703 function documentContainsStyleHash21(targetDocument, hash) {
22704 if (!targetDocument.head) {
22705 return false;
22706 }
22707 for (const style of targetDocument.head.querySelectorAll(
22708 `style[${STYLE_HASH_ATTRIBUTE21}]`
22709 )) {
22710 if (style.getAttribute(STYLE_HASH_ATTRIBUTE21) === hash) {
22711 return true;
22712 }
22713 }
22714 return false;
22715 }
22716 function injectStyle21(targetDocument, hash, css) {
22717 if (!targetDocument.head) {
22718 return;
22719 }
22720 const runtime = getRuntime21();
22721 let injectedStyles = runtime.injectedStyles.get(targetDocument);
22722 if (!injectedStyles) {
22723 injectedStyles = /* @__PURE__ */ new Set();
22724 runtime.injectedStyles.set(targetDocument, injectedStyles);
22725 }
22726 if (injectedStyles.has(hash)) {
22727 return;
22728 }
22729 if (documentContainsStyleHash21(targetDocument, hash)) {
22730 injectedStyles.add(hash);
22731 return;
22732 }
22733 const style = targetDocument.createElement("style");
22734 style.setAttribute(STYLE_HASH_ATTRIBUTE21, hash);
22735 style.appendChild(targetDocument.createTextNode(css));
22736 targetDocument.head.appendChild(style);
22737 injectedStyles.add(hash);
22738 }
22739 function registerDocument21(targetDocument) {
22740 const runtime = getRuntime21();
22741 runtime.documents.set(
22742 targetDocument,
22743 (runtime.documents.get(targetDocument) ?? 0) + 1
22744 );
22745 for (const [hash, css] of runtime.styles) {
22746 injectStyle21(targetDocument, hash, css);
22747 }
22748 return () => {
22749 const count = runtime.documents.get(targetDocument);
22750 if (count === void 0) {
22751 return;
22752 }
22753 if (count <= 1) {
22754 runtime.documents.delete(targetDocument);
22755 return;
22756 }
22757 runtime.documents.set(targetDocument, count - 1);
22758 };
22759 }
22760 function registerStyle21(hash, css) {
22761 const runtime = getRuntime21();
22762 runtime.styles.set(hash, css);
22763 for (const targetDocument of runtime.documents.keys()) {
22764 injectStyle21(targetDocument, hash, css);
22765 }
22766 }
22767 if (typeof process === "undefined" || true) {
22768 registerStyle21("e4f4f9600b", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{.cb2baafdc08746bb__input-layout{--wp-ui-input-layout-padding-inline:var(--wpds-dimension-padding-md,12px);background-color:var(--wpds-color-background-interactive-neutral,var(--wpds-color-background-surface-neutral-strong,#fff));border-color:var(--wpds-color-stroke-interactive-neutral,#8d8d8d);border-radius:var(--wpds-border-radius-sm,2px);border-style:solid;border-width:var(--wpds-border-width-xs,1px);color:var(--wpds-color-foreground-interactive-neutral,#1e1e1e);display:flex;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:max(var(--wpds-typography-font-size-md,13px),16px);height:var(--wpds-dimension-size-lg,40px);line-height:1;@media (min-width:600px){font-size:var(--wpds-typography-font-size-md,13px)}&._0c807a84cbb94e0c__is-size-compact{height:var(--wpds-dimension-size-md,32px)}&._0c807a84cbb94e0c__is-size-compact,&.ed67cda122dc1e7b__is-size-small{--wp-ui-input-layout-padding-inline:var(--wpds-dimension-padding-sm,8px)}&.ed67cda122dc1e7b__is-size-small{height:var(--wpds-dimension-size-sm,24px)}&._6fb7104732387680__is-disabled,&:has([data-can-disable-input-layout][data-disabled]){color:var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d);@media (forced-colors:active){color:GrayText}&:not(._8097270636ca6100__is-borderless){background-color:var(--wpds-color-background-interactive-neutral-disabled,var(--wpds-color-background-surface-neutral-strong,#fff));border-color:var(--wpds-color-stroke-interactive-neutral-disabled,#dbdbdb);@media (forced-colors:active){border-bottom-color:GrayText;border-left-color:GrayText;border-right-color:GrayText;border-top-color:GrayText}}}&._8097270636ca6100__is-borderless{background-color:var(--wpds-color-background-interactive-neutral-weak,#0000);border-color:transparent}&:has(._0d7afad74a057888__input-layout-slot:focus-within){--_gcd-div-outline:none;outline:none}&:hover:not(._6fb7104732387680__is-disabled,:has([data-can-disable-input-layout][data-disabled]),._8097270636ca6100__is-borderless){background-color:var(--wpds-color-background-interactive-neutral-active,var(--wpds-color-background-surface-neutral-strong,#fff));border-color:var(--wpds-color-stroke-interactive-neutral-active,#6e6e6e)}&:has(:invalid[data-validity-visible]){--focus-color:var(--wpds-color-stroke-interactive-error,#cc1818);border-color:var(--wpds-color-stroke-interactive-error,#cc1818);&:hover{border-color:var(--wpds-color-stroke-interactive-error-active,#9d0000)}}}.c192b41a12b4387b__slot-wrapper{display:contents}._0d7afad74a057888__input-layout-slot{align-items:center;display:flex;&._0c952682762ca288__is-padding-minimal{--wp-ui-input-layout-prefix-padding-start:calc(var(--wp-ui-input-layout-padding-inline) - var(--wpds-dimension-padding-xs, 4px));--wp-ui-input-layout-suffix-padding-end:calc(var(--wp-ui-input-layout-padding-inline) - var(--wpds-dimension-padding-xs, 4px))}[data-slot-type=prefix] &{padding-inline-start:var(--wp-ui-input-layout-prefix-padding-start,var(--wp-ui-input-layout-padding-inline))}[data-slot-type=suffix] &{padding-inline-end:var(--wp-ui-input-layout-suffix-padding-end,var(--wp-ui-input-layout-padding-inline))}}}}');
22769 }
22770 var style_default20 = { "input-layout": "cb2baafdc08746bb__input-layout", "is-size-compact": "_0c807a84cbb94e0c__is-size-compact", "is-size-small": "ed67cda122dc1e7b__is-size-small", "is-disabled": "_6fb7104732387680__is-disabled", "is-borderless": "_8097270636ca6100__is-borderless", "input-layout-slot": "_0d7afad74a057888__input-layout-slot", "slot-wrapper": "c192b41a12b4387b__slot-wrapper", "is-padding-minimal": "_0c952682762ca288__is-padding-minimal" };
22771 var InputLayoutSlot = (0, import_element47.forwardRef)(function InputLayoutSlot2({ padding = "default", className, ...restProps }, ref) {
22772 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
22773 "div",
22774 {
22775 ref,
22776 className: clsx_default(
22777 style_default20["input-layout-slot"],
22778 style_default20[`is-padding-${padding}`],
22779 className
22780 ),
22781 ...restProps
22782 }
22783 );
22784 });
22785 InputLayoutSlot.displayName = "InputLayout.Slot";
22786
22787 // packages/ui/build-module/form/primitives/input-layout/index.mjs
22788 var InputLayout3 = Object.assign(InputLayout, {
22789 Slot: InputLayoutSlot
22790 });
22791
22792 // packages/ui/build-module/form/primitives/input/input.mjs
22793 var import_jsx_runtime76 = __toESM(require_jsx_runtime(), 1);
22794 var STYLE_HASH_ATTRIBUTE22 = "data-wp-hash";
22795 function getRuntime22() {
22796 const globalScope = globalThis;
22797 if (globalScope.__wpStyleRuntime) {
22798 return globalScope.__wpStyleRuntime;
22799 }
22800 globalScope.__wpStyleRuntime = {
22801 documents: /* @__PURE__ */ new Map(),
22802 styles: /* @__PURE__ */ new Map(),
22803 injectedStyles: /* @__PURE__ */ new WeakMap()
22804 };
22805 if (typeof document !== "undefined") {
22806 registerDocument22(document);
22807 }
22808 return globalScope.__wpStyleRuntime;
22809 }
22810 function documentContainsStyleHash22(targetDocument, hash) {
22811 if (!targetDocument.head) {
22812 return false;
22813 }
22814 for (const style of targetDocument.head.querySelectorAll(
22815 `style[${STYLE_HASH_ATTRIBUTE22}]`
22816 )) {
22817 if (style.getAttribute(STYLE_HASH_ATTRIBUTE22) === hash) {
22818 return true;
22819 }
22820 }
22821 return false;
22822 }
22823 function injectStyle22(targetDocument, hash, css) {
22824 if (!targetDocument.head) {
22825 return;
22826 }
22827 const runtime = getRuntime22();
22828 let injectedStyles = runtime.injectedStyles.get(targetDocument);
22829 if (!injectedStyles) {
22830 injectedStyles = /* @__PURE__ */ new Set();
22831 runtime.injectedStyles.set(targetDocument, injectedStyles);
22832 }
22833 if (injectedStyles.has(hash)) {
22834 return;
22835 }
22836 if (documentContainsStyleHash22(targetDocument, hash)) {
22837 injectedStyles.add(hash);
22838 return;
22839 }
22840 const style = targetDocument.createElement("style");
22841 style.setAttribute(STYLE_HASH_ATTRIBUTE22, hash);
22842 style.appendChild(targetDocument.createTextNode(css));
22843 targetDocument.head.appendChild(style);
22844 injectedStyles.add(hash);
22845 }
22846 function registerDocument22(targetDocument) {
22847 const runtime = getRuntime22();
22848 runtime.documents.set(
22849 targetDocument,
22850 (runtime.documents.get(targetDocument) ?? 0) + 1
22851 );
22852 for (const [hash, css] of runtime.styles) {
22853 injectStyle22(targetDocument, hash, css);
22854 }
22855 return () => {
22856 const count = runtime.documents.get(targetDocument);
22857 if (count === void 0) {
22858 return;
22859 }
22860 if (count <= 1) {
22861 runtime.documents.delete(targetDocument);
22862 return;
22863 }
22864 runtime.documents.set(targetDocument, count - 1);
22865 };
22866 }
22867 function registerStyle22(hash, css) {
22868 const runtime = getRuntime22();
22869 runtime.styles.set(hash, css);
22870 for (const targetDocument of runtime.documents.keys()) {
22871 injectStyle22(targetDocument, hash, css);
22872 }
22873 }
22874 if (typeof process === "undefined" || true) {
22875 registerStyle22("e8e31009f5", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-foreground-interactive-neutral-weak,#707070))}&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,transparent);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 transparent);color:var(--_gcd-input-color,var(--wpds-color-foreground-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,transparent);border-color:var(--_gcd-input-border-color-disabled,transparent);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid transparent)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-foreground-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-emphasis,600));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid transparent);transition:var(--_gcd-a-transition,none)}.c59a0ebebd71fa4a__ol{list-style:var(--_gcd-ol-list-style,none);margin:var(--_gcd-ol-margin,0);padding-block:var(--_gcd-ol-padding-block,0);padding-inline:var(--_gcd-ol-padding-inline,0)}._46b5cb0c8e24e8c9__li{margin:var(--_gcd-li-margin,0)}");
22876 }
22877 var global_css_defense_default7 = { "button": "_6defc79820e382c6__button", "input": "d2cff2e5dea83bd1__input", "textarea": "_547d86373d02e108__textarea", "div": "_8c15fd0ed9f28ba4__div", "p": "_43cec3e1eec1066d__p", "heading": "e97669c6d9a38497__heading", "a": "_2c0831b0499dbd6e__a", "ol": "c59a0ebebd71fa4a__ol", "li": "_46b5cb0c8e24e8c9__li" };
22878 if (typeof process === "undefined" || true) {
22879 registerStyle22("08122b3d53", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{.af79fb116edb0dd7__outset-ring--focus:focus,.dfcfdc28396e5d98__outset-ring--focus-visible:focus-visible,.e5cd9ee879f6403a__outset-ring--focus-within:focus-within,:focus-visible ._81935a08e952f267__outset-ring--focus-parent-visible{--_gcd-a-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--focus-color,var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9)));--_gcd-div-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--focus-color,var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9)));outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--focus-color,var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9)));outline-offset:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px))}._3c9f5ee9fc9c136d__outset-ring--focus-within-except-active:focus-within,.abc777e9713fa711__outset-ring--focus-except-active:focus{outline:none}._3c9f5ee9fc9c136d__outset-ring--focus-within-except-active:focus-within:not(:has(:active)),.abc777e9713fa711__outset-ring--focus-except-active:focus:not(:active){--_gcd-a-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--focus-color,var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9)));--_gcd-div-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--focus-color,var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9)));outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--focus-color,var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9)));outline-offset:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px))}}}");
22880 }
22881 var focus_module_default5 = { "outset-ring--focus": "af79fb116edb0dd7__outset-ring--focus", "outset-ring--focus-visible": "dfcfdc28396e5d98__outset-ring--focus-visible", "outset-ring--focus-within": "e5cd9ee879f6403a__outset-ring--focus-within", "outset-ring--focus-parent-visible": "_81935a08e952f267__outset-ring--focus-parent-visible", "outset-ring--focus-except-active": "abc777e9713fa711__outset-ring--focus-except-active", "outset-ring--focus-within-except-active": "_3c9f5ee9fc9c136d__outset-ring--focus-within-except-active" };
22882 if (typeof process === "undefined" || true) {
22883 registerStyle22("1a25f6a232", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._2ae7be2fc1bb17a3__input{--_gcd-input-padding:var(--wp-ui-input-padding-block,0px) var(--wp-ui-input-layout-padding-inline,0px);background:transparent;border:none;color:var(--wpds-color-foreground-interactive-neutral,#1e1e1e);font-family:inherit;font-size:inherit;line-height:inherit;outline:none;padding-block:var(--wp-ui-input-padding-block,0);padding-inline:var(--wp-ui-input-layout-padding-inline,0);width:100%;&::placeholder{color:var(--wpds-color-foreground-interactive-neutral-weak,#707070)}&:disabled,&[aria-disabled=true]{--_gcd-input-placeholder-color:var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d);color:var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d);&::placeholder{color:var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d)}@media (forced-colors:active){color:GrayText}}&[type=email],&[type=url]{direction:ltr}&[type=number]{appearance:textfield;&::-webkit-inner-spin-button,&::-webkit-outer-spin-button{appearance:none;margin:0}}}}}");
22884 }
22885 var style_default21 = { "input": "_2ae7be2fc1bb17a3__input" };
22886 var Input3 = (0, import_element48.forwardRef)(function Input22({ className, size: size4 = "default", prefix, suffix, style, ...restProps }, ref) {
22887 return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
22888 InputLayout3,
22889 {
22890 className: clsx_default(
22891 focus_module_default5["outset-ring--focus-within"],
22892 className
22893 ),
22894 style,
22895 size: size4,
22896 visuallyDisabled: restProps.disabled,
22897 prefix,
22898 suffix,
22899 children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
22900 Input,
22901 {
22902 ref,
22903 className: clsx_default(global_css_defense_default7.input, style_default21.input),
22904 ...restProps
22905 }
22906 )
22907 }
22908 );
22909 });
22910
22911 // packages/ui/build-module/form/primitives/control-with-error/control-with-error.mjs
22912 var import_i18n7 = __toESM(require_i18n(), 1);
22913 var import_element50 = __toESM(require_element(), 1);
22914
22915 // packages/ui/build-module/spinner/spinner.mjs
22916 var import_element49 = __toESM(require_element(), 1);
22917 var import_jsx_runtime77 = __toESM(require_jsx_runtime(), 1);
22918 var STYLE_HASH_ATTRIBUTE23 = "data-wp-hash";
22919 function getRuntime23() {
22920 const globalScope = globalThis;
22921 if (globalScope.__wpStyleRuntime) {
22922 return globalScope.__wpStyleRuntime;
22923 }
22924 globalScope.__wpStyleRuntime = {
22925 documents: /* @__PURE__ */ new Map(),
22926 styles: /* @__PURE__ */ new Map(),
22927 injectedStyles: /* @__PURE__ */ new WeakMap()
22928 };
22929 if (typeof document !== "undefined") {
22930 registerDocument23(document);
22931 }
22932 return globalScope.__wpStyleRuntime;
22933 }
22934 function documentContainsStyleHash23(targetDocument, hash) {
22935 if (!targetDocument.head) {
22936 return false;
22937 }
22938 for (const style of targetDocument.head.querySelectorAll(
22939 `style[${STYLE_HASH_ATTRIBUTE23}]`
22940 )) {
22941 if (style.getAttribute(STYLE_HASH_ATTRIBUTE23) === hash) {
22942 return true;
22943 }
22944 }
22945 return false;
22946 }
22947 function injectStyle23(targetDocument, hash, css) {
22948 if (!targetDocument.head) {
22949 return;
22950 }
22951 const runtime = getRuntime23();
22952 let injectedStyles = runtime.injectedStyles.get(targetDocument);
22953 if (!injectedStyles) {
22954 injectedStyles = /* @__PURE__ */ new Set();
22955 runtime.injectedStyles.set(targetDocument, injectedStyles);
22956 }
22957 if (injectedStyles.has(hash)) {
22958 return;
22959 }
22960 if (documentContainsStyleHash23(targetDocument, hash)) {
22961 injectedStyles.add(hash);
22962 return;
22963 }
22964 const style = targetDocument.createElement("style");
22965 style.setAttribute(STYLE_HASH_ATTRIBUTE23, hash);
22966 style.appendChild(targetDocument.createTextNode(css));
22967 targetDocument.head.appendChild(style);
22968 injectedStyles.add(hash);
22969 }
22970 function registerDocument23(targetDocument) {
22971 const runtime = getRuntime23();
22972 runtime.documents.set(
22973 targetDocument,
22974 (runtime.documents.get(targetDocument) ?? 0) + 1
22975 );
22976 for (const [hash, css] of runtime.styles) {
22977 injectStyle23(targetDocument, hash, css);
22978 }
22979 return () => {
22980 const count = runtime.documents.get(targetDocument);
22981 if (count === void 0) {
22982 return;
22983 }
22984 if (count <= 1) {
22985 runtime.documents.delete(targetDocument);
22986 return;
22987 }
22988 runtime.documents.set(targetDocument, count - 1);
22989 };
22990 }
22991 function registerStyle23(hash, css) {
22992 const runtime = getRuntime23();
22993 runtime.styles.set(hash, css);
22994 for (const targetDocument of runtime.documents.keys()) {
22995 injectStyle23(targetDocument, hash, css);
22996 }
22997 }
22998 if (typeof process === "undefined" || true) {
22999 registerStyle23("bbbecfe373", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{.ab4d64c07c0ba587__spinner{background-color:transparent;display:inline-block;height:var(--wpds-dimension-size-2xs,16px);opacity:1;overflow:visible;position:relative;width:var(--wpds-dimension-size-2xs,16px)}.a7654e10245bb7d2__indicator,.dc51f80c84b35fe2__track{fill:transparent;stroke-width:1.5px}.dc51f80c84b35fe2__track{stroke:var(--wpds-color-background-track-neutral,#dbdbdb)}.a7654e10245bb7d2__indicator{stroke:var(--wpds-color-background-thumb-brand,var(--wp-admin-theme-color,#3858e9));stroke-linecap:round;animation:_02322d973909703c__spinner-spin 1.4s linear infinite both;transform-origin:50% 50%}@keyframes _02322d973909703c__spinner-spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}}}");
23000 }
23001 var style_default22 = { "spinner": "ab4d64c07c0ba587__spinner", "track": "dc51f80c84b35fe2__track", "indicator": "a7654e10245bb7d2__indicator", "spinner-spin": "_02322d973909703c__spinner-spin" };
23002 var Spinner = (0, import_element49.forwardRef)(
23003 function Spinner2({ className, ...props }, ref) {
23004 return /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(
23005 "svg",
23006 {
23007 className: clsx_default(style_default22.spinner, className),
23008 viewBox: "0 0 100 100",
23009 xmlns: "http://www.w3.org/2000/svg",
23010 role: "presentation",
23011 focusable: "false",
23012 ...props,
23013 ref,
23014 children: [
23015 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
23016 "circle",
23017 {
23018 className: style_default22.track,
23019 cx: "50",
23020 cy: "50",
23021 r: "50",
23022 vectorEffect: "non-scaling-stroke"
23023 }
23024 ),
23025 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
23026 "path",
23027 {
23028 className: style_default22.indicator,
23029 d: "m 50 0 a 50 50 0 0 1 50 50",
23030 vectorEffect: "non-scaling-stroke"
23031 }
23032 )
23033 ]
23034 }
23035 );
23036 }
23037 );
23038
23039 // packages/ui/build-module/form/primitives/validity-indicator/validity-indicator.mjs
23040 var import_jsx_runtime78 = __toESM(require_jsx_runtime(), 1);
23041 var STYLE_HASH_ATTRIBUTE24 = "data-wp-hash";
23042 function getRuntime24() {
23043 const globalScope = globalThis;
23044 if (globalScope.__wpStyleRuntime) {
23045 return globalScope.__wpStyleRuntime;
23046 }
23047 globalScope.__wpStyleRuntime = {
23048 documents: /* @__PURE__ */ new Map(),
23049 styles: /* @__PURE__ */ new Map(),
23050 injectedStyles: /* @__PURE__ */ new WeakMap()
23051 };
23052 if (typeof document !== "undefined") {
23053 registerDocument24(document);
23054 }
23055 return globalScope.__wpStyleRuntime;
23056 }
23057 function documentContainsStyleHash24(targetDocument, hash) {
23058 if (!targetDocument.head) {
23059 return false;
23060 }
23061 for (const style of targetDocument.head.querySelectorAll(
23062 `style[${STYLE_HASH_ATTRIBUTE24}]`
23063 )) {
23064 if (style.getAttribute(STYLE_HASH_ATTRIBUTE24) === hash) {
23065 return true;
23066 }
23067 }
23068 return false;
23069 }
23070 function injectStyle24(targetDocument, hash, css) {
23071 if (!targetDocument.head) {
23072 return;
23073 }
23074 const runtime = getRuntime24();
23075 let injectedStyles = runtime.injectedStyles.get(targetDocument);
23076 if (!injectedStyles) {
23077 injectedStyles = /* @__PURE__ */ new Set();
23078 runtime.injectedStyles.set(targetDocument, injectedStyles);
23079 }
23080 if (injectedStyles.has(hash)) {
23081 return;
23082 }
23083 if (documentContainsStyleHash24(targetDocument, hash)) {
23084 injectedStyles.add(hash);
23085 return;
23086 }
23087 const style = targetDocument.createElement("style");
23088 style.setAttribute(STYLE_HASH_ATTRIBUTE24, hash);
23089 style.appendChild(targetDocument.createTextNode(css));
23090 targetDocument.head.appendChild(style);
23091 injectedStyles.add(hash);
23092 }
23093 function registerDocument24(targetDocument) {
23094 const runtime = getRuntime24();
23095 runtime.documents.set(
23096 targetDocument,
23097 (runtime.documents.get(targetDocument) ?? 0) + 1
23098 );
23099 for (const [hash, css] of runtime.styles) {
23100 injectStyle24(targetDocument, hash, css);
23101 }
23102 return () => {
23103 const count = runtime.documents.get(targetDocument);
23104 if (count === void 0) {
23105 return;
23106 }
23107 if (count <= 1) {
23108 runtime.documents.delete(targetDocument);
23109 return;
23110 }
23111 runtime.documents.set(targetDocument, count - 1);
23112 };
23113 }
23114 function registerStyle24(hash, css) {
23115 const runtime = getRuntime24();
23116 runtime.styles.set(hash, css);
23117 for (const targetDocument of runtime.documents.keys()) {
23118 injectStyle24(targetDocument, hash, css);
23119 }
23120 }
23121 if (typeof process === "undefined" || true) {
23122 registerStyle24("e8e31009f5", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-foreground-interactive-neutral-weak,#707070))}&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,transparent);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 transparent);color:var(--_gcd-input-color,var(--wpds-color-foreground-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,transparent);border-color:var(--_gcd-input-border-color-disabled,transparent);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid transparent)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-foreground-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-emphasis,600));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid transparent);transition:var(--_gcd-a-transition,none)}.c59a0ebebd71fa4a__ol{list-style:var(--_gcd-ol-list-style,none);margin:var(--_gcd-ol-margin,0);padding-block:var(--_gcd-ol-padding-block,0);padding-inline:var(--_gcd-ol-padding-inline,0)}._46b5cb0c8e24e8c9__li{margin:var(--_gcd-li-margin,0)}");
23123 }
23124 var global_css_defense_default8 = { "button": "_6defc79820e382c6__button", "input": "d2cff2e5dea83bd1__input", "textarea": "_547d86373d02e108__textarea", "div": "_8c15fd0ed9f28ba4__div", "p": "_43cec3e1eec1066d__p", "heading": "e97669c6d9a38497__heading", "a": "_2c0831b0499dbd6e__a", "ol": "c59a0ebebd71fa4a__ol", "li": "_46b5cb0c8e24e8c9__li" };
23125 if (typeof process === "undefined" || true) {
23126 registerStyle24("d11816833c", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._7a7ac88e306348e7__indicator{--_gcd-p-font-size:var(--wpds-typography-font-size-sm,12px);--_gcd-p-line-height:var(--wpds-typography-line-height-xs,16px);align-items:flex-start;color:var(--wpds-color-foreground-content-neutral-weak,#707070);display:flex;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);gap:var(--wpds-dimension-gap-xs,4px);line-height:var(--wpds-typography-line-height-xs,16px);@media not (prefers-reduced-motion){animation:_48722cc5dd090ce4__indicator-jump var(--wpds-motion-duration-md,.2s) cubic-bezier(.68,-.55,.27,1.55)}}._57a3bbbfbe38a5c6__is-invalid{color:var(--wpds-color-foreground-content-error-weak,#cc1818)}._9e944dc198aac10b__is-valid{color:var(--wpds-color-foreground-content-success-weak,#008030)}.e482806667437c6a__indicator-icon{flex-shrink:0}._6e46434cc23019d2__indicator-spinner{height:var(--wpds-dimension-size-3xs,12px);margin:2px;width:var(--wpds-dimension-size-3xs,12px)}@keyframes _48722cc5dd090ce4__indicator-jump{0%{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}}}');
23127 }
23128 var style_default23 = { "indicator": "_7a7ac88e306348e7__indicator", "indicator-jump": "_48722cc5dd090ce4__indicator-jump", "is-invalid": "_57a3bbbfbe38a5c6__is-invalid", "is-valid": "_9e944dc198aac10b__is-valid", "indicator-icon": "e482806667437c6a__indicator-icon", "indicator-spinner": "_6e46434cc23019d2__indicator-spinner" };
23129 var ICON = {
23130 valid: published_default,
23131 invalid: error_default
23132 };
23133 function ValidityIndicator({
23134 id,
23135 type,
23136 message: message2
23137 }) {
23138 return /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)(
23139 "p",
23140 {
23141 id,
23142 className: clsx_default(
23143 global_css_defense_default8.p,
23144 style_default23.indicator,
23145 style_default23[`is-${type}`]
23146 ),
23147 children: [
23148 type === "validating" ? /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(Spinner, { className: style_default23["indicator-spinner"] }) : /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
23149 Icon,
23150 {
23151 className: style_default23["indicator-icon"],
23152 icon: ICON[type],
23153 size: 16,
23154 fill: "currentColor"
23155 }
23156 ),
23157 message2
23158 ]
23159 }
23160 );
23161 }
23162
23163 // packages/ui/build-module/form/primitives/control-with-error/control-with-error.mjs
23164 var import_jsx_runtime79 = __toESM(require_jsx_runtime(), 1);
23165 var DEFAULT_RENDER = (props) => /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(Stack, { ...props, direction: "column", gap: "sm" });
23166 function appendRequiredIndicator(label, required, markWhenOptional) {
23167 let suffix;
23168 if (required && !markWhenOptional) {
23169 suffix = `(${(0, import_i18n7.__)("Required")})`;
23170 } else if (!required && markWhenOptional) {
23171 suffix = `(${(0, import_i18n7.__)("Optional")})`;
23172 }
23173 if (!suffix) {
23174 return label;
23175 }
23176 if (typeof label === "string") {
23177 return `${label} ${suffix}`;
23178 }
23179 return /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(import_jsx_runtime79.Fragment, { children: [
23180 label,
23181 " ",
23182 suffix
23183 ] });
23184 }
23185 var VALIDITY_VISIBLE_ATTRIBUTE = "data-validity-visible";
23186 var ControlWithError = (0, import_element50.forwardRef)(function ControlWithError2({
23187 required,
23188 markWhenOptional,
23189 customValidity,
23190 getValidityTarget,
23191 children,
23192 render: render4 = DEFAULT_RENDER,
23193 ...restProps
23194 }, forwardedRef) {
23195 const [errorMessage, setErrorMessage] = (0, import_element50.useState)();
23196 const [statusMessage, setStatusMessage] = (0, import_element50.useState)();
23197 const [showMessage, setShowMessage] = (0, import_element50.useState)(false);
23198 const [isTouched, setIsTouched] = (0, import_element50.useState)(false);
23199 const wrapperRef = (0, import_element50.useRef)(null);
23200 (0, import_element50.useEffect)(() => {
23201 const validityTarget = getValidityTarget();
23202 const handler = () => {
23203 if (customValidity?.type !== "validating") {
23204 setErrorMessage(validityTarget?.validationMessage);
23205 }
23206 setShowMessage(true);
23207 validityTarget?.setAttribute(VALIDITY_VISIBLE_ATTRIBUTE, "");
23208 };
23209 validityTarget?.addEventListener("invalid", handler);
23210 return () => validityTarget?.removeEventListener("invalid", handler);
23211 }, [customValidity?.type, getValidityTarget]);
23212 (0, import_element50.useEffect)(() => {
23213 const validityTarget = getValidityTarget();
23214 const suppressNativePopover = (event) => {
23215 event.preventDefault();
23216 if (!event.isTrusted) {
23217 return;
23218 }
23219 const target = event.target;
23220 const firstErrorInForm = Array.from(
23221 target.form?.elements ?? []
23222 ).find((el) => !el.validity.valid);
23223 if (!target.form || firstErrorInForm === target) {
23224 target.focus();
23225 }
23226 };
23227 const radioSiblings = validityTarget?.type === "radio" && validityTarget?.name ? Array.from(
23228 wrapperRef.current?.querySelectorAll(
23229 `input[type="radio"][name="${validityTarget?.name}"]`
23230 ) ?? []
23231 ).filter((sibling) => sibling !== validityTarget) : [];
23232 validityTarget?.addEventListener("invalid", suppressNativePopover);
23233 radioSiblings.forEach(
23234 (sibling) => sibling.addEventListener("invalid", suppressNativePopover)
23235 );
23236 return () => {
23237 validityTarget?.removeEventListener(
23238 "invalid",
23239 suppressNativePopover
23240 );
23241 radioSiblings.forEach(
23242 (sibling) => sibling.removeEventListener("invalid", suppressNativePopover)
23243 );
23244 };
23245 }, [getValidityTarget]);
23246 (0, import_element50.useEffect)(() => {
23247 const validityTarget = getValidityTarget();
23248 if (!customValidity?.type) {
23249 validityTarget?.setCustomValidity("");
23250 setErrorMessage(validityTarget?.validationMessage);
23251 setStatusMessage(void 0);
23252 return;
23253 }
23254 switch (customValidity.type) {
23255 case "validating": {
23256 validityTarget?.setCustomValidity("");
23257 setErrorMessage(void 0);
23258 setStatusMessage({
23259 type: "validating",
23260 message: customValidity.message
23261 });
23262 break;
23263 }
23264 case "valid": {
23265 validityTarget?.setCustomValidity("");
23266 setErrorMessage(validityTarget?.validationMessage);
23267 setStatusMessage({
23268 type: "valid",
23269 message: customValidity.message
23270 });
23271 break;
23272 }
23273 case "invalid": {
23274 validityTarget?.setCustomValidity(
23275 customValidity.message ?? ""
23276 );
23277 setErrorMessage(validityTarget?.validationMessage);
23278 setStatusMessage(void 0);
23279 break;
23280 }
23281 }
23282 }, [customValidity, getValidityTarget]);
23283 (0, import_element50.useEffect)(() => {
23284 if (!isTouched || showMessage) {
23285 return;
23286 }
23287 if (customValidity?.type === "validating") {
23288 const timer = setTimeout(() => {
23289 setShowMessage(true);
23290 }, 1e3);
23291 return () => clearTimeout(timer);
23292 }
23293 setShowMessage(true);
23294 }, [isTouched, customValidity?.type, showMessage]);
23295 const onBlur = (event) => {
23296 if (event.relatedTarget && event.currentTarget.contains(event.relatedTarget)) {
23297 return;
23298 }
23299 if (!isTouched) {
23300 setIsTouched(true);
23301 getValidityTarget()?.setAttribute(VALIDITY_VISIBLE_ATTRIBUTE, "");
23302 }
23303 const validityTarget = getValidityTarget();
23304 const isValidating = customValidity?.type === "validating";
23305 window.queueMicrotask(() => {
23306 if (!isValidating) {
23307 setErrorMessage(validityTarget?.validationMessage);
23308 }
23309 });
23310 };
23311 const messageId = (0, import_element50.useId)();
23312 const message2 = (() => {
23313 if (errorMessage) {
23314 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
23315 ValidityIndicator,
23316 {
23317 id: messageId,
23318 type: "invalid",
23319 message: errorMessage
23320 }
23321 );
23322 }
23323 if (statusMessage?.type) {
23324 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
23325 ValidityIndicator,
23326 {
23327 id: messageId,
23328 type: statusMessage.type,
23329 message: statusMessage.message
23330 }
23331 );
23332 }
23333 return null;
23334 })();
23335 const visibleMessage = showMessage ? message2 : null;
23336 (0, import_element50.useEffect)(() => {
23337 const target = getValidityTarget();
23338 if (!target) {
23339 return;
23340 }
23341 function setDescribedBy(el, shouldAdd) {
23342 const ids = (el.getAttribute("aria-describedby") ?? "").split(" ").filter((id) => id && id !== messageId);
23343 if (shouldAdd) {
23344 ids.push(messageId);
23345 }
23346 if (ids.length) {
23347 el.setAttribute("aria-describedby", ids.join(" "));
23348 } else {
23349 el.removeAttribute("aria-describedby");
23350 }
23351 }
23352 setDescribedBy(target, !!visibleMessage);
23353 return () => setDescribedBy(target, false);
23354 }, [visibleMessage, messageId, getValidityTarget]);
23355 return useRender({
23356 render: render4,
23357 ref: [forwardedRef, wrapperRef],
23358 props: mergeProps(restProps, {
23359 onBlur,
23360 children: /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(import_jsx_runtime79.Fragment, { children: [
23361 (0, import_element50.cloneElement)(children, {
23362 label: appendRequiredIndicator(
23363 children.props.label,
23364 required,
23365 markWhenOptional
23366 ),
23367 required
23368 }),
23369 visibleMessage
23370 ] })
23371 })
23372 });
23373 });
23374
23375 // packages/ui/build-module/form/primitives/field/index.mjs
23376 var field_exports = {};
23377 __export(field_exports, {
23378 Control: () => Control,
23379 Description: () => Description,
23380 Details: () => Details,
23381 Item: () => Item,
23382 Label: () => Label,
23383 Root: () => Root6,
23384 VisualLabel: () => VisualLabel
23385 });
23386
23387 // packages/ui/build-module/form/primitives/field/root.mjs
23388 var import_element51 = __toESM(require_element(), 1);
23389 var import_jsx_runtime80 = __toESM(require_jsx_runtime(), 1);
23390 var STYLE_HASH_ATTRIBUTE25 = "data-wp-hash";
23391 function getRuntime25() {
23392 const globalScope = globalThis;
23393 if (globalScope.__wpStyleRuntime) {
23394 return globalScope.__wpStyleRuntime;
23395 }
23396 globalScope.__wpStyleRuntime = {
23397 documents: /* @__PURE__ */ new Map(),
23398 styles: /* @__PURE__ */ new Map(),
23399 injectedStyles: /* @__PURE__ */ new WeakMap()
23400 };
23401 if (typeof document !== "undefined") {
23402 registerDocument25(document);
23403 }
23404 return globalScope.__wpStyleRuntime;
23405 }
23406 function documentContainsStyleHash25(targetDocument, hash) {
23407 if (!targetDocument.head) {
23408 return false;
23409 }
23410 for (const style of targetDocument.head.querySelectorAll(
23411 `style[${STYLE_HASH_ATTRIBUTE25}]`
23412 )) {
23413 if (style.getAttribute(STYLE_HASH_ATTRIBUTE25) === hash) {
23414 return true;
23415 }
23416 }
23417 return false;
23418 }
23419 function injectStyle25(targetDocument, hash, css) {
23420 if (!targetDocument.head) {
23421 return;
23422 }
23423 const runtime = getRuntime25();
23424 let injectedStyles = runtime.injectedStyles.get(targetDocument);
23425 if (!injectedStyles) {
23426 injectedStyles = /* @__PURE__ */ new Set();
23427 runtime.injectedStyles.set(targetDocument, injectedStyles);
23428 }
23429 if (injectedStyles.has(hash)) {
23430 return;
23431 }
23432 if (documentContainsStyleHash25(targetDocument, hash)) {
23433 injectedStyles.add(hash);
23434 return;
23435 }
23436 const style = targetDocument.createElement("style");
23437 style.setAttribute(STYLE_HASH_ATTRIBUTE25, hash);
23438 style.appendChild(targetDocument.createTextNode(css));
23439 targetDocument.head.appendChild(style);
23440 injectedStyles.add(hash);
23441 }
23442 function registerDocument25(targetDocument) {
23443 const runtime = getRuntime25();
23444 runtime.documents.set(
23445 targetDocument,
23446 (runtime.documents.get(targetDocument) ?? 0) + 1
23447 );
23448 for (const [hash, css] of runtime.styles) {
23449 injectStyle25(targetDocument, hash, css);
23450 }
23451 return () => {
23452 const count = runtime.documents.get(targetDocument);
23453 if (count === void 0) {
23454 return;
23455 }
23456 if (count <= 1) {
23457 runtime.documents.delete(targetDocument);
23458 return;
23459 }
23460 runtime.documents.set(targetDocument, count - 1);
23461 };
23462 }
23463 function registerStyle25(hash, css) {
23464 const runtime = getRuntime25();
23465 runtime.styles.set(hash, css);
23466 for (const targetDocument of runtime.documents.keys()) {
23467 injectStyle25(targetDocument, hash, css);
23468 }
23469 }
23470 if (typeof process === "undefined" || true) {
23471 registerStyle25("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}");
23472 }
23473 var resets_default7 = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
23474 var DEFAULT_RENDER2 = (props) => /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(Stack, { ...props, direction: "column", gap: "sm" });
23475 var Root6 = (0, import_element51.forwardRef)(function Root22({ className, render: render4 = DEFAULT_RENDER2, ...restProps }, ref) {
23476 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
23477 index_parts_exports2.Root,
23478 {
23479 ref,
23480 className: clsx_default(resets_default7["box-sizing"], className),
23481 render: render4,
23482 ...restProps
23483 }
23484 );
23485 });
23486
23487 // packages/ui/build-module/form/primitives/field/item.mjs
23488 var import_element52 = __toESM(require_element(), 1);
23489 var import_jsx_runtime81 = __toESM(require_jsx_runtime(), 1);
23490 var Item = (0, import_element52.forwardRef)(function Item2(props, ref) {
23491 return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(index_parts_exports2.Item, { ref, ...props });
23492 });
23493
23494 // packages/ui/build-module/form/primitives/field/label.mjs
23495 var import_element53 = __toESM(require_element(), 1);
23496 var import_jsx_runtime82 = __toESM(require_jsx_runtime(), 1);
23497 var STYLE_HASH_ATTRIBUTE26 = "data-wp-hash";
23498 function getRuntime26() {
23499 const globalScope = globalThis;
23500 if (globalScope.__wpStyleRuntime) {
23501 return globalScope.__wpStyleRuntime;
23502 }
23503 globalScope.__wpStyleRuntime = {
23504 documents: /* @__PURE__ */ new Map(),
23505 styles: /* @__PURE__ */ new Map(),
23506 injectedStyles: /* @__PURE__ */ new WeakMap()
23507 };
23508 if (typeof document !== "undefined") {
23509 registerDocument26(document);
23510 }
23511 return globalScope.__wpStyleRuntime;
23512 }
23513 function documentContainsStyleHash26(targetDocument, hash) {
23514 if (!targetDocument.head) {
23515 return false;
23516 }
23517 for (const style of targetDocument.head.querySelectorAll(
23518 `style[${STYLE_HASH_ATTRIBUTE26}]`
23519 )) {
23520 if (style.getAttribute(STYLE_HASH_ATTRIBUTE26) === hash) {
23521 return true;
23522 }
23523 }
23524 return false;
23525 }
23526 function injectStyle26(targetDocument, hash, css) {
23527 if (!targetDocument.head) {
23528 return;
23529 }
23530 const runtime = getRuntime26();
23531 let injectedStyles = runtime.injectedStyles.get(targetDocument);
23532 if (!injectedStyles) {
23533 injectedStyles = /* @__PURE__ */ new Set();
23534 runtime.injectedStyles.set(targetDocument, injectedStyles);
23535 }
23536 if (injectedStyles.has(hash)) {
23537 return;
23538 }
23539 if (documentContainsStyleHash26(targetDocument, hash)) {
23540 injectedStyles.add(hash);
23541 return;
23542 }
23543 const style = targetDocument.createElement("style");
23544 style.setAttribute(STYLE_HASH_ATTRIBUTE26, hash);
23545 style.appendChild(targetDocument.createTextNode(css));
23546 targetDocument.head.appendChild(style);
23547 injectedStyles.add(hash);
23548 }
23549 function registerDocument26(targetDocument) {
23550 const runtime = getRuntime26();
23551 runtime.documents.set(
23552 targetDocument,
23553 (runtime.documents.get(targetDocument) ?? 0) + 1
23554 );
23555 for (const [hash, css] of runtime.styles) {
23556 injectStyle26(targetDocument, hash, css);
23557 }
23558 return () => {
23559 const count = runtime.documents.get(targetDocument);
23560 if (count === void 0) {
23561 return;
23562 }
23563 if (count <= 1) {
23564 runtime.documents.delete(targetDocument);
23565 return;
23566 }
23567 runtime.documents.set(targetDocument, count - 1);
23568 };
23569 }
23570 function registerStyle26(hash, css) {
23571 const runtime = getRuntime26();
23572 runtime.styles.set(hash, css);
23573 for (const targetDocument of runtime.documents.keys()) {
23574 injectStyle26(targetDocument, hash, css);
23575 }
23576 }
23577 if (typeof process === "undefined" || true) {
23578 registerStyle26("df33c48b2d", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._2d5ad850b2f90964__label{--wp-ui-field-label-line-height:var(--wpds-typography-line-height-xs,16px);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-xs,11px);font-weight:var(--wpds-typography-font-weight-emphasis,600);line-height:var(--wp-ui-field-label-line-height);text-transform:uppercase;&._17c4214649230bea__is-plain{font-size:var(--wpds-typography-font-size-md,13px);font-weight:var(--wpds-typography-font-weight-default,400);text-transform:none}}._08a3750500e0233f__description{--_gcd-p-font-size:var(--wpds-typography-font-size-sm,12px);--_gcd-p-line-height:var(--wpds-typography-line-height-xs,16px);--_gcd-p-margin:0;text-wrap:pretty;color:var(--wpds-color-foreground-content-neutral-weak,#707070);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:var(--wpds-typography-line-height-xs,16px)}}}');
23579 }
23580 var field_default = { "label": "_2d5ad850b2f90964__label", "is-plain": "_17c4214649230bea__is-plain", "description": "_08a3750500e0233f__description" };
23581 var Label = (0, import_element53.forwardRef)(
23582 function Label2({ className, hideFromVision, variant, ...restProps }, ref) {
23583 const label = /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
23584 index_parts_exports2.Label,
23585 {
23586 ref,
23587 className: clsx_default(
23588 field_default.label,
23589 variant && field_default[`is-${variant}`],
23590 className
23591 ),
23592 ...restProps
23593 }
23594 );
23595 if (hideFromVision) {
23596 return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(VisuallyHidden, { render: label });
23597 }
23598 return label;
23599 }
23600 );
23601
23602 // packages/ui/build-module/form/primitives/field/description.mjs
23603 var import_element54 = __toESM(require_element(), 1);
23604 var import_jsx_runtime83 = __toESM(require_jsx_runtime(), 1);
23605 var STYLE_HASH_ATTRIBUTE27 = "data-wp-hash";
23606 function getRuntime27() {
23607 const globalScope = globalThis;
23608 if (globalScope.__wpStyleRuntime) {
23609 return globalScope.__wpStyleRuntime;
23610 }
23611 globalScope.__wpStyleRuntime = {
23612 documents: /* @__PURE__ */ new Map(),
23613 styles: /* @__PURE__ */ new Map(),
23614 injectedStyles: /* @__PURE__ */ new WeakMap()
23615 };
23616 if (typeof document !== "undefined") {
23617 registerDocument27(document);
23618 }
23619 return globalScope.__wpStyleRuntime;
23620 }
23621 function documentContainsStyleHash27(targetDocument, hash) {
23622 if (!targetDocument.head) {
23623 return false;
23624 }
23625 for (const style of targetDocument.head.querySelectorAll(
23626 `style[${STYLE_HASH_ATTRIBUTE27}]`
23627 )) {
23628 if (style.getAttribute(STYLE_HASH_ATTRIBUTE27) === hash) {
23629 return true;
23630 }
23631 }
23632 return false;
23633 }
23634 function injectStyle27(targetDocument, hash, css) {
23635 if (!targetDocument.head) {
23636 return;
23637 }
23638 const runtime = getRuntime27();
23639 let injectedStyles = runtime.injectedStyles.get(targetDocument);
23640 if (!injectedStyles) {
23641 injectedStyles = /* @__PURE__ */ new Set();
23642 runtime.injectedStyles.set(targetDocument, injectedStyles);
23643 }
23644 if (injectedStyles.has(hash)) {
23645 return;
23646 }
23647 if (documentContainsStyleHash27(targetDocument, hash)) {
23648 injectedStyles.add(hash);
23649 return;
23650 }
23651 const style = targetDocument.createElement("style");
23652 style.setAttribute(STYLE_HASH_ATTRIBUTE27, hash);
23653 style.appendChild(targetDocument.createTextNode(css));
23654 targetDocument.head.appendChild(style);
23655 injectedStyles.add(hash);
23656 }
23657 function registerDocument27(targetDocument) {
23658 const runtime = getRuntime27();
23659 runtime.documents.set(
23660 targetDocument,
23661 (runtime.documents.get(targetDocument) ?? 0) + 1
23662 );
23663 for (const [hash, css] of runtime.styles) {
23664 injectStyle27(targetDocument, hash, css);
23665 }
23666 return () => {
23667 const count = runtime.documents.get(targetDocument);
23668 if (count === void 0) {
23669 return;
23670 }
23671 if (count <= 1) {
23672 runtime.documents.delete(targetDocument);
23673 return;
23674 }
23675 runtime.documents.set(targetDocument, count - 1);
23676 };
23677 }
23678 function registerStyle27(hash, css) {
23679 const runtime = getRuntime27();
23680 runtime.styles.set(hash, css);
23681 for (const targetDocument of runtime.documents.keys()) {
23682 injectStyle27(targetDocument, hash, css);
23683 }
23684 }
23685 if (typeof process === "undefined" || true) {
23686 registerStyle27("e8e31009f5", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-foreground-interactive-neutral-weak,#707070))}&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,transparent);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 transparent);color:var(--_gcd-input-color,var(--wpds-color-foreground-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,transparent);border-color:var(--_gcd-input-border-color-disabled,transparent);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid transparent)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-foreground-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-emphasis,600));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid transparent);transition:var(--_gcd-a-transition,none)}.c59a0ebebd71fa4a__ol{list-style:var(--_gcd-ol-list-style,none);margin:var(--_gcd-ol-margin,0);padding-block:var(--_gcd-ol-padding-block,0);padding-inline:var(--_gcd-ol-padding-inline,0)}._46b5cb0c8e24e8c9__li{margin:var(--_gcd-li-margin,0)}");
23687 }
23688 var global_css_defense_default9 = { "button": "_6defc79820e382c6__button", "input": "d2cff2e5dea83bd1__input", "textarea": "_547d86373d02e108__textarea", "div": "_8c15fd0ed9f28ba4__div", "p": "_43cec3e1eec1066d__p", "heading": "e97669c6d9a38497__heading", "a": "_2c0831b0499dbd6e__a", "ol": "c59a0ebebd71fa4a__ol", "li": "_46b5cb0c8e24e8c9__li" };
23689 if (typeof process === "undefined" || true) {
23690 registerStyle27("df33c48b2d", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._2d5ad850b2f90964__label{--wp-ui-field-label-line-height:var(--wpds-typography-line-height-xs,16px);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-xs,11px);font-weight:var(--wpds-typography-font-weight-emphasis,600);line-height:var(--wp-ui-field-label-line-height);text-transform:uppercase;&._17c4214649230bea__is-plain{font-size:var(--wpds-typography-font-size-md,13px);font-weight:var(--wpds-typography-font-weight-default,400);text-transform:none}}._08a3750500e0233f__description{--_gcd-p-font-size:var(--wpds-typography-font-size-sm,12px);--_gcd-p-line-height:var(--wpds-typography-line-height-xs,16px);--_gcd-p-margin:0;text-wrap:pretty;color:var(--wpds-color-foreground-content-neutral-weak,#707070);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:var(--wpds-typography-line-height-xs,16px)}}}');
23691 }
23692 var field_default2 = { "label": "_2d5ad850b2f90964__label", "is-plain": "_17c4214649230bea__is-plain", "description": "_08a3750500e0233f__description" };
23693 var Description = (0, import_element54.forwardRef)(function Description2({ className, ...restProps }, ref) {
23694 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
23695 index_parts_exports2.Description,
23696 {
23697 ref,
23698 className: clsx_default(
23699 global_css_defense_default9.p,
23700 field_default2.description,
23701 className
23702 ),
23703 ...restProps
23704 }
23705 );
23706 });
23707
23708 // packages/ui/build-module/form/primitives/field/details.mjs
23709 var import_element55 = __toESM(require_element(), 1);
23710 var import_i18n8 = __toESM(require_i18n(), 1);
23711 var import_jsx_runtime84 = __toESM(require_jsx_runtime(), 1);
23712 var STYLE_HASH_ATTRIBUTE28 = "data-wp-hash";
23713 function getRuntime28() {
23714 const globalScope = globalThis;
23715 if (globalScope.__wpStyleRuntime) {
23716 return globalScope.__wpStyleRuntime;
23717 }
23718 globalScope.__wpStyleRuntime = {
23719 documents: /* @__PURE__ */ new Map(),
23720 styles: /* @__PURE__ */ new Map(),
23721 injectedStyles: /* @__PURE__ */ new WeakMap()
23722 };
23723 if (typeof document !== "undefined") {
23724 registerDocument28(document);
23725 }
23726 return globalScope.__wpStyleRuntime;
23727 }
23728 function documentContainsStyleHash28(targetDocument, hash) {
23729 if (!targetDocument.head) {
23730 return false;
23731 }
23732 for (const style of targetDocument.head.querySelectorAll(
23733 `style[${STYLE_HASH_ATTRIBUTE28}]`
23734 )) {
23735 if (style.getAttribute(STYLE_HASH_ATTRIBUTE28) === hash) {
23736 return true;
23737 }
23738 }
23739 return false;
23740 }
23741 function injectStyle28(targetDocument, hash, css) {
23742 if (!targetDocument.head) {
23743 return;
23744 }
23745 const runtime = getRuntime28();
23746 let injectedStyles = runtime.injectedStyles.get(targetDocument);
23747 if (!injectedStyles) {
23748 injectedStyles = /* @__PURE__ */ new Set();
23749 runtime.injectedStyles.set(targetDocument, injectedStyles);
23750 }
23751 if (injectedStyles.has(hash)) {
23752 return;
23753 }
23754 if (documentContainsStyleHash28(targetDocument, hash)) {
23755 injectedStyles.add(hash);
23756 return;
23757 }
23758 const style = targetDocument.createElement("style");
23759 style.setAttribute(STYLE_HASH_ATTRIBUTE28, hash);
23760 style.appendChild(targetDocument.createTextNode(css));
23761 targetDocument.head.appendChild(style);
23762 injectedStyles.add(hash);
23763 }
23764 function registerDocument28(targetDocument) {
23765 const runtime = getRuntime28();
23766 runtime.documents.set(
23767 targetDocument,
23768 (runtime.documents.get(targetDocument) ?? 0) + 1
23769 );
23770 for (const [hash, css] of runtime.styles) {
23771 injectStyle28(targetDocument, hash, css);
23772 }
23773 return () => {
23774 const count = runtime.documents.get(targetDocument);
23775 if (count === void 0) {
23776 return;
23777 }
23778 if (count <= 1) {
23779 runtime.documents.delete(targetDocument);
23780 return;
23781 }
23782 runtime.documents.set(targetDocument, count - 1);
23783 };
23784 }
23785 function registerStyle28(hash, css) {
23786 const runtime = getRuntime28();
23787 runtime.styles.set(hash, css);
23788 for (const targetDocument of runtime.documents.keys()) {
23789 injectStyle28(targetDocument, hash, css);
23790 }
23791 }
23792 if (typeof process === "undefined" || true) {
23793 registerStyle28("df33c48b2d", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._2d5ad850b2f90964__label{--wp-ui-field-label-line-height:var(--wpds-typography-line-height-xs,16px);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-xs,11px);font-weight:var(--wpds-typography-font-weight-emphasis,600);line-height:var(--wp-ui-field-label-line-height);text-transform:uppercase;&._17c4214649230bea__is-plain{font-size:var(--wpds-typography-font-size-md,13px);font-weight:var(--wpds-typography-font-weight-default,400);text-transform:none}}._08a3750500e0233f__description{--_gcd-p-font-size:var(--wpds-typography-font-size-sm,12px);--_gcd-p-line-height:var(--wpds-typography-line-height-xs,16px);--_gcd-p-margin:0;text-wrap:pretty;color:var(--wpds-color-foreground-content-neutral-weak,#707070);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:var(--wpds-typography-line-height-xs,16px)}}}');
23794 }
23795 var field_default3 = { "label": "_2d5ad850b2f90964__label", "is-plain": "_17c4214649230bea__is-plain", "description": "_08a3750500e0233f__description" };
23796 var Details = (0, import_element55.forwardRef)(
23797 function Details2({ className, ...restProps }, ref) {
23798 return /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(import_jsx_runtime84.Fragment, { children: [
23799 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(index_parts_exports2.Description, {}), children: (0, import_i18n8.__)("More details follow the field.") }),
23800 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
23801 "div",
23802 {
23803 ref,
23804 className: clsx_default(field_default3.description, className),
23805 ...restProps
23806 }
23807 )
23808 ] });
23809 }
23810 );
23811
23812 // packages/ui/build-module/form/primitives/field/control.mjs
23813 var import_element56 = __toESM(require_element(), 1);
23814 var import_jsx_runtime85 = __toESM(require_jsx_runtime(), 1);
23815 var Control = (0, import_element56.forwardRef)(
23816 function Control2(props, ref) {
23817 return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(index_parts_exports2.Control, { ref, ...props });
23818 }
23819 );
23820
23821 // packages/ui/build-module/form/primitives/field/visual-label.mjs
23822 var import_element57 = __toESM(require_element(), 1);
23823 var STYLE_HASH_ATTRIBUTE29 = "data-wp-hash";
23824 function getRuntime29() {
23825 const globalScope = globalThis;
23826 if (globalScope.__wpStyleRuntime) {
23827 return globalScope.__wpStyleRuntime;
23828 }
23829 globalScope.__wpStyleRuntime = {
23830 documents: /* @__PURE__ */ new Map(),
23831 styles: /* @__PURE__ */ new Map(),
23832 injectedStyles: /* @__PURE__ */ new WeakMap()
23833 };
23834 if (typeof document !== "undefined") {
23835 registerDocument29(document);
23836 }
23837 return globalScope.__wpStyleRuntime;
23838 }
23839 function documentContainsStyleHash29(targetDocument, hash) {
23840 if (!targetDocument.head) {
23841 return false;
23842 }
23843 for (const style of targetDocument.head.querySelectorAll(
23844 `style[${STYLE_HASH_ATTRIBUTE29}]`
23845 )) {
23846 if (style.getAttribute(STYLE_HASH_ATTRIBUTE29) === hash) {
23847 return true;
23848 }
23849 }
23850 return false;
23851 }
23852 function injectStyle29(targetDocument, hash, css) {
23853 if (!targetDocument.head) {
23854 return;
23855 }
23856 const runtime = getRuntime29();
23857 let injectedStyles = runtime.injectedStyles.get(targetDocument);
23858 if (!injectedStyles) {
23859 injectedStyles = /* @__PURE__ */ new Set();
23860 runtime.injectedStyles.set(targetDocument, injectedStyles);
23861 }
23862 if (injectedStyles.has(hash)) {
23863 return;
23864 }
23865 if (documentContainsStyleHash29(targetDocument, hash)) {
23866 injectedStyles.add(hash);
23867 return;
23868 }
23869 const style = targetDocument.createElement("style");
23870 style.setAttribute(STYLE_HASH_ATTRIBUTE29, hash);
23871 style.appendChild(targetDocument.createTextNode(css));
23872 targetDocument.head.appendChild(style);
23873 injectedStyles.add(hash);
23874 }
23875 function registerDocument29(targetDocument) {
23876 const runtime = getRuntime29();
23877 runtime.documents.set(
23878 targetDocument,
23879 (runtime.documents.get(targetDocument) ?? 0) + 1
23880 );
23881 for (const [hash, css] of runtime.styles) {
23882 injectStyle29(targetDocument, hash, css);
23883 }
23884 return () => {
23885 const count = runtime.documents.get(targetDocument);
23886 if (count === void 0) {
23887 return;
23888 }
23889 if (count <= 1) {
23890 runtime.documents.delete(targetDocument);
23891 return;
23892 }
23893 runtime.documents.set(targetDocument, count - 1);
23894 };
23895 }
23896 function registerStyle29(hash, css) {
23897 const runtime = getRuntime29();
23898 runtime.styles.set(hash, css);
23899 for (const targetDocument of runtime.documents.keys()) {
23900 injectStyle29(targetDocument, hash, css);
23901 }
23902 }
23903 if (typeof process === "undefined" || true) {
23904 registerStyle29("df33c48b2d", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._2d5ad850b2f90964__label{--wp-ui-field-label-line-height:var(--wpds-typography-line-height-xs,16px);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-xs,11px);font-weight:var(--wpds-typography-font-weight-emphasis,600);line-height:var(--wp-ui-field-label-line-height);text-transform:uppercase;&._17c4214649230bea__is-plain{font-size:var(--wpds-typography-font-size-md,13px);font-weight:var(--wpds-typography-font-weight-default,400);text-transform:none}}._08a3750500e0233f__description{--_gcd-p-font-size:var(--wpds-typography-font-size-sm,12px);--_gcd-p-line-height:var(--wpds-typography-line-height-xs,16px);--_gcd-p-margin:0;text-wrap:pretty;color:var(--wpds-color-foreground-content-neutral-weak,#707070);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:var(--wpds-typography-line-height-xs,16px)}}}');
23905 }
23906 var field_default4 = { "label": "_2d5ad850b2f90964__label", "is-plain": "_17c4214649230bea__is-plain", "description": "_08a3750500e0233f__description" };
23907 var VisualLabel = (0, import_element57.forwardRef)(
23908 function VisualLabel2({ className, render: render4, variant, ...restProps }, ref) {
23909 return useRender({
23910 defaultTagName: "span",
23911 render: render4,
23912 ref,
23913 props: mergeProps(restProps, {
23914 className: clsx_default(
23915 field_default4.label,
23916 variant && field_default4[`is-${variant}`],
23917 className
23918 )
23919 })
23920 });
23921 }
23922 );
23923 VisualLabel.displayName = "Field.VisualLabel";
23924
23925 // packages/ui/build-module/form/primitives/textarea/textarea.mjs
23926 var import_element58 = __toESM(require_element(), 1);
23927 var import_jsx_runtime86 = __toESM(require_jsx_runtime(), 1);
23928 var STYLE_HASH_ATTRIBUTE30 = "data-wp-hash";
23929 function getRuntime30() {
23930 const globalScope = globalThis;
23931 if (globalScope.__wpStyleRuntime) {
23932 return globalScope.__wpStyleRuntime;
23933 }
23934 globalScope.__wpStyleRuntime = {
23935 documents: /* @__PURE__ */ new Map(),
23936 styles: /* @__PURE__ */ new Map(),
23937 injectedStyles: /* @__PURE__ */ new WeakMap()
23938 };
23939 if (typeof document !== "undefined") {
23940 registerDocument30(document);
23941 }
23942 return globalScope.__wpStyleRuntime;
23943 }
23944 function documentContainsStyleHash30(targetDocument, hash) {
23945 if (!targetDocument.head) {
23946 return false;
23947 }
23948 for (const style of targetDocument.head.querySelectorAll(
23949 `style[${STYLE_HASH_ATTRIBUTE30}]`
23950 )) {
23951 if (style.getAttribute(STYLE_HASH_ATTRIBUTE30) === hash) {
23952 return true;
23953 }
23954 }
23955 return false;
23956 }
23957 function injectStyle30(targetDocument, hash, css) {
23958 if (!targetDocument.head) {
23959 return;
23960 }
23961 const runtime = getRuntime30();
23962 let injectedStyles = runtime.injectedStyles.get(targetDocument);
23963 if (!injectedStyles) {
23964 injectedStyles = /* @__PURE__ */ new Set();
23965 runtime.injectedStyles.set(targetDocument, injectedStyles);
23966 }
23967 if (injectedStyles.has(hash)) {
23968 return;
23969 }
23970 if (documentContainsStyleHash30(targetDocument, hash)) {
23971 injectedStyles.add(hash);
23972 return;
23973 }
23974 const style = targetDocument.createElement("style");
23975 style.setAttribute(STYLE_HASH_ATTRIBUTE30, hash);
23976 style.appendChild(targetDocument.createTextNode(css));
23977 targetDocument.head.appendChild(style);
23978 injectedStyles.add(hash);
23979 }
23980 function registerDocument30(targetDocument) {
23981 const runtime = getRuntime30();
23982 runtime.documents.set(
23983 targetDocument,
23984 (runtime.documents.get(targetDocument) ?? 0) + 1
23985 );
23986 for (const [hash, css] of runtime.styles) {
23987 injectStyle30(targetDocument, hash, css);
23988 }
23989 return () => {
23990 const count = runtime.documents.get(targetDocument);
23991 if (count === void 0) {
23992 return;
23993 }
23994 if (count <= 1) {
23995 runtime.documents.delete(targetDocument);
23996 return;
23997 }
23998 runtime.documents.set(targetDocument, count - 1);
23999 };
24000 }
24001 function registerStyle30(hash, css) {
24002 const runtime = getRuntime30();
24003 runtime.styles.set(hash, css);
24004 for (const targetDocument of runtime.documents.keys()) {
24005 injectStyle30(targetDocument, hash, css);
24006 }
24007 }
24008 if (typeof process === "undefined" || true) {
24009 registerStyle30("1540cbc709", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._1e441c22c9dc5d28__wrapper{--wp-ui-textarea-min-height:var(--wpds-dimension-size-lg,40px)}._414844876c32ecee__textarea{min-height:calc(var(--wp-ui-textarea-min-height) - 2px);resize:block}}@layer compositions{._1e441c22c9dc5d28__wrapper{--wp-ui-input-padding-block:9.9px;height:auto;line-height:1.4}}}");
24010 }
24011 var style_default24 = { "wrapper": "_1e441c22c9dc5d28__wrapper", "textarea": "_414844876c32ecee__textarea" };
24012 if (typeof process === "undefined" || true) {
24013 registerStyle30("e8e31009f5", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-foreground-interactive-neutral-weak,#707070))}&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,transparent);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 transparent);color:var(--_gcd-input-color,var(--wpds-color-foreground-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,transparent);border-color:var(--_gcd-input-border-color-disabled,transparent);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid transparent)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-foreground-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-emphasis,600));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid transparent);transition:var(--_gcd-a-transition,none)}.c59a0ebebd71fa4a__ol{list-style:var(--_gcd-ol-list-style,none);margin:var(--_gcd-ol-margin,0);padding-block:var(--_gcd-ol-padding-block,0);padding-inline:var(--_gcd-ol-padding-inline,0)}._46b5cb0c8e24e8c9__li{margin:var(--_gcd-li-margin,0)}");
24014 }
24015 var global_css_defense_default10 = { "button": "_6defc79820e382c6__button", "input": "d2cff2e5dea83bd1__input", "textarea": "_547d86373d02e108__textarea", "div": "_8c15fd0ed9f28ba4__div", "p": "_43cec3e1eec1066d__p", "heading": "e97669c6d9a38497__heading", "a": "_2c0831b0499dbd6e__a", "ol": "c59a0ebebd71fa4a__ol", "li": "_46b5cb0c8e24e8c9__li" };
24016 var wrappedRender = (render4, restProps) => {
24017 return function textareaRender(props) {
24018 return typeof render4 === "function" ? render4(mergeProps(props, restProps)) : (0, import_element58.cloneElement)(render4, mergeProps(props, restProps));
24019 };
24020 };
24021 var Textarea = (0, import_element58.forwardRef)(
24022 function Textarea2({
24023 className,
24024 defaultValue,
24025 disabled: disabled2,
24026 onValueChange,
24027 render: render4,
24028 rows = 4,
24029 style,
24030 value,
24031 ...restProps
24032 }, ref) {
24033 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
24034 Input3,
24035 {
24036 className: clsx_default(style_default24.wrapper, className),
24037 style,
24038 render: wrappedRender(
24039 render4 || ((props) => /* @__PURE__ */ (0, import_jsx_runtime86.jsx)("textarea", { ...props })),
24040 {
24041 className: clsx_default(
24042 global_css_defense_default10.textarea,
24043 style_default24.textarea
24044 ),
24045 ref,
24046 rows,
24047 ...restProps
24048 }
24049 ),
24050 value,
24051 defaultValue,
24052 onValueChange,
24053 disabled: disabled2
24054 }
24055 );
24056 }
24057 );
24058
24059 // packages/ui/build-module/form/input-control/input-control.mjs
24060 var import_element59 = __toESM(require_element(), 1);
24061 var import_jsx_runtime87 = __toESM(require_jsx_runtime(), 1);
24062 var STYLE_HASH_ATTRIBUTE31 = "data-wp-hash";
24063 function getRuntime31() {
24064 const globalScope = globalThis;
24065 if (globalScope.__wpStyleRuntime) {
24066 return globalScope.__wpStyleRuntime;
24067 }
24068 globalScope.__wpStyleRuntime = {
24069 documents: /* @__PURE__ */ new Map(),
24070 styles: /* @__PURE__ */ new Map(),
24071 injectedStyles: /* @__PURE__ */ new WeakMap()
24072 };
24073 if (typeof document !== "undefined") {
24074 registerDocument31(document);
24075 }
24076 return globalScope.__wpStyleRuntime;
24077 }
24078 function documentContainsStyleHash31(targetDocument, hash) {
24079 if (!targetDocument.head) {
24080 return false;
24081 }
24082 for (const style of targetDocument.head.querySelectorAll(
24083 `style[${STYLE_HASH_ATTRIBUTE31}]`
24084 )) {
24085 if (style.getAttribute(STYLE_HASH_ATTRIBUTE31) === hash) {
24086 return true;
24087 }
24088 }
24089 return false;
24090 }
24091 function injectStyle31(targetDocument, hash, css) {
24092 if (!targetDocument.head) {
24093 return;
24094 }
24095 const runtime = getRuntime31();
24096 let injectedStyles = runtime.injectedStyles.get(targetDocument);
24097 if (!injectedStyles) {
24098 injectedStyles = /* @__PURE__ */ new Set();
24099 runtime.injectedStyles.set(targetDocument, injectedStyles);
24100 }
24101 if (injectedStyles.has(hash)) {
24102 return;
24103 }
24104 if (documentContainsStyleHash31(targetDocument, hash)) {
24105 injectedStyles.add(hash);
24106 return;
24107 }
24108 const style = targetDocument.createElement("style");
24109 style.setAttribute(STYLE_HASH_ATTRIBUTE31, hash);
24110 style.appendChild(targetDocument.createTextNode(css));
24111 targetDocument.head.appendChild(style);
24112 injectedStyles.add(hash);
24113 }
24114 function registerDocument31(targetDocument) {
24115 const runtime = getRuntime31();
24116 runtime.documents.set(
24117 targetDocument,
24118 (runtime.documents.get(targetDocument) ?? 0) + 1
24119 );
24120 for (const [hash, css] of runtime.styles) {
24121 injectStyle31(targetDocument, hash, css);
24122 }
24123 return () => {
24124 const count = runtime.documents.get(targetDocument);
24125 if (count === void 0) {
24126 return;
24127 }
24128 if (count <= 1) {
24129 runtime.documents.delete(targetDocument);
24130 return;
24131 }
24132 runtime.documents.set(targetDocument, count - 1);
24133 };
24134 }
24135 function registerStyle31(hash, css) {
24136 const runtime = getRuntime31();
24137 runtime.styles.set(hash, css);
24138 for (const targetDocument of runtime.documents.keys()) {
24139 injectStyle31(targetDocument, hash, css);
24140 }
24141 }
24142 if (typeof process === "undefined" || true) {
24143 registerStyle31("0c752c3d08", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer compositions{@supports (-webkit-hyphens:none) and (not (-moz-appearance:none)){.a9211a7e6af24bed__root input[type=date]:not([data-filled]):not(:focus),.a9211a7e6af24bed__root input[type=datetime-local]:not([data-filled]):not(:focus),.a9211a7e6af24bed__root input[type=time]:not([data-filled]):not(:focus){--_gcd-input-color:transparent;--_gcd-input-color-disabled:transparent;color:transparent;&:disabled::-webkit-datetime-edit-text{color:transparent}}}}}");
24144 }
24145 var style_default25 = { "root": "a9211a7e6af24bed__root" };
24146 var InputControl = (0, import_element59.forwardRef)(
24147 function InputControl2({
24148 className,
24149 label,
24150 description,
24151 details,
24152 hideLabelFromVision,
24153 ...restProps
24154 }, ref) {
24155 return /* @__PURE__ */ (0, import_jsx_runtime87.jsxs)(field_exports.Root, { className: clsx_default(style_default25.root, className), children: [
24156 /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(field_exports.Label, { hideFromVision: hideLabelFromVision, children: label }),
24157 /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(Input3, { ref, ...restProps }),
24158 description && /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(field_exports.Description, { children: description }),
24159 details && /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(field_exports.Details, { children: details })
24160 ] });
24161 }
24162 );
24163
24164 // packages/ui/build-module/form/textarea-control/textarea-control.mjs
24165 var import_element60 = __toESM(require_element(), 1);
24166 var import_jsx_runtime88 = __toESM(require_jsx_runtime(), 1);
24167 var TextareaControl = (0, import_element60.forwardRef)(function TextareaControl2({
24168 className,
24169 label,
24170 description,
24171 details,
24172 hideLabelFromVision,
24173 ...restProps
24174 }, ref) {
24175 return /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(field_exports.Root, { className, children: [
24176 /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(field_exports.Label, { hideFromVision: hideLabelFromVision, children: label }),
24177 /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(Textarea, { ref, ...restProps }),
24178 description && /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(field_exports.Description, { children: description }),
24179 details && /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(field_exports.Details, { children: details })
24180 ] });
24181 });
24182
24183 // packages/ui/build-module/form/with-validation/validated-input-control/validated-input-control.mjs
24184 var import_element61 = __toESM(require_element(), 1);
24185 var import_compose5 = __toESM(require_compose(), 1);
24186 var import_jsx_runtime89 = __toESM(require_jsx_runtime(), 1);
24187 var ValidatedInputControl = (0, import_element61.forwardRef)(function ValidatedInputControl2({ required, markWhenOptional, customValidity, ...restProps }, forwardedRef) {
24188 const validityTargetRef = (0, import_element61.useRef)(null);
24189 const mergedRefs = (0, import_compose5.useMergeRefs)([forwardedRef, validityTargetRef]);
24190 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
24191 ControlWithError,
24192 {
24193 required,
24194 markWhenOptional,
24195 customValidity,
24196 getValidityTarget: () => validityTargetRef.current,
24197 children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(InputControl, { ref: mergedRefs, ...restProps })
24198 }
24199 );
24200 });
24201
24202 // packages/ui/build-module/form/with-validation/validated-textarea-control/validated-textarea-control.mjs
24203 var import_element62 = __toESM(require_element(), 1);
24204 var import_compose6 = __toESM(require_compose(), 1);
24205 var import_jsx_runtime90 = __toESM(require_jsx_runtime(), 1);
24206 var ValidatedTextareaControl = (0, import_element62.forwardRef)(function ValidatedTextareaControl2({ required, markWhenOptional, customValidity, ...restProps }, forwardedRef) {
24207 const validityTargetRef = (0, import_element62.useRef)(null);
24208 const mergedRefs = (0, import_compose6.useMergeRefs)([forwardedRef, validityTargetRef]);
24209 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
24210 ControlWithError,
24211 {
24212 required,
24213 markWhenOptional,
24214 customValidity,
24215 getValidityTarget: () => validityTargetRef.current,
24216 children: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(TextareaControl, { ref: mergedRefs, ...restProps })
24217 }
24218 );
24219 });
24220
24221 // packages/ui/build-module/tabs/index.mjs
24222 var tabs_exports = {};
24223 __export(tabs_exports, {
24224 List: () => List,
24225 Panel: () => Panel2,
24226 Root: () => Root7,
24227 Tab: () => Tab
24228 });
24229
24230 // packages/ui/build-module/tabs/list.mjs
24231 var import_element63 = __toESM(require_element(), 1);
24232 var import_compose7 = __toESM(require_compose(), 1);
24233 var import_jsx_runtime91 = __toESM(require_jsx_runtime(), 1);
24234 var STYLE_HASH_ATTRIBUTE32 = "data-wp-hash";
24235 function getRuntime32() {
24236 const globalScope = globalThis;
24237 if (globalScope.__wpStyleRuntime) {
24238 return globalScope.__wpStyleRuntime;
24239 }
24240 globalScope.__wpStyleRuntime = {
24241 documents: /* @__PURE__ */ new Map(),
24242 styles: /* @__PURE__ */ new Map(),
24243 injectedStyles: /* @__PURE__ */ new WeakMap()
24244 };
24245 if (typeof document !== "undefined") {
24246 registerDocument32(document);
24247 }
24248 return globalScope.__wpStyleRuntime;
24249 }
24250 function documentContainsStyleHash32(targetDocument, hash) {
24251 if (!targetDocument.head) {
24252 return false;
24253 }
24254 for (const style of targetDocument.head.querySelectorAll(
24255 `style[${STYLE_HASH_ATTRIBUTE32}]`
24256 )) {
24257 if (style.getAttribute(STYLE_HASH_ATTRIBUTE32) === hash) {
24258 return true;
24259 }
24260 }
24261 return false;
24262 }
24263 function injectStyle32(targetDocument, hash, css) {
24264 if (!targetDocument.head) {
24265 return;
24266 }
24267 const runtime = getRuntime32();
24268 let injectedStyles = runtime.injectedStyles.get(targetDocument);
24269 if (!injectedStyles) {
24270 injectedStyles = /* @__PURE__ */ new Set();
24271 runtime.injectedStyles.set(targetDocument, injectedStyles);
24272 }
24273 if (injectedStyles.has(hash)) {
24274 return;
24275 }
24276 if (documentContainsStyleHash32(targetDocument, hash)) {
24277 injectedStyles.add(hash);
24278 return;
24279 }
24280 const style = targetDocument.createElement("style");
24281 style.setAttribute(STYLE_HASH_ATTRIBUTE32, hash);
24282 style.appendChild(targetDocument.createTextNode(css));
24283 targetDocument.head.appendChild(style);
24284 injectedStyles.add(hash);
24285 }
24286 function registerDocument32(targetDocument) {
24287 const runtime = getRuntime32();
24288 runtime.documents.set(
24289 targetDocument,
24290 (runtime.documents.get(targetDocument) ?? 0) + 1
24291 );
24292 for (const [hash, css] of runtime.styles) {
24293 injectStyle32(targetDocument, hash, css);
24294 }
24295 return () => {
24296 const count = runtime.documents.get(targetDocument);
24297 if (count === void 0) {
24298 return;
24299 }
24300 if (count <= 1) {
24301 runtime.documents.delete(targetDocument);
24302 return;
24303 }
24304 runtime.documents.set(targetDocument, count - 1);
24305 };
24306 }
24307 function registerStyle32(hash, css) {
24308 const runtime = getRuntime32();
24309 runtime.styles.set(hash, css);
24310 for (const targetDocument of runtime.documents.keys()) {
24311 injectStyle32(targetDocument, hash, css);
24312 }
24313 }
24314 if (typeof process === "undefined" || true) {
24315 registerStyle32("54ae3f4680", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._7313adbc8a112e90__tablist{--direction-start:left;--direction-end:right;align-items:stretch;display:flex;overflow-inline:auto;overscroll-behavior-inline:none;position:relative;&:dir(rtl){--direction-start:right;--direction-end:left}&[data-orientation=horizontal]{--fade-width:4rem;--fade-gradient-base:transparent 0%,#000 var(--fade-width);--fade-gradient-composed:var(--fade-gradient-base),#000 60%,transparent 50%;width:fit-content;&._9f2ac729c68a735a__is-overflowing-first{mask-image:linear-gradient(to var(--direction-end),var(--fade-gradient-base))}&._81c799c1f3cdd261__is-overflowing-last{mask-image:linear-gradient(to var(--direction-start),var(--fade-gradient-base))}&._9f2ac729c68a735a__is-overflowing-first._81c799c1f3cdd261__is-overflowing-last{mask-image:linear-gradient(to right,var(--fade-gradient-composed)),linear-gradient(to left,var(--fade-gradient-composed))}&._59228b5227f38a99__is-minimal-variant{gap:1rem}}&[data-orientation=vertical]{flex-direction:column}}._1c37dcfaa1ad8cda__indicator{@media not (prefers-reduced-motion){transition-duration:.2s;transition-property:translate,width,height,border-radius,border-block;transition-timing-function:ease-out}outline:2px solid transparent;outline-offset:-1px;pointer-events:none;position:absolute;&[data-orientation=horizontal]{background-color:var(--wpds-color-stroke-interactive-neutral-strong,#6e6e6e);bottom:0;height:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px));left:0;translate:var(--active-tab-left) 0;width:var(--active-tab-width);z-index:1}&[data-orientation=vertical]{background-color:var(--wpds-color-background-interactive-neutral-weak-active,#ededed);border-radius:var(--wpds-border-radius-sm,2px);height:var(--active-tab-height);left:50%;top:0;translate:-50% var(--active-tab-top);width:100%;z-index:0}._7313adbc8a112e90__tablist[data-select-on-move=true]:has(:focus-visible)\n &[data-orientation=vertical]{border:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9));box-sizing:border-box}}.a5fd8814f195aa5e__tab{align-items:center;background:transparent;border:none;border-radius:0;box-shadow:none;color:var(--wpds-color-foreground-interactive-neutral,#1e1e1e);cursor:var(--wpds-cursor-control,pointer);display:flex;flex:1 0 auto;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-md,13px);font-weight:400;line-height:1.2;outline:none;padding:0;position:relative;white-space:nowrap;z-index:1;&[data-disabled]{color:var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d);cursor:default;@media (forced-colors:active){color:GrayText}}&:not([data-disabled]):is(:hover,:focus-visible){color:var(--wpds-color-foreground-interactive-neutral-active,#1e1e1e)}&:after{border-radius:var(--wpds-border-radius-sm,2px);opacity:0;outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9));pointer-events:none;position:absolute;z-index:-1;@media not (prefers-reduced-motion){transition:opacity .1s linear}}&:focus-visible:after{opacity:1}[data-orientation=horizontal] &{height:48px;padding-inline:var(--wpds-dimension-padding-lg,16px);scroll-margin:24px;&:after{content:"";inset:var(--wpds-dimension-padding-md,12px)}}._59228b5227f38a99__is-minimal-variant[data-orientation=horizontal] &{padding-inline:0;&:after{inset-inline:round(up,var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)),1px)}}[data-orientation=vertical] &{min-height:var(--wpds-dimension-size-lg,40px);padding:var(--wpds-dimension-padding-sm,8px) var(--wpds-dimension-padding-md,12px)}[data-orientation=vertical][data-select-on-move=false] &:after{content:"";inset:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px))}}._5dfc77e6edd345d4__tab-children{align-items:center;display:flex;flex-grow:1;[data-orientation=horizontal] &{justify-content:center}[data-orientation=vertical] &{justify-content:start}}._4a20e969d15e5ac1__tab-chevron{flex-shrink:0;margin-inline-end:calc(var(--wpds-dimension-gap-xs, 4px)*-1);opacity:0;[data-orientation=horizontal] &{display:none}[role=tab]:is([aria-selected=true],:focus-visible,:hover) &{opacity:1}@media not (prefers-reduced-motion){[data-select-on-move=true]\n [role=tab]:is([aria-selected=true])\n &{transition:opacity .15s linear .15s}}&:dir(rtl){rotate:180deg}}}}');
24316 }
24317 var style_default26 = { "tablist": "_7313adbc8a112e90__tablist", "is-overflowing-first": "_9f2ac729c68a735a__is-overflowing-first", "is-overflowing-last": "_81c799c1f3cdd261__is-overflowing-last", "is-minimal-variant": "_59228b5227f38a99__is-minimal-variant", "indicator": "_1c37dcfaa1ad8cda__indicator", "tab": "a5fd8814f195aa5e__tab", "tab-children": "_5dfc77e6edd345d4__tab-children", "tab-chevron": "_4a20e969d15e5ac1__tab-chevron" };
24318 var SCROLL_EPSILON = 1;
24319 var List = (0, import_element63.forwardRef)(
24320 function TabList({
24321 children,
24322 variant = "default",
24323 className,
24324 activateOnFocus,
24325 ...otherProps
24326 }, forwardedRef) {
24327 const [listEl, setListEl] = (0, import_element63.useState)(null);
24328 const [overflow, setOverflow] = (0, import_element63.useState)({
24329 first: false,
24330 last: false,
24331 isScrolling: false
24332 });
24333 (0, import_element63.useEffect)(() => {
24334 if (!listEl) {
24335 return;
24336 }
24337 const measureOverflow = () => {
24338 const { scrollWidth, clientWidth, scrollLeft } = listEl;
24339 const maxScroll = Math.max(scrollWidth - clientWidth, 0);
24340 const direction = listEl.dir || (typeof window !== "undefined" ? window.getComputedStyle(listEl).direction : "ltr");
24341 const scrollFromStart = direction === "rtl" && scrollLeft < 0 ? (
24342 // In RTL layouts, scrollLeft is typically 0 at the visual "start"
24343 // (right edge) and becomes negative toward the "end" (left edge).
24344 // Normalize value for correct first/last detection logic.
24345 -scrollLeft
24346 ) : scrollLeft;
24347 const next = {
24348 first: scrollFromStart > SCROLL_EPSILON,
24349 last: scrollFromStart < maxScroll - SCROLL_EPSILON,
24350 isScrolling: scrollWidth > clientWidth
24351 };
24352 setOverflow(
24353 (prev) => prev.first === next.first && prev.last === next.last && prev.isScrolling === next.isScrolling ? prev : next
24354 );
24355 };
24356 const resizeObserver = new ResizeObserver(measureOverflow);
24357 const observeTabs = () => {
24358 resizeObserver.disconnect();
24359 resizeObserver.observe(listEl);
24360 listEl.querySelectorAll('[role="tab"]').forEach((tab) => resizeObserver.observe(tab));
24361 };
24362 const mutationObserver = new MutationObserver(observeTabs);
24363 mutationObserver.observe(listEl, {
24364 childList: true,
24365 subtree: true
24366 });
24367 let scrollTick = false;
24368 const throttleMeasureOverflowOnScroll = () => {
24369 if (!scrollTick) {
24370 requestAnimationFrame(() => {
24371 measureOverflow();
24372 scrollTick = false;
24373 });
24374 scrollTick = true;
24375 }
24376 };
24377 listEl.addEventListener(
24378 "scroll",
24379 throttleMeasureOverflowOnScroll,
24380 { passive: true }
24381 );
24382 observeTabs();
24383 measureOverflow();
24384 return () => {
24385 listEl.removeEventListener(
24386 "scroll",
24387 throttleMeasureOverflowOnScroll
24388 );
24389 resizeObserver.disconnect();
24390 mutationObserver.disconnect();
24391 };
24392 }, [listEl]);
24393 const mergedListRef = (0, import_compose7.useMergeRefs)([
24394 forwardedRef,
24395 (el) => setListEl(el)
24396 ]);
24397 return /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
24398 index_parts_exports3.List,
24399 {
24400 ref: mergedListRef,
24401 activateOnFocus,
24402 "data-select-on-move": activateOnFocus ? "true" : "false",
24403 className: clsx_default(
24404 style_default26.tablist,
24405 overflow.first && style_default26["is-overflowing-first"],
24406 overflow.last && style_default26["is-overflowing-last"],
24407 style_default26[`is-${variant}-variant`],
24408 className
24409 ),
24410 ...otherProps,
24411 tabIndex: otherProps.tabIndex ?? (overflow.isScrolling ? -1 : void 0),
24412 children: [
24413 children,
24414 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(index_parts_exports3.Indicator, { className: style_default26.indicator })
24415 ]
24416 }
24417 );
24418 }
24419 );
24420
24421 // packages/ui/build-module/tabs/panel.mjs
24422 var import_element65 = __toESM(require_element(), 1);
24423
24424 // packages/ui/build-module/tabs/context.mjs
24425 var import_element64 = __toESM(require_element(), 1);
24426 var import_jsx_runtime92 = __toESM(require_jsx_runtime(), 1);
24427 var VALIDATION_ENABLED = true;
24428 var TabsValidationContext = VALIDATION_ENABLED ? (0, import_element64.createContext)(null) : null;
24429 function useRegisterTabDev() {
24430 const context = (0, import_element64.useContext)(TabsValidationContext);
24431 (0, import_element64.useEffect)(() => {
24432 if (context) {
24433 return context.registerTab();
24434 }
24435 return void 0;
24436 }, [context]);
24437 }
24438 function useRegisterTabProd() {
24439 }
24440 var useRegisterTab = VALIDATION_ENABLED ? useRegisterTabDev : useRegisterTabProd;
24441 function useRegisterPanelDev() {
24442 const context = (0, import_element64.useContext)(TabsValidationContext);
24443 (0, import_element64.useEffect)(() => {
24444 if (context) {
24445 return context.registerPanel();
24446 }
24447 return void 0;
24448 }, [context]);
24449 }
24450 function useRegisterPanelProd() {
24451 }
24452 var useRegisterPanel = VALIDATION_ENABLED ? useRegisterPanelDev : useRegisterPanelProd;
24453 function TabsValidationProviderDev({
24454 children
24455 }) {
24456 const tabCountRef = (0, import_element64.useRef)(0);
24457 const panelCountRef = (0, import_element64.useRef)(0);
24458 const scheduleValidation = useScheduleValidation(() => {
24459 const tabCount = tabCountRef.current;
24460 const panelCount = panelCountRef.current;
24461 if (tabCount !== panelCount) {
24462 throw new Error(
24463 `Tabs: Tab/Panel count mismatch (${tabCount} Tabs, ${panelCount} Panels). Each Tab must be associated with exactly one Panel. Mismatched or missing associations can break screen reader navigation and violate WAI-ARIA Tabs pattern requirements.`
24464 );
24465 }
24466 });
24467 const registerTab = (0, import_element64.useCallback)(() => {
24468 tabCountRef.current += 1;
24469 scheduleValidation();
24470 return () => {
24471 tabCountRef.current -= 1;
24472 scheduleValidation();
24473 };
24474 }, [scheduleValidation]);
24475 const registerPanel = (0, import_element64.useCallback)(() => {
24476 panelCountRef.current += 1;
24477 scheduleValidation();
24478 return () => {
24479 panelCountRef.current -= 1;
24480 scheduleValidation();
24481 };
24482 }, [scheduleValidation]);
24483 const contextValue = (0, import_element64.useMemo)(
24484 () => ({
24485 registerTab,
24486 registerPanel
24487 }),
24488 [registerTab, registerPanel]
24489 );
24490 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(TabsValidationContext.Provider, { value: contextValue, children });
24491 }
24492 function TabsValidationProviderProd({
24493 children
24494 }) {
24495 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(import_jsx_runtime92.Fragment, { children });
24496 }
24497 var TabsValidationProvider = VALIDATION_ENABLED ? TabsValidationProviderDev : TabsValidationProviderProd;
24498
24499 // packages/ui/build-module/tabs/panel.mjs
24500 var import_jsx_runtime93 = __toESM(require_jsx_runtime(), 1);
24501 var STYLE_HASH_ATTRIBUTE33 = "data-wp-hash";
24502 function getRuntime33() {
24503 const globalScope = globalThis;
24504 if (globalScope.__wpStyleRuntime) {
24505 return globalScope.__wpStyleRuntime;
24506 }
24507 globalScope.__wpStyleRuntime = {
24508 documents: /* @__PURE__ */ new Map(),
24509 styles: /* @__PURE__ */ new Map(),
24510 injectedStyles: /* @__PURE__ */ new WeakMap()
24511 };
24512 if (typeof document !== "undefined") {
24513 registerDocument33(document);
24514 }
24515 return globalScope.__wpStyleRuntime;
24516 }
24517 function documentContainsStyleHash33(targetDocument, hash) {
24518 if (!targetDocument.head) {
24519 return false;
24520 }
24521 for (const style of targetDocument.head.querySelectorAll(
24522 `style[${STYLE_HASH_ATTRIBUTE33}]`
24523 )) {
24524 if (style.getAttribute(STYLE_HASH_ATTRIBUTE33) === hash) {
24525 return true;
24526 }
24527 }
24528 return false;
24529 }
24530 function injectStyle33(targetDocument, hash, css) {
24531 if (!targetDocument.head) {
24532 return;
24533 }
24534 const runtime = getRuntime33();
24535 let injectedStyles = runtime.injectedStyles.get(targetDocument);
24536 if (!injectedStyles) {
24537 injectedStyles = /* @__PURE__ */ new Set();
24538 runtime.injectedStyles.set(targetDocument, injectedStyles);
24539 }
24540 if (injectedStyles.has(hash)) {
24541 return;
24542 }
24543 if (documentContainsStyleHash33(targetDocument, hash)) {
24544 injectedStyles.add(hash);
24545 return;
24546 }
24547 const style = targetDocument.createElement("style");
24548 style.setAttribute(STYLE_HASH_ATTRIBUTE33, hash);
24549 style.appendChild(targetDocument.createTextNode(css));
24550 targetDocument.head.appendChild(style);
24551 injectedStyles.add(hash);
24552 }
24553 function registerDocument33(targetDocument) {
24554 const runtime = getRuntime33();
24555 runtime.documents.set(
24556 targetDocument,
24557 (runtime.documents.get(targetDocument) ?? 0) + 1
24558 );
24559 for (const [hash, css] of runtime.styles) {
24560 injectStyle33(targetDocument, hash, css);
24561 }
24562 return () => {
24563 const count = runtime.documents.get(targetDocument);
24564 if (count === void 0) {
24565 return;
24566 }
24567 if (count <= 1) {
24568 runtime.documents.delete(targetDocument);
24569 return;
24570 }
24571 runtime.documents.set(targetDocument, count - 1);
24572 };
24573 }
24574 function registerStyle33(hash, css) {
24575 const runtime = getRuntime33();
24576 runtime.styles.set(hash, css);
24577 for (const targetDocument of runtime.documents.keys()) {
24578 injectStyle33(targetDocument, hash, css);
24579 }
24580 }
24581 if (typeof process === "undefined" || true) {
24582 registerStyle33("e8e31009f5", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-foreground-interactive-neutral-weak,#707070))}&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,transparent);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 transparent);color:var(--_gcd-input-color,var(--wpds-color-foreground-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,transparent);border-color:var(--_gcd-input-border-color-disabled,transparent);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid transparent)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-foreground-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-emphasis,600));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid transparent);transition:var(--_gcd-a-transition,none)}.c59a0ebebd71fa4a__ol{list-style:var(--_gcd-ol-list-style,none);margin:var(--_gcd-ol-margin,0);padding-block:var(--_gcd-ol-padding-block,0);padding-inline:var(--_gcd-ol-padding-inline,0)}._46b5cb0c8e24e8c9__li{margin:var(--_gcd-li-margin,0)}");
24583 }
24584 var global_css_defense_default11 = { "button": "_6defc79820e382c6__button", "input": "d2cff2e5dea83bd1__input", "textarea": "_547d86373d02e108__textarea", "div": "_8c15fd0ed9f28ba4__div", "p": "_43cec3e1eec1066d__p", "heading": "e97669c6d9a38497__heading", "a": "_2c0831b0499dbd6e__a", "ol": "c59a0ebebd71fa4a__ol", "li": "_46b5cb0c8e24e8c9__li" };
24585 if (typeof process === "undefined" || true) {
24586 registerStyle33("08122b3d53", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{.af79fb116edb0dd7__outset-ring--focus:focus,.dfcfdc28396e5d98__outset-ring--focus-visible:focus-visible,.e5cd9ee879f6403a__outset-ring--focus-within:focus-within,:focus-visible ._81935a08e952f267__outset-ring--focus-parent-visible{--_gcd-a-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--focus-color,var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9)));--_gcd-div-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--focus-color,var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9)));outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--focus-color,var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9)));outline-offset:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px))}._3c9f5ee9fc9c136d__outset-ring--focus-within-except-active:focus-within,.abc777e9713fa711__outset-ring--focus-except-active:focus{outline:none}._3c9f5ee9fc9c136d__outset-ring--focus-within-except-active:focus-within:not(:has(:active)),.abc777e9713fa711__outset-ring--focus-except-active:focus:not(:active){--_gcd-a-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--focus-color,var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9)));--_gcd-div-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--focus-color,var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9)));outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--focus-color,var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9)));outline-offset:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px))}}}");
24587 }
24588 var focus_module_default6 = { "outset-ring--focus": "af79fb116edb0dd7__outset-ring--focus", "outset-ring--focus-visible": "dfcfdc28396e5d98__outset-ring--focus-visible", "outset-ring--focus-within": "e5cd9ee879f6403a__outset-ring--focus-within", "outset-ring--focus-parent-visible": "_81935a08e952f267__outset-ring--focus-parent-visible", "outset-ring--focus-except-active": "abc777e9713fa711__outset-ring--focus-except-active", "outset-ring--focus-within-except-active": "_3c9f5ee9fc9c136d__outset-ring--focus-within-except-active" };
24589 var Panel2 = (0, import_element65.forwardRef)(
24590 function TabPanel({ className, ...otherProps }, forwardedRef) {
24591 useRegisterPanel();
24592 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
24593 index_parts_exports3.Panel,
24594 {
24595 ref: forwardedRef,
24596 className: clsx_default(
24597 global_css_defense_default11.div,
24598 focus_module_default6["outset-ring--focus-visible"],
24599 className
24600 ),
24601 ...otherProps
24602 }
24603 );
24604 }
24605 );
24606
24607 // packages/ui/build-module/tabs/root.mjs
24608 var import_element66 = __toESM(require_element(), 1);
24609 var import_jsx_runtime94 = __toESM(require_jsx_runtime(), 1);
24610 var Root7 = (0, import_element66.forwardRef)(
24611 function TabsRoot3({ ...otherProps }, forwardedRef) {
24612 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(DirectionProvider3, { children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(TabsValidationProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(index_parts_exports3.Root, { ref: forwardedRef, ...otherProps }) }) });
24613 }
24614 );
24615
24616 // packages/ui/build-module/tabs/tab.mjs
24617 var import_element67 = __toESM(require_element(), 1);
24618 var import_jsx_runtime95 = __toESM(require_jsx_runtime(), 1);
24619 var STYLE_HASH_ATTRIBUTE34 = "data-wp-hash";
24620 function getRuntime34() {
24621 const globalScope = globalThis;
24622 if (globalScope.__wpStyleRuntime) {
24623 return globalScope.__wpStyleRuntime;
24624 }
24625 globalScope.__wpStyleRuntime = {
24626 documents: /* @__PURE__ */ new Map(),
24627 styles: /* @__PURE__ */ new Map(),
24628 injectedStyles: /* @__PURE__ */ new WeakMap()
24629 };
24630 if (typeof document !== "undefined") {
24631 registerDocument34(document);
24632 }
24633 return globalScope.__wpStyleRuntime;
24634 }
24635 function documentContainsStyleHash34(targetDocument, hash) {
24636 if (!targetDocument.head) {
24637 return false;
24638 }
24639 for (const style of targetDocument.head.querySelectorAll(
24640 `style[${STYLE_HASH_ATTRIBUTE34}]`
24641 )) {
24642 if (style.getAttribute(STYLE_HASH_ATTRIBUTE34) === hash) {
24643 return true;
24644 }
24645 }
24646 return false;
24647 }
24648 function injectStyle34(targetDocument, hash, css) {
24649 if (!targetDocument.head) {
24650 return;
24651 }
24652 const runtime = getRuntime34();
24653 let injectedStyles = runtime.injectedStyles.get(targetDocument);
24654 if (!injectedStyles) {
24655 injectedStyles = /* @__PURE__ */ new Set();
24656 runtime.injectedStyles.set(targetDocument, injectedStyles);
24657 }
24658 if (injectedStyles.has(hash)) {
24659 return;
24660 }
24661 if (documentContainsStyleHash34(targetDocument, hash)) {
24662 injectedStyles.add(hash);
24663 return;
24664 }
24665 const style = targetDocument.createElement("style");
24666 style.setAttribute(STYLE_HASH_ATTRIBUTE34, hash);
24667 style.appendChild(targetDocument.createTextNode(css));
24668 targetDocument.head.appendChild(style);
24669 injectedStyles.add(hash);
24670 }
24671 function registerDocument34(targetDocument) {
24672 const runtime = getRuntime34();
24673 runtime.documents.set(
24674 targetDocument,
24675 (runtime.documents.get(targetDocument) ?? 0) + 1
24676 );
24677 for (const [hash, css] of runtime.styles) {
24678 injectStyle34(targetDocument, hash, css);
24679 }
24680 return () => {
24681 const count = runtime.documents.get(targetDocument);
24682 if (count === void 0) {
24683 return;
24684 }
24685 if (count <= 1) {
24686 runtime.documents.delete(targetDocument);
24687 return;
24688 }
24689 runtime.documents.set(targetDocument, count - 1);
24690 };
24691 }
24692 function registerStyle34(hash, css) {
24693 const runtime = getRuntime34();
24694 runtime.styles.set(hash, css);
24695 for (const targetDocument of runtime.documents.keys()) {
24696 injectStyle34(targetDocument, hash, css);
24697 }
24698 }
24699 if (typeof process === "undefined" || true) {
24700 registerStyle34("54ae3f4680", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._7313adbc8a112e90__tablist{--direction-start:left;--direction-end:right;align-items:stretch;display:flex;overflow-inline:auto;overscroll-behavior-inline:none;position:relative;&:dir(rtl){--direction-start:right;--direction-end:left}&[data-orientation=horizontal]{--fade-width:4rem;--fade-gradient-base:transparent 0%,#000 var(--fade-width);--fade-gradient-composed:var(--fade-gradient-base),#000 60%,transparent 50%;width:fit-content;&._9f2ac729c68a735a__is-overflowing-first{mask-image:linear-gradient(to var(--direction-end),var(--fade-gradient-base))}&._81c799c1f3cdd261__is-overflowing-last{mask-image:linear-gradient(to var(--direction-start),var(--fade-gradient-base))}&._9f2ac729c68a735a__is-overflowing-first._81c799c1f3cdd261__is-overflowing-last{mask-image:linear-gradient(to right,var(--fade-gradient-composed)),linear-gradient(to left,var(--fade-gradient-composed))}&._59228b5227f38a99__is-minimal-variant{gap:1rem}}&[data-orientation=vertical]{flex-direction:column}}._1c37dcfaa1ad8cda__indicator{@media not (prefers-reduced-motion){transition-duration:.2s;transition-property:translate,width,height,border-radius,border-block;transition-timing-function:ease-out}outline:2px solid transparent;outline-offset:-1px;pointer-events:none;position:absolute;&[data-orientation=horizontal]{background-color:var(--wpds-color-stroke-interactive-neutral-strong,#6e6e6e);bottom:0;height:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px));left:0;translate:var(--active-tab-left) 0;width:var(--active-tab-width);z-index:1}&[data-orientation=vertical]{background-color:var(--wpds-color-background-interactive-neutral-weak-active,#ededed);border-radius:var(--wpds-border-radius-sm,2px);height:var(--active-tab-height);left:50%;top:0;translate:-50% var(--active-tab-top);width:100%;z-index:0}._7313adbc8a112e90__tablist[data-select-on-move=true]:has(:focus-visible)\n &[data-orientation=vertical]{border:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9));box-sizing:border-box}}.a5fd8814f195aa5e__tab{align-items:center;background:transparent;border:none;border-radius:0;box-shadow:none;color:var(--wpds-color-foreground-interactive-neutral,#1e1e1e);cursor:var(--wpds-cursor-control,pointer);display:flex;flex:1 0 auto;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-md,13px);font-weight:400;line-height:1.2;outline:none;padding:0;position:relative;white-space:nowrap;z-index:1;&[data-disabled]{color:var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d);cursor:default;@media (forced-colors:active){color:GrayText}}&:not([data-disabled]):is(:hover,:focus-visible){color:var(--wpds-color-foreground-interactive-neutral-active,#1e1e1e)}&:after{border-radius:var(--wpds-border-radius-sm,2px);opacity:0;outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9));pointer-events:none;position:absolute;z-index:-1;@media not (prefers-reduced-motion){transition:opacity .1s linear}}&:focus-visible:after{opacity:1}[data-orientation=horizontal] &{height:48px;padding-inline:var(--wpds-dimension-padding-lg,16px);scroll-margin:24px;&:after{content:"";inset:var(--wpds-dimension-padding-md,12px)}}._59228b5227f38a99__is-minimal-variant[data-orientation=horizontal] &{padding-inline:0;&:after{inset-inline:round(up,var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)),1px)}}[data-orientation=vertical] &{min-height:var(--wpds-dimension-size-lg,40px);padding:var(--wpds-dimension-padding-sm,8px) var(--wpds-dimension-padding-md,12px)}[data-orientation=vertical][data-select-on-move=false] &:after{content:"";inset:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px))}}._5dfc77e6edd345d4__tab-children{align-items:center;display:flex;flex-grow:1;[data-orientation=horizontal] &{justify-content:center}[data-orientation=vertical] &{justify-content:start}}._4a20e969d15e5ac1__tab-chevron{flex-shrink:0;margin-inline-end:calc(var(--wpds-dimension-gap-xs, 4px)*-1);opacity:0;[data-orientation=horizontal] &{display:none}[role=tab]:is([aria-selected=true],:focus-visible,:hover) &{opacity:1}@media not (prefers-reduced-motion){[data-select-on-move=true]\n [role=tab]:is([aria-selected=true])\n &{transition:opacity .15s linear .15s}}&:dir(rtl){rotate:180deg}}}}');
24701 }
24702 var style_default27 = { "tablist": "_7313adbc8a112e90__tablist", "is-overflowing-first": "_9f2ac729c68a735a__is-overflowing-first", "is-overflowing-last": "_81c799c1f3cdd261__is-overflowing-last", "is-minimal-variant": "_59228b5227f38a99__is-minimal-variant", "indicator": "_1c37dcfaa1ad8cda__indicator", "tab": "a5fd8814f195aa5e__tab", "tab-children": "_5dfc77e6edd345d4__tab-children", "tab-chevron": "_4a20e969d15e5ac1__tab-chevron" };
24703 var Tab = (0, import_element67.forwardRef)(function Tab2({ className, children, ...otherProps }, forwardedRef) {
24704 useRegisterTab();
24705 return /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(
24706 index_parts_exports3.Tab,
24707 {
24708 ref: forwardedRef,
24709 className: clsx_default(style_default27.tab, className),
24710 ...otherProps,
24711 children: [
24712 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)("span", { className: style_default27["tab-children"], children }),
24713 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(Icon, { icon: chevron_right_default, className: style_default27["tab-chevron"] })
24714 ]
24715 }
24716 );
24717 });
24718
24719 // packages/admin-ui/build-module/breadcrumbs/index.mjs
24720 var import_jsx_runtime96 = __toESM(require_jsx_runtime(), 1);
24721 var STYLE_HASH_ATTRIBUTE35 = "data-wp-hash";
24722 function getRuntime35() {
24723 const globalScope = globalThis;
24724 if (globalScope.__wpStyleRuntime) {
24725 return globalScope.__wpStyleRuntime;
24726 }
24727 globalScope.__wpStyleRuntime = {
24728 documents: /* @__PURE__ */ new Map(),
24729 styles: /* @__PURE__ */ new Map(),
24730 injectedStyles: /* @__PURE__ */ new WeakMap()
24731 };
24732 if (typeof document !== "undefined") {
24733 registerDocument35(document);
24734 }
24735 return globalScope.__wpStyleRuntime;
24736 }
24737 function documentContainsStyleHash35(targetDocument, hash) {
24738 if (!targetDocument.head) {
24739 return false;
24740 }
24741 for (const style of targetDocument.head.querySelectorAll(
24742 `style[${STYLE_HASH_ATTRIBUTE35}]`
24743 )) {
24744 if (style.getAttribute(STYLE_HASH_ATTRIBUTE35) === hash) {
24745 return true;
24746 }
24747 }
24748 return false;
24749 }
24750 function injectStyle35(targetDocument, hash, css) {
24751 if (!targetDocument.head) {
24752 return;
24753 }
24754 const runtime = getRuntime35();
24755 let injectedStyles = runtime.injectedStyles.get(targetDocument);
24756 if (!injectedStyles) {
24757 injectedStyles = /* @__PURE__ */ new Set();
24758 runtime.injectedStyles.set(targetDocument, injectedStyles);
24759 }
24760 if (injectedStyles.has(hash)) {
24761 return;
24762 }
24763 if (documentContainsStyleHash35(targetDocument, hash)) {
24764 injectedStyles.add(hash);
24765 return;
24766 }
24767 const style = targetDocument.createElement("style");
24768 style.setAttribute(STYLE_HASH_ATTRIBUTE35, hash);
24769 style.appendChild(targetDocument.createTextNode(css));
24770 targetDocument.head.appendChild(style);
24771 injectedStyles.add(hash);
24772 }
24773 function registerDocument35(targetDocument) {
24774 const runtime = getRuntime35();
24775 runtime.documents.set(
24776 targetDocument,
24777 (runtime.documents.get(targetDocument) ?? 0) + 1
24778 );
24779 for (const [hash, css] of runtime.styles) {
24780 injectStyle35(targetDocument, hash, css);
24781 }
24782 return () => {
24783 const count = runtime.documents.get(targetDocument);
24784 if (count === void 0) {
24785 return;
24786 }
24787 if (count <= 1) {
24788 runtime.documents.delete(targetDocument);
24789 return;
24790 }
24791 runtime.documents.set(targetDocument, count - 1);
24792 };
24793 }
24794 function registerStyle35(hash, css) {
24795 const runtime = getRuntime35();
24796 runtime.styles.set(hash, css);
24797 for (const targetDocument of runtime.documents.keys()) {
24798 injectStyle35(targetDocument, hash, css);
24799 }
24800 }
24801 if (typeof process === "undefined" || true) {
24802 registerStyle35("a90be4572a", "._5f4053eba32ce092__list{list-style:none;margin:0;padding:0}._5f4053eba32ce092__list>li{flex-shrink:0;margin:0}._5f4053eba32ce092__list>li:last-child{flex-shrink:1;min-width:0}.d1978551971a3360__current{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._6d9152063d443376__separator{color:var(--wpds-color-stroke-surface-neutral,#dbdbdb);margin:0 var(--wpds-dimension-gap-sm,8px);user-select:none}");
24803 }
24804 var style_default28 = { "list": "_5f4053eba32ce092__list", "current": "d1978551971a3360__current", "separator": "_6d9152063d443376__separator" };
24805 var Breadcrumbs = ({ items }) => {
24806 if (!items.length) {
24807 return null;
24808 }
24809 const precedingItems = items.slice(0, -1);
24810 const lastItem = items[items.length - 1];
24811 if (true) {
24812 const invalidItem = precedingItems.find((item) => !item.to);
24813 if (invalidItem) {
24814 throw new Error(
24815 `Breadcrumbs: item "${invalidItem.label}" is missing a \`to\` prop. All items except the last one must have a \`to\` prop.`
24816 );
24817 }
24818 }
24819 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)("nav", { "aria-label": (0, import_i18n9._x)("Breadcrumbs", "area label"), children: /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(
24820 Stack,
24821 {
24822 render: /* @__PURE__ */ (0, import_jsx_runtime96.jsx)("ul", {}),
24823 direction: "row",
24824 align: "center",
24825 className: style_default28.list,
24826 children: [
24827 precedingItems.map((item, index3) => /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)("li", { children: [
24828 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
24829 Text,
24830 {
24831 variant: "body-lg",
24832 render: /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
24833 Link,
24834 {
24835 tone: "neutral",
24836 render: /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(RouterLink, { to: item.to })
24837 }
24838 ),
24839 children: item.label
24840 }
24841 ),
24842 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
24843 Text,
24844 {
24845 variant: "body-lg",
24846 "aria-hidden": "true",
24847 className: style_default28.separator,
24848 children: "/"
24849 }
24850 )
24851 ] }, index3)),
24852 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)("li", { children: lastItem.to ? /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
24853 Text,
24854 {
24855 variant: "body-lg",
24856 render: /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
24857 Link,
24858 {
24859 tone: "neutral",
24860 render: /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(RouterLink, { to: lastItem.to })
24861 }
24862 ),
24863 children: lastItem.label
24864 }
24865 ) : /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
24866 Text,
24867 {
24868 variant: "heading-lg",
24869 render: /* @__PURE__ */ (0, import_jsx_runtime96.jsx)("h1", {}),
24870 className: style_default28.current,
24871 children: lastItem.label
24872 }
24873 ) })
24874 ]
24875 }
24876 ) });
24877 };
24878 var breadcrumbs_default = Breadcrumbs;
24879
24880 // packages/admin-ui/build-module/navigable-region/index.mjs
24881 var import_element68 = __toESM(require_element(), 1);
24882 var import_jsx_runtime97 = __toESM(require_jsx_runtime(), 1);
24883 var NavigableRegion = (0, import_element68.forwardRef)(
24884 ({ children, className, ariaLabel, as: Tag = "div", ...props }, ref) => {
24885 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
24886 Tag,
24887 {
24888 ref,
24889 className: clsx_default("admin-ui-navigable-region", className),
24890 "aria-label": ariaLabel,
24891 role: "region",
24892 tabIndex: "-1",
24893 ...props,
24894 children
24895 }
24896 );
24897 }
24898 );
24899 NavigableRegion.displayName = "NavigableRegion";
24900 var navigable_region_default = NavigableRegion;
24901
24902 // packages/admin-ui/build-module/navigation/index.mjs
24903 var import_i18n10 = __toESM(require_i18n(), 1);
24904 var import_jsx_runtime98 = __toESM(require_jsx_runtime(), 1);
24905 var STYLE_HASH_ATTRIBUTE36 = "data-wp-hash";
24906 function getRuntime36() {
24907 const globalScope = globalThis;
24908 if (globalScope.__wpStyleRuntime) {
24909 return globalScope.__wpStyleRuntime;
24910 }
24911 globalScope.__wpStyleRuntime = {
24912 documents: /* @__PURE__ */ new Map(),
24913 styles: /* @__PURE__ */ new Map(),
24914 injectedStyles: /* @__PURE__ */ new WeakMap()
24915 };
24916 if (typeof document !== "undefined") {
24917 registerDocument36(document);
24918 }
24919 return globalScope.__wpStyleRuntime;
24920 }
24921 function documentContainsStyleHash36(targetDocument, hash) {
24922 if (!targetDocument.head) {
24923 return false;
24924 }
24925 for (const style of targetDocument.head.querySelectorAll(
24926 `style[${STYLE_HASH_ATTRIBUTE36}]`
24927 )) {
24928 if (style.getAttribute(STYLE_HASH_ATTRIBUTE36) === hash) {
24929 return true;
24930 }
24931 }
24932 return false;
24933 }
24934 function injectStyle36(targetDocument, hash, css) {
24935 if (!targetDocument.head) {
24936 return;
24937 }
24938 const runtime = getRuntime36();
24939 let injectedStyles = runtime.injectedStyles.get(targetDocument);
24940 if (!injectedStyles) {
24941 injectedStyles = /* @__PURE__ */ new Set();
24942 runtime.injectedStyles.set(targetDocument, injectedStyles);
24943 }
24944 if (injectedStyles.has(hash)) {
24945 return;
24946 }
24947 if (documentContainsStyleHash36(targetDocument, hash)) {
24948 injectedStyles.add(hash);
24949 return;
24950 }
24951 const style = targetDocument.createElement("style");
24952 style.setAttribute(STYLE_HASH_ATTRIBUTE36, hash);
24953 style.appendChild(targetDocument.createTextNode(css));
24954 targetDocument.head.appendChild(style);
24955 injectedStyles.add(hash);
24956 }
24957 function registerDocument36(targetDocument) {
24958 const runtime = getRuntime36();
24959 runtime.documents.set(
24960 targetDocument,
24961 (runtime.documents.get(targetDocument) ?? 0) + 1
24962 );
24963 for (const [hash, css] of runtime.styles) {
24964 injectStyle36(targetDocument, hash, css);
24965 }
24966 return () => {
24967 const count = runtime.documents.get(targetDocument);
24968 if (count === void 0) {
24969 return;
24970 }
24971 if (count <= 1) {
24972 runtime.documents.delete(targetDocument);
24973 return;
24974 }
24975 runtime.documents.set(targetDocument, count - 1);
24976 };
24977 }
24978 function registerStyle36(hash, css) {
24979 const runtime = getRuntime36();
24980 runtime.styles.set(hash, css);
24981 for (const targetDocument of runtime.documents.keys()) {
24982 injectStyle36(targetDocument, hash, css);
24983 }
24984 }
24985 if (typeof process === "undefined" || true) {
24986 registerStyle36("72ef022400", ".bfb5a2dd8cceebd3__list{--focus-ring-size:calc(var(--wpds-border-width-focus, var(--wp-admin-border-width-focus, 2px))*2);list-style:none;margin:calc(var(--focus-ring-size)*-1);overflow-x:auto;padding:var(--focus-ring-size);scroll-padding:var(--focus-ring-size)}.a4759b4cb2c8bd92__li{flex-shrink:0}._07da506d3f2d9afe__item{align-items:center;color:var(--wpds-color-foreground-interactive-neutral-weak,#707070);display:flex;font-weight:var(--wpds-typography-font-weight-default,400);min-block-size:44px;min-inline-size:44px;text-decoration:none}._07da506d3f2d9afe__item:hover,._07da506d3f2d9afe__item[aria-current=page]{color:var(--wpds-color-foreground-interactive-neutral-weak-active,#1e1e1e)}._07da506d3f2d9afe__item[aria-current=page]{font-weight:var(--wpds-typography-font-weight-emphasis,600)}");
24987 }
24988 var style_default29 = { "list": "bfb5a2dd8cceebd3__list", "li": "a4759b4cb2c8bd92__li", "item": "_07da506d3f2d9afe__item" };
24989 var Navigation = ({
24990 items,
24991 currentHref,
24992 ariaLabel = (0, import_i18n10.__)("Sections"),
24993 linkComponent,
24994 className
24995 }) => {
24996 if (!items.length) {
24997 return null;
24998 }
24999 const LinkComponent = linkComponent ?? "a";
25000 if (true) {
25001 const invalidItem = items.find(
25002 (item) => typeof item.href !== "string"
25003 );
25004 if (invalidItem) {
25005 throw new Error(
25006 `Navigation: item "${invalidItem.label}" is missing an \`href\` prop.`
25007 );
25008 }
25009 const duplicate = items.find(
25010 (item, index3) => items.findIndex((other) => other.href === item.href) !== index3
25011 );
25012 if (duplicate) {
25013 throw new Error(
25014 `Navigation: duplicate \`href\` "${duplicate.href}". Each item must have a unique \`href\` so a single item receives \`aria-current="page"\`.`
25015 );
25016 }
25017 }
25018 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("nav", { "aria-label": ariaLabel, className, children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
25019 Stack,
25020 {
25021 render: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("ul", { role: "list" }),
25022 direction: "row",
25023 align: "center",
25024 gap: "md",
25025 className: style_default29.list,
25026 children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("li", { className: style_default29.li, children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
25027 Text,
25028 {
25029 variant: "body-md",
25030 className: style_default29.item,
25031 render: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
25032 Link,
25033 {
25034 variant: "unstyled",
25035 "aria-current": item.href === currentHref ? "page" : void 0,
25036 render: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(LinkComponent, { href: item.href })
25037 }
25038 ),
25039 children: item.label
25040 }
25041 ) }, item.href))
25042 }
25043 ) });
25044 };
25045 var navigation_default = Navigation;
25046
25047 // packages/admin-ui/build-module/page/sidebar-toggle-slot.mjs
25048 var import_components2 = __toESM(require_components(), 1);
25049 var { Fill: SidebarToggleFill, Slot: SidebarToggleSlot } = (0, import_components2.createSlotFill)("SidebarToggle");
25050
25051 // packages/admin-ui/build-module/page/header.mjs
25052 var import_jsx_runtime99 = __toESM(require_jsx_runtime(), 1);
25053 var STYLE_HASH_ATTRIBUTE37 = "data-wp-hash";
25054 function getRuntime37() {
25055 const globalScope = globalThis;
25056 if (globalScope.__wpStyleRuntime) {
25057 return globalScope.__wpStyleRuntime;
25058 }
25059 globalScope.__wpStyleRuntime = {
25060 documents: /* @__PURE__ */ new Map(),
25061 styles: /* @__PURE__ */ new Map(),
25062 injectedStyles: /* @__PURE__ */ new WeakMap()
25063 };
25064 if (typeof document !== "undefined") {
25065 registerDocument37(document);
25066 }
25067 return globalScope.__wpStyleRuntime;
25068 }
25069 function documentContainsStyleHash37(targetDocument, hash) {
25070 if (!targetDocument.head) {
25071 return false;
25072 }
25073 for (const style of targetDocument.head.querySelectorAll(
25074 `style[${STYLE_HASH_ATTRIBUTE37}]`
25075 )) {
25076 if (style.getAttribute(STYLE_HASH_ATTRIBUTE37) === hash) {
25077 return true;
25078 }
25079 }
25080 return false;
25081 }
25082 function injectStyle37(targetDocument, hash, css) {
25083 if (!targetDocument.head) {
25084 return;
25085 }
25086 const runtime = getRuntime37();
25087 let injectedStyles = runtime.injectedStyles.get(targetDocument);
25088 if (!injectedStyles) {
25089 injectedStyles = /* @__PURE__ */ new Set();
25090 runtime.injectedStyles.set(targetDocument, injectedStyles);
25091 }
25092 if (injectedStyles.has(hash)) {
25093 return;
25094 }
25095 if (documentContainsStyleHash37(targetDocument, hash)) {
25096 injectedStyles.add(hash);
25097 return;
25098 }
25099 const style = targetDocument.createElement("style");
25100 style.setAttribute(STYLE_HASH_ATTRIBUTE37, hash);
25101 style.appendChild(targetDocument.createTextNode(css));
25102 targetDocument.head.appendChild(style);
25103 injectedStyles.add(hash);
25104 }
25105 function registerDocument37(targetDocument) {
25106 const runtime = getRuntime37();
25107 runtime.documents.set(
25108 targetDocument,
25109 (runtime.documents.get(targetDocument) ?? 0) + 1
25110 );
25111 for (const [hash, css] of runtime.styles) {
25112 injectStyle37(targetDocument, hash, css);
25113 }
25114 return () => {
25115 const count = runtime.documents.get(targetDocument);
25116 if (count === void 0) {
25117 return;
25118 }
25119 if (count <= 1) {
25120 runtime.documents.delete(targetDocument);
25121 return;
25122 }
25123 runtime.documents.set(targetDocument, count - 1);
25124 };
25125 }
25126 function registerStyle37(hash, css) {
25127 const runtime = getRuntime37();
25128 runtime.styles.set(hash, css);
25129 for (const targetDocument of runtime.documents.keys()) {
25130 injectStyle37(targetDocument, hash, css);
25131 }
25132 }
25133 if (typeof process === "undefined" || true) {
25134 registerStyle37("1f3750277d", "._956b6df0898efed0__page{text-wrap:pretty;background-color:var(--wpds-color-background-surface-neutral,#fcfcfc);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:flex;flex-flow:column;height:100%;position:relative;z-index:1}._0625b55e82a0d93d__header{background:var(--wpds-color-background-surface-neutral-strong,#fff);border-block-end:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);inset-block-start:0;padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px);position:sticky;z-index:1}.a43c44d5ae28b2e8__header-content{min-height:var(--wpds-dimension-size-md,32px)}.b7cb5b9daf3a3b25__header-actions{flex-shrink:0}._8bcd33103b451f30__header-lockup{min-width:0}._8113be94e7caf73c__header-title{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._9a776c7f70996f61__header-visual{display:grid;flex-shrink:0;grid-template-columns:1fr;grid-template-rows:1fr;height:var(--wpds-dimension-size-sm,24px);width:var(--wpds-dimension-size-sm,24px);>*{grid-column:1/-1;grid-row:1/-1;max-height:100%;max-width:100%}}.d5e0920cd15d35bc__sidebar-toggle-slot:empty{display:none}._60fea2f6bf5319cd__header-subtitle{color:var(--wpds-color-foreground-content-neutral-weak,#707070);padding-block-end:var(--wpds-dimension-padding-xs,4px)}._0625b55e82a0d93d__header._4b0f17e503d11619__has-navigation,._0625b55e82a0d93d__header._4b0f17e503d11619__has-navigation ._60fea2f6bf5319cd__header-subtitle{padding-block-end:0}._673c99dcbfb58211__header-navigation{margin-block-start:var(--wpds-dimension-gap-md,12px)}.be5e57d029ec4036__content{display:flex;flex-direction:column;flex-grow:1;overflow:auto;&._128806d0b26e3a50__has-padding{padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px)}}");
25135 }
25136 var style_default30 = { "page": "_956b6df0898efed0__page", "header": "_0625b55e82a0d93d__header", "header-content": "a43c44d5ae28b2e8__header-content", "header-actions": "b7cb5b9daf3a3b25__header-actions", "header-lockup": "_8bcd33103b451f30__header-lockup", "header-title": "_8113be94e7caf73c__header-title", "header-visual": "_9a776c7f70996f61__header-visual", "sidebar-toggle-slot": "d5e0920cd15d35bc__sidebar-toggle-slot", "header-subtitle": "_60fea2f6bf5319cd__header-subtitle", "has-navigation": "_4b0f17e503d11619__has-navigation", "header-navigation": "_673c99dcbfb58211__header-navigation", "content": "be5e57d029ec4036__content", "has-padding": "_128806d0b26e3a50__has-padding" };
25137 function Header3({
25138 headingLevel = 1,
25139 breadcrumbs,
25140 badges,
25141 visual,
25142 title,
25143 subTitle,
25144 actions,
25145 navigation,
25146 components,
25147 showSidebarToggle = true
25148 }) {
25149 const HeadingTag = `h${headingLevel}`;
25150 const hasNavigation = !!navigation?.items?.length;
25151 return /* @__PURE__ */ (0, import_jsx_runtime99.jsxs)(
25152 Stack,
25153 {
25154 direction: "column",
25155 className: clsx_default(
25156 style_default30.header,
25157 hasNavigation && style_default30["has-navigation"]
25158 ),
25159 children: [
25160 /* @__PURE__ */ (0, import_jsx_runtime99.jsxs)(
25161 Stack,
25162 {
25163 className: style_default30["header-content"],
25164 direction: "row",
25165 gap: "sm",
25166 justify: "space-between",
25167 children: [
25168 /* @__PURE__ */ (0, import_jsx_runtime99.jsxs)(
25169 Stack,
25170 {
25171 direction: "row",
25172 gap: "sm",
25173 align: "center",
25174 justify: "start",
25175 className: style_default30["header-lockup"],
25176 children: [
25177 showSidebarToggle && /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
25178 SidebarToggleSlot,
25179 {
25180 bubblesVirtually: true,
25181 className: style_default30["sidebar-toggle-slot"]
25182 }
25183 ),
25184 visual && /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
25185 "div",
25186 {
25187 className: style_default30["header-visual"],
25188 "aria-hidden": "true",
25189 children: visual
25190 }
25191 ),
25192 title && /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
25193 Text,
25194 {
25195 className: style_default30["header-title"],
25196 render: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(HeadingTag, {}),
25197 variant: "heading-lg",
25198 children: title
25199 }
25200 ),
25201 breadcrumbs,
25202 badges
25203 ]
25204 }
25205 ),
25206 actions && /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
25207 Stack,
25208 {
25209 align: "center",
25210 className: style_default30["header-actions"],
25211 direction: "row",
25212 gap: "sm",
25213 children: actions
25214 }
25215 )
25216 ]
25217 }
25218 ),
25219 subTitle && /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
25220 Text,
25221 {
25222 render: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)("p", {}),
25223 variant: "body-md",
25224 className: style_default30["header-subtitle"],
25225 children: subTitle
25226 }
25227 ),
25228 hasNavigation && /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
25229 navigation_default,
25230 {
25231 ...navigation,
25232 linkComponent: components?.link,
25233 className: style_default30["header-navigation"]
25234 }
25235 )
25236 ]
25237 }
25238 );
25239 }
25240
25241 // packages/admin-ui/build-module/page/index.mjs
25242 var import_jsx_runtime100 = __toESM(require_jsx_runtime(), 1);
25243 var STYLE_HASH_ATTRIBUTE38 = "data-wp-hash";
25244 function getRuntime38() {
25245 const globalScope = globalThis;
25246 if (globalScope.__wpStyleRuntime) {
25247 return globalScope.__wpStyleRuntime;
25248 }
25249 globalScope.__wpStyleRuntime = {
25250 documents: /* @__PURE__ */ new Map(),
25251 styles: /* @__PURE__ */ new Map(),
25252 injectedStyles: /* @__PURE__ */ new WeakMap()
25253 };
25254 if (typeof document !== "undefined") {
25255 registerDocument38(document);
25256 }
25257 return globalScope.__wpStyleRuntime;
25258 }
25259 function documentContainsStyleHash38(targetDocument, hash) {
25260 if (!targetDocument.head) {
25261 return false;
25262 }
25263 for (const style of targetDocument.head.querySelectorAll(
25264 `style[${STYLE_HASH_ATTRIBUTE38}]`
25265 )) {
25266 if (style.getAttribute(STYLE_HASH_ATTRIBUTE38) === hash) {
25267 return true;
25268 }
25269 }
25270 return false;
25271 }
25272 function injectStyle38(targetDocument, hash, css) {
25273 if (!targetDocument.head) {
25274 return;
25275 }
25276 const runtime = getRuntime38();
25277 let injectedStyles = runtime.injectedStyles.get(targetDocument);
25278 if (!injectedStyles) {
25279 injectedStyles = /* @__PURE__ */ new Set();
25280 runtime.injectedStyles.set(targetDocument, injectedStyles);
25281 }
25282 if (injectedStyles.has(hash)) {
25283 return;
25284 }
25285 if (documentContainsStyleHash38(targetDocument, hash)) {
25286 injectedStyles.add(hash);
25287 return;
25288 }
25289 const style = targetDocument.createElement("style");
25290 style.setAttribute(STYLE_HASH_ATTRIBUTE38, hash);
25291 style.appendChild(targetDocument.createTextNode(css));
25292 targetDocument.head.appendChild(style);
25293 injectedStyles.add(hash);
25294 }
25295 function registerDocument38(targetDocument) {
25296 const runtime = getRuntime38();
25297 runtime.documents.set(
25298 targetDocument,
25299 (runtime.documents.get(targetDocument) ?? 0) + 1
25300 );
25301 for (const [hash, css] of runtime.styles) {
25302 injectStyle38(targetDocument, hash, css);
25303 }
25304 return () => {
25305 const count = runtime.documents.get(targetDocument);
25306 if (count === void 0) {
25307 return;
25308 }
25309 if (count <= 1) {
25310 runtime.documents.delete(targetDocument);
25311 return;
25312 }
25313 runtime.documents.set(targetDocument, count - 1);
25314 };
25315 }
25316 function registerStyle38(hash, css) {
25317 const runtime = getRuntime38();
25318 runtime.styles.set(hash, css);
25319 for (const targetDocument of runtime.documents.keys()) {
25320 injectStyle38(targetDocument, hash, css);
25321 }
25322 }
25323 if (typeof process === "undefined" || true) {
25324 registerStyle38("1f3750277d", "._956b6df0898efed0__page{text-wrap:pretty;background-color:var(--wpds-color-background-surface-neutral,#fcfcfc);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:flex;flex-flow:column;height:100%;position:relative;z-index:1}._0625b55e82a0d93d__header{background:var(--wpds-color-background-surface-neutral-strong,#fff);border-block-end:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);inset-block-start:0;padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px);position:sticky;z-index:1}.a43c44d5ae28b2e8__header-content{min-height:var(--wpds-dimension-size-md,32px)}.b7cb5b9daf3a3b25__header-actions{flex-shrink:0}._8bcd33103b451f30__header-lockup{min-width:0}._8113be94e7caf73c__header-title{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._9a776c7f70996f61__header-visual{display:grid;flex-shrink:0;grid-template-columns:1fr;grid-template-rows:1fr;height:var(--wpds-dimension-size-sm,24px);width:var(--wpds-dimension-size-sm,24px);>*{grid-column:1/-1;grid-row:1/-1;max-height:100%;max-width:100%}}.d5e0920cd15d35bc__sidebar-toggle-slot:empty{display:none}._60fea2f6bf5319cd__header-subtitle{color:var(--wpds-color-foreground-content-neutral-weak,#707070);padding-block-end:var(--wpds-dimension-padding-xs,4px)}._0625b55e82a0d93d__header._4b0f17e503d11619__has-navigation,._0625b55e82a0d93d__header._4b0f17e503d11619__has-navigation ._60fea2f6bf5319cd__header-subtitle{padding-block-end:0}._673c99dcbfb58211__header-navigation{margin-block-start:var(--wpds-dimension-gap-md,12px)}.be5e57d029ec4036__content{display:flex;flex-direction:column;flex-grow:1;overflow:auto;&._128806d0b26e3a50__has-padding{padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px)}}");
25325 }
25326 var style_default31 = { "page": "_956b6df0898efed0__page", "header": "_0625b55e82a0d93d__header", "header-content": "a43c44d5ae28b2e8__header-content", "header-actions": "b7cb5b9daf3a3b25__header-actions", "header-lockup": "_8bcd33103b451f30__header-lockup", "header-title": "_8113be94e7caf73c__header-title", "header-visual": "_9a776c7f70996f61__header-visual", "sidebar-toggle-slot": "d5e0920cd15d35bc__sidebar-toggle-slot", "header-subtitle": "_60fea2f6bf5319cd__header-subtitle", "has-navigation": "_4b0f17e503d11619__has-navigation", "header-navigation": "_673c99dcbfb58211__header-navigation", "content": "be5e57d029ec4036__content", "has-padding": "_128806d0b26e3a50__has-padding" };
25327 function Page({
25328 headingLevel,
25329 breadcrumbs,
25330 badges,
25331 visual,
25332 title,
25333 subTitle,
25334 children,
25335 className,
25336 actions,
25337 navigation,
25338 components,
25339 ariaLabel,
25340 hasPadding = false,
25341 showSidebarToggle = true
25342 }) {
25343 const classes = clsx_default(style_default31.page, className);
25344 const effectiveAriaLabel = ariaLabel ?? (typeof title === "string" ? title : "");
25345 return /* @__PURE__ */ (0, import_jsx_runtime100.jsxs)(navigable_region_default, { className: classes, ariaLabel: effectiveAriaLabel, children: [
25346 (title || breadcrumbs || badges || actions || visual || !!navigation?.items?.length) && /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
25347 Header3,
25348 {
25349 headingLevel,
25350 breadcrumbs,
25351 badges,
25352 visual,
25353 title,
25354 subTitle,
25355 actions,
25356 navigation,
25357 components,
25358 showSidebarToggle
25359 }
25360 ),
25361 hasPadding ? /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
25362 "div",
25363 {
25364 className: clsx_default(
25365 style_default31.content,
25366 style_default31["has-padding"]
25367 ),
25368 children
25369 }
25370 ) : children
25371 ] });
25372 }
25373 Page.SidebarToggleFill = SidebarToggleFill;
25374 var page_default = Page;
25375
25376 // routes/media-editor/stage.tsx
25377 var import_core_data3 = __toESM(require_core_data());
25378 var import_data5 = __toESM(require_data());
25379 var import_editor = __toESM(require_editor());
25380 var import_html_entities = __toESM(require_html_entities());
25381 var import_i18n47 = __toESM(require_i18n());
25382
25383 // packages/media-editor/build-module/components/media-editor-provider/index.mjs
25384 var import_element69 = __toESM(require_element(), 1);
25385 var import_jsx_runtime101 = __toESM(require_jsx_runtime(), 1);
25386 var MediaEditorContext = (0, import_element69.createContext)(
25387 void 0
25388 );
25389 function MediaEditorProvider({
25390 value,
25391 onChange,
25392 settings = {},
25393 children
25394 }) {
25395 const contextValue = {
25396 media: value,
25397 onChange,
25398 fields: settings.fields || []
25399 };
25400 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(MediaEditorContext.Provider, { value: contextValue, children });
25401 }
25402 function useMediaEditorContext() {
25403 const context = (0, import_element69.useContext)(MediaEditorContext);
25404 if (!context) {
25405 throw new Error(
25406 "useMediaEditorContext must be used within MediaEditorProvider"
25407 );
25408 }
25409 return context;
25410 }
25411
25412 // packages/media-editor/build-module/components/media-preview/index.mjs
25413 var import_components3 = __toESM(require_components(), 1);
25414 var import_element70 = __toESM(require_element(), 1);
25415 var import_i18n11 = __toESM(require_i18n(), 1);
25416
25417 // packages/media-editor/build-module/utils/get-media-type.mjs
25418 function getMediaTypeFromMimeType(mimeType) {
25419 if (!mimeType) {
25420 return { type: "application" };
25421 }
25422 if (mimeType.startsWith("image/")) {
25423 return { type: "image" };
25424 }
25425 if (mimeType.startsWith("video/")) {
25426 return { type: "video" };
25427 }
25428 if (mimeType.startsWith("audio/")) {
25429 return { type: "audio" };
25430 }
25431 return { type: "application" };
25432 }
25433
25434 // packages/media-editor/build-module/components/media-preview/index.mjs
25435 var import_jsx_runtime102 = __toESM(require_jsx_runtime(), 1);
25436 function MediaPreviewContent({
25437 mediaType,
25438 mediaUrl,
25439 altText,
25440 displayTitle,
25441 mimeType,
25442 onLoad,
25443 onError,
25444 loadingState
25445 }) {
25446 switch (mediaType.type) {
25447 case "image":
25448 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
25449 "img",
25450 {
25451 className: loadingState === "loaded" ? "loaded" : "",
25452 src: mediaUrl,
25453 alt: altText || "",
25454 onLoad,
25455 onError
25456 }
25457 );
25458 case "video":
25459 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)("video", { src: mediaUrl, controls: true, onError, children: displayTitle });
25460 case "audio":
25461 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)("audio", { src: mediaUrl, controls: true, onError, children: displayTitle });
25462 default:
25463 return /* @__PURE__ */ (0, import_jsx_runtime102.jsxs)("div", { className: "media-editor-preview__file-info", children: [
25464 /* @__PURE__ */ (0, import_jsx_runtime102.jsx)("p", { className: "media-editor-preview__file-name", children: displayTitle }),
25465 /* @__PURE__ */ (0, import_jsx_runtime102.jsx)("p", { className: "media-editor-preview__mime-type", children: mimeType }),
25466 /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
25467 "a",
25468 {
25469 href: mediaUrl,
25470 target: "_blank",
25471 rel: "noopener",
25472 className: "media-editor-preview__download-link",
25473 children: (0, import_i18n11.__)("View file")
25474 }
25475 )
25476 ] });
25477 }
25478 }
25479 function MediaPreview(props) {
25480 const [loadingState, setLoadingState] = (0, import_element70.useState)("loading");
25481 const { media } = useMediaEditorContext();
25482 const {
25483 source_url: mediaUrl,
25484 mime_type: mimeType,
25485 alt_text: altText,
25486 title
25487 } = media || {};
25488 const mediaType = getMediaTypeFromMimeType(mimeType);
25489 if (!mediaUrl) {
25490 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)("div", { className: "media-editor-preview media-editor-preview--empty", children: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)("p", { children: (0, import_i18n11.__)("No media file available.") }) });
25491 }
25492 if (loadingState === "error") {
25493 return /* @__PURE__ */ (0, import_jsx_runtime102.jsxs)("div", { className: "media-editor-preview media-editor-preview--error", children: [
25494 /* @__PURE__ */ (0, import_jsx_runtime102.jsx)("p", { children: (0, import_i18n11.__)("Failed to load media file.") }),
25495 /* @__PURE__ */ (0, import_jsx_runtime102.jsx)("p", { className: "media-editor-preview__url", children: mediaUrl })
25496 ] });
25497 }
25498 const displayTitle = typeof title === "string" ? title : title?.rendered || title?.raw;
25499 return /* @__PURE__ */ (0, import_jsx_runtime102.jsxs)(
25500 "div",
25501 {
25502 ...props,
25503 className: `media-editor-preview media-editor-preview--${mediaType.type}`,
25504 children: [
25505 mediaType.type === "image" && loadingState === "loading" && /* @__PURE__ */ (0, import_jsx_runtime102.jsx)("div", { className: "media-editor-preview__spinner", children: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(import_components3.Spinner, {}) }),
25506 /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
25507 MediaPreviewContent,
25508 {
25509 mediaType,
25510 mediaUrl,
25511 altText,
25512 displayTitle,
25513 mimeType,
25514 onLoad: () => setLoadingState("loaded"),
25515 onError: () => setLoadingState("error"),
25516 loadingState
25517 }
25518 )
25519 ]
25520 }
25521 );
25522 }
25523
25524 // packages/dataviews/build-module/constants.mjs
25525 var import_i18n12 = __toESM(require_i18n(), 1);
25526 var OPERATOR_IS_ANY = "isAny";
25527 var OPERATOR_IS_NONE = "isNone";
25528 var OPERATOR_IS_ALL = "isAll";
25529 var OPERATOR_IS_NOT_ALL = "isNotAll";
25530 var OPERATOR_BETWEEN = "between";
25531 var OPERATOR_IN_THE_PAST = "inThePast";
25532 var OPERATOR_OVER = "over";
25533 var OPERATOR_IS = "is";
25534 var OPERATOR_IS_NOT = "isNot";
25535 var OPERATOR_LESS_THAN = "lessThan";
25536 var OPERATOR_GREATER_THAN = "greaterThan";
25537 var OPERATOR_LESS_THAN_OR_EQUAL = "lessThanOrEqual";
25538 var OPERATOR_GREATER_THAN_OR_EQUAL = "greaterThanOrEqual";
25539 var OPERATOR_BEFORE = "before";
25540 var OPERATOR_AFTER = "after";
25541 var OPERATOR_BEFORE_INC = "beforeInc";
25542 var OPERATOR_AFTER_INC = "afterInc";
25543 var OPERATOR_CONTAINS = "contains";
25544 var OPERATOR_NOT_CONTAINS = "notContains";
25545 var OPERATOR_STARTS_WITH = "startsWith";
25546 var OPERATOR_ON = "on";
25547 var OPERATOR_NOT_ON = "notOn";
25548 var sortLabels = {
25549 asc: (0, import_i18n12.__)("Sort ascending"),
25550 desc: (0, import_i18n12.__)("Sort descending")
25551 };
25552
25553 // packages/dataviews/build-module/hooks/use-elements.mjs
25554 var import_element71 = __toESM(require_element(), 1);
25555 var EMPTY_ARRAY2 = [];
25556 function useElements({
25557 elements,
25558 getElements
25559 }) {
25560 const staticElements = Array.isArray(elements) && elements.length > 0 ? elements : EMPTY_ARRAY2;
25561 const [records, setRecords] = (0, import_element71.useState)(staticElements);
25562 const [isLoading, setIsLoading] = (0, import_element71.useState)(false);
25563 (0, import_element71.useEffect)(() => {
25564 if (!getElements) {
25565 setRecords(staticElements);
25566 return;
25567 }
25568 let cancelled = false;
25569 setIsLoading(true);
25570 getElements().then((fetchedElements) => {
25571 if (!cancelled) {
25572 const dynamicElements = Array.isArray(fetchedElements) && fetchedElements.length > 0 ? fetchedElements : staticElements;
25573 setRecords(dynamicElements);
25574 }
25575 }).catch(() => {
25576 if (!cancelled) {
25577 setRecords(staticElements);
25578 }
25579 }).finally(() => {
25580 if (!cancelled) {
25581 setIsLoading(false);
25582 }
25583 });
25584 return () => {
25585 cancelled = true;
25586 };
25587 }, [getElements, staticElements]);
25588 return {
25589 elements: records,
25590 isLoading
25591 };
25592 }
25593
25594 // packages/dataviews/build-module/utils/operators.mjs
25595 var import_i18n13 = __toESM(require_i18n(), 1);
25596 var import_element72 = __toESM(require_element(), 1);
25597 var import_date2 = __toESM(require_date(), 1);
25598
25599 // packages/dataviews/build-module/field-types/utils/parse-time.mjs
25600 var ZONE_DESIGNATOR = /(?:[Zz]|[+-](?:[01]\d|2[0-3]):?[0-5]\d)$/;
25601 var TIME_FORMATS = ["HH:mm", "HH:mm:ss"];
25602 var REFERENCE_DATE = new Date(2e3, 0, 1);
25603 function parseTime2(value) {
25604 if (typeof value !== "string") {
25605 return null;
25606 }
25607 const time = value.trim().replace(ZONE_DESIGNATOR, "");
25608 for (const timeFormat of TIME_FORMATS) {
25609 const parsed = parse(time, timeFormat, REFERENCE_DATE);
25610 if (isValid(parsed)) {
25611 return parsed.getHours() * 3600 + parsed.getMinutes() * 60 + parsed.getSeconds();
25612 }
25613 }
25614 return null;
25615 }
25616
25617 // packages/dataviews/build-module/utils/operators.mjs
25618 var import_jsx_runtime103 = __toESM(require_jsx_runtime(), 1);
25619 var filterTextWrappers = {
25620 Name: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("span", { className: "dataviews-filters__summary-filter-text-name" }),
25621 Value: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("span", { className: "dataviews-filters__summary-filter-text-value" })
25622 };
25623 function toComparableTemporals(fieldValue, filterValue) {
25624 const filterTime = parseTime2(filterValue);
25625 if (filterTime !== null) {
25626 return [parseTime2(fieldValue) ?? NaN, filterTime];
25627 }
25628 return [
25629 (0, import_date2.getDate)(fieldValue).getTime(),
25630 (0, import_date2.getDate)(filterValue).getTime()
25631 ];
25632 }
25633 function getRelativeDate(value, unit) {
25634 switch (unit) {
25635 case "days":
25636 return subDays(/* @__PURE__ */ new Date(), value);
25637 case "weeks":
25638 return subWeeks(/* @__PURE__ */ new Date(), value);
25639 case "months":
25640 return subMonths(/* @__PURE__ */ new Date(), value);
25641 case "years":
25642 return subYears(/* @__PURE__ */ new Date(), value);
25643 default:
25644 return /* @__PURE__ */ new Date();
25645 }
25646 }
25647 var isNoneOperatorDefinition = {
25648 /* translators: DataViews operator name */
25649 label: (0, import_i18n13.__)("Is none of"),
25650 filterText: (filter, activeElements) => (0, import_element72.createInterpolateElement)(
25651 (0, import_i18n13.sprintf)(
25652 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */
25653 (0, import_i18n13.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"),
25654 filter.name,
25655 activeElements.map((element) => element.label).join(", ")
25656 ),
25657 filterTextWrappers
25658 ),
25659 filter: ((item, field, filterValue) => {
25660 if (!filterValue?.length) {
25661 return true;
25662 }
25663 const fieldValue = field.getValue({ item });
25664 if (Array.isArray(fieldValue)) {
25665 return !filterValue.some(
25666 (fv) => fieldValue.includes(fv)
25667 );
25668 } else if (typeof fieldValue === "string" || typeof fieldValue === "number") {
25669 return !filterValue.includes(fieldValue);
25670 }
25671 return false;
25672 }),
25673 selection: "multi"
25674 };
25675 var OPERATORS = [
25676 {
25677 name: OPERATOR_IS_ANY,
25678 /* translators: DataViews operator name */
25679 label: (0, import_i18n13.__)("Includes"),
25680 filterText: (filter, activeElements) => (0, import_element72.createInterpolateElement)(
25681 (0, import_i18n13.sprintf)(
25682 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is any: Admin, Editor". */
25683 (0, import_i18n13.__)("<Name>%1$s includes: </Name><Value>%2$s</Value>"),
25684 filter.name,
25685 activeElements.map((element) => element.label).join(", ")
25686 ),
25687 filterTextWrappers
25688 ),
25689 filter(item, field, filterValue) {
25690 if (!filterValue?.length) {
25691 return true;
25692 }
25693 const fieldValue = field.getValue({ item });
25694 if (Array.isArray(fieldValue)) {
25695 return filterValue.some(
25696 (fv) => fieldValue.includes(fv)
25697 );
25698 } else if (typeof fieldValue === "string" || typeof fieldValue === "number") {
25699 return filterValue.includes(fieldValue);
25700 }
25701 return false;
25702 },
25703 selection: "multi"
25704 },
25705 {
25706 name: OPERATOR_IS_NONE,
25707 ...isNoneOperatorDefinition
25708 },
25709 {
25710 name: OPERATOR_IS_ALL,
25711 /* translators: DataViews operator name */
25712 label: (0, import_i18n13.__)("Includes all"),
25713 filterText: (filter, activeElements) => (0, import_element72.createInterpolateElement)(
25714 (0, import_i18n13.sprintf)(
25715 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author includes all: Admin, Editor". */
25716 (0, import_i18n13.__)("<Name>%1$s includes all: </Name><Value>%2$s</Value>"),
25717 filter.name,
25718 activeElements.map((element) => element.label).join(", ")
25719 ),
25720 filterTextWrappers
25721 ),
25722 filter(item, field, filterValue) {
25723 if (!filterValue?.length) {
25724 return true;
25725 }
25726 const fieldValue = field.getValue({ item });
25727 if (!Array.isArray(fieldValue)) {
25728 return false;
25729 }
25730 return filterValue.every(
25731 (value) => fieldValue.includes(value)
25732 );
25733 },
25734 selection: "multi"
25735 },
25736 {
25737 name: OPERATOR_IS_NOT_ALL,
25738 ...isNoneOperatorDefinition
25739 },
25740 {
25741 name: OPERATOR_BETWEEN,
25742 /* translators: DataViews operator name */
25743 label: (0, import_i18n13.__)("Between (inc)"),
25744 filterText: (filter, activeElements) => (0, import_element72.createInterpolateElement)(
25745 (0, import_i18n13.sprintf)(
25746 /* translators: 1: Filter name (e.g. "Item count"). 2: Filter value min. 3: Filter value max. e.g.: "Item count between (inc): 10 and 180". */
25747 (0, import_i18n13.__)(
25748 "<Name>%1$s between (inc): </Name><Value>%2$s and %3$s</Value>"
25749 ),
25750 filter.name,
25751 activeElements[0].label[0],
25752 activeElements[0].label[1]
25753 ),
25754 filterTextWrappers
25755 ),
25756 filter(item, field, filterValue) {
25757 if (!Array.isArray(filterValue) || filterValue.length !== 2 || // An unfilled bound is `undefined` from the controls, `''`
25758 // when it arrives from a persisted view, or `null` once
25759 // `undefined` round-trips through JSON persistence.
25760 filterValue.includes(void 0) || filterValue.includes("") || filterValue.includes(null)) {
25761 return true;
25762 }
25763 const fieldValue = field.getValue({ item });
25764 const [min4, max4] = filterValue.map(parseTime2);
25765 if (min4 !== null && max4 !== null) {
25766 const value = parseTime2(fieldValue);
25767 return value !== null && value >= min4 && value <= max4;
25768 }
25769 if (typeof fieldValue === "number" || fieldValue instanceof Date || typeof fieldValue === "string") {
25770 return fieldValue >= filterValue[0] && fieldValue <= filterValue[1];
25771 }
25772 return false;
25773 },
25774 selection: "custom"
25775 },
25776 {
25777 name: OPERATOR_IN_THE_PAST,
25778 /* translators: DataViews operator name */
25779 label: (0, import_i18n13.__)("In the past"),
25780 filterText: (filter, activeElements) => (0, import_element72.createInterpolateElement)(
25781 (0, import_i18n13.sprintf)(
25782 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is in the past: 7 days". */
25783 (0, import_i18n13.__)(
25784 "<Name>%1$s is in the past: </Name><Value>%2$s</Value>"
25785 ),
25786 filter.name,
25787 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
25788 ),
25789 filterTextWrappers
25790 ),
25791 filter(item, field, filterValue) {
25792 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
25793 return true;
25794 }
25795 const targetDate = getRelativeDate(
25796 filterValue.value,
25797 filterValue.unit
25798 );
25799 const fieldValue = (0, import_date2.getDate)(field.getValue({ item }));
25800 return fieldValue >= targetDate && fieldValue <= /* @__PURE__ */ new Date();
25801 },
25802 selection: "custom"
25803 },
25804 {
25805 name: OPERATOR_OVER,
25806 /* translators: DataViews operator name */
25807 label: (0, import_i18n13.__)("Over"),
25808 filterText: (filter, activeElements) => (0, import_element72.createInterpolateElement)(
25809 (0, import_i18n13.sprintf)(
25810 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is over: 7 days". */
25811 (0, import_i18n13.__)("<Name>%1$s is over: </Name><Value>%2$s</Value>"),
25812 filter.name,
25813 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
25814 ),
25815 filterTextWrappers
25816 ),
25817 filter(item, field, filterValue) {
25818 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
25819 return true;
25820 }
25821 const targetDate = getRelativeDate(
25822 filterValue.value,
25823 filterValue.unit
25824 );
25825 const fieldValue = (0, import_date2.getDate)(field.getValue({ item }));
25826 return fieldValue < targetDate;
25827 },
25828 selection: "custom"
25829 },
25830 {
25831 name: OPERATOR_IS,
25832 /* translators: DataViews operator name */
25833 label: (0, import_i18n13.__)("Is"),
25834 filterText: (filter, activeElements) => (0, import_element72.createInterpolateElement)(
25835 (0, import_i18n13.sprintf)(
25836 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is: Admin". */
25837 (0, import_i18n13.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
25838 filter.name,
25839 activeElements[0].label
25840 ),
25841 filterTextWrappers
25842 ),
25843 filter(item, field, filterValue) {
25844 return filterValue === field.getValue({ item }) || filterValue === void 0;
25845 },
25846 selection: "single"
25847 },
25848 {
25849 name: OPERATOR_IS_NOT,
25850 /* translators: DataViews operator name */
25851 label: (0, import_i18n13.__)("Is not"),
25852 filterText: (filter, activeElements) => (0, import_element72.createInterpolateElement)(
25853 (0, import_i18n13.sprintf)(
25854 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is not: Admin". */
25855 (0, import_i18n13.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
25856 filter.name,
25857 activeElements[0].label
25858 ),
25859 filterTextWrappers
25860 ),
25861 filter(item, field, filterValue) {
25862 return filterValue !== field.getValue({ item });
25863 },
25864 selection: "single"
25865 },
25866 {
25867 name: OPERATOR_LESS_THAN,
25868 /* translators: DataViews operator name */
25869 label: (0, import_i18n13.__)("Less than"),
25870 filterText: (filter, activeElements) => (0, import_element72.createInterpolateElement)(
25871 (0, import_i18n13.sprintf)(
25872 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than: 10". */
25873 (0, import_i18n13.__)("<Name>%1$s is less than: </Name><Value>%2$s</Value>"),
25874 filter.name,
25875 activeElements[0].label
25876 ),
25877 filterTextWrappers
25878 ),
25879 filter(item, field, filterValue) {
25880 if (filterValue === void 0) {
25881 return true;
25882 }
25883 const fieldValue = field.getValue({ item });
25884 return fieldValue < filterValue;
25885 },
25886 selection: "single"
25887 },
25888 {
25889 name: OPERATOR_GREATER_THAN,
25890 /* translators: DataViews operator name */
25891 label: (0, import_i18n13.__)("Greater than"),
25892 filterText: (filter, activeElements) => (0, import_element72.createInterpolateElement)(
25893 (0, import_i18n13.sprintf)(
25894 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than: 10". */
25895 (0, import_i18n13.__)(
25896 "<Name>%1$s is greater than: </Name><Value>%2$s</Value>"
25897 ),
25898 filter.name,
25899 activeElements[0].label
25900 ),
25901 filterTextWrappers
25902 ),
25903 filter(item, field, filterValue) {
25904 if (filterValue === void 0) {
25905 return true;
25906 }
25907 const fieldValue = field.getValue({ item });
25908 return fieldValue > filterValue;
25909 },
25910 selection: "single"
25911 },
25912 {
25913 name: OPERATOR_LESS_THAN_OR_EQUAL,
25914 /* translators: DataViews operator name */
25915 label: (0, import_i18n13.__)("Less than or equal"),
25916 filterText: (filter, activeElements) => (0, import_element72.createInterpolateElement)(
25917 (0, import_i18n13.sprintf)(
25918 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than or equal to: 10". */
25919 (0, import_i18n13.__)(
25920 "<Name>%1$s is less than or equal to: </Name><Value>%2$s</Value>"
25921 ),
25922 filter.name,
25923 activeElements[0].label
25924 ),
25925 filterTextWrappers
25926 ),
25927 filter(item, field, filterValue) {
25928 if (filterValue === void 0) {
25929 return true;
25930 }
25931 const fieldValue = field.getValue({ item });
25932 return fieldValue <= filterValue;
25933 },
25934 selection: "single"
25935 },
25936 {
25937 name: OPERATOR_GREATER_THAN_OR_EQUAL,
25938 /* translators: DataViews operator name */
25939 label: (0, import_i18n13.__)("Greater than or equal"),
25940 filterText: (filter, activeElements) => (0, import_element72.createInterpolateElement)(
25941 (0, import_i18n13.sprintf)(
25942 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than or equal to: 10". */
25943 (0, import_i18n13.__)(
25944 "<Name>%1$s is greater than or equal to: </Name><Value>%2$s</Value>"
25945 ),
25946 filter.name,
25947 activeElements[0].label
25948 ),
25949 filterTextWrappers
25950 ),
25951 filter(item, field, filterValue) {
25952 if (filterValue === void 0) {
25953 return true;
25954 }
25955 const fieldValue = field.getValue({ item });
25956 return fieldValue >= filterValue;
25957 },
25958 selection: "single"
25959 },
25960 {
25961 name: OPERATOR_BEFORE,
25962 /* translators: DataViews operator name */
25963 label: (0, import_i18n13.__)("Before"),
25964 filterText: (filter, activeElements) => (0, import_element72.createInterpolateElement)(
25965 (0, import_i18n13.sprintf)(
25966 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is before: 2024-01-01". */
25967 (0, import_i18n13.__)("<Name>%1$s is before: </Name><Value>%2$s</Value>"),
25968 filter.name,
25969 activeElements[0].label
25970 ),
25971 filterTextWrappers
25972 ),
25973 filter(item, field, filterValue) {
25974 if (filterValue === void 0) {
25975 return true;
25976 }
25977 const [fieldTemporal, filterTemporal] = toComparableTemporals(
25978 field.getValue({ item }),
25979 filterValue
25980 );
25981 return fieldTemporal < filterTemporal;
25982 },
25983 selection: "single"
25984 },
25985 {
25986 name: OPERATOR_AFTER,
25987 /* translators: DataViews operator name */
25988 label: (0, import_i18n13.__)("After"),
25989 filterText: (filter, activeElements) => (0, import_element72.createInterpolateElement)(
25990 (0, import_i18n13.sprintf)(
25991 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is after: 2024-01-01". */
25992 (0, import_i18n13.__)("<Name>%1$s is after: </Name><Value>%2$s</Value>"),
25993 filter.name,
25994 activeElements[0].label
25995 ),
25996 filterTextWrappers
25997 ),
25998 filter(item, field, filterValue) {
25999 if (filterValue === void 0) {
26000 return true;
26001 }
26002 const [fieldTemporal, filterTemporal] = toComparableTemporals(
26003 field.getValue({ item }),
26004 filterValue
26005 );
26006 return fieldTemporal > filterTemporal;
26007 },
26008 selection: "single"
26009 },
26010 {
26011 name: OPERATOR_BEFORE_INC,
26012 /* translators: DataViews operator name */
26013 label: (0, import_i18n13.__)("Before (inc)"),
26014 filterText: (filter, activeElements) => (0, import_element72.createInterpolateElement)(
26015 (0, import_i18n13.sprintf)(
26016 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or before: 2024-01-01". */
26017 (0, import_i18n13.__)(
26018 "<Name>%1$s is on or before: </Name><Value>%2$s</Value>"
26019 ),
26020 filter.name,
26021 activeElements[0].label
26022 ),
26023 filterTextWrappers
26024 ),
26025 filter(item, field, filterValue) {
26026 if (filterValue === void 0) {
26027 return true;
26028 }
26029 const [fieldTemporal, filterTemporal] = toComparableTemporals(
26030 field.getValue({ item }),
26031 filterValue
26032 );
26033 return fieldTemporal <= filterTemporal;
26034 },
26035 selection: "single"
26036 },
26037 {
26038 name: OPERATOR_AFTER_INC,
26039 /* translators: DataViews operator name */
26040 label: (0, import_i18n13.__)("After (inc)"),
26041 filterText: (filter, activeElements) => (0, import_element72.createInterpolateElement)(
26042 (0, import_i18n13.sprintf)(
26043 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or after: 2024-01-01". */
26044 (0, import_i18n13.__)(
26045 "<Name>%1$s is on or after: </Name><Value>%2$s</Value>"
26046 ),
26047 filter.name,
26048 activeElements[0].label
26049 ),
26050 filterTextWrappers
26051 ),
26052 filter(item, field, filterValue) {
26053 if (filterValue === void 0) {
26054 return true;
26055 }
26056 const [fieldTemporal, filterTemporal] = toComparableTemporals(
26057 field.getValue({ item }),
26058 filterValue
26059 );
26060 return fieldTemporal >= filterTemporal;
26061 },
26062 selection: "single"
26063 },
26064 {
26065 name: OPERATOR_CONTAINS,
26066 /* translators: DataViews operator name */
26067 label: (0, import_i18n13.__)("Contains"),
26068 filterText: (filter, activeElements) => (0, import_element72.createInterpolateElement)(
26069 (0, import_i18n13.sprintf)(
26070 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title contains: Hello". */
26071 (0, import_i18n13.__)("<Name>%1$s contains: </Name><Value>%2$s</Value>"),
26072 filter.name,
26073 activeElements[0].label
26074 ),
26075 filterTextWrappers
26076 ),
26077 filter(item, field, filterValue) {
26078 if (filterValue === void 0) {
26079 return true;
26080 }
26081 const fieldValue = field.getValue({ item });
26082 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
26083 },
26084 selection: "single"
26085 },
26086 {
26087 name: OPERATOR_NOT_CONTAINS,
26088 /* translators: DataViews operator name */
26089 label: (0, import_i18n13.__)("Doesn't contain"),
26090 filterText: (filter, activeElements) => (0, import_element72.createInterpolateElement)(
26091 (0, import_i18n13.sprintf)(
26092 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title doesn't contain: Hello". */
26093 (0, import_i18n13.__)(
26094 "<Name>%1$s doesn't contain: </Name><Value>%2$s</Value>"
26095 ),
26096 filter.name,
26097 activeElements[0].label
26098 ),
26099 filterTextWrappers
26100 ),
26101 filter(item, field, filterValue) {
26102 if (filterValue === void 0) {
26103 return true;
26104 }
26105 const fieldValue = field.getValue({ item });
26106 return typeof fieldValue === "string" && filterValue && !fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
26107 },
26108 selection: "single"
26109 },
26110 {
26111 name: OPERATOR_STARTS_WITH,
26112 /* translators: DataViews operator name */
26113 label: (0, import_i18n13.__)("Starts with"),
26114 filterText: (filter, activeElements) => (0, import_element72.createInterpolateElement)(
26115 (0, import_i18n13.sprintf)(
26116 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title starts with: Hello". */
26117 (0, import_i18n13.__)("<Name>%1$s starts with: </Name><Value>%2$s</Value>"),
26118 filter.name,
26119 activeElements[0].label
26120 ),
26121 filterTextWrappers
26122 ),
26123 filter(item, field, filterValue) {
26124 if (filterValue === void 0) {
26125 return true;
26126 }
26127 const fieldValue = field.getValue({ item });
26128 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().startsWith(String(filterValue).toLowerCase());
26129 },
26130 selection: "single"
26131 },
26132 {
26133 name: OPERATOR_ON,
26134 /* translators: DataViews operator name */
26135 label: (0, import_i18n13.__)("On"),
26136 filterText: (filter, activeElements) => (0, import_element72.createInterpolateElement)(
26137 (0, import_i18n13.sprintf)(
26138 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is: 2024-01-01". */
26139 (0, import_i18n13.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
26140 filter.name,
26141 activeElements[0].label
26142 ),
26143 filterTextWrappers
26144 ),
26145 filter(item, field, filterValue) {
26146 if (filterValue === void 0) {
26147 return true;
26148 }
26149 const [fieldTemporal, filterTemporal] = toComparableTemporals(
26150 field.getValue({ item }),
26151 filterValue
26152 );
26153 return fieldTemporal === filterTemporal;
26154 },
26155 selection: "single"
26156 },
26157 {
26158 name: OPERATOR_NOT_ON,
26159 /* translators: DataViews operator name */
26160 label: (0, import_i18n13.__)("Not on"),
26161 filterText: (filter, activeElements) => (0, import_element72.createInterpolateElement)(
26162 (0, import_i18n13.sprintf)(
26163 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is not: 2024-01-01". */
26164 (0, import_i18n13.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
26165 filter.name,
26166 activeElements[0].label
26167 ),
26168 filterTextWrappers
26169 ),
26170 filter(item, field, filterValue) {
26171 if (filterValue === void 0) {
26172 return true;
26173 }
26174 const [fieldTemporal, filterTemporal] = toComparableTemporals(
26175 field.getValue({ item }),
26176 filterValue
26177 );
26178 return fieldTemporal !== filterTemporal;
26179 },
26180 selection: "single"
26181 }
26182 ];
26183 var getOperatorByName = (name) => OPERATORS.find((op) => op.name === name);
26184 var getAllOperatorNames = () => OPERATORS.map((op) => op.name);
26185
26186 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
26187 var import_element81 = __toESM(require_element(), 1);
26188
26189 // packages/dataviews/build-module/components/validated-form-controls/checkbox-control.mjs
26190 var import_element73 = __toESM(require_element(), 1);
26191 var import_compose8 = __toESM(require_compose(), 1);
26192 var import_components4 = __toESM(require_components(), 1);
26193 var import_jsx_runtime104 = __toESM(require_jsx_runtime(), 1);
26194 var UnforwardedValidatedCheckboxControl = ({
26195 required,
26196 customValidity,
26197 markWhenOptional,
26198 ...restProps
26199 }, forwardedRef) => {
26200 const validityTargetRef = (0, import_element73.useRef)(null);
26201 const mergedRefs = (0, import_compose8.useMergeRefs)([forwardedRef, validityTargetRef]);
26202 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
26203 ControlWithError,
26204 {
26205 className: "dataviews-validated-control",
26206 required,
26207 markWhenOptional,
26208 ref: mergedRefs,
26209 customValidity,
26210 getValidityTarget: () => validityTargetRef.current?.querySelector(
26211 'input[type="checkbox"]'
26212 ),
26213 children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
26214 import_components4.CheckboxControl,
26215 {
26216 ...restProps
26217 }
26218 )
26219 }
26220 );
26221 };
26222 var ValidatedCheckboxControl = (0, import_element73.forwardRef)(UnforwardedValidatedCheckboxControl);
26223 ValidatedCheckboxControl.displayName = "ValidatedCheckboxControl";
26224
26225 // packages/dataviews/build-module/components/validated-form-controls/combobox-control.mjs
26226 var import_element74 = __toESM(require_element(), 1);
26227 var import_compose9 = __toESM(require_compose(), 1);
26228 var import_components5 = __toESM(require_components(), 1);
26229 var import_jsx_runtime105 = __toESM(require_jsx_runtime(), 1);
26230 var UnforwardedValidatedComboboxControl = ({
26231 required,
26232 customValidity,
26233 markWhenOptional,
26234 ...restProps
26235 }, forwardedRef) => {
26236 const validityTargetRef = (0, import_element74.useRef)(null);
26237 const mergedRefs = (0, import_compose9.useMergeRefs)([forwardedRef, validityTargetRef]);
26238 (0, import_element74.useEffect)(() => {
26239 const input = validityTargetRef.current?.querySelector(
26240 'input[role="combobox"]'
26241 );
26242 if (input) {
26243 input.required = required ?? false;
26244 }
26245 }, [required]);
26246 return (
26247 // TODO: Bug - Missing value error is not cleared immediately on change, waits for blur.
26248 /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
26249 ControlWithError,
26250 {
26251 className: "dataviews-validated-control",
26252 required,
26253 markWhenOptional,
26254 ref: mergedRefs,
26255 customValidity,
26256 getValidityTarget: () => validityTargetRef.current?.querySelector(
26257 'input[role="combobox"]'
26258 ),
26259 children: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(import_components5.ComboboxControl, { ...restProps })
26260 }
26261 )
26262 );
26263 };
26264 var ValidatedComboboxControl = (0, import_element74.forwardRef)(UnforwardedValidatedComboboxControl);
26265 ValidatedComboboxControl.displayName = "ValidatedComboboxControl";
26266
26267 // packages/dataviews/build-module/components/validated-form-controls/form-token-field.mjs
26268 var import_element75 = __toESM(require_element(), 1);
26269 var import_components6 = __toESM(require_components(), 1);
26270 var import_jsx_runtime106 = __toESM(require_jsx_runtime(), 1);
26271 var UnforwardedValidatedFormTokenField = ({
26272 required,
26273 customValidity,
26274 markWhenOptional,
26275 ...restProps
26276 }, forwardedRef) => {
26277 const validityTargetRef = (0, import_element75.useRef)(null);
26278 return /* @__PURE__ */ (0, import_jsx_runtime106.jsxs)(
26279 "div",
26280 {
26281 className: "dataviews-validated-control__wrapper-with-error-delegate",
26282 ref: forwardedRef,
26283 children: [
26284 /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
26285 ControlWithError,
26286 {
26287 className: "dataviews-validated-control",
26288 required,
26289 markWhenOptional,
26290 customValidity,
26291 getValidityTarget: () => validityTargetRef.current,
26292 children: /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(import_components6.FormTokenField, { ...restProps })
26293 }
26294 ),
26295 /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
26296 "input",
26297 {
26298 className: "dataviews-validated-control__error-delegate",
26299 type: "text",
26300 ref: validityTargetRef,
26301 required,
26302 value: restProps.value && restProps.value.length > 0 ? "hasvalue" : "",
26303 tabIndex: -1,
26304 onChange: () => {
26305 },
26306 onFocus: (e) => {
26307 e.target.previousElementSibling?.querySelector(
26308 'input[type="text"]'
26309 )?.focus();
26310 }
26311 }
26312 )
26313 ]
26314 }
26315 );
26316 };
26317 var ValidatedFormTokenField = (0, import_element75.forwardRef)(UnforwardedValidatedFormTokenField);
26318 ValidatedFormTokenField.displayName = "ValidatedFormTokenField";
26319
26320 // packages/dataviews/build-module/components/validated-form-controls/number-control.mjs
26321 var import_element76 = __toESM(require_element(), 1);
26322 var import_compose10 = __toESM(require_compose(), 1);
26323 var import_components7 = __toESM(require_components(), 1);
26324 var import_jsx_runtime107 = __toESM(require_jsx_runtime(), 1);
26325 var UnforwardedValidatedNumberControl = ({
26326 required,
26327 customValidity,
26328 markWhenOptional,
26329 ...restProps
26330 }, forwardedRef) => {
26331 const validityTargetRef = (0, import_element76.useRef)(null);
26332 const mergedRefs = (0, import_compose10.useMergeRefs)([forwardedRef, validityTargetRef]);
26333 return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
26334 ControlWithError,
26335 {
26336 className: "dataviews-validated-control",
26337 required,
26338 markWhenOptional,
26339 customValidity,
26340 getValidityTarget: () => validityTargetRef.current,
26341 children: /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(import_components7.__experimentalNumberControl, { ref: mergedRefs, ...restProps })
26342 }
26343 );
26344 };
26345 var ValidatedNumberControl = (0, import_element76.forwardRef)(UnforwardedValidatedNumberControl);
26346 ValidatedNumberControl.displayName = "ValidatedNumberControl";
26347
26348 // packages/dataviews/build-module/components/validated-form-controls/radio-control.mjs
26349 var import_element77 = __toESM(require_element(), 1);
26350 var import_compose11 = __toESM(require_compose(), 1);
26351 var import_components8 = __toESM(require_components(), 1);
26352 var import_jsx_runtime108 = __toESM(require_jsx_runtime(), 1);
26353 var UnforwardedValidatedRadioControl = ({
26354 required,
26355 customValidity,
26356 markWhenOptional,
26357 ...restProps
26358 }, forwardedRef) => {
26359 const validityTargetRef = (0, import_element77.useRef)(null);
26360 const mergedRefs = (0, import_compose11.useMergeRefs)([forwardedRef, validityTargetRef]);
26361 return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(
26362 ControlWithError,
26363 {
26364 className: "dataviews-validated-control",
26365 required,
26366 markWhenOptional,
26367 ref: mergedRefs,
26368 customValidity,
26369 getValidityTarget: () => validityTargetRef.current?.querySelector(
26370 'input[type="radio"]'
26371 ),
26372 children: /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(import_components8.RadioControl, { ...restProps })
26373 }
26374 );
26375 };
26376 var ValidatedRadioControl = (0, import_element77.forwardRef)(UnforwardedValidatedRadioControl);
26377 ValidatedRadioControl.displayName = "ValidatedRadioControl";
26378
26379 // packages/dataviews/build-module/components/validated-form-controls/select-control.mjs
26380 var import_element78 = __toESM(require_element(), 1);
26381 var import_compose12 = __toESM(require_compose(), 1);
26382 var import_components9 = __toESM(require_components(), 1);
26383 var import_jsx_runtime109 = __toESM(require_jsx_runtime(), 1);
26384 var UnforwardedValidatedSelectControl = ({
26385 required,
26386 customValidity,
26387 markWhenOptional,
26388 ...restProps
26389 }, forwardedRef) => {
26390 const validityTargetRef = (0, import_element78.useRef)(null);
26391 const mergedRefs = (0, import_compose12.useMergeRefs)([forwardedRef, validityTargetRef]);
26392 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
26393 ControlWithError,
26394 {
26395 className: "dataviews-validated-control",
26396 required,
26397 markWhenOptional,
26398 customValidity,
26399 getValidityTarget: () => validityTargetRef.current,
26400 children: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
26401 import_components9.SelectControl,
26402 {
26403 ref: mergedRefs,
26404 // A runtime boolean cannot statically discriminate
26405 // SelectControl's single/multiple props union.
26406 ...restProps
26407 }
26408 )
26409 }
26410 );
26411 };
26412 var ValidatedSelectControl = (0, import_element78.forwardRef)(UnforwardedValidatedSelectControl);
26413 ValidatedSelectControl.displayName = "ValidatedSelectControl";
26414
26415 // packages/dataviews/build-module/components/validated-form-controls/toggle-control.mjs
26416 var import_element79 = __toESM(require_element(), 1);
26417 var import_compose13 = __toESM(require_compose(), 1);
26418 var import_components10 = __toESM(require_components(), 1);
26419 var import_jsx_runtime110 = __toESM(require_jsx_runtime(), 1);
26420 var UnforwardedValidatedToggleControl = ({
26421 required,
26422 customValidity,
26423 markWhenOptional,
26424 ...restProps
26425 }, forwardedRef) => {
26426 const validityTargetRef = (0, import_element79.useRef)(null);
26427 const mergedRefs = (0, import_compose13.useMergeRefs)([forwardedRef, validityTargetRef]);
26428 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
26429 ControlWithError,
26430 {
26431 className: "dataviews-validated-control",
26432 required,
26433 markWhenOptional,
26434 customValidity,
26435 getValidityTarget: () => validityTargetRef.current,
26436 children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
26437 import_components10.ToggleControl,
26438 {
26439 ref: mergedRefs,
26440 required,
26441 ...restProps
26442 }
26443 )
26444 }
26445 );
26446 };
26447 var ValidatedToggleControl = (0, import_element79.forwardRef)(UnforwardedValidatedToggleControl);
26448 ValidatedToggleControl.displayName = "ValidatedToggleControl";
26449
26450 // packages/dataviews/build-module/components/validated-form-controls/toggle-group-control.mjs
26451 var import_element80 = __toESM(require_element(), 1);
26452 var import_components11 = __toESM(require_components(), 1);
26453 var import_jsx_runtime111 = __toESM(require_jsx_runtime(), 1);
26454 var UnforwardedValidatedToggleGroupControl = ({
26455 required,
26456 customValidity,
26457 markWhenOptional,
26458 ...restProps
26459 }, forwardedRef) => {
26460 const validityTargetRef = (0, import_element80.useRef)(null);
26461 const nameAttr = (0, import_element80.useId)();
26462 return /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)("div", { className: "dataviews-validated-control__wrapper-with-error-delegate", children: [
26463 /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
26464 ControlWithError,
26465 {
26466 className: "dataviews-validated-control",
26467 required,
26468 markWhenOptional,
26469 customValidity,
26470 getValidityTarget: () => validityTargetRef.current,
26471 children: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(import_components11.__experimentalToggleGroupControl, { ref: forwardedRef, ...restProps })
26472 }
26473 ),
26474 /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
26475 "input",
26476 {
26477 className: "dataviews-validated-control__error-delegate",
26478 type: "radio",
26479 ref: validityTargetRef,
26480 required,
26481 checked: restProps.value !== void 0,
26482 tabIndex: -1,
26483 name: nameAttr,
26484 onChange: () => {
26485 },
26486 onFocus: (e) => {
26487 e.target.previousElementSibling?.querySelector(
26488 '[data-active-item="true"]'
26489 )?.focus();
26490 }
26491 }
26492 )
26493 ] });
26494 };
26495 var ValidatedToggleGroupControl = (0, import_element80.forwardRef)(UnforwardedValidatedToggleGroupControl);
26496 ValidatedToggleGroupControl.displayName = "ValidatedToggleGroupControl";
26497
26498 // packages/dataviews/build-module/components/dataform-controls/utils/get-custom-validity.mjs
26499 function getCustomValidity(isValid2, validity) {
26500 let customValidity;
26501 if (isValid2?.required && validity?.required) {
26502 customValidity = validity.required.message ? {
26503 type: validity.required.type,
26504 message: validity.required.message
26505 } : void 0;
26506 } else if (isValid2?.pattern && validity?.pattern) {
26507 customValidity = validity.pattern;
26508 } else if (isValid2?.min && validity?.min) {
26509 customValidity = validity.min;
26510 } else if (isValid2?.max && validity?.max) {
26511 customValidity = validity.max;
26512 } else if (isValid2?.minLength && validity?.minLength) {
26513 customValidity = validity.minLength;
26514 } else if (isValid2?.maxLength && validity?.maxLength) {
26515 customValidity = validity.maxLength;
26516 } else if (isValid2?.elements && validity?.elements) {
26517 customValidity = validity.elements;
26518 } else if (validity?.custom) {
26519 customValidity = validity.custom;
26520 }
26521 return customValidity;
26522 }
26523
26524 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
26525 var import_jsx_runtime112 = __toESM(require_jsx_runtime(), 1);
26526 function Checkbox({
26527 field,
26528 onChange,
26529 data,
26530 hideLabelFromVision,
26531 markWhenOptional,
26532 validity
26533 }) {
26534 const { getValue, setValue, label, description, isValid: isValid2 } = field;
26535 const disabled2 = field.isDisabled({ item: data, field });
26536 const onChangeControl = (0, import_element81.useCallback)(() => {
26537 onChange(
26538 setValue({ item: data, value: !getValue({ item: data }) })
26539 );
26540 }, [data, getValue, onChange, setValue]);
26541 return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
26542 ValidatedCheckboxControl,
26543 {
26544 required: !!field.isValid?.required,
26545 markWhenOptional,
26546 customValidity: getCustomValidity(isValid2, validity),
26547 hidden: hideLabelFromVision,
26548 label,
26549 help: description,
26550 checked: getValue({ item: data }),
26551 onChange: onChangeControl,
26552 disabled: disabled2
26553 }
26554 );
26555 }
26556
26557 // packages/dataviews/build-module/components/dataform-controls/combobox.mjs
26558 var import_components12 = __toESM(require_components(), 1);
26559 var import_element82 = __toESM(require_element(), 1);
26560 var import_jsx_runtime113 = __toESM(require_jsx_runtime(), 1);
26561 function Combobox({
26562 data,
26563 field,
26564 onChange,
26565 hideLabelFromVision,
26566 validity
26567 }) {
26568 const { label, description, placeholder, getValue, setValue, isValid: isValid2 } = field;
26569 const value = getValue({ item: data }) ?? "";
26570 const onChangeControl = (0, import_element82.useCallback)(
26571 (newValue) => onChange(setValue({ item: data, value: newValue ?? "" })),
26572 [data, onChange, setValue]
26573 );
26574 const { elements, isLoading } = useElements({
26575 elements: field.elements,
26576 getElements: field.getElements
26577 });
26578 if (isLoading) {
26579 return /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(import_components12.Spinner, {});
26580 }
26581 return /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
26582 ValidatedComboboxControl,
26583 {
26584 required: !!field.isValid?.required,
26585 customValidity: getCustomValidity(isValid2, validity),
26586 label,
26587 value,
26588 help: description,
26589 placeholder,
26590 options: elements,
26591 onChange: onChangeControl,
26592 hideLabelFromVision,
26593 allowReset: true,
26594 expandOnFocus: true
26595 }
26596 );
26597 }
26598
26599 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
26600 var import_components14 = __toESM(require_components(), 1);
26601 var import_element85 = __toESM(require_element(), 1);
26602 var import_i18n16 = __toESM(require_i18n(), 1);
26603 var import_date5 = __toESM(require_date(), 1);
26604 import { speak as speak2 } from "@wordpress/a11y";
26605
26606 // packages/dataviews/build-module/components/dataform-controls/utils/relative-date-control.mjs
26607 var import_components13 = __toESM(require_components(), 1);
26608 var import_element83 = __toESM(require_element(), 1);
26609 var import_i18n14 = __toESM(require_i18n(), 1);
26610 var import_jsx_runtime114 = __toESM(require_jsx_runtime(), 1);
26611 var TIME_UNITS_OPTIONS = {
26612 [OPERATOR_IN_THE_PAST]: [
26613 { value: "days", label: (0, import_i18n14.__)("Days") },
26614 { value: "weeks", label: (0, import_i18n14.__)("Weeks") },
26615 { value: "months", label: (0, import_i18n14.__)("Months") },
26616 { value: "years", label: (0, import_i18n14.__)("Years") }
26617 ],
26618 [OPERATOR_OVER]: [
26619 { value: "days", label: (0, import_i18n14.__)("Days ago") },
26620 { value: "weeks", label: (0, import_i18n14.__)("Weeks ago") },
26621 { value: "months", label: (0, import_i18n14.__)("Months ago") },
26622 { value: "years", label: (0, import_i18n14.__)("Years ago") }
26623 ]
26624 };
26625 function RelativeDateControl({
26626 className,
26627 data,
26628 field,
26629 onChange,
26630 hideLabelFromVision,
26631 operator
26632 }) {
26633 const options = TIME_UNITS_OPTIONS[operator === OPERATOR_IN_THE_PAST ? "inThePast" : "over"];
26634 const { id, label, description, getValue, setValue } = field;
26635 const disabled2 = field.isDisabled({ item: data, field });
26636 const fieldValue = getValue({ item: data });
26637 const { value: relValue = "", unit = options[0].value } = fieldValue && typeof fieldValue === "object" ? fieldValue : {};
26638 const onChangeValue = (0, import_element83.useCallback)(
26639 (newValue) => onChange(
26640 setValue({
26641 item: data,
26642 value: { value: Number(newValue), unit }
26643 })
26644 ),
26645 [onChange, setValue, data, unit]
26646 );
26647 const onChangeUnit = (0, import_element83.useCallback)(
26648 (newUnit) => onChange(
26649 setValue({
26650 item: data,
26651 value: { value: relValue, unit: newUnit }
26652 })
26653 ),
26654 [onChange, setValue, data, relValue]
26655 );
26656 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
26657 import_components13.BaseControl,
26658 {
26659 id,
26660 className: clsx_default(className, "dataviews-controls__relative-date"),
26661 label,
26662 hideLabelFromVision,
26663 help: description,
26664 children: /* @__PURE__ */ (0, import_jsx_runtime114.jsxs)(Stack, { direction: "row", gap: "sm", children: [
26665 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
26666 import_components13.__experimentalNumberControl,
26667 {
26668 className: "dataviews-controls__relative-date-number",
26669 spinControls: "none",
26670 min: 1,
26671 step: 1,
26672 value: relValue,
26673 onChange: onChangeValue,
26674 disabled: disabled2
26675 }
26676 ),
26677 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
26678 import_components13.SelectControl,
26679 {
26680 className: "dataviews-controls__relative-date-unit",
26681 label: (0, import_i18n14.__)("Unit"),
26682 value: unit,
26683 options,
26684 onChange: onChangeUnit,
26685 hideLabelFromVision: true,
26686 disabled: disabled2
26687 }
26688 )
26689 ] })
26690 }
26691 );
26692 }
26693
26694 // packages/dataviews/build-module/components/dataform-controls/utils/to-calendar-date.mjs
26695 function toCalendarDate(date, timeZone) {
26696 return timeZone ? new TZDate(date, timeZone) : date;
26697 }
26698
26699 // packages/dataviews/build-module/components/dataform-controls/utils/use-disabled-date-matchers.mjs
26700 var import_element84 = __toESM(require_element(), 1);
26701 function useDisabledDateMatchers(isValid2, parseDateFn) {
26702 const minConstraint = typeof isValid2.min?.constraint === "string" ? isValid2.min.constraint : void 0;
26703 const maxConstraint = typeof isValid2.max?.constraint === "string" ? isValid2.max.constraint : void 0;
26704 const disabledMatchers = (0, import_element84.useMemo)(() => {
26705 const matchers = [];
26706 if (minConstraint) {
26707 const minDate = parseDateFn(minConstraint);
26708 if (minDate) {
26709 matchers.push({ before: minDate });
26710 }
26711 }
26712 if (maxConstraint) {
26713 const maxDate = parseDateFn(maxConstraint);
26714 if (maxDate) {
26715 matchers.push({ after: maxDate });
26716 }
26717 }
26718 return matchers.length > 0 ? matchers : void 0;
26719 }, [minConstraint, maxConstraint, parseDateFn]);
26720 return { minConstraint, maxConstraint, disabledMatchers };
26721 }
26722
26723 // packages/dataviews/build-module/components/dataform-controls/utils/get-calendar-locale.mjs
26724 var LANGUAGE_ALIASES = {
26725 ary: "ar-MA",
26726 // Moroccan Arabic.
26727 haz: "fa"
26728 // Hazaragi, a variety of Persian.
26729 };
26730 function getCalendarLocale(wpLocale) {
26731 const subtags = wpLocale?.trim().split(/[_-]/) ?? [];
26732 const language = subtags.shift()?.toLowerCase();
26733 if (!language) {
26734 return void 0;
26735 }
26736 const normalized = [LANGUAGE_ALIASES[language] ?? language];
26737 for (const subtag of subtags) {
26738 if (/^[a-z]{4}$/i.test(subtag) || /^([a-z]{2}|\d{3})$/i.test(subtag)) {
26739 normalized.push(subtag);
26740 }
26741 }
26742 return normalized.join("-");
26743 }
26744
26745 // packages/dataviews/build-module/components/dataform-controls/utils/get-timezone-description.mjs
26746 var import_date3 = __toESM(require_date(), 1);
26747 var import_i18n15 = __toESM(require_i18n(), 1);
26748 function getTimezoneDescription() {
26749 const { timezone } = (0, import_date3.getSettings)();
26750 const userTimezoneOffset = -1 * ((/* @__PURE__ */ new Date()).getTimezoneOffset() / 60);
26751 if (Number(timezone.offset) === userTimezoneOffset) {
26752 return void 0;
26753 }
26754 const offsetSymbol = Number(timezone.offset) >= 0 ? "+" : "";
26755 const zoneAbbr = "" !== timezone.abbr && isNaN(Number(timezone.abbr)) ? timezone.abbr : `UTC${offsetSymbol}${timezone.offsetFormatted}`;
26756 const prettyTimezoneString = timezone.string.replaceAll("_", " ");
26757 let timezoneDetail = zoneAbbr;
26758 if ("UTC" === timezone.string) {
26759 timezoneDetail = (0, import_i18n15.__)("Coordinated Universal Time");
26760 } else if (prettyTimezoneString.trim().length > 0) {
26761 timezoneDetail = `(${zoneAbbr}) ${prettyTimezoneString}`;
26762 }
26763 return (0, import_i18n15.sprintf)(
26764 /* translators: %s: timezone detail, e.g. "(CEST) Europe/Madrid" or "UTC+3". */
26765 (0, import_i18n15.__)("Timezone: %s"),
26766 timezoneDetail
26767 );
26768 }
26769
26770 // packages/dataviews/build-module/field-types/utils/parse-date-time.mjs
26771 var import_date4 = __toESM(require_date(), 1);
26772 function parseDateTime(dateTimeString) {
26773 if (!dateTimeString) {
26774 return null;
26775 }
26776 const parsed = (0, import_date4.getDate)(dateTimeString);
26777 return parsed && isValid(parsed) ? parsed : null;
26778 }
26779
26780 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
26781 var import_jsx_runtime115 = __toESM(require_jsx_runtime(), 1);
26782 var formatDateTime = (value) => {
26783 if (!value) {
26784 return "";
26785 }
26786 return (0, import_date5.dateI18n)("Y-m-d\\TH:i", (0, import_date5.getDate)(value));
26787 };
26788 function CalendarDateTimeControl({
26789 data,
26790 field,
26791 onChange,
26792 hideLabelFromVision,
26793 markWhenOptional,
26794 validity,
26795 config
26796 }) {
26797 const { compact } = config || {};
26798 const { id, label, description, setValue, getValue, isValid: isValid2 } = field;
26799 const disabled2 = field.isDisabled({ item: data, field });
26800 const fieldValue = getValue({ item: data });
26801 const value = typeof fieldValue === "string" ? fieldValue : void 0;
26802 const { timezone } = (0, import_date5.getSettings)();
26803 const timeZone = timezone.string || (0, import_date5.dateI18n)("P");
26804 const [calendarMonth, setCalendarMonth] = (0, import_element85.useState)(() => {
26805 const parsedDate = parseDateTime(value);
26806 return toCalendarDate(parsedDate || /* @__PURE__ */ new Date(), timeZone);
26807 });
26808 (0, import_element85.useEffect)(() => {
26809 const parsedDate = parseDateTime(value);
26810 if (parsedDate) {
26811 const targetMonth = toCalendarDate(parsedDate, timeZone);
26812 setCalendarMonth(
26813 (currentMonth) => isSameMonth(
26814 targetMonth,
26815 toCalendarDate(currentMonth, timeZone)
26816 ) ? currentMonth : targetMonth
26817 );
26818 }
26819 }, [timeZone, value]);
26820 const inputControlRef = (0, import_element85.useRef)(null);
26821 const validationTimeoutRef = (0, import_element85.useRef)(void 0);
26822 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDateTime);
26823 const onChangeCallback = (0, import_element85.useCallback)(
26824 (newValue) => onChange(setValue({ item: data, value: newValue })),
26825 [data, onChange, setValue]
26826 );
26827 (0, import_element85.useEffect)(() => {
26828 return () => clearTimeout(validationTimeoutRef.current);
26829 }, []);
26830 const onSelectDate = (0, import_element85.useCallback)(
26831 (newDate) => {
26832 if (newDate) {
26833 const wpDate = (0, import_date5.dateI18n)("Y-m-d", newDate);
26834 const wpTime = value ? (0, import_date5.dateI18n)("H:i", (0, import_date5.getDate)(value)) : "00:00";
26835 const finalDateTime = (0, import_date5.getDate)(`${wpDate}T${wpTime}`);
26836 onChangeCallback(finalDateTime.toISOString());
26837 } else {
26838 onChangeCallback(void 0);
26839 }
26840 clearTimeout(validationTimeoutRef.current);
26841 validationTimeoutRef.current = setTimeout(() => {
26842 const input = inputControlRef.current;
26843 if (!input) {
26844 return;
26845 }
26846 input.dispatchEvent(
26847 new Event("invalid", { cancelable: true })
26848 );
26849 if (input.validationMessage) {
26850 speak2(input.validationMessage);
26851 }
26852 }, 0);
26853 },
26854 [onChangeCallback, value]
26855 );
26856 const handleManualDateTimeChange = (0, import_element85.useCallback)(
26857 (newValue) => {
26858 if (newValue) {
26859 const dateTime = (0, import_date5.getDate)(newValue);
26860 onChangeCallback(dateTime.toISOString());
26861 const parsedDate = parseDateTime(dateTime.toISOString());
26862 if (parsedDate) {
26863 setCalendarMonth(toCalendarDate(parsedDate, timeZone));
26864 }
26865 } else {
26866 onChangeCallback(void 0);
26867 }
26868 },
26869 [onChangeCallback, timeZone]
26870 );
26871 const { format: fieldFormat } = field;
26872 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date5.getSettings)().l10n.startOfWeek;
26873 const locale = getCalendarLocale((0, import_date5.getSettings)().l10n.locale);
26874 let displayLabel = label;
26875 if (isValid2?.required && !markWhenOptional && !hideLabelFromVision) {
26876 displayLabel = `${label} (${(0, import_i18n16.__)("Required")})`;
26877 } else if (!isValid2?.required && markWhenOptional && !hideLabelFromVision) {
26878 displayLabel = `${label} (${(0, import_i18n16.__)("Optional")})`;
26879 }
26880 return /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(
26881 import_components14.BaseControl,
26882 {
26883 id,
26884 label: displayLabel,
26885 help: description,
26886 hideLabelFromVision,
26887 children: /* @__PURE__ */ (0, import_jsx_runtime115.jsxs)(Stack, { direction: "column", gap: "lg", children: [
26888 /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(
26889 ValidatedInputControl,
26890 {
26891 ref: inputControlRef,
26892 required: !!isValid2?.required,
26893 customValidity: getCustomValidity(isValid2, validity),
26894 type: "datetime-local",
26895 label: (0, import_i18n16.__)("Date time"),
26896 hideLabelFromVision: true,
26897 value: formatDateTime(value),
26898 onValueChange: handleManualDateTimeChange,
26899 disabled: disabled2,
26900 description: getTimezoneDescription(),
26901 min: minConstraint ? formatDateTime(minConstraint) : void 0,
26902 max: maxConstraint ? formatDateTime(maxConstraint) : void 0
26903 }
26904 ),
26905 !compact && /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(
26906 Calendar,
26907 {
26908 style: { width: "100%" },
26909 value: value ? parseDateTime(value) : null,
26910 onValueChange: onSelectDate,
26911 month: calendarMonth,
26912 onMonthChange: setCalendarMonth,
26913 timeZone,
26914 locale,
26915 dir: (0, import_i18n16.isRTL)() ? "rtl" : "ltr",
26916 weekStartsOn,
26917 disabled: disabled2 || disabledMatchers
26918 }
26919 )
26920 ] })
26921 }
26922 );
26923 }
26924 function DateTime({
26925 data,
26926 field,
26927 onChange,
26928 hideLabelFromVision,
26929 markWhenOptional,
26930 operator,
26931 validity,
26932 config
26933 }) {
26934 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
26935 return /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(
26936 RelativeDateControl,
26937 {
26938 className: "dataviews-controls__datetime",
26939 data,
26940 field,
26941 onChange,
26942 hideLabelFromVision,
26943 operator
26944 }
26945 );
26946 }
26947 return /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(
26948 CalendarDateTimeControl,
26949 {
26950 data,
26951 field,
26952 onChange,
26953 hideLabelFromVision,
26954 markWhenOptional,
26955 validity,
26956 config
26957 }
26958 );
26959 }
26960
26961 // packages/dataviews/build-module/components/dataform-controls/date.mjs
26962 var import_components15 = __toESM(require_components(), 1);
26963 var import_element86 = __toESM(require_element(), 1);
26964 var import_i18n17 = __toESM(require_i18n(), 1);
26965 var import_date6 = __toESM(require_date(), 1);
26966 import { speak as speak3 } from "@wordpress/a11y";
26967 var import_jsx_runtime116 = __toESM(require_jsx_runtime(), 1);
26968 var DATE_PRESETS = [
26969 {
26970 id: "today",
26971 label: (0, import_i18n17.__)("Today"),
26972 getValue: () => (0, import_date6.getDate)(null)
26973 },
26974 {
26975 id: "yesterday",
26976 label: (0, import_i18n17.__)("Yesterday"),
26977 getValue: () => {
26978 const today = (0, import_date6.getDate)(null);
26979 return subDays(today, 1);
26980 }
26981 },
26982 {
26983 id: "past-week",
26984 label: (0, import_i18n17.__)("Past week"),
26985 getValue: () => {
26986 const today = (0, import_date6.getDate)(null);
26987 return subDays(today, 7);
26988 }
26989 },
26990 {
26991 id: "past-month",
26992 label: (0, import_i18n17.__)("Past month"),
26993 getValue: () => {
26994 const today = (0, import_date6.getDate)(null);
26995 return subMonths(today, 1);
26996 }
26997 }
26998 ];
26999 var DATE_RANGE_PRESETS = [
27000 {
27001 id: "last-7-days",
27002 label: (0, import_i18n17.__)("Last 7 days"),
27003 getValue: () => {
27004 const today = (0, import_date6.getDate)(null);
27005 return [subDays(today, 7), today];
27006 }
27007 },
27008 {
27009 id: "last-30-days",
27010 label: (0, import_i18n17.__)("Last 30 days"),
27011 getValue: () => {
27012 const today = (0, import_date6.getDate)(null);
27013 return [subDays(today, 30), today];
27014 }
27015 },
27016 {
27017 id: "month-to-date",
27018 label: (0, import_i18n17.__)("Month to date"),
27019 getValue: () => {
27020 const today = (0, import_date6.getDate)(null);
27021 return [startOfMonth(today), today];
27022 }
27023 },
27024 {
27025 id: "last-year",
27026 label: (0, import_i18n17.__)("Last year"),
27027 getValue: () => {
27028 const today = (0, import_date6.getDate)(null);
27029 return [subYears(today, 1), today];
27030 }
27031 },
27032 {
27033 id: "year-to-date",
27034 label: (0, import_i18n17.__)("Year to date"),
27035 getValue: () => {
27036 const today = (0, import_date6.getDate)(null);
27037 return [startOfYear(today), today];
27038 }
27039 }
27040 ];
27041 var parseDate2 = (dateString) => {
27042 if (!dateString) {
27043 return null;
27044 }
27045 const parsed = parseISO(dateString);
27046 return isValid(parsed) ? parsed : null;
27047 };
27048 var formatDate = (date) => {
27049 if (!date) {
27050 return "";
27051 }
27052 return typeof date === "string" ? date : format(date, "yyyy-MM-dd");
27053 };
27054 function ValidatedDateControl({
27055 field,
27056 validity,
27057 inputRefs,
27058 isTouched,
27059 setIsTouched,
27060 children
27061 }) {
27062 const { isValid: isValid2 } = field;
27063 const [customValidity, setCustomValidity] = (0, import_element86.useState)(void 0);
27064 const validateRefs = (0, import_element86.useCallback)(() => {
27065 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
27066 for (const ref of refs) {
27067 const input = ref.current;
27068 if (input && !input.validity.valid) {
27069 setCustomValidity({
27070 type: "invalid",
27071 message: input.validationMessage
27072 });
27073 return;
27074 }
27075 }
27076 setCustomValidity(void 0);
27077 }, [inputRefs]);
27078 (0, import_element86.useEffect)(() => {
27079 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
27080 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
27081 for (const ref of refs) {
27082 const input = ref.current;
27083 if (input) {
27084 input.setCustomValidity(
27085 result?.type === "invalid" && result.message ? result.message : ""
27086 );
27087 }
27088 }
27089 }, [inputRefs, isValid2, validity]);
27090 (0, import_element86.useEffect)(() => {
27091 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
27092 const handleInvalid = (event) => {
27093 event.preventDefault();
27094 setIsTouched(true);
27095 };
27096 for (const ref of refs) {
27097 ref.current?.addEventListener("invalid", handleInvalid);
27098 }
27099 return () => {
27100 for (const ref of refs) {
27101 ref.current?.removeEventListener("invalid", handleInvalid);
27102 }
27103 };
27104 }, [inputRefs, setIsTouched]);
27105 (0, import_element86.useEffect)(() => {
27106 if (!isTouched) {
27107 return;
27108 }
27109 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
27110 if (result) {
27111 setCustomValidity(result);
27112 } else {
27113 validateRefs();
27114 }
27115 }, [isTouched, isValid2, validity, validateRefs]);
27116 (0, import_element86.useEffect)(() => {
27117 if (isTouched && customValidity?.message) {
27118 speak3(customValidity.message);
27119 }
27120 }, [isTouched, customValidity?.message]);
27121 const onBlur = (event) => {
27122 if (isTouched) {
27123 return;
27124 }
27125 if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) {
27126 setIsTouched(true);
27127 }
27128 };
27129 return /* @__PURE__ */ (0, import_jsx_runtime116.jsxs)(Stack, { direction: "column", gap: "sm", onBlur, children: [
27130 children,
27131 customValidity && /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
27132 ValidityIndicator,
27133 {
27134 type: customValidity.type,
27135 message: customValidity.message
27136 }
27137 )
27138 ] });
27139 }
27140 function CalendarDateControl({
27141 data,
27142 field,
27143 onChange,
27144 hideLabelFromVision,
27145 markWhenOptional,
27146 validity
27147 }) {
27148 const {
27149 id,
27150 label,
27151 description,
27152 setValue,
27153 getValue,
27154 isValid: isValid2,
27155 format: fieldFormat
27156 } = field;
27157 const disabled2 = field.isDisabled({ item: data, field });
27158 const [selectedPresetId, setSelectedPresetId] = (0, import_element86.useState)(
27159 null
27160 );
27161 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date6.getSettings)().l10n.startOfWeek;
27162 const locale = getCalendarLocale((0, import_date6.getSettings)().l10n.locale);
27163 const fieldValue = getValue({ item: data });
27164 const value = typeof fieldValue === "string" ? fieldValue : void 0;
27165 const [calendarMonth, setCalendarMonth] = (0, import_element86.useState)(() => {
27166 const parsedDate = parseDate2(value);
27167 return parsedDate || /* @__PURE__ */ new Date();
27168 });
27169 (0, import_element86.useEffect)(() => {
27170 const parsedDate = parseDate2(value);
27171 if (parsedDate) {
27172 setCalendarMonth(
27173 (currentMonth) => isSameMonth(parsedDate, currentMonth) ? currentMonth : parsedDate
27174 );
27175 }
27176 }, [value]);
27177 const [isTouched, setIsTouched] = (0, import_element86.useState)(false);
27178 const validityTargetRef = (0, import_element86.useRef)(null);
27179 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate2);
27180 const onChangeCallback = (0, import_element86.useCallback)(
27181 (newValue) => onChange(setValue({ item: data, value: newValue })),
27182 [data, onChange, setValue]
27183 );
27184 const onSelectDate = (0, import_element86.useCallback)(
27185 (newDate) => {
27186 const dateValue = newDate ? formatDate(newDate) : void 0;
27187 onChangeCallback(dateValue);
27188 setSelectedPresetId(null);
27189 setIsTouched(true);
27190 },
27191 [onChangeCallback]
27192 );
27193 const handlePresetClick = (0, import_element86.useCallback)(
27194 (preset) => {
27195 const presetDate = preset.getValue();
27196 const dateValue = formatDate(presetDate);
27197 setCalendarMonth(presetDate);
27198 onChangeCallback(dateValue);
27199 setSelectedPresetId(preset.id);
27200 setIsTouched(true);
27201 },
27202 [onChangeCallback]
27203 );
27204 const handleManualDateChange = (0, import_element86.useCallback)(
27205 (newValue) => {
27206 onChangeCallback(newValue);
27207 if (newValue) {
27208 const parsedDate = parseDate2(newValue);
27209 if (parsedDate) {
27210 setCalendarMonth(parsedDate);
27211 }
27212 }
27213 setSelectedPresetId(null);
27214 setIsTouched(true);
27215 },
27216 [onChangeCallback]
27217 );
27218 let displayLabel = label;
27219 if (isValid2?.required && !markWhenOptional) {
27220 displayLabel = `${label} (${(0, import_i18n17.__)("Required")})`;
27221 } else if (!isValid2?.required && markWhenOptional) {
27222 displayLabel = `${label} (${(0, import_i18n17.__)("Optional")})`;
27223 }
27224 return /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
27225 ValidatedDateControl,
27226 {
27227 field,
27228 validity,
27229 inputRefs: validityTargetRef,
27230 isTouched,
27231 setIsTouched,
27232 children: /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
27233 import_components15.BaseControl,
27234 {
27235 id,
27236 className: "dataviews-controls__date",
27237 label: displayLabel,
27238 help: description,
27239 hideLabelFromVision,
27240 children: /* @__PURE__ */ (0, import_jsx_runtime116.jsxs)(Stack, { direction: "column", gap: "lg", children: [
27241 /* @__PURE__ */ (0, import_jsx_runtime116.jsxs)(
27242 Stack,
27243 {
27244 direction: "row",
27245 gap: "sm",
27246 wrap: "wrap",
27247 justify: "flex-start",
27248 children: [
27249 DATE_PRESETS.map((preset) => {
27250 const isSelected = selectedPresetId === preset.id;
27251 return /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
27252 import_components15.Button,
27253 {
27254 className: "dataviews-controls__date-preset",
27255 variant: "tertiary",
27256 isPressed: isSelected,
27257 size: "small",
27258 disabled: disabled2,
27259 accessibleWhenDisabled: true,
27260 onClick: () => handlePresetClick(preset),
27261 children: preset.label
27262 },
27263 preset.id
27264 );
27265 }),
27266 /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
27267 import_components15.Button,
27268 {
27269 className: "dataviews-controls__date-preset",
27270 variant: "tertiary",
27271 isPressed: !selectedPresetId,
27272 size: "small",
27273 disabled: !!selectedPresetId || disabled2,
27274 accessibleWhenDisabled: true,
27275 children: (0, import_i18n17.__)("Custom")
27276 }
27277 )
27278 ]
27279 }
27280 ),
27281 /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
27282 import_components15.__experimentalInputControl,
27283 {
27284 ref: validityTargetRef,
27285 type: "date",
27286 label: (0, import_i18n17.__)("Date"),
27287 hideLabelFromVision: true,
27288 value,
27289 onChange: handleManualDateChange,
27290 required: !!field.isValid?.required,
27291 disabled: disabled2,
27292 min: minConstraint,
27293 max: maxConstraint
27294 }
27295 ),
27296 /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
27297 Calendar,
27298 {
27299 style: { width: "100%" },
27300 value: value ? parseDate2(value) : null,
27301 onValueChange: onSelectDate,
27302 month: calendarMonth,
27303 onMonthChange: setCalendarMonth,
27304 locale,
27305 dir: (0, import_i18n17.isRTL)() ? "rtl" : "ltr",
27306 weekStartsOn,
27307 disabled: disabled2 || disabledMatchers,
27308 disableNavigation: disabled2
27309 }
27310 )
27311 ] })
27312 }
27313 )
27314 }
27315 );
27316 }
27317 function CalendarDateRangeControl({
27318 data,
27319 field,
27320 onChange,
27321 hideLabelFromVision,
27322 markWhenOptional,
27323 validity
27324 }) {
27325 const {
27326 id,
27327 label,
27328 description,
27329 getValue,
27330 setValue,
27331 isValid: isValid2,
27332 format: fieldFormat
27333 } = field;
27334 const disabled2 = field.isDisabled({ item: data, field });
27335 let value;
27336 const fieldValue = getValue({ item: data });
27337 if (Array.isArray(fieldValue) && fieldValue.length === 2 && fieldValue.every((date) => typeof date === "string")) {
27338 value = fieldValue;
27339 }
27340 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date6.getSettings)().l10n.startOfWeek;
27341 const locale = getCalendarLocale((0, import_date6.getSettings)().l10n.locale);
27342 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate2);
27343 const onChangeCallback = (0, import_element86.useCallback)(
27344 (newValue) => {
27345 onChange(
27346 setValue({
27347 item: data,
27348 value: newValue
27349 })
27350 );
27351 },
27352 [data, onChange, setValue]
27353 );
27354 const [selectedPresetId, setSelectedPresetId] = (0, import_element86.useState)(
27355 null
27356 );
27357 const selectedRange = (0, import_element86.useMemo)(() => {
27358 if (!value) {
27359 return null;
27360 }
27361 const [from, to] = value;
27362 return {
27363 from: parseDate2(from) || void 0,
27364 to: parseDate2(to) || void 0
27365 };
27366 }, [value]);
27367 const [calendarMonth, setCalendarMonth] = (0, import_element86.useState)(() => {
27368 return selectedRange?.from || /* @__PURE__ */ new Date();
27369 });
27370 const [fromValue, toValue] = value ?? [];
27371 (0, import_element86.useEffect)(() => {
27372 setCalendarMonth((currentMonth) => {
27373 const from = parseDate2(fromValue);
27374 const to = parseDate2(toValue);
27375 const targetMonth = from ?? to;
27376 const isRangeVisible = from && to ? areIntervalsOverlapping(
27377 { start: from, end: to },
27378 {
27379 start: startOfMonth(currentMonth),
27380 end: endOfMonth(currentMonth)
27381 },
27382 { inclusive: true }
27383 ) : [from, to].some(
27384 (date) => date && isSameMonth(date, currentMonth)
27385 );
27386 return targetMonth && !isRangeVisible ? targetMonth : currentMonth;
27387 });
27388 }, [fromValue, toValue]);
27389 const [isTouched, setIsTouched] = (0, import_element86.useState)(false);
27390 const fromInputRef = (0, import_element86.useRef)(null);
27391 const toInputRef = (0, import_element86.useRef)(null);
27392 const updateDateRange = (0, import_element86.useCallback)(
27393 (fromDate, toDate2) => {
27394 if (!fromDate && !toDate2) {
27395 onChangeCallback(void 0);
27396 return;
27397 }
27398 onChangeCallback([
27399 formatDate(fromDate),
27400 formatDate(toDate2)
27401 ]);
27402 },
27403 [onChangeCallback]
27404 );
27405 const onSelectCalendarRange = (0, import_element86.useCallback)(
27406 (newRange) => {
27407 updateDateRange(newRange?.from, newRange?.to);
27408 setSelectedPresetId(null);
27409 setIsTouched(true);
27410 },
27411 [updateDateRange]
27412 );
27413 const handlePresetClick = (0, import_element86.useCallback)(
27414 (preset) => {
27415 const [startDate, endDate] = preset.getValue();
27416 setCalendarMonth(startDate);
27417 updateDateRange(startDate, endDate);
27418 setSelectedPresetId(preset.id);
27419 setIsTouched(true);
27420 },
27421 [updateDateRange]
27422 );
27423 const handleManualDateChange = (0, import_element86.useCallback)(
27424 (fromOrTo, newValue) => {
27425 const [currentFrom, currentTo] = value || [
27426 void 0,
27427 void 0
27428 ];
27429 const updatedFrom = fromOrTo === "from" ? newValue : currentFrom;
27430 const updatedTo = fromOrTo === "to" ? newValue : currentTo;
27431 updateDateRange(updatedFrom, updatedTo);
27432 if (newValue) {
27433 const parsedDate = parseDate2(newValue);
27434 if (parsedDate) {
27435 setCalendarMonth(parsedDate);
27436 }
27437 }
27438 setSelectedPresetId(null);
27439 setIsTouched(true);
27440 },
27441 [value, updateDateRange]
27442 );
27443 let displayLabel = label;
27444 if (field.isValid?.required && !markWhenOptional) {
27445 displayLabel = `${label} (${(0, import_i18n17.__)("Required")})`;
27446 } else if (!field.isValid?.required && markWhenOptional) {
27447 displayLabel = `${label} (${(0, import_i18n17.__)("Optional")})`;
27448 }
27449 return /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
27450 ValidatedDateControl,
27451 {
27452 field,
27453 validity,
27454 inputRefs: [fromInputRef, toInputRef],
27455 isTouched,
27456 setIsTouched,
27457 children: /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
27458 import_components15.BaseControl,
27459 {
27460 id,
27461 className: "dataviews-controls__date",
27462 label: displayLabel,
27463 help: description,
27464 hideLabelFromVision,
27465 children: /* @__PURE__ */ (0, import_jsx_runtime116.jsxs)(Stack, { direction: "column", gap: "lg", children: [
27466 /* @__PURE__ */ (0, import_jsx_runtime116.jsxs)(
27467 Stack,
27468 {
27469 direction: "row",
27470 gap: "sm",
27471 wrap: "wrap",
27472 justify: "flex-start",
27473 children: [
27474 DATE_RANGE_PRESETS.map((preset) => {
27475 const isSelected = selectedPresetId === preset.id;
27476 return /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
27477 import_components15.Button,
27478 {
27479 className: "dataviews-controls__date-preset",
27480 variant: "tertiary",
27481 isPressed: isSelected,
27482 size: "small",
27483 disabled: disabled2,
27484 accessibleWhenDisabled: true,
27485 onClick: () => handlePresetClick(preset),
27486 children: preset.label
27487 },
27488 preset.id
27489 );
27490 }),
27491 /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
27492 import_components15.Button,
27493 {
27494 className: "dataviews-controls__date-preset",
27495 variant: "tertiary",
27496 isPressed: !selectedPresetId,
27497 size: "small",
27498 accessibleWhenDisabled: true,
27499 disabled: !!selectedPresetId || disabled2,
27500 children: (0, import_i18n17.__)("Custom")
27501 }
27502 )
27503 ]
27504 }
27505 ),
27506 /* @__PURE__ */ (0, import_jsx_runtime116.jsxs)(
27507 Stack,
27508 {
27509 direction: "row",
27510 gap: "sm",
27511 justify: "space-between",
27512 className: "dataviews-controls__date-range-inputs",
27513 children: [
27514 /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
27515 import_components15.__experimentalInputControl,
27516 {
27517 ref: fromInputRef,
27518 type: "date",
27519 label: (0, import_i18n17.__)("From"),
27520 hideLabelFromVision: true,
27521 value: value?.[0],
27522 onChange: (newValue) => handleManualDateChange("from", newValue),
27523 required: !!field.isValid?.required,
27524 disabled: disabled2,
27525 min: minConstraint,
27526 max: maxConstraint
27527 }
27528 ),
27529 /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
27530 import_components15.__experimentalInputControl,
27531 {
27532 ref: toInputRef,
27533 type: "date",
27534 label: (0, import_i18n17.__)("To"),
27535 hideLabelFromVision: true,
27536 value: value?.[1],
27537 onChange: (newValue) => handleManualDateChange("to", newValue),
27538 required: !!field.isValid?.required,
27539 disabled: disabled2,
27540 min: minConstraint,
27541 max: maxConstraint
27542 }
27543 )
27544 ]
27545 }
27546 ),
27547 /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
27548 RangeCalendar,
27549 {
27550 style: { width: "100%" },
27551 value: selectedRange,
27552 onValueChange: onSelectCalendarRange,
27553 month: calendarMonth,
27554 onMonthChange: setCalendarMonth,
27555 locale,
27556 dir: (0, import_i18n17.isRTL)() ? "rtl" : "ltr",
27557 weekStartsOn,
27558 disabled: disabled2 || disabledMatchers
27559 }
27560 )
27561 ] })
27562 }
27563 )
27564 }
27565 );
27566 }
27567 function DateControl({
27568 data,
27569 field,
27570 onChange,
27571 hideLabelFromVision,
27572 markWhenOptional,
27573 operator,
27574 validity
27575 }) {
27576 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
27577 return /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
27578 RelativeDateControl,
27579 {
27580 className: "dataviews-controls__date",
27581 data,
27582 field,
27583 onChange,
27584 hideLabelFromVision,
27585 operator
27586 }
27587 );
27588 }
27589 if (operator === OPERATOR_BETWEEN) {
27590 return /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
27591 CalendarDateRangeControl,
27592 {
27593 data,
27594 field,
27595 onChange,
27596 hideLabelFromVision,
27597 markWhenOptional,
27598 validity
27599 }
27600 );
27601 }
27602 return /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
27603 CalendarDateControl,
27604 {
27605 data,
27606 field,
27607 onChange,
27608 hideLabelFromVision,
27609 markWhenOptional,
27610 validity
27611 }
27612 );
27613 }
27614
27615 // packages/dataviews/build-module/components/dataform-controls/select.mjs
27616 var import_components16 = __toESM(require_components(), 1);
27617 var import_element87 = __toESM(require_element(), 1);
27618 var import_jsx_runtime117 = __toESM(require_jsx_runtime(), 1);
27619 function Select2({
27620 data,
27621 field,
27622 onChange,
27623 hideLabelFromVision,
27624 markWhenOptional,
27625 validity
27626 }) {
27627 const { type, label, description, getValue, setValue, isValid: isValid2 } = field;
27628 const disabled2 = field.isDisabled({ item: data, field });
27629 const isMultiple = type === "array";
27630 const value = getValue({ item: data }) ?? (isMultiple ? [] : "");
27631 const onChangeControl = (0, import_element87.useCallback)(
27632 (newValue) => onChange(setValue({ item: data, value: newValue })),
27633 [data, onChange, setValue]
27634 );
27635 const { elements, isLoading } = useElements({
27636 elements: field.elements,
27637 getElements: field.getElements
27638 });
27639 if (isLoading) {
27640 return /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(import_components16.Spinner, {});
27641 }
27642 return /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
27643 ValidatedSelectControl,
27644 {
27645 required: !!field.isValid?.required,
27646 markWhenOptional,
27647 customValidity: getCustomValidity(isValid2, validity),
27648 label,
27649 value,
27650 help: description,
27651 options: elements,
27652 onChange: onChangeControl,
27653 hideLabelFromVision,
27654 multiple: isMultiple,
27655 disabled: disabled2
27656 }
27657 );
27658 }
27659
27660 // packages/dataviews/build-module/components/dataform-controls/adaptive-select.mjs
27661 var import_jsx_runtime118 = __toESM(require_jsx_runtime(), 1);
27662 var ELEMENTS_THRESHOLD = 10;
27663 function AdaptiveSelect(props) {
27664 const { field } = props;
27665 const { elements } = useElements({
27666 elements: field.elements,
27667 getElements: field.getElements
27668 });
27669 if (elements.length >= ELEMENTS_THRESHOLD) {
27670 return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(Combobox, { ...props });
27671 }
27672 return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(Select2, { ...props });
27673 }
27674
27675 // packages/dataviews/build-module/components/dataform-controls/utils/validated-input.mjs
27676 var import_element88 = __toESM(require_element(), 1);
27677 var import_jsx_runtime119 = __toESM(require_jsx_runtime(), 1);
27678 function ValidatedText({
27679 data,
27680 field,
27681 onChange,
27682 hideLabelFromVision,
27683 markWhenOptional,
27684 type,
27685 prefix,
27686 suffix,
27687 validity
27688 }) {
27689 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
27690 const value = getValue({ item: data });
27691 const disabled2 = field.isDisabled({ item: data, field });
27692 const onValueChangeControl = (0, import_element88.useCallback)(
27693 (newValue) => onChange(
27694 setValue({
27695 item: data,
27696 value: newValue
27697 })
27698 ),
27699 [data, setValue, onChange]
27700 );
27701 return /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(
27702 ValidatedInputControl,
27703 {
27704 required: !!isValid2.required,
27705 markWhenOptional,
27706 customValidity: getCustomValidity(isValid2, validity),
27707 label,
27708 placeholder,
27709 value: value ?? "",
27710 description: typeof description === "string" ? description : void 0,
27711 details: typeof description === "string" ? void 0 : description,
27712 onValueChange: onValueChangeControl,
27713 hideLabelFromVision,
27714 type,
27715 prefix,
27716 suffix,
27717 disabled: disabled2,
27718 pattern: isValid2.pattern ? isValid2.pattern.constraint : void 0,
27719 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
27720 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0
27721 }
27722 );
27723 }
27724
27725 // packages/dataviews/build-module/components/dataform-controls/email.mjs
27726 var import_jsx_runtime120 = __toESM(require_jsx_runtime(), 1);
27727 function Email({
27728 data,
27729 field,
27730 onChange,
27731 hideLabelFromVision,
27732 markWhenOptional,
27733 validity
27734 }) {
27735 return /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(
27736 ValidatedText,
27737 {
27738 ...{
27739 data,
27740 field,
27741 onChange,
27742 hideLabelFromVision,
27743 markWhenOptional,
27744 validity,
27745 type: "email",
27746 prefix: /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(InputLayout3.Slot, { padding: "minimal", children: /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(Icon, { icon: envelope_default }) })
27747 }
27748 }
27749 );
27750 }
27751
27752 // packages/dataviews/build-module/components/dataform-controls/telephone.mjs
27753 var import_jsx_runtime121 = __toESM(require_jsx_runtime(), 1);
27754 function Telephone({
27755 data,
27756 field,
27757 onChange,
27758 hideLabelFromVision,
27759 markWhenOptional,
27760 validity
27761 }) {
27762 return /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
27763 ValidatedText,
27764 {
27765 ...{
27766 data,
27767 field,
27768 onChange,
27769 hideLabelFromVision,
27770 markWhenOptional,
27771 validity,
27772 type: "tel",
27773 prefix: /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(InputLayout3.Slot, { padding: "minimal", children: /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(Icon, { icon: mobile_default }) })
27774 }
27775 }
27776 );
27777 }
27778
27779 // packages/dataviews/build-module/components/dataform-controls/url.mjs
27780 var import_jsx_runtime122 = __toESM(require_jsx_runtime(), 1);
27781 function Url({
27782 data,
27783 field,
27784 onChange,
27785 hideLabelFromVision,
27786 markWhenOptional,
27787 validity
27788 }) {
27789 return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
27790 ValidatedText,
27791 {
27792 ...{
27793 data,
27794 field,
27795 onChange,
27796 hideLabelFromVision,
27797 markWhenOptional,
27798 validity,
27799 type: "url",
27800 prefix: /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(InputLayout3.Slot, { padding: "minimal", children: /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(Icon, { icon: link_default }) })
27801 }
27802 }
27803 );
27804 }
27805
27806 // packages/dataviews/build-module/components/dataform-controls/utils/validated-number.mjs
27807 var import_components17 = __toESM(require_components(), 1);
27808 var import_element89 = __toESM(require_element(), 1);
27809 var import_i18n18 = __toESM(require_i18n(), 1);
27810 var import_jsx_runtime123 = __toESM(require_jsx_runtime(), 1);
27811 function toNumberOrEmpty(value) {
27812 if (value === "" || value === void 0) {
27813 return "";
27814 }
27815 const number = Number(value);
27816 return Number.isFinite(number) ? number : "";
27817 }
27818 function BetweenControls({
27819 value,
27820 onChange,
27821 hideLabelFromVision,
27822 step
27823 }) {
27824 const [min4 = "", max4 = ""] = value;
27825 const onChangeMin = (0, import_element89.useCallback)(
27826 (newValue) => onChange([toNumberOrEmpty(newValue), max4]),
27827 [onChange, max4]
27828 );
27829 const onChangeMax = (0, import_element89.useCallback)(
27830 (newValue) => onChange([min4, toNumberOrEmpty(newValue)]),
27831 [onChange, min4]
27832 );
27833 return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
27834 import_components17.BaseControl,
27835 {
27836 help: (0, import_i18n18.__)("The max. value must be greater than the min. value."),
27837 children: /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)(import_components17.Flex, { direction: "row", gap: 4, children: [
27838 /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
27839 import_components17.__experimentalNumberControl,
27840 {
27841 label: (0, import_i18n18.__)("Min."),
27842 value: min4,
27843 max: max4 ? Number(max4) - step : void 0,
27844 onChange: onChangeMin,
27845 hideLabelFromVision,
27846 step
27847 }
27848 ),
27849 /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
27850 import_components17.__experimentalNumberControl,
27851 {
27852 label: (0, import_i18n18.__)("Max."),
27853 value: max4,
27854 min: min4 ? Number(min4) + step : void 0,
27855 onChange: onChangeMax,
27856 hideLabelFromVision,
27857 step
27858 }
27859 )
27860 ] })
27861 }
27862 );
27863 }
27864 function ValidatedNumber({
27865 data,
27866 field,
27867 onChange,
27868 hideLabelFromVision,
27869 markWhenOptional,
27870 operator,
27871 validity
27872 }) {
27873 const decimals = field.format?.decimals ?? 0;
27874 const step = Math.pow(10, Math.abs(decimals) * -1);
27875 const { label, description, getValue, setValue, isValid: isValid2 } = field;
27876 const value = getValue({ item: data }) ?? "";
27877 const disabled2 = field.isDisabled({ item: data, field });
27878 const onChangeControl = (0, import_element89.useCallback)(
27879 (newValue) => {
27880 onChange(
27881 setValue({
27882 item: data,
27883 // Do not convert an empty string or undefined to a number,
27884 // otherwise there's a mismatch between the UI control (empty)
27885 // and the data relied by onChange (0).
27886 value: ["", void 0].includes(newValue) ? void 0 : Number(newValue)
27887 })
27888 );
27889 },
27890 [data, onChange, setValue]
27891 );
27892 const onChangeBetweenControls = (0, import_element89.useCallback)(
27893 (newValue) => {
27894 onChange(
27895 setValue({
27896 item: data,
27897 value: newValue
27898 })
27899 );
27900 },
27901 [data, onChange, setValue]
27902 );
27903 if (operator === OPERATOR_BETWEEN) {
27904 let valueBetween = ["", ""];
27905 if (Array.isArray(value) && value.length === 2 && value.every(
27906 (element) => typeof element === "number" || element === ""
27907 )) {
27908 valueBetween = value;
27909 }
27910 return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
27911 BetweenControls,
27912 {
27913 value: valueBetween,
27914 onChange: onChangeBetweenControls,
27915 hideLabelFromVision,
27916 step
27917 }
27918 );
27919 }
27920 return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
27921 ValidatedNumberControl,
27922 {
27923 required: !!isValid2.required,
27924 markWhenOptional,
27925 customValidity: getCustomValidity(isValid2, validity),
27926 label,
27927 help: description,
27928 value,
27929 onChange: onChangeControl,
27930 hideLabelFromVision,
27931 step,
27932 min: typeof isValid2.min?.constraint === "number" ? isValid2.min.constraint : void 0,
27933 max: typeof isValid2.max?.constraint === "number" ? isValid2.max.constraint : void 0,
27934 disabled: disabled2
27935 }
27936 );
27937 }
27938
27939 // packages/dataviews/build-module/components/dataform-controls/integer.mjs
27940 var import_jsx_runtime124 = __toESM(require_jsx_runtime(), 1);
27941 function Integer(props) {
27942 return /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(ValidatedNumber, { ...props });
27943 }
27944
27945 // packages/dataviews/build-module/components/dataform-controls/number.mjs
27946 var import_jsx_runtime125 = __toESM(require_jsx_runtime(), 1);
27947 function Number2(props) {
27948 return /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(ValidatedNumber, { ...props });
27949 }
27950
27951 // packages/dataviews/build-module/components/dataform-controls/radio.mjs
27952 var import_components18 = __toESM(require_components(), 1);
27953 var import_element90 = __toESM(require_element(), 1);
27954 var import_jsx_runtime126 = __toESM(require_jsx_runtime(), 1);
27955 function Radio({
27956 data,
27957 field,
27958 onChange,
27959 hideLabelFromVision,
27960 markWhenOptional,
27961 validity
27962 }) {
27963 const { label, description, getValue, setValue, isValid: isValid2 } = field;
27964 const disabled2 = field.isDisabled({ item: data, field });
27965 const { elements, isLoading } = useElements({
27966 elements: field.elements,
27967 getElements: field.getElements
27968 });
27969 const value = getValue({ item: data });
27970 const onChangeControl = (0, import_element90.useCallback)(
27971 (newValue) => onChange(setValue({ item: data, value: newValue })),
27972 [data, onChange, setValue]
27973 );
27974 if (isLoading) {
27975 return /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(import_components18.Spinner, {});
27976 }
27977 return /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(
27978 ValidatedRadioControl,
27979 {
27980 required: !!field.isValid?.required,
27981 markWhenOptional,
27982 customValidity: getCustomValidity(isValid2, validity),
27983 label,
27984 help: description,
27985 onChange: onChangeControl,
27986 options: elements,
27987 selected: value,
27988 hideLabelFromVision,
27989 disabled: disabled2
27990 }
27991 );
27992 }
27993
27994 // packages/dataviews/build-module/components/dataform-controls/text.mjs
27995 var import_element91 = __toESM(require_element(), 1);
27996 var import_jsx_runtime127 = __toESM(require_jsx_runtime(), 1);
27997 function Text3({
27998 data,
27999 field,
28000 onChange,
28001 hideLabelFromVision,
28002 markWhenOptional,
28003 config,
28004 validity
28005 }) {
28006 const { prefix, suffix } = config || {};
28007 return /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(
28008 ValidatedText,
28009 {
28010 ...{
28011 data,
28012 field,
28013 onChange,
28014 hideLabelFromVision,
28015 markWhenOptional,
28016 validity,
28017 prefix: prefix ? (0, import_element91.createElement)(prefix) : void 0,
28018 suffix: suffix ? (0, import_element91.createElement)(suffix) : void 0
28019 }
28020 }
28021 );
28022 }
28023
28024 // packages/dataviews/build-module/components/dataform-controls/time.mjs
28025 var import_components19 = __toESM(require_components(), 1);
28026 var import_element92 = __toESM(require_element(), 1);
28027 var import_i18n19 = __toESM(require_i18n(), 1);
28028 var import_jsx_runtime128 = __toESM(require_jsx_runtime(), 1);
28029 function getStep(timeFormat, values) {
28030 const tokens = (timeFormat ?? "").replace(/\\./g, "");
28031 const hasSeconds = tokens.includes("s") || values.some((value) => (parseTime2(value) ?? 0) % 60 !== 0);
28032 return hasSeconds ? 1 : void 0;
28033 }
28034 function toInputValue(value) {
28035 const seconds = parseTime2(value);
28036 if (seconds === null) {
28037 return "";
28038 }
28039 const parts = [
28040 Math.floor(seconds / 3600),
28041 Math.floor(seconds % 3600 / 60)
28042 ];
28043 if (seconds % 60 !== 0) {
28044 parts.push(seconds % 60);
28045 }
28046 return parts.map((part) => String(part).padStart(2, "0")).join(":");
28047 }
28048 function BetweenControls2({
28049 value,
28050 onChange,
28051 hideLabelFromVision,
28052 disabled: disabled2,
28053 step,
28054 min: min4,
28055 max: max4
28056 }) {
28057 const [from = "", to = ""] = value;
28058 const onChangeFrom = (0, import_element92.useCallback)(
28059 (newValue) => onChange([newValue ?? "", to]),
28060 [onChange, to]
28061 );
28062 const onChangeTo = (0, import_element92.useCallback)(
28063 (newValue) => onChange([from, newValue ?? ""]),
28064 [onChange, from]
28065 );
28066 return /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(
28067 import_components19.BaseControl,
28068 {
28069 help: (0, import_i18n19.__)("The end time must be later than the start time."),
28070 children: /* @__PURE__ */ (0, import_jsx_runtime128.jsxs)(Stack, { direction: "row", gap: "sm", justify: "space-between", children: [
28071 /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(
28072 ValidatedInputControl,
28073 {
28074 type: "time",
28075 label: (0, import_i18n19.__)("From"),
28076 value: from,
28077 onValueChange: onChangeFrom,
28078 hideLabelFromVision,
28079 disabled: disabled2,
28080 step,
28081 min: min4,
28082 max: to || max4
28083 }
28084 ),
28085 /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(
28086 ValidatedInputControl,
28087 {
28088 type: "time",
28089 label: (0, import_i18n19.__)("To"),
28090 value: to,
28091 onValueChange: onChangeTo,
28092 hideLabelFromVision,
28093 disabled: disabled2,
28094 step,
28095 min: from || min4,
28096 max: max4
28097 }
28098 )
28099 ] })
28100 }
28101 );
28102 }
28103 function Time({
28104 data,
28105 field,
28106 onChange,
28107 hideLabelFromVision,
28108 markWhenOptional,
28109 operator,
28110 validity
28111 }) {
28112 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
28113 const value = getValue({ item: data });
28114 const disabled2 = field.isDisabled({ item: data, field });
28115 const timeFormat = field.format?.time;
28116 const min4 = typeof isValid2.min?.constraint === "string" ? isValid2.min.constraint : void 0;
28117 const max4 = typeof isValid2.max?.constraint === "string" ? isValid2.max.constraint : void 0;
28118 const onChangeControl = (0, import_element92.useCallback)(
28119 (newValue) => onChange(
28120 setValue({
28121 item: data,
28122 value: newValue === "" ? void 0 : newValue
28123 })
28124 ),
28125 [data, onChange, setValue]
28126 );
28127 const onChangeBetweenControls = (0, import_element92.useCallback)(
28128 ([from, to]) => onChange(
28129 setValue({
28130 item: data,
28131 // An unfilled bound is stored as `undefined`, which the
28132 // `between` operator reads as "do not apply the filter".
28133 value: [from || void 0, to || void 0]
28134 })
28135 ),
28136 [data, onChange, setValue]
28137 );
28138 if (operator === OPERATOR_BETWEEN) {
28139 let valueBetween = ["", ""];
28140 if (Array.isArray(value) && value.length === 2) {
28141 valueBetween = [
28142 toInputValue(value[0]),
28143 toInputValue(value[1])
28144 ];
28145 }
28146 return /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(
28147 BetweenControls2,
28148 {
28149 value: valueBetween,
28150 onChange: onChangeBetweenControls,
28151 hideLabelFromVision,
28152 disabled: disabled2,
28153 step: getStep(timeFormat, valueBetween),
28154 min: min4,
28155 max: max4
28156 }
28157 );
28158 }
28159 return /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(
28160 ValidatedInputControl,
28161 {
28162 required: !!isValid2.required,
28163 markWhenOptional,
28164 customValidity: getCustomValidity(isValid2, validity),
28165 type: "time",
28166 label,
28167 placeholder,
28168 description: typeof description === "string" ? description : void 0,
28169 details: typeof description === "string" ? void 0 : description,
28170 value: toInputValue(value),
28171 onValueChange: onChangeControl,
28172 hideLabelFromVision,
28173 disabled: disabled2,
28174 step: getStep(timeFormat, [value]),
28175 min: min4,
28176 max: max4
28177 }
28178 );
28179 }
28180
28181 // packages/dataviews/build-module/components/dataform-controls/toggle.mjs
28182 var import_element93 = __toESM(require_element(), 1);
28183 var import_jsx_runtime129 = __toESM(require_jsx_runtime(), 1);
28184 function Toggle({
28185 field,
28186 onChange,
28187 data,
28188 hideLabelFromVision,
28189 markWhenOptional,
28190 validity
28191 }) {
28192 const { label, description, getValue, setValue, isValid: isValid2 } = field;
28193 const disabled2 = field.isDisabled({ item: data, field });
28194 const onChangeControl = (0, import_element93.useCallback)(() => {
28195 onChange(
28196 setValue({ item: data, value: !getValue({ item: data }) })
28197 );
28198 }, [onChange, setValue, data, getValue]);
28199 return /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(
28200 ValidatedToggleControl,
28201 {
28202 required: !!isValid2.required,
28203 markWhenOptional,
28204 customValidity: getCustomValidity(isValid2, validity),
28205 hidden: hideLabelFromVision,
28206 label,
28207 help: description,
28208 checked: getValue({ item: data }),
28209 onChange: onChangeControl,
28210 disabled: disabled2
28211 }
28212 );
28213 }
28214
28215 // packages/dataviews/build-module/components/dataform-controls/textarea.mjs
28216 var import_element94 = __toESM(require_element(), 1);
28217 var import_jsx_runtime130 = __toESM(require_jsx_runtime(), 1);
28218 function Textarea3({
28219 data,
28220 field,
28221 onChange,
28222 hideLabelFromVision,
28223 markWhenOptional,
28224 config,
28225 validity
28226 }) {
28227 const { rows = 4 } = config || {};
28228 const disabled2 = field.isDisabled({ item: data, field });
28229 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
28230 const value = field.getValue({ item: data });
28231 const onValueChangeControl = (0, import_element94.useCallback)(
28232 (newValue) => onChange(setValue({ item: data, value: newValue })),
28233 [data, onChange, setValue]
28234 );
28235 return /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
28236 ValidatedTextareaControl,
28237 {
28238 required: !!isValid2.required,
28239 markWhenOptional,
28240 customValidity: getCustomValidity(isValid2, validity),
28241 label,
28242 placeholder,
28243 value: value ?? "",
28244 description: typeof description === "string" ? description : void 0,
28245 details: typeof description === "string" ? void 0 : description,
28246 onValueChange: onValueChangeControl,
28247 rows,
28248 disabled: disabled2,
28249 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
28250 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
28251 hideLabelFromVision
28252 }
28253 );
28254 }
28255
28256 // packages/dataviews/build-module/components/dataform-controls/toggle-group.mjs
28257 var import_components20 = __toESM(require_components(), 1);
28258 var import_element95 = __toESM(require_element(), 1);
28259 var import_jsx_runtime131 = __toESM(require_jsx_runtime(), 1);
28260 function ToggleGroup({
28261 data,
28262 field,
28263 onChange,
28264 hideLabelFromVision,
28265 markWhenOptional,
28266 validity
28267 }) {
28268 const { getValue, setValue, isValid: isValid2 } = field;
28269 const disabled2 = field.isDisabled({ item: data, field });
28270 const value = getValue({ item: data });
28271 const onChangeControl = (0, import_element95.useCallback)(
28272 (newValue) => onChange(setValue({ item: data, value: newValue })),
28273 [data, onChange, setValue]
28274 );
28275 const { elements, isLoading } = useElements({
28276 elements: field.elements,
28277 getElements: field.getElements
28278 });
28279 if (isLoading) {
28280 return /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(import_components20.Spinner, {});
28281 }
28282 if (elements.length === 0) {
28283 return null;
28284 }
28285 const selectedOption = elements.find((el) => el.value === value);
28286 return /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(
28287 ValidatedToggleGroupControl,
28288 {
28289 required: !!field.isValid?.required,
28290 markWhenOptional,
28291 customValidity: getCustomValidity(isValid2, validity),
28292 isBlock: true,
28293 label: field.label,
28294 help: selectedOption?.description || field.description,
28295 onChange: onChangeControl,
28296 value,
28297 hideLabelFromVision,
28298 children: elements.map((el) => /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(
28299 import_components20.__experimentalToggleGroupControlOption,
28300 {
28301 label: el.label,
28302 value: el.value,
28303 disabled: disabled2
28304 },
28305 el.value
28306 ))
28307 }
28308 );
28309 }
28310
28311 // packages/dataviews/build-module/components/dataform-controls/array.mjs
28312 var import_components21 = __toESM(require_components(), 1);
28313 var import_element96 = __toESM(require_element(), 1);
28314 var import_jsx_runtime132 = __toESM(require_jsx_runtime(), 1);
28315 function ArrayControl({
28316 data,
28317 field,
28318 onChange,
28319 hideLabelFromVision,
28320 markWhenOptional,
28321 validity
28322 }) {
28323 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
28324 const value = getValue({ item: data });
28325 const disabled2 = field.isDisabled({ item: data, field });
28326 const { elements, isLoading } = useElements({
28327 elements: field.elements,
28328 getElements: field.getElements
28329 });
28330 const arrayValueAsElements = (0, import_element96.useMemo)(
28331 () => Array.isArray(value) ? value.map((token) => {
28332 const element = elements?.find(
28333 (suggestion) => suggestion.value === token
28334 );
28335 return element || { value: token, label: token };
28336 }) : [],
28337 [value, elements]
28338 );
28339 const onChangeControl = (0, import_element96.useCallback)(
28340 (tokens) => {
28341 const valueTokens = tokens.map((token) => {
28342 if (typeof token === "object" && "value" in token) {
28343 return token.value;
28344 }
28345 return token;
28346 });
28347 onChange(setValue({ item: data, value: valueTokens }));
28348 },
28349 [onChange, setValue, data]
28350 );
28351 if (isLoading) {
28352 return /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(import_components21.Spinner, {});
28353 }
28354 return /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
28355 ValidatedFormTokenField,
28356 {
28357 required: !!isValid2?.required,
28358 markWhenOptional,
28359 customValidity: getCustomValidity(isValid2, validity),
28360 label: hideLabelFromVision ? void 0 : label,
28361 value: arrayValueAsElements,
28362 onChange: onChangeControl,
28363 placeholder,
28364 suggestions: elements?.map((element) => element.value),
28365 disabled: disabled2,
28366 __experimentalValidateInput: (token) => {
28367 if (field.isValid?.elements && elements) {
28368 return elements.some(
28369 (element) => element.value === token || element.label === token
28370 );
28371 }
28372 return true;
28373 },
28374 __experimentalExpandOnFocus: elements && elements.length > 0,
28375 help: description ?? (field.isValid?.elements ? "" : void 0),
28376 displayTransform: (token) => {
28377 if (typeof token === "object" && "label" in token) {
28378 return token.label;
28379 }
28380 if (typeof token === "string" && elements) {
28381 const element = elements.find(
28382 (el) => el.value === token
28383 );
28384 return element?.label || token;
28385 }
28386 return token;
28387 },
28388 __experimentalRenderItem: ({ item }) => {
28389 if (typeof item === "string" && elements) {
28390 const element = elements.find(
28391 (el) => el.value === item
28392 );
28393 return /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("span", { children: element?.label || item });
28394 }
28395 return /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("span", { children: item });
28396 }
28397 }
28398 );
28399 }
28400
28401 // node_modules/colord/index.mjs
28402 for (r2 = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, t = function(r3) {
28403 return "string" == typeof r3 ? r3.length > 0 : "number" == typeof r3;
28404 }, n = function(r3, t2, n2) {
28405 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = Math.pow(10, t2)), Math.round(n2 * r3) / n2 + 0;
28406 }, u = function(r3, t2, n2) {
28407 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = 1), r3 > n2 ? n2 : r3 > t2 ? r3 : t2;
28408 }, e = function(r3) {
28409 return (r3 = isFinite(r3) ? r3 % 360 : 0) < 0 ? r3 + 360 : r3;
28410 }, o = function(r3, t2) {
28411 return void 0 === t2 && (t2 = 0), n(r3, t2) % 360;
28412 }, a = function(r3) {
28413 return { r: u(r3.r, 0, 255), g: u(r3.g, 0, 255), b: u(r3.b, 0, 255), a: u(r3.a) };
28414 }, i = function(r3) {
28415 return { r: n(r3.r), g: n(r3.g), b: n(r3.b), a: n(r3.a, 3) };
28416 }, s = /^#([0-9a-f]{3,8})$/i, d = function(r3, t2) {
28417 var n2 = r3.charCodeAt(t2);
28418 return (15 & n2) + 9 * (n2 >> 6);
28419 }, h = function(r3, t2) {
28420 return d(r3, t2) << 4 | d(r3, t2 + 1);
28421 }, b = [], f = 0; f < 256; f++) b.push((f < 16 ? "0" : "") + f.toString(16));
28422 var r2;
28423 var t;
28424 var n;
28425 var u;
28426 var e;
28427 var o;
28428 var a;
28429 var i;
28430 var s;
28431 var d;
28432 var h;
28433 var b;
28434 var f;
28435 var g = function(r2) {
28436 return b[u(r2, 0, 255)];
28437 };
28438 var c = function(r2) {
28439 var t = r2.r, n = r2.g, u = r2.b, e = r2.a, o = Math.max(t, n, u), a = o - Math.min(t, n, u), i = a ? o === t ? (n - u) / a : o === n ? 2 + (u - t) / a : 4 + (t - n) / a : 0;
28440 return { h: 60 * (i < 0 ? i + 6 : i), s: o ? a / o * 100 : 0, v: o / 255 * 100, a: e };
28441 };
28442 var v = function(r2) {
28443 var t = r2.h, n = r2.s, u = r2.v, e = r2.a;
28444 t = t / 360 * 6, n /= 100, u /= 100;
28445 var o = Math.floor(t), a = u * (1 - n), i = u * (1 - (t - o) * n), s = u * (1 - (1 - t + o) * n), d = o % 6;
28446 return { r: 255 * [u, i, a, a, s, u][d], g: 255 * [s, u, u, i, a, a][d], b: 255 * [a, a, s, u, u, i][d], a: e };
28447 };
28448 var l = function(r2) {
28449 return { h: e(r2.h), s: u(r2.s, 0, 100), l: u(r2.l, 0, 100), a: u(r2.a) };
28450 };
28451 var p = function(r2) {
28452 return { h: o(r2.h), s: n(r2.s), l: n(r2.l), a: n(r2.a, 3) };
28453 };
28454 var m = function(r2) {
28455 return v((n = (t = r2).s, { h: t.h, s: (n *= ((u = t.l) < 50 ? u : 100 - u) / 100) > 0 ? 2 * n / (u + n) * 100 : 0, v: u + n, a: t.a }));
28456 var t, n, u;
28457 };
28458 var y = function(r2) {
28459 return { h: (t = c(r2)).h, s: (e = (200 - (n = t.s)) * (u = t.v) / 100) > 0 && e < 200 ? n * u / 100 / (e <= 100 ? e : 200 - e) * 100 : 0, l: e / 2, a: t.a };
28460 var t, n, u, e;
28461 };
28462 var N = /^hsla?\(\s*([+-]?(?:\d*\.\d+|\d+))(deg|rad|grad|turn)?\s*,\s*([+-]?(?:\d*\.\d+|\d+))%\s*,\s*([+-]?(?:\d*\.\d+|\d+))%\s*(?:,\s*([+-]?(?:\d*\.\d+|\d+))(%)?\s*)?\)$/i;
28463 var x = /^hsla?\(\s*([+-]?(?:\d*\.\d+|\d+))(deg|rad|grad|turn)?\s+([+-]?(?:\d*\.\d+|\d+))%\s+([+-]?(?:\d*\.\d+|\d+))%\s*(?:\/\s*([+-]?(?:\d*\.\d+|\d+))(%)?\s*)?\)$/i;
28464 var M = /^rgba?\(\s*([+-]?(?:\d*\.\d+|\d+))(%)?\s*,\s*([+-]?(?:\d*\.\d+|\d+))(%)?\s*,\s*([+-]?(?:\d*\.\d+|\d+))(%)?\s*(?:,\s*([+-]?(?:\d*\.\d+|\d+))(%)?\s*)?\)$/i;
28465 var H = /^rgba?\(\s*([+-]?(?:\d*\.\d+|\d+))(%)?\s+([+-]?(?:\d*\.\d+|\d+))(%)?\s+([+-]?(?:\d*\.\d+|\d+))(%)?\s*(?:\/\s*([+-]?(?:\d*\.\d+|\d+))(%)?\s*)?\)$/i;
28466 var $ = { string: [[function(r2) {
28467 if (!s.test(r2)) return null;
28468 var t = r2.length;
28469 return t <= 5 ? { r: 17 * d(r2, 1), g: 17 * d(r2, 2), b: 17 * d(r2, 3), a: 5 === t ? n(17 * d(r2, 4) / 255, 2) : 1 } : 7 === t || 9 === t ? { r: h(r2, 1), g: h(r2, 3), b: h(r2, 5), a: 9 === t ? n(h(r2, 7) / 255, 2) : 1 } : null;
28470 }, "hex"], [function(r2) {
28471 var t = M.exec(r2) || H.exec(r2);
28472 return t ? t[2] !== t[4] || t[4] !== t[6] ? null : a({ r: Number(t[1]) / (t[2] ? 100 / 255 : 1), g: Number(t[3]) / (t[4] ? 100 / 255 : 1), b: Number(t[5]) / (t[6] ? 100 / 255 : 1), a: void 0 === t[7] ? 1 : Number(t[7]) / (t[8] ? 100 : 1) }) : null;
28473 }, "rgb"], [function(t) {
28474 var n = N.exec(t) || x.exec(t);
28475 if (!n) return null;
28476 var u, e, o = l({ h: (u = n[1], e = n[2], void 0 === e && (e = "deg"), Number(u) * (r2[e] || 1)), s: Number(n[3]), l: Number(n[4]), a: void 0 === n[5] ? 1 : Number(n[5]) / (n[6] ? 100 : 1) });
28477 return m(o);
28478 }, "hsl"]], object: [[function(r2) {
28479 var n = r2.r, u = r2.g, e = r2.b, o = r2.a, i = void 0 === o ? 1 : o;
28480 return t(n) && t(u) && t(e) ? a({ r: Number(n), g: Number(u), b: Number(e), a: Number(i) }) : null;
28481 }, "rgb"], [function(r2) {
28482 var n = r2.h, u = r2.s, e = r2.l, o = r2.a, a = void 0 === o ? 1 : o;
28483 if (!t(n) || !t(u) || !t(e)) return null;
28484 var i = l({ h: Number(n), s: Number(u), l: Number(e), a: Number(a) });
28485 return m(i);
28486 }, "hsl"], [function(r2) {
28487 var n = r2.h, o = r2.s, a = r2.v, i = r2.a, s = void 0 === i ? 1 : i;
28488 if (!t(n) || !t(o) || !t(a)) return null;
28489 var d = (function(r3) {
28490 return { h: e(r3.h), s: u(r3.s, 0, 100), v: u(r3.v, 0, 100), a: u(r3.a) };
28491 })({ h: Number(n), s: Number(o), v: Number(a), a: Number(s) });
28492 return v(d);
28493 }, "hsv"]] };
28494 var j = function(r2, t) {
28495 for (var n = 0; n < t.length; n++) {
28496 var u = t[n][0](r2);
28497 if (u) return [u, t[n][1]];
28498 }
28499 return [null, void 0];
28500 };
28501 var w = function(r2) {
28502 return "string" == typeof r2 ? j(r2.trim(), $.string) : "object" == typeof r2 && null !== r2 ? j(r2, $.object) : [null, void 0];
28503 };
28504 var k = function(r2, t) {
28505 var n = y(r2);
28506 return { h: n.h, s: u(n.s + 100 * t, 0, 100), l: n.l, a: n.a };
28507 };
28508 var E = function(r2) {
28509 return (299 * r2.r + 587 * r2.g + 114 * r2.b) / 1e3 / 255;
28510 };
28511 var R = function(r2, t) {
28512 var n = y(r2);
28513 return { h: n.h, s: n.s, l: u(n.l + 100 * t, 0, 100), a: n.a };
28514 };
28515 var q = (function() {
28516 function r2(r3) {
28517 this.parsed = w(r3)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
28518 }
28519 return r2.prototype.isValid = function() {
28520 return null !== this.parsed;
28521 }, r2.prototype.brightness = function() {
28522 return n(E(this.rgba), 2);
28523 }, r2.prototype.isDark = function() {
28524 return E(this.rgba) < 0.5;
28525 }, r2.prototype.isLight = function() {
28526 return E(this.rgba) >= 0.5;
28527 }, r2.prototype.toHex = function() {
28528 return r3 = i(this.rgba), t = r3.r, u = r3.g, e = r3.b, a = (o = r3.a) < 1 ? g(n(255 * o)) : "", "#" + g(t) + g(u) + g(e) + a;
28529 var r3, t, u, e, o, a;
28530 }, r2.prototype.toRgb = function() {
28531 return i(this.rgba);
28532 }, r2.prototype.toRgbString = function() {
28533 return r3 = i(this.rgba), t = r3.r, n = r3.g, u = r3.b, (e = r3.a) < 1 ? "rgba(" + t + ", " + n + ", " + u + ", " + e + ")" : "rgb(" + t + ", " + n + ", " + u + ")";
28534 var r3, t, n, u, e;
28535 }, r2.prototype.toHsl = function() {
28536 return p(y(this.rgba));
28537 }, r2.prototype.toHslString = function() {
28538 return r3 = p(y(this.rgba)), t = r3.h, n = r3.s, u = r3.l, (e = r3.a) < 1 ? "hsla(" + t + ", " + n + "%, " + u + "%, " + e + ")" : "hsl(" + t + ", " + n + "%, " + u + "%)";
28539 var r3, t, n, u, e;
28540 }, r2.prototype.toHsv = function() {
28541 return r3 = c(this.rgba), { h: o(r3.h), s: n(r3.s), v: n(r3.v), a: n(r3.a, 3) };
28542 var r3;
28543 }, r2.prototype.invert = function() {
28544 return A({ r: 255 - (r3 = this.rgba).r, g: 255 - r3.g, b: 255 - r3.b, a: r3.a });
28545 var r3;
28546 }, r2.prototype.saturate = function(r3) {
28547 return void 0 === r3 && (r3 = 0.1), A(k(this.rgba, r3));
28548 }, r2.prototype.desaturate = function(r3) {
28549 return void 0 === r3 && (r3 = 0.1), A(k(this.rgba, -r3));
28550 }, r2.prototype.grayscale = function() {
28551 return A(k(this.rgba, -1));
28552 }, r2.prototype.lighten = function(r3) {
28553 return void 0 === r3 && (r3 = 0.1), A(R(this.rgba, r3));
28554 }, r2.prototype.darken = function(r3) {
28555 return void 0 === r3 && (r3 = 0.1), A(R(this.rgba, -r3));
28556 }, r2.prototype.rotate = function(r3) {
28557 return void 0 === r3 && (r3 = 15), this.hue(y(this.rgba).h + r3);
28558 }, r2.prototype.alpha = function(r3) {
28559 return "number" == typeof r3 ? A({ r: (t = this.rgba).r, g: t.g, b: t.b, a: r3 }) : n(this.rgba.a, 3);
28560 var t;
28561 }, r2.prototype.hue = function(r3) {
28562 var t = y(this.rgba);
28563 return "number" == typeof r3 ? A({ h: r3, s: t.s, l: t.l, a: t.a }) : o(t.h);
28564 }, r2.prototype.isEqual = function(r3) {
28565 return this.toHex() === A(r3).toHex();
28566 }, r2;
28567 })();
28568 var A = function(r2) {
28569 return r2 instanceof q ? r2 : new q(r2);
28570 };
28571
28572 // packages/dataviews/build-module/components/dataform-controls/color.mjs
28573 var import_components22 = __toESM(require_components(), 1);
28574 var import_element97 = __toESM(require_element(), 1);
28575 var import_i18n20 = __toESM(require_i18n(), 1);
28576 var import_jsx_runtime133 = __toESM(require_jsx_runtime(), 1);
28577 var ColorPickerDropdown = ({
28578 color,
28579 onColorChange,
28580 disabled: disabled2
28581 }) => {
28582 const validColor = color && A(color).isValid() ? color : "#ffffff";
28583 return /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(
28584 import_components22.Dropdown,
28585 {
28586 className: "dataviews-controls__color-picker-dropdown",
28587 popoverProps: { resize: false },
28588 renderToggle: ({ onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(
28589 import_components22.Button,
28590 {
28591 onClick: onToggle,
28592 "aria-label": (0, import_i18n20.__)("Open color picker"),
28593 size: "small",
28594 disabled: disabled2,
28595 accessibleWhenDisabled: true,
28596 icon: () => /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(import_components22.ColorIndicator, { colorValue: validColor })
28597 }
28598 ),
28599 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(import_components22.__experimentalDropdownContentWrapper, { paddingSize: "none", children: /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(
28600 import_components22.ColorPicker,
28601 {
28602 color: validColor,
28603 onChange: onColorChange,
28604 enableAlpha: true
28605 }
28606 ) })
28607 }
28608 );
28609 };
28610 function Color({
28611 data,
28612 field,
28613 onChange,
28614 hideLabelFromVision,
28615 markWhenOptional,
28616 validity
28617 }) {
28618 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
28619 const disabled2 = field.isDisabled({ item: data, field });
28620 const value = field.getValue({ item: data }) || "";
28621 const handleColorChange = (0, import_element97.useCallback)(
28622 (newColor) => {
28623 onChange(setValue({ item: data, value: newColor }));
28624 },
28625 [data, onChange, setValue]
28626 );
28627 const handleInputChange = (0, import_element97.useCallback)(
28628 (newValue) => {
28629 onChange(setValue({ item: data, value: newValue || "" }));
28630 },
28631 [data, onChange, setValue]
28632 );
28633 return /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(
28634 ValidatedInputControl,
28635 {
28636 required: !!field.isValid?.required,
28637 markWhenOptional,
28638 customValidity: getCustomValidity(isValid2, validity),
28639 label,
28640 placeholder,
28641 value,
28642 description: typeof description === "string" ? description : void 0,
28643 details: typeof description === "string" ? void 0 : description,
28644 onValueChange: handleInputChange,
28645 hideLabelFromVision,
28646 type: "text",
28647 disabled: disabled2,
28648 prefix: /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(InputLayout3.Slot, { padding: "minimal", children: /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(
28649 ColorPickerDropdown,
28650 {
28651 color: value,
28652 onColorChange: handleColorChange,
28653 disabled: disabled2
28654 }
28655 ) })
28656 }
28657 );
28658 }
28659
28660 // packages/dataviews/build-module/components/dataform-controls/password.mjs
28661 var import_components23 = __toESM(require_components(), 1);
28662 var import_element98 = __toESM(require_element(), 1);
28663 var import_i18n21 = __toESM(require_i18n(), 1);
28664 var import_jsx_runtime134 = __toESM(require_jsx_runtime(), 1);
28665 function Password({
28666 data,
28667 field,
28668 onChange,
28669 hideLabelFromVision,
28670 markWhenOptional,
28671 validity
28672 }) {
28673 const [isVisible, setIsVisible] = (0, import_element98.useState)(false);
28674 const disabled2 = field.isDisabled({ item: data, field });
28675 const toggleVisibility = (0, import_element98.useCallback)(() => {
28676 setIsVisible((prev) => !prev);
28677 }, []);
28678 return /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
28679 ValidatedText,
28680 {
28681 ...{
28682 data,
28683 field,
28684 onChange,
28685 hideLabelFromVision,
28686 markWhenOptional,
28687 validity,
28688 type: isVisible ? "text" : "password",
28689 suffix: /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(InputLayout3.Slot, { padding: "minimal", children: /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
28690 import_components23.Button,
28691 {
28692 icon: isVisible ? unseen_default : seen_default,
28693 onClick: toggleVisibility,
28694 size: "small",
28695 label: isVisible ? (0, import_i18n21.__)("Hide password") : (0, import_i18n21.__)("Show password"),
28696 disabled: disabled2,
28697 accessibleWhenDisabled: true
28698 }
28699 ) })
28700 }
28701 }
28702 );
28703 }
28704
28705 // packages/dataviews/build-module/field-types/utils/has-elements.mjs
28706 function hasElements(field) {
28707 return Array.isArray(field.elements) && field.elements.length > 0 || typeof field.getElements === "function";
28708 }
28709
28710 // packages/dataviews/build-module/components/dataform-controls/index.mjs
28711 var import_jsx_runtime135 = __toESM(require_jsx_runtime(), 1);
28712 var FORM_CONTROLS = {
28713 adaptiveSelect: AdaptiveSelect,
28714 array: ArrayControl,
28715 checkbox: Checkbox,
28716 color: Color,
28717 combobox: Combobox,
28718 datetime: DateTime,
28719 date: DateControl,
28720 email: Email,
28721 telephone: Telephone,
28722 url: Url,
28723 integer: Integer,
28724 number: Number2,
28725 password: Password,
28726 radio: Radio,
28727 select: Select2,
28728 text: Text3,
28729 time: Time,
28730 toggle: Toggle,
28731 textarea: Textarea3,
28732 toggleGroup: ToggleGroup
28733 };
28734 function isEditConfig(value) {
28735 return value && typeof value === "object" && typeof value.control === "string";
28736 }
28737 function createConfiguredControl(config) {
28738 const { control, ...controlConfig } = config;
28739 const BaseControlType = getControlByType(control);
28740 if (BaseControlType === null) {
28741 return null;
28742 }
28743 return function ConfiguredControl(props) {
28744 return /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(BaseControlType, { ...props, config: controlConfig });
28745 };
28746 }
28747 function getControl(field, fallback) {
28748 if (typeof field.Edit === "function") {
28749 return field.Edit;
28750 }
28751 if (typeof field.Edit === "string") {
28752 return getControlByType(field.Edit);
28753 }
28754 if (isEditConfig(field.Edit)) {
28755 return createConfiguredControl(field.Edit);
28756 }
28757 if (hasElements(field) && field.type !== "array") {
28758 return getControlByType("adaptiveSelect");
28759 }
28760 if (fallback === null) {
28761 return null;
28762 }
28763 return getControlByType(fallback);
28764 }
28765 function getControlByType(type) {
28766 if (Object.keys(FORM_CONTROLS).includes(type)) {
28767 return FORM_CONTROLS[type];
28768 }
28769 return null;
28770 }
28771
28772 // packages/dataviews/build-module/field-types/utils/get-filter-by.mjs
28773 function getFilterBy(field, defaultOperators, validOperators) {
28774 if (field.filterBy === false) {
28775 return false;
28776 }
28777 const operators = field.filterBy?.operators?.filter(
28778 (op) => validOperators.includes(op)
28779 ) ?? defaultOperators;
28780 if (operators.length === 0) {
28781 return false;
28782 }
28783 return {
28784 isPrimary: !!field.filterBy?.isPrimary,
28785 operators
28786 };
28787 }
28788 var get_filter_by_default = getFilterBy;
28789
28790 // packages/dataviews/build-module/field-types/utils/get-value-from-id.mjs
28791 var getValueFromId = (id) => ({ item }) => {
28792 const path = id.split(".");
28793 let value = item;
28794 for (const segment of path) {
28795 if (value.hasOwnProperty(segment)) {
28796 value = value[segment];
28797 } else {
28798 value = void 0;
28799 }
28800 }
28801 return value;
28802 };
28803 var get_value_from_id_default = getValueFromId;
28804
28805 // packages/dataviews/build-module/field-types/utils/set-value-from-id.mjs
28806 var setValueFromId = (id) => ({ value }) => {
28807 const path = id.split(".");
28808 const result = {};
28809 let current = result;
28810 for (const segment of path.slice(0, -1)) {
28811 current[segment] = {};
28812 current = current[segment];
28813 }
28814 current[path.at(-1)] = value;
28815 return result;
28816 };
28817 var set_value_from_id_default = setValueFromId;
28818
28819 // packages/dataviews/build-module/field-types/email.mjs
28820 var import_i18n22 = __toESM(require_i18n(), 1);
28821
28822 // packages/dataviews/build-module/field-types/utils/render-from-elements.mjs
28823 function RenderFromElements({
28824 item,
28825 field
28826 }) {
28827 const { elements, isLoading } = useElements({
28828 elements: field.elements,
28829 getElements: field.getElements
28830 });
28831 const value = field.getValue({ item });
28832 if (isLoading) {
28833 return value;
28834 }
28835 if (elements.length === 0) {
28836 return value;
28837 }
28838 return elements?.find((element) => element.value === value)?.label || field.getValue({ item });
28839 }
28840
28841 // packages/dataviews/build-module/field-types/utils/render-default.mjs
28842 var import_jsx_runtime136 = __toESM(require_jsx_runtime(), 1);
28843 function render({
28844 item,
28845 field
28846 }) {
28847 if (field.hasElements) {
28848 return /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(RenderFromElements, { item, field });
28849 }
28850 return field.getValueFormatted({ item, field });
28851 }
28852
28853 // packages/dataviews/build-module/field-types/utils/sort-text.mjs
28854 var sort_text_default = (a, b, direction) => {
28855 return direction === "asc" ? a.localeCompare(b) : b.localeCompare(a);
28856 };
28857
28858 // packages/dataviews/build-module/field-types/utils/is-valid-required.mjs
28859 function isValidRequired(item, field) {
28860 const value = field.getValue({ item });
28861 return ![void 0, "", null].includes(value);
28862 }
28863
28864 // packages/dataviews/build-module/field-types/utils/is-valid-min-length.mjs
28865 function isValidMinLength(item, field) {
28866 if (typeof field.isValid.minLength?.constraint !== "number") {
28867 return false;
28868 }
28869 const value = field.getValue({ item });
28870 if ([void 0, "", null].includes(value)) {
28871 return true;
28872 }
28873 return String(value).length >= field.isValid.minLength.constraint;
28874 }
28875
28876 // packages/dataviews/build-module/field-types/utils/is-valid-max-length.mjs
28877 function isValidMaxLength(item, field) {
28878 if (typeof field.isValid.maxLength?.constraint !== "number") {
28879 return false;
28880 }
28881 const value = field.getValue({ item });
28882 if ([void 0, "", null].includes(value)) {
28883 return true;
28884 }
28885 return String(value).length <= field.isValid.maxLength.constraint;
28886 }
28887
28888 // packages/dataviews/build-module/field-types/utils/is-valid-pattern.mjs
28889 function isValidPattern(item, field) {
28890 if (field.isValid.pattern?.constraint === void 0) {
28891 return true;
28892 }
28893 try {
28894 const regexp = new RegExp(field.isValid.pattern.constraint);
28895 const value = field.getValue({ item });
28896 if ([void 0, "", null].includes(value)) {
28897 return true;
28898 }
28899 return regexp.test(String(value));
28900 } catch {
28901 return false;
28902 }
28903 }
28904
28905 // packages/dataviews/build-module/field-types/utils/is-valid-elements.mjs
28906 function isValidElements(item, field) {
28907 const elements = field.elements ?? [];
28908 const validValues = elements.map((el) => el.value);
28909 if (validValues.length === 0) {
28910 return true;
28911 }
28912 const value = field.getValue({ item });
28913 return [].concat(value).every((v2) => validValues.includes(v2));
28914 }
28915
28916 // packages/dataviews/build-module/field-types/utils/get-value-formatted-default.mjs
28917 function getValueFormatted({
28918 item,
28919 field
28920 }) {
28921 return field.getValue({ item });
28922 }
28923 var get_value_formatted_default_default = getValueFormatted;
28924
28925 // packages/dataviews/build-module/field-types/email.mjs
28926 var emailRegex = /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
28927 function isValidCustom(item, field) {
28928 const value = field.getValue({ item });
28929 if (![void 0, "", null].includes(value) && !emailRegex.test(value)) {
28930 return (0, import_i18n22.__)("Value must be a valid email address.");
28931 }
28932 return null;
28933 }
28934 var email_default = {
28935 type: "email",
28936 render,
28937 Edit: "email",
28938 sort: sort_text_default,
28939 enableSorting: true,
28940 enableGlobalSearch: false,
28941 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
28942 validOperators: [
28943 OPERATOR_IS,
28944 OPERATOR_IS_NOT,
28945 OPERATOR_CONTAINS,
28946 OPERATOR_NOT_CONTAINS,
28947 OPERATOR_STARTS_WITH,
28948 // Multiple selection
28949 OPERATOR_IS_ANY,
28950 OPERATOR_IS_NONE,
28951 OPERATOR_IS_NOT_ALL
28952 ],
28953 format: {},
28954 getValueFormatted: get_value_formatted_default_default,
28955 validate: {
28956 required: isValidRequired,
28957 pattern: isValidPattern,
28958 minLength: isValidMinLength,
28959 maxLength: isValidMaxLength,
28960 elements: isValidElements,
28961 custom: isValidCustom
28962 }
28963 };
28964
28965 // packages/dataviews/build-module/field-types/integer.mjs
28966 var import_i18n23 = __toESM(require_i18n(), 1);
28967
28968 // packages/dataviews/build-module/field-types/utils/sort-number.mjs
28969 var sort_number_default = (a, b, direction) => {
28970 return direction === "asc" ? a - b : b - a;
28971 };
28972
28973 // packages/dataviews/build-module/field-types/utils/is-valid-min.mjs
28974 function isValidMin(item, field) {
28975 if (typeof field.isValid.min?.constraint !== "number") {
28976 return false;
28977 }
28978 const value = field.getValue({ item });
28979 if ([void 0, "", null].includes(value)) {
28980 return true;
28981 }
28982 return Number(value) >= field.isValid.min.constraint;
28983 }
28984
28985 // packages/dataviews/build-module/field-types/utils/is-valid-max.mjs
28986 function isValidMax(item, field) {
28987 if (typeof field.isValid.max?.constraint !== "number") {
28988 return false;
28989 }
28990 const value = field.getValue({ item });
28991 if ([void 0, "", null].includes(value)) {
28992 return true;
28993 }
28994 return Number(value) <= field.isValid.max.constraint;
28995 }
28996
28997 // packages/dataviews/build-module/field-types/integer.mjs
28998 var format2 = {
28999 separatorThousand: ","
29000 };
29001 function getValueFormatted2({
29002 item,
29003 field
29004 }) {
29005 let value = field.getValue({ item });
29006 if (value === null || value === void 0) {
29007 return "";
29008 }
29009 value = Number(value);
29010 if (!Number.isFinite(value)) {
29011 return String(value);
29012 }
29013 let formatInteger;
29014 if (field.type !== "integer") {
29015 formatInteger = format2;
29016 } else {
29017 formatInteger = field.format;
29018 }
29019 const { separatorThousand } = formatInteger;
29020 const integerValue = Math.trunc(value);
29021 if (!separatorThousand) {
29022 return String(integerValue);
29023 }
29024 return String(integerValue).replace(
29025 /\B(?=(\d{3})+(?!\d))/g,
29026 separatorThousand
29027 );
29028 }
29029 function isValidCustom2(item, field) {
29030 const value = field.getValue({ item });
29031 if (![void 0, "", null].includes(value) && !Number.isInteger(value)) {
29032 return (0, import_i18n23.__)("Value must be an integer.");
29033 }
29034 return null;
29035 }
29036 var integer_default = {
29037 type: "integer",
29038 render,
29039 Edit: "integer",
29040 sort: sort_number_default,
29041 enableSorting: true,
29042 enableGlobalSearch: false,
29043 defaultOperators: [
29044 OPERATOR_IS,
29045 OPERATOR_IS_NOT,
29046 OPERATOR_LESS_THAN,
29047 OPERATOR_GREATER_THAN,
29048 OPERATOR_LESS_THAN_OR_EQUAL,
29049 OPERATOR_GREATER_THAN_OR_EQUAL,
29050 OPERATOR_BETWEEN
29051 ],
29052 validOperators: [
29053 // Single-selection
29054 OPERATOR_IS,
29055 OPERATOR_IS_NOT,
29056 OPERATOR_LESS_THAN,
29057 OPERATOR_GREATER_THAN,
29058 OPERATOR_LESS_THAN_OR_EQUAL,
29059 OPERATOR_GREATER_THAN_OR_EQUAL,
29060 OPERATOR_BETWEEN,
29061 // Multiple-selection
29062 OPERATOR_IS_ANY,
29063 OPERATOR_IS_NONE,
29064 OPERATOR_IS_NOT_ALL
29065 ],
29066 format: format2,
29067 getValueFormatted: getValueFormatted2,
29068 validate: {
29069 required: isValidRequired,
29070 min: isValidMin,
29071 max: isValidMax,
29072 elements: isValidElements,
29073 custom: isValidCustom2
29074 }
29075 };
29076
29077 // packages/dataviews/build-module/field-types/number.mjs
29078 var import_i18n24 = __toESM(require_i18n(), 1);
29079 var format3 = {
29080 separatorThousand: ",",
29081 separatorDecimal: ".",
29082 decimals: 2
29083 };
29084 function getValueFormatted3({
29085 item,
29086 field
29087 }) {
29088 let value = field.getValue({ item });
29089 if (value === null || value === void 0) {
29090 return "";
29091 }
29092 value = Number(value);
29093 if (!Number.isFinite(value)) {
29094 return String(value);
29095 }
29096 let formatNumber;
29097 if (field.type !== "number") {
29098 formatNumber = format3;
29099 } else {
29100 formatNumber = field.format;
29101 }
29102 const { separatorThousand, separatorDecimal, decimals } = formatNumber;
29103 const fixedValue = value.toFixed(decimals);
29104 const [integerPart, decimalPart] = fixedValue.split(".");
29105 const formattedInteger = separatorThousand ? integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, separatorThousand) : integerPart;
29106 return decimals === 0 ? formattedInteger : formattedInteger + separatorDecimal + decimalPart;
29107 }
29108 function isEmpty(value) {
29109 return value === "" || value === void 0 || value === null;
29110 }
29111 function isValidCustom3(item, field) {
29112 const value = field.getValue({ item });
29113 if (!isEmpty(value) && !Number.isFinite(value)) {
29114 return (0, import_i18n24.__)("Value must be a number.");
29115 }
29116 return null;
29117 }
29118 var number_default = {
29119 type: "number",
29120 render,
29121 Edit: "number",
29122 sort: sort_number_default,
29123 enableSorting: true,
29124 enableGlobalSearch: false,
29125 defaultOperators: [
29126 OPERATOR_IS,
29127 OPERATOR_IS_NOT,
29128 OPERATOR_LESS_THAN,
29129 OPERATOR_GREATER_THAN,
29130 OPERATOR_LESS_THAN_OR_EQUAL,
29131 OPERATOR_GREATER_THAN_OR_EQUAL,
29132 OPERATOR_BETWEEN
29133 ],
29134 validOperators: [
29135 // Single-selection
29136 OPERATOR_IS,
29137 OPERATOR_IS_NOT,
29138 OPERATOR_LESS_THAN,
29139 OPERATOR_GREATER_THAN,
29140 OPERATOR_LESS_THAN_OR_EQUAL,
29141 OPERATOR_GREATER_THAN_OR_EQUAL,
29142 OPERATOR_BETWEEN,
29143 // Multiple-selection
29144 OPERATOR_IS_ANY,
29145 OPERATOR_IS_NONE,
29146 OPERATOR_IS_NOT_ALL
29147 ],
29148 format: format3,
29149 getValueFormatted: getValueFormatted3,
29150 validate: {
29151 required: isValidRequired,
29152 min: isValidMin,
29153 max: isValidMax,
29154 elements: isValidElements,
29155 custom: isValidCustom3
29156 }
29157 };
29158
29159 // packages/dataviews/build-module/field-types/text.mjs
29160 var text_default = {
29161 type: "text",
29162 render,
29163 Edit: "text",
29164 sort: sort_text_default,
29165 enableSorting: true,
29166 enableGlobalSearch: false,
29167 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
29168 validOperators: [
29169 // Single selection
29170 OPERATOR_IS,
29171 OPERATOR_IS_NOT,
29172 OPERATOR_CONTAINS,
29173 OPERATOR_NOT_CONTAINS,
29174 OPERATOR_STARTS_WITH,
29175 // Multiple selection
29176 OPERATOR_IS_ANY,
29177 OPERATOR_IS_NONE,
29178 OPERATOR_IS_NOT_ALL
29179 ],
29180 format: {},
29181 getValueFormatted: get_value_formatted_default_default,
29182 validate: {
29183 required: isValidRequired,
29184 pattern: isValidPattern,
29185 minLength: isValidMinLength,
29186 maxLength: isValidMaxLength,
29187 elements: isValidElements
29188 }
29189 };
29190
29191 // packages/dataviews/build-module/field-types/datetime.mjs
29192 var import_date9 = __toESM(require_date(), 1);
29193
29194 // packages/dataviews/build-module/field-types/utils/is-valid-boundary.mjs
29195 var import_date8 = __toESM(require_date(), 1);
29196 function parseDateLike(value) {
29197 if (!isValid(new Date(value))) {
29198 return null;
29199 }
29200 const parsed = (0, import_date8.getDate)(value);
29201 return parsed && isValid(parsed) ? parsed.getTime() : null;
29202 }
29203 function validateBoundary(item, field, boundary, parse2) {
29204 const constraint = field.isValid[boundary]?.constraint;
29205 if (typeof constraint !== "string") {
29206 return false;
29207 }
29208 const value = field.getValue({ item });
29209 const boundaryValue = Array.isArray(value) ? value[boundary === "min" ? 0 : value.length - 1] : value;
29210 if (boundaryValue === void 0 || boundaryValue === null || boundaryValue === "") {
29211 return true;
29212 }
29213 const parsedConstraint = parse2(constraint);
29214 const parsedValue = parse2(String(boundaryValue));
29215 if (parsedConstraint === null || parsedValue === null) {
29216 return false;
29217 }
29218 return boundary === "min" ? parsedValue >= parsedConstraint : parsedValue <= parsedConstraint;
29219 }
29220 function isValidMinDate(item, field) {
29221 return validateBoundary(item, field, "min", parseDateLike);
29222 }
29223 function isValidMaxDate(item, field) {
29224 return validateBoundary(item, field, "max", parseDateLike);
29225 }
29226 function isValidMinTime(item, field) {
29227 return validateBoundary(item, field, "min", parseTime2);
29228 }
29229 function isValidMaxTime(item, field) {
29230 return validateBoundary(item, field, "max", parseTime2);
29231 }
29232
29233 // packages/dataviews/build-module/field-types/datetime.mjs
29234 var format4 = {
29235 datetime: (0, import_date9.getSettings)().formats.datetime,
29236 weekStartsOn: (0, import_date9.getSettings)().l10n.startOfWeek
29237 };
29238 function getValueFormatted4({
29239 item,
29240 field
29241 }) {
29242 const value = field.getValue({ item });
29243 if (["", void 0, null].includes(value)) {
29244 return "";
29245 }
29246 let formatDatetime;
29247 if (field.type !== "datetime") {
29248 formatDatetime = format4;
29249 } else {
29250 formatDatetime = field.format;
29251 }
29252 return (0, import_date9.dateI18n)(formatDatetime.datetime, (0, import_date9.getDate)(value));
29253 }
29254 var sort = (a, b, direction) => {
29255 const timeA = new Date(a).getTime();
29256 const timeB = new Date(b).getTime();
29257 return direction === "asc" ? timeA - timeB : timeB - timeA;
29258 };
29259 var datetime_default = {
29260 type: "datetime",
29261 render,
29262 Edit: "datetime",
29263 sort,
29264 enableSorting: true,
29265 enableGlobalSearch: false,
29266 defaultOperators: [
29267 OPERATOR_ON,
29268 OPERATOR_NOT_ON,
29269 OPERATOR_BEFORE,
29270 OPERATOR_AFTER,
29271 OPERATOR_BEFORE_INC,
29272 OPERATOR_AFTER_INC,
29273 OPERATOR_IN_THE_PAST,
29274 OPERATOR_OVER
29275 ],
29276 validOperators: [
29277 OPERATOR_ON,
29278 OPERATOR_NOT_ON,
29279 OPERATOR_BEFORE,
29280 OPERATOR_AFTER,
29281 OPERATOR_BEFORE_INC,
29282 OPERATOR_AFTER_INC,
29283 OPERATOR_IN_THE_PAST,
29284 OPERATOR_OVER
29285 ],
29286 format: format4,
29287 getValueFormatted: getValueFormatted4,
29288 validate: {
29289 required: isValidRequired,
29290 elements: isValidElements,
29291 min: isValidMinDate,
29292 max: isValidMaxDate
29293 }
29294 };
29295
29296 // packages/dataviews/build-module/field-types/date.mjs
29297 var import_date10 = __toESM(require_date(), 1);
29298 var format5 = {
29299 date: (0, import_date10.getSettings)().formats.date,
29300 weekStartsOn: (0, import_date10.getSettings)().l10n.startOfWeek
29301 };
29302 function getValueFormatted5({
29303 item,
29304 field
29305 }) {
29306 const value = field.getValue({ item });
29307 if (["", void 0, null].includes(value)) {
29308 return "";
29309 }
29310 let formatDate2;
29311 if (field.type !== "date") {
29312 formatDate2 = format5;
29313 } else {
29314 formatDate2 = field.format;
29315 }
29316 return (0, import_date10.dateI18n)(formatDate2.date, (0, import_date10.getDate)(value));
29317 }
29318 var sort2 = (a, b, direction) => {
29319 const timeA = new Date(a).getTime();
29320 const timeB = new Date(b).getTime();
29321 return direction === "asc" ? timeA - timeB : timeB - timeA;
29322 };
29323 var date_default = {
29324 type: "date",
29325 render,
29326 Edit: "date",
29327 sort: sort2,
29328 enableSorting: true,
29329 enableGlobalSearch: false,
29330 defaultOperators: [
29331 OPERATOR_ON,
29332 OPERATOR_NOT_ON,
29333 OPERATOR_BEFORE,
29334 OPERATOR_AFTER,
29335 OPERATOR_BEFORE_INC,
29336 OPERATOR_AFTER_INC,
29337 OPERATOR_IN_THE_PAST,
29338 OPERATOR_OVER,
29339 OPERATOR_BETWEEN
29340 ],
29341 validOperators: [
29342 OPERATOR_ON,
29343 OPERATOR_NOT_ON,
29344 OPERATOR_BEFORE,
29345 OPERATOR_AFTER,
29346 OPERATOR_BEFORE_INC,
29347 OPERATOR_AFTER_INC,
29348 OPERATOR_IN_THE_PAST,
29349 OPERATOR_OVER,
29350 OPERATOR_BETWEEN
29351 ],
29352 format: format5,
29353 getValueFormatted: getValueFormatted5,
29354 validate: {
29355 required: isValidRequired,
29356 elements: isValidElements,
29357 min: isValidMinDate,
29358 max: isValidMaxDate
29359 }
29360 };
29361
29362 // packages/dataviews/build-module/field-types/time.mjs
29363 var import_date11 = __toESM(require_date(), 1);
29364 var format6 = {
29365 time: (0, import_date11.getSettings)().formats.time
29366 };
29367 var ANCHOR_DATE = "2000-01-01";
29368 function toAnchoredDate(secondsSinceMidnight) {
29369 const hours = Math.floor(secondsSinceMidnight / 3600);
29370 const minutes = Math.floor(secondsSinceMidnight % 3600 / 60);
29371 const seconds = secondsSinceMidnight % 60;
29372 const time = [hours, minutes, seconds].map((part) => String(part).padStart(2, "0")).join(":");
29373 return (0, import_date11.getDate)(`${ANCHOR_DATE}T${time}`);
29374 }
29375 function getValueFormatted6({
29376 item,
29377 field
29378 }) {
29379 const secondsSinceMidnight = parseTime2(field.getValue({ item }));
29380 if (secondsSinceMidnight === null) {
29381 return "";
29382 }
29383 let formatTime;
29384 if (field.type !== "time") {
29385 formatTime = format6;
29386 } else {
29387 formatTime = field.format;
29388 }
29389 return (0, import_date11.dateI18n)(formatTime.time, toAnchoredDate(secondsSinceMidnight));
29390 }
29391 var sort3 = (a, b, direction) => {
29392 const timeA = parseTime2(a);
29393 const timeB = parseTime2(b);
29394 if (timeA === null || timeB === null) {
29395 if (timeA === timeB) {
29396 return 0;
29397 }
29398 return timeA === null ? 1 : -1;
29399 }
29400 return direction === "asc" ? timeA - timeB : timeB - timeA;
29401 };
29402 var time_default = {
29403 type: "time",
29404 render,
29405 Edit: "time",
29406 sort: sort3,
29407 enableSorting: true,
29408 enableGlobalSearch: false,
29409 defaultOperators: [
29410 OPERATOR_ON,
29411 OPERATOR_NOT_ON,
29412 OPERATOR_BEFORE,
29413 OPERATOR_AFTER,
29414 OPERATOR_BEFORE_INC,
29415 OPERATOR_AFTER_INC,
29416 OPERATOR_BETWEEN
29417 ],
29418 validOperators: [
29419 OPERATOR_ON,
29420 OPERATOR_NOT_ON,
29421 OPERATOR_BEFORE,
29422 OPERATOR_AFTER,
29423 OPERATOR_BEFORE_INC,
29424 OPERATOR_AFTER_INC,
29425 OPERATOR_BETWEEN
29426 ],
29427 format: format6,
29428 getValueFormatted: getValueFormatted6,
29429 validate: {
29430 required: isValidRequired,
29431 elements: isValidElements,
29432 min: isValidMinTime,
29433 max: isValidMaxTime
29434 }
29435 };
29436
29437 // packages/dataviews/build-module/field-types/boolean.mjs
29438 var import_i18n25 = __toESM(require_i18n(), 1);
29439
29440 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-bool.mjs
29441 function isValidRequiredForBool(item, field) {
29442 const value = field.getValue({ item });
29443 return value === true;
29444 }
29445
29446 // packages/dataviews/build-module/field-types/boolean.mjs
29447 function getValueFormatted7({
29448 item,
29449 field
29450 }) {
29451 const value = field.getValue({ item });
29452 if (value === true) {
29453 return (0, import_i18n25.__)("True");
29454 }
29455 if (value === false) {
29456 return (0, import_i18n25.__)("False");
29457 }
29458 return "";
29459 }
29460 function isValidCustom4(item, field) {
29461 const value = field.getValue({ item });
29462 if (![void 0, "", null].includes(value) && ![true, false].includes(value)) {
29463 return (0, import_i18n25.__)("Value must be true, false, or undefined");
29464 }
29465 return null;
29466 }
29467 var sort4 = (a, b, direction) => {
29468 const boolA = Boolean(a);
29469 const boolB = Boolean(b);
29470 if (boolA === boolB) {
29471 return 0;
29472 }
29473 if (direction === "asc") {
29474 return boolA ? 1 : -1;
29475 }
29476 return boolA ? -1 : 1;
29477 };
29478 var boolean_default = {
29479 type: "boolean",
29480 render,
29481 Edit: "checkbox",
29482 sort: sort4,
29483 validate: {
29484 required: isValidRequiredForBool,
29485 elements: isValidElements,
29486 custom: isValidCustom4
29487 },
29488 enableSorting: true,
29489 enableGlobalSearch: false,
29490 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
29491 validOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
29492 format: {},
29493 getValueFormatted: getValueFormatted7
29494 };
29495
29496 // packages/dataviews/build-module/field-types/media.mjs
29497 var media_default = {
29498 type: "media",
29499 render: () => null,
29500 Edit: null,
29501 sort: () => 0,
29502 enableSorting: false,
29503 enableGlobalSearch: false,
29504 defaultOperators: [],
29505 validOperators: [],
29506 format: {},
29507 getValueFormatted: get_value_formatted_default_default,
29508 // cannot validate any constraint, so
29509 // the only available validation for the field author
29510 // would be providing a custom validator.
29511 validate: {}
29512 };
29513
29514 // packages/dataviews/build-module/field-types/array.mjs
29515 var import_i18n26 = __toESM(require_i18n(), 1);
29516
29517 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-array.mjs
29518 function isValidRequiredForArray(item, field) {
29519 const value = field.getValue({ item });
29520 return Array.isArray(value) && value.length > 0 && value.every(
29521 (element) => ![void 0, "", null].includes(element)
29522 );
29523 }
29524
29525 // packages/dataviews/build-module/field-types/array.mjs
29526 function getValueFormatted8({
29527 item,
29528 field
29529 }) {
29530 const value = field.getValue({ item });
29531 const arr = Array.isArray(value) ? value : [];
29532 return arr.join(", ");
29533 }
29534 function render2({ item, field }) {
29535 return getValueFormatted8({ item, field });
29536 }
29537 function isValidCustom5(item, field) {
29538 const value = field.getValue({ item });
29539 if ([void 0, "", null].includes(value)) {
29540 return null;
29541 }
29542 if (!Array.isArray(value)) {
29543 return (0, import_i18n26.__)("Value must be an array.");
29544 }
29545 if (!value.every((v2) => typeof v2 === "string")) {
29546 return (0, import_i18n26.__)("Every value must be a string.");
29547 }
29548 return null;
29549 }
29550 var sort5 = (a, b, direction) => {
29551 const arrA = Array.isArray(a) ? a : [];
29552 const arrB = Array.isArray(b) ? b : [];
29553 if (arrA.length !== arrB.length) {
29554 return direction === "asc" ? arrA.length - arrB.length : arrB.length - arrA.length;
29555 }
29556 const joinedA = arrA.join(",");
29557 const joinedB = arrB.join(",");
29558 return direction === "asc" ? joinedA.localeCompare(joinedB) : joinedB.localeCompare(joinedA);
29559 };
29560 var array_default = {
29561 type: "array",
29562 render: render2,
29563 Edit: "array",
29564 sort: sort5,
29565 enableSorting: true,
29566 enableGlobalSearch: false,
29567 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
29568 validOperators: [
29569 OPERATOR_IS_ANY,
29570 OPERATOR_IS_NONE,
29571 OPERATOR_IS_ALL,
29572 OPERATOR_IS_NOT_ALL
29573 ],
29574 format: {},
29575 getValueFormatted: getValueFormatted8,
29576 validate: {
29577 required: isValidRequiredForArray,
29578 elements: isValidElements,
29579 custom: isValidCustom5
29580 }
29581 };
29582
29583 // packages/dataviews/build-module/field-types/password.mjs
29584 function getValueFormatted9({
29585 item,
29586 field
29587 }) {
29588 return field.getValue({ item }) ? "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" : "";
29589 }
29590 var password_default = {
29591 type: "password",
29592 render,
29593 Edit: "password",
29594 sort: () => 0,
29595 // Passwords should not be sortable for security reasons
29596 enableSorting: false,
29597 enableGlobalSearch: false,
29598 defaultOperators: [],
29599 validOperators: [],
29600 format: {},
29601 getValueFormatted: getValueFormatted9,
29602 validate: {
29603 required: isValidRequired,
29604 pattern: isValidPattern,
29605 minLength: isValidMinLength,
29606 maxLength: isValidMaxLength,
29607 elements: isValidElements
29608 }
29609 };
29610
29611 // packages/dataviews/build-module/field-types/telephone.mjs
29612 var telephone_default = {
29613 type: "telephone",
29614 render,
29615 Edit: "telephone",
29616 sort: sort_text_default,
29617 enableSorting: true,
29618 enableGlobalSearch: false,
29619 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
29620 validOperators: [
29621 OPERATOR_IS,
29622 OPERATOR_IS_NOT,
29623 OPERATOR_CONTAINS,
29624 OPERATOR_NOT_CONTAINS,
29625 OPERATOR_STARTS_WITH,
29626 // Multiple selection
29627 OPERATOR_IS_ANY,
29628 OPERATOR_IS_NONE,
29629 OPERATOR_IS_NOT_ALL
29630 ],
29631 format: {},
29632 getValueFormatted: get_value_formatted_default_default,
29633 validate: {
29634 required: isValidRequired,
29635 pattern: isValidPattern,
29636 minLength: isValidMinLength,
29637 maxLength: isValidMaxLength,
29638 elements: isValidElements
29639 }
29640 };
29641
29642 // packages/dataviews/build-module/field-types/color.mjs
29643 var import_i18n27 = __toESM(require_i18n(), 1);
29644 var import_jsx_runtime137 = __toESM(require_jsx_runtime(), 1);
29645 function render3({ item, field }) {
29646 if (field.hasElements) {
29647 return /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(RenderFromElements, { item, field });
29648 }
29649 const value = get_value_formatted_default_default({ item, field });
29650 if (!value || !A(value).isValid()) {
29651 return value;
29652 }
29653 return /* @__PURE__ */ (0, import_jsx_runtime137.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
29654 /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(
29655 "div",
29656 {
29657 style: {
29658 width: "16px",
29659 height: "16px",
29660 borderRadius: "50%",
29661 backgroundColor: value,
29662 border: "1px solid #ddd",
29663 flexShrink: 0
29664 }
29665 }
29666 ),
29667 /* @__PURE__ */ (0, import_jsx_runtime137.jsx)("span", { children: value })
29668 ] });
29669 }
29670 function isValidCustom6(item, field) {
29671 const value = field.getValue({ item });
29672 if (![void 0, "", null].includes(value) && !A(value).isValid()) {
29673 return (0, import_i18n27.__)("Value must be a valid color.");
29674 }
29675 return null;
29676 }
29677 var sort6 = (a, b, direction) => {
29678 const colorA = A(a);
29679 const colorB = A(b);
29680 if (!colorA.isValid() && !colorB.isValid()) {
29681 return 0;
29682 }
29683 if (!colorA.isValid()) {
29684 return direction === "asc" ? 1 : -1;
29685 }
29686 if (!colorB.isValid()) {
29687 return direction === "asc" ? -1 : 1;
29688 }
29689 const hslA = colorA.toHsl();
29690 const hslB = colorB.toHsl();
29691 if (hslA.h !== hslB.h) {
29692 return direction === "asc" ? hslA.h - hslB.h : hslB.h - hslA.h;
29693 }
29694 if (hslA.s !== hslB.s) {
29695 return direction === "asc" ? hslA.s - hslB.s : hslB.s - hslA.s;
29696 }
29697 return direction === "asc" ? hslA.l - hslB.l : hslB.l - hslA.l;
29698 };
29699 var color_default = {
29700 type: "color",
29701 render: render3,
29702 Edit: "color",
29703 sort: sort6,
29704 enableSorting: true,
29705 enableGlobalSearch: false,
29706 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
29707 validOperators: [
29708 OPERATOR_IS,
29709 OPERATOR_IS_NOT,
29710 OPERATOR_IS_ANY,
29711 OPERATOR_IS_NONE
29712 ],
29713 format: {},
29714 getValueFormatted: get_value_formatted_default_default,
29715 validate: {
29716 required: isValidRequired,
29717 elements: isValidElements,
29718 custom: isValidCustom6
29719 }
29720 };
29721
29722 // packages/dataviews/build-module/field-types/url.mjs
29723 var url_default = {
29724 type: "url",
29725 render,
29726 Edit: "url",
29727 sort: sort_text_default,
29728 enableSorting: true,
29729 enableGlobalSearch: false,
29730 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
29731 validOperators: [
29732 OPERATOR_IS,
29733 OPERATOR_IS_NOT,
29734 OPERATOR_CONTAINS,
29735 OPERATOR_NOT_CONTAINS,
29736 OPERATOR_STARTS_WITH,
29737 // Multiple selection
29738 OPERATOR_IS_ANY,
29739 OPERATOR_IS_NONE,
29740 OPERATOR_IS_NOT_ALL
29741 ],
29742 format: {},
29743 getValueFormatted: get_value_formatted_default_default,
29744 validate: {
29745 required: isValidRequired,
29746 pattern: isValidPattern,
29747 minLength: isValidMinLength,
29748 maxLength: isValidMaxLength,
29749 elements: isValidElements
29750 }
29751 };
29752
29753 // packages/dataviews/build-module/field-types/no-type.mjs
29754 var sort7 = (a, b, direction) => {
29755 if (typeof a === "number" && typeof b === "number") {
29756 return sort_number_default(a, b, direction);
29757 }
29758 return sort_text_default(a, b, direction);
29759 };
29760 var no_type_default = {
29761 // type: no type for this one
29762 render,
29763 Edit: null,
29764 sort: sort7,
29765 enableSorting: true,
29766 enableGlobalSearch: false,
29767 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
29768 validOperators: getAllOperatorNames(),
29769 format: {},
29770 getValueFormatted: get_value_formatted_default_default,
29771 validate: {
29772 required: isValidRequired,
29773 elements: isValidElements
29774 }
29775 };
29776
29777 // packages/dataviews/build-module/field-types/utils/get-is-valid.mjs
29778 function supportsNumericRangeConstraint(type) {
29779 return type === "integer" || type === "number";
29780 }
29781 function supportsStringRangeConstraint(type) {
29782 return type === "date" || type === "datetime" || type === "time";
29783 }
29784 function normalizeRangeRule(value, fieldType, key) {
29785 const validator = fieldType.validate[key];
29786 if (validator && (typeof value === "number" && supportsNumericRangeConstraint(fieldType.type) || typeof value === "string" && supportsStringRangeConstraint(fieldType.type))) {
29787 return { constraint: value, validate: validator };
29788 }
29789 return void 0;
29790 }
29791 function getIsValid(field, fieldType) {
29792 const rules = field.isValid;
29793 let required;
29794 if (rules?.required === true && fieldType.validate.required !== void 0) {
29795 required = {
29796 constraint: true,
29797 validate: fieldType.validate.required
29798 };
29799 }
29800 let elements;
29801 if ((rules?.elements === true || // elements is enabled unless the field opts-out
29802 rules?.elements === void 0 && (!!field.elements || !!field.getElements)) && fieldType.validate.elements !== void 0) {
29803 elements = {
29804 constraint: true,
29805 validate: fieldType.validate.elements
29806 };
29807 }
29808 const min4 = normalizeRangeRule(rules?.min, fieldType, "min");
29809 const max4 = normalizeRangeRule(rules?.max, fieldType, "max");
29810 const minLengthValue = rules?.minLength;
29811 let minLength;
29812 if (typeof minLengthValue === "number" && fieldType.validate.minLength !== void 0) {
29813 minLength = {
29814 constraint: minLengthValue,
29815 validate: fieldType.validate.minLength
29816 };
29817 }
29818 const maxLengthValue = rules?.maxLength;
29819 let maxLength;
29820 if (typeof maxLengthValue === "number" && fieldType.validate.maxLength !== void 0) {
29821 maxLength = {
29822 constraint: maxLengthValue,
29823 validate: fieldType.validate.maxLength
29824 };
29825 }
29826 const patternValue = rules?.pattern;
29827 let pattern;
29828 if (patternValue !== void 0 && fieldType.validate.pattern !== void 0) {
29829 pattern = {
29830 constraint: patternValue,
29831 validate: fieldType.validate.pattern
29832 };
29833 }
29834 const custom = rules?.custom ?? fieldType.validate.custom;
29835 return {
29836 required,
29837 elements,
29838 min: min4,
29839 max: max4,
29840 minLength,
29841 maxLength,
29842 pattern,
29843 custom
29844 };
29845 }
29846
29847 // packages/dataviews/build-module/field-types/utils/get-filter.mjs
29848 function getFilter(fieldType) {
29849 return fieldType.validOperators.reduce((accumulator, operator) => {
29850 const operatorObj = getOperatorByName(operator);
29851 if (operatorObj?.filter) {
29852 accumulator[operator] = operatorObj.filter;
29853 }
29854 return accumulator;
29855 }, {});
29856 }
29857
29858 // packages/dataviews/build-module/field-types/utils/get-format.mjs
29859 function getFormat(field, fieldType) {
29860 return {
29861 ...fieldType.format,
29862 ...field.format
29863 };
29864 }
29865 var get_format_default = getFormat;
29866
29867 // packages/dataviews/build-module/field-types/index.mjs
29868 function getFieldTypeByName(type) {
29869 const found = [
29870 email_default,
29871 integer_default,
29872 number_default,
29873 text_default,
29874 datetime_default,
29875 date_default,
29876 time_default,
29877 boolean_default,
29878 media_default,
29879 array_default,
29880 password_default,
29881 telephone_default,
29882 color_default,
29883 url_default
29884 ].find((fieldType) => fieldType?.type === type);
29885 if (!!found) {
29886 return found;
29887 }
29888 return no_type_default;
29889 }
29890 function normalizeFields(fields) {
29891 return fields.map((field) => {
29892 const fieldType = getFieldTypeByName(field.type);
29893 const getValue = field.getValue || get_value_from_id_default(field.id);
29894 const sort8 = function(a, b, direction) {
29895 const aValue = getValue({ item: a });
29896 const bValue = getValue({ item: b });
29897 return field.sort ? field.sort(aValue, bValue, direction) : fieldType.sort(aValue, bValue, direction);
29898 };
29899 return {
29900 id: field.id,
29901 label: field.label || field.id,
29902 header: field.header || field.label || field.id,
29903 description: field.description,
29904 placeholder: field.placeholder,
29905 getValue,
29906 setValue: field.setValue || set_value_from_id_default(field.id),
29907 elements: field.elements,
29908 getElements: field.getElements,
29909 hasElements: hasElements(field),
29910 isVisible: field.isVisible,
29911 isDisabled: typeof field.isDisabled === "function" ? field.isDisabled : () => !!field.isDisabled,
29912 enableHiding: field.enableHiding ?? true,
29913 readOnly: field.readOnly ?? false,
29914 // The type provides defaults for the following props
29915 type: fieldType.type,
29916 render: field.render ?? fieldType.render,
29917 Edit: getControl(field, fieldType.Edit),
29918 sort: sort8,
29919 enableSorting: field.enableSorting ?? fieldType.enableSorting,
29920 enableGlobalSearch: field.enableGlobalSearch ?? fieldType.enableGlobalSearch,
29921 isValid: getIsValid(field, fieldType),
29922 filterBy: get_filter_by_default(
29923 field,
29924 fieldType.defaultOperators,
29925 fieldType.validOperators
29926 ),
29927 filter: getFilter(fieldType),
29928 format: get_format_default(field, fieldType),
29929 getValueFormatted: field.getValueFormatted ?? fieldType.getValueFormatted
29930 };
29931 });
29932 }
29933
29934 // packages/dataviews/build-module/dataform/index.mjs
29935 var import_element109 = __toESM(require_element(), 1);
29936
29937 // packages/dataviews/build-module/components/dataform-context/index.mjs
29938 var import_element99 = __toESM(require_element(), 1);
29939 var import_jsx_runtime138 = __toESM(require_jsx_runtime(), 1);
29940 var DataFormContext = (0, import_element99.createContext)({
29941 fields: []
29942 });
29943 DataFormContext.displayName = "DataFormContext";
29944 function DataFormProvider({
29945 fields,
29946 children
29947 }) {
29948 return /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(DataFormContext.Provider, { value: { fields }, children });
29949 }
29950 var dataform_context_default = DataFormContext;
29951
29952 // packages/dataviews/build-module/components/dataform-layouts/data-form-layout.mjs
29953 var import_element108 = __toESM(require_element(), 1);
29954
29955 // packages/dataviews/build-module/components/dataform-layouts/regular/index.mjs
29956 var import_element100 = __toESM(require_element(), 1);
29957 var import_components24 = __toESM(require_components(), 1);
29958
29959 // packages/dataviews/build-module/components/dataform-layouts/can-render-field.mjs
29960 function canRenderField(field) {
29961 return !!field && (field.readOnly === true || !!field.Edit);
29962 }
29963
29964 // packages/dataviews/build-module/components/dataform-layouts/normalize-form.mjs
29965 var import_i18n28 = __toESM(require_i18n(), 1);
29966 var DEFAULT_LAYOUT = {
29967 type: "regular",
29968 labelPosition: "top"
29969 };
29970 var normalizeCardSummaryField = (sum) => {
29971 if (typeof sum === "string") {
29972 return [{ id: sum, visibility: "when-collapsed" }];
29973 }
29974 return sum.map((item) => {
29975 if (typeof item === "string") {
29976 return { id: item, visibility: "when-collapsed" };
29977 }
29978 return { id: item.id, visibility: item.visibility };
29979 });
29980 };
29981 function normalizeLayout(layout) {
29982 let normalizedLayout = DEFAULT_LAYOUT;
29983 if (layout?.type === "regular") {
29984 normalizedLayout = {
29985 type: "regular",
29986 labelPosition: layout?.labelPosition ?? "top"
29987 };
29988 } else if (layout?.type === "panel") {
29989 const summary = layout.summary ?? [];
29990 const normalizedSummary = Array.isArray(summary) ? summary : [summary];
29991 const openAs = layout?.openAs;
29992 let normalizedOpenAs;
29993 if (typeof openAs === "object" && openAs.type === "modal") {
29994 normalizedOpenAs = {
29995 type: "modal",
29996 applyLabel: openAs.applyLabel?.trim() || (0, import_i18n28.__)("Apply"),
29997 cancelLabel: openAs.cancelLabel?.trim() || (0, import_i18n28.__)("Cancel")
29998 };
29999 } else if (openAs === "modal") {
30000 normalizedOpenAs = {
30001 type: "modal",
30002 applyLabel: (0, import_i18n28.__)("Apply"),
30003 cancelLabel: (0, import_i18n28.__)("Cancel")
30004 };
30005 } else {
30006 normalizedOpenAs = { type: "dropdown" };
30007 }
30008 normalizedLayout = {
30009 type: "panel",
30010 labelPosition: layout?.labelPosition ?? "side",
30011 openAs: normalizedOpenAs,
30012 summary: normalizedSummary,
30013 editVisibility: layout?.editVisibility ?? "on-hover",
30014 showPlaceholderIfEmpty: layout?.showPlaceholderIfEmpty ?? false
30015 };
30016 } else if (layout?.type === "card") {
30017 if (layout.withHeader === false) {
30018 normalizedLayout = {
30019 type: "card",
30020 withHeader: false,
30021 isOpened: true,
30022 summary: [],
30023 isCollapsible: false
30024 };
30025 } else {
30026 const summary = layout.summary ?? [];
30027 normalizedLayout = {
30028 type: "card",
30029 withHeader: true,
30030 isOpened: typeof layout.isOpened === "boolean" ? layout.isOpened : true,
30031 summary: normalizeCardSummaryField(summary),
30032 isCollapsible: layout.isCollapsible === void 0 ? true : layout.isCollapsible
30033 };
30034 }
30035 } else if (layout?.type === "row") {
30036 normalizedLayout = {
30037 type: "row",
30038 alignment: layout?.alignment ?? "center",
30039 styles: layout?.styles ?? {}
30040 };
30041 } else if (layout?.type === "details") {
30042 normalizedLayout = {
30043 type: "details",
30044 summary: layout?.summary ?? ""
30045 };
30046 }
30047 return normalizedLayout;
30048 }
30049 function normalizeForm(form) {
30050 const normalizedFormLayout = normalizeLayout(form?.layout);
30051 const normalizedFields = (form.fields ?? []).map(
30052 (field) => {
30053 if (typeof field === "string") {
30054 return {
30055 id: field,
30056 layout: normalizedFormLayout
30057 };
30058 }
30059 const fieldLayout = field.layout ? normalizeLayout(field.layout) : normalizedFormLayout;
30060 return {
30061 id: field.id,
30062 layout: fieldLayout,
30063 ...!!field.label && { label: field.label },
30064 ...!!field.description && {
30065 description: field.description
30066 },
30067 ..."children" in field && Array.isArray(field.children) && {
30068 children: normalizeForm({
30069 fields: field.children,
30070 layout: DEFAULT_LAYOUT
30071 }).fields
30072 }
30073 };
30074 }
30075 );
30076 return {
30077 layout: normalizedFormLayout,
30078 fields: normalizedFields
30079 };
30080 }
30081 var normalize_form_default = normalizeForm;
30082
30083 // packages/dataviews/build-module/components/dataform-layouts/regular/index.mjs
30084 var import_jsx_runtime139 = __toESM(require_jsx_runtime(), 1);
30085 function Header4({ title }) {
30086 return /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
30087 Stack,
30088 {
30089 direction: "column",
30090 className: "dataforms-layouts-regular__header",
30091 gap: "lg",
30092 children: /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(Stack, { direction: "row", align: "center", children: /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(import_components24.__experimentalHeading, { level: 2, size: 13, children: title }) })
30093 }
30094 );
30095 }
30096 function FormRegularField({
30097 data,
30098 field,
30099 onChange,
30100 hideLabelFromVision,
30101 markWhenOptional,
30102 validity
30103 }) {
30104 const { fields } = (0, import_element100.useContext)(dataform_context_default);
30105 const layout = field.layout;
30106 const form = (0, import_element100.useMemo)(
30107 () => ({
30108 layout: DEFAULT_LAYOUT,
30109 fields: !!field.children ? field.children : []
30110 }),
30111 [field]
30112 );
30113 if (!!field.children) {
30114 return /* @__PURE__ */ (0, import_jsx_runtime139.jsxs)(import_jsx_runtime139.Fragment, { children: [
30115 !hideLabelFromVision && field.label && /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(Header4, { title: field.label }),
30116 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
30117 DataFormLayout,
30118 {
30119 data,
30120 form,
30121 onChange,
30122 validity: validity?.children
30123 }
30124 )
30125 ] });
30126 }
30127 const labelPosition = layout.labelPosition;
30128 const fieldDefinition = fields.find(
30129 (fieldDef) => fieldDef.id === field.id
30130 );
30131 if (!canRenderField(fieldDefinition)) {
30132 return null;
30133 }
30134 if (labelPosition === "side") {
30135 return /* @__PURE__ */ (0, import_jsx_runtime139.jsxs)(
30136 Stack,
30137 {
30138 direction: "row",
30139 className: "dataforms-layouts-regular__field",
30140 gap: "sm",
30141 children: [
30142 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
30143 "div",
30144 {
30145 className: clsx_default(
30146 "dataforms-layouts-regular__field-label",
30147 `dataforms-layouts-regular__field-label--label-position-${labelPosition}`
30148 ),
30149 children: /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(import_components24.BaseControl.VisualLabel, { children: fieldDefinition.label })
30150 }
30151 ),
30152 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)("div", { className: "dataforms-layouts-regular__field-control", children: fieldDefinition.readOnly === true ? /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
30153 fieldDefinition.render,
30154 {
30155 item: data,
30156 field: fieldDefinition
30157 }
30158 ) : fieldDefinition.Edit && /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
30159 fieldDefinition.Edit,
30160 {
30161 data,
30162 field: fieldDefinition,
30163 onChange,
30164 hideLabelFromVision: true,
30165 markWhenOptional,
30166 validity
30167 },
30168 fieldDefinition.id
30169 ) })
30170 ]
30171 }
30172 );
30173 }
30174 return /* @__PURE__ */ (0, import_jsx_runtime139.jsx)("div", { className: "dataforms-layouts-regular__field", children: fieldDefinition.readOnly === true ? /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(import_jsx_runtime139.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime139.jsxs)(import_jsx_runtime139.Fragment, { children: [
30175 !hideLabelFromVision && labelPosition !== "none" && /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(import_components24.BaseControl.VisualLabel, { children: fieldDefinition.label }),
30176 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
30177 fieldDefinition.render,
30178 {
30179 item: data,
30180 field: fieldDefinition
30181 }
30182 )
30183 ] }) }) : fieldDefinition.Edit && /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
30184 fieldDefinition.Edit,
30185 {
30186 data,
30187 field: fieldDefinition,
30188 onChange,
30189 hideLabelFromVision: labelPosition === "none" ? true : hideLabelFromVision,
30190 markWhenOptional,
30191 validity
30192 }
30193 ) });
30194 }
30195
30196 // packages/dataviews/build-module/components/dataform-layouts/panel/modal.mjs
30197 var import_deepmerge2 = __toESM(require_cjs(), 1);
30198 var import_components27 = __toESM(require_components(), 1);
30199 var import_element104 = __toESM(require_element(), 1);
30200 var import_compose15 = __toESM(require_compose(), 1);
30201
30202 // packages/dataviews/build-module/components/dataform-layouts/panel/summary-button.mjs
30203 var import_components26 = __toESM(require_components(), 1);
30204 var import_i18n29 = __toESM(require_i18n(), 1);
30205 var import_compose14 = __toESM(require_compose(), 1);
30206
30207 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/get-label-classname.mjs
30208 function getLabelClassName(labelPosition, showError) {
30209 return clsx_default(
30210 "dataforms-layouts-panel__field-label",
30211 `dataforms-layouts-panel__field-label--label-position-${labelPosition}`,
30212 { "has-error": showError }
30213 );
30214 }
30215 var get_label_classname_default = getLabelClassName;
30216
30217 // packages/dataviews/build-module/components/dataform-layouts/panel/field-label-content.mjs
30218 var import_components25 = __toESM(require_components(), 1);
30219 var import_jsx_runtime140 = __toESM(require_jsx_runtime(), 1);
30220 function FieldLabelContent({
30221 showError,
30222 errorMessage,
30223 fieldLabel,
30224 errorId
30225 }) {
30226 if (!showError) {
30227 return /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(import_jsx_runtime140.Fragment, { children: fieldLabel });
30228 }
30229 return /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)("span", { className: "dataforms-layouts-panel__field-label-error-content", children: [
30230 /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(import_components25.Icon, { icon: error_default, size: 16 }),
30231 /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(VisuallyHidden, { id: errorId, children: errorMessage }),
30232 fieldLabel
30233 ] });
30234 }
30235 var field_label_content_default = FieldLabelContent;
30236
30237 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/get-first-validation-error.mjs
30238 function getFirstValidationError(validity) {
30239 if (!validity) {
30240 return void 0;
30241 }
30242 const validityRules = Object.keys(validity).filter(
30243 (key) => key !== "children"
30244 );
30245 for (const key of validityRules) {
30246 const rule = validity[key];
30247 if (rule === void 0) {
30248 continue;
30249 }
30250 if (rule.type === "invalid") {
30251 if (rule.message) {
30252 return rule.message;
30253 }
30254 if (key === "required") {
30255 return "A required field is empty";
30256 }
30257 return "Unidentified validation error";
30258 }
30259 }
30260 if (validity.children) {
30261 for (const childValidity of Object.values(validity.children)) {
30262 const childError = getFirstValidationError(childValidity);
30263 if (childError) {
30264 return childError;
30265 }
30266 }
30267 }
30268 return void 0;
30269 }
30270 var get_first_validation_error_default = getFirstValidationError;
30271
30272 // packages/dataviews/build-module/components/dataform-layouts/panel/summary-button.mjs
30273 var import_jsx_runtime141 = __toESM(require_jsx_runtime(), 1);
30274 function SummaryValue({
30275 item,
30276 field,
30277 showPlaceholderIfEmpty
30278 }) {
30279 if (showPlaceholderIfEmpty && field.placeholder && [void 0, null, ""].includes(field.getValue({ item }))) {
30280 return /* @__PURE__ */ (0, import_jsx_runtime141.jsx)("span", { className: "dataforms-layouts-panel__field-placeholder", children: field.placeholder });
30281 }
30282 return /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(field.render, { item, field });
30283 }
30284 function SummaryButton({
30285 data,
30286 field,
30287 fieldLabel,
30288 summaryFields,
30289 validity,
30290 touched,
30291 disabled: disabled2,
30292 isOpen: isOpen2,
30293 onClick
30294 }) {
30295 const { labelPosition, editVisibility, showPlaceholderIfEmpty } = field.layout;
30296 const errorMessage = get_first_validation_error_default(validity);
30297 const showError = touched && !!errorMessage;
30298 const labelClassName = get_label_classname_default(labelPosition, showError);
30299 const className = clsx_default(
30300 "dataforms-layouts-panel__field-trigger",
30301 `dataforms-layouts-panel__field-trigger--label-${labelPosition}`,
30302 {
30303 "is-disabled": disabled2,
30304 "dataforms-layouts-panel__field-trigger--edit-always": editVisibility === "always"
30305 }
30306 );
30307 const controlId = (0, import_compose14.useInstanceId)(
30308 SummaryButton,
30309 "dataforms-layouts-panel__field-control"
30310 );
30311 const errorId = `${controlId}-error`;
30312 const ariaLabel = showError ? (0, import_i18n29.sprintf)(
30313 // translators: %s: Field name.
30314 (0, import_i18n29._x)("Edit %s (has errors)", "field"),
30315 fieldLabel || ""
30316 ) : (0, import_i18n29.sprintf)(
30317 // translators: %s: Field name.
30318 (0, import_i18n29._x)("Edit %s", "field"),
30319 fieldLabel || ""
30320 );
30321 return /* @__PURE__ */ (0, import_jsx_runtime141.jsxs)("div", { className, children: [
30322 labelPosition !== "none" && /* @__PURE__ */ (0, import_jsx_runtime141.jsx)("span", { className: labelClassName, children: /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(
30323 field_label_content_default,
30324 {
30325 showError,
30326 errorMessage,
30327 fieldLabel,
30328 errorId
30329 }
30330 ) }),
30331 labelPosition === "none" && showError && /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(
30332 field_label_content_default,
30333 {
30334 showError: true,
30335 errorMessage,
30336 errorId
30337 }
30338 ),
30339 /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(
30340 "span",
30341 {
30342 id: `${controlId}`,
30343 className: "dataforms-layouts-panel__field-control",
30344 children: summaryFields.length > 1 ? /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(
30345 "span",
30346 {
30347 style: {
30348 display: "flex",
30349 flexDirection: "column",
30350 alignItems: "flex-start",
30351 width: "100%",
30352 gap: "2px"
30353 },
30354 children: summaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(
30355 "span",
30356 {
30357 style: { width: "100%" },
30358 children: /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(
30359 SummaryValue,
30360 {
30361 item: data,
30362 field: summaryField,
30363 showPlaceholderIfEmpty
30364 }
30365 )
30366 },
30367 summaryField.id
30368 ))
30369 }
30370 ) : summaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(
30371 SummaryValue,
30372 {
30373 item: data,
30374 field: summaryField,
30375 showPlaceholderIfEmpty
30376 },
30377 summaryField.id
30378 ))
30379 }
30380 ),
30381 !disabled2 && /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(
30382 import_components26.Button,
30383 {
30384 className: "dataforms-layouts-panel__field-trigger-icon",
30385 label: ariaLabel,
30386 icon: pencil_default,
30387 size: "small",
30388 "aria-expanded": isOpen2,
30389 "aria-haspopup": "dialog",
30390 "aria-describedby": showError ? `${controlId} ${errorId}` : controlId,
30391 onClick
30392 }
30393 )
30394 ] });
30395 }
30396
30397 // packages/dataviews/build-module/hooks/use-form-validity.mjs
30398 var import_deepmerge = __toESM(require_cjs(), 1);
30399 var import_es6 = __toESM(require_es6(), 1);
30400 var import_element101 = __toESM(require_element(), 1);
30401 var import_i18n30 = __toESM(require_i18n(), 1);
30402 function isFormValid(formValidity) {
30403 if (!formValidity) {
30404 return true;
30405 }
30406 return Object.values(formValidity).every((fieldValidation) => {
30407 return Object.entries(fieldValidation).every(
30408 ([key, validation]) => {
30409 if (key === "children" && validation && typeof validation === "object") {
30410 return isFormValid(validation);
30411 }
30412 return validation.type !== "invalid" && validation.type !== "validating";
30413 }
30414 );
30415 });
30416 }
30417 function getFormFieldsToValidate(form, fields) {
30418 const normalizedForm = normalize_form_default(form);
30419 if (normalizedForm.fields.length === 0) {
30420 return [];
30421 }
30422 const fieldsMap = /* @__PURE__ */ new Map();
30423 fields.forEach((field) => {
30424 fieldsMap.set(field.id, field);
30425 });
30426 function processFormField(formField) {
30427 if ("children" in formField && Array.isArray(formField.children)) {
30428 const processedChildren = formField.children.map(processFormField).filter((child) => child !== null);
30429 if (processedChildren.length === 0) {
30430 return null;
30431 }
30432 return {
30433 id: formField.id,
30434 children: processedChildren
30435 };
30436 }
30437 const fieldDef = fieldsMap.get(formField.id);
30438 if (!fieldDef) {
30439 return null;
30440 }
30441 const [normalizedField] = normalizeFields([fieldDef]);
30442 return {
30443 id: formField.id,
30444 children: [],
30445 field: normalizedField
30446 };
30447 }
30448 const toValidate = normalizedForm.fields.map(processFormField).filter((field) => field !== null);
30449 return toValidate;
30450 }
30451 function setValidityAtPath(formValidity, fieldValidity, path) {
30452 if (!formValidity) {
30453 formValidity = {};
30454 }
30455 if (path.length === 0) {
30456 return formValidity;
30457 }
30458 const result = { ...formValidity };
30459 let current = result;
30460 for (let i = 0; i < path.length - 1; i++) {
30461 const segment = path[i];
30462 if (!current[segment]) {
30463 current[segment] = {};
30464 }
30465 current[segment] = { ...current[segment] };
30466 current = current[segment];
30467 }
30468 const finalKey = path[path.length - 1];
30469 current[finalKey] = {
30470 ...current[finalKey] || {},
30471 ...fieldValidity
30472 };
30473 return result;
30474 }
30475 function removeValidationProperty(formValidity, path, property) {
30476 if (!formValidity || path.length === 0) {
30477 return formValidity;
30478 }
30479 const result = { ...formValidity };
30480 let current = result;
30481 for (let i = 0; i < path.length - 1; i++) {
30482 const segment = path[i];
30483 if (!current[segment]) {
30484 return formValidity;
30485 }
30486 current[segment] = { ...current[segment] };
30487 current = current[segment];
30488 }
30489 const finalKey = path[path.length - 1];
30490 if (!current[finalKey]) {
30491 return formValidity;
30492 }
30493 const fieldValidity = { ...current[finalKey] };
30494 delete fieldValidity[property];
30495 if (Object.keys(fieldValidity).length === 0) {
30496 delete current[finalKey];
30497 } else {
30498 current[finalKey] = fieldValidity;
30499 }
30500 if (Object.keys(result).length === 0) {
30501 return void 0;
30502 }
30503 return result;
30504 }
30505 function handleElementsValidationAsync(promise, formField, promiseHandler) {
30506 const { elementsCounterRef, setFormValidity, path, item } = promiseHandler;
30507 const currentToken = (elementsCounterRef.current[formField.id] || 0) + 1;
30508 elementsCounterRef.current[formField.id] = currentToken;
30509 promise.then((result) => {
30510 if (currentToken !== elementsCounterRef.current[formField.id]) {
30511 return;
30512 }
30513 if (!Array.isArray(result)) {
30514 setFormValidity((prev) => {
30515 const newFormValidity = setValidityAtPath(
30516 prev,
30517 {
30518 elements: {
30519 type: "invalid",
30520 message: (0, import_i18n30.__)("Could not validate elements.")
30521 }
30522 },
30523 [...path, formField.id]
30524 );
30525 return newFormValidity;
30526 });
30527 return;
30528 }
30529 if (formField.field?.isValid.elements && !formField.field.isValid.elements.validate(item, {
30530 ...formField.field,
30531 elements: result
30532 })) {
30533 setFormValidity((prev) => {
30534 const newFormValidity = setValidityAtPath(
30535 prev,
30536 {
30537 elements: {
30538 type: "invalid",
30539 message: (0, import_i18n30.__)(
30540 "Value must be one of the elements."
30541 )
30542 }
30543 },
30544 [...path, formField.id]
30545 );
30546 return newFormValidity;
30547 });
30548 } else {
30549 setFormValidity((prev) => {
30550 return removeValidationProperty(
30551 prev,
30552 [...path, formField.id],
30553 "elements"
30554 );
30555 });
30556 }
30557 }).catch((error2) => {
30558 if (currentToken !== elementsCounterRef.current[formField.id]) {
30559 return;
30560 }
30561 let errorMessage;
30562 if (error2 instanceof Error) {
30563 errorMessage = error2.message;
30564 } else {
30565 errorMessage = String(error2) || (0, import_i18n30.__)(
30566 "Unknown error when running elements validation asynchronously."
30567 );
30568 }
30569 setFormValidity((prev) => {
30570 const newFormValidity = setValidityAtPath(
30571 prev,
30572 {
30573 elements: {
30574 type: "invalid",
30575 message: errorMessage
30576 }
30577 },
30578 [...path, formField.id]
30579 );
30580 return newFormValidity;
30581 });
30582 });
30583 }
30584 function handleCustomValidationAsync(promise, formField, promiseHandler) {
30585 const { customCounterRef, setFormValidity, path } = promiseHandler;
30586 const currentToken = (customCounterRef.current[formField.id] || 0) + 1;
30587 customCounterRef.current[formField.id] = currentToken;
30588 promise.then((result) => {
30589 if (currentToken !== customCounterRef.current[formField.id]) {
30590 return;
30591 }
30592 if (result === null) {
30593 setFormValidity((prev) => {
30594 return removeValidationProperty(
30595 prev,
30596 [...path, formField.id],
30597 "custom"
30598 );
30599 });
30600 return;
30601 }
30602 if (typeof result === "string") {
30603 setFormValidity((prev) => {
30604 const newFormValidity = setValidityAtPath(
30605 prev,
30606 {
30607 custom: {
30608 type: "invalid",
30609 message: result
30610 }
30611 },
30612 [...path, formField.id]
30613 );
30614 return newFormValidity;
30615 });
30616 return;
30617 }
30618 setFormValidity((prev) => {
30619 const newFormValidity = setValidityAtPath(
30620 prev,
30621 {
30622 custom: {
30623 type: "invalid",
30624 message: (0, import_i18n30.__)("Validation could not be processed.")
30625 }
30626 },
30627 [...path, formField.id]
30628 );
30629 return newFormValidity;
30630 });
30631 }).catch((error2) => {
30632 if (currentToken !== customCounterRef.current[formField.id]) {
30633 return;
30634 }
30635 let errorMessage;
30636 if (error2 instanceof Error) {
30637 errorMessage = error2.message;
30638 } else {
30639 errorMessage = String(error2) || (0, import_i18n30.__)(
30640 "Unknown error when running custom validation asynchronously."
30641 );
30642 }
30643 setFormValidity((prev) => {
30644 const newFormValidity = setValidityAtPath(
30645 prev,
30646 {
30647 custom: {
30648 type: "invalid",
30649 message: errorMessage
30650 }
30651 },
30652 [...path, formField.id]
30653 );
30654 return newFormValidity;
30655 });
30656 });
30657 }
30658 function isFormFieldHidden(formField, item) {
30659 return formField.children.length === 0 && !!formField.field?.isVisible && !formField.field.isVisible(item);
30660 }
30661 function validateFormField(item, formField, promiseHandler) {
30662 if (isFormFieldHidden(formField, item)) {
30663 const { customCounterRef, elementsCounterRef } = promiseHandler;
30664 if (customCounterRef.current[formField.id]) {
30665 customCounterRef.current[formField.id] += 1;
30666 }
30667 if (elementsCounterRef.current[formField.id]) {
30668 elementsCounterRef.current[formField.id] += 1;
30669 }
30670 return void 0;
30671 }
30672 if (formField.field?.isValid.required && !formField.field.isValid.required.validate(item, formField.field)) {
30673 return {
30674 required: { type: "invalid" }
30675 };
30676 }
30677 if (formField.field?.isValid.pattern && !formField.field.isValid.pattern.validate(item, formField.field)) {
30678 return {
30679 pattern: {
30680 type: "invalid",
30681 message: (0, import_i18n30.__)("Value does not match the required pattern.")
30682 }
30683 };
30684 }
30685 if (formField.field?.isValid.min && !formField.field.isValid.min.validate(item, formField.field)) {
30686 return {
30687 min: {
30688 type: "invalid",
30689 message: (0, import_i18n30.__)("Value is below the minimum.")
30690 }
30691 };
30692 }
30693 if (formField.field?.isValid.max && !formField.field.isValid.max.validate(item, formField.field)) {
30694 return {
30695 max: {
30696 type: "invalid",
30697 message: (0, import_i18n30.__)("Value is above the maximum.")
30698 }
30699 };
30700 }
30701 if (formField.field?.isValid.minLength && !formField.field.isValid.minLength.validate(item, formField.field)) {
30702 return {
30703 minLength: {
30704 type: "invalid",
30705 message: (0, import_i18n30.__)("Value is too short.")
30706 }
30707 };
30708 }
30709 if (formField.field?.isValid.maxLength && !formField.field.isValid.maxLength.validate(item, formField.field)) {
30710 return {
30711 maxLength: {
30712 type: "invalid",
30713 message: (0, import_i18n30.__)("Value is too long.")
30714 }
30715 };
30716 }
30717 if (formField.field?.isValid.elements && formField.field.hasElements && !formField.field.getElements && Array.isArray(formField.field.elements) && !formField.field.isValid.elements.validate(item, formField.field)) {
30718 return {
30719 elements: {
30720 type: "invalid",
30721 message: (0, import_i18n30.__)("Value must be one of the elements.")
30722 }
30723 };
30724 }
30725 let customError;
30726 if (!!formField.field && formField.field.isValid.custom) {
30727 try {
30728 const value = formField.field.getValue({ item });
30729 customError = formField.field.isValid.custom(
30730 (0, import_deepmerge.default)(
30731 item,
30732 formField.field.setValue({
30733 item,
30734 value
30735 })
30736 ),
30737 formField.field
30738 );
30739 } catch (error2) {
30740 let errorMessage;
30741 if (error2 instanceof Error) {
30742 errorMessage = error2.message;
30743 } else {
30744 errorMessage = String(error2) || (0, import_i18n30.__)("Unknown error when running custom validation.");
30745 }
30746 return {
30747 custom: {
30748 type: "invalid",
30749 message: errorMessage
30750 }
30751 };
30752 }
30753 }
30754 if (typeof customError === "string") {
30755 return {
30756 custom: {
30757 type: "invalid",
30758 message: customError
30759 }
30760 };
30761 }
30762 const fieldValidity = {};
30763 if (!!formField.field && formField.field.isValid.elements && formField.field.hasElements && typeof formField.field.getElements === "function") {
30764 handleElementsValidationAsync(
30765 formField.field.getElements(),
30766 formField,
30767 promiseHandler
30768 );
30769 fieldValidity.elements = {
30770 type: "validating",
30771 message: (0, import_i18n30.__)("Validating\u2026")
30772 };
30773 }
30774 if (customError instanceof Promise) {
30775 handleCustomValidationAsync(customError, formField, promiseHandler);
30776 fieldValidity.custom = {
30777 type: "validating",
30778 message: (0, import_i18n30.__)("Validating\u2026")
30779 };
30780 }
30781 if (Object.keys(fieldValidity).length > 0) {
30782 return fieldValidity;
30783 }
30784 if (formField.children.length > 0) {
30785 const result = {};
30786 formField.children.forEach((child) => {
30787 result[child.id] = validateFormField(item, child, {
30788 ...promiseHandler,
30789 path: [...promiseHandler.path, formField.id, "children"]
30790 });
30791 });
30792 const filteredResult = {};
30793 Object.entries(result).forEach(([key, value]) => {
30794 if (value !== void 0) {
30795 filteredResult[key] = value;
30796 }
30797 });
30798 if (Object.keys(filteredResult).length === 0) {
30799 return void 0;
30800 }
30801 return {
30802 children: filteredResult
30803 };
30804 }
30805 return void 0;
30806 }
30807 function getFormFieldValue(formField, item) {
30808 const fieldValue = formField?.field?.getValue({ item });
30809 const isHidden = isFormFieldHidden(formField, item);
30810 if (formField.children.length === 0) {
30811 return { value: fieldValue, isHidden };
30812 }
30813 const childrenValues = formField.children.map(
30814 (child) => getFormFieldValue(child, item)
30815 );
30816 return {
30817 value: fieldValue,
30818 isHidden,
30819 children: childrenValues
30820 };
30821 }
30822 function useFormValidity(item, fields, form) {
30823 const [formValidity, setFormValidity] = (0, import_element101.useState)();
30824 const customCounterRef = (0, import_element101.useRef)({});
30825 const elementsCounterRef = (0, import_element101.useRef)({});
30826 const previousValuesRef = (0, import_element101.useRef)({});
30827 const validate = (0, import_element101.useCallback)(() => {
30828 const promiseHandler = {
30829 customCounterRef,
30830 elementsCounterRef,
30831 setFormValidity,
30832 path: [],
30833 item
30834 };
30835 const formFieldsToValidate = getFormFieldsToValidate(form, fields);
30836 if (formFieldsToValidate.length === 0) {
30837 setFormValidity(void 0);
30838 return;
30839 }
30840 const newFormValidity = {};
30841 const untouchedFields = [];
30842 formFieldsToValidate.forEach((formField) => {
30843 const value = getFormFieldValue(formField, item);
30844 if (previousValuesRef.current.hasOwnProperty(formField.id) && (0, import_es6.default)(
30845 previousValuesRef.current[formField.id],
30846 value
30847 )) {
30848 untouchedFields.push(formField.id);
30849 return;
30850 }
30851 previousValuesRef.current[formField.id] = value;
30852 const fieldValidity = validateFormField(
30853 item,
30854 formField,
30855 promiseHandler
30856 );
30857 if (fieldValidity !== void 0) {
30858 newFormValidity[formField.id] = fieldValidity;
30859 }
30860 });
30861 setFormValidity((existingFormValidity) => {
30862 let validity = {
30863 ...existingFormValidity,
30864 ...newFormValidity
30865 };
30866 const fieldsToKeep = [
30867 ...untouchedFields,
30868 ...Object.keys(newFormValidity)
30869 ];
30870 Object.keys(validity).forEach((key) => {
30871 if (validity && !fieldsToKeep.includes(key)) {
30872 delete validity[key];
30873 }
30874 });
30875 if (Object.keys(validity).length === 0) {
30876 validity = void 0;
30877 }
30878 const areEqual = (0, import_es6.default)(existingFormValidity, validity);
30879 if (areEqual) {
30880 return existingFormValidity;
30881 }
30882 return validity;
30883 });
30884 }, [item, fields, form]);
30885 (0, import_element101.useEffect)(() => {
30886 validate();
30887 }, [validate]);
30888 return {
30889 validity: formValidity,
30890 isValid: isFormValid(formValidity)
30891 };
30892 }
30893 var use_form_validity_default = useFormValidity;
30894
30895 // packages/dataviews/build-module/hooks/use-reveal-validity.mjs
30896 var import_element102 = __toESM(require_element(), 1);
30897 function useRevealValidity(ref, shouldReveal) {
30898 const revealValidity = (0, import_element102.useCallback)(() => {
30899 const inputs = ref.current?.querySelectorAll("input, textarea, select");
30900 let revealedCount = 0;
30901 inputs?.forEach((input) => {
30902 if (input.willValidate && !input.validity.valid) {
30903 revealedCount++;
30904 input.dispatchEvent(
30905 new Event("invalid", { cancelable: true })
30906 );
30907 }
30908 });
30909 return revealedCount;
30910 }, [ref]);
30911 (0, import_element102.useEffect)(() => {
30912 if (shouldReveal) {
30913 revealValidity();
30914 }
30915 }, [shouldReveal, revealValidity]);
30916 return revealValidity;
30917 }
30918
30919 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/use-field-from-form-field.mjs
30920 var import_element103 = __toESM(require_element(), 1);
30921
30922 // packages/dataviews/build-module/components/dataform-layouts/get-summary-fields.mjs
30923 function extractSummaryIds(summary) {
30924 if (Array.isArray(summary)) {
30925 return summary.map(
30926 (item) => typeof item === "string" ? item : item.id
30927 );
30928 }
30929 return [];
30930 }
30931 var getSummaryFields = (summaryField, fields) => {
30932 if (Array.isArray(summaryField) && summaryField.length > 0) {
30933 const summaryIds = extractSummaryIds(summaryField);
30934 return summaryIds.map(
30935 (summaryId) => fields.find((_field) => _field.id === summaryId)
30936 ).filter((_field) => _field !== void 0);
30937 }
30938 return [];
30939 };
30940
30941 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/use-field-from-form-field.mjs
30942 var getFieldDefinition = (field, fields) => {
30943 if (!!field.children) {
30944 const simpleChildren = field.children.filter(
30945 (child) => !child.children
30946 );
30947 if (simpleChildren.length === 0) {
30948 return void 0;
30949 }
30950 return fields.find(
30951 (_field) => _field.id === simpleChildren[0].id
30952 );
30953 }
30954 return fields.find((_field) => _field.id === field.id);
30955 };
30956 function useFieldFromFormField(field) {
30957 const { fields } = (0, import_element103.useContext)(dataform_context_default);
30958 const layout = field.layout;
30959 const summaryFields = getSummaryFields(layout.summary, fields);
30960 const fieldDefinition = getFieldDefinition(field, fields);
30961 const fieldLabel = !!field.children ? field.label : fieldDefinition?.label;
30962 if (summaryFields.length === 0) {
30963 return {
30964 summaryFields: fieldDefinition ? [fieldDefinition] : [],
30965 fieldDefinition,
30966 fieldLabel
30967 };
30968 }
30969 return {
30970 summaryFields,
30971 fieldDefinition,
30972 fieldLabel
30973 };
30974 }
30975 var use_field_from_form_field_default = useFieldFromFormField;
30976
30977 // packages/dataviews/build-module/components/dataform-layouts/panel/modal.mjs
30978 var import_jsx_runtime142 = __toESM(require_jsx_runtime(), 1);
30979 function ModalContent({
30980 data,
30981 field,
30982 onChange,
30983 fieldLabel,
30984 onClose,
30985 touched
30986 }) {
30987 const { openAs } = field.layout;
30988 const { applyLabel, cancelLabel } = openAs;
30989 const { fields } = (0, import_element104.useContext)(dataform_context_default);
30990 const [changes, setChanges] = (0, import_element104.useState)({});
30991 const modalData = (0, import_element104.useMemo)(() => {
30992 return (0, import_deepmerge2.default)(data, changes, {
30993 arrayMerge: (target, source) => source
30994 });
30995 }, [data, changes]);
30996 const form = (0, import_element104.useMemo)(
30997 () => ({
30998 layout: DEFAULT_LAYOUT,
30999 fields: !!field.children ? field.children : (
31000 // If not explicit children return the field id itself.
31001 [{ id: field.id, layout: DEFAULT_LAYOUT }]
31002 )
31003 }),
31004 [field]
31005 );
31006 const fieldsAsFieldType = fields.map((f) => ({
31007 ...f,
31008 Edit: f.Edit === null ? void 0 : f.Edit,
31009 isValid: {
31010 required: f.isValid.required?.constraint,
31011 elements: f.isValid.elements?.constraint,
31012 min: f.isValid.min?.constraint,
31013 max: f.isValid.max?.constraint,
31014 pattern: f.isValid.pattern?.constraint,
31015 minLength: f.isValid.minLength?.constraint,
31016 maxLength: f.isValid.maxLength?.constraint
31017 }
31018 }));
31019 const { validity } = use_form_validity_default(modalData, fieldsAsFieldType, form);
31020 const onApply = () => {
31021 onChange(changes);
31022 onClose();
31023 };
31024 const handleOnChange = (newValue) => {
31025 setChanges(
31026 (prev) => (0, import_deepmerge2.default)(prev, newValue, {
31027 arrayMerge: (target, source) => source
31028 })
31029 );
31030 };
31031 const focusOnMountRef = (0, import_compose15.useFocusOnMount)("firstInputElement");
31032 const contentRef = (0, import_element104.useRef)(null);
31033 const mergedRef = (0, import_compose15.useMergeRefs)([focusOnMountRef, contentRef]);
31034 useRevealValidity(contentRef, touched);
31035 return /* @__PURE__ */ (0, import_jsx_runtime142.jsxs)(
31036 import_components27.Modal,
31037 {
31038 className: "dataforms-layouts-panel__modal",
31039 onRequestClose: onClose,
31040 isFullScreen: false,
31041 title: fieldLabel,
31042 size: "medium",
31043 children: [
31044 /* @__PURE__ */ (0, import_jsx_runtime142.jsx)("div", { ref: mergedRef, children: /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
31045 DataFormLayout,
31046 {
31047 data: modalData,
31048 form,
31049 onChange: handleOnChange,
31050 validity,
31051 children: (FieldLayout, childField, childFieldValidity, markWhenOptional) => /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
31052 FieldLayout,
31053 {
31054 data: modalData,
31055 field: childField,
31056 onChange: handleOnChange,
31057 hideLabelFromVision: form.fields.length < 2,
31058 markWhenOptional,
31059 validity: childFieldValidity
31060 },
31061 childField.id
31062 )
31063 }
31064 ) }),
31065 /* @__PURE__ */ (0, import_jsx_runtime142.jsxs)(
31066 Stack,
31067 {
31068 direction: "row",
31069 className: "dataforms-layouts-panel__modal-footer",
31070 gap: "md",
31071 children: [
31072 /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(import_components27.__experimentalSpacer, { style: { flex: 1 } }),
31073 /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
31074 import_components27.Button,
31075 {
31076 variant: "tertiary",
31077 onClick: onClose,
31078 __next40pxDefaultSize: true,
31079 children: cancelLabel
31080 }
31081 ),
31082 /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
31083 import_components27.Button,
31084 {
31085 variant: "primary",
31086 onClick: onApply,
31087 __next40pxDefaultSize: true,
31088 children: applyLabel
31089 }
31090 )
31091 ]
31092 }
31093 )
31094 ]
31095 }
31096 );
31097 }
31098 function PanelModal({
31099 data,
31100 field,
31101 onChange,
31102 validity
31103 }) {
31104 const [touched, setTouched] = (0, import_element104.useState)(false);
31105 const [isOpen2, setIsOpen] = (0, import_element104.useState)(false);
31106 const { fieldDefinition, fieldLabel, summaryFields } = use_field_from_form_field_default(field);
31107 if (!fieldDefinition) {
31108 return null;
31109 }
31110 const isDisabled = fieldDefinition.readOnly === true || fieldDefinition.isDisabled({ item: data, field: fieldDefinition });
31111 const handleClose = () => {
31112 setIsOpen(false);
31113 setTouched(true);
31114 };
31115 return /* @__PURE__ */ (0, import_jsx_runtime142.jsxs)(import_jsx_runtime142.Fragment, { children: [
31116 /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
31117 SummaryButton,
31118 {
31119 data,
31120 field,
31121 fieldLabel,
31122 summaryFields,
31123 validity,
31124 touched,
31125 disabled: isDisabled,
31126 onClick: () => setIsOpen(true),
31127 isOpen: isOpen2
31128 }
31129 ),
31130 isOpen2 && /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
31131 ModalContent,
31132 {
31133 data,
31134 field,
31135 onChange,
31136 fieldLabel: fieldLabel ?? "",
31137 onClose: handleClose,
31138 touched
31139 }
31140 )
31141 ] });
31142 }
31143 var modal_default = PanelModal;
31144
31145 // packages/dataviews/build-module/components/dataform-layouts/panel/dropdown.mjs
31146 var import_components28 = __toESM(require_components(), 1);
31147 var import_i18n31 = __toESM(require_i18n(), 1);
31148 var import_element105 = __toESM(require_element(), 1);
31149 var import_compose16 = __toESM(require_compose(), 1);
31150 var import_jsx_runtime143 = __toESM(require_jsx_runtime(), 1);
31151 function DropdownHeader({
31152 title,
31153 onClose
31154 }) {
31155 return /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(
31156 Stack,
31157 {
31158 direction: "column",
31159 className: "dataforms-layouts-panel__dropdown-header",
31160 gap: "lg",
31161 children: /* @__PURE__ */ (0, import_jsx_runtime143.jsxs)(Stack, { direction: "row", gap: "sm", align: "center", children: [
31162 title && /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(import_components28.__experimentalHeading, { level: 2, size: 13, children: title }),
31163 /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(import_components28.__experimentalSpacer, { style: { flex: 1 } }),
31164 onClose && /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(
31165 import_components28.Button,
31166 {
31167 label: (0, import_i18n31.__)("Close"),
31168 icon: close_small_default,
31169 onClick: onClose,
31170 size: "small"
31171 }
31172 )
31173 ] })
31174 }
31175 );
31176 }
31177 function DropdownContentWithValidation({
31178 touched,
31179 children
31180 }) {
31181 const ref = (0, import_element105.useRef)(null);
31182 useRevealValidity(ref, touched);
31183 return /* @__PURE__ */ (0, import_jsx_runtime143.jsx)("div", { ref, children });
31184 }
31185 function PanelDropdown({
31186 data,
31187 field,
31188 onChange,
31189 validity
31190 }) {
31191 const [touched, setTouched] = (0, import_element105.useState)(false);
31192 const [popoverAnchor, setPopoverAnchor] = (0, import_element105.useState)(
31193 null
31194 );
31195 const popoverProps = (0, import_element105.useMemo)(
31196 () => ({
31197 // Anchor the popover to the middle of the entire row so that it doesn't
31198 // move around when the label changes.
31199 anchor: popoverAnchor,
31200 placement: "left-start",
31201 offset: 36,
31202 shift: true
31203 }),
31204 [popoverAnchor]
31205 );
31206 const [dialogRef, dialogProps] = (0, import_compose16.__experimentalUseDialog)({
31207 focusOnMount: "firstInputElement"
31208 });
31209 const form = (0, import_element105.useMemo)(
31210 () => ({
31211 layout: DEFAULT_LAYOUT,
31212 fields: !!field.children ? field.children : (
31213 // If not explicit children return the field id itself.
31214 [{ id: field.id, layout: DEFAULT_LAYOUT }]
31215 )
31216 }),
31217 [field]
31218 );
31219 const formValidity = (0, import_element105.useMemo)(() => {
31220 if (validity === void 0) {
31221 return void 0;
31222 }
31223 if (!!field.children) {
31224 return validity?.children;
31225 }
31226 return { [field.id]: validity };
31227 }, [validity, field]);
31228 const { fieldDefinition, fieldLabel, summaryFields } = use_field_from_form_field_default(field);
31229 if (!fieldDefinition) {
31230 return null;
31231 }
31232 const isDisabled = fieldDefinition.readOnly === true || fieldDefinition.isDisabled({ item: data, field: fieldDefinition });
31233 return /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(
31234 "div",
31235 {
31236 ref: setPopoverAnchor,
31237 className: "dataforms-layouts-panel__field-dropdown-anchor",
31238 children: /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(
31239 import_components28.Dropdown,
31240 {
31241 contentClassName: "dataforms-layouts-panel__field-dropdown",
31242 popoverProps,
31243 focusOnMount: false,
31244 onToggle: (willOpen) => {
31245 if (!willOpen) {
31246 setTouched(true);
31247 }
31248 },
31249 renderToggle: ({ isOpen: isOpen2, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(
31250 SummaryButton,
31251 {
31252 data,
31253 field,
31254 fieldLabel,
31255 summaryFields,
31256 validity,
31257 touched,
31258 disabled: isDisabled,
31259 isOpen: isOpen2,
31260 onClick: onToggle
31261 }
31262 ),
31263 renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(DropdownContentWithValidation, { touched, children: /* @__PURE__ */ (0, import_jsx_runtime143.jsxs)("div", { ref: dialogRef, ...dialogProps, children: [
31264 /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(
31265 DropdownHeader,
31266 {
31267 title: fieldLabel,
31268 onClose
31269 }
31270 ),
31271 /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(
31272 DataFormLayout,
31273 {
31274 data,
31275 form,
31276 onChange,
31277 validity: formValidity,
31278 children: (FieldLayout, childField, childFieldValidity, markWhenOptional) => /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(
31279 FieldLayout,
31280 {
31281 data,
31282 field: childField,
31283 onChange,
31284 hideLabelFromVision: (form?.fields ?? []).length < 2,
31285 markWhenOptional,
31286 validity: childFieldValidity
31287 },
31288 childField.id
31289 )
31290 }
31291 )
31292 ] }) })
31293 }
31294 )
31295 }
31296 );
31297 }
31298 var dropdown_default = PanelDropdown;
31299
31300 // packages/dataviews/build-module/components/dataform-layouts/panel/index.mjs
31301 var import_jsx_runtime144 = __toESM(require_jsx_runtime(), 1);
31302 function FormPanelField({
31303 data,
31304 field,
31305 onChange,
31306 validity
31307 }) {
31308 const layout = field.layout;
31309 if (layout.openAs.type === "modal") {
31310 return /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(
31311 modal_default,
31312 {
31313 data,
31314 field,
31315 onChange,
31316 validity
31317 }
31318 );
31319 }
31320 return /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(
31321 dropdown_default,
31322 {
31323 data,
31324 field,
31325 onChange,
31326 validity
31327 }
31328 );
31329 }
31330
31331 // packages/dataviews/build-module/components/dataform-layouts/card/index.mjs
31332 var import_element106 = __toESM(require_element(), 1);
31333 var import_compose17 = __toESM(require_compose(), 1);
31334 import { speak as speak4 } from "@wordpress/a11y";
31335
31336 // packages/dataviews/build-module/components/dataform-layouts/get-validation-message.mjs
31337 var import_i18n32 = __toESM(require_i18n(), 1);
31338 function countInvalidFields(validity) {
31339 if (!validity) {
31340 return 0;
31341 }
31342 let count = 0;
31343 const validityRules = Object.keys(validity).filter(
31344 (key) => key !== "children"
31345 );
31346 for (const key of validityRules) {
31347 const rule = validity[key];
31348 if (rule?.type === "invalid") {
31349 count++;
31350 }
31351 }
31352 if (validity.children) {
31353 for (const childValidity of Object.values(validity.children)) {
31354 count += countInvalidFields(childValidity);
31355 }
31356 }
31357 return count;
31358 }
31359 function getValidationMessage(validity) {
31360 const invalidCount = countInvalidFields(validity);
31361 if (invalidCount === 0) {
31362 return void 0;
31363 }
31364 return (0, import_i18n32.sprintf)(
31365 /* translators: %d: Number of fields that need attention */
31366 (0, import_i18n32._n)(
31367 "%d field needs attention",
31368 "%d fields need attention",
31369 invalidCount
31370 ),
31371 invalidCount
31372 );
31373 }
31374
31375 // packages/dataviews/build-module/components/dataform-layouts/validation-badge.mjs
31376 var import_jsx_runtime145 = __toESM(require_jsx_runtime(), 1);
31377 function ValidationBadge({
31378 validity
31379 }) {
31380 const message2 = getValidationMessage(validity);
31381 if (!message2) {
31382 return null;
31383 }
31384 return /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(Badge, { intent: "high", children: message2 });
31385 }
31386
31387 // packages/dataviews/build-module/components/dataform-layouts/card/index.mjs
31388 var import_jsx_runtime146 = __toESM(require_jsx_runtime(), 1);
31389 function isSummaryFieldVisible(summaryField, summaryConfig, isOpen2) {
31390 if (!summaryConfig || Array.isArray(summaryConfig) && summaryConfig.length === 0) {
31391 return false;
31392 }
31393 const summaryConfigArray = Array.isArray(summaryConfig) ? summaryConfig : [summaryConfig];
31394 const fieldConfig = summaryConfigArray.find((config) => {
31395 if (typeof config === "string") {
31396 return config === summaryField.id;
31397 }
31398 if (typeof config === "object" && "id" in config) {
31399 return config.id === summaryField.id;
31400 }
31401 return false;
31402 });
31403 if (!fieldConfig) {
31404 return false;
31405 }
31406 if (typeof fieldConfig === "string") {
31407 return true;
31408 }
31409 if (typeof fieldConfig === "object" && "visibility" in fieldConfig) {
31410 return fieldConfig.visibility === "always" || fieldConfig.visibility === "when-collapsed" && !isOpen2;
31411 }
31412 return true;
31413 }
31414 function HeaderContent({
31415 data,
31416 fields,
31417 label,
31418 layout,
31419 isOpen: isOpen2,
31420 touched,
31421 validity
31422 }) {
31423 const summaryFields = getSummaryFields(layout.summary, fields);
31424 const visibleSummaryFields = summaryFields.filter(
31425 (summaryField) => isSummaryFieldVisible(summaryField, layout.summary, isOpen2)
31426 );
31427 const hasBadge = touched && layout.isCollapsible;
31428 const hasSummary = visibleSummaryFields.length > 0 && layout.withHeader;
31429 return /* @__PURE__ */ (0, import_jsx_runtime146.jsxs)(
31430 Stack,
31431 {
31432 align: "center",
31433 justify: "space-between",
31434 className: "dataforms-layouts-card__field-header-content",
31435 children: [
31436 /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(card_exports.Title, { children: label }),
31437 (hasBadge || hasSummary) && /* @__PURE__ */ (0, import_jsx_runtime146.jsxs)(collapsible_card_exports.HeaderDescription, { className: "dataforms-layouts-card__field-header-content-description", children: [
31438 hasBadge && /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(ValidationBadge, { validity }),
31439 hasSummary && /* @__PURE__ */ (0, import_jsx_runtime146.jsx)("div", { className: "dataforms-layouts-card__field-summary", children: visibleSummaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(
31440 summaryField.render,
31441 {
31442 item: data,
31443 field: summaryField
31444 },
31445 summaryField.id
31446 )) })
31447 ] })
31448 ]
31449 }
31450 );
31451 }
31452 function BodyContent({
31453 data,
31454 field,
31455 form,
31456 onChange,
31457 hideLabelFromVision,
31458 markWhenOptional,
31459 validity,
31460 withHeader
31461 }) {
31462 if (field.children) {
31463 return /* @__PURE__ */ (0, import_jsx_runtime146.jsxs)(import_jsx_runtime146.Fragment, { children: [
31464 field.description && /* @__PURE__ */ (0, import_jsx_runtime146.jsx)("div", { className: "dataforms-layouts-card__field-description", children: field.description }),
31465 /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(
31466 DataFormLayout,
31467 {
31468 data,
31469 form,
31470 onChange,
31471 validity: validity?.children
31472 }
31473 )
31474 ] });
31475 }
31476 const SingleFieldLayout = getFormFieldLayout("regular")?.component;
31477 if (!SingleFieldLayout) {
31478 return null;
31479 }
31480 return /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(
31481 SingleFieldLayout,
31482 {
31483 data,
31484 field,
31485 onChange,
31486 hideLabelFromVision: hideLabelFromVision || withHeader,
31487 markWhenOptional,
31488 validity
31489 }
31490 );
31491 }
31492 function FormCardField({
31493 data,
31494 field,
31495 onChange,
31496 hideLabelFromVision,
31497 markWhenOptional,
31498 validity
31499 }) {
31500 const { fields } = (0, import_element106.useContext)(dataform_context_default);
31501 const layout = field.layout;
31502 const contentRef = (0, import_element106.useRef)(null);
31503 const hasFocusedContentRef = (0, import_element106.useRef)(false);
31504 const form = (0, import_element106.useMemo)(
31505 () => ({
31506 layout: DEFAULT_LAYOUT,
31507 fields: field.children ?? []
31508 }),
31509 [field]
31510 );
31511 const { isOpened, isCollapsible } = layout;
31512 const [isOpen2, setIsOpen] = (0, import_element106.useState)(isOpened);
31513 const [touched, setTouched] = (0, import_element106.useState)(false);
31514 (0, import_element106.useEffect)(() => {
31515 setIsOpen(isOpened);
31516 }, [isOpened]);
31517 const handleOpenChange = (0, import_element106.useCallback)((open3) => {
31518 if (!open3) {
31519 setTouched(true);
31520 }
31521 setIsOpen(open3);
31522 }, []);
31523 const revealValidity = useRevealValidity(
31524 contentRef,
31525 (isCollapsible ? isOpen2 : true) && touched
31526 );
31527 const handleContentFocus = (0, import_element106.useCallback)(() => {
31528 hasFocusedContentRef.current = true;
31529 }, []);
31530 const handleFocusOutside = (0, import_element106.useCallback)(() => {
31531 if (!hasFocusedContentRef.current) {
31532 return;
31533 }
31534 setTouched(true);
31535 if (isCollapsible && !isOpen2) {
31536 return;
31537 }
31538 const revealedCount = revealValidity();
31539 const message2 = getValidationMessage(validity);
31540 if (revealedCount > 0 && message2) {
31541 speak4(message2, "polite");
31542 }
31543 }, [isCollapsible, isOpen2, revealValidity, validity]);
31544 const focusOutsideProps = (0, import_compose17.__experimentalUseFocusOutside)(handleFocusOutside);
31545 let label = field.label;
31546 let withHeader;
31547 if (field.children) {
31548 withHeader = !!label && layout.withHeader;
31549 } else {
31550 const fieldDefinition = fields.find(
31551 (fieldDef) => fieldDef.id === field.id
31552 );
31553 if (!canRenderField(fieldDefinition)) {
31554 return null;
31555 }
31556 label = fieldDefinition.label;
31557 withHeader = !!label && layout.withHeader;
31558 }
31559 const bodyContent = /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(
31560 BodyContent,
31561 {
31562 data,
31563 field,
31564 form,
31565 onChange,
31566 hideLabelFromVision,
31567 markWhenOptional,
31568 validity,
31569 withHeader
31570 }
31571 );
31572 const headerContent = /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(
31573 HeaderContent,
31574 {
31575 data,
31576 fields,
31577 label,
31578 layout,
31579 isOpen: isCollapsible ? !!isOpen2 : true,
31580 touched,
31581 validity
31582 }
31583 );
31584 if (withHeader && isCollapsible) {
31585 return /* @__PURE__ */ (0, import_jsx_runtime146.jsxs)(
31586 collapsible_card_exports.Root,
31587 {
31588 className: "dataforms-layouts-card__field",
31589 open: isOpen2,
31590 onOpenChange: handleOpenChange,
31591 ...focusOutsideProps,
31592 children: [
31593 /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(collapsible_card_exports.Header, { children: headerContent }),
31594 /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(
31595 collapsible_card_exports.Content,
31596 {
31597 ref: contentRef,
31598 onFocus: handleContentFocus,
31599 children: bodyContent
31600 }
31601 )
31602 ]
31603 }
31604 );
31605 }
31606 return /* @__PURE__ */ (0, import_jsx_runtime146.jsxs)(
31607 card_exports.Root,
31608 {
31609 className: "dataforms-layouts-card__field",
31610 ...focusOutsideProps,
31611 children: [
31612 withHeader && /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(card_exports.Header, { children: headerContent }),
31613 /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(card_exports.Content, { ref: contentRef, onFocus: handleContentFocus, children: bodyContent })
31614 ]
31615 }
31616 );
31617 }
31618
31619 // packages/dataviews/build-module/components/dataform-layouts/row/index.mjs
31620 var import_components29 = __toESM(require_components(), 1);
31621 var import_jsx_runtime147 = __toESM(require_jsx_runtime(), 1);
31622 function Header5({ title }) {
31623 return /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(
31624 Stack,
31625 {
31626 direction: "column",
31627 className: "dataforms-layouts-row__header",
31628 gap: "lg",
31629 children: /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(Stack, { direction: "row", align: "center", children: /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(import_components29.__experimentalHeading, { level: 2, size: 13, children: title }) })
31630 }
31631 );
31632 }
31633 var EMPTY_WRAPPER = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(import_jsx_runtime147.Fragment, { children });
31634 function FormRowField({
31635 data,
31636 field,
31637 onChange,
31638 hideLabelFromVision,
31639 markWhenOptional,
31640 validity
31641 }) {
31642 const layout = field.layout;
31643 if (!!field.children) {
31644 const form = {
31645 layout: DEFAULT_LAYOUT,
31646 fields: field.children
31647 };
31648 return /* @__PURE__ */ (0, import_jsx_runtime147.jsxs)("div", { className: "dataforms-layouts-row__field", children: [
31649 !hideLabelFromVision && field.label && /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(Header5, { title: field.label }),
31650 /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(Stack, { direction: "row", align: layout.alignment, gap: "lg", children: /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(
31651 DataFormLayout,
31652 {
31653 data,
31654 form,
31655 onChange,
31656 validity: validity?.children,
31657 as: EMPTY_WRAPPER,
31658 children: (FieldLayout, childField, childFieldValidity) => /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(
31659 "div",
31660 {
31661 className: "dataforms-layouts-row__field-control",
31662 style: layout.styles[childField.id],
31663 children: /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(
31664 FieldLayout,
31665 {
31666 data,
31667 field: childField,
31668 onChange,
31669 hideLabelFromVision,
31670 markWhenOptional,
31671 validity: childFieldValidity
31672 }
31673 )
31674 },
31675 childField.id
31676 )
31677 }
31678 ) })
31679 ] });
31680 }
31681 const RegularLayout = getFormFieldLayout("regular")?.component;
31682 if (!RegularLayout) {
31683 return null;
31684 }
31685 return /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(import_jsx_runtime147.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime147.jsx)("div", { className: "dataforms-layouts-row__field-control", children: /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(
31686 RegularLayout,
31687 {
31688 data,
31689 field,
31690 onChange,
31691 markWhenOptional,
31692 validity
31693 }
31694 ) }) });
31695 }
31696
31697 // packages/dataviews/build-module/components/dataform-layouts/details/index.mjs
31698 var import_element107 = __toESM(require_element(), 1);
31699 var import_i18n33 = __toESM(require_i18n(), 1);
31700 var import_compose18 = __toESM(require_compose(), 1);
31701 import { speak as speak5 } from "@wordpress/a11y";
31702 var import_jsx_runtime148 = __toESM(require_jsx_runtime(), 1);
31703 function FormDetailsField({
31704 data,
31705 field,
31706 onChange,
31707 validity
31708 }) {
31709 const { fields } = (0, import_element107.useContext)(dataform_context_default);
31710 const detailsRef = (0, import_element107.useRef)(null);
31711 const contentRef = (0, import_element107.useRef)(null);
31712 const hasFocusedContentRef = (0, import_element107.useRef)(false);
31713 const [touched, setTouched] = (0, import_element107.useState)(false);
31714 const [isOpen2, setIsOpen] = (0, import_element107.useState)(false);
31715 const form = (0, import_element107.useMemo)(
31716 () => ({
31717 layout: DEFAULT_LAYOUT,
31718 fields: field.children ?? []
31719 }),
31720 [field]
31721 );
31722 (0, import_element107.useEffect)(() => {
31723 const details = detailsRef.current;
31724 if (!details) {
31725 return;
31726 }
31727 const handleToggle = () => {
31728 const nowOpen = details.open;
31729 if (!nowOpen) {
31730 setTouched(true);
31731 }
31732 setIsOpen(nowOpen);
31733 };
31734 details.addEventListener("toggle", handleToggle);
31735 return () => {
31736 details.removeEventListener("toggle", handleToggle);
31737 };
31738 }, []);
31739 const revealValidity = useRevealValidity(contentRef, isOpen2 && touched);
31740 const handleContentFocus = (0, import_element107.useCallback)(() => {
31741 hasFocusedContentRef.current = true;
31742 }, []);
31743 const handleFocusOutside = (0, import_element107.useCallback)(() => {
31744 if (!hasFocusedContentRef.current) {
31745 return;
31746 }
31747 setTouched(true);
31748 if (!detailsRef.current?.open) {
31749 return;
31750 }
31751 const revealedCount = revealValidity();
31752 const message2 = getValidationMessage(validity);
31753 if (revealedCount > 0 && message2) {
31754 speak5(message2, "polite");
31755 }
31756 }, [revealValidity, validity]);
31757 const focusOutsideProps = (0, import_compose18.__experimentalUseFocusOutside)(handleFocusOutside);
31758 if (!field.children) {
31759 return null;
31760 }
31761 const summaryFieldId = field.layout.summary ?? "";
31762 const summaryField = summaryFieldId ? fields.find((fieldDef) => fieldDef.id === summaryFieldId) : void 0;
31763 let summaryContent;
31764 if (summaryField && summaryField.render) {
31765 summaryContent = /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(summaryField.render, { item: data, field: summaryField });
31766 } else {
31767 summaryContent = field.label || (0, import_i18n33.__)("More details");
31768 }
31769 return /* @__PURE__ */ (0, import_jsx_runtime148.jsxs)(
31770 "details",
31771 {
31772 ref: detailsRef,
31773 className: "dataforms-layouts-details__details",
31774 ...focusOutsideProps,
31775 children: [
31776 /* @__PURE__ */ (0, import_jsx_runtime148.jsx)("summary", { className: "dataforms-layouts-details__summary", children: /* @__PURE__ */ (0, import_jsx_runtime148.jsxs)(
31777 Stack,
31778 {
31779 direction: "row",
31780 align: "center",
31781 gap: "md",
31782 className: "dataforms-layouts-details__summary-content",
31783 children: [
31784 summaryContent,
31785 touched && /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(ValidationBadge, { validity })
31786 ]
31787 }
31788 ) }),
31789 /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(
31790 "div",
31791 {
31792 ref: contentRef,
31793 className: "dataforms-layouts-details__content",
31794 onFocus: handleContentFocus,
31795 children: /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(
31796 DataFormLayout,
31797 {
31798 data,
31799 form,
31800 onChange,
31801 validity: validity?.children
31802 }
31803 )
31804 }
31805 )
31806 ]
31807 }
31808 );
31809 }
31810
31811 // packages/dataviews/build-module/components/dataform-layouts/index.mjs
31812 var import_jsx_runtime149 = __toESM(require_jsx_runtime(), 1);
31813 var FORM_FIELD_LAYOUTS = [
31814 {
31815 type: "regular",
31816 component: FormRegularField,
31817 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(
31818 Stack,
31819 {
31820 direction: "column",
31821 className: "dataforms-layouts__wrapper",
31822 gap: "lg",
31823 children
31824 }
31825 )
31826 },
31827 {
31828 type: "panel",
31829 component: FormPanelField,
31830 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(
31831 Stack,
31832 {
31833 direction: "column",
31834 className: "dataforms-layouts__wrapper",
31835 gap: "md",
31836 children
31837 }
31838 )
31839 },
31840 {
31841 type: "card",
31842 component: FormCardField,
31843 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(
31844 Stack,
31845 {
31846 direction: "column",
31847 className: "dataforms-layouts__wrapper",
31848 gap: "xl",
31849 children
31850 }
31851 )
31852 },
31853 {
31854 type: "row",
31855 component: FormRowField,
31856 wrapper: ({
31857 children,
31858 layout
31859 }) => /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(
31860 Stack,
31861 {
31862 direction: "column",
31863 className: "dataforms-layouts__wrapper",
31864 gap: "lg",
31865 children: /* @__PURE__ */ (0, import_jsx_runtime149.jsx)("div", { className: "dataforms-layouts-row__field", children: /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(
31866 Stack,
31867 {
31868 direction: "row",
31869 gap: "lg",
31870 align: layout.alignment,
31871 children
31872 }
31873 ) })
31874 }
31875 )
31876 },
31877 {
31878 type: "details",
31879 component: FormDetailsField
31880 }
31881 ];
31882 function getFormFieldLayout(type) {
31883 return FORM_FIELD_LAYOUTS.find((layout) => layout.type === type);
31884 }
31885
31886 // packages/dataviews/build-module/components/dataform-layouts/data-form-layout.mjs
31887 var import_jsx_runtime150 = __toESM(require_jsx_runtime(), 1);
31888 var DEFAULT_WRAPPER = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(Stack, { direction: "column", className: "dataforms-layouts__wrapper", gap: "lg", children });
31889 function DataFormLayout({
31890 data,
31891 form,
31892 onChange,
31893 validity,
31894 children,
31895 as
31896 }) {
31897 const { fields: fieldDefinitions } = (0, import_element108.useContext)(dataform_context_default);
31898 const markWhenOptional = (0, import_element108.useMemo)(() => {
31899 const requiredCount = fieldDefinitions.filter(
31900 (f) => !!f.isValid?.required
31901 ).length;
31902 const optionalCount = fieldDefinitions.length - requiredCount;
31903 return requiredCount > optionalCount;
31904 }, [fieldDefinitions]);
31905 function getFieldDefinition2(field) {
31906 return fieldDefinitions.find(
31907 (fieldDefinition) => fieldDefinition.id === field.id
31908 );
31909 }
31910 const Wrapper = as ?? getFormFieldLayout(form.layout.type)?.wrapper ?? DEFAULT_WRAPPER;
31911 return /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(Wrapper, { layout: form.layout, children: form.fields.map((formField) => {
31912 const FieldLayout = getFormFieldLayout(
31913 formField.layout.type
31914 )?.component;
31915 if (!FieldLayout) {
31916 return null;
31917 }
31918 const fieldDefinition = !formField.children ? getFieldDefinition2(formField) : void 0;
31919 if (fieldDefinition && fieldDefinition.isVisible && !fieldDefinition.isVisible(data)) {
31920 return null;
31921 }
31922 if (children) {
31923 return children(
31924 FieldLayout,
31925 formField,
31926 validity?.[formField.id],
31927 markWhenOptional
31928 );
31929 }
31930 return /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(
31931 FieldLayout,
31932 {
31933 data,
31934 field: formField,
31935 onChange,
31936 markWhenOptional,
31937 validity: validity?.[formField.id]
31938 },
31939 formField.id
31940 );
31941 }) });
31942 }
31943
31944 // packages/dataviews/build-module/dataform/index.mjs
31945 var import_jsx_runtime151 = __toESM(require_jsx_runtime(), 1);
31946 function DataForm({
31947 data,
31948 form,
31949 fields,
31950 onChange,
31951 validity
31952 }) {
31953 const normalizedForm = (0, import_element109.useMemo)(() => normalize_form_default(form), [form]);
31954 const normalizedFields = (0, import_element109.useMemo)(
31955 () => normalizeFields(fields),
31956 [fields]
31957 );
31958 if (!form.fields) {
31959 return null;
31960 }
31961 return /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(DataFormProvider, { fields: normalizedFields, children: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
31962 DataFormLayout,
31963 {
31964 data,
31965 form: normalizedForm,
31966 onChange,
31967 validity
31968 }
31969 ) });
31970 }
31971
31972 // packages/media-editor/build-module/components/media-form/index.mjs
31973 var import_components30 = __toESM(require_components(), 1);
31974 var import_i18n34 = __toESM(require_i18n(), 1);
31975 var import_jsx_runtime152 = __toESM(require_jsx_runtime(), 1);
31976 function MediaForm({
31977 form: formOverrides,
31978 header
31979 }) {
31980 const { media, fields, onChange } = useMediaEditorContext();
31981 if (!media || !onChange) {
31982 return /* @__PURE__ */ (0, import_jsx_runtime152.jsx)("div", { className: "media-editor-form media-editor-form--loading", children: /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(import_components30.Spinner, {}) });
31983 }
31984 const regularFieldIds = ["title", "alt_text", "caption", "description"];
31985 const sortedFields = [
31986 ...fields.filter(
31987 (field) => regularFieldIds.includes(field.id)
31988 ),
31989 ...fields.filter(
31990 (field) => !regularFieldIds.includes(field.id)
31991 )
31992 ];
31993 const defaultForm = {
31994 layout: {
31995 type: "panel"
31996 },
31997 fields: sortedFields.map((field) => {
31998 if (regularFieldIds.includes(field.id)) {
31999 return {
32000 id: field.id,
32001 layout: {
32002 type: "regular",
32003 labelPosition: "top"
32004 }
32005 };
32006 }
32007 return field.id;
32008 })
32009 };
32010 const form = formOverrides || defaultForm;
32011 return /* @__PURE__ */ (0, import_jsx_runtime152.jsx)("div", { className: "media-editor-form", children: /* @__PURE__ */ (0, import_jsx_runtime152.jsxs)(import_components30.__experimentalVStack, { spacing: 4, children: [
32012 /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime152.jsx)("h2", {}), children: (0, import_i18n34.__)("Media details") }),
32013 header,
32014 /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(
32015 DataForm,
32016 {
32017 data: media,
32018 fields,
32019 form,
32020 onChange
32021 }
32022 )
32023 ] }) });
32024 }
32025
32026 // packages/media-editor/build-module/lock-unlock.mjs
32027 var import_private_apis2 = __toESM(require_private_apis(), 1);
32028 var { lock: lock2, unlock: unlock2 } = (0, import_private_apis2.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
32029 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
32030 "@wordpress/media-editor"
32031 );
32032
32033 // packages/media-editor/build-module/store/index.mjs
32034 var import_data = __toESM(require_data(), 1);
32035
32036 // packages/media-editor/build-module/store/reducer.mjs
32037 var DEFAULT_STATE = {
32038 isOpen: false,
32039 id: null,
32040 onUpdate: null,
32041 onClose: null
32042 };
32043 function reducer(state = DEFAULT_STATE, action) {
32044 switch (action.type) {
32045 case "OPEN_MEDIA_EDITOR_MODAL": {
32046 const { id, onUpdate, onClose } = action;
32047 return {
32048 isOpen: true,
32049 id,
32050 onUpdate,
32051 onClose
32052 };
32053 }
32054 case "CLOSE_MEDIA_EDITOR_MODAL":
32055 return DEFAULT_STATE;
32056 }
32057 return state;
32058 }
32059
32060 // packages/media-editor/build-module/store/actions.mjs
32061 var actions_exports = {};
32062 __export(actions_exports, {
32063 closeMediaEditorModal: () => closeMediaEditorModal,
32064 openMediaEditorModal: () => openMediaEditorModal
32065 });
32066 function openMediaEditorModal({
32067 id,
32068 onUpdate,
32069 onClose
32070 }) {
32071 return {
32072 type: "OPEN_MEDIA_EDITOR_MODAL",
32073 id,
32074 onUpdate: onUpdate ?? null,
32075 onClose: onClose ?? null
32076 };
32077 }
32078 function closeMediaEditorModal() {
32079 return { type: "CLOSE_MEDIA_EDITOR_MODAL" };
32080 }
32081
32082 // packages/media-editor/build-module/store/selectors.mjs
32083 var selectors_exports = {};
32084 __export(selectors_exports, {
32085 getId: () => getId,
32086 getOnClose: () => getOnClose,
32087 getOnUpdate: () => getOnUpdate,
32088 isOpen: () => isOpen
32089 });
32090 function isOpen(state) {
32091 return state.isOpen;
32092 }
32093 function getId(state) {
32094 return state.id;
32095 }
32096 function getOnUpdate(state) {
32097 return state.onUpdate;
32098 }
32099 function getOnClose(state) {
32100 return state.onClose;
32101 }
32102
32103 // packages/media-editor/build-module/store/constants.mjs
32104 var STORE_NAME = "core/media-editor";
32105
32106 // packages/media-editor/build-module/store/index.mjs
32107 var store = (0, import_data.createReduxStore)(STORE_NAME, {
32108 reducer,
32109 actions: actions_exports,
32110 selectors: selectors_exports
32111 });
32112 (0, import_data.register)(store);
32113
32114 // packages/media-editor/build-module/components/media-editor-modal/index.mjs
32115 var import_components37 = __toESM(require_components(), 1);
32116 var import_data4 = __toESM(require_data(), 1);
32117 var import_i18n46 = __toESM(require_i18n(), 1);
32118 var import_keyboard_shortcuts = __toESM(require_keyboard_shortcuts(), 1);
32119 var import_notices3 = __toESM(require_notices(), 1);
32120
32121 // packages/media-editor/build-module/components/media-editor/index.mjs
32122 var import_components36 = __toESM(require_components(), 1);
32123 var import_compose19 = __toESM(require_compose(), 1);
32124 var import_data3 = __toESM(require_data(), 1);
32125 var import_core_data2 = __toESM(require_core_data(), 1);
32126 var import_element127 = __toESM(require_element(), 1);
32127 var import_i18n45 = __toESM(require_i18n(), 1);
32128 var import_keycodes2 = __toESM(require_keycodes(), 1);
32129 var import_notices2 = __toESM(require_notices(), 1);
32130
32131 // packages/media-editor/build-module/components/media-editor-canvas/index.mjs
32132 var import_element120 = __toESM(require_element(), 1);
32133 var import_components32 = __toESM(require_components(), 1);
32134 var import_i18n39 = __toESM(require_i18n(), 1);
32135
32136 // packages/media-editor/build-module/image-editor/core/constants.mjs
32137 var import_i18n35 = __toESM(require_i18n(), 1);
32138 var MIN_ZOOM = 1;
32139 var ABSOLUTE_MIN_ZOOM = 0.1;
32140 var MAX_ZOOM = 10;
32141 var MIN_CROP_PIXELS = 16;
32142 var MIN_CROP_SCREEN_PX = 44;
32143 var SETTLE_TARGET_CANVAS_FILL = 0.8;
32144 var MAX_VIEW_SCALE = 8;
32145 var PIXEL_SNAP_DISPLAY_SCALE = 1;
32146 var DEFAULT_WHEEL_ZOOM_SPEED = 25e-4;
32147 var DEFAULT_KEYBOARD_STEP = 0.01;
32148 var KEYBOARD_SHIFT_STEP_MULTIPLIER = 10;
32149 var MAX_ROTATION_OFFSET = 45;
32150 var DEFAULT_CROP_RECT = {
32151 x: 0,
32152 y: 0,
32153 width: 1,
32154 height: 1
32155 };
32156 var DEFAULT_FLIP = {
32157 horizontal: false,
32158 vertical: false
32159 };
32160 var DEFAULT_PAN = {
32161 x: 0,
32162 y: 0
32163 };
32164 var DEFAULT_STATE2 = {
32165 image: null,
32166 pan: { ...DEFAULT_PAN },
32167 zoom: MIN_ZOOM,
32168 rotation: 0,
32169 basePan: { ...DEFAULT_PAN },
32170 baseZoom: MIN_ZOOM,
32171 baseRotation: 0,
32172 flip: { ...DEFAULT_FLIP },
32173 cropRect: { ...DEFAULT_CROP_RECT }
32174 };
32175 var ORIGINAL_ASPECT_RATIO = -1;
32176 var DEFAULT_ASPECT_RATIOS = [
32177 { label: (0, import_i18n35.__)("Free"), value: 0 },
32178 { label: (0, import_i18n35.__)("Original"), value: ORIGINAL_ASPECT_RATIO },
32179 { label: (0, import_i18n35.__)("Square (1:1)"), value: 1 },
32180 { label: (0, import_i18n35.__)("Landscape (16:9)"), value: 16 / 9 },
32181 { label: (0, import_i18n35.__)("Portrait (9:16)"), value: 9 / 16 },
32182 { label: (0, import_i18n35.__)("Classic (4:3)"), value: 4 / 3 },
32183 { label: (0, import_i18n35.__)("Classic portrait (3:4)"), value: 3 / 4 },
32184 { label: (0, import_i18n35.__)("Photo (3:2)"), value: 3 / 2 },
32185 { label: (0, import_i18n35.__)("Photo portrait (2:3)"), value: 2 / 3 }
32186 ];
32187
32188 // node_modules/gl-matrix/esm/common.js
32189 var EPSILON = 1e-6;
32190 var ARRAY_TYPE = typeof Float32Array !== "undefined" ? Float32Array : Array;
32191 var RANDOM = Math.random;
32192 function round2(a) {
32193 if (a >= 0) return Math.round(a);
32194 return a % 0.5 === 0 ? Math.floor(a) : Math.round(a);
32195 }
32196 var degree = Math.PI / 180;
32197 var radian = 180 / Math.PI;
32198
32199 // node_modules/gl-matrix/esm/mat2d.js
32200 var mat2d_exports = {};
32201 __export(mat2d_exports, {
32202 add: () => add,
32203 clone: () => clone,
32204 copy: () => copy,
32205 create: () => create,
32206 determinant: () => determinant,
32207 equals: () => equals,
32208 exactEquals: () => exactEquals,
32209 frob: () => frob,
32210 fromRotation: () => fromRotation,
32211 fromScaling: () => fromScaling,
32212 fromTranslation: () => fromTranslation,
32213 fromValues: () => fromValues,
32214 identity: () => identity,
32215 invert: () => invert,
32216 mul: () => mul,
32217 multiply: () => multiply,
32218 multiplyScalar: () => multiplyScalar,
32219 multiplyScalarAndAdd: () => multiplyScalarAndAdd,
32220 rotate: () => rotate,
32221 scale: () => scale,
32222 set: () => set,
32223 str: () => str,
32224 sub: () => sub,
32225 subtract: () => subtract,
32226 translate: () => translate
32227 });
32228 function create() {
32229 var out = new ARRAY_TYPE(6);
32230 if (ARRAY_TYPE != Float32Array) {
32231 out[1] = 0;
32232 out[2] = 0;
32233 out[4] = 0;
32234 out[5] = 0;
32235 }
32236 out[0] = 1;
32237 out[3] = 1;
32238 return out;
32239 }
32240 function clone(a) {
32241 var out = new ARRAY_TYPE(6);
32242 out[0] = a[0];
32243 out[1] = a[1];
32244 out[2] = a[2];
32245 out[3] = a[3];
32246 out[4] = a[4];
32247 out[5] = a[5];
32248 return out;
32249 }
32250 function copy(out, a) {
32251 out[0] = a[0];
32252 out[1] = a[1];
32253 out[2] = a[2];
32254 out[3] = a[3];
32255 out[4] = a[4];
32256 out[5] = a[5];
32257 return out;
32258 }
32259 function identity(out) {
32260 out[0] = 1;
32261 out[1] = 0;
32262 out[2] = 0;
32263 out[3] = 1;
32264 out[4] = 0;
32265 out[5] = 0;
32266 return out;
32267 }
32268 function fromValues(a, b, c2, d, tx, ty) {
32269 var out = new ARRAY_TYPE(6);
32270 out[0] = a;
32271 out[1] = b;
32272 out[2] = c2;
32273 out[3] = d;
32274 out[4] = tx;
32275 out[5] = ty;
32276 return out;
32277 }
32278 function set(out, a, b, c2, d, tx, ty) {
32279 out[0] = a;
32280 out[1] = b;
32281 out[2] = c2;
32282 out[3] = d;
32283 out[4] = tx;
32284 out[5] = ty;
32285 return out;
32286 }
32287 function invert(out, a) {
32288 var aa = a[0], ab = a[1], ac = a[2], ad = a[3];
32289 var atx = a[4], aty = a[5];
32290 var det = aa * ad - ab * ac;
32291 if (!det) {
32292 return null;
32293 }
32294 det = 1 / det;
32295 out[0] = ad * det;
32296 out[1] = -ab * det;
32297 out[2] = -ac * det;
32298 out[3] = aa * det;
32299 out[4] = (ac * aty - ad * atx) * det;
32300 out[5] = (ab * atx - aa * aty) * det;
32301 return out;
32302 }
32303 function determinant(a) {
32304 return a[0] * a[3] - a[1] * a[2];
32305 }
32306 function multiply(out, a, b) {
32307 var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5];
32308 var b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5];
32309 out[0] = a0 * b0 + a2 * b1;
32310 out[1] = a1 * b0 + a3 * b1;
32311 out[2] = a0 * b2 + a2 * b3;
32312 out[3] = a1 * b2 + a3 * b3;
32313 out[4] = a0 * b4 + a2 * b5 + a4;
32314 out[5] = a1 * b4 + a3 * b5 + a5;
32315 return out;
32316 }
32317 function rotate(out, a, rad) {
32318 var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5];
32319 var s = Math.sin(rad);
32320 var c2 = Math.cos(rad);
32321 out[0] = a0 * c2 + a2 * s;
32322 out[1] = a1 * c2 + a3 * s;
32323 out[2] = a0 * -s + a2 * c2;
32324 out[3] = a1 * -s + a3 * c2;
32325 out[4] = a4;
32326 out[5] = a5;
32327 return out;
32328 }
32329 function scale(out, a, v2) {
32330 var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5];
32331 var v0 = v2[0], v1 = v2[1];
32332 out[0] = a0 * v0;
32333 out[1] = a1 * v0;
32334 out[2] = a2 * v1;
32335 out[3] = a3 * v1;
32336 out[4] = a4;
32337 out[5] = a5;
32338 return out;
32339 }
32340 function translate(out, a, v2) {
32341 var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5];
32342 var v0 = v2[0], v1 = v2[1];
32343 out[0] = a0;
32344 out[1] = a1;
32345 out[2] = a2;
32346 out[3] = a3;
32347 out[4] = a0 * v0 + a2 * v1 + a4;
32348 out[5] = a1 * v0 + a3 * v1 + a5;
32349 return out;
32350 }
32351 function fromRotation(out, rad) {
32352 var s = Math.sin(rad), c2 = Math.cos(rad);
32353 out[0] = c2;
32354 out[1] = s;
32355 out[2] = -s;
32356 out[3] = c2;
32357 out[4] = 0;
32358 out[5] = 0;
32359 return out;
32360 }
32361 function fromScaling(out, v2) {
32362 out[0] = v2[0];
32363 out[1] = 0;
32364 out[2] = 0;
32365 out[3] = v2[1];
32366 out[4] = 0;
32367 out[5] = 0;
32368 return out;
32369 }
32370 function fromTranslation(out, v2) {
32371 out[0] = 1;
32372 out[1] = 0;
32373 out[2] = 0;
32374 out[3] = 1;
32375 out[4] = v2[0];
32376 out[5] = v2[1];
32377 return out;
32378 }
32379 function str(a) {
32380 return "mat2d(" + a[0] + ", " + a[1] + ", " + a[2] + ", " + a[3] + ", " + a[4] + ", " + a[5] + ")";
32381 }
32382 function frob(a) {
32383 return Math.sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2] + a[3] * a[3] + a[4] * a[4] + a[5] * a[5] + 1);
32384 }
32385 function add(out, a, b) {
32386 out[0] = a[0] + b[0];
32387 out[1] = a[1] + b[1];
32388 out[2] = a[2] + b[2];
32389 out[3] = a[3] + b[3];
32390 out[4] = a[4] + b[4];
32391 out[5] = a[5] + b[5];
32392 return out;
32393 }
32394 function subtract(out, a, b) {
32395 out[0] = a[0] - b[0];
32396 out[1] = a[1] - b[1];
32397 out[2] = a[2] - b[2];
32398 out[3] = a[3] - b[3];
32399 out[4] = a[4] - b[4];
32400 out[5] = a[5] - b[5];
32401 return out;
32402 }
32403 function multiplyScalar(out, a, b) {
32404 out[0] = a[0] * b;
32405 out[1] = a[1] * b;
32406 out[2] = a[2] * b;
32407 out[3] = a[3] * b;
32408 out[4] = a[4] * b;
32409 out[5] = a[5] * b;
32410 return out;
32411 }
32412 function multiplyScalarAndAdd(out, a, b, scale3) {
32413 out[0] = a[0] + b[0] * scale3;
32414 out[1] = a[1] + b[1] * scale3;
32415 out[2] = a[2] + b[2] * scale3;
32416 out[3] = a[3] + b[3] * scale3;
32417 out[4] = a[4] + b[4] * scale3;
32418 out[5] = a[5] + b[5] * scale3;
32419 return out;
32420 }
32421 function exactEquals(a, b) {
32422 return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] && a[4] === b[4] && a[5] === b[5];
32423 }
32424 function equals(a, b) {
32425 var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5];
32426 var b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5];
32427 return Math.abs(a0 - b0) <= EPSILON * Math.max(1, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= EPSILON * Math.max(1, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= EPSILON * Math.max(1, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= EPSILON * Math.max(1, Math.abs(a3), Math.abs(b3)) && Math.abs(a4 - b4) <= EPSILON * Math.max(1, Math.abs(a4), Math.abs(b4)) && Math.abs(a5 - b5) <= EPSILON * Math.max(1, Math.abs(a5), Math.abs(b5));
32428 }
32429 var mul = multiply;
32430 var sub = subtract;
32431
32432 // node_modules/gl-matrix/esm/vec2.js
32433 var vec2_exports = {};
32434 __export(vec2_exports, {
32435 add: () => add2,
32436 angle: () => angle,
32437 ceil: () => ceil,
32438 clone: () => clone2,
32439 copy: () => copy2,
32440 create: () => create2,
32441 cross: () => cross,
32442 dist: () => dist,
32443 distance: () => distance,
32444 div: () => div,
32445 divide: () => divide,
32446 dot: () => dot,
32447 equals: () => equals2,
32448 exactEquals: () => exactEquals2,
32449 floor: () => floor2,
32450 forEach: () => forEach,
32451 fromValues: () => fromValues2,
32452 inverse: () => inverse,
32453 len: () => len,
32454 length: () => length,
32455 lerp: () => lerp,
32456 max: () => max3,
32457 min: () => min3,
32458 mul: () => mul2,
32459 multiply: () => multiply2,
32460 negate: () => negate,
32461 normalize: () => normalize,
32462 random: () => random,
32463 rotate: () => rotate2,
32464 round: () => round3,
32465 scale: () => scale2,
32466 scaleAndAdd: () => scaleAndAdd,
32467 set: () => set2,
32468 signedAngle: () => signedAngle,
32469 sqrDist: () => sqrDist,
32470 sqrLen: () => sqrLen,
32471 squaredDistance: () => squaredDistance,
32472 squaredLength: () => squaredLength,
32473 str: () => str2,
32474 sub: () => sub2,
32475 subtract: () => subtract2,
32476 transformMat2: () => transformMat2,
32477 transformMat2d: () => transformMat2d,
32478 transformMat3: () => transformMat3,
32479 transformMat4: () => transformMat4,
32480 zero: () => zero
32481 });
32482 function create2() {
32483 var out = new ARRAY_TYPE(2);
32484 if (ARRAY_TYPE != Float32Array) {
32485 out[0] = 0;
32486 out[1] = 0;
32487 }
32488 return out;
32489 }
32490 function clone2(a) {
32491 var out = new ARRAY_TYPE(2);
32492 out[0] = a[0];
32493 out[1] = a[1];
32494 return out;
32495 }
32496 function fromValues2(x2, y2) {
32497 var out = new ARRAY_TYPE(2);
32498 out[0] = x2;
32499 out[1] = y2;
32500 return out;
32501 }
32502 function copy2(out, a) {
32503 out[0] = a[0];
32504 out[1] = a[1];
32505 return out;
32506 }
32507 function set2(out, x2, y2) {
32508 out[0] = x2;
32509 out[1] = y2;
32510 return out;
32511 }
32512 function add2(out, a, b) {
32513 out[0] = a[0] + b[0];
32514 out[1] = a[1] + b[1];
32515 return out;
32516 }
32517 function subtract2(out, a, b) {
32518 out[0] = a[0] - b[0];
32519 out[1] = a[1] - b[1];
32520 return out;
32521 }
32522 function multiply2(out, a, b) {
32523 out[0] = a[0] * b[0];
32524 out[1] = a[1] * b[1];
32525 return out;
32526 }
32527 function divide(out, a, b) {
32528 out[0] = a[0] / b[0];
32529 out[1] = a[1] / b[1];
32530 return out;
32531 }
32532 function ceil(out, a) {
32533 out[0] = Math.ceil(a[0]);
32534 out[1] = Math.ceil(a[1]);
32535 return out;
32536 }
32537 function floor2(out, a) {
32538 out[0] = Math.floor(a[0]);
32539 out[1] = Math.floor(a[1]);
32540 return out;
32541 }
32542 function min3(out, a, b) {
32543 out[0] = Math.min(a[0], b[0]);
32544 out[1] = Math.min(a[1], b[1]);
32545 return out;
32546 }
32547 function max3(out, a, b) {
32548 out[0] = Math.max(a[0], b[0]);
32549 out[1] = Math.max(a[1], b[1]);
32550 return out;
32551 }
32552 function round3(out, a) {
32553 out[0] = round2(a[0]);
32554 out[1] = round2(a[1]);
32555 return out;
32556 }
32557 function scale2(out, a, b) {
32558 out[0] = a[0] * b;
32559 out[1] = a[1] * b;
32560 return out;
32561 }
32562 function scaleAndAdd(out, a, b, scale3) {
32563 out[0] = a[0] + b[0] * scale3;
32564 out[1] = a[1] + b[1] * scale3;
32565 return out;
32566 }
32567 function distance(a, b) {
32568 var x2 = b[0] - a[0], y2 = b[1] - a[1];
32569 return Math.sqrt(x2 * x2 + y2 * y2);
32570 }
32571 function squaredDistance(a, b) {
32572 var x2 = b[0] - a[0], y2 = b[1] - a[1];
32573 return x2 * x2 + y2 * y2;
32574 }
32575 function length(a) {
32576 var x2 = a[0], y2 = a[1];
32577 return Math.sqrt(x2 * x2 + y2 * y2);
32578 }
32579 function squaredLength(a) {
32580 var x2 = a[0], y2 = a[1];
32581 return x2 * x2 + y2 * y2;
32582 }
32583 function negate(out, a) {
32584 out[0] = -a[0];
32585 out[1] = -a[1];
32586 return out;
32587 }
32588 function inverse(out, a) {
32589 out[0] = 1 / a[0];
32590 out[1] = 1 / a[1];
32591 return out;
32592 }
32593 function normalize(out, a) {
32594 var x2 = a[0], y2 = a[1];
32595 var len2 = x2 * x2 + y2 * y2;
32596 if (len2 > 0) {
32597 len2 = 1 / Math.sqrt(len2);
32598 }
32599 out[0] = a[0] * len2;
32600 out[1] = a[1] * len2;
32601 return out;
32602 }
32603 function dot(a, b) {
32604 return a[0] * b[0] + a[1] * b[1];
32605 }
32606 function cross(out, a, b) {
32607 var z = a[0] * b[1] - a[1] * b[0];
32608 out[0] = out[1] = 0;
32609 out[2] = z;
32610 return out;
32611 }
32612 function lerp(out, a, b, t) {
32613 var ax = a[0], ay = a[1];
32614 out[0] = ax + t * (b[0] - ax);
32615 out[1] = ay + t * (b[1] - ay);
32616 return out;
32617 }
32618 function random(out, scale3) {
32619 scale3 = scale3 === void 0 ? 1 : scale3;
32620 var r2 = RANDOM() * 2 * Math.PI;
32621 out[0] = Math.cos(r2) * scale3;
32622 out[1] = Math.sin(r2) * scale3;
32623 return out;
32624 }
32625 function transformMat2(out, a, m2) {
32626 var x2 = a[0], y2 = a[1];
32627 out[0] = m2[0] * x2 + m2[2] * y2;
32628 out[1] = m2[1] * x2 + m2[3] * y2;
32629 return out;
32630 }
32631 function transformMat2d(out, a, m2) {
32632 var x2 = a[0], y2 = a[1];
32633 out[0] = m2[0] * x2 + m2[2] * y2 + m2[4];
32634 out[1] = m2[1] * x2 + m2[3] * y2 + m2[5];
32635 return out;
32636 }
32637 function transformMat3(out, a, m2) {
32638 var x2 = a[0], y2 = a[1];
32639 out[0] = m2[0] * x2 + m2[3] * y2 + m2[6];
32640 out[1] = m2[1] * x2 + m2[4] * y2 + m2[7];
32641 return out;
32642 }
32643 function transformMat4(out, a, m2) {
32644 var x2 = a[0];
32645 var y2 = a[1];
32646 out[0] = m2[0] * x2 + m2[4] * y2 + m2[12];
32647 out[1] = m2[1] * x2 + m2[5] * y2 + m2[13];
32648 return out;
32649 }
32650 function rotate2(out, a, b, rad) {
32651 var p0 = a[0] - b[0], p1 = a[1] - b[1], sinC = Math.sin(rad), cosC = Math.cos(rad);
32652 out[0] = p0 * cosC - p1 * sinC + b[0];
32653 out[1] = p0 * sinC + p1 * cosC + b[1];
32654 return out;
32655 }
32656 function angle(a, b) {
32657 var ax = a[0], ay = a[1], bx = b[0], by = b[1];
32658 return Math.abs(Math.atan2(ay * bx - ax * by, ax * bx + ay * by));
32659 }
32660 function signedAngle(a, b) {
32661 var ax = a[0], ay = a[1], bx = b[0], by = b[1];
32662 return Math.atan2(ax * by - ay * bx, ax * bx + ay * by);
32663 }
32664 function zero(out) {
32665 out[0] = 0;
32666 out[1] = 0;
32667 return out;
32668 }
32669 function str2(a) {
32670 return "vec2(" + a[0] + ", " + a[1] + ")";
32671 }
32672 function exactEquals2(a, b) {
32673 return a[0] === b[0] && a[1] === b[1];
32674 }
32675 function equals2(a, b) {
32676 var a0 = a[0], a1 = a[1];
32677 var b0 = b[0], b1 = b[1];
32678 return Math.abs(a0 - b0) <= EPSILON * Math.max(1, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= EPSILON * Math.max(1, Math.abs(a1), Math.abs(b1));
32679 }
32680 var len = length;
32681 var sub2 = subtract2;
32682 var mul2 = multiply2;
32683 var div = divide;
32684 var dist = distance;
32685 var sqrDist = squaredDistance;
32686 var sqrLen = squaredLength;
32687 var forEach = (function() {
32688 var vec = create2();
32689 return function(a, stride, offset4, count, fn, arg) {
32690 var i, l2;
32691 if (!stride) {
32692 stride = 2;
32693 }
32694 if (!offset4) {
32695 offset4 = 0;
32696 }
32697 if (count) {
32698 l2 = Math.min(count * stride + offset4, a.length);
32699 } else {
32700 l2 = a.length;
32701 }
32702 for (i = offset4; i < l2; i += stride) {
32703 vec[0] = a[i];
32704 vec[1] = a[i + 1];
32705 fn(vec, vec, arg);
32706 a[i] = vec[0];
32707 a[i + 1] = vec[1];
32708 }
32709 return a;
32710 };
32711 })();
32712
32713 // packages/media-editor/build-module/image-editor/core/math/rotation.mjs
32714 function normalizeRotation(degrees) {
32715 if (degrees >= 0) {
32716 return degrees % 360;
32717 }
32718 return (360 + degrees % 360) % 360;
32719 }
32720 function degreesToRadians(degrees) {
32721 return degrees * Math.PI / 180;
32722 }
32723
32724 // packages/media-editor/build-module/image-editor/core/math/sanitize.mjs
32725 var MAX_SAFE_MAGNITUDE = 1e6;
32726 function safeBoundedNumber(value, fallback) {
32727 if (!Number.isFinite(value)) {
32728 return fallback;
32729 }
32730 if (Math.abs(value) > MAX_SAFE_MAGNITUDE) {
32731 return fallback;
32732 }
32733 return value;
32734 }
32735 function isSafeNumber(value) {
32736 return Number.isFinite(value) && Math.abs(value) <= MAX_SAFE_MAGNITUDE;
32737 }
32738 function isValidSize(size4) {
32739 return Number.isFinite(size4.width) && Number.isFinite(size4.height) && size4.width >= Number.EPSILON && size4.height >= Number.EPSILON && size4.width <= MAX_SAFE_MAGNITUDE && size4.height <= MAX_SAFE_MAGNITUDE;
32740 }
32741 function sanitizeRect(rect) {
32742 const x2 = safeBoundedNumber(rect.x, 0);
32743 const y2 = safeBoundedNumber(rect.y, 0);
32744 const width = safeBoundedNumber(rect.width, 0);
32745 const height = safeBoundedNumber(rect.height, 0);
32746 if (x2 === rect.x && y2 === rect.y && width === rect.width && height === rect.height) {
32747 return rect;
32748 }
32749 return { x: x2, y: y2, width, height };
32750 }
32751 function sanitizeCropperState(state) {
32752 const panX = safeBoundedNumber(state.pan.x, 0);
32753 const panY = safeBoundedNumber(state.pan.y, 0);
32754 const basePanX = safeBoundedNumber(state.basePan.x, 0);
32755 const basePanY = safeBoundedNumber(state.basePan.y, 0);
32756 const rotation = safeBoundedNumber(state.rotation, 0);
32757 const baseRotation = safeBoundedNumber(state.baseRotation, 0);
32758 const rawZoom = safeBoundedNumber(state.zoom, 1);
32759 const zoom = rawZoom >= Number.EPSILON ? rawZoom : 1;
32760 const rawBaseZoom = safeBoundedNumber(state.baseZoom, 1);
32761 const baseZoom = rawBaseZoom >= Number.EPSILON ? rawBaseZoom : 1;
32762 const cropRect = sanitizeRect(state.cropRect);
32763 const panUnchanged = panX === state.pan.x && panY === state.pan.y;
32764 const basePanUnchanged = basePanX === state.basePan.x && basePanY === state.basePan.y;
32765 if (panUnchanged && basePanUnchanged && zoom === state.zoom && baseZoom === state.baseZoom && rotation === state.rotation && baseRotation === state.baseRotation && cropRect === state.cropRect) {
32766 return state;
32767 }
32768 return {
32769 ...state,
32770 pan: panUnchanged ? state.pan : { x: panX, y: panY },
32771 zoom,
32772 rotation,
32773 basePan: basePanUnchanged ? state.basePan : { x: basePanX, y: basePanY },
32774 baseZoom,
32775 baseRotation,
32776 cropRect
32777 };
32778 }
32779
32780 // packages/media-editor/build-module/image-editor/core/camera.mjs
32781 var _scratchMat = mat2d_exports.create();
32782 var _scratchVec = vec2_exports.create();
32783 function getRotatedBBox(width, height, rotation) {
32784 if (!isSafeNumber(width) || !isSafeNumber(height) || !isSafeNumber(rotation) || width <= 0 || height <= 0) {
32785 return { width: 0, height: 0 };
32786 }
32787 const rad = degreesToRadians(rotation);
32788 const cosR = Math.abs(Math.cos(rad));
32789 const sinR = Math.abs(Math.sin(rad));
32790 return {
32791 width: cosR * width + sinR * height,
32792 height: sinR * width + cosR * height
32793 };
32794 }
32795 function getImageFit(containerSize, imageSize, rotation) {
32796 if (!isValidSize(containerSize) || !isValidSize(imageSize)) {
32797 return {
32798 elementSize: { width: 0, height: 0 },
32799 visualSize: { width: 0, height: 0 }
32800 };
32801 }
32802 const safeRotation = safeBoundedNumber(rotation, 0);
32803 const snapRotation = Math.round(safeRotation / 90) * 90;
32804 const naturalBBox = getRotatedBBox(
32805 imageSize.width,
32806 imageSize.height,
32807 snapRotation
32808 );
32809 if (naturalBBox.width === 0 || naturalBBox.height === 0) {
32810 return {
32811 elementSize: { width: 0, height: 0 },
32812 visualSize: { width: 0, height: 0 }
32813 };
32814 }
32815 const fitScale = Math.min(
32816 containerSize.width / naturalBBox.width,
32817 containerSize.height / naturalBBox.height
32818 );
32819 const renderedW = imageSize.width * fitScale;
32820 const renderedH = imageSize.height * fitScale;
32821 const visualSize = getRotatedBBox(renderedW, renderedH, snapRotation);
32822 return {
32823 elementSize: { width: renderedW, height: renderedH },
32824 visualSize
32825 };
32826 }
32827 function getViewScale(cropRect, canvasSize, visualSize, targetFill, maxScale) {
32828 const cropScreenW = cropRect.width * visualSize.width;
32829 const cropScreenH = cropRect.height * visualSize.height;
32830 if (!isValidSize(canvasSize) || !isValidSize(visualSize) || !(cropScreenW > 0) || !(cropScreenH > 0) || !Number.isFinite(targetFill) || !Number.isFinite(maxScale) || !(targetFill > 0) || !(maxScale >= 1)) {
32831 return 1;
32832 }
32833 const kW = targetFill * canvasSize.width / cropScreenW;
32834 const kH = targetFill * canvasSize.height / cropScreenH;
32835 const k2 = Math.min(kW, kH);
32836 return Math.min(maxScale, Math.max(1, k2));
32837 }
32838 function createCamera(state, containerSize, imageSize) {
32839 const m2 = mat2d_exports.create();
32840 if (!isValidSize(containerSize) || !isValidSize(imageSize)) {
32841 return m2;
32842 }
32843 const safeState = sanitizeCropperState(state);
32844 const snapRotation = Math.round(safeState.rotation / 90) * 90;
32845 const naturalBBox = getRotatedBBox(
32846 imageSize.width,
32847 imageSize.height,
32848 snapRotation
32849 );
32850 if (naturalBBox.width === 0 || naturalBBox.height === 0) {
32851 return m2;
32852 }
32853 const fitScale = Math.min(
32854 containerSize.width / naturalBBox.width,
32855 containerSize.height / naturalBBox.height
32856 );
32857 const renderedW = imageSize.width * fitScale;
32858 const renderedH = imageSize.height * fitScale;
32859 const { width: visualW, height: visualH } = getRotatedBBox(
32860 renderedW,
32861 renderedH,
32862 snapRotation
32863 );
32864 mat2d_exports.translate(m2, m2, [
32865 containerSize.width / 2,
32866 containerSize.height / 2
32867 ]);
32868 mat2d_exports.translate(m2, m2, [
32869 safeState.pan.x * visualW,
32870 safeState.pan.y * visualH
32871 ]);
32872 mat2d_exports.scale(m2, m2, [
32873 safeState.flip.horizontal ? -1 : 1,
32874 safeState.flip.vertical ? -1 : 1
32875 ]);
32876 mat2d_exports.rotate(m2, m2, degreesToRadians(safeState.rotation));
32877 mat2d_exports.scale(m2, m2, [safeState.zoom, safeState.zoom]);
32878 mat2d_exports.translate(m2, m2, [-renderedW / 2, -renderedH / 2]);
32879 mat2d_exports.scale(m2, m2, [renderedW, renderedH]);
32880 return m2;
32881 }
32882 function aabb(camera, corners) {
32883 const screenCorners = corners.map((c2) => {
32884 const out = vec2_exports.create();
32885 vec2_exports.transformMat2d(out, c2, camera);
32886 return out;
32887 });
32888 let minX = screenCorners[0][0];
32889 let maxX = screenCorners[0][0];
32890 let minY = screenCorners[0][1];
32891 let maxY = screenCorners[0][1];
32892 for (let i = 1; i < screenCorners.length; i++) {
32893 const s = screenCorners[i];
32894 if (s[0] < minX) {
32895 minX = s[0];
32896 }
32897 if (s[0] > maxX) {
32898 maxX = s[0];
32899 }
32900 if (s[1] < minY) {
32901 minY = s[1];
32902 }
32903 if (s[1] > maxY) {
32904 maxY = s[1];
32905 }
32906 }
32907 return { left: minX, top: minY, width: maxX - minX, height: maxY - minY };
32908 }
32909 function getVisibleBounds(camera) {
32910 return aabb(camera, [
32911 [0, 0],
32912 [1, 0],
32913 [1, 1],
32914 [0, 1]
32915 ]);
32916 }
32917 function createExportCamera(state, imageSize, outputSize) {
32918 const m2 = mat2d_exports.create();
32919 if (!isValidSize(imageSize) || !isValidSize(outputSize)) {
32920 return m2;
32921 }
32922 const { rotation, flip: flip4, cropRect, zoom, pan } = sanitizeCropperState(state);
32923 const snapRotation = Math.round(rotation / 90) * 90;
32924 const { width: rotW, height: rotH } = getRotatedBBox(
32925 imageSize.width,
32926 imageSize.height,
32927 snapRotation
32928 );
32929 const naturalCropW = cropRect.width * rotW;
32930 const naturalCropH = cropRect.height * rotH;
32931 const outputScaleX = naturalCropW > 0 ? outputSize.width / naturalCropW : 1;
32932 const outputScaleY = naturalCropH > 0 ? outputSize.height / naturalCropH : 1;
32933 const cropOffsetX = cropRect.x * rotW + outputSize.width / 2 / outputScaleX;
32934 const cropOffsetY = cropRect.y * rotH + outputSize.height / 2 / outputScaleY;
32935 const visualCenterX = rotW / 2 + pan.x * rotW;
32936 const visualCenterY = rotH / 2 + pan.y * rotH;
32937 mat2d_exports.scale(m2, m2, [outputScaleX, outputScaleY]);
32938 mat2d_exports.translate(m2, m2, [
32939 visualCenterX - cropOffsetX + outputSize.width / 2 / outputScaleX,
32940 visualCenterY - cropOffsetY + outputSize.height / 2 / outputScaleY
32941 ]);
32942 mat2d_exports.scale(m2, m2, [flip4.horizontal ? -1 : 1, flip4.vertical ? -1 : 1]);
32943 mat2d_exports.rotate(m2, m2, degreesToRadians(rotation));
32944 mat2d_exports.scale(m2, m2, [zoom, zoom]);
32945 mat2d_exports.translate(m2, m2, [-imageSize.width / 2, -imageSize.height / 2]);
32946 return m2;
32947 }
32948
32949 // packages/media-editor/build-module/image-editor/core/export/canvas-renderer.mjs
32950 var DEFAULT_QUALITY = 0.92;
32951 function loadImage(src) {
32952 return new Promise((resolve, reject) => {
32953 const image = new Image();
32954 image.addEventListener("load", () => resolve(image));
32955 image.addEventListener("error", (error2) => reject(error2));
32956 image.crossOrigin = "anonymous";
32957 image.src = src;
32958 });
32959 }
32960 function renderToCanvas(image, state) {
32961 const { naturalWidth, naturalHeight } = image;
32962 const { rotation, cropRect } = state;
32963 const imageSize = { width: naturalWidth, height: naturalHeight };
32964 const snapRotation = Math.round(rotation / 90) * 90;
32965 const rotBBox = getRotatedBBox(naturalWidth, naturalHeight, snapRotation);
32966 const outW = Math.round(cropRect.width * rotBBox.width);
32967 const outH = Math.round(cropRect.height * rotBBox.height);
32968 const canvas = document.createElement("canvas");
32969 canvas.width = outW;
32970 canvas.height = outH;
32971 const ctx = canvas.getContext("2d");
32972 if (!ctx) {
32973 throw new Error(
32974 "Could not obtain a 2D context for the export canvas."
32975 );
32976 }
32977 const camera = createExportCamera(state, imageSize, {
32978 width: outW,
32979 height: outH
32980 });
32981 ctx.setTransform(
32982 camera[0],
32983 camera[1],
32984 camera[2],
32985 camera[3],
32986 camera[4],
32987 camera[5]
32988 );
32989 ctx.drawImage(image, 0, 0);
32990 return canvas;
32991 }
32992 function canvasToBlob(canvas, mimeType = "image/png", quality = DEFAULT_QUALITY) {
32993 return new Promise((resolve, reject) => {
32994 canvas.toBlob(
32995 (blob) => {
32996 if (blob) {
32997 resolve(blob);
32998 } else {
32999 reject(new Error("Canvas toBlob returned null."));
33000 }
33001 },
33002 mimeType,
33003 quality
33004 );
33005 });
33006 }
33007 async function exportCroppedImage(src, state, mimeType = "image/png", quality = DEFAULT_QUALITY) {
33008 const image = await loadImage(src);
33009 const canvas = renderToCanvas(image, state);
33010 return canvasToBlob(canvas, mimeType, quality);
33011 }
33012
33013 // packages/media-editor/build-module/image-editor/core/containment.mjs
33014 var EPSILON2 = 1e-9;
33015 function getVisualDimensions(rotation, imageAspectRatio) {
33016 const rad = degreesToRadians(rotation);
33017 const absC = Math.abs(Math.cos(rad));
33018 const absS = Math.abs(Math.sin(rad));
33019 const bbox = getRotatedBBox(imageAspectRatio, 1, rotation);
33020 return {
33021 visualW: bbox.width,
33022 visualH: bbox.height,
33023 absC,
33024 absS
33025 };
33026 }
33027 function getMinZoomForCover(rotation, imageAspectRatio, cropRect) {
33028 const aspectRatio = Math.max(imageAspectRatio, Number.EPSILON);
33029 const snapRotation = Math.round(rotation / 90) * 90;
33030 const { visualW: snapVisualW, visualH: snapVisualH } = getVisualDimensions(
33031 snapRotation,
33032 aspectRatio
33033 );
33034 const { absC, absS } = getVisualDimensions(rotation, aspectRatio);
33035 const cropHalfW = cropRect.width * snapVisualW / 2;
33036 const cropHalfH = cropRect.height * snapVisualH / 2;
33037 const spanAlpha = cropHalfW * absC + cropHalfH * absS;
33038 const spanBeta = cropHalfW * absS + cropHalfH * absC;
33039 const zoomFromAlpha = 2 * spanAlpha / aspectRatio;
33040 const zoomFromBeta = 2 * spanBeta;
33041 return Math.max(zoomFromAlpha, zoomFromBeta);
33042 }
33043 function getMinZoom(state) {
33044 if (!state.image) {
33045 return MIN_ZOOM;
33046 }
33047 const imageSize = {
33048 width: state.image.naturalWidth,
33049 height: state.image.naturalHeight
33050 };
33051 if (!isValidSize(imageSize)) {
33052 return MIN_ZOOM;
33053 }
33054 const safeState = sanitizeCropperState(state);
33055 const aspectRatio = imageSize.width / imageSize.height;
33056 return Math.max(
33057 ABSOLUTE_MIN_ZOOM,
33058 getMinZoomForCover(
33059 safeState.rotation,
33060 aspectRatio,
33061 safeState.cropRect
33062 )
33063 );
33064 }
33065 function getImageCropBounds(state, elementSize, visualSize) {
33066 if (!isValidSize(elementSize) || !isValidSize(visualSize)) {
33067 return { minX: 0, minY: 0, maxX: 1, maxY: 1 };
33068 }
33069 const safeState = sanitizeCropperState(state);
33070 const tx = safeState.pan.x * visualSize.width;
33071 const ty = safeState.pan.y * visualSize.height;
33072 const rad = degreesToRadians(safeState.rotation);
33073 const cos = Math.cos(rad);
33074 const sin = Math.sin(rad);
33075 const sx = safeState.flip.horizontal ? -1 : 1;
33076 const sy = safeState.flip.vertical ? -1 : 1;
33077 const z = safeState.zoom;
33078 const ma = sx * cos * z;
33079 const mb = sy * sin * z;
33080 const mc = -sx * sin * z;
33081 const md = sy * cos * z;
33082 const hw = elementSize.width / 2;
33083 const hh = elementSize.height / 2;
33084 const corners = [
33085 [-hw, -hh],
33086 [hw, -hh],
33087 [hw, hh],
33088 [-hw, hh]
33089 ];
33090 let imgMinX = Infinity;
33091 let imgMaxX = -Infinity;
33092 let imgMinY = Infinity;
33093 let imgMaxY = -Infinity;
33094 for (const [cx, cy] of corners) {
33095 const screenX = ma * cx + mc * cy + tx;
33096 const screenY = mb * cx + md * cy + ty;
33097 const nx = screenX / visualSize.width + 0.5;
33098 const ny = screenY / visualSize.height + 0.5;
33099 imgMinX = Math.min(imgMinX, nx);
33100 imgMaxX = Math.max(imgMaxX, nx);
33101 imgMinY = Math.min(imgMinY, ny);
33102 imgMaxY = Math.max(imgMaxY, ny);
33103 }
33104 return {
33105 minX: imgMinX,
33106 minY: imgMinY,
33107 maxX: imgMaxX,
33108 maxY: imgMaxY
33109 };
33110 }
33111 function restrictCropRect(cropRect, zoom, rotation, imageAspectRatio) {
33112 const safeRect = sanitizeRect(cropRect);
33113 const zoomCandidate = safeBoundedNumber(zoom, 1);
33114 const safeZoom = zoomCandidate >= Number.EPSILON ? zoomCandidate : 1;
33115 const safeRotation = safeBoundedNumber(rotation, 0);
33116 const safeAspect = safeBoundedNumber(imageAspectRatio, 1);
33117 const aspectRatio = Math.max(safeAspect, Number.EPSILON);
33118 const snapRotation = Math.round(safeRotation / 90) * 90;
33119 const { visualW, visualH } = getVisualDimensions(
33120 snapRotation,
33121 aspectRatio
33122 );
33123 const { absC, absS } = getVisualDimensions(safeRotation, aspectRatio);
33124 const W = safeRect.width;
33125 const H2 = safeRect.height;
33126 const cropWPx = W * visualW;
33127 const cropHPx = H2 * visualH;
33128 const spanAlpha = cropWPx * absC + cropHPx * absS;
33129 const spanBeta = cropWPx * absS + cropHPx * absC;
33130 const limitAlpha = aspectRatio * safeZoom;
33131 const limitBeta = safeZoom;
33132 let t = 1;
33133 if (spanAlpha > 0) {
33134 t = Math.min(t, limitAlpha / spanAlpha);
33135 }
33136 if (spanBeta > 0) {
33137 t = Math.min(t, limitBeta / spanBeta);
33138 }
33139 if (t >= 1 - EPSILON2) {
33140 return safeRect;
33141 }
33142 const newW = W * t;
33143 const newH = H2 * t;
33144 const centerX = safeRect.x + W / 2;
33145 const centerY = safeRect.y + H2 / 2;
33146 let newX = centerX - newW / 2;
33147 let newY = centerY - newH / 2;
33148 newX = Math.max(0, Math.min(newX, 1 - newW));
33149 newY = Math.max(0, Math.min(newY, 1 - newH));
33150 return { x: newX, y: newY, width: newW, height: newH };
33151 }
33152 var CANONICAL_CONTAINER = { width: 1e3, height: 1e3 };
33153 var _scratchMat2 = mat2d_exports.create();
33154 var _scratchVec2 = vec2_exports.create();
33155 function restrictPanZoom(state, imageSize, cropRect) {
33156 const safeState = sanitizeCropperState(state);
33157 const safeCropRect = sanitizeRect(cropRect);
33158 const aspectRatio = isValidSize(imageSize) ? imageSize.width / imageSize.height : 1;
33159 const minZoom = Math.max(
33160 ABSOLUTE_MIN_ZOOM,
33161 getMinZoomForCover(safeState.rotation, aspectRatio, safeCropRect)
33162 );
33163 const zoom = Math.min(MAX_ZOOM, Math.max(safeState.zoom, minZoom));
33164 const candidateState = { ...safeState, zoom };
33165 const camera = createCamera(
33166 candidateState,
33167 CANONICAL_CONTAINER,
33168 imageSize
33169 );
33170 const snapRotation = Math.round(safeState.rotation / 90) * 90;
33171 const baseCamera = createCamera(
33172 {
33173 ...candidateState,
33174 pan: { x: 0, y: 0 },
33175 zoom: 1,
33176 rotation: snapRotation
33177 },
33178 CANONICAL_CONTAINER,
33179 imageSize
33180 );
33181 const visibleBounds = getVisibleBounds(baseCamera);
33182 const stencilCorners = [
33183 [
33184 visibleBounds.left + safeCropRect.x * visibleBounds.width,
33185 visibleBounds.top + safeCropRect.y * visibleBounds.height
33186 ],
33187 [
33188 visibleBounds.left + (safeCropRect.x + safeCropRect.width) * visibleBounds.width,
33189 visibleBounds.top + safeCropRect.y * visibleBounds.height
33190 ],
33191 [
33192 visibleBounds.left + (safeCropRect.x + safeCropRect.width) * visibleBounds.width,
33193 visibleBounds.top + (safeCropRect.y + safeCropRect.height) * visibleBounds.height
33194 ],
33195 [
33196 visibleBounds.left + safeCropRect.x * visibleBounds.width,
33197 visibleBounds.top + (safeCropRect.y + safeCropRect.height) * visibleBounds.height
33198 ]
33199 ];
33200 mat2d_exports.invert(_scratchMat2, camera);
33201 let minWx = Infinity;
33202 let maxWx = -Infinity;
33203 let minWy = Infinity;
33204 let maxWy = -Infinity;
33205 for (const corner of stencilCorners) {
33206 vec2_exports.transformMat2d(_scratchVec2, corner, _scratchMat2);
33207 const w2 = _scratchVec2;
33208 if (w2[0] < minWx) {
33209 minWx = w2[0];
33210 }
33211 if (w2[0] > maxWx) {
33212 maxWx = w2[0];
33213 }
33214 if (w2[1] < minWy) {
33215 minWy = w2[1];
33216 }
33217 if (w2[1] > maxWy) {
33218 maxWy = w2[1];
33219 }
33220 }
33221 if (minWx >= -EPSILON2 && maxWx <= 1 + EPSILON2 && minWy >= -EPSILON2 && maxWy <= 1 + EPSILON2) {
33222 return { pan: safeState.pan, zoom };
33223 }
33224 let dwx = 0;
33225 let dwy = 0;
33226 if (minWx < 0 && maxWx <= 1 + EPSILON2) {
33227 dwx = -minWx;
33228 } else if (maxWx > 1 && minWx >= -EPSILON2) {
33229 dwx = 1 - maxWx;
33230 } else if (minWx < 0 && maxWx > 1) {
33231 dwx = (1 - maxWx - minWx) / 2;
33232 }
33233 if (minWy < 0 && maxWy <= 1 + EPSILON2) {
33234 dwy = -minWy;
33235 } else if (maxWy > 1 && minWy >= -EPSILON2) {
33236 dwy = 1 - maxWy;
33237 } else if (minWy < 0 && maxWy > 1) {
33238 dwy = (1 - maxWy - minWy) / 2;
33239 }
33240 const dsx = camera[0] * dwx + camera[2] * dwy;
33241 const dsy = camera[1] * dwx + camera[3] * dwy;
33242 const newPanX = safeState.pan.x - (visibleBounds.width > 0 ? dsx / visibleBounds.width : 0);
33243 const newPanY = safeState.pan.y - (visibleBounds.height > 0 ? dsy / visibleBounds.height : 0);
33244 return {
33245 pan: { x: newPanX, y: newPanY },
33246 zoom
33247 };
33248 }
33249
33250 // packages/media-editor/build-module/image-editor/core/state.mjs
33251 var STATE_EPSILON = 1e-6;
33252 function nearlyEqual(a, b) {
33253 return Math.abs(a - b) < STATE_EPSILON;
33254 }
33255 function areCropperStatesEqual(a, b) {
33256 const aImage = a.image;
33257 const bImage = b.image;
33258 return aImage?.src === bImage?.src && aImage?.naturalWidth === bImage?.naturalWidth && aImage?.naturalHeight === bImage?.naturalHeight && nearlyEqual(a.pan.x, b.pan.x) && nearlyEqual(a.pan.y, b.pan.y) && nearlyEqual(a.zoom, b.zoom) && nearlyEqual(a.rotation, b.rotation) && a.flip.horizontal === b.flip.horizontal && a.flip.vertical === b.flip.vertical && nearlyEqual(a.cropRect.x, b.cropRect.x) && nearlyEqual(a.cropRect.y, b.cropRect.y) && nearlyEqual(a.cropRect.width, b.cropRect.width) && nearlyEqual(a.cropRect.height, b.cropRect.height);
33259 }
33260 function clampRequestedZoom(state, zoom) {
33261 if (state.image) {
33262 return Math.min(MAX_ZOOM, Math.max(ABSOLUTE_MIN_ZOOM, zoom));
33263 }
33264 return Math.min(MAX_ZOOM, Math.max(MIN_ZOOM, zoom));
33265 }
33266 function operationToAction(state, op) {
33267 switch (op.type) {
33268 case "crop":
33269 return { type: "SET_CROP_RECT", payload: { ...op.rect } };
33270 case "rotate": {
33271 const singleFlip = state.flip.horizontal !== state.flip.vertical;
33272 const fieldDelta = singleFlip ? -op.degrees : op.degrees;
33273 return {
33274 type: "SET_ROTATION",
33275 payload: normalizeRotation(state.rotation + fieldDelta)
33276 };
33277 }
33278 case "flip":
33279 return {
33280 type: "SET_FLIP",
33281 payload: {
33282 ...state.flip,
33283 [op.direction]: !state.flip[op.direction]
33284 }
33285 };
33286 case "zoom":
33287 return { type: "SET_ZOOM", payload: op.factor };
33288 }
33289 }
33290 function enforceContainment(state) {
33291 if (!state.image) {
33292 return state;
33293 }
33294 const imageSize = {
33295 width: state.image.naturalWidth,
33296 height: state.image.naturalHeight
33297 };
33298 const imageAspectRatio = imageSize.width / imageSize.height;
33299 const { pan: panAfterZoom, zoom } = restrictPanZoom(
33300 state,
33301 imageSize,
33302 state.cropRect
33303 );
33304 const cropRect = restrictCropRect(
33305 state.cropRect,
33306 zoom,
33307 state.rotation,
33308 imageAspectRatio
33309 );
33310 let pan = panAfterZoom;
33311 if (cropRect !== state.cropRect) {
33312 ({ pan } = restrictPanZoom(
33313 { ...state, zoom, cropRect },
33314 imageSize,
33315 cropRect
33316 ));
33317 }
33318 if (pan.x === state.pan.x && pan.y === state.pan.y && zoom === state.zoom && cropRect === state.cropRect) {
33319 return state;
33320 }
33321 return { ...state, pan, zoom, cropRect };
33322 }
33323 function commitBase(next) {
33324 if (next.basePan.x === next.pan.x && next.basePan.y === next.pan.y && next.baseZoom === next.zoom && next.baseRotation === next.rotation) {
33325 return next;
33326 }
33327 return {
33328 ...next,
33329 basePan: { x: next.pan.x, y: next.pan.y },
33330 baseZoom: next.zoom,
33331 baseRotation: next.rotation
33332 };
33333 }
33334 function cropperReducer(state, action) {
33335 switch (action.type) {
33336 case "SET_IMAGE":
33337 return commitBase(
33338 enforceContainment({
33339 ...state,
33340 image: action.payload
33341 })
33342 );
33343 case "SET_PAN":
33344 return commitBase(
33345 enforceContainment({
33346 ...state,
33347 pan: action.payload
33348 })
33349 );
33350 case "SET_ZOOM": {
33351 const z = clampRequestedZoom(state, action.payload);
33352 return commitBase(
33353 enforceContainment({
33354 ...state,
33355 zoom: z
33356 })
33357 );
33358 }
33359 case "SET_ZOOM_AT_POINT": {
33360 const z = clampRequestedZoom(state, action.payload.zoom);
33361 return commitBase(
33362 enforceContainment({
33363 ...state,
33364 zoom: z,
33365 pan: action.payload.pan
33366 })
33367 );
33368 }
33369 case "SET_ROTATION": {
33370 const newRotation = normalizeRotation(action.payload);
33371 const singleFlip = state.flip.horizontal !== state.flip.vertical;
33372 const deltaRad = degreesToRadians(
33373 newRotation - state.baseRotation
33374 );
33375 const cos = Math.cos(deltaRad);
33376 const sin = Math.sin(deltaRad) * (singleFlip ? -1 : 1);
33377 const cropCx = state.cropRect.x + state.cropRect.width / 2;
33378 const cropCy = state.cropRect.y + state.cropRect.height / 2;
33379 const ox = cropCx - 0.5;
33380 const oy = cropCy - 0.5;
33381 const dx = state.basePan.x - ox;
33382 const dy = state.basePan.y - oy;
33383 return enforceContainment({
33384 ...state,
33385 rotation: newRotation,
33386 zoom: state.baseZoom,
33387 pan: {
33388 x: ox + cos * dx - sin * dy,
33389 y: oy + sin * dx + cos * dy
33390 }
33391 });
33392 }
33393 case "SNAP_ROTATE_90": {
33394 const rawDir = action.payload.direction;
33395 const singleFlip = state.flip.horizontal !== state.flip.vertical;
33396 const fieldDir = singleFlip ? -rawDir : rawDir;
33397 const rot90 = normalizeRotation(state.rotation + fieldDir * 90);
33398 const rect = state.cropRect;
33399 const cx = rect.x + rect.width / 2;
33400 const cy = rect.y + rect.height / 2;
33401 const newPanX = rawDir === 1 ? -state.pan.y : state.pan.y;
33402 const newPanY = rawDir === 1 ? state.pan.x : -state.pan.x;
33403 return commitBase(
33404 enforceContainment({
33405 ...state,
33406 rotation: rot90,
33407 zoom: state.baseZoom,
33408 pan: { x: newPanX, y: newPanY },
33409 cropRect: {
33410 x: cx - rect.height / 2,
33411 y: cy - rect.width / 2,
33412 width: rect.height,
33413 height: rect.width
33414 }
33415 })
33416 );
33417 }
33418 case "SET_FLIP": {
33419 const oldFlip = state.flip;
33420 const newFlip = action.payload;
33421 const flippedH = oldFlip.horizontal !== newFlip.horizontal;
33422 const flippedV = oldFlip.vertical !== newFlip.vertical;
33423 const rect = state.cropRect;
33424 return commitBase(
33425 enforceContainment({
33426 ...state,
33427 flip: newFlip,
33428 pan: {
33429 x: flippedH ? -state.pan.x : state.pan.x,
33430 y: flippedV ? -state.pan.y : state.pan.y
33431 },
33432 cropRect: {
33433 x: flippedH ? 1 - rect.x - rect.width : rect.x,
33434 y: flippedV ? 1 - rect.y - rect.height : rect.y,
33435 width: rect.width,
33436 height: rect.height
33437 }
33438 })
33439 );
33440 }
33441 case "SET_CROP_RECT":
33442 return commitBase(
33443 enforceContainment({
33444 ...state,
33445 cropRect: action.payload
33446 })
33447 );
33448 case "SETTLE_CROP": {
33449 const rect = state.cropRect;
33450 if (rect.width === 0 || rect.height === 0 || !state.image) {
33451 return state;
33452 }
33453 const fitScale = 1 / Math.max(rect.width, rect.height);
33454 const zoomCap = state.zoom > 0 ? MAX_ZOOM / state.zoom : fitScale;
33455 const s = Math.min(fitScale, zoomCap);
33456 const newW = rect.width * s;
33457 const newH = rect.height * s;
33458 const oldCx = rect.x + rect.width / 2;
33459 const oldCy = rect.y + rect.height / 2;
33460 return commitBase(
33461 enforceContainment({
33462 ...state,
33463 zoom: state.zoom * s,
33464 pan: {
33465 x: (state.pan.x - oldCx + 0.5) * s,
33466 y: (state.pan.y - oldCy + 0.5) * s
33467 },
33468 cropRect: {
33469 x: (1 - newW) / 2,
33470 y: (1 - newH) / 2,
33471 width: newW,
33472 height: newH
33473 }
33474 })
33475 );
33476 }
33477 case "APPLY_OPERATION":
33478 return cropperReducer(
33479 state,
33480 operationToAction(state, action.payload)
33481 );
33482 case "RESET":
33483 return commitBase(
33484 enforceContainment({
33485 ...DEFAULT_STATE2,
33486 image: state.image,
33487 ...action.payload
33488 })
33489 );
33490 }
33491 }
33492
33493 // packages/media-editor/build-module/image-editor/core/setter-helpers.mjs
33494 function buildFocalPointZoomAction(state, requestedZoom) {
33495 const clampedZoom = Math.min(
33496 MAX_ZOOM,
33497 Math.max(getMinZoom(state), requestedZoom)
33498 );
33499 if (clampedZoom === state.zoom) {
33500 return null;
33501 }
33502 const { cropRect } = state;
33503 const focalNormX = cropRect.x + cropRect.width / 2 - 0.5;
33504 const focalNormY = cropRect.y + cropRect.height / 2 - 0.5;
33505 const zoomRatio = 1 - clampedZoom / state.zoom;
33506 const newPanX = state.pan.x + (focalNormX - state.pan.x) * zoomRatio;
33507 const newPanY = state.pan.y + (focalNormY - state.pan.y) * zoomRatio;
33508 const imageSize = state.image ? {
33509 width: state.image.naturalWidth,
33510 height: state.image.naturalHeight
33511 } : { width: 1, height: 1 };
33512 const { pan: clampedPan } = restrictPanZoom(
33513 {
33514 ...state,
33515 zoom: clampedZoom,
33516 pan: { x: newPanX, y: newPanY }
33517 },
33518 imageSize,
33519 state.cropRect
33520 );
33521 return {
33522 type: "SET_ZOOM_AT_POINT",
33523 payload: { zoom: clampedZoom, pan: clampedPan }
33524 };
33525 }
33526
33527 // packages/media-editor/build-module/image-editor/react/hooks/build-cropper-setters.mjs
33528 function buildCropperSetters(dispatchCropperAction, getCropperState) {
33529 return {
33530 setPan: (pan) => dispatchCropperAction({ type: "SET_PAN", payload: pan }),
33531 setZoom: (zoom) => {
33532 const action = buildFocalPointZoomAction(getCropperState(), zoom);
33533 if (action) {
33534 dispatchCropperAction(action);
33535 }
33536 },
33537 setZoomAtPoint: (zoom, pan) => dispatchCropperAction({
33538 type: "SET_ZOOM_AT_POINT",
33539 payload: { zoom, pan }
33540 }),
33541 setRotation: (rotation) => dispatchCropperAction({
33542 type: "SET_ROTATION",
33543 payload: rotation
33544 }),
33545 setFlip: (flip4) => dispatchCropperAction({ type: "SET_FLIP", payload: flip4 }),
33546 toggleFlip: (direction) => {
33547 const { flip: flip4 } = getCropperState();
33548 dispatchCropperAction({
33549 type: "SET_FLIP",
33550 payload: { ...flip4, [direction]: !flip4[direction] }
33551 });
33552 },
33553 snapRotate90: (direction) => dispatchCropperAction({
33554 type: "SNAP_ROTATE_90",
33555 payload: { direction }
33556 }),
33557 setCropRect: (rect) => dispatchCropperAction({
33558 type: "SET_CROP_RECT",
33559 payload: rect
33560 }),
33561 settleCrop: () => dispatchCropperAction({ type: "SETTLE_CROP" }),
33562 applyOperation: (op) => dispatchCropperAction({
33563 type: "APPLY_OPERATION",
33564 payload: op
33565 })
33566 };
33567 }
33568
33569 // packages/media-editor/build-module/image-editor/react/components/cropper.mjs
33570 var import_element117 = __toESM(require_element(), 1);
33571 var import_i18n38 = __toESM(require_i18n(), 1);
33572
33573 // packages/media-editor/build-module/image-editor/core/crop-rect.mjs
33574 function computeInscribedRect(aspectRatio, visualSize) {
33575 let w2 = 1;
33576 let h = 1;
33577 if (aspectRatio && aspectRatio > 0 && visualSize.width > 0) {
33578 const normalizedRatio = aspectRatio * visualSize.height / visualSize.width;
33579 if (normalizedRatio <= 1) {
33580 w2 = normalizedRatio;
33581 } else {
33582 h = 1 / normalizedRatio;
33583 }
33584 }
33585 return {
33586 x: (1 - w2) / 2,
33587 y: (1 - h) / 2,
33588 width: w2,
33589 height: h
33590 };
33591 }
33592
33593 // packages/media-editor/build-module/image-editor/core/stencil-math.mjs
33594 function getMinCropPixels(displayScale) {
33595 if (displayScale <= 0) {
33596 return MIN_CROP_PIXELS;
33597 }
33598 return Math.max(MIN_CROP_PIXELS, MIN_CROP_SCREEN_PX / displayScale);
33599 }
33600 var DEFAULT_MIN_CROP_SIZE = { width: 0.05, height: 0.05 };
33601 function computeFreeResizeRect(drag2, clientX, clientY, imageSize, bounds, minCropSize = DEFAULT_MIN_CROP_SIZE) {
33602 const dx = imageSize.width > 0 ? (clientX - drag2.startX) / imageSize.width : 0;
33603 const dy = imageSize.height > 0 ? (clientY - drag2.startY) / imageSize.height : 0;
33604 const s = drag2.startRect;
33605 const handle = drag2.handle;
33606 let edgeTop = s.y;
33607 let edgeBottom = s.y + s.height;
33608 let edgeLeft = s.x;
33609 let edgeRight = s.x + s.width;
33610 if (handle === "n" || handle === "nw" || handle === "ne") {
33611 edgeTop = Math.max(
33612 bounds.minY,
33613 Math.min(s.y + dy, edgeBottom - minCropSize.height)
33614 );
33615 }
33616 if (handle === "s" || handle === "sw" || handle === "se") {
33617 edgeBottom = Math.max(
33618 edgeTop + minCropSize.height,
33619 Math.min(s.y + s.height + dy, bounds.maxY)
33620 );
33621 }
33622 if (handle === "w" || handle === "nw" || handle === "sw") {
33623 edgeLeft = Math.max(
33624 bounds.minX,
33625 Math.min(s.x + dx, edgeRight - minCropSize.width)
33626 );
33627 }
33628 if (handle === "e" || handle === "ne" || handle === "se") {
33629 edgeRight = Math.max(
33630 edgeLeft + minCropSize.width,
33631 Math.min(s.x + s.width + dx, bounds.maxX)
33632 );
33633 }
33634 return {
33635 x: edgeLeft,
33636 y: edgeTop,
33637 width: edgeRight - edgeLeft,
33638 height: edgeBottom - edgeTop
33639 };
33640 }
33641 function computeLockedResizeRect(drag2, clientX, clientY, imageSize, bounds, normalizedRatio, minCropSize = DEFAULT_MIN_CROP_SIZE, driverAxis) {
33642 if (normalizedRatio <= 0 || imageSize.width <= 0 || imageSize.height <= 0) {
33643 return { ...drag2.startRect };
33644 }
33645 const dx = (clientX - drag2.startX) / imageSize.width;
33646 const dy = (clientY - drag2.startY) / imageSize.height;
33647 const s = drag2.startRect;
33648 const handle = drag2.handle;
33649 const anchorX = handle === "nw" || handle === "sw" ? s.x + s.width : s.x;
33650 const anchorY = handle === "nw" || handle === "ne" ? s.y + s.height : s.y;
33651 const dirX = handle === "nw" || handle === "sw" ? -1 : 1;
33652 const dirY = handle === "nw" || handle === "ne" ? -1 : 1;
33653 const draggedX = (handle === "nw" || handle === "sw" ? s.x : s.x + s.width) + dx;
33654 const draggedY = (handle === "nw" || handle === "ne" ? s.y : s.y + s.height) + dy;
33655 let distW = (draggedX - anchorX) * dirX;
33656 let distH = (draggedY - anchorY) * dirY;
33657 const minDistW = Math.max(
33658 minCropSize.width,
33659 minCropSize.height * normalizedRatio
33660 );
33661 const minDistH = minDistW / normalizedRatio;
33662 distW = Math.max(distW, minDistW);
33663 distH = Math.max(distH, minDistH);
33664 const pixelRatio = normalizedRatio * imageSize.width / imageSize.height;
33665 const isWidthDriver = driverAxis === "width" || !driverAxis && distW * imageSize.width / (distH * imageSize.height) > pixelRatio;
33666 if (isWidthDriver) {
33667 distH = distW / normalizedRatio;
33668 } else {
33669 distW = distH * normalizedRatio;
33670 }
33671 const maxW = dirX > 0 ? bounds.maxX - anchorX : anchorX - bounds.minX;
33672 const maxH = dirY > 0 ? bounds.maxY - anchorY : anchorY - bounds.minY;
33673 if (distW > maxW) {
33674 distW = maxW;
33675 distH = distW / normalizedRatio;
33676 }
33677 if (distH > maxH) {
33678 distH = maxH;
33679 distW = distH * normalizedRatio;
33680 }
33681 distW = Math.max(distW, minDistW);
33682 distH = Math.max(distH, minDistH);
33683 const newX = dirX > 0 ? anchorX : anchorX - distW;
33684 const newY = dirY > 0 ? anchorY : anchorY - distH;
33685 return { x: newX, y: newY, width: distW, height: distH };
33686 }
33687 function computeShiftLockedResizeRect(drag2, clientX, clientY, imageSize, bounds, minCropSize = DEFAULT_MIN_CROP_SIZE) {
33688 const s = drag2.startRect;
33689 const pixelW = s.width * imageSize.width;
33690 const pixelH = s.height * imageSize.height;
33691 if (pixelH <= 0 || pixelW <= 0) {
33692 return computeFreeResizeRect(
33693 drag2,
33694 clientX,
33695 clientY,
33696 imageSize,
33697 bounds,
33698 minCropSize
33699 );
33700 }
33701 const normalizedRatio = s.width / s.height;
33702 const handle = drag2.handle;
33703 if (handle === "nw" || handle === "ne" || handle === "sw" || handle === "se") {
33704 return computeLockedResizeRect(
33705 drag2,
33706 clientX,
33707 clientY,
33708 imageSize,
33709 bounds,
33710 normalizedRatio,
33711 minCropSize
33712 );
33713 }
33714 const free = computeFreeResizeRect(
33715 drag2,
33716 clientX,
33717 clientY,
33718 imageSize,
33719 bounds,
33720 minCropSize
33721 );
33722 if (handle === "n" || handle === "s") {
33723 let newHeight2 = free.height;
33724 let newWidth2 = newHeight2 * normalizedRatio;
33725 const centerX = s.x + s.width / 2;
33726 const maxWidth = Math.min(centerX - bounds.minX, bounds.maxX - centerX) * 2;
33727 if (newWidth2 > maxWidth) {
33728 newWidth2 = maxWidth;
33729 newHeight2 = newWidth2 / normalizedRatio;
33730 }
33731 const minHeight = Math.max(
33732 minCropSize.height,
33733 minCropSize.width / normalizedRatio
33734 );
33735 if (newHeight2 < minHeight) {
33736 newHeight2 = minHeight;
33737 newWidth2 = newHeight2 * normalizedRatio;
33738 }
33739 const newY = handle === "n" ? s.y + s.height - newHeight2 : s.y;
33740 return {
33741 x: centerX - newWidth2 / 2,
33742 y: newY,
33743 width: newWidth2,
33744 height: newHeight2
33745 };
33746 }
33747 let newWidth = free.width;
33748 let newHeight = newWidth / normalizedRatio;
33749 const centerY = s.y + s.height / 2;
33750 const maxHeight = Math.min(centerY - bounds.minY, bounds.maxY - centerY) * 2;
33751 if (newHeight > maxHeight) {
33752 newHeight = maxHeight;
33753 newWidth = newHeight * normalizedRatio;
33754 }
33755 const minWidth = Math.max(
33756 minCropSize.width,
33757 minCropSize.height * normalizedRatio
33758 );
33759 if (newWidth < minWidth) {
33760 newWidth = minWidth;
33761 newHeight = newWidth / normalizedRatio;
33762 }
33763 const newX = handle === "w" ? s.x + s.width - newWidth : s.x;
33764 return {
33765 x: newX,
33766 y: centerY - newHeight / 2,
33767 width: newWidth,
33768 height: newHeight
33769 };
33770 }
33771
33772 // packages/media-editor/build-module/image-editor/react/hooks/use-interaction.mjs
33773 var import_element110 = __toESM(require_element(), 1);
33774
33775 // packages/media-editor/build-module/image-editor/core/interaction-controller.mjs
33776 var DOUBLE_TAP_TIME = 300;
33777 var DOUBLE_TAP_DISTANCE = 30;
33778 var ZOOM_ANIMATION_DURATION = 200;
33779 function getImageSizeFromState(state) {
33780 return state.image ? { width: state.image.naturalWidth, height: state.image.naturalHeight } : { width: 1, height: 1 };
33781 }
33782 function getTouchDistance(t1, t2) {
33783 const dx = t1.clientX - t2.clientX;
33784 const dy = t1.clientY - t2.clientY;
33785 return Math.sqrt(dx * dx + dy * dy);
33786 }
33787 var InteractionController = class {
33788 options;
33789 /** Current drag/zoom status. */
33790 isDragging = false;
33791 isZooming = false;
33792 /** Active drag state during pointer interactions. */
33793 drag = null;
33794 /** Active touch state during touch interactions. */
33795 touch = null;
33796 /** Cleanup function for active touch listeners on document. */
33797 touchCleanup = null;
33798 /**
33799 * Cleanup function for active pointer-drag listeners on the
33800 * captured element. Set while a pointer drag is in progress so
33801 * `destroy()` can tear the drag down cleanly if the consumer
33802 * unmounts mid-drag. Cleared on pointerup/lostpointercapture.
33803 */
33804 pointerCleanup = null;
33805 /** Last tap info for double-tap detection. */
33806 lastTap = null;
33807 /** Timer for the zoom animation state (double-tap). */
33808 zoomTimer;
33809 /** Timer for wheel gesture debounce. */
33810 wheelGestureTimer;
33811 /** Whether a wheel gesture is currently active. */
33812 wheelGestureActive = false;
33813 /** Current requestAnimationFrame ID. */
33814 rafId = 0;
33815 constructor(options) {
33816 this.options = options;
33817 }
33818 /** Read minZoom lazily so option changes take effect immediately. */
33819 get minZoom() {
33820 return this.options.minZoom ?? MIN_ZOOM;
33821 }
33822 /** Read maxZoom lazily so option changes take effect immediately. */
33823 get maxZoom() {
33824 return this.options.maxZoom ?? MAX_ZOOM;
33825 }
33826 /** Read zoomSpeed lazily so option changes take effect immediately. */
33827 get zoomSpeed() {
33828 return this.options.zoomSpeed ?? DEFAULT_WHEEL_ZOOM_SPEED;
33829 }
33830 /** Read keyboardStep lazily so option changes take effect immediately. */
33831 get keyboardStep() {
33832 return this.options.keyboardStep ?? DEFAULT_KEYBOARD_STEP;
33833 }
33834 /**
33835 * Get the keyboard pan step, including modifier-based coarse movement.
33836 *
33837 * @param event The native KeyboardEvent.
33838 * @return The normalized pan step.
33839 */
33840 getKeyboardStep(event) {
33841 return event.shiftKey ? this.keyboardStep * KEYBOARD_SHIFT_STEP_MULTIPLIER : this.keyboardStep;
33842 }
33843 /** Read doubleTapZoom lazily so option changes take effect immediately. */
33844 get doubleTapZoom() {
33845 return this.options.doubleTapZoom ?? 2;
33846 }
33847 /**
33848 * Update the drag/zoom status and notify via callback if changed.
33849 *
33850 * @param update Partial status with isDragging and/or isZooming.
33851 */
33852 setStatus(update2) {
33853 let changed = false;
33854 if (update2.isDragging !== void 0 && update2.isDragging !== this.isDragging) {
33855 this.isDragging = update2.isDragging;
33856 changed = true;
33857 }
33858 if (update2.isZooming !== void 0 && update2.isZooming !== this.isZooming) {
33859 this.isZooming = update2.isZooming;
33860 changed = true;
33861 }
33862 if (changed) {
33863 this.options.onStatusChange?.({
33864 isDragging: this.isDragging,
33865 isZooming: this.isZooming
33866 });
33867 }
33868 }
33869 /**
33870 * Handle a pointer-down event on the container element.
33871 *
33872 * Initiates a drag (pan) interaction. Captures the pointer on the
33873 * provided element and registers pointermove/pointerup/lostpointercapture
33874 * listeners for the duration of the drag.
33875 *
33876 * @param e The native PointerEvent.
33877 * @param el The DOM element to capture the pointer on.
33878 */
33879 handlePointerDown(e, el) {
33880 if (e.button !== 0) {
33881 return;
33882 }
33883 if (e.pointerType === "touch") {
33884 return;
33885 }
33886 e.preventDefault();
33887 const ownerDoc = el.ownerDocument;
33888 if (ownerDoc?.activeElement instanceof HTMLElement && ownerDoc.activeElement !== el) {
33889 ownerDoc.activeElement.blur();
33890 }
33891 el.focus();
33892 el.setPointerCapture(e.pointerId);
33893 this.setStatus({ isDragging: true });
33894 this.options.onGestureStart?.();
33895 const currentState = this.options.getState();
33896 this.drag = {
33897 startX: e.clientX,
33898 startY: e.clientY,
33899 startPanX: currentState.pan.x,
33900 startPanY: currentState.pan.y
33901 };
33902 const onPointerMove = (moveEvent) => {
33903 const drag2 = this.drag;
33904 if (!drag2) {
33905 return;
33906 }
33907 const pe = moveEvent;
33908 cancelAnimationFrame(this.rafId);
33909 this.rafId = requestAnimationFrame(() => {
33910 const s = this.options.getState();
33911 const imgSize = this.options.getImageSize();
33912 const containerSize = this.options.getContainerSize();
33913 const panSize = imgSize ?? containerSize;
33914 const deltaX = panSize.width > 0 ? (pe.clientX - drag2.startX) / panSize.width : 0;
33915 const deltaY = panSize.height > 0 ? (pe.clientY - drag2.startY) / panSize.height : 0;
33916 const { pan: newCrop } = restrictPanZoom(
33917 {
33918 ...s,
33919 pan: {
33920 x: drag2.startPanX + deltaX,
33921 y: drag2.startPanY + deltaY
33922 }
33923 },
33924 getImageSizeFromState(s),
33925 s.cropRect
33926 );
33927 this.options.actions.setPan(newCrop);
33928 });
33929 };
33930 const removeListeners = () => {
33931 el.removeEventListener("pointermove", onPointerMove);
33932 el.removeEventListener("pointerup", onPointerUp);
33933 el.removeEventListener("lostpointercapture", onPointerUp);
33934 };
33935 const onPointerUp = () => {
33936 this.setStatus({ isDragging: false });
33937 this.options.onGestureEnd?.();
33938 this.drag = null;
33939 cancelAnimationFrame(this.rafId);
33940 removeListeners();
33941 this.pointerCleanup = null;
33942 };
33943 el.addEventListener("pointermove", onPointerMove);
33944 el.addEventListener("pointerup", onPointerUp);
33945 el.addEventListener("lostpointercapture", onPointerUp);
33946 this.pointerCleanup = removeListeners;
33947 }
33948 /**
33949 * Handle a wheel event on the container element.
33950 *
33951 * Implements focal-point zoom: the point under the cursor stays
33952 * stationary on screen while the zoom level changes.
33953 *
33954 * Must be registered with `{ passive: false }` to allow preventDefault.
33955 *
33956 * @param e The native WheelEvent.
33957 */
33958 handleWheel(e) {
33959 e.preventDefault();
33960 if (this.drag) {
33961 return;
33962 }
33963 if (!this.wheelGestureActive) {
33964 this.wheelGestureActive = true;
33965 this.options.onGestureStart?.();
33966 }
33967 clearTimeout(this.wheelGestureTimer);
33968 this.wheelGestureTimer = setTimeout(() => {
33969 this.wheelGestureActive = false;
33970 this.options.onGestureEnd?.();
33971 }, DOUBLE_TAP_TIME);
33972 const s = this.options.getState();
33973 const delta = -e.deltaY * this.zoomSpeed;
33974 const newZoom = Math.min(
33975 this.maxZoom,
33976 Math.max(this.minZoom, s.zoom + delta)
33977 );
33978 if (newZoom === s.zoom) {
33979 return;
33980 }
33981 const containerSize = this.options.getContainerSize();
33982 const imgSize = this.options.getImageSize();
33983 const visSize = imgSize ?? containerSize;
33984 const target = e.currentTarget;
33985 const rect = target instanceof Element ? target.getBoundingClientRect() : void 0;
33986 if (visSize.width > 0 && visSize.height > 0 && rect) {
33987 const fx = e.clientX - rect.left - containerSize.width / 2;
33988 const fy = e.clientY - rect.top - containerSize.height / 2;
33989 const zoomRatio = 1 - newZoom / s.zoom;
33990 const focalNormX = fx / visSize.width;
33991 const focalNormY = fy / visSize.height;
33992 const newCropX = s.pan.x + (focalNormX - s.pan.x) * zoomRatio;
33993 const newCropY = s.pan.y + (focalNormY - s.pan.y) * zoomRatio;
33994 const { pan: clampedCrop } = restrictPanZoom(
33995 { ...s, zoom: newZoom, pan: { x: newCropX, y: newCropY } },
33996 getImageSizeFromState(s),
33997 s.cropRect
33998 );
33999 this.options.actions.setZoomAtPoint(newZoom, clampedCrop);
34000 } else {
34001 this.options.actions.setZoom(newZoom);
34002 }
34003 }
34004 /**
34005 * Handle a touch-start event on the container element.
34006 *
34007 * Supports single-finger pan, two-finger pinch zoom, and
34008 * double-tap to toggle between fit and 2x zoom. Registers
34009 * touchmove/touchend/touchcancel on the provided document for the
34010 * duration of the gesture.
34011 *
34012 * @param e The native TouchEvent.
34013 * @param containerRect The bounding rect of the container element.
34014 * @param doc The document to register move/end listeners on.
34015 * Defaults to globalThis.document. Pass the iframe's
34016 * contentDocument when running inside an iframe.
34017 */
34018 handleTouchStart(e, containerRect, doc = document) {
34019 if (this.touch && e.touches.length === 2) {
34020 const s = this.options.getState();
34021 const distance2 = getTouchDistance(e.touches[0], e.touches[1]);
34022 const midX = (e.touches[0].clientX + e.touches[1].clientX) / 2;
34023 const midY = (e.touches[0].clientY + e.touches[1].clientY) / 2;
34024 this.touch.didPinch = true;
34025 this.touch.startDistance = distance2;
34026 this.touch.startZoom = s.zoom;
34027 this.touch.startPanX = s.pan.x;
34028 this.touch.startPanY = s.pan.y;
34029 this.touch.startMidX = midX;
34030 this.touch.startMidY = midY;
34031 this.touch.containerRect = containerRect;
34032 this.setStatus({ isDragging: false });
34033 return;
34034 }
34035 if (e.touches.length === 1) {
34036 const tapX = e.touches[0].clientX;
34037 const tapY = e.touches[0].clientY;
34038 if (this.tryDoubleTap(e, tapX, tapY, containerRect)) {
34039 return;
34040 }
34041 const currentState = this.options.getState();
34042 this.touch = {
34043 startDistance: 0,
34044 startZoom: currentState.zoom,
34045 lastTouchX: e.touches[0].clientX,
34046 lastTouchY: e.touches[0].clientY,
34047 startPanX: currentState.pan.x,
34048 startPanY: currentState.pan.y,
34049 containerRect,
34050 startMidX: 0,
34051 startMidY: 0,
34052 didPinch: false,
34053 moved: false
34054 };
34055 this.options.onGestureStart?.();
34056 } else if (e.touches.length === 2) {
34057 const currentState = this.options.getState();
34058 const distance2 = getTouchDistance(e.touches[0], e.touches[1]);
34059 const midX = (e.touches[0].clientX + e.touches[1].clientX) / 2;
34060 const midY = (e.touches[0].clientY + e.touches[1].clientY) / 2;
34061 this.touch = {
34062 startDistance: distance2,
34063 startZoom: currentState.zoom,
34064 lastTouchX: 0,
34065 lastTouchY: 0,
34066 startPanX: currentState.pan.x,
34067 startPanY: currentState.pan.y,
34068 containerRect,
34069 startMidX: midX,
34070 startMidY: midY,
34071 didPinch: true,
34072 moved: false
34073 };
34074 this.options.onGestureStart?.();
34075 }
34076 const onTouchEnd = () => {
34077 this.touch = null;
34078 this.touchCleanup = null;
34079 cancelAnimationFrame(this.rafId);
34080 doc.removeEventListener("touchmove", this.handleTouchMove);
34081 doc.removeEventListener("touchend", onTouchEnd);
34082 doc.removeEventListener("touchcancel", onTouchEnd);
34083 this.setStatus({ isDragging: false });
34084 this.options.onGestureEnd?.();
34085 };
34086 this.touchCleanup?.();
34087 doc.addEventListener("touchmove", this.handleTouchMove, {
34088 passive: false
34089 });
34090 doc.addEventListener("touchend", onTouchEnd);
34091 doc.addEventListener("touchcancel", onTouchEnd);
34092 this.touchCleanup = onTouchEnd;
34093 }
34094 // Handle a touchmove event during an active touch gesture. Decides pinch
34095 // vs. pan based on current `moveEvent.touches.length`, so the gesture
34096 // can transition between modes without timing sensitivity (e.g. fingers
34097 // landing 0ms vs 200ms apart). Arrow-property binding so `this` stays
34098 // attached when used as an event listener.
34099 handleTouchMove = (moveEvent) => {
34100 const touch = this.touch;
34101 if (!touch) {
34102 return;
34103 }
34104 moveEvent.preventDefault();
34105 cancelAnimationFrame(this.rafId);
34106 this.rafId = requestAnimationFrame(() => {
34107 const s = this.options.getState();
34108 if (moveEvent.touches.length === 2) {
34109 if (!touch.didPinch) {
34110 touch.didPinch = true;
34111 touch.startDistance = getTouchDistance(
34112 moveEvent.touches[0],
34113 moveEvent.touches[1]
34114 );
34115 touch.startZoom = s.zoom;
34116 touch.startPanX = s.pan.x;
34117 touch.startPanY = s.pan.y;
34118 touch.startMidX = (moveEvent.touches[0].clientX + moveEvent.touches[1].clientX) / 2;
34119 touch.startMidY = (moveEvent.touches[0].clientY + moveEvent.touches[1].clientY) / 2;
34120 this.setStatus({ isDragging: false });
34121 return;
34122 }
34123 const latestContainerSize = this.options.getContainerSize();
34124 const latestImageSize = this.options.getImageSize();
34125 const t0 = moveEvent.touches[0];
34126 const t1 = moveEvent.touches[1];
34127 const currentDistance = getTouchDistance(t0, t1);
34128 const ratio = currentDistance / touch.startDistance;
34129 const newZoom = Math.min(
34130 this.maxZoom,
34131 Math.max(this.minZoom, touch.startZoom * ratio)
34132 );
34133 const visSize = latestImageSize ?? latestContainerSize;
34134 const rect = touch.containerRect;
34135 if (visSize.width > 0 && visSize.height > 0 && rect) {
34136 const mx = (t0.clientX + t1.clientX) / 2 - rect.left - latestContainerSize.width / 2;
34137 const my = (t0.clientY + t1.clientY) / 2 - rect.top - latestContainerSize.height / 2;
34138 const startMx = touch.startMidX - rect.left - latestContainerSize.width / 2;
34139 const startMy = touch.startMidY - rect.top - latestContainerSize.height / 2;
34140 const panDx = visSize.width > 0 ? (mx - startMx) / visSize.width : 0;
34141 const panDy = visSize.height > 0 ? (my - startMy) / visSize.height : 0;
34142 const zoomRatio = touch.startZoom !== 0 ? 1 - newZoom / touch.startZoom : 0;
34143 const startFocalNormX = startMx / visSize.width;
34144 const startFocalNormY = startMy / visSize.height;
34145 const newCropX = touch.startPanX + panDx + (startFocalNormX - touch.startPanX) * zoomRatio;
34146 const newCropY = touch.startPanY + panDy + (startFocalNormY - touch.startPanY) * zoomRatio;
34147 const { pan: clampedCrop } = restrictPanZoom(
34148 {
34149 ...s,
34150 zoom: newZoom,
34151 pan: { x: newCropX, y: newCropY }
34152 },
34153 getImageSizeFromState(s),
34154 s.cropRect
34155 );
34156 this.options.actions.setZoomAtPoint(newZoom, clampedCrop);
34157 } else if (newZoom !== s.zoom) {
34158 this.options.actions.setZoom(newZoom);
34159 }
34160 } else if (moveEvent.touches.length === 1 && !touch.didPinch) {
34161 if (!touch.moved) {
34162 touch.moved = true;
34163 this.setStatus({ isDragging: true });
34164 }
34165 const panImageSize = this.options.getImageSize();
34166 const panContainerSize = this.options.getContainerSize();
34167 const panSize = panImageSize ?? panContainerSize;
34168 const deltaX = panSize.width > 0 ? (moveEvent.touches[0].clientX - touch.lastTouchX) / panSize.width : 0;
34169 const deltaY = panSize.height > 0 ? (moveEvent.touches[0].clientY - touch.lastTouchY) / panSize.height : 0;
34170 const { pan: newCrop } = restrictPanZoom(
34171 {
34172 ...s,
34173 pan: {
34174 x: touch.startPanX + deltaX,
34175 y: touch.startPanY + deltaY
34176 }
34177 },
34178 getImageSizeFromState(s),
34179 s.cropRect
34180 );
34181 this.options.actions.setPan(newCrop);
34182 }
34183 });
34184 };
34185 // Handle double-tap-to-toggle-zoom. On a second tap within the configured
34186 // time/distance threshold, toggles zoom between `minZoom` and
34187 // `doubleTapZoom` around the tap point and dispatches. Returns `true` if
34188 // the tap was handled as a double-tap (caller should early-return),
34189 // `false` otherwise (caller proceeds with normal single-tap handling).
34190 // Either way, records the tap for next time.
34191 tryDoubleTap(e, tapX, tapY, containerRect) {
34192 const now = Date.now();
34193 const lastTap = this.lastTap;
34194 if (!lastTap) {
34195 this.lastTap = { time: now, x: tapX, y: tapY };
34196 return false;
34197 }
34198 const timeDelta = now - lastTap.time;
34199 const distDelta = Math.sqrt(
34200 (tapX - lastTap.x) ** 2 + (tapY - lastTap.y) ** 2
34201 );
34202 const isDoubleTap = timeDelta < DOUBLE_TAP_TIME && distDelta < DOUBLE_TAP_DISTANCE;
34203 if (!isDoubleTap) {
34204 this.lastTap = { time: now, x: tapX, y: tapY };
34205 return false;
34206 }
34207 e.preventDefault();
34208 this.lastTap = null;
34209 const currentState = this.options.getState();
34210 const containerSize = this.options.getContainerSize();
34211 const imgSize = this.options.getImageSize();
34212 const targetZoom = currentState.zoom > (this.minZoom + this.doubleTapZoom) / 2 ? this.minZoom : this.doubleTapZoom;
34213 const visSize = imgSize ?? containerSize;
34214 this.setStatus({ isZooming: true });
34215 clearTimeout(this.zoomTimer);
34216 this.zoomTimer = setTimeout(() => {
34217 this.setStatus({ isZooming: false });
34218 }, ZOOM_ANIMATION_DURATION);
34219 this.options.onGestureStart?.();
34220 if (visSize.width > 0 && visSize.height > 0) {
34221 const fx = tapX - containerRect.left - containerSize.width / 2;
34222 const fy = tapY - containerRect.top - containerSize.height / 2;
34223 const zoomRatio = 1 - targetZoom / currentState.zoom;
34224 const focalNormX = fx / visSize.width;
34225 const focalNormY = fy / visSize.height;
34226 const newCropX = currentState.pan.x + (focalNormX - currentState.pan.x) * zoomRatio;
34227 const newCropY = currentState.pan.y + (focalNormY - currentState.pan.y) * zoomRatio;
34228 const { pan: clampedCrop } = restrictPanZoom(
34229 {
34230 ...currentState,
34231 zoom: targetZoom,
34232 pan: { x: newCropX, y: newCropY }
34233 },
34234 getImageSizeFromState(currentState),
34235 currentState.cropRect
34236 );
34237 this.options.actions.setZoomAtPoint(targetZoom, clampedCrop);
34238 } else {
34239 this.options.actions.setZoom(targetZoom);
34240 }
34241 this.options.onGestureEnd?.();
34242 return true;
34243 }
34244 /**
34245 * Handle a keydown event on the container element.
34246 *
34247 * Supports arrow keys for panning, +/- for zoom, and r/R for rotation.
34248 *
34249 * @param e The native KeyboardEvent.
34250 */
34251 handleKeyDown(e) {
34252 const currentState = this.options.getState();
34253 switch (e.key) {
34254 case "ArrowUp": {
34255 e.preventDefault();
34256 const keyboardStep = this.getKeyboardStep(e);
34257 const { pan: newCrop } = restrictPanZoom(
34258 {
34259 ...currentState,
34260 pan: {
34261 x: currentState.pan.x,
34262 y: currentState.pan.y + keyboardStep
34263 }
34264 },
34265 getImageSizeFromState(currentState),
34266 currentState.cropRect
34267 );
34268 this.options.actions.setPan(newCrop);
34269 break;
34270 }
34271 case "ArrowDown": {
34272 e.preventDefault();
34273 const keyboardStep = this.getKeyboardStep(e);
34274 const { pan: newCrop } = restrictPanZoom(
34275 {
34276 ...currentState,
34277 pan: {
34278 x: currentState.pan.x,
34279 y: currentState.pan.y - keyboardStep
34280 }
34281 },
34282 getImageSizeFromState(currentState),
34283 currentState.cropRect
34284 );
34285 this.options.actions.setPan(newCrop);
34286 break;
34287 }
34288 case "ArrowLeft": {
34289 e.preventDefault();
34290 const keyboardStep = this.getKeyboardStep(e);
34291 const { pan: newCrop } = restrictPanZoom(
34292 {
34293 ...currentState,
34294 pan: {
34295 x: currentState.pan.x + keyboardStep,
34296 y: currentState.pan.y
34297 }
34298 },
34299 getImageSizeFromState(currentState),
34300 currentState.cropRect
34301 );
34302 this.options.actions.setPan(newCrop);
34303 break;
34304 }
34305 case "ArrowRight": {
34306 e.preventDefault();
34307 const keyboardStep = this.getKeyboardStep(e);
34308 const { pan: newCrop } = restrictPanZoom(
34309 {
34310 ...currentState,
34311 pan: {
34312 x: currentState.pan.x - keyboardStep,
34313 y: currentState.pan.y
34314 }
34315 },
34316 getImageSizeFromState(currentState),
34317 currentState.cropRect
34318 );
34319 this.options.actions.setPan(newCrop);
34320 break;
34321 }
34322 case "+":
34323 case "=": {
34324 e.preventDefault();
34325 const newZoom = Math.min(
34326 this.maxZoom,
34327 Math.max(this.minZoom, currentState.zoom + 0.5)
34328 );
34329 this.options.actions.setZoom(newZoom);
34330 break;
34331 }
34332 case "-":
34333 case "_": {
34334 e.preventDefault();
34335 const newZoom = Math.min(
34336 this.maxZoom,
34337 Math.max(this.minZoom, currentState.zoom - 0.5)
34338 );
34339 this.options.actions.setZoom(newZoom);
34340 break;
34341 }
34342 case "r":
34343 case "R": {
34344 if (e.metaKey || e.ctrlKey || e.altKey) {
34345 break;
34346 }
34347 e.preventDefault();
34348 this.options.actions.snapRotate90(e.shiftKey ? -1 : 1);
34349 break;
34350 }
34351 case "h":
34352 case "H": {
34353 if (e.metaKey || e.ctrlKey || e.altKey || e.shiftKey) {
34354 break;
34355 }
34356 e.preventDefault();
34357 this.options.actions.toggleFlip?.("horizontal");
34358 break;
34359 }
34360 case "v":
34361 case "V": {
34362 if (e.metaKey || e.ctrlKey || e.altKey || e.shiftKey) {
34363 break;
34364 }
34365 e.preventDefault();
34366 this.options.actions.toggleFlip?.("vertical");
34367 break;
34368 }
34369 }
34370 }
34371 /**
34372 * Clean up all timers, animation frames, and active touch listeners.
34373 *
34374 * Must be called when the controller is no longer needed (e.g., on
34375 * component unmount or element removal).
34376 */
34377 destroy() {
34378 cancelAnimationFrame(this.rafId);
34379 clearTimeout(this.zoomTimer);
34380 clearTimeout(this.wheelGestureTimer);
34381 this.touchCleanup?.();
34382 this.touchCleanup = null;
34383 this.pointerCleanup?.();
34384 this.pointerCleanup = null;
34385 this.drag = null;
34386 this.touch = null;
34387 this.lastTap = null;
34388 this.wheelGestureActive = false;
34389 this.isDragging = false;
34390 this.isZooming = false;
34391 }
34392 };
34393
34394 // packages/media-editor/build-module/image-editor/react/hooks/use-interaction.mjs
34395 var KEYBOARD_INTERACTION_IDLE_MS = 300;
34396 function isHandledKeyboardPan(event) {
34397 switch (event.key) {
34398 case "ArrowUp":
34399 case "ArrowDown":
34400 case "ArrowLeft":
34401 case "ArrowRight":
34402 return true;
34403 default:
34404 return false;
34405 }
34406 }
34407 function isHandledKeyboardZoom(event) {
34408 switch (event.key) {
34409 case "+":
34410 case "=":
34411 case "-":
34412 case "_":
34413 return true;
34414 default:
34415 return false;
34416 }
34417 }
34418 function useInteraction(state, actions, containerSize, imageSize, options) {
34419 const [isDragging, setIsDragging] = (0, import_element110.useState)(false);
34420 const [isZooming, setIsZooming] = (0, import_element110.useState)(false);
34421 const [isGestureActive, setIsGestureActive] = (0, import_element110.useState)(false);
34422 const [isKeyboardPanning, setIsKeyboardPanning] = (0, import_element110.useState)(false);
34423 const keyboardInteractionTimerRef = (0, import_element110.useRef)();
34424 const isKeyboardGestureActiveRef = (0, import_element110.useRef)(false);
34425 const stateRef = (0, import_element110.useRef)(state);
34426 stateRef.current = state;
34427 const containerSizeRef = (0, import_element110.useRef)(containerSize);
34428 containerSizeRef.current = containerSize;
34429 const imageSizeRef = (0, import_element110.useRef)(imageSize);
34430 imageSizeRef.current = imageSize;
34431 const optionsRef = (0, import_element110.useRef)(options);
34432 optionsRef.current = options;
34433 const actionsRef = (0, import_element110.useRef)(actions);
34434 actionsRef.current = actions;
34435 const controllerRef = (0, import_element110.useRef)(null);
34436 const startPlacementGesture = (0, import_element110.useCallback)(() => {
34437 setIsGestureActive(true);
34438 }, []);
34439 const stopPlacementGesture = (0, import_element110.useCallback)(() => {
34440 setIsGestureActive(false);
34441 }, []);
34442 const signalKeyboardGesture = (0, import_element110.useCallback)(() => {
34443 if (!isKeyboardGestureActiveRef.current) {
34444 isKeyboardGestureActiveRef.current = true;
34445 optionsRef.current?.onGestureStart?.();
34446 }
34447 clearTimeout(keyboardInteractionTimerRef.current);
34448 keyboardInteractionTimerRef.current = setTimeout(() => {
34449 isKeyboardGestureActiveRef.current = false;
34450 setIsKeyboardPanning(false);
34451 optionsRef.current?.onGestureEnd?.();
34452 }, KEYBOARD_INTERACTION_IDLE_MS);
34453 }, []);
34454 (0, import_element110.useEffect)(() => {
34455 return () => {
34456 clearTimeout(keyboardInteractionTimerRef.current);
34457 };
34458 }, []);
34459 (0, import_element110.useEffect)(() => {
34460 const controller = new InteractionController({
34461 getState: () => stateRef.current,
34462 actions: {
34463 setPan: (pan) => actionsRef.current.setPan(pan),
34464 setZoom: (zoom) => actionsRef.current.setZoom(zoom),
34465 setZoomAtPoint: (zoom, pan) => actionsRef.current.setZoomAtPoint(zoom, pan),
34466 snapRotate90: (direction) => actionsRef.current.snapRotate90(direction),
34467 toggleFlip: (direction) => actionsRef.current.toggleFlip?.(direction)
34468 },
34469 getContainerSize: () => containerSizeRef.current,
34470 getImageSize: () => imageSizeRef.current,
34471 get minZoom() {
34472 return optionsRef.current?.minZoom;
34473 },
34474 get maxZoom() {
34475 return optionsRef.current?.maxZoom;
34476 },
34477 get zoomSpeed() {
34478 return optionsRef.current?.zoomSpeed;
34479 },
34480 get keyboardStep() {
34481 return optionsRef.current?.keyboardStep;
34482 },
34483 get doubleTapZoom() {
34484 return optionsRef.current?.doubleTapZoom;
34485 },
34486 onGestureStart: () => {
34487 startPlacementGesture();
34488 optionsRef.current?.onGestureStart?.();
34489 },
34490 onGestureEnd: () => {
34491 stopPlacementGesture();
34492 optionsRef.current?.onGestureEnd?.();
34493 },
34494 onStatusChange: (status) => {
34495 setIsDragging(status.isDragging);
34496 setIsZooming(status.isZooming);
34497 }
34498 });
34499 controllerRef.current = controller;
34500 return () => {
34501 controller.destroy();
34502 controllerRef.current = null;
34503 };
34504 }, [startPlacementGesture, stopPlacementGesture]);
34505 const isDisabled = options?.disabled ?? false;
34506 (0, import_element110.useEffect)(() => {
34507 if (!isDisabled) {
34508 return;
34509 }
34510 controllerRef.current?.destroy();
34511 setIsDragging(false);
34512 setIsZooming(false);
34513 setIsKeyboardPanning(false);
34514 const wasGestureOpen = isGestureActive || isKeyboardGestureActiveRef.current;
34515 if (isKeyboardGestureActiveRef.current) {
34516 isKeyboardGestureActiveRef.current = false;
34517 clearTimeout(keyboardInteractionTimerRef.current);
34518 }
34519 stopPlacementGesture();
34520 if (wasGestureOpen) {
34521 optionsRef.current?.onGestureEnd?.();
34522 }
34523 }, [isDisabled, isGestureActive, stopPlacementGesture]);
34524 const onPointerDown = (0, import_element110.useCallback)((e) => {
34525 if (optionsRef.current?.disabled) {
34526 return;
34527 }
34528 const el = e.currentTarget;
34529 controllerRef.current?.handlePointerDown(e.nativeEvent, el);
34530 }, []);
34531 const onTouchStart = (0, import_element110.useCallback)((e) => {
34532 if (optionsRef.current?.disabled) {
34533 return;
34534 }
34535 const el = e.currentTarget;
34536 const rect = el.getBoundingClientRect();
34537 controllerRef.current?.handleTouchStart(
34538 e.nativeEvent,
34539 rect,
34540 el.ownerDocument
34541 );
34542 }, []);
34543 const onKeyDown = (0, import_element110.useCallback)(
34544 (e) => {
34545 if (optionsRef.current?.disabled) {
34546 return;
34547 }
34548 if (isHandledKeyboardPan(e.nativeEvent)) {
34549 setIsKeyboardPanning(true);
34550 signalKeyboardGesture();
34551 } else if (isHandledKeyboardZoom(e.nativeEvent)) {
34552 signalKeyboardGesture();
34553 }
34554 controllerRef.current?.handleKeyDown(e.nativeEvent);
34555 },
34556 [signalKeyboardGesture]
34557 );
34558 const onWheelNative = (0, import_element110.useCallback)((e) => {
34559 if (optionsRef.current?.disabled) {
34560 return;
34561 }
34562 controllerRef.current?.handleWheel(e);
34563 }, []);
34564 return {
34565 handlers: {
34566 onPointerDown,
34567 onTouchStart,
34568 onKeyDown
34569 },
34570 onWheelNative,
34571 isDragging,
34572 isZooming,
34573 isPlacementActive: isGestureActive || isKeyboardPanning || isZooming
34574 };
34575 }
34576
34577 // packages/media-editor/build-module/image-editor/react/hooks/use-transform-style.mjs
34578 var import_element111 = __toESM(require_element(), 1);
34579
34580 // packages/media-editor/build-module/image-editor/core/transform-style.mjs
34581 var IDENTITY_MATRIX_STYLE = "matrix(1, 0, 0, 1, 0, 0)";
34582 function computeTransformStyle(state, imageSize) {
34583 if (!isValidSize(imageSize)) {
34584 return IDENTITY_MATRIX_STYLE;
34585 }
34586 const safeState = sanitizeCropperState(state);
34587 const translateX = safeState.pan.x * imageSize.width;
34588 const translateY = safeState.pan.y * imageSize.height;
34589 const rad = degreesToRadians(safeState.rotation);
34590 const cos = Math.cos(rad);
34591 const sin = Math.sin(rad);
34592 const sx = safeState.flip.horizontal ? -1 : 1;
34593 const sy = safeState.flip.vertical ? -1 : 1;
34594 const z = safeState.zoom;
34595 const a = sx * cos * z;
34596 const b = sy * sin * z;
34597 const c2 = -sx * sin * z;
34598 const d = sy * cos * z;
34599 return `matrix(${a}, ${b}, ${c2}, ${d}, ${translateX}, ${translateY})`;
34600 }
34601
34602 // packages/media-editor/build-module/image-editor/react/hooks/use-transform-style.mjs
34603 function useTransformStyle(state, imageSize) {
34604 return (0, import_element111.useMemo)(
34605 () => computeTransformStyle(state, imageSize),
34606 [state, imageSize]
34607 );
34608 }
34609
34610 // packages/media-editor/build-module/image-editor/react/hooks/use-aria-announcer.mjs
34611 var import_element112 = __toESM(require_element(), 1);
34612 var import_i18n36 = __toESM(require_i18n(), 1);
34613 import { speak as speak6 } from "@wordpress/a11y";
34614
34615 // packages/media-editor/build-module/image-editor/core/source-region.mjs
34616 function getSourceRegion(state, imageSize) {
34617 const safeState = sanitizeCropperState(state);
34618 if (!isValidSize(imageSize)) {
34619 return {
34620 x: 0,
34621 y: 0,
34622 width: 0,
34623 height: 0,
34624 rotation: safeState.rotation,
34625 flip: { ...safeState.flip },
34626 zoom: safeState.zoom
34627 };
34628 }
34629 const syntheticContainer = { width: 1e3, height: 1e3 };
34630 const camera = createCamera(safeState, syntheticContainer, imageSize);
34631 const inv = mat2d_exports.create();
34632 mat2d_exports.invert(inv, camera);
34633 const baseCamera = createCamera(
34634 { ...safeState, pan: { x: 0, y: 0 }, zoom: 1 },
34635 syntheticContainer,
34636 imageSize
34637 );
34638 const visibleBounds = getVisibleBounds(baseCamera);
34639 const cropRect = safeState.cropRect;
34640 const cropCenterScreenX = visibleBounds.left + (cropRect.x + cropRect.width / 2) * visibleBounds.width;
34641 const cropCenterScreenY = visibleBounds.top + (cropRect.y + cropRect.height / 2) * visibleBounds.height;
34642 const srcCenter = vec2_exports.create();
34643 vec2_exports.transformMat2d(
34644 srcCenter,
34645 [cropCenterScreenX, cropCenterScreenY],
34646 inv
34647 );
34648 const snapRotation = Math.round(safeState.rotation / 90) * 90;
34649 const { width: rotW, height: rotH } = getRotatedBBox(
34650 imageSize.width,
34651 imageSize.height,
34652 snapRotation
34653 );
34654 const sourceW = cropRect.width * rotW / safeState.zoom;
34655 const sourceH = cropRect.height * rotH / safeState.zoom;
34656 return {
34657 x: srcCenter[0] * imageSize.width - sourceW / 2,
34658 y: srcCenter[1] * imageSize.height - sourceH / 2,
34659 width: sourceW,
34660 height: sourceH,
34661 rotation: safeState.rotation,
34662 flip: { ...safeState.flip },
34663 zoom: safeState.zoom
34664 };
34665 }
34666 function getCropRectFromSourceRegion(state, imageSize, region) {
34667 if (!isValidSize(imageSize) || region.width <= 0 || region.height <= 0) {
34668 return null;
34669 }
34670 const safeState = sanitizeCropperState(state);
34671 const syntheticContainer = { width: 1e3, height: 1e3 };
34672 const baseCamera = createCamera(
34673 { ...safeState, pan: { x: 0, y: 0 }, zoom: 1 },
34674 syntheticContainer,
34675 imageSize
34676 );
34677 const visibleBounds = getVisibleBounds(baseCamera);
34678 if (visibleBounds.width <= 0 || visibleBounds.height <= 0) {
34679 return null;
34680 }
34681 const sourceCenter = vec2_exports.fromValues(
34682 (region.x + region.width / 2) / imageSize.width,
34683 (region.y + region.height / 2) / imageSize.height
34684 );
34685 const screenCenter = vec2_exports.create();
34686 const camera = createCamera(safeState, syntheticContainer, imageSize);
34687 vec2_exports.transformMat2d(screenCenter, sourceCenter, camera);
34688 const snapRotation = Math.round(safeState.rotation / 90) * 90;
34689 const { width: rotW, height: rotH } = getRotatedBBox(
34690 imageSize.width,
34691 imageSize.height,
34692 snapRotation
34693 );
34694 if (rotW <= 0 || rotH <= 0) {
34695 return null;
34696 }
34697 const width = region.width * safeState.zoom / rotW;
34698 const height = region.height * safeState.zoom / rotH;
34699 const centerX = (screenCenter[0] - visibleBounds.left) / visibleBounds.width;
34700 const centerY = (screenCenter[1] - visibleBounds.top) / visibleBounds.height;
34701 return {
34702 x: centerX - width / 2,
34703 y: centerY - height / 2,
34704 width,
34705 height
34706 };
34707 }
34708 var CARDINAL_ROTATION_EPSILON = 1e-6;
34709 function isCardinalRotation(rotation) {
34710 const normalizedRotation = normalizeRotation(rotation);
34711 const nearestCardinal = Math.round(normalizedRotation / 90) * 90;
34712 return Math.abs(normalizedRotation - nearestCardinal) < CARDINAL_ROTATION_EPSILON;
34713 }
34714 function snapCropRectToSourcePixels(state, imageSize, cropRect, handle) {
34715 const safeState = sanitizeCropperState(state);
34716 if (!isCardinalRotation(safeState.rotation)) {
34717 return cropRect;
34718 }
34719 return snapCropRectEdgesToSourcePixels(safeState, imageSize, cropRect, {
34720 left: handle.includes("w"),
34721 top: handle.includes("n"),
34722 right: handle.includes("e"),
34723 bottom: handle.includes("s")
34724 });
34725 }
34726 function snapCropRectToSourcePixelGrid(state, imageSize, cropRect) {
34727 return snapCropRectEdgesToSourcePixels(state, imageSize, cropRect, {
34728 left: true,
34729 top: true,
34730 right: true,
34731 bottom: true
34732 });
34733 }
34734 function snapCropRectEdgesToSourcePixels(state, imageSize, cropRect, edges) {
34735 if (!isValidSize(imageSize)) {
34736 return cropRect;
34737 }
34738 const stateWithCrop = sanitizeCropperState({ ...state, cropRect });
34739 const region = getSourceRegion(stateWithCrop, imageSize);
34740 const shouldSnapX = edges.left || edges.right;
34741 const shouldSnapY = edges.top || edges.bottom;
34742 const left = edges.left ? Math.round(region.x) : region.x;
34743 const top = edges.top ? Math.round(region.y) : region.y;
34744 const right = edges.right ? Math.round(region.x + region.width) : region.x + region.width;
34745 const bottom = edges.bottom ? Math.round(region.y + region.height) : region.y + region.height;
34746 if (right <= left || bottom <= top) {
34747 return cropRect;
34748 }
34749 const snappedCropRect = getCropRectFromSourceRegion(
34750 stateWithCrop,
34751 imageSize,
34752 {
34753 ...region,
34754 x: left,
34755 y: top,
34756 width: right - left,
34757 height: bottom - top
34758 }
34759 );
34760 if (!snappedCropRect) {
34761 return cropRect;
34762 }
34763 return {
34764 x: shouldSnapX ? snappedCropRect.x : cropRect.x,
34765 y: shouldSnapY ? snappedCropRect.y : cropRect.y,
34766 width: shouldSnapX ? snappedCropRect.width : cropRect.width,
34767 height: shouldSnapY ? snappedCropRect.height : cropRect.height
34768 };
34769 }
34770
34771 // packages/media-editor/build-module/image-editor/react/hooks/use-aria-announcer.mjs
34772 var ARIA_DEBOUNCE_MS = 300;
34773 function getFlipAnnouncement(state, previousState) {
34774 if (!previousState || previousState.flip.horizontal === state.flip.horizontal && previousState.flip.vertical === state.flip.vertical) {
34775 return void 0;
34776 }
34777 const { horizontal, vertical } = state.flip;
34778 if (horizontal && vertical) {
34779 return (0, import_i18n36.__)("Flipped horizontally and vertically");
34780 }
34781 if (horizontal) {
34782 return (0, import_i18n36.__)("Flipped horizontally");
34783 }
34784 if (vertical) {
34785 return (0, import_i18n36.__)("Flipped vertically");
34786 }
34787 return (0, import_i18n36.__)("Flip removed");
34788 }
34789 function getRotationAnnouncement(state, previousState) {
34790 if (previousState && Math.round(previousState.rotation) === Math.round(state.rotation)) {
34791 return void 0;
34792 }
34793 const singleFlip = state.flip.horizontal !== state.flip.vertical;
34794 const visualDir = singleFlip ? -1 : 1;
34795 let visualRotation = Math.round(state.rotation) * visualDir % 360;
34796 if (visualRotation > 180) {
34797 visualRotation -= 360;
34798 }
34799 if (visualRotation <= -180) {
34800 visualRotation += 360;
34801 }
34802 if (visualRotation === 0) {
34803 return previousState ? (0, import_i18n36.__)("Rotation 0 degrees") : void 0;
34804 }
34805 if (visualRotation > 0) {
34806 return (0, import_i18n36.sprintf)(
34807 /* translators: %d: rotation angle in degrees. */
34808 (0, import_i18n36.__)("Rotated %d degrees clockwise"),
34809 visualRotation
34810 );
34811 }
34812 return (0, import_i18n36.sprintf)(
34813 /* translators: %d: rotation angle in degrees. */
34814 (0, import_i18n36.__)("Rotated %d degrees counterclockwise"),
34815 Math.abs(visualRotation)
34816 );
34817 }
34818 function getCropAnnouncement(state, previousState) {
34819 if (!state.image) {
34820 return void 0;
34821 }
34822 const imageSize = {
34823 width: state.image.naturalWidth,
34824 height: state.image.naturalHeight
34825 };
34826 const region = getSourceRegion(state, imageSize);
34827 if (previousState?.image) {
34828 const previousRegion = getSourceRegion(
34829 { ...state, cropRect: previousState.cropRect },
34830 imageSize
34831 );
34832 if (Math.round(previousRegion.width) === Math.round(region.width) && Math.round(previousRegion.height) === Math.round(region.height)) {
34833 return void 0;
34834 }
34835 }
34836 return (0, import_i18n36.sprintf)(
34837 /* translators: 1: crop width in pixels, 2: crop height in pixels. */
34838 (0, import_i18n36.__)("Crop %1$d by %2$d pixels"),
34839 Math.round(region.width),
34840 Math.round(region.height)
34841 );
34842 }
34843 function getZoomAnnouncement(state, previousState) {
34844 if (previousState && Math.round(previousState.zoom * 100) === Math.round(state.zoom * 100)) {
34845 return void 0;
34846 }
34847 return (0, import_i18n36.sprintf)(
34848 /* translators: %d: zoom level as a percentage. */
34849 (0, import_i18n36.__)("Zoom %d%%"),
34850 Math.round(state.zoom * 100)
34851 );
34852 }
34853 function buildAnnouncement(state, previousState) {
34854 const flip4 = getFlipAnnouncement(state, previousState);
34855 if (flip4) {
34856 return flip4;
34857 }
34858 const parts = [
34859 getRotationAnnouncement(state, previousState),
34860 getZoomAnnouncement(state, previousState),
34861 getCropAnnouncement(state, previousState)
34862 ].filter((part) => part !== void 0);
34863 return parts.join(", ");
34864 }
34865 function useAriaAnnouncer(state) {
34866 const timerRef = (0, import_element112.useRef)();
34867 const prevMessageRef = (0, import_element112.useRef)("");
34868 const prevStateRef = (0, import_element112.useRef)(null);
34869 const latestStateRef = (0, import_element112.useRef)(state);
34870 (0, import_element112.useLayoutEffect)(() => {
34871 latestStateRef.current = state;
34872 }, [state]);
34873 (0, import_element112.useEffect)(() => {
34874 clearTimeout(timerRef.current);
34875 timerRef.current = setTimeout(() => {
34876 const current = latestStateRef.current;
34877 const msg = buildAnnouncement(current, prevStateRef.current);
34878 prevStateRef.current = current;
34879 if (msg !== prevMessageRef.current) {
34880 prevMessageRef.current = msg;
34881 speak6(msg);
34882 }
34883 }, ARIA_DEBOUNCE_MS);
34884 return () => {
34885 clearTimeout(timerRef.current);
34886 };
34887 }, [
34888 state.zoom,
34889 state.rotation,
34890 state.cropRect.width,
34891 state.cropRect.height,
34892 state.flip.horizontal,
34893 state.flip.vertical
34894 ]);
34895 }
34896
34897 // packages/media-editor/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs
34898 var import_element113 = __toESM(require_element(), 1);
34899 var import_i18n37 = __toESM(require_i18n(), 1);
34900
34901 // packages/media-editor/build-module/image-editor/react/visually-hidden-style.mjs
34902 var VISUALLY_HIDDEN_STYLE = {
34903 position: "absolute",
34904 width: 1,
34905 height: 1,
34906 padding: 0,
34907 margin: -1,
34908 overflow: "hidden",
34909 clip: "rect(0, 0, 0, 0)",
34910 whiteSpace: "nowrap",
34911 border: 0
34912 };
34913
34914 // packages/media-editor/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs
34915 var import_jsx_runtime153 = __toESM(require_jsx_runtime(), 1);
34916 var CORNER_POSITIONS = ["nw", "ne", "se", "sw"];
34917 var ALL_POSITIONS = [
34918 "nw",
34919 "n",
34920 "ne",
34921 "e",
34922 "se",
34923 "s",
34924 "sw",
34925 "w"
34926 ];
34927 function getHandleLabel(pos) {
34928 switch (pos) {
34929 case "n":
34930 return (0, import_i18n37.__)("Resize from top edge");
34931 case "s":
34932 return (0, import_i18n37.__)("Resize from bottom edge");
34933 case "e":
34934 return (0, import_i18n37.__)("Resize from right edge");
34935 case "w":
34936 return (0, import_i18n37.__)("Resize from left edge");
34937 case "nw":
34938 return (0, import_i18n37.__)("Resize from top-left corner");
34939 case "ne":
34940 return (0, import_i18n37.__)("Resize from top-right corner");
34941 case "sw":
34942 return (0, import_i18n37.__)("Resize from bottom-left corner");
34943 case "se":
34944 return (0, import_i18n37.__)("Resize from bottom-right corner");
34945 }
34946 }
34947 var KEYBOARD_SETTLE_DELAY = 500;
34948 function RectangleStencil({
34949 cropRect,
34950 containerSize,
34951 imageSize,
34952 onCropChange,
34953 onResizeStart,
34954 onResizeEnd,
34955 aspectRatio,
34956 freeformCrop = false,
34957 isResizeDisabled = false,
34958 stencilTransition,
34959 cropBounds,
34960 onEscape,
34961 minCropSize,
34962 snapCropRect,
34963 keyboardResizeStep
34964 }) {
34965 const boundsMinX = cropBounds?.minX ?? 0;
34966 const boundsMinY = cropBounds?.minY ?? 0;
34967 const boundsMaxX = cropBounds?.maxX ?? 1;
34968 const boundsMaxY = cropBounds?.maxY ?? 1;
34969 const bounds = (0, import_element113.useMemo)(
34970 () => ({
34971 minX: boundsMinX,
34972 minY: boundsMinY,
34973 maxX: boundsMaxX,
34974 maxY: boundsMaxY
34975 }),
34976 [boundsMinX, boundsMinY, boundsMaxX, boundsMaxY]
34977 );
34978 const keyboardSettleTimerRef = (0, import_element113.useRef)();
34979 const keyboardResizeActiveRef = (0, import_element113.useRef)(false);
34980 const resizeHandleDescriptionId = (0, import_element113.useId)();
34981 const hasLockedRatio = !!(aspectRatio && aspectRatio > 0);
34982 const activePointerResizeRef = (0, import_element113.useRef)(null);
34983 (0, import_element113.useEffect)(() => {
34984 return () => {
34985 clearTimeout(keyboardSettleTimerRef.current);
34986 keyboardResizeActiveRef.current = false;
34987 activePointerResizeRef.current?.cancel(false);
34988 };
34989 }, []);
34990 const latestHandlersRef = (0, import_element113.useRef)(null);
34991 const normalizedRatio = (0, import_element113.useMemo)(() => {
34992 if (!hasLockedRatio || imageSize.width === 0) {
34993 return 0;
34994 }
34995 return aspectRatio * imageSize.height / imageSize.width;
34996 }, [aspectRatio, hasLockedRatio, imageSize.width, imageSize.height]);
34997 const offsetX = (containerSize.width - imageSize.width) / 2;
34998 const offsetY = (containerSize.height - imageSize.height) / 2;
34999 const left = offsetX + cropRect.x * imageSize.width;
35000 const top = offsetY + cropRect.y * imageSize.height;
35001 const width = cropRect.width * imageSize.width;
35002 const height = cropRect.height * imageSize.height;
35003 const handlePointerDown = (0, import_element113.useCallback)(
35004 (handle, event) => {
35005 if (isResizeDisabled || event.pointerType === "touch" && event.isPrimary === false) {
35006 event.preventDefault();
35007 event.stopPropagation();
35008 return;
35009 }
35010 if (event.button !== 0) {
35011 return;
35012 }
35013 event.preventDefault();
35014 event.stopPropagation();
35015 const ownerDoc = event.currentTarget.ownerDocument;
35016 if (ownerDoc.activeElement instanceof HTMLElement) {
35017 ownerDoc.activeElement.blur();
35018 }
35019 const el = event.currentTarget;
35020 el.setPointerCapture(event.pointerId);
35021 const drag2 = {
35022 handle,
35023 startX: event.clientX,
35024 startY: event.clientY,
35025 startRect: { ...cropRect }
35026 };
35027 let rafId = 0;
35028 let latestX = event.clientX;
35029 let latestY = event.clientY;
35030 let latestShift = event.shiftKey;
35031 const onMove = (e) => {
35032 const pe = e;
35033 latestX = pe.clientX;
35034 latestY = pe.clientY;
35035 latestShift = pe.shiftKey;
35036 if (rafId) {
35037 return;
35038 }
35039 rafId = requestAnimationFrame(() => {
35040 rafId = 0;
35041 const h = latestHandlersRef.current;
35042 if (!h) {
35043 return;
35044 }
35045 let newRect;
35046 if (h.hasLockedRatio) {
35047 newRect = h.computeLockedRect(drag2, latestX, latestY);
35048 } else if (latestShift) {
35049 newRect = h.computeShiftLockedRect(
35050 drag2,
35051 latestX,
35052 latestY
35053 );
35054 } else {
35055 newRect = h.computeFreeRect(drag2, latestX, latestY);
35056 newRect = h.snapCropRect?.(newRect, drag2.handle) ?? newRect;
35057 }
35058 h.onCropChange(newRect);
35059 });
35060 };
35061 let ended = false;
35062 const endResize = (notifyResizeEnd = true, restoreFocus = true) => {
35063 if (ended) {
35064 return;
35065 }
35066 ended = true;
35067 if (rafId) {
35068 cancelAnimationFrame(rafId);
35069 rafId = 0;
35070 }
35071 el.removeEventListener("pointermove", onMove);
35072 el.removeEventListener("pointerup", onEnd);
35073 el.removeEventListener("lostpointercapture", onEnd);
35074 activePointerResizeRef.current = null;
35075 if (notifyResizeEnd) {
35076 latestHandlersRef.current?.onResizeEnd?.();
35077 }
35078 if (restoreFocus) {
35079 el.focus({ preventScroll: true });
35080 }
35081 };
35082 const cancelResize = (notifyResizeEnd = true) => endResize(notifyResizeEnd, false);
35083 const onEnd = () => endResize();
35084 el.addEventListener("pointermove", onMove);
35085 el.addEventListener("pointerup", onEnd);
35086 el.addEventListener("lostpointercapture", onEnd);
35087 activePointerResizeRef.current = { cancel: cancelResize };
35088 onResizeStart?.(handle);
35089 clearTimeout(keyboardSettleTimerRef.current);
35090 keyboardResizeActiveRef.current = false;
35091 },
35092 [cropRect, isResizeDisabled, onResizeStart]
35093 );
35094 const computeFreeRect = (0, import_element113.useCallback)(
35095 (drag2, clientX, clientY) => computeFreeResizeRect(
35096 drag2,
35097 clientX,
35098 clientY,
35099 imageSize,
35100 bounds,
35101 minCropSize
35102 ),
35103 [imageSize, bounds, minCropSize]
35104 );
35105 const computeLockedRect = (0, import_element113.useCallback)(
35106 (drag2, clientX, clientY, driverAxis) => computeLockedResizeRect(
35107 drag2,
35108 clientX,
35109 clientY,
35110 imageSize,
35111 bounds,
35112 normalizedRatio,
35113 minCropSize,
35114 driverAxis
35115 ),
35116 [imageSize, bounds, normalizedRatio, minCropSize]
35117 );
35118 const computeShiftLockedRect = (0, import_element113.useCallback)(
35119 (drag2, clientX, clientY) => computeShiftLockedResizeRect(
35120 drag2,
35121 clientX,
35122 clientY,
35123 imageSize,
35124 bounds,
35125 minCropSize
35126 ),
35127 [imageSize, bounds, minCropSize]
35128 );
35129 latestHandlersRef.current = {
35130 hasLockedRatio,
35131 computeLockedRect,
35132 computeFreeRect,
35133 computeShiftLockedRect,
35134 onCropChange,
35135 onResizeEnd,
35136 snapCropRect
35137 };
35138 (0, import_element113.useEffect)(() => {
35139 if (!isResizeDisabled) {
35140 return;
35141 }
35142 activePointerResizeRef.current?.cancel();
35143 if (keyboardResizeActiveRef.current) {
35144 clearTimeout(keyboardSettleTimerRef.current);
35145 keyboardResizeActiveRef.current = false;
35146 latestHandlersRef.current?.onResizeEnd?.();
35147 }
35148 }, [isResizeDisabled]);
35149 const handleKeyDown = (0, import_element113.useCallback)(
35150 (handle, event) => {
35151 const key = event.key;
35152 if (isResizeDisabled) {
35153 return;
35154 }
35155 if (key === "Escape") {
35156 event.preventDefault();
35157 event.stopPropagation();
35158 onEscape?.();
35159 return;
35160 }
35161 if (key !== "ArrowUp" && key !== "ArrowDown" && key !== "ArrowLeft" && key !== "ArrowRight") {
35162 return;
35163 }
35164 event.preventDefault();
35165 event.stopPropagation();
35166 if (!keyboardResizeActiveRef.current) {
35167 keyboardResizeActiveRef.current = true;
35168 onResizeStart?.(handle);
35169 }
35170 const scheduleKeyboardResizeEnd = () => {
35171 clearTimeout(keyboardSettleTimerRef.current);
35172 keyboardSettleTimerRef.current = setTimeout(() => {
35173 keyboardResizeActiveRef.current = false;
35174 onResizeEnd?.();
35175 }, KEYBOARD_SETTLE_DELAY);
35176 };
35177 const stepMultiplier = event.shiftKey ? KEYBOARD_SHIFT_STEP_MULTIPLIER : 1;
35178 const stepX = keyboardResizeStep?.width ?? DEFAULT_KEYBOARD_STEP;
35179 const stepY = keyboardResizeStep?.height ?? DEFAULT_KEYBOARD_STEP;
35180 const adjustedStepX = stepX * stepMultiplier;
35181 const adjustedStepY = stepY * stepMultiplier;
35182 let dx = 0;
35183 let dy = 0;
35184 if (key === "ArrowLeft") {
35185 dx = -adjustedStepX;
35186 }
35187 if (key === "ArrowRight") {
35188 dx = adjustedStepX;
35189 }
35190 if (key === "ArrowUp") {
35191 dy = -adjustedStepY;
35192 }
35193 if (key === "ArrowDown") {
35194 dy = adjustedStepY;
35195 }
35196 const keyboardDriverAxis = dx !== 0 ? "width" : "height";
35197 if (hasLockedRatio) {
35198 const syntheticDrag = {
35199 handle,
35200 startX: 0,
35201 startY: 0,
35202 startRect: { ...cropRect }
35203 };
35204 const clientX = dx * imageSize.width;
35205 const clientY = dy * imageSize.height;
35206 onCropChange(
35207 computeLockedRect(
35208 syntheticDrag,
35209 clientX,
35210 clientY,
35211 keyboardDriverAxis
35212 )
35213 );
35214 scheduleKeyboardResizeEnd();
35215 } else {
35216 const syntheticDrag = {
35217 handle,
35218 startX: 0,
35219 startY: 0,
35220 startRect: { ...cropRect }
35221 };
35222 const clientX = dx * imageSize.width;
35223 const clientY = dy * imageSize.height;
35224 const rect = computeFreeRect(syntheticDrag, clientX, clientY);
35225 onCropChange(snapCropRect?.(rect, handle) ?? rect);
35226 scheduleKeyboardResizeEnd();
35227 }
35228 },
35229 [
35230 cropRect,
35231 hasLockedRatio,
35232 imageSize.width,
35233 imageSize.height,
35234 computeLockedRect,
35235 computeFreeRect,
35236 onCropChange,
35237 onResizeStart,
35238 onResizeEnd,
35239 onEscape,
35240 keyboardResizeStep,
35241 snapCropRect,
35242 isResizeDisabled
35243 ]
35244 );
35245 if (containerSize.width === 0 || containerSize.height === 0) {
35246 return null;
35247 }
35248 const handles = hasLockedRatio ? CORNER_POSITIONS : ALL_POSITIONS;
35249 return /* @__PURE__ */ (0, import_jsx_runtime153.jsxs)(
35250 "div",
35251 {
35252 className: "wp-media-editor-image-editor__stencil",
35253 "data-testid": "cropper-stencil",
35254 style: {
35255 left,
35256 top,
35257 width,
35258 height,
35259 transition: stencilTransition
35260 },
35261 children: [
35262 freeformCrop && /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(
35263 "div",
35264 {
35265 id: resizeHandleDescriptionId,
35266 style: VISUALLY_HIDDEN_STYLE,
35267 children: (0, import_i18n37.__)(
35268 "Use arrow keys to resize the crop area. Hold Shift for larger steps."
35269 )
35270 }
35271 ),
35272 /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(
35273 "div",
35274 {
35275 className: "wp-media-editor-image-editor__stencil-rect",
35276 style: {
35277 width: "100%",
35278 height: "100%",
35279 top: 0,
35280 left: 0
35281 }
35282 }
35283 ),
35284 freeformCrop && handles.map((pos) => /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(
35285 "button",
35286 {
35287 type: "button",
35288 className: `wp-media-editor-image-editor__handle wp-media-editor-image-editor__handle--${pos}`,
35289 onPointerDown: (event) => handlePointerDown(pos, event),
35290 onTouchStart: (event) => {
35291 if (event.touches.length < 2) {
35292 event.stopPropagation();
35293 }
35294 },
35295 onKeyDown: (event) => handleKeyDown(pos, event),
35296 disabled: isResizeDisabled,
35297 "aria-label": getHandleLabel(pos),
35298 "aria-describedby": resizeHandleDescriptionId
35299 },
35300 pos
35301 ))
35302 ]
35303 }
35304 );
35305 }
35306
35307 // packages/media-editor/build-module/image-editor/react/components/overlays/dimming-overlay.mjs
35308 var import_jsx_runtime154 = __toESM(require_jsx_runtime(), 1);
35309 function DimmingOverlay({
35310 cropRect,
35311 containerSize,
35312 imageSize,
35313 transition
35314 }) {
35315 if (containerSize.width === 0 || containerSize.height === 0) {
35316 return null;
35317 }
35318 const offsetX = (containerSize.width - imageSize.width) / 2;
35319 const offsetY = (containerSize.height - imageSize.height) / 2;
35320 const left = offsetX + cropRect.x * imageSize.width;
35321 const top = offsetY + cropRect.y * imageSize.height;
35322 const width = cropRect.width * imageSize.width;
35323 const height = cropRect.height * imageSize.height;
35324 const composedTransition = transition ? `${transition}, box-shadow 0.15s ease` : void 0;
35325 return /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(
35326 "div",
35327 {
35328 className: "wp-media-editor-image-editor__dimming",
35329 "data-testid": "cropper-dimming",
35330 style: {
35331 left,
35332 top,
35333 width,
35334 height,
35335 transition: composedTransition
35336 }
35337 }
35338 );
35339 }
35340
35341 // packages/media-editor/build-module/image-editor/react/components/overlays/grid-overlay.mjs
35342 var import_jsx_runtime155 = __toESM(require_jsx_runtime(), 1);
35343 function GridOverlay({
35344 cropRect,
35345 containerSize,
35346 imageSize
35347 }) {
35348 if (containerSize.width === 0 || containerSize.height === 0) {
35349 return null;
35350 }
35351 const offsetX = (containerSize.width - imageSize.width) / 2;
35352 const offsetY = (containerSize.height - imageSize.height) / 2;
35353 const left = offsetX + cropRect.x * imageSize.width;
35354 const top = offsetY + cropRect.y * imageSize.height;
35355 const width = cropRect.width * imageSize.width;
35356 const height = cropRect.height * imageSize.height;
35357 const thirdW = width / 3;
35358 const thirdH = height / 3;
35359 return /* @__PURE__ */ (0, import_jsx_runtime155.jsxs)(
35360 "div",
35361 {
35362 className: "wp-media-editor-image-editor__grid",
35363 "data-testid": "cropper-grid",
35364 style: {
35365 left,
35366 top,
35367 width,
35368 height
35369 },
35370 children: [
35371 /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(
35372 "div",
35373 {
35374 className: "wp-media-editor-image-editor__grid-line wp-media-editor-image-editor__grid-line--horizontal",
35375 style: { top: thirdH }
35376 }
35377 ),
35378 /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(
35379 "div",
35380 {
35381 className: "wp-media-editor-image-editor__grid-line wp-media-editor-image-editor__grid-line--horizontal",
35382 style: { top: thirdH * 2 }
35383 }
35384 ),
35385 /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(
35386 "div",
35387 {
35388 className: "wp-media-editor-image-editor__grid-line wp-media-editor-image-editor__grid-line--vertical",
35389 style: { left: thirdW }
35390 }
35391 ),
35392 /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(
35393 "div",
35394 {
35395 className: "wp-media-editor-image-editor__grid-line wp-media-editor-image-editor__grid-line--vertical",
35396 style: { left: thirdW * 2 }
35397 }
35398 )
35399 ]
35400 }
35401 );
35402 }
35403
35404 // packages/media-editor/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs
35405 var import_element114 = __toESM(require_element(), 1);
35406 var import_jsx_runtime156 = __toESM(require_jsx_runtime(), 1);
35407 var HANDLE_GAP_PX = 12;
35408 var TRANSLATE_PERCENT = {
35409 before: "-100%",
35410 center: "-50%",
35411 after: "0"
35412 };
35413 var GAP_DIRECTION = {
35414 before: -1,
35415 center: 0,
35416 after: 1
35417 };
35418 var OPPOSITE_SIDE = {
35419 before: "after",
35420 center: "center",
35421 after: "before"
35422 };
35423 function preferredAnchor(handle) {
35424 let x2 = "center";
35425 if (handle.includes("w")) {
35426 x2 = "before";
35427 } else if (handle.includes("e")) {
35428 x2 = "after";
35429 }
35430 let y2 = "center";
35431 if (handle.includes("n")) {
35432 y2 = "before";
35433 } else if (handle.includes("s")) {
35434 y2 = "after";
35435 }
35436 return { x: x2, y: y2 };
35437 }
35438 function sideStart(side, handlePos, length2) {
35439 if (side === "before") {
35440 return handlePos - HANDLE_GAP_PX - length2;
35441 }
35442 if (side === "after") {
35443 return handlePos + HANDLE_GAP_PX;
35444 }
35445 return handlePos - length2 / 2;
35446 }
35447 function fittingSide(preferred, handlePos, length2, containerLength) {
35448 const fits = (side) => {
35449 const start = sideStart(side, handlePos, length2);
35450 return start >= 0 && start + length2 <= containerLength;
35451 };
35452 if (fits(preferred)) {
35453 return preferred;
35454 }
35455 const opposite = OPPOSITE_SIDE[preferred];
35456 if (opposite !== preferred && fits(opposite)) {
35457 return opposite;
35458 }
35459 if (preferred !== "center" && fits("center")) {
35460 return "center";
35461 }
35462 const overflow = (side) => {
35463 const start = sideStart(side, handlePos, length2);
35464 return Math.max(0, -start) + Math.max(0, start + length2 - containerLength);
35465 };
35466 const candidates = [preferred, opposite, "center"];
35467 return candidates.reduce(
35468 (best, side) => overflow(side) < overflow(best) ? side : best
35469 );
35470 }
35471 function DimensionsOverlay({
35472 cropRect,
35473 containerSize,
35474 imageSize,
35475 activeHandle,
35476 outputWidth,
35477 outputHeight
35478 }) {
35479 const tooltipRef = (0, import_element114.useRef)(null);
35480 const [tooltipSize, setTooltipSize] = (0, import_element114.useState)(null);
35481 (0, import_element114.useLayoutEffect)(() => {
35482 if (!tooltipRef.current) {
35483 return;
35484 }
35485 const rect = tooltipRef.current.getBoundingClientRect();
35486 setTooltipSize((prev) => {
35487 if (prev && prev.width === rect.width && prev.height === rect.height) {
35488 return prev;
35489 }
35490 return { width: rect.width, height: rect.height };
35491 });
35492 }, [outputWidth, outputHeight]);
35493 if (!activeHandle || containerSize.width === 0 || containerSize.height === 0) {
35494 return null;
35495 }
35496 const offsetX = (containerSize.width - imageSize.width) / 2;
35497 const offsetY = (containerSize.height - imageSize.height) / 2;
35498 const left = offsetX + cropRect.x * imageSize.width;
35499 const top = offsetY + cropRect.y * imageSize.height;
35500 const width = cropRect.width * imageSize.width;
35501 const height = cropRect.height * imageSize.height;
35502 let handleX = left + width / 2;
35503 if (activeHandle.includes("w")) {
35504 handleX = left;
35505 } else if (activeHandle.includes("e")) {
35506 handleX = left + width;
35507 }
35508 let handleY = top + height / 2;
35509 if (activeHandle.includes("n")) {
35510 handleY = top;
35511 } else if (activeHandle.includes("s")) {
35512 handleY = top + height;
35513 }
35514 const preferred = preferredAnchor(activeHandle);
35515 const anchor = tooltipSize ? {
35516 x: fittingSide(
35517 preferred.x,
35518 handleX,
35519 tooltipSize.width,
35520 containerSize.width
35521 ),
35522 y: fittingSide(
35523 preferred.y,
35524 handleY,
35525 tooltipSize.height,
35526 containerSize.height
35527 )
35528 } : preferred;
35529 return /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(
35530 "div",
35531 {
35532 ref: tooltipRef,
35533 className: "wp-media-editor-image-editor__dimensions-tooltip",
35534 "data-testid": "cropper-dimensions-tooltip",
35535 style: {
35536 left: handleX + GAP_DIRECTION[anchor.x] * HANDLE_GAP_PX,
35537 top: handleY + GAP_DIRECTION[anchor.y] * HANDLE_GAP_PX,
35538 transform: `translate(${TRANSLATE_PERCENT[anchor.x]}, ${TRANSLATE_PERCENT[anchor.y]})`
35539 },
35540 "aria-hidden": "true",
35541 children: `W: ${Math.round(outputWidth)}px H: ${Math.round(
35542 outputHeight
35543 )}px`
35544 }
35545 );
35546 }
35547
35548 // packages/media-editor/build-module/image-editor/react/components/viewport-provider.mjs
35549 var import_element116 = __toESM(require_element(), 1);
35550
35551 // packages/media-editor/build-module/image-editor/react/hooks/use-viewport-state.mjs
35552 var import_element115 = __toESM(require_element(), 1);
35553
35554 // packages/media-editor/build-module/image-editor/core/viewport-state.mjs
35555 var DEFAULT_VIEWPORT_STATE = {
35556 zoom: 1,
35557 pan: { x: 0, y: 0 }
35558 };
35559 function viewportReducer(state, action) {
35560 switch (action.type) {
35561 case "SET_VIEWPORT_ZOOM": {
35562 const zoom = Math.min(4, Math.max(0.1, action.payload));
35563 return zoom === state.zoom ? state : { ...state, zoom };
35564 }
35565 case "SET_VIEWPORT_PAN": {
35566 const { x: x2, y: y2 } = action.payload;
35567 return x2 === state.pan.x && y2 === state.pan.y ? state : { ...state, pan: action.payload };
35568 }
35569 case "RESET_VIEWPORT":
35570 return state.zoom === DEFAULT_VIEWPORT_STATE.zoom && state.pan.x === DEFAULT_VIEWPORT_STATE.pan.x && state.pan.y === DEFAULT_VIEWPORT_STATE.pan.y ? state : DEFAULT_VIEWPORT_STATE;
35571 }
35572 }
35573
35574 // packages/media-editor/build-module/image-editor/react/hooks/use-viewport-state.mjs
35575 function useViewportState() {
35576 const [viewport, dispatch] = (0, import_element115.useReducer)(
35577 viewportReducer,
35578 DEFAULT_VIEWPORT_STATE
35579 );
35580 const setViewportZoom = (0, import_element115.useCallback)((zoom) => {
35581 dispatch({ type: "SET_VIEWPORT_ZOOM", payload: zoom });
35582 }, []);
35583 const setViewportPan = (0, import_element115.useCallback)((pan) => {
35584 dispatch({ type: "SET_VIEWPORT_PAN", payload: pan });
35585 }, []);
35586 const resetViewport = (0, import_element115.useCallback)(() => {
35587 dispatch({ type: "RESET_VIEWPORT" });
35588 }, []);
35589 return (0, import_element115.useMemo)(
35590 () => ({ viewport, setViewportZoom, setViewportPan, resetViewport }),
35591 [viewport, setViewportZoom, setViewportPan, resetViewport]
35592 );
35593 }
35594
35595 // packages/media-editor/build-module/image-editor/react/components/viewport-provider.mjs
35596 var import_jsx_runtime157 = __toESM(require_jsx_runtime(), 1);
35597 var ViewportContext = (0, import_element116.createContext)(null);
35598 function ViewportProvider({
35599 children
35600 }) {
35601 const viewportState = useViewportState();
35602 return /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(ViewportContext.Provider, { value: viewportState, children });
35603 }
35604 function useViewport() {
35605 const context = (0, import_element116.useContext)(ViewportContext);
35606 if (!context) {
35607 throw new Error(
35608 "useViewport must be used within a ViewportProvider."
35609 );
35610 }
35611 return context;
35612 }
35613
35614 // packages/media-editor/build-module/image-editor/react/components/cropper.mjs
35615 var import_jsx_runtime158 = __toESM(require_jsx_runtime(), 1);
35616 var CROP_RECT_EPSILON = 1e-6;
35617 var CARDINAL_ROTATION_EPSILON2 = 1e-6;
35618 var SETTLE_TRANSITION_DURATION_MS = 200;
35619 var SETTLE_TRANSITION_FALLBACK_MS = SETTLE_TRANSITION_DURATION_MS + 100;
35620 var SETTLE_TRANSFORM_TRANSITION = `transform ${SETTLE_TRANSITION_DURATION_MS}ms ease-out`;
35621 var SETTLE_STENCIL_TRANSITION = [
35622 `left ${SETTLE_TRANSITION_DURATION_MS}ms ease-out`,
35623 `top ${SETTLE_TRANSITION_DURATION_MS}ms ease-out`,
35624 `width ${SETTLE_TRANSITION_DURATION_MS}ms ease-out`,
35625 `height ${SETTLE_TRANSITION_DURATION_MS}ms ease-out`
35626 ].join(", ");
35627 function CropperInner({
35628 src,
35629 controller,
35630 stencil: StencilComponent = RectangleStencil,
35631 showGrid = false,
35632 isPlacementActive = false,
35633 showDimming = true,
35634 showDimensions = true,
35635 minZoom,
35636 maxZoom,
35637 aspectRatio,
35638 freeformCrop = false,
35639 focusOnMount = false,
35640 disabled: disabled2 = false,
35641 onImageLoaded,
35642 onStateChange,
35643 onGestureStart,
35644 onGestureEnd,
35645 className
35646 }, ref) {
35647 const {
35648 state,
35649 setImage,
35650 setCropRect,
35651 settleCrop,
35652 setVisualSize,
35653 adjustCropRectForViewport
35654 } = controller;
35655 const {
35656 viewport: viewportState,
35657 setViewportPan,
35658 resetViewport
35659 } = useViewport();
35660 const canvasRef = (0, import_element117.useRef)(null);
35661 const cropAreaDescriptionId = (0, import_element117.useId)();
35662 const [isCropAreaFocused, setIsCropAreaFocused] = (0, import_element117.useState)(focusOnMount);
35663 const [isFocusVisible, setIsFocusVisible] = (0, import_element117.useState)(false);
35664 const [canvasSize, setCanvasSize] = (0, import_element117.useState)({
35665 width: 0,
35666 height: 0
35667 });
35668 (0, import_element117.useLayoutEffect)(() => {
35669 if (focusOnMount) {
35670 canvasRef.current?.focus({ preventScroll: true });
35671 }
35672 }, [focusOnMount]);
35673 const handleCropAreaFocus = (0, import_element117.useCallback)(
35674 (event) => {
35675 const target = event.target;
35676 if (target === event.currentTarget) {
35677 setIsCropAreaFocused(true);
35678 }
35679 if (event.relatedTarget !== null && target.matches(":focus-visible")) {
35680 setIsFocusVisible(true);
35681 }
35682 },
35683 []
35684 );
35685 const handleCropAreaBlur = (0, import_element117.useCallback)(
35686 (event) => {
35687 if (event.target === event.currentTarget) {
35688 setIsCropAreaFocused(false);
35689 }
35690 if (!event.currentTarget.contains(
35691 event.relatedTarget
35692 )) {
35693 setIsFocusVisible(false);
35694 }
35695 },
35696 []
35697 );
35698 (0, import_element117.useEffect)(() => {
35699 const element = canvasRef.current;
35700 if (!element) {
35701 return;
35702 }
35703 const observer = new ResizeObserver((entries) => {
35704 for (const entry of entries) {
35705 const { width, height } = entry.contentRect;
35706 setCanvasSize((prev) => {
35707 if (prev.width === width && prev.height === height) {
35708 return prev;
35709 }
35710 return { width, height };
35711 });
35712 }
35713 });
35714 observer.observe(element);
35715 return () => {
35716 observer.disconnect();
35717 };
35718 }, []);
35719 (0, import_element117.useEffect)(() => {
35720 onStateChange?.(state);
35721 }, [state, onStateChange]);
35722 useAriaAnnouncer(state);
35723 const naturalWidth = state.image?.naturalWidth ?? 0;
35724 const naturalHeight = state.image?.naturalHeight ?? 0;
35725 const { elementSize, visualSize } = (0, import_element117.useMemo)(
35726 () => getImageFit(
35727 canvasSize,
35728 { width: naturalWidth, height: naturalHeight },
35729 state.rotation
35730 ),
35731 [canvasSize, naturalWidth, naturalHeight, state.rotation]
35732 );
35733 (0, import_element117.useEffect)(() => {
35734 setVisualSize(visualSize);
35735 }, [visualSize, setVisualSize]);
35736 (0, import_element117.useEffect)(() => {
35737 if (freeformCrop || visualSize.width === 0 || visualSize.height === 0 || !aspectRatio || aspectRatio <= 0) {
35738 return;
35739 }
35740 const rect = computeInscribedRect(aspectRatio, visualSize);
35741 const current = state.cropRect;
35742 if (Math.abs(current.x - rect.x) < CROP_RECT_EPSILON && Math.abs(current.y - rect.y) < CROP_RECT_EPSILON && Math.abs(current.width - rect.width) < CROP_RECT_EPSILON && Math.abs(current.height - rect.height) < CROP_RECT_EPSILON) {
35743 return;
35744 }
35745 adjustCropRectForViewport(rect);
35746 }, [
35747 freeformCrop,
35748 aspectRatio,
35749 visualSize,
35750 adjustCropRectForViewport,
35751 state.cropRect
35752 ]);
35753 const prevAspectRatioRef = (0, import_element117.useRef)(aspectRatio);
35754 (0, import_element117.useEffect)(() => {
35755 if (prevAspectRatioRef.current === aspectRatio) {
35756 return;
35757 }
35758 prevAspectRatioRef.current = aspectRatio;
35759 if (!freeformCrop || visualSize.width === 0 || visualSize.height === 0 || !aspectRatio || aspectRatio <= 0) {
35760 return;
35761 }
35762 const rect = computeInscribedRect(aspectRatio, visualSize);
35763 const current = state.cropRect;
35764 if (Math.abs(current.x - rect.x) < CROP_RECT_EPSILON && Math.abs(current.y - rect.y) < CROP_RECT_EPSILON && Math.abs(current.width - rect.width) < CROP_RECT_EPSILON && Math.abs(current.height - rect.height) < CROP_RECT_EPSILON) {
35765 return;
35766 }
35767 adjustCropRectForViewport(rect);
35768 }, [
35769 aspectRatio,
35770 freeformCrop,
35771 visualSize,
35772 adjustCropRectForViewport,
35773 state.cropRect
35774 ]);
35775 const cropBounds = (0, import_element117.useMemo)(() => {
35776 if (!state.image || elementSize.width === 0) {
35777 return void 0;
35778 }
35779 return getImageCropBounds(state, elementSize, visualSize);
35780 }, [state, elementSize, visualSize]);
35781 const effectiveMinZoom = minZoom !== void 0 ? minZoom : getMinZoom(state);
35782 const [isResizing, setIsResizing] = (0, import_element117.useState)(false);
35783 const isResizingRef = (0, import_element117.useRef)(false);
35784 const isSettlingRef = (0, import_element117.useRef)(false);
35785 const [isTouchPinching, setIsTouchPinchingState] = (0, import_element117.useState)(false);
35786 const isTouchPinchingRef = (0, import_element117.useRef)(false);
35787 const setTouchPinching = (0, import_element117.useCallback)((isPinching) => {
35788 isTouchPinchingRef.current = isPinching;
35789 setIsTouchPinchingState(isPinching);
35790 }, []);
35791 const [activeHandle, setActiveHandle] = (0, import_element117.useState)(
35792 null
35793 );
35794 const viewScaleRest = (0, import_element117.useMemo)(
35795 () => getViewScale(
35796 state.cropRect,
35797 canvasSize,
35798 visualSize,
35799 SETTLE_TARGET_CANVAS_FILL,
35800 MAX_VIEW_SCALE
35801 ),
35802 [state.cropRect, canvasSize, visualSize]
35803 );
35804 const [frozenViewScale, setFrozenViewScale] = (0, import_element117.useState)(1);
35805 const viewScale = isResizing ? frozenViewScale : viewScaleRest;
35806 const scaledVisualSize = (0, import_element117.useMemo)(
35807 () => ({
35808 width: visualSize.width * viewScale,
35809 height: visualSize.height * viewScale
35810 }),
35811 [visualSize.width, visualSize.height, viewScale]
35812 );
35813 const displayScale = naturalWidth > 0 ? elementSize.width / naturalWidth * state.zoom * viewScale : 0;
35814 const keyboardResizeStep = (0, import_element117.useMemo)(() => {
35815 if (displayScale < PIXEL_SNAP_DISPLAY_SCALE || aspectRatio && aspectRatio > 0 || naturalWidth <= 0 || naturalHeight <= 0) {
35816 return void 0;
35817 }
35818 const snapRotation = Math.round(state.rotation / 90) * 90;
35819 if (Math.abs(state.rotation - snapRotation) >= CARDINAL_ROTATION_EPSILON2) {
35820 return void 0;
35821 }
35822 const bbox = getRotatedBBox(
35823 naturalWidth,
35824 naturalHeight,
35825 snapRotation
35826 );
35827 if (bbox.width <= 0 || bbox.height <= 0) {
35828 return void 0;
35829 }
35830 return {
35831 width: state.zoom / bbox.width,
35832 height: state.zoom / bbox.height
35833 };
35834 }, [
35835 displayScale,
35836 aspectRatio,
35837 naturalWidth,
35838 naturalHeight,
35839 state.rotation,
35840 state.zoom
35841 ]);
35842 const minCropSize = (0, import_element117.useMemo)(() => {
35843 if (naturalWidth <= 0 || naturalHeight <= 0) {
35844 return void 0;
35845 }
35846 const snapRotation = Math.round(state.rotation / 90) * 90;
35847 const bbox = getRotatedBBox(
35848 naturalWidth,
35849 naturalHeight,
35850 snapRotation
35851 );
35852 const minPixels = getMinCropPixels(displayScale);
35853 return {
35854 width: Math.min(1, minPixels * state.zoom / bbox.width),
35855 height: Math.min(1, minPixels * state.zoom / bbox.height)
35856 };
35857 }, [
35858 naturalWidth,
35859 naturalHeight,
35860 state.rotation,
35861 state.zoom,
35862 displayScale
35863 ]);
35864 const snapCropRect = (0, import_element117.useCallback)(
35865 (rect, handle) => {
35866 if (displayScale < PIXEL_SNAP_DISPLAY_SCALE || naturalWidth <= 0 || naturalHeight <= 0) {
35867 return rect;
35868 }
35869 return snapCropRectToSourcePixels(
35870 state,
35871 { width: naturalWidth, height: naturalHeight },
35872 rect,
35873 handle
35874 );
35875 },
35876 [displayScale, naturalWidth, naturalHeight, state]
35877 );
35878 const wasPixelSnapEnabledRef = (0, import_element117.useRef)(false);
35879 (0, import_element117.useEffect)(() => {
35880 const isPixelSnapEnabled = freeformCrop && (!aspectRatio || aspectRatio <= 0) && displayScale >= PIXEL_SNAP_DISPLAY_SCALE && naturalWidth > 0 && naturalHeight > 0;
35881 const wasPixelSnapEnabled = wasPixelSnapEnabledRef.current;
35882 wasPixelSnapEnabledRef.current = isPixelSnapEnabled;
35883 if (!isPixelSnapEnabled || wasPixelSnapEnabled) {
35884 return;
35885 }
35886 const snappedCropRect = snapCropRectToSourcePixelGrid(
35887 state,
35888 { width: naturalWidth, height: naturalHeight },
35889 state.cropRect
35890 );
35891 const currentCropRect = state.cropRect;
35892 if (Math.abs(currentCropRect.x - snappedCropRect.x) < CROP_RECT_EPSILON && Math.abs(currentCropRect.y - snappedCropRect.y) < CROP_RECT_EPSILON && Math.abs(currentCropRect.width - snappedCropRect.width) < CROP_RECT_EPSILON && Math.abs(currentCropRect.height - snappedCropRect.height) < CROP_RECT_EPSILON) {
35893 return;
35894 }
35895 setCropRect(snappedCropRect);
35896 }, [
35897 aspectRatio,
35898 displayScale,
35899 freeformCrop,
35900 naturalWidth,
35901 naturalHeight,
35902 setCropRect,
35903 state
35904 ]);
35905 const {
35906 handlers,
35907 onWheelNative,
35908 isDragging,
35909 isZooming,
35910 isPlacementActive: isInteractionPlacementActive
35911 } = useInteraction(state, controller, canvasSize, scaledVisualSize, {
35912 minZoom: effectiveMinZoom,
35913 maxZoom,
35914 onGestureStart,
35915 onGestureEnd,
35916 disabled: disabled2
35917 });
35918 const canvasHandlers = {
35919 ...handlers,
35920 onPointerDownCapture: () => {
35921 setIsFocusVisible(false);
35922 },
35923 onTouchStartCapture: (event) => {
35924 if (event.touches.length > 1) {
35925 setTouchPinching(true);
35926 }
35927 },
35928 onTouchMoveCapture: (event) => {
35929 if (event.touches.length > 1) {
35930 setTouchPinching(true);
35931 }
35932 },
35933 onTouchEndCapture: (event) => {
35934 if (event.touches.length === 0) {
35935 setTouchPinching(false);
35936 }
35937 },
35938 onTouchCancelCapture: (event) => {
35939 if (event.touches.length === 0) {
35940 setTouchPinching(false);
35941 }
35942 },
35943 onKeyDownCapture: (event) => {
35944 if (!["Shift", "Control", "Alt", "Meta"].includes(event.key)) {
35945 setIsFocusVisible(true);
35946 }
35947 },
35948 onPointerDown: (event) => {
35949 if (disabled2 || isResizingRef.current || isTouchPinchingRef.current || event.pointerType === "touch" && event.isPrimary === false) {
35950 event.preventDefault();
35951 return;
35952 }
35953 handlers.onPointerDown?.(event);
35954 setIsFocusVisible(false);
35955 }
35956 };
35957 (0, import_element117.useEffect)(() => {
35958 const el = canvasRef.current;
35959 if (!el) {
35960 return;
35961 }
35962 const handleWheel = (event) => {
35963 if (isResizingRef.current || isSettlingRef.current) {
35964 event.preventDefault();
35965 return;
35966 }
35967 onWheelNative(event);
35968 };
35969 el.addEventListener("wheel", handleWheel, {
35970 passive: false
35971 });
35972 return () => {
35973 el.removeEventListener("wheel", handleWheel);
35974 };
35975 }, [onWheelNative]);
35976 const transformString = useTransformStyle(state, visualSize);
35977 const handleImageLoad = (0, import_element117.useCallback)(
35978 (event) => {
35979 const img = event.currentTarget;
35980 const size4 = {
35981 width: img.naturalWidth,
35982 height: img.naturalHeight
35983 };
35984 setImage({
35985 src,
35986 naturalWidth: size4.width,
35987 naturalHeight: size4.height
35988 });
35989 onImageLoaded?.(size4);
35990 },
35991 [src, setImage, onImageLoaded]
35992 );
35993 const handleCropChange = (0, import_element117.useCallback)(
35994 (rect) => {
35995 if (isTouchPinchingRef.current) {
35996 return;
35997 }
35998 setCropRect(rect);
35999 if (isResizingRef.current && scaledVisualSize.width > 0 && scaledVisualSize.height > 0) {
36000 const offsetX = (canvasSize.width - scaledVisualSize.width) / 2;
36001 const offsetY = (canvasSize.height - scaledVisualSize.height) / 2;
36002 const rightOverflow = Math.max(
36003 0,
36004 offsetX + (rect.x + rect.width) * scaledVisualSize.width - canvasSize.width
36005 );
36006 const leftOverflow = Math.max(
36007 0,
36008 -(offsetX + rect.x * scaledVisualSize.width)
36009 );
36010 const bottomOverflow = Math.max(
36011 0,
36012 offsetY + (rect.y + rect.height) * scaledVisualSize.height - canvasSize.height
36013 );
36014 const topOverflow = Math.max(
36015 0,
36016 -(offsetY + rect.y * scaledVisualSize.height)
36017 );
36018 setViewportPan({
36019 x: -rightOverflow + leftOverflow,
36020 y: -bottomOverflow + topOverflow
36021 });
36022 }
36023 },
36024 [setCropRect, setViewportPan, canvasSize, scaledVisualSize]
36025 );
36026 const [settling, setSettling] = (0, import_element117.useState)(false);
36027 const settleTimerRef = (0, import_element117.useRef)();
36028 const finishSettling = (0, import_element117.useCallback)(() => {
36029 clearTimeout(settleTimerRef.current);
36030 isSettlingRef.current = false;
36031 setSettling(false);
36032 }, []);
36033 (0, import_element117.useEffect)(() => {
36034 return () => {
36035 clearTimeout(settleTimerRef.current);
36036 };
36037 }, []);
36038 const isInteractiveGrid = showGrid === "interactive";
36039 const showInteractiveGrid = isInteractiveGrid && (isInteractionPlacementActive || isResizing || isPlacementActive);
36040 const outputSize = (0, import_element117.useMemo)(() => {
36041 if (!showDimensions || !activeHandle || !state.image) {
36042 return null;
36043 }
36044 const region = getSourceRegion(state, {
36045 width: state.image.naturalWidth,
36046 height: state.image.naturalHeight
36047 });
36048 return { width: region.width, height: region.height };
36049 }, [showDimensions, activeHandle, state]);
36050 const handleEscape = (0, import_element117.useCallback)(() => {
36051 setIsFocusVisible(true);
36052 canvasRef.current?.focus({ preventScroll: true });
36053 }, []);
36054 const handleResizeStart = (0, import_element117.useCallback)(
36055 (handle) => {
36056 if (isTouchPinchingRef.current) {
36057 return;
36058 }
36059 setFrozenViewScale(viewScaleRest);
36060 isResizingRef.current = true;
36061 setIsResizing(true);
36062 setActiveHandle(handle ?? null);
36063 finishSettling();
36064 resetViewport();
36065 onGestureStart?.();
36066 },
36067 [finishSettling, onGestureStart, resetViewport, viewScaleRest]
36068 );
36069 const handleResizeEnd = (0, import_element117.useCallback)(() => {
36070 const isCancellingForPinch = isTouchPinchingRef.current;
36071 isResizingRef.current = false;
36072 setIsResizing(false);
36073 setActiveHandle(null);
36074 clearTimeout(settleTimerRef.current);
36075 if (isCancellingForPinch) {
36076 finishSettling();
36077 resetViewport();
36078 return;
36079 }
36080 isSettlingRef.current = true;
36081 setSettling(true);
36082 resetViewport();
36083 settleCrop();
36084 onGestureEnd?.();
36085 settleTimerRef.current = setTimeout(
36086 finishSettling,
36087 SETTLE_TRANSITION_FALLBACK_MS
36088 );
36089 }, [finishSettling, settleCrop, onGestureEnd, resetViewport]);
36090 const handleSettleTransitionEnd = (0, import_element117.useCallback)(
36091 (event) => {
36092 if (!isSettlingRef.current || event.propertyName !== "transform") {
36093 return;
36094 }
36095 finishSettling();
36096 },
36097 [finishSettling]
36098 );
36099 let imageTransition;
36100 if (settling) {
36101 imageTransition = SETTLE_TRANSFORM_TRANSITION;
36102 } else if (isZooming) {
36103 imageTransition = "transform 150ms linear";
36104 }
36105 const settleStencilTransition = settling ? SETTLE_STENCIL_TRANSITION : void 0;
36106 const imageStyle = (0, import_element117.useMemo)(() => {
36107 if (elementSize.width === 0 || elementSize.height === 0) {
36108 return {};
36109 }
36110 const centerX = (canvasSize.width - elementSize.width) / 2;
36111 const centerY = (canvasSize.height - elementSize.height) / 2;
36112 return {
36113 width: elementSize.width,
36114 height: elementSize.height,
36115 maxWidth: elementSize.width,
36116 maxHeight: elementSize.height,
36117 left: centerX,
36118 top: centerY,
36119 // Always lead with `scale()` (identity at rest) so the transform's
36120 // function list stays structurally constant across rest, resize, and
36121 // settle. A conditional that dropped `scale()` at viewScale === 1
36122 // would change the list shape exactly when the settle transition
36123 // crosses 1:1, forcing the browser to fall back to matrix-decomposition
36124 // interpolation instead of interpolating each function in turn.
36125 transform: `scale(${viewScale}) ${transformString}`,
36126 transition: imageTransition,
36127 imageRendering: displayScale > 1 ? "pixelated" : void 0
36128 };
36129 }, [
36130 canvasSize,
36131 elementSize,
36132 transformString,
36133 imageTransition,
36134 displayScale,
36135 viewScale
36136 ]);
36137 const settleTransition = settling ? SETTLE_TRANSFORM_TRANSITION : void 0;
36138 const willChange = isResizing || settling ? "transform" : void 0;
36139 let stageStyle;
36140 if (viewportState.pan.x !== 0 || viewportState.pan.y !== 0) {
36141 stageStyle = {
36142 transform: `translate(${viewportState.pan.x}px, ${viewportState.pan.y}px)`,
36143 transition: settleTransition,
36144 willChange
36145 };
36146 } else if (settling) {
36147 stageStyle = {
36148 transform: "translate(0px, 0px)",
36149 transition: settleTransition,
36150 willChange
36151 };
36152 }
36153 const setContainerRef = (0, import_element117.useCallback)(
36154 (element) => {
36155 if (typeof ref === "function") {
36156 ref(element);
36157 } else if (ref) {
36158 ref.current = element;
36159 }
36160 },
36161 [ref]
36162 );
36163 return /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
36164 "div",
36165 {
36166 ref: setContainerRef,
36167 className: clsx_default(
36168 "wp-media-editor-image-editor",
36169 isDragging && "wp-media-editor-image-editor--dragging",
36170 className
36171 ),
36172 children: /* @__PURE__ */ (0, import_jsx_runtime158.jsxs)(
36173 "div",
36174 {
36175 ref: canvasRef,
36176 className: clsx_default(
36177 "wp-media-editor-image-editor__canvas",
36178 isInteractiveGrid && "wp-media-editor-image-editor__canvas--grid-interactive",
36179 showInteractiveGrid && "wp-media-editor-image-editor__canvas--show-grid",
36180 settling && "wp-media-editor-image-editor__canvas--settling",
36181 // Marks the cropper as in keyboard-interaction mode.
36182 // CSS uses :focus on the canvas to show the stencil
36183 // outline and :focus on a handle to show its ring,
36184 // so the class applies whenever any cropper element
36185 // has keyboard focus.
36186 isFocusVisible && "wp-media-editor-image-editor__canvas--focus-visible"
36187 ),
36188 tabIndex: 0,
36189 role: "group",
36190 "aria-label": (0, import_i18n38.__)("Crop area"),
36191 "aria-describedby": isCropAreaFocused ? cropAreaDescriptionId : void 0,
36192 onFocus: handleCropAreaFocus,
36193 onBlur: handleCropAreaBlur,
36194 ...canvasHandlers,
36195 children: [
36196 /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
36197 "div",
36198 {
36199 id: cropAreaDescriptionId,
36200 style: VISUALLY_HIDDEN_STYLE,
36201 children: (0, import_i18n38.__)(
36202 "When this area is focused, use arrow keys to move the image and plus or minus to zoom. Tab to resize handles and controls."
36203 )
36204 }
36205 ),
36206 /* @__PURE__ */ (0, import_jsx_runtime158.jsxs)(
36207 "div",
36208 {
36209 className: "wp-media-editor-image-editor__stage",
36210 "data-testid": "cropper-stage",
36211 style: stageStyle,
36212 onTransitionEnd: handleSettleTransitionEnd,
36213 children: [
36214 /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
36215 "img",
36216 {
36217 className: "wp-media-editor-image-editor__image",
36218 "data-testid": "cropper-image",
36219 src,
36220 alt: "",
36221 onLoad: handleImageLoad,
36222 style: imageStyle,
36223 draggable: false
36224 }
36225 ),
36226 showDimming && /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
36227 DimmingOverlay,
36228 {
36229 cropRect: state.cropRect,
36230 containerSize: canvasSize,
36231 imageSize: scaledVisualSize,
36232 transition: settleStencilTransition
36233 }
36234 ),
36235 /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
36236 StencilComponent,
36237 {
36238 cropRect: state.cropRect,
36239 containerSize: canvasSize,
36240 imageSize: scaledVisualSize,
36241 onCropChange: handleCropChange,
36242 onResizeStart: handleResizeStart,
36243 onResizeEnd: handleResizeEnd,
36244 onEscape: handleEscape,
36245 aspectRatio,
36246 freeformCrop,
36247 isResizeDisabled: isTouchPinching || disabled2,
36248 stencilTransition: settleStencilTransition,
36249 cropBounds,
36250 minCropSize,
36251 snapCropRect,
36252 keyboardResizeStep
36253 }
36254 ),
36255 (showGrid === true || isInteractiveGrid) && /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
36256 GridOverlay,
36257 {
36258 cropRect: state.cropRect,
36259 containerSize: canvasSize,
36260 imageSize: scaledVisualSize
36261 }
36262 ),
36263 activeHandle && outputSize && /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
36264 DimensionsOverlay,
36265 {
36266 cropRect: state.cropRect,
36267 containerSize: canvasSize,
36268 imageSize: scaledVisualSize,
36269 activeHandle,
36270 outputWidth: outputSize.width,
36271 outputHeight: outputSize.height
36272 }
36273 )
36274 ]
36275 }
36276 )
36277 ]
36278 }
36279 )
36280 }
36281 );
36282 }
36283 var CropperInnerWithRef = (0, import_element117.forwardRef)(
36284 CropperInner
36285 );
36286 var Cropper = (0, import_element117.forwardRef)(
36287 (props, ref) => /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(ViewportProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(CropperInnerWithRef, { ...props, ref }) })
36288 );
36289
36290 // packages/media-editor/build-module/state/use-media-editor-state.mjs
36291 var import_element118 = __toESM(require_element(), 1);
36292
36293 // packages/media-editor/build-module/state/types.mjs
36294 var DEFAULT_CROP_OPTIONS = {
36295 aspectRatioValue: "0"
36296 };
36297
36298 // packages/media-editor/build-module/state/composite-reducer.mjs
36299 function mediaEditorReducer(state, action) {
36300 switch (action.type) {
36301 case "CROPPER": {
36302 const nextCropper = cropperReducer(state.cropper, action.action);
36303 if (nextCropper === state.cropper) {
36304 return state;
36305 }
36306 return { ...state, cropper: nextCropper };
36307 }
36308 case "SET_ASPECT_RATIO_VALUE": {
36309 const { presetKey, resolved, visualSize } = action.payload;
36310 const shouldReshape = resolved !== void 0 && resolved > 0 && visualSize.width > 0 && visualSize.height > 0;
36311 const nextCropOptions = {
36312 ...state.cropOptions,
36313 aspectRatioValue: presetKey
36314 };
36315 if (!shouldReshape) {
36316 if (state.cropOptions.aspectRatioValue === presetKey) {
36317 return state;
36318 }
36319 return { ...state, cropOptions: nextCropOptions };
36320 }
36321 const newCropRect = computeInscribedRect(resolved, visualSize);
36322 const nextCropper = cropperReducer(state.cropper, {
36323 type: "SET_CROP_RECT",
36324 payload: newCropRect
36325 });
36326 return {
36327 cropper: nextCropper,
36328 cropOptions: nextCropOptions
36329 };
36330 }
36331 case "RESET_CROP_OPTIONS": {
36332 if (state.cropOptions.aspectRatioValue === DEFAULT_CROP_OPTIONS.aspectRatioValue) {
36333 return state;
36334 }
36335 return {
36336 ...state,
36337 cropOptions: { ...DEFAULT_CROP_OPTIONS }
36338 };
36339 }
36340 case "RESTORE_SNAPSHOT":
36341 return action.payload;
36342 case "VIEWPORT_ADJUST_CROP_RECT": {
36343 const nextCropper = cropperReducer(state.cropper, {
36344 type: "SET_CROP_RECT",
36345 payload: action.payload
36346 });
36347 if (nextCropper === state.cropper) {
36348 return state;
36349 }
36350 return { ...state, cropper: nextCropper };
36351 }
36352 }
36353 }
36354 function areMediaEditorStatesEqual(a, b) {
36355 if (a === b) {
36356 return true;
36357 }
36358 return areCropperStatesEqual(a.cropper, b.cropper) && a.cropOptions.aspectRatioValue === b.cropOptions.aspectRatioValue;
36359 }
36360 function buildInitialMediaEditorState(initialCropper, initialOptions) {
36361 return {
36362 cropper: initialCropper,
36363 cropOptions: { ...DEFAULT_CROP_OPTIONS, ...initialOptions }
36364 };
36365 }
36366
36367 // packages/media-editor/build-module/state/use-media-editor-state.mjs
36368 function resolveAspectRatio(presetKey, cropperImage) {
36369 const num = parseFloat(presetKey);
36370 if (num === 0 || Number.isNaN(num)) {
36371 return void 0;
36372 }
36373 if (num === ORIGINAL_ASPECT_RATIO) {
36374 if (cropperImage && cropperImage.naturalWidth > 0 && cropperImage.naturalHeight > 0) {
36375 return cropperImage.naturalWidth / cropperImage.naturalHeight;
36376 }
36377 return void 0;
36378 }
36379 if (num > 0) {
36380 return num;
36381 }
36382 return void 0;
36383 }
36384 function areCropperImagesEqual(a, b) {
36385 return a?.src === b?.src && a?.naturalWidth === b?.naturalWidth && a?.naturalHeight === b?.naturalHeight;
36386 }
36387 function useMediaEditorState(initialState) {
36388 const [state, dispatch] = (0, import_element118.useReducer)(
36389 mediaEditorReducer,
36390 null,
36391 () => buildInitialMediaEditorState(
36392 enforceContainment({
36393 ...DEFAULT_STATE2,
36394 ...initialState?.cropper
36395 }),
36396 initialState?.cropOptions
36397 )
36398 );
36399 const [initialBaseline, setInitialBaseline] = (0, import_element118.useState)(() => state);
36400 const stateRef = (0, import_element118.useRef)(state);
36401 const visualSizeRef = (0, import_element118.useRef)({ width: 0, height: 0 });
36402 const historyRef = (0, import_element118.useRef)([]);
36403 const redoStackRef = (0, import_element118.useRef)([]);
36404 const [hasUndo, setHasUndo] = (0, import_element118.useState)(false);
36405 const [hasRedo, setHasRedo] = (0, import_element118.useState)(false);
36406 const isGestureOpenRef = (0, import_element118.useRef)(false);
36407 const gestureSnapshotRef = (0, import_element118.useRef)(null);
36408 const pushSnapshot = (0, import_element118.useCallback)((snapshot) => {
36409 const last = historyRef.current[historyRef.current.length - 1];
36410 if (last && areMediaEditorStatesEqual(last, snapshot)) {
36411 return;
36412 }
36413 historyRef.current = [...historyRef.current, snapshot];
36414 redoStackRef.current = [];
36415 setHasUndo(true);
36416 setHasRedo(false);
36417 }, []);
36418 const dispatchWithHistory = (0, import_element118.useCallback)(
36419 (action, recordHistory = true) => {
36420 const preState = stateRef.current;
36421 const postState = mediaEditorReducer(preState, action);
36422 if (recordHistory) {
36423 if (!areMediaEditorStatesEqual(preState, postState)) {
36424 if (isGestureOpenRef.current) {
36425 if (gestureSnapshotRef.current === null) {
36426 gestureSnapshotRef.current = preState;
36427 }
36428 } else {
36429 pushSnapshot(preState);
36430 }
36431 }
36432 }
36433 stateRef.current = postState;
36434 dispatch(action);
36435 },
36436 [pushSnapshot]
36437 );
36438 const beginGesture = (0, import_element118.useCallback)(() => {
36439 if (isGestureOpenRef.current) {
36440 return;
36441 }
36442 isGestureOpenRef.current = true;
36443 gestureSnapshotRef.current = null;
36444 }, []);
36445 const endGesture = (0, import_element118.useCallback)(() => {
36446 const snapshot = gestureSnapshotRef.current;
36447 if (snapshot && !areMediaEditorStatesEqual(snapshot, stateRef.current)) {
36448 pushSnapshot(snapshot);
36449 }
36450 gestureSnapshotRef.current = null;
36451 isGestureOpenRef.current = false;
36452 }, [pushSnapshot]);
36453 const dispatchCropperAction = (0, import_element118.useCallback)(
36454 (action) => {
36455 dispatchWithHistory({ type: "CROPPER", action });
36456 },
36457 [dispatchWithHistory]
36458 );
36459 const cropperSetters = (0, import_element118.useMemo)(
36460 () => buildCropperSetters(
36461 dispatchCropperAction,
36462 () => stateRef.current.cropper
36463 ),
36464 [dispatchCropperAction]
36465 );
36466 const setImage = (0, import_element118.useCallback)((image) => {
36467 if (areCropperImagesEqual(stateRef.current.cropper.image, image)) {
36468 return;
36469 }
36470 const action = {
36471 type: "CROPPER",
36472 action: { type: "SET_IMAGE", payload: image }
36473 };
36474 const next = mediaEditorReducer(stateRef.current, action);
36475 stateRef.current = next;
36476 dispatch(action);
36477 setInitialBaseline(next);
36478 isGestureOpenRef.current = false;
36479 gestureSnapshotRef.current = null;
36480 historyRef.current = [];
36481 redoStackRef.current = [];
36482 setHasUndo(false);
36483 setHasRedo(false);
36484 }, []);
36485 const reset = (0, import_element118.useCallback)(
36486 (resetState) => {
36487 dispatchWithHistory({
36488 type: "CROPPER",
36489 action: { type: "RESET", payload: resetState }
36490 });
36491 },
36492 [dispatchWithHistory]
36493 );
36494 const setAspectRatioValue = (0, import_element118.useCallback)(
36495 (presetKey) => {
36496 const resolved = resolveAspectRatio(
36497 presetKey,
36498 stateRef.current.cropper.image
36499 );
36500 dispatchWithHistory({
36501 type: "SET_ASPECT_RATIO_VALUE",
36502 payload: {
36503 presetKey,
36504 resolved,
36505 visualSize: visualSizeRef.current
36506 }
36507 });
36508 },
36509 [dispatchWithHistory]
36510 );
36511 const resetCropOptions = (0, import_element118.useCallback)(() => {
36512 dispatchWithHistory({ type: "RESET_CROP_OPTIONS" });
36513 }, [dispatchWithHistory]);
36514 const undo = (0, import_element118.useCallback)(() => {
36515 endGesture();
36516 const prev = historyRef.current[historyRef.current.length - 1];
36517 if (!prev) {
36518 return;
36519 }
36520 redoStackRef.current = [stateRef.current, ...redoStackRef.current];
36521 historyRef.current = historyRef.current.slice(0, -1);
36522 setHasUndo(historyRef.current.length > 0);
36523 setHasRedo(true);
36524 stateRef.current = prev;
36525 dispatch({ type: "RESTORE_SNAPSHOT", payload: prev });
36526 }, [endGesture]);
36527 const redo = (0, import_element118.useCallback)(() => {
36528 endGesture();
36529 const next = redoStackRef.current[0];
36530 if (!next) {
36531 return;
36532 }
36533 historyRef.current = [...historyRef.current, stateRef.current];
36534 redoStackRef.current = redoStackRef.current.slice(1);
36535 setHasUndo(true);
36536 setHasRedo(redoStackRef.current.length > 0);
36537 stateRef.current = next;
36538 dispatch({ type: "RESTORE_SNAPSHOT", payload: next });
36539 }, [endGesture]);
36540 const setVisualSize = (0, import_element118.useCallback)((size4) => {
36541 visualSizeRef.current = size4;
36542 }, []);
36543 const adjustCropRectForViewport = (0, import_element118.useCallback)(
36544 (rect) => {
36545 dispatchWithHistory(
36546 { type: "VIEWPORT_ADJUST_CROP_RECT", payload: rect },
36547 false
36548 );
36549 },
36550 [dispatchWithHistory]
36551 );
36552 const isDirty = !areMediaEditorStatesEqual(state, initialBaseline);
36553 const isCropperDirty = !areCropperStatesEqual(
36554 state.cropper,
36555 initialBaseline.cropper
36556 );
36557 const getCroppedImage = (0, import_element118.useCallback)(
36558 (mimeType, quality) => {
36559 if (!state.cropper.image) {
36560 return Promise.reject(
36561 new Error("No image loaded \u2014 call setImage first.")
36562 );
36563 }
36564 return exportCroppedImage(
36565 state.cropper.image.src,
36566 state.cropper,
36567 mimeType,
36568 quality
36569 );
36570 },
36571 [state.cropper]
36572 );
36573 const controller = (0, import_element118.useMemo)(
36574 () => ({
36575 // CropperController surface (state is the cropper slice so a
36576 // <Cropper> takes this controller as-is).
36577 ...cropperSetters,
36578 state: state.cropper,
36579 setImage,
36580 reset,
36581 isDirty,
36582 getCroppedImage,
36583 // Composite extensions
36584 cropOptions: state.cropOptions,
36585 setAspectRatioValue,
36586 resetCropOptions,
36587 isCropperDirty,
36588 hasUndo,
36589 hasRedo,
36590 undo,
36591 redo,
36592 beginGesture,
36593 endGesture,
36594 setVisualSize,
36595 adjustCropRectForViewport
36596 }),
36597 [
36598 cropperSetters,
36599 state.cropper,
36600 setImage,
36601 reset,
36602 isDirty,
36603 getCroppedImage,
36604 state.cropOptions,
36605 setAspectRatioValue,
36606 resetCropOptions,
36607 isCropperDirty,
36608 hasUndo,
36609 hasRedo,
36610 undo,
36611 redo,
36612 beginGesture,
36613 endGesture,
36614 setVisualSize,
36615 adjustCropRectForViewport
36616 ]
36617 );
36618 return controller;
36619 }
36620
36621 // packages/media-editor/build-module/state/media-editor-state-provider.mjs
36622 var import_element119 = __toESM(require_element(), 1);
36623 var import_jsx_runtime159 = __toESM(require_jsx_runtime(), 1);
36624 var MediaEditorStateContext = (0, import_element119.createContext)(
36625 null
36626 );
36627 function MediaEditorStateProvider({
36628 initialCropperState,
36629 initialCropOptions,
36630 children
36631 }) {
36632 const controller = useMediaEditorState({
36633 cropper: initialCropperState,
36634 cropOptions: initialCropOptions
36635 });
36636 return /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(MediaEditorStateContext.Provider, { value: controller, children });
36637 }
36638 function useMediaEditor() {
36639 const context = (0, import_element119.useContext)(MediaEditorStateContext);
36640 if (!context) {
36641 throw new Error(
36642 "useMediaEditor must be used within a MediaEditorStateProvider."
36643 );
36644 }
36645 return context;
36646 }
36647
36648 // packages/media-editor/build-module/components/media-editor-canvas/index.mjs
36649 var import_jsx_runtime160 = __toESM(require_jsx_runtime(), 1);
36650 function MediaEditorCanvas({
36651 isPlacementActive = false,
36652 onGestureStart,
36653 onGestureEnd,
36654 disabled: disabled2 = false
36655 }) {
36656 const { media } = useMediaEditorContext();
36657 const controller = useMediaEditor();
36658 const { aspectRatioValue } = controller.cropOptions;
36659 const cropperImage = controller.state.image;
36660 const { beginGesture, endGesture, setImage } = controller;
36661 const [status, setStatus] = (0, import_element120.useState)(
36662 "loading"
36663 );
36664 const aspectRatio = (0, import_element120.useMemo)(
36665 () => resolveAspectRatio(aspectRatioValue, cropperImage),
36666 [aspectRatioValue, cropperImage]
36667 );
36668 const handleGestureStart = (0, import_element120.useCallback)(() => {
36669 beginGesture();
36670 onGestureStart?.();
36671 }, [beginGesture, onGestureStart]);
36672 const handleGestureEnd = (0, import_element120.useCallback)(() => {
36673 endGesture();
36674 onGestureEnd?.();
36675 }, [endGesture, onGestureEnd]);
36676 const mediaUrl = media?.source_url;
36677 const mediaType = getMediaTypeFromMimeType(media?.mime_type);
36678 const mediaWidth = Number(media?.media_details?.width);
36679 const mediaHeight = Number(media?.media_details?.height);
36680 (0, import_element120.useEffect)(() => {
36681 if (cropperImage || !mediaUrl || !Number.isFinite(mediaWidth) || !Number.isFinite(mediaHeight) || mediaWidth <= 0 || mediaHeight <= 0) {
36682 return;
36683 }
36684 setImage({
36685 src: mediaUrl,
36686 naturalWidth: mediaWidth,
36687 naturalHeight: mediaHeight
36688 });
36689 }, [cropperImage, mediaUrl, mediaWidth, mediaHeight, setImage]);
36690 const isImage = mediaType.type === "image";
36691 (0, import_element120.useEffect)(() => {
36692 if (!mediaUrl || !isImage) {
36693 return;
36694 }
36695 setStatus("loading");
36696 const probe = new window.Image();
36697 probe.onload = () => setStatus("loaded");
36698 probe.onerror = () => setStatus("error");
36699 probe.src = mediaUrl;
36700 if (probe.complete) {
36701 setStatus(probe.naturalWidth > 0 ? "loaded" : "error");
36702 }
36703 return () => {
36704 probe.onload = null;
36705 probe.onerror = null;
36706 };
36707 }, [mediaUrl, isImage]);
36708 if (!mediaUrl || !isImage) {
36709 return null;
36710 }
36711 if (status === "error") {
36712 return /* @__PURE__ */ (0, import_jsx_runtime160.jsx)("div", { className: "media-editor-canvas", children: /* @__PURE__ */ (0, import_jsx_runtime160.jsx)("div", { className: "media-editor-canvas__error", role: "alert", children: /* @__PURE__ */ (0, import_jsx_runtime160.jsx)("p", { children: (0, import_i18n39.__)("Failed to load image.") }) }) });
36713 }
36714 return /* @__PURE__ */ (0, import_jsx_runtime160.jsxs)("div", { className: "media-editor-canvas", children: [
36715 status === "loading" && /* @__PURE__ */ (0, import_jsx_runtime160.jsx)("div", { className: "media-editor-canvas__spinner", children: /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(import_components32.Spinner, {}) }),
36716 /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(
36717 "div",
36718 {
36719 className: clsx_default("media-editor-canvas__cropper", {
36720 "is-loaded": status === "loaded"
36721 }),
36722 children: /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(
36723 Cropper,
36724 {
36725 src: mediaUrl,
36726 controller,
36727 aspectRatio,
36728 freeformCrop: true,
36729 showGrid: "interactive",
36730 isPlacementActive,
36731 onGestureStart: handleGestureStart,
36732 onGestureEnd: handleGestureEnd,
36733 disabled: disabled2
36734 }
36735 )
36736 }
36737 )
36738 ] });
36739 }
36740
36741 // packages/media-editor/build-module/components/media-editor-fine-rotation/index.mjs
36742 var import_i18n40 = __toESM(require_i18n(), 1);
36743
36744 // packages/media-editor/build-module/hooks/use-crop-gesture-handlers.mjs
36745 var import_element121 = __toESM(require_element(), 1);
36746 var CROP_CONTROL_ATTR = "data-crop-control";
36747 var KEYBOARD_GESTURE_IDLE_MS = 300;
36748 function useCropGestureHandlers(options = {}) {
36749 const { commitOnKeyUp = true } = options;
36750 const { beginGesture, endGesture } = useMediaEditor();
36751 const keyboardTimerRef = (0, import_element121.useRef)();
36752 const clearKeyboardTimer = (0, import_element121.useCallback)(() => {
36753 clearTimeout(keyboardTimerRef.current);
36754 }, []);
36755 const scheduleKeyboardEnd = (0, import_element121.useCallback)(() => {
36756 clearKeyboardTimer();
36757 keyboardTimerRef.current = setTimeout(() => {
36758 endGesture();
36759 }, KEYBOARD_GESTURE_IDLE_MS);
36760 }, [clearKeyboardTimer, endGesture]);
36761 (0, import_element121.useEffect)(() => clearKeyboardTimer, [clearKeyboardTimer]);
36762 const handlePointerDownCapture = (0, import_element121.useCallback)(() => {
36763 clearKeyboardTimer();
36764 beginGesture();
36765 }, [beginGesture, clearKeyboardTimer]);
36766 const handlePointerEnd = (0, import_element121.useCallback)(() => {
36767 clearKeyboardTimer();
36768 endGesture();
36769 }, [clearKeyboardTimer, endGesture]);
36770 const handleKeyDownCapture = (0, import_element121.useCallback)(() => {
36771 beginGesture();
36772 if (!commitOnKeyUp) {
36773 scheduleKeyboardEnd();
36774 }
36775 }, [beginGesture, commitOnKeyUp, scheduleKeyboardEnd]);
36776 const handleKeyUp = (0, import_element121.useCallback)(() => {
36777 if (commitOnKeyUp) {
36778 endGesture();
36779 return;
36780 }
36781 scheduleKeyboardEnd();
36782 }, [commitOnKeyUp, endGesture, scheduleKeyboardEnd]);
36783 return {
36784 [CROP_CONTROL_ATTR]: true,
36785 onPointerDownCapture: handlePointerDownCapture,
36786 onPointerUp: handlePointerEnd,
36787 onPointerCancel: handlePointerEnd,
36788 onKeyDownCapture: handleKeyDownCapture,
36789 onKeyUp: handleKeyUp
36790 };
36791 }
36792
36793 // packages/media-editor/build-module/components/rotation-ruler/index.mjs
36794 var import_element123 = __toESM(require_element(), 1);
36795
36796 // packages/media-editor/build-module/components/rotation-ruler/use-ruler-drag.mjs
36797 var import_element122 = __toESM(require_element(), 1);
36798 function pxToValueDelta(deltaPx, pixelsPerStep, step) {
36799 return -deltaPx / pixelsPerStep * step;
36800 }
36801 function clampValue(value, min4, max4) {
36802 if (value < min4) {
36803 return min4;
36804 }
36805 if (value > max4) {
36806 return max4;
36807 }
36808 return value;
36809 }
36810 function quantize(value, step) {
36811 return Math.round(value / step) * step;
36812 }
36813 function useRulerDrag(options) {
36814 const {
36815 value,
36816 onChange,
36817 min: min4,
36818 max: max4,
36819 step,
36820 pixelsPerStep,
36821 disabled: disabled2,
36822 onPointerDownStart
36823 } = options;
36824 const latestRef = (0, import_element122.useRef)({
36825 value,
36826 startX: 0,
36827 startValue: 0,
36828 activeStep: step,
36829 dragging: false,
36830 captureElement: null,
36831 capturePointerId: 0,
36832 windowPointerUp: null
36833 });
36834 (0, import_element122.useEffect)(() => {
36835 latestRef.current.value = value;
36836 }, [value]);
36837 const endDrag = (0, import_element122.useCallback)(() => {
36838 const state = latestRef.current;
36839 if (!state.dragging) {
36840 return;
36841 }
36842 state.dragging = false;
36843 if (state.captureElement && state.captureElement.hasPointerCapture(state.capturePointerId)) {
36844 state.captureElement.releasePointerCapture(
36845 state.capturePointerId
36846 );
36847 }
36848 state.captureElement = null;
36849 if (state.windowPointerUp) {
36850 window.removeEventListener("pointerup", state.windowPointerUp);
36851 window.removeEventListener(
36852 "pointercancel",
36853 state.windowPointerUp
36854 );
36855 state.windowPointerUp = null;
36856 }
36857 }, []);
36858 (0, import_element122.useEffect)(() => endDrag, [endDrag]);
36859 (0, import_element122.useEffect)(() => {
36860 if (disabled2) {
36861 endDrag();
36862 }
36863 }, [disabled2, endDrag]);
36864 const onPointerDown = (0, import_element122.useCallback)(
36865 (event) => {
36866 if (disabled2 || event.button !== 0) {
36867 return;
36868 }
36869 const state = latestRef.current;
36870 event.currentTarget.setPointerCapture(event.pointerId);
36871 state.captureElement = event.currentTarget;
36872 state.capturePointerId = event.pointerId;
36873 state.startX = event.clientX;
36874 state.startValue = state.value;
36875 state.activeStep = event.shiftKey ? step / 2 : step;
36876 state.dragging = true;
36877 onPointerDownStart?.();
36878 const onWindowUp = () => endDrag();
36879 state.windowPointerUp = onWindowUp;
36880 window.addEventListener("pointerup", onWindowUp);
36881 window.addEventListener("pointercancel", onWindowUp);
36882 },
36883 [disabled2, onPointerDownStart, endDrag, step]
36884 );
36885 const onPointerMove = (0, import_element122.useCallback)(
36886 (event) => {
36887 const state = latestRef.current;
36888 if (disabled2 || !state.dragging) {
36889 return;
36890 }
36891 const requestedStep = event.shiftKey ? step / 2 : step;
36892 if (requestedStep !== state.activeStep) {
36893 state.startX = event.clientX;
36894 state.startValue = state.value;
36895 state.activeStep = requestedStep;
36896 }
36897 const deltaPx = event.clientX - state.startX;
36898 const deltaValue = pxToValueDelta(
36899 deltaPx,
36900 pixelsPerStep,
36901 state.activeStep
36902 );
36903 const raw = state.startValue + deltaValue;
36904 const stepped = quantize(raw, state.activeStep);
36905 const next = clampValue(stepped, min4, max4);
36906 if (next !== state.value) {
36907 state.value = next;
36908 onChange(next);
36909 }
36910 },
36911 [disabled2, onChange, min4, max4, step, pixelsPerStep]
36912 );
36913 return {
36914 onPointerDown,
36915 onPointerMove,
36916 onPointerUp: endDrag,
36917 onPointerCancel: endDrag
36918 };
36919 }
36920
36921 // packages/media-editor/build-module/components/rotation-ruler/index.mjs
36922 var import_jsx_runtime161 = __toESM(require_jsx_runtime(), 1);
36923 var STRIP_HEIGHT = 32;
36924 var LABEL_BASELINE_Y = 11;
36925 var MAJOR_INTERVAL = 15;
36926 var TICK_HEIGHT_MINOR = 4;
36927 var TICK_HEIGHT_MID = 8;
36928 var TICK_HEIGHT_MAJOR = 14;
36929 function useTicks(min4, max4) {
36930 return (0, import_element123.useMemo)(() => {
36931 const out = [];
36932 for (let v2 = Math.ceil(min4); v2 <= Math.floor(max4); v2 += 1) {
36933 let kind = "minor";
36934 let height = TICK_HEIGHT_MINOR;
36935 if (v2 % 15 === 0) {
36936 kind = "major";
36937 height = TICK_HEIGHT_MAJOR;
36938 } else if (v2 % 5 === 0) {
36939 kind = "mid";
36940 height = TICK_HEIGHT_MID;
36941 }
36942 out.push({ value: v2, kind, height });
36943 }
36944 return out;
36945 }, [min4, max4]);
36946 }
36947 function formatValue(value) {
36948 const rounded = Math.round(value * 10) / 10;
36949 return Number.isInteger(rounded) ? rounded.toFixed(0) : rounded.toFixed(1);
36950 }
36951 function RotationRuler(props) {
36952 const {
36953 value,
36954 onChange,
36955 min: min4 = -45,
36956 max: max4 = 45,
36957 step = 1,
36958 label,
36959 unit = "\xB0",
36960 pixelsPerStep = 6,
36961 className,
36962 id,
36963 disabled: disabled2 = false
36964 } = props;
36965 const inputRef = (0, import_element123.useRef)(null);
36966 const generatedId = (0, import_element123.useId)();
36967 const inputId = id ?? generatedId;
36968 const dragHandlers = useRulerDrag({
36969 value,
36970 onChange,
36971 min: min4,
36972 max: max4,
36973 step,
36974 pixelsPerStep,
36975 disabled: disabled2,
36976 onPointerDownStart: () => inputRef.current?.focus()
36977 });
36978 const handleKeyDown = (event) => {
36979 const isIncrement = event.key === "ArrowRight" || event.key === "ArrowUp";
36980 const isDecrement = event.key === "ArrowLeft" || event.key === "ArrowDown";
36981 if (!isIncrement && !isDecrement) {
36982 return;
36983 }
36984 event.preventDefault();
36985 if (disabled2) {
36986 return;
36987 }
36988 const direction = isIncrement ? 1 : -1;
36989 const magnitude = event.shiftKey ? step / 2 : step;
36990 const next = clampValue(value + direction * magnitude, min4, max4);
36991 if (next !== value) {
36992 onChange(next);
36993 }
36994 };
36995 const display = `${formatValue(value)}${unit}`;
36996 const ticks = useTicks(min4, max4);
36997 const pxPerUnit = pixelsPerStep / step;
36998 const stripStyle = (0, import_element123.useMemo)(() => {
36999 const offset4 = -value * pxPerUnit;
37000 return {
37001 transform: `translateX(calc(-50% + ${offset4}px))`
37002 };
37003 }, [value, pxPerUnit]);
37004 const closestMajor = Math.round(value / MAJOR_INTERVAL) * MAJOR_INTERVAL;
37005 const onMajor = Math.abs(value - closestMajor) < 0.01;
37006 const numberText = onMajor ? `${closestMajor}` : formatValue(value);
37007 const isNegative = numberText.startsWith("-");
37008 const digits = isNegative ? numberText.slice(1) : numberText;
37009 const majorTicks = ticks.filter((tick) => tick.kind === "major");
37010 return /* @__PURE__ */ (0, import_jsx_runtime161.jsxs)(
37011 "div",
37012 {
37013 className: clsx_default("rotation-ruler", className),
37014 role: "presentation",
37015 "data-testid": "rotation-ruler",
37016 "data-disabled": disabled2 || void 0,
37017 ...dragHandlers,
37018 children: [
37019 /* @__PURE__ */ (0, import_jsx_runtime161.jsx)(
37020 "input",
37021 {
37022 ref: inputRef,
37023 id: inputId,
37024 type: "range",
37025 className: "rotation-ruler__input",
37026 min: min4,
37027 max: max4,
37028 step: "any",
37029 value,
37030 disabled: disabled2,
37031 "aria-label": label,
37032 "aria-valuetext": display,
37033 onChange: (event) => onChange(
37034 clampValue(event.target.valueAsNumber, min4, max4)
37035 ),
37036 onKeyDown: handleKeyDown
37037 }
37038 ),
37039 /* @__PURE__ */ (0, import_jsx_runtime161.jsx)("div", { className: "rotation-ruler__strip", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime161.jsxs)(
37040 "svg",
37041 {
37042 className: "rotation-ruler__ticks",
37043 style: stripStyle,
37044 width: (max4 - min4) * pxPerUnit,
37045 height: STRIP_HEIGHT,
37046 viewBox: `${min4 * pxPerUnit} 0 ${(max4 - min4) * pxPerUnit} ${STRIP_HEIGHT}`,
37047 preserveAspectRatio: "xMidYMid meet",
37048 children: [
37049 ticks.map((tick) => /* @__PURE__ */ (0, import_jsx_runtime161.jsx)(
37050 "line",
37051 {
37052 x1: tick.value * pxPerUnit,
37053 x2: tick.value * pxPerUnit,
37054 y1: STRIP_HEIGHT - tick.height,
37055 y2: STRIP_HEIGHT,
37056 className: `rotation-ruler__tick rotation-ruler__tick--${tick.kind}`
37057 },
37058 tick.value
37059 )),
37060 majorTicks.map((tick) => /* @__PURE__ */ (0, import_jsx_runtime161.jsxs)(
37061 "text",
37062 {
37063 x: tick.value * pxPerUnit,
37064 y: LABEL_BASELINE_Y,
37065 textAnchor: "middle",
37066 className: "rotation-ruler__label",
37067 children: [
37068 tick.value,
37069 unit
37070 ]
37071 },
37072 tick.value
37073 ))
37074 ]
37075 }
37076 ) }),
37077 /* @__PURE__ */ (0, import_jsx_runtime161.jsx)("div", { className: "rotation-ruler__active-label", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime161.jsxs)("span", { className: "rotation-ruler__active-label-number", children: [
37078 isNegative && /* @__PURE__ */ (0, import_jsx_runtime161.jsx)("span", { className: "rotation-ruler__active-label-sign", children: "-" }),
37079 digits,
37080 /* @__PURE__ */ (0, import_jsx_runtime161.jsx)("span", { className: "rotation-ruler__active-label-unit", children: unit })
37081 ] }) }),
37082 /* @__PURE__ */ (0, import_jsx_runtime161.jsx)("div", { className: "rotation-ruler__pointer", "aria-hidden": "true" })
37083 ]
37084 }
37085 );
37086 }
37087
37088 // packages/media-editor/build-module/components/media-editor-fine-rotation/index.mjs
37089 var import_jsx_runtime162 = __toESM(require_jsx_runtime(), 1);
37090 function MediaEditorFineRotation({
37091 onPlacementControlInteraction,
37092 disabled: disabled2 = false
37093 }) {
37094 const { state, setRotation } = useMediaEditor();
37095 const rotationGestureHandlers = useCropGestureHandlers({
37096 commitOnKeyUp: false
37097 });
37098 const baseAngle = Math.round(state.rotation / 90) * 90;
37099 const singleFlip = state.flip.horizontal !== state.flip.vertical;
37100 const visualDir = singleFlip ? -1 : 1;
37101 const fineOffset = (state.rotation - baseAngle) * visualDir;
37102 const handleRotationSlider = (value) => {
37103 const EPS = 0.01;
37104 const clamped = Math.max(
37105 -MAX_ROTATION_OFFSET + EPS,
37106 Math.min(MAX_ROTATION_OFFSET - EPS, value)
37107 );
37108 onPlacementControlInteraction?.();
37109 setRotation(baseAngle + clamped * visualDir);
37110 };
37111 return /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(
37112 "div",
37113 {
37114 role: "presentation",
37115 className: "media-editor-fine-rotation",
37116 ...rotationGestureHandlers,
37117 children: /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(
37118 RotationRuler,
37119 {
37120 label: (0, import_i18n40.__)("Fine rotation"),
37121 min: -MAX_ROTATION_OFFSET,
37122 max: MAX_ROTATION_OFFSET,
37123 value: fineOffset,
37124 onChange: handleRotationSlider,
37125 disabled: disabled2
37126 }
37127 )
37128 }
37129 );
37130 }
37131
37132 // packages/media-editor/build-module/components/media-editor-crop-panel/index.mjs
37133 var import_components34 = __toESM(require_components(), 1);
37134 var import_i18n42 = __toESM(require_i18n(), 1);
37135
37136 // packages/media-editor/build-module/components/media-editor-image-controls/index.mjs
37137 var import_components33 = __toESM(require_components(), 1);
37138 var import_i18n41 = __toESM(require_i18n(), 1);
37139
37140 // packages/media-editor/build-module/components/media-editor/use-crop-options.mjs
37141 var import_element124 = __toESM(require_element(), 1);
37142 function getAspectRatioOptions(aspectRatioPresets) {
37143 return [
37144 ...DEFAULT_ASPECT_RATIOS.filter((preset) => preset.value <= 0),
37145 ...aspectRatioPresets ?? DEFAULT_ASPECT_RATIOS.filter((preset) => preset.value > 0)
37146 ];
37147 }
37148 function useCropOptions({
37149 aspectRatioPresets
37150 } = {}) {
37151 const controller = useMediaEditor();
37152 const { aspectRatioValue } = controller.cropOptions;
37153 const cropperImage = controller.state.image;
37154 const aspectRatioOptions = (0, import_element124.useMemo)(
37155 () => getAspectRatioOptions(aspectRatioPresets),
37156 [aspectRatioPresets]
37157 );
37158 const resolvedAspectRatio = (0, import_element124.useMemo)(
37159 () => resolveAspectRatio(aspectRatioValue, cropperImage),
37160 [aspectRatioValue, cropperImage]
37161 );
37162 return {
37163 aspectRatioValue,
37164 setAspectRatioValue: controller.setAspectRatioValue,
37165 aspectRatioOptions,
37166 resolvedAspectRatio,
37167 resetCropOptions: controller.resetCropOptions
37168 };
37169 }
37170
37171 // packages/media-editor/build-module/components/media-editor-image-controls/index.mjs
37172 var import_jsx_runtime163 = __toESM(require_jsx_runtime(), 1);
37173 var DEFAULT_ZOOM_FACTOR = 1.2;
37174 function MediaEditorImageControls({
37175 withLabels = false,
37176 showAspectRatioControl = false,
37177 aspectRatioPresets,
37178 zoomFactor = DEFAULT_ZOOM_FACTOR,
37179 disabled: disabled2 = false
37180 }) {
37181 const { state, setFlip, snapRotate90, setZoom } = useMediaEditor();
37182 const { aspectRatioValue, setAspectRatioValue, aspectRatioOptions } = useCropOptions({ aspectRatioPresets });
37183 const hasAspectRatioControl = !withLabels && showAspectRatioControl;
37184 const minZoom = getMinZoom(state);
37185 const zoomByFactor = (factor) => {
37186 setZoom(
37187 Math.min(MAX_ZOOM, Math.max(minZoom, state.zoom * factor))
37188 );
37189 };
37190 const rotateButtons = /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)(import_jsx_runtime163.Fragment, { children: [
37191 /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(
37192 import_components33.Button,
37193 {
37194 size: "compact",
37195 icon: rotate_left_default,
37196 label: (0, import_i18n41.__)("Rotate 90\xB0 counter-clockwise"),
37197 showTooltip: true,
37198 disabled: disabled2,
37199 accessibleWhenDisabled: true,
37200 onClick: () => snapRotate90(-1)
37201 }
37202 ),
37203 /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(
37204 import_components33.Button,
37205 {
37206 size: "compact",
37207 icon: rotate_right_default,
37208 label: (0, import_i18n41.__)("Rotate 90\xB0 clockwise"),
37209 showTooltip: true,
37210 disabled: disabled2,
37211 accessibleWhenDisabled: true,
37212 onClick: () => snapRotate90(1)
37213 }
37214 )
37215 ] });
37216 const flipButtons = /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)(import_jsx_runtime163.Fragment, { children: [
37217 /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(
37218 import_components33.Button,
37219 {
37220 size: "compact",
37221 icon: flip_horizontal_default,
37222 label: (0, import_i18n41.__)("Flip horizontal"),
37223 showTooltip: true,
37224 isPressed: state.flip.horizontal,
37225 disabled: disabled2,
37226 accessibleWhenDisabled: true,
37227 onClick: () => setFlip({
37228 horizontal: !state.flip.horizontal,
37229 vertical: state.flip.vertical
37230 })
37231 }
37232 ),
37233 /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(
37234 import_components33.Button,
37235 {
37236 size: "compact",
37237 icon: flip_vertical_default,
37238 label: (0, import_i18n41.__)("Flip vertical"),
37239 showTooltip: true,
37240 isPressed: state.flip.vertical,
37241 disabled: disabled2,
37242 accessibleWhenDisabled: true,
37243 onClick: () => setFlip({
37244 horizontal: state.flip.horizontal,
37245 vertical: !state.flip.vertical
37246 })
37247 }
37248 )
37249 ] });
37250 const zoomButtons = /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)(import_jsx_runtime163.Fragment, { children: [
37251 /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(
37252 import_components33.Button,
37253 {
37254 size: "compact",
37255 icon: plus_default,
37256 label: (0, import_i18n41.__)("Zoom in"),
37257 showTooltip: true,
37258 disabled: disabled2 || state.zoom >= MAX_ZOOM,
37259 accessibleWhenDisabled: true,
37260 onClick: () => zoomByFactor(zoomFactor)
37261 }
37262 ),
37263 /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(
37264 import_components33.Button,
37265 {
37266 size: "compact",
37267 icon: line_solid_default,
37268 label: (0, import_i18n41.__)("Zoom out"),
37269 showTooltip: true,
37270 disabled: disabled2 || state.zoom <= minZoom,
37271 accessibleWhenDisabled: true,
37272 onClick: () => zoomByFactor(1 / zoomFactor)
37273 }
37274 )
37275 ] });
37276 const aspectRatioDropdown = hasAspectRatioControl ? /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(
37277 import_components33.DropdownMenu,
37278 {
37279 icon: aspect_ratio_default,
37280 label: (0, import_i18n41.__)("Aspect ratio"),
37281 popoverProps: { placement: "top" },
37282 toggleProps: { size: "compact", disabled: disabled2 },
37283 children: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(import_components33.MenuGroup, { label: (0, import_i18n41.__)("Aspect ratio"), children: aspectRatioOptions.map((preset) => {
37284 const value = preset.value.toString();
37285 const isSelected = value === aspectRatioValue;
37286 return /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(
37287 import_components33.MenuItem,
37288 {
37289 role: "menuitemradio",
37290 isSelected,
37291 icon: isSelected ? check_default : void 0,
37292 disabled: disabled2,
37293 onClick: () => {
37294 if (disabled2) {
37295 return;
37296 }
37297 setAspectRatioValue(value);
37298 onClose();
37299 },
37300 children: preset.label
37301 },
37302 value
37303 );
37304 }) })
37305 }
37306 ) : null;
37307 if (withLabels) {
37308 return /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)("div", { className: "media-editor-image-controls is-stacked", children: [
37309 /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)("div", { className: "media-editor-image-controls__transforms", children: [
37310 /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)(
37311 "div",
37312 {
37313 className: "media-editor-image-controls__group",
37314 role: "group",
37315 "aria-label": (0, import_i18n41.__)("Rotate"),
37316 children: [
37317 /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(
37318 "span",
37319 {
37320 className: "media-editor-image-controls__label",
37321 "aria-hidden": "true",
37322 children: (0, import_i18n41.__)("Rotate")
37323 }
37324 ),
37325 /* @__PURE__ */ (0, import_jsx_runtime163.jsx)("div", { className: "media-editor-image-controls__buttons", children: rotateButtons })
37326 ]
37327 }
37328 ),
37329 /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)(
37330 "div",
37331 {
37332 className: "media-editor-image-controls__group",
37333 role: "group",
37334 "aria-label": (0, import_i18n41.__)("Flip"),
37335 children: [
37336 /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(
37337 "span",
37338 {
37339 className: "media-editor-image-controls__label",
37340 "aria-hidden": "true",
37341 children: (0, import_i18n41.__)("Flip")
37342 }
37343 ),
37344 /* @__PURE__ */ (0, import_jsx_runtime163.jsx)("div", { className: "media-editor-image-controls__buttons", children: flipButtons })
37345 ]
37346 }
37347 )
37348 ] }),
37349 /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)(
37350 "div",
37351 {
37352 className: "media-editor-image-controls__group",
37353 role: "group",
37354 "aria-label": (0, import_i18n41.__)("Zoom"),
37355 children: [
37356 /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(
37357 "span",
37358 {
37359 className: "media-editor-image-controls__label",
37360 "aria-hidden": "true",
37361 children: (0, import_i18n41.__)("Zoom")
37362 }
37363 ),
37364 /* @__PURE__ */ (0, import_jsx_runtime163.jsx)("div", { className: "media-editor-image-controls__buttons", children: zoomButtons })
37365 ]
37366 }
37367 )
37368 ] });
37369 }
37370 return /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)("div", { className: "media-editor-image-controls", children: [
37371 rotateButtons,
37372 flipButtons,
37373 zoomButtons,
37374 aspectRatioDropdown
37375 ] });
37376 }
37377
37378 // packages/media-editor/build-module/components/media-editor-crop-panel/index.mjs
37379 var import_jsx_runtime164 = __toESM(require_jsx_runtime(), 1);
37380 function MediaEditorCropPanel({
37381 aspectRatioValue,
37382 onAspectRatioChange,
37383 aspectRatioOptions,
37384 disabled: disabled2 = false
37385 }) {
37386 return (
37387 // Tag the whole panel as a crop-control region so the modal's
37388 // Cmd+Z handler doesn't mistake the SelectControl input for a
37389 // metadata field (which would suppress undo).
37390 /* @__PURE__ */ (0, import_jsx_runtime164.jsxs)(
37391 Stack,
37392 {
37393 direction: "column",
37394 gap: "xl",
37395 ...{ [CROP_CONTROL_ATTR]: true },
37396 children: [
37397 /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime164.jsx)("h2", {}), children: (0, import_i18n42.__)("Crop options") }),
37398 /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(MediaEditorImageControls, { withLabels: true, disabled: disabled2 }),
37399 /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(
37400 import_components34.SelectControl,
37401 {
37402 label: (0, import_i18n42.__)("Aspect ratio"),
37403 value: aspectRatioValue,
37404 onChange: onAspectRatioChange,
37405 disabled: disabled2,
37406 options: aspectRatioOptions.map((preset) => ({
37407 label: preset.label,
37408 value: preset.value.toString()
37409 }))
37410 }
37411 )
37412 ]
37413 }
37414 )
37415 );
37416 }
37417
37418 // packages/media-editor/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs
37419 var import_components35 = __toESM(require_components(), 1);
37420 var import_element125 = __toESM(require_element(), 1);
37421 var import_i18n43 = __toESM(require_i18n(), 1);
37422 var import_keycodes = __toESM(require_keycodes(), 1);
37423 var import_jsx_runtime165 = __toESM(require_jsx_runtime(), 1);
37424 var SHORTCUTS = [
37425 {
37426 description: (0, import_i18n43.__)("Undo"),
37427 keyCombination: { modifier: "primary", character: "z" }
37428 },
37429 {
37430 description: (0, import_i18n43.__)("Redo"),
37431 keyCombination: { modifier: "primaryShift", character: "z" }
37432 },
37433 {
37434 description: (0, import_i18n43.__)("Pan"),
37435 keyCombination: {
37436 character: ["\u2191", "\u2193", "\u2190", "\u2192"],
37437 ariaLabel: (0, import_i18n43.__)("Arrow keys")
37438 }
37439 },
37440 {
37441 description: (0, import_i18n43.__)("Zoom in"),
37442 keyCombination: { character: "+" }
37443 },
37444 {
37445 description: (0, import_i18n43.__)("Zoom out"),
37446 keyCombination: { character: "-" }
37447 },
37448 {
37449 description: (0, import_i18n43.__)("Rotate 90\xB0 clockwise"),
37450 keyCombination: { character: "R" }
37451 },
37452 {
37453 description: (0, import_i18n43.__)("Rotate 90\xB0 counter-clockwise"),
37454 keyCombination: { modifier: "shift", character: "R" }
37455 },
37456 {
37457 description: (0, import_i18n43.__)("Flip horizontal"),
37458 keyCombination: { character: "H" }
37459 },
37460 {
37461 description: (0, import_i18n43.__)("Flip vertical"),
37462 keyCombination: { character: "V" }
37463 },
37464 {
37465 description: (0, import_i18n43.__)("Pan or resize crop (large step)"),
37466 keyCombination: {
37467 modifier: "shift",
37468 character: ["\u2191", "\u2193", "\u2190", "\u2192"],
37469 ariaLabel: (0, import_i18n43.__)("Shift + Arrow keys")
37470 }
37471 }
37472 ];
37473 function KeyCombinationDisplay({
37474 keyCombination
37475 }) {
37476 const { modifier, character, ariaLabel } = keyCombination;
37477 let keys;
37478 if (Array.isArray(character)) {
37479 if (modifier) {
37480 const sample = import_keycodes.displayShortcutList[modifier](character[0]);
37481 keys = [...sample.slice(0, -1), ...character];
37482 } else {
37483 keys = character;
37484 }
37485 } else {
37486 keys = modifier ? import_keycodes.displayShortcutList[modifier](character) : [character];
37487 }
37488 const charString = Array.isArray(character) ? character.join("") : character;
37489 let label;
37490 if (ariaLabel) {
37491 label = ariaLabel;
37492 } else if (modifier) {
37493 label = import_keycodes.shortcutAriaLabel[modifier](charString);
37494 } else {
37495 label = charString;
37496 }
37497 return /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(
37498 "kbd",
37499 {
37500 className: "media-editor-keyboard-shortcuts-modal__shortcut-term",
37501 "aria-label": label,
37502 children: keys.map(
37503 (key, index3) => key === "+" && modifier ? /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(import_element125.Fragment, { children: key }, index3) : /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(
37504 "kbd",
37505 {
37506 className: "media-editor-keyboard-shortcuts-modal__shortcut-key",
37507 children: key
37508 },
37509 index3
37510 )
37511 )
37512 }
37513 );
37514 }
37515 function MediaEditorKeyboardShortcutsModal({
37516 onClose
37517 }) {
37518 return /* @__PURE__ */ (0, import_jsx_runtime165.jsxs)(
37519 import_components35.Modal,
37520 {
37521 className: "media-editor-keyboard-shortcuts-modal",
37522 title: (0, import_i18n43.__)("Keyboard shortcuts"),
37523 onRequestClose: onClose,
37524 children: [
37525 /* @__PURE__ */ (0, import_jsx_runtime165.jsx)("p", { className: "media-editor-keyboard-shortcuts-modal__note", children: (0, import_i18n43.__)(
37526 "These shortcuts work when the image editor has focus."
37527 ) }),
37528 /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(
37529 "ul",
37530 {
37531 className: "media-editor-keyboard-shortcuts-modal__shortcut-list",
37532 role: "list",
37533 children: SHORTCUTS.map(({ description, keyCombination }, index3) => /* @__PURE__ */ (0, import_jsx_runtime165.jsxs)(
37534 "li",
37535 {
37536 className: "media-editor-keyboard-shortcuts-modal__shortcut",
37537 children: [
37538 /* @__PURE__ */ (0, import_jsx_runtime165.jsx)("span", { className: "media-editor-keyboard-shortcuts-modal__shortcut-description", children: description }),
37539 /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(
37540 KeyCombinationDisplay,
37541 {
37542 keyCombination
37543 }
37544 )
37545 ]
37546 },
37547 index3
37548 ))
37549 }
37550 )
37551 ]
37552 }
37553 );
37554 }
37555
37556 // packages/media-editor/build-module/components/media-editor/use-save-media-editor.mjs
37557 var import_api_fetch = __toESM(require_api_fetch(), 1);
37558 var import_data2 = __toESM(require_data(), 1);
37559 var import_core_data = __toESM(require_core_data(), 1);
37560 var import_element126 = __toESM(require_element(), 1);
37561 var import_i18n44 = __toESM(require_i18n(), 1);
37562 var import_notices = __toESM(require_notices(), 1);
37563
37564 // packages/media-editor/build-module/components/media-editor-modal/build-modifiers.mjs
37565 var CROP_TOLERANCE = 0.1;
37566 function buildModifiers(state, imageSize) {
37567 const modifiers = [];
37568 if (imageSize.width === 0 || imageSize.height === 0) {
37569 return modifiers;
37570 }
37571 const { cropRect, pan, zoom, flip: flip4 } = state;
37572 const hasFlipH = flip4.horizontal;
37573 const hasFlipV = flip4.vertical;
37574 if (hasFlipH || hasFlipV) {
37575 modifiers.push({
37576 type: "flip",
37577 args: { flip: { horizontal: hasFlipH, vertical: hasFlipV } }
37578 });
37579 }
37580 const rawAngle = (state.rotation % 360 + 360) % 360;
37581 const singleAxisFlip = hasFlipH !== hasFlipV;
37582 const signedAngle2 = singleAxisFlip ? (360 - rawAngle) % 360 : rawAngle;
37583 if (signedAngle2 !== 0) {
37584 modifiers.push({ type: "rotate", args: { angle: signedAngle2 } });
37585 }
37586 const snapRotation = Math.round(state.rotation / 90) * 90;
37587 const { width: snapW, height: snapH } = getRotatedBBox(
37588 imageSize.width,
37589 imageSize.height,
37590 snapRotation
37591 );
37592 const { width: fullW, height: fullH } = getRotatedBBox(
37593 imageSize.width,
37594 imageSize.height,
37595 state.rotation
37596 );
37597 const imgLeft = 0.5 + pan.x - zoom / 2;
37598 const imgTop = 0.5 + pan.y - zoom / 2;
37599 const snapX = (cropRect.x - imgLeft) / zoom * snapW;
37600 const snapY = (cropRect.y - imgTop) / zoom * snapH;
37601 const widthPx = cropRect.width / zoom * snapW;
37602 const heightPx = cropRect.height / zoom * snapH;
37603 const offsetX = (fullW - snapW) / 2;
37604 const offsetY = (fullH - snapH) / 2;
37605 const fullX = snapX + offsetX;
37606 const fullY = snapY + offsetY;
37607 const leftPct = fullX / fullW * 100;
37608 const topPct = fullY / fullH * 100;
37609 const widthPct = widthPx / fullW * 100;
37610 const heightPct = heightPx / fullH * 100;
37611 const coversFullFrame = leftPct <= CROP_TOLERANCE && topPct <= CROP_TOLERANCE && widthPct >= 100 - CROP_TOLERANCE && heightPct >= 100 - CROP_TOLERANCE;
37612 if (!coversFullFrame) {
37613 modifiers.push({
37614 type: "crop",
37615 args: {
37616 left: leftPct,
37617 top: topPct,
37618 width: widthPct,
37619 height: heightPct
37620 }
37621 });
37622 }
37623 return modifiers;
37624 }
37625
37626 // packages/media-editor/build-module/components/media-editor/use-save-media-editor.mjs
37627 var METADATA_EDIT_KEYS = [
37628 "title",
37629 "caption",
37630 "description",
37631 "alt_text",
37632 "post"
37633 ];
37634 var MEDIA_EDITOR_NOTICES_CONTEXT = "media-editor";
37635 function getCropModifiers(cropper) {
37636 if (!cropper.isCropperDirty || !cropper.state.image) {
37637 return [];
37638 }
37639 return buildModifiers(cropper.state, {
37640 width: cropper.state.image.naturalWidth,
37641 height: cropper.state.image.naturalHeight
37642 });
37643 }
37644 function getMetadataEdits(pendingEdits, media) {
37645 const metadataEdits = {};
37646 for (const key of METADATA_EDIT_KEYS) {
37647 if (pendingEdits && key in pendingEdits) {
37648 metadataEdits[key] = pendingEdits[key];
37649 }
37650 }
37651 if (!("post" in metadataEdits) && media?.post !== void 0) {
37652 metadataEdits.post = media.post;
37653 }
37654 return metadataEdits;
37655 }
37656 function useSaveMediaEditor({
37657 cropper,
37658 id,
37659 isImage,
37660 media,
37661 onSaved
37662 }) {
37663 const registry = (0, import_data2.useRegistry)();
37664 const {
37665 clearEntityRecordEdits,
37666 receiveEntityRecords,
37667 saveEditedEntityRecord
37668 } = (0, import_data2.useDispatch)(import_core_data.store);
37669 const { createErrorNotice, removeAllNotices } = (0, import_data2.useDispatch)(import_notices.store);
37670 const [isSaving, setIsSaving] = (0, import_element126.useState)(false);
37671 const save = (0, import_element126.useCallback)(async () => {
37672 removeAllNotices("snackbar", MEDIA_EDITOR_NOTICES_CONTEXT);
37673 setIsSaving(true);
37674 try {
37675 let saved;
37676 const modifiers = getCropModifiers(cropper);
37677 const previous = modifiers.length > 0 && media ? {
37678 id,
37679 url: media.source_url
37680 } : void 0;
37681 if (modifiers.length > 0) {
37682 const pendingEdits = registry.select(import_core_data.store).getEntityRecordNonTransientEdits(
37683 "postType",
37684 "attachment",
37685 id
37686 );
37687 const metadataEdits = getMetadataEdits(pendingEdits, media);
37688 saved = await (0, import_api_fetch.default)({
37689 path: `/wp/v2/media/${id}/edit`,
37690 method: "POST",
37691 data: {
37692 src: media?.source_url,
37693 modifiers,
37694 ...metadataEdits
37695 }
37696 });
37697 if (saved) {
37698 receiveEntityRecords(
37699 "postType",
37700 "attachment",
37701 saved,
37702 void 0,
37703 true
37704 );
37705 }
37706 } else {
37707 saved = await saveEditedEntityRecord(
37708 "postType",
37709 "attachment",
37710 id
37711 );
37712 }
37713 const next = saved ?? media;
37714 if (next && next.id !== id) {
37715 clearEntityRecordEdits("postType", "attachment", id);
37716 }
37717 if (next && next.id) {
37718 if (next.id === id) {
37719 cropper.reset();
37720 }
37721 onSaved?.({
37722 id: next.id,
37723 url: next.source_url,
37724 media: next,
37725 previous
37726 });
37727 }
37728 } catch (error2) {
37729 const message2 = error2 instanceof Error ? error2.message : error2?.message ?? (0, import_i18n44.__)("An unknown error occurred.");
37730 createErrorNotice(
37731 isImage ? (0, import_i18n44.sprintf)(
37732 /* translators: %s: Error message. */
37733 (0, import_i18n44.__)("Could not save image. %s"),
37734 message2
37735 ) : (0, import_i18n44.sprintf)(
37736 /* translators: %s: Error message. */
37737 (0, import_i18n44.__)("Could not save media. %s"),
37738 message2
37739 ),
37740 {
37741 type: "snackbar",
37742 context: MEDIA_EDITOR_NOTICES_CONTEXT
37743 }
37744 );
37745 } finally {
37746 setIsSaving(false);
37747 }
37748 }, [
37749 clearEntityRecordEdits,
37750 createErrorNotice,
37751 cropper,
37752 id,
37753 isImage,
37754 media,
37755 onSaved,
37756 receiveEntityRecords,
37757 registry,
37758 removeAllNotices,
37759 saveEditedEntityRecord
37760 ]);
37761 return { isSaving, save };
37762 }
37763
37764 // packages/media-editor/build-module/components/media-editor/index.mjs
37765 var import_jsx_runtime166 = __toESM(require_jsx_runtime(), 1);
37766 var ATTACHMENT_EMBED_QUERY = { _embed: "author,wp:attached-to" };
37767 var PLACEMENT_CONTROL_IDLE_MS = 300;
37768 var DETAILS_PANEL = "details";
37769 var CROP_PANEL = "crop";
37770 function MediaEditorSidebar({
37771 tabs,
37772 activeTab,
37773 onSelectTab,
37774 disabled: disabled2 = false
37775 }) {
37776 return /* @__PURE__ */ (0, import_jsx_runtime166.jsxs)(
37777 navigable_region_default,
37778 {
37779 className: "media-editor__sidebar",
37780 ariaLabel: (0, import_i18n45.__)("Media settings"),
37781 children: [
37782 /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime166.jsx)("h2", {}), children: (0, import_i18n45.__)("Media settings") }),
37783 /* @__PURE__ */ (0, import_jsx_runtime166.jsxs)(
37784 tabs_exports.Root,
37785 {
37786 className: "media-editor__tabs",
37787 value: activeTab,
37788 onValueChange: onSelectTab,
37789 children: [
37790 /* @__PURE__ */ (0, import_jsx_runtime166.jsx)("div", { className: "media-editor__tablist", children: /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(tabs_exports.List, { variant: "minimal", children: tabs.map((tab) => /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(
37791 tabs_exports.Tab,
37792 {
37793 value: tab.id,
37794 disabled: disabled2,
37795 children: tab.title
37796 },
37797 tab.id
37798 )) }) }),
37799 tabs.map((tab) => /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(
37800 tabs_exports.Panel,
37801 {
37802 value: tab.id,
37803 tabIndex: -1,
37804 className: "media-editor__panel",
37805 children: /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(Stack, { direction: "column", gap: "lg", children: tab.render() })
37806 },
37807 tab.id
37808 ))
37809 ]
37810 }
37811 )
37812 ]
37813 }
37814 );
37815 }
37816 var MediaEditorFrameContext = (0, import_element127.createContext)(null);
37817 function useMediaEditorFrameContext() {
37818 const context = (0, import_element127.useContext)(MediaEditorFrameContext);
37819 if (!context) {
37820 throw new Error(
37821 "useMediaEditorFrameContext must be used within MediaEditor"
37822 );
37823 }
37824 return context;
37825 }
37826 function HeaderActions({ showCloseButton = false }) {
37827 const { isImage, isSaving, onCancel, isWide, activePanel, onTogglePanel } = useMediaEditorFrameContext();
37828 const isPanelOpen = !!activePanel;
37829 const [isShortcutsModalOpen, setIsShortcutsModalOpen] = (0, import_element127.useState)(false);
37830 return /* @__PURE__ */ (0, import_jsx_runtime166.jsxs)(
37831 Stack,
37832 {
37833 className: "media-editor__header-actions",
37834 justify: "flex-end",
37835 align: "center",
37836 gap: "sm",
37837 children: [
37838 isImage && /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(
37839 import_components36.Button,
37840 {
37841 size: "compact",
37842 icon: keyboard_default,
37843 label: (0, import_i18n45.__)("Keyboard shortcuts"),
37844 onClick: () => setIsShortcutsModalOpen(true)
37845 }
37846 ),
37847 /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(
37848 import_components36.Button,
37849 {
37850 size: "compact",
37851 icon: drawer_right_default,
37852 label: (0, import_i18n45.__)("Media settings"),
37853 isPressed: isPanelOpen,
37854 "aria-expanded": isWide ? isPanelOpen : void 0,
37855 onClick: onTogglePanel
37856 }
37857 ),
37858 showCloseButton && /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(
37859 import_components36.Button,
37860 {
37861 size: "compact",
37862 icon: close_default,
37863 label: (0, import_i18n45.__)("Close"),
37864 onClick: onCancel,
37865 disabled: isSaving,
37866 accessibleWhenDisabled: true
37867 }
37868 ),
37869 isShortcutsModalOpen && /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(
37870 MediaEditorKeyboardShortcutsModal,
37871 {
37872 onClose: () => setIsShortcutsModalOpen(false)
37873 }
37874 )
37875 ]
37876 }
37877 );
37878 }
37879 function HistoryActions() {
37880 const { isImage, isUndoRedoDisabled, onReset, isWide, activePanel } = useMediaEditorFrameContext();
37881 const {
37882 reset,
37883 isDirty,
37884 hasUndo,
37885 hasRedo,
37886 undo: undoCrop,
37887 redo: redoCrop,
37888 beginGesture,
37889 endGesture
37890 } = useMediaEditor();
37891 if (!isImage || !isWide && !!activePanel) {
37892 return null;
37893 }
37894 const handleUndo = () => {
37895 if (isUndoRedoDisabled) {
37896 return;
37897 }
37898 undoCrop();
37899 };
37900 const handleRedo = () => {
37901 if (isUndoRedoDisabled) {
37902 return;
37903 }
37904 redoCrop();
37905 };
37906 const handleReset = () => {
37907 if (isUndoRedoDisabled) {
37908 return;
37909 }
37910 beginGesture();
37911 reset();
37912 onReset();
37913 endGesture();
37914 };
37915 return /* @__PURE__ */ (0, import_jsx_runtime166.jsxs)(
37916 Stack,
37917 {
37918 className: "media-editor__history-actions",
37919 align: "center",
37920 gap: "sm",
37921 children: [
37922 /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(
37923 import_components36.Button,
37924 {
37925 size: "compact",
37926 variant: "tertiary",
37927 disabled: isUndoRedoDisabled || !isDirty,
37928 accessibleWhenDisabled: true,
37929 onClick: handleReset,
37930 children: (0, import_i18n45.__)("Reset")
37931 }
37932 ),
37933 /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(
37934 import_components36.Button,
37935 {
37936 size: "compact",
37937 icon: undo_default,
37938 label: (0, import_i18n45.__)("Undo"),
37939 showTooltip: true,
37940 shortcut: import_keycodes2.displayShortcut.primary("z"),
37941 disabled: isUndoRedoDisabled || !hasUndo,
37942 accessibleWhenDisabled: true,
37943 onClick: handleUndo
37944 }
37945 ),
37946 /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(
37947 import_components36.Button,
37948 {
37949 size: "compact",
37950 icon: redo_default,
37951 label: (0, import_i18n45.__)("Redo"),
37952 showTooltip: true,
37953 shortcut: (0, import_keycodes2.isAppleOS)() ? import_keycodes2.displayShortcut.primaryShift("z") : import_keycodes2.displayShortcut.primary("y"),
37954 disabled: isUndoRedoDisabled || !hasRedo,
37955 accessibleWhenDisabled: true,
37956 onClick: handleRedo
37957 }
37958 )
37959 ]
37960 }
37961 );
37962 }
37963 function SaveActions({ size: size4 = "default" }) {
37964 const { isSaving, hasMedia, hasChanges, onCancel, onSave } = useMediaEditorFrameContext();
37965 const saveDisabled = isSaving || !hasMedia || !hasChanges;
37966 return /* @__PURE__ */ (0, import_jsx_runtime166.jsxs)(
37967 Stack,
37968 {
37969 className: "media-editor__save-actions",
37970 justify: "flex-end",
37971 align: "center",
37972 gap: "sm",
37973 children: [
37974 /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(
37975 import_components36.Button,
37976 {
37977 __next40pxDefaultSize: true,
37978 size: size4,
37979 variant: "tertiary",
37980 onClick: onCancel,
37981 disabled: isSaving,
37982 accessibleWhenDisabled: true,
37983 children: (0, import_i18n45.__)("Cancel")
37984 }
37985 ),
37986 /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(
37987 import_components36.Button,
37988 {
37989 __next40pxDefaultSize: true,
37990 size: size4,
37991 variant: "primary",
37992 onClick: onSave,
37993 isBusy: isSaving,
37994 disabled: saveDisabled,
37995 accessibleWhenDisabled: true,
37996 children: (0, import_i18n45.__)("Save")
37997 }
37998 )
37999 ]
38000 }
38001 );
38002 }
38003 function MediaEditorContent({
38004 fields = [],
38005 id,
38006 aspectRatioPresets,
38007 onClose,
38008 onSaved,
38009 renderFrame,
38010 noticesClassName = "media-editor__snackbar",
38011 noticesPortalElement,
38012 shouldCloseOnEsc = false
38013 }) {
38014 const cropper = useMediaEditor();
38015 const isWide = (0, import_compose19.useViewportMatch)("small");
38016 const [activePanel, setActivePanel] = (0, import_element127.useState)(
38017 isWide ? DETAILS_PANEL : null
38018 );
38019 const hasChosenPanelRef = (0, import_element127.useRef)(false);
38020 const lastPanelRef = (0, import_element127.useRef)(DETAILS_PANEL);
38021 const hasChosenTabRef = (0, import_element127.useRef)(false);
38022 const selectPanel = (0, import_element127.useCallback)((panel) => {
38023 hasChosenTabRef.current = true;
38024 lastPanelRef.current = panel;
38025 setActivePanel(panel);
38026 }, []);
38027 const togglePanel = (0, import_element127.useCallback)(() => {
38028 hasChosenPanelRef.current = true;
38029 setActivePanel((open3) => open3 ? null : lastPanelRef.current);
38030 }, []);
38031 const layout = isWide ? "wide" : "narrow";
38032 const { media, hasEdits } = (0, import_data3.useSelect)(
38033 (select) => {
38034 const {
38035 getEditedEntityRecord,
38036 getEntityRecord,
38037 hasEditsForEntityRecord
38038 } = select(import_core_data2.store);
38039 getEntityRecord(
38040 "postType",
38041 "attachment",
38042 id,
38043 ATTACHMENT_EMBED_QUERY
38044 );
38045 return {
38046 media: getEditedEntityRecord(
38047 "postType",
38048 "attachment",
38049 id
38050 ),
38051 hasEdits: hasEditsForEntityRecord(
38052 "postType",
38053 "attachment",
38054 id
38055 )
38056 };
38057 },
38058 [id]
38059 );
38060 const hasChanges = cropper.isCropperDirty || hasEdits;
38061 const { clearEntityRecordEdits, editEntityRecord, invalidateResolution } = (0, import_data3.useDispatch)(import_core_data2.store);
38062 const { removeAllNotices } = (0, import_data3.useDispatch)(import_notices2.store);
38063 const [isDiscardDialogOpen, setIsDiscardDialogOpen] = (0, import_element127.useState)(false);
38064 const [isPlacementActive, setIsPlacementActive] = (0, import_element127.useState)(false);
38065 const [isCanvasGestureActive, setIsCanvasGestureActive] = (0, import_element127.useState)(false);
38066 const placementControlTimerRef = (0, import_element127.useRef)();
38067 const signalPlacementControlInteraction = (0, import_element127.useCallback)(() => {
38068 setIsPlacementActive(true);
38069 clearTimeout(placementControlTimerRef.current);
38070 placementControlTimerRef.current = setTimeout(() => {
38071 setIsPlacementActive(false);
38072 }, PLACEMENT_CONTROL_IDLE_MS);
38073 }, []);
38074 const handleCanvasGestureStart = (0, import_element127.useCallback)(() => {
38075 setIsCanvasGestureActive(true);
38076 }, []);
38077 const handleCanvasGestureEnd = (0, import_element127.useCallback)(() => {
38078 setIsCanvasGestureActive(false);
38079 }, []);
38080 const isCropInteractionActive = isPlacementActive || isCanvasGestureActive;
38081 (0, import_element127.useEffect)(() => {
38082 return () => {
38083 clearTimeout(placementControlTimerRef.current);
38084 };
38085 }, []);
38086 (0, import_element127.useEffect)(() => {
38087 setIsPlacementActive(false);
38088 setIsCanvasGestureActive(false);
38089 }, [id]);
38090 (0, import_element127.useEffect)(() => {
38091 invalidateResolution("getEntityRecord", [
38092 "postType",
38093 "attachment",
38094 id,
38095 ATTACHMENT_EMBED_QUERY
38096 ]);
38097 }, [id, invalidateResolution]);
38098 const mediaType = getMediaTypeFromMimeType(media?.mime_type).type;
38099 const isImage = !!media && mediaType === "image";
38100 (0, import_element127.useEffect)(() => {
38101 if (hasChosenPanelRef.current && hasChosenTabRef.current) {
38102 return;
38103 }
38104 const defaultPanel = isWide && isImage ? CROP_PANEL : DETAILS_PANEL;
38105 if (!hasChosenTabRef.current) {
38106 lastPanelRef.current = defaultPanel;
38107 }
38108 if (!hasChosenPanelRef.current) {
38109 setActivePanel(isWide ? lastPanelRef.current : null);
38110 }
38111 }, [isWide, isImage]);
38112 const {
38113 aspectRatioValue,
38114 setAspectRatioValue,
38115 aspectRatioOptions,
38116 resetCropOptions
38117 } = useCropOptions({ aspectRatioPresets });
38118 const { isSaving, save: saveMediaEditor } = useSaveMediaEditor({
38119 cropper,
38120 id,
38121 isImage,
38122 media,
38123 onSaved
38124 });
38125 const handleChange = (updates) => {
38126 if (isSaving) {
38127 return;
38128 }
38129 editEntityRecord("postType", "attachment", id, updates);
38130 };
38131 const discardAndClose = () => {
38132 removeAllNotices("snackbar", MEDIA_EDITOR_NOTICES_CONTEXT);
38133 clearEntityRecordEdits("postType", "attachment", id);
38134 onClose?.();
38135 };
38136 const handleRequestClose = () => {
38137 if (isSaving) {
38138 return;
38139 }
38140 if (hasChanges) {
38141 setIsDiscardDialogOpen(true);
38142 return;
38143 }
38144 discardAndClose();
38145 };
38146 const handleKeyDown = (event) => {
38147 const isUndoShortcut = import_keycodes2.isKeyboardEvent.primary(event, "z");
38148 const isRedoShortcut = import_keycodes2.isKeyboardEvent.primaryShift(event, "z") || !(0, import_keycodes2.isAppleOS)() && import_keycodes2.isKeyboardEvent.primary(event, "y");
38149 if ((isUndoShortcut || isRedoShortcut) && isImage) {
38150 const target = event.target;
38151 const isMetadataField = (target.tagName === "INPUT" || target.tagName === "TEXTAREA" || target.isContentEditable) && !target.closest(`[${CROP_CONTROL_ATTR}]`);
38152 if (!isMetadataField) {
38153 event.preventDefault();
38154 if (isCropInteractionActive || isSaving) {
38155 return;
38156 }
38157 if (isRedoShortcut) {
38158 cropper.redo();
38159 } else {
38160 cropper.undo();
38161 }
38162 }
38163 }
38164 if (shouldCloseOnEsc) {
38165 if (event.code !== "Escape" && event.key !== "Escape") {
38166 return;
38167 }
38168 if (isSaving) {
38169 event.preventDefault();
38170 return;
38171 }
38172 if (hasChanges) {
38173 event.preventDefault();
38174 setIsDiscardDialogOpen(true);
38175 }
38176 }
38177 };
38178 const snackbar = /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(
38179 import_notices2.SnackbarNotices,
38180 {
38181 className: noticesClassName,
38182 context: MEDIA_EDITOR_NOTICES_CONTEXT
38183 }
38184 );
38185 const imageControls = isImage && !isWide ? /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(
38186 MediaEditorImageControls,
38187 {
38188 showAspectRatioControl: true,
38189 aspectRatioPresets,
38190 disabled: isSaving
38191 }
38192 ) : null;
38193 const tabs = [
38194 ...isImage ? [
38195 {
38196 id: CROP_PANEL,
38197 title: (0, import_i18n45.__)("Crop"),
38198 render: () => /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(
38199 MediaEditorCropPanel,
38200 {
38201 aspectRatioValue,
38202 onAspectRatioChange: setAspectRatioValue,
38203 aspectRatioOptions,
38204 disabled: isSaving
38205 }
38206 )
38207 }
38208 ] : [],
38209 {
38210 id: DETAILS_PANEL,
38211 title: (0, import_i18n45.__)("Details"),
38212 render: () => /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(MediaForm, {})
38213 }
38214 ];
38215 const ruler = isImage ? /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(
38216 MediaEditorFineRotation,
38217 {
38218 onPlacementControlInteraction: signalPlacementControlInteraction,
38219 disabled: isSaving
38220 }
38221 ) : null;
38222 const children = /* @__PURE__ */ (0, import_jsx_runtime166.jsxs)(
38223 MediaEditorProvider,
38224 {
38225 value: media ?? void 0,
38226 onChange: handleChange,
38227 settings: {
38228 // Disable the fields while saving, so the guard in
38229 // `handleChange` is not silently swallowing typing.
38230 // `readOnly` would swap the field's layout mid-save;
38231 // disabled keeps it in place and greys it out.
38232 fields: isSaving ? fields.map((field) => ({
38233 ...field,
38234 isDisabled: true
38235 })) : fields
38236 },
38237 children: [
38238 /* @__PURE__ */ (0, import_jsx_runtime166.jsx)("div", { className: "media-editor", children: !media ? /* @__PURE__ */ (0, import_jsx_runtime166.jsx)("div", { className: "media-editor__loading", children: /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(import_components36.Spinner, {}) }) : /* @__PURE__ */ (0, import_jsx_runtime166.jsxs)(
38239 "div",
38240 {
38241 className: clsx_default("media-editor__body", {
38242 "has-panel-open": !!activePanel
38243 }),
38244 children: [
38245 /* @__PURE__ */ (0, import_jsx_runtime166.jsxs)(
38246 navigable_region_default,
38247 {
38248 className: "media-editor__content",
38249 ariaLabel: isImage ? (0, import_i18n45.__)("Image editor") : (0, import_i18n45.__)("Media preview"),
38250 children: [
38251 /* @__PURE__ */ (0, import_jsx_runtime166.jsx)("div", { className: "media-editor__canvas-area", children: isImage ? /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(
38252 MediaEditorCanvas,
38253 {
38254 isPlacementActive,
38255 onGestureStart: handleCanvasGestureStart,
38256 onGestureEnd: handleCanvasGestureEnd,
38257 disabled: isSaving
38258 }
38259 ) : /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(MediaPreview, {}) }),
38260 isImage && /* @__PURE__ */ (0, import_jsx_runtime166.jsxs)("div", { className: "media-editor__canvas-toolbar", children: [
38261 ruler,
38262 imageControls
38263 ] })
38264 ]
38265 }
38266 ),
38267 !!activePanel && /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(
38268 MediaEditorSidebar,
38269 {
38270 tabs,
38271 activeTab: tabs.some(
38272 (tab) => tab.id === activePanel
38273 ) ? activePanel : DETAILS_PANEL,
38274 onSelectTab: selectPanel,
38275 disabled: isSaving
38276 }
38277 )
38278 ]
38279 }
38280 ) }),
38281 /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(
38282 import_components36.__experimentalConfirmDialog,
38283 {
38284 isOpen: isDiscardDialogOpen,
38285 confirmButtonText: (0, import_i18n45.__)("Discard"),
38286 cancelButtonText: (0, import_i18n45.__)("Keep editing"),
38287 onCancel: () => setIsDiscardDialogOpen(false),
38288 onConfirm: () => {
38289 setIsDiscardDialogOpen(false);
38290 discardAndClose();
38291 },
38292 children: (0, import_i18n45.__)(
38293 "Are you sure you want to discard your unsaved changes?"
38294 )
38295 }
38296 ),
38297 noticesPortalElement ? (0, import_element127.createPortal)(snackbar, noticesPortalElement) : snackbar
38298 ]
38299 }
38300 );
38301 const contextValue = {
38302 isImage,
38303 isSaving,
38304 hasMedia: !!media,
38305 hasChanges,
38306 // Saving freezes the whole edit surface: `save()` reads the
38307 // modifiers once and then awaits, so anything changed after that
38308 // would be silently dropped when the save resolves.
38309 isUndoRedoDisabled: isCropInteractionActive || isSaving,
38310 aspectRatioPresets,
38311 isWide,
38312 activePanel,
38313 onTogglePanel: togglePanel,
38314 onCancel: handleRequestClose,
38315 onSave: saveMediaEditor,
38316 onReset: resetCropOptions
38317 };
38318 return /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(MediaEditorFrameContext.Provider, { value: contextValue, children: renderFrame({
38319 children,
38320 isImage,
38321 layout,
38322 onRequestClose: handleRequestClose,
38323 onKeyDown: handleKeyDown,
38324 shouldCloseOnClickOutside: !hasChanges && !isSaving,
38325 isSaving,
38326 hasChanges,
38327 hasMedia: !!media
38328 }) });
38329 }
38330 function MediaEditor(props) {
38331 return /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(MediaEditorStateProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(MediaEditorContent, { ...props }) }, props.id);
38332 }
38333 MediaEditor.HeaderActions = HeaderActions;
38334 MediaEditor.HistoryActions = HistoryActions;
38335 MediaEditor.SaveActions = SaveActions;
38336 var media_editor_default = MediaEditor;
38337
38338 // packages/media-editor/build-module/components/media-editor-modal/index.mjs
38339 var import_jsx_runtime167 = __toESM(require_jsx_runtime(), 1);
38340 function ModalFooter() {
38341 return /* @__PURE__ */ (0, import_jsx_runtime167.jsxs)(
38342 "div",
38343 {
38344 className: "media-editor-modal__footer",
38345 role: "region",
38346 "aria-label": (0, import_i18n46.__)("Editor actions"),
38347 children: [
38348 /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(media_editor_default.HistoryActions, {}),
38349 /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(media_editor_default.SaveActions, {})
38350 ]
38351 }
38352 );
38353 }
38354 function MediaEditorModal({
38355 fields = [],
38356 aspectRatioPresets
38357 }) {
38358 const { isModalOpen, id, onUpdate, onClose } = (0, import_data4.useSelect)((select) => {
38359 const { isOpen: isOpen2, getId: getId2, getOnUpdate: getOnUpdate2, getOnClose: getOnClose2 } = select(store);
38360 return {
38361 isModalOpen: isOpen2(),
38362 id: getId2(),
38363 onUpdate: getOnUpdate2(),
38364 onClose: getOnClose2()
38365 };
38366 }, []);
38367 const { closeMediaEditorModal: closeMediaEditorModal2 } = (0, import_data4.useDispatch)(store);
38368 const { createSuccessNotice } = (0, import_data4.useDispatch)(import_notices3.store);
38369 if (!isModalOpen || !id) {
38370 return null;
38371 }
38372 const portalElement = typeof document === "undefined" ? null : document.body;
38373 const stopKeyDownPropagation = (event) => {
38374 event.stopPropagation();
38375 };
38376 const handleClose = () => {
38377 closeMediaEditorModal2();
38378 onClose?.();
38379 };
38380 return /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(
38381 media_editor_default,
38382 {
38383 id,
38384 fields,
38385 aspectRatioPresets,
38386 shouldCloseOnEsc: true,
38387 noticesClassName: "media-editor-modal__snackbar",
38388 noticesPortalElement: portalElement,
38389 onClose: handleClose,
38390 onSaved: ({ id: savedId, url, previous }) => {
38391 if (savedId && onUpdate) {
38392 const update2 = {
38393 id: savedId,
38394 url
38395 };
38396 onUpdate(update2);
38397 }
38398 handleClose();
38399 if (previous && savedId !== previous.id && onUpdate) {
38400 createSuccessNotice((0, import_i18n46.__)("Image edited."), {
38401 type: "snackbar",
38402 actions: [
38403 {
38404 label: (0, import_i18n46.__)("Undo"),
38405 onClick: () => {
38406 onUpdate({
38407 id: previous.id,
38408 url: previous.url
38409 });
38410 }
38411 }
38412 ]
38413 });
38414 }
38415 },
38416 renderFrame: ({
38417 children,
38418 onRequestClose,
38419 onKeyDown,
38420 shouldCloseOnClickOutside
38421 }) => /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(
38422 import_keyboard_shortcuts.ShortcutProvider,
38423 {
38424 className: "media-editor-modal__shortcut-scope",
38425 onKeyDown: stopKeyDownPropagation,
38426 children: /* @__PURE__ */ (0, import_jsx_runtime167.jsxs)(
38427 import_components37.Modal,
38428 {
38429 className: "media-editor-modal",
38430 title: (0, import_i18n46.__)("Edit media"),
38431 size: "fill",
38432 isDismissible: false,
38433 shouldCloseOnClickOutside,
38434 onKeyDown,
38435 onRequestClose,
38436 headerActions: /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(media_editor_default.HeaderActions, { showCloseButton: true }),
38437 children: [
38438 children,
38439 /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(ModalFooter, {})
38440 ]
38441 }
38442 )
38443 }
38444 )
38445 }
38446 );
38447 }
38448
38449 // packages/media-editor/build-module/private-apis.mjs
38450 var privateApis = {};
38451 lock2(privateApis, {
38452 store,
38453 MediaEditor,
38454 MediaEditorModal
38455 });
38456
38457 // routes/media-editor/stage.tsx
38458 import { useNavigate, useParams } from "@wordpress/route";
38459
38460 // routes/lock-unlock/index.ts
38461 var import_private_apis4 = __toESM(require_private_apis());
38462 var { lock: lock3, unlock: unlock3 } = (0, import_private_apis4.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
38463 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
38464 "@wordpress/routes"
38465 );
38466
38467 // routes/media-editor/style.scss
38468 if (typeof document !== "undefined" && (typeof process === "undefined" || true) && !document.head.querySelector("style[data-wp-hash='12da0bb9bd']")) {
38469 const style = document.createElement("style");
38470 style.setAttribute("data-wp-hash", "12da0bb9bd");
38471 style.appendChild(document.createTextNode('.media-editor-preview{align-items:center;box-sizing:border-box;display:flex;justify-content:center;min-height:100%;padding:32px;position:relative}.media-editor-preview__spinner{left:50%;position:absolute;top:50%;transform:translate(-50%,-50%)}.media-editor-preview--loading{height:100%;width:100%}.media-editor-preview--image img{height:auto;max-height:100%;max-width:100%;object-fit:contain;opacity:0;width:auto}@media not (prefers-reduced-motion){.media-editor-preview--image img.loaded{animation:__wp-base-styles-fade-in .08s linear 0s;animation-fill-mode:forwards}}.media-editor-preview--video video{height:auto;max-height:100%;max-width:100%;object-fit:contain;width:auto}.media-editor-preview--audio audio{max-width:100%}.media-editor-preview--file{text-align:center}.media-editor-preview__file-info{background:#f0f0f0;border-radius:2px;padding:24px}.media-editor-preview__file-name{font-weight:var(--wpds-typography-font-weight-emphasis,600);margin-bottom:8px}.media-editor-preview__mime-type{color:#757575;font-size:.9em;margin-bottom:16px}.media-editor-preview__download-link{display:inline-block;margin-top:8px}.media-editor-preview--empty,.media-editor-preview--error{color:#757575;text-align:center}.media-editor-preview__url{color:#949494;font-size:.9em;margin-top:8px;word-break:break-all}.wp-media-editor-image-editor{cursor:grab;height:100%;overflow:hidden;position:relative;touch-action:none;-webkit-user-select:none;user-select:none;width:100%}.wp-media-editor-image-editor__canvas{inset:24px;min-height:100px;min-width:100px;position:absolute}.wp-media-editor-image-editor__canvas:focus{outline:none}.wp-media-editor-image-editor__stage{inset:0;position:absolute}.wp-media-editor-image-editor--dragging{cursor:grabbing}.wp-media-editor-image-editor__image{left:0;position:absolute;top:0;transform-origin:center center;will-change:transform}.wp-media-editor-image-editor__stencil{pointer-events:none;position:absolute}.wp-media-editor-image-editor__dimming{box-shadow:0 0 0 9999px hsla(0,0%,88%,.6);pointer-events:none;position:absolute;transition:box-shadow .15s ease}.wp-media-editor-image-editor--dragging .wp-media-editor-image-editor__dimming{box-shadow:0 0 0 9999px hsla(0,0%,88%,.4)}.wp-media-editor-image-editor__grid{overflow:hidden;pointer-events:none;position:absolute;transition:opacity .15s ease}.wp-media-editor-image-editor__canvas--grid-interactive .wp-media-editor-image-editor__grid{opacity:0;transition-delay:.1s}.wp-media-editor-image-editor__canvas--show-grid .wp-media-editor-image-editor__grid{opacity:1;transition-delay:0s}.wp-media-editor-image-editor__canvas--settling .wp-media-editor-image-editor__grid{opacity:0;transition:none}.wp-media-editor-image-editor__grid-line{background:hsla(0,0%,100%,.4);position:absolute}.wp-media-editor-image-editor__grid-line--horizontal{height:1px;left:0;width:100%}.wp-media-editor-image-editor__grid-line--vertical{height:100%;top:0;width:1px}.wp-media-editor-image-editor__dimensions-tooltip{background:#fff;box-shadow:0 0 0 1px rgba(0,0,0,.06),0 1px 2px rgba(0,0,0,.08);color:#1e1e1e;font-size:11px;font-variant-numeric:tabular-nums;line-height:1.4;padding:2px 6px;pointer-events:none;position:absolute;white-space:nowrap;z-index:2}.wp-media-editor-image-editor__stencil-rect{border:1px solid #1e1e1e;box-sizing:border-box;pointer-events:none;position:absolute;transition:border-color .15s ease,box-shadow .15s ease}.wp-media-editor-image-editor__canvas--focus-visible:focus .wp-media-editor-image-editor__stencil-rect{border-color:var(--wp-image-editor-focus-color,var(--wp-admin-theme-color,#007cba));box-shadow:0 0 0 1px var(--wp-image-editor-focus-color,var(--wp-admin-theme-color,#007cba))}.wp-media-editor-image-editor__handle{appearance:none;background:#fff;border:1px solid var(--wp-admin-theme-color,#007cba);border-radius:50%;box-sizing:border-box;cursor:default;font:inherit;height:12px;margin:0;padding:0;pointer-events:auto;position:absolute;transition:background-color .15s ease,box-shadow .15s ease;width:12px}.wp-media-editor-image-editor__handle:focus{outline:none}.wp-media-editor-image-editor__canvas--focus-visible .wp-media-editor-image-editor__handle:focus{background:var(--wp-image-editor-focus-color,var(--wp-admin-theme-color,#007cba));border-color:transparent;box-shadow:0 0 0 2px #fff,0 0 0 4px var(--wp-image-editor-focus-color,var(--wp-admin-theme-color,#007cba))}.wp-media-editor-image-editor__handle:before{content:"";height:44px;left:50%;position:absolute;top:50%;transform:translate(-50%,-50%);width:44px}.wp-media-editor-image-editor__handle--n{cursor:ns-resize;left:50%;margin-left:-6px;top:-6px}.wp-media-editor-image-editor__handle--s{bottom:-6px;cursor:ns-resize;left:50%;margin-left:-6px}.wp-media-editor-image-editor__handle--e{cursor:ew-resize;margin-top:-6px;right:-6px;top:50%}.wp-media-editor-image-editor__handle--w{cursor:ew-resize;left:-6px;margin-top:-6px;top:50%}.wp-media-editor-image-editor__handle--nw{cursor:nwse-resize;left:-6px;top:-6px}.wp-media-editor-image-editor__handle--ne{cursor:nesw-resize;right:-6px;top:-6px}.wp-media-editor-image-editor__handle--sw{bottom:-6px;cursor:nesw-resize;left:-6px}.wp-media-editor-image-editor__handle--se{bottom:-6px;cursor:nwse-resize;right:-6px}.media-editor{display:flex;flex:1;flex-direction:column;height:100%;min-height:0}.media-editor .media-editor__loading{align-items:center;display:flex;height:100%;justify-content:center}.media-editor .media-editor__body{container-name:media-editor-body;container-type:inline-size;display:flex;flex:1;min-height:0}.media-editor .media-editor__content{display:flex;flex:1;flex-direction:column;margin:24px 24px 8px;min-height:0;min-width:0}@media (min-width:600px){.media-editor .media-editor__content{margin:0 24px}}@container media-editor-body (min-width: 864px){.media-editor .media-editor__content{min-width:520px}}.media-editor .media-editor__canvas-toolbar{align-items:center;display:flex;flex:0 0 auto;flex-direction:column;gap:12px}.media-editor .media-editor__canvas-toolbar .media-editor-fine-rotation{align-self:stretch;background:#e0e0e0;border-radius:0 0 8px 8px;display:flex;justify-content:center;padding:8px 16px}.media-editor .media-editor__canvas-toolbar .media-editor-fine-rotation .rotation-ruler{flex:0 1 360px;min-width:0}.media-editor .media-editor__canvas-area{align-items:center;background:#e0e0e0;border-radius:8px;display:flex;flex:1;justify-content:center;min-height:0;overflow:auto}.media-editor .media-editor__canvas-area .media-editor-preview{height:100%}.media-editor .media-editor__canvas-area img,.media-editor .media-editor__canvas-area video{max-height:100%;max-width:100%;object-fit:contain}.media-editor .media-editor__sidebar{display:flex;flex:1;flex-direction:column;min-height:0;min-width:0;overflow:hidden}@media (min-width:600px){.media-editor .media-editor__sidebar{flex:none;width:var(--wpds-dimension-surface-width-sm,320px)}}.media-editor .media-editor__tabs{display:flex;flex:1;flex-direction:column;min-height:0}.media-editor .media-editor__tablist{background:#fff;border-bottom:1px solid #ddd;flex-shrink:0;margin-inline:24px}.media-editor .media-editor__panel{flex:1;min-height:0;overflow-y:auto;padding-block:24px;padding-inline:24px}.media-editor .media-editor__content:has(.media-editor-fine-rotation) .media-editor__canvas-area{border-end-end-radius:0;border-end-start-radius:0}.media-editor .media-editor__body.has-panel-open .media-editor__content{display:none}@media (min-width:600px){.media-editor .media-editor__body.has-panel-open .media-editor__content{display:flex;margin:0 0 0 24px}}.media-editor__snackbar{bottom:var(--wpds-dimension-size-md,32px);box-sizing:border-box;display:flex;flex-direction:column;left:0;padding-inline:16px;pointer-events:none;position:fixed;right:0}.media-editor__snackbar .components-snackbar{margin-inline:auto}.media-editor-form .dataforms-layouts-panel__field-control{text-wrap:pretty}.media-editor-modal.components-modal__frame .components-modal__content{display:flex;flex-direction:column;margin-bottom:0;min-height:0;padding:0}.media-editor-modal.components-modal__frame .components-modal__children-container{display:flex;flex:1;flex-direction:column;min-height:0}.media-editor-modal.components-modal__frame .media-editor-modal__footer{align-items:center;background:#fff;display:flex;flex-direction:row;flex-shrink:0;gap:16px;padding:24px}.media-editor-modal.components-modal__frame .media-editor-modal__footer .media-editor__save-actions{margin-left:auto}.media-editor-modal .media-editor__history-actions .components-button.has-icon:not([aria-disabled=true]){color:var(--wp-admin-theme-color)}.media-editor-modal,.media-editor-modal__snackbar{display:flex;flex-direction:column}.media-editor-modal__snackbar{bottom:var(--wpds-dimension-size-md,32px);box-sizing:border-box;left:0;padding-inline:16px;pointer-events:none;position:fixed;right:0}.media-editor-modal__snackbar .components-snackbar{margin-inline:auto}.media-editor-modal__snackbar{z-index:1000001}.media-editor-canvas{height:100%;position:relative;width:100%}.media-editor-canvas__cropper{height:100%;opacity:0;pointer-events:none;width:100%}.media-editor-canvas__cropper.is-loaded{opacity:1;pointer-events:auto}@keyframes __wp-base-styles-fade-in{0%{opacity:0}to{opacity:1}}@media not (prefers-reduced-motion){.media-editor-canvas__cropper.is-loaded{animation:__wp-base-styles-fade-in .2s linear 0s;animation-fill-mode:forwards}}.media-editor-canvas__spinner{left:50%;position:absolute;top:50%;transform:translate(-50%,-50%)}.media-editor-canvas__error{align-items:center;color:#757575;display:flex;height:100%;justify-content:center;text-align:center;width:100%}.media-editor-image-controls{align-items:center;display:flex;flex-wrap:nowrap;gap:8px}.media-editor-image-controls.is-stacked{align-items:flex-start;flex-direction:column;gap:24px}.media-editor-image-controls__transforms{display:flex;gap:48px}.media-editor-image-controls__group{display:flex;flex-direction:column;gap:4px}.media-editor-image-controls__label{font-size:11px;font-weight:var(--wpds-typography-font-weight-emphasis,600);line-height:1.4;text-transform:uppercase}.media-editor-image-controls__buttons{display:flex;gap:8px;padding-inline:2px 0}.media-editor-keyboard-shortcuts-modal{min-width:280px}.media-editor-keyboard-shortcuts-modal .media-editor-keyboard-shortcuts-modal__note{color:#757575;font-size:13px;margin:0 0 16px}.media-editor-keyboard-shortcuts-modal .media-editor-keyboard-shortcuts-modal__shortcut-list{list-style:none;margin:0;padding:0}.media-editor-keyboard-shortcuts-modal .media-editor-keyboard-shortcuts-modal__shortcut{align-items:baseline;border-top:1px solid #ddd;display:flex;margin-bottom:0;padding:.6rem 0}.media-editor-keyboard-shortcuts-modal .media-editor-keyboard-shortcuts-modal__shortcut:last-child{border-bottom:1px solid #ddd}.media-editor-keyboard-shortcuts-modal .media-editor-keyboard-shortcuts-modal__shortcut-description{flex:1;margin:0}.media-editor-keyboard-shortcuts-modal .media-editor-keyboard-shortcuts-modal__shortcut-term{background:none;font-weight:var(--wpds-typography-font-weight-emphasis,600);margin:0 0 0 1rem;padding:0;text-align:right}.media-editor-keyboard-shortcuts-modal .media-editor-keyboard-shortcuts-modal__shortcut-key{border-radius:8%;margin:0 .2rem;padding:.25rem .5rem}.media-editor-keyboard-shortcuts-modal .media-editor-keyboard-shortcuts-modal__shortcut-key:last-child{margin:0 0 0 .2rem}.rotation-ruler{box-sizing:border-box;color:#1e1e1e;container-type:inline-size;cursor:ew-resize;direction:ltr;font-family:-apple-system,system-ui,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;height:32px;min-width:180px;padding:0 8px;position:relative;touch-action:none;-webkit-user-select:none;user-select:none}.rotation-ruler[data-disabled]{cursor:default;opacity:.5;pointer-events:none}.rotation-ruler:has(.rotation-ruler__input:focus-visible){border-radius:4px;outline:2px solid var(--wp-admin-theme-color,#3858e9);outline-offset:2px}.rotation-ruler__input{border:0;clip-path:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px}.rotation-ruler__pointer{background:var(--wp-admin-theme-color,#3858e9);border-radius:1px;bottom:0;height:18px;left:50%;pointer-events:none;position:absolute;transform:translateX(-50%);width:2px}.rotation-ruler__strip{inset:0;mask-image:linear-gradient(90deg,transparent 0,#000 8px,#000 calc(100% - 8px),transparent);-webkit-mask-image:linear-gradient(90deg,transparent 0,#000 8px,#000 calc(100% - 8px),transparent);overflow:hidden;position:absolute}.rotation-ruler__ticks{display:block;left:50%;overflow:visible;position:absolute;top:0}.rotation-ruler__tick{stroke:currentColor;stroke-width:1}.rotation-ruler__tick--minor{opacity:.35}.rotation-ruler__tick--mid{opacity:.6}.rotation-ruler__tick--major{opacity:1}.rotation-ruler__label{fill:currentColor;font-size:10px;font-weight:400;opacity:.45}.rotation-ruler__active-label{color:#1e1e1e;font-size:12px;font-weight:var(--wpds-typography-font-weight-emphasis,600);height:14px;left:50%;line-height:14px;pointer-events:none;position:absolute;top:0;transform:translateX(-50%)}.rotation-ruler__active-label:before{background:linear-gradient(90deg,transparent 0,#e0e0e0 12px,#e0e0e0 calc(100% - 12px),transparent);content:"";height:100%;left:50%;position:absolute;top:0;transform:translateX(-50%);width:60px}.rotation-ruler__active-label-number{display:inline-block;position:relative}.rotation-ruler__active-label-sign{position:absolute;right:100%;top:0}.rotation-ruler__active-label-unit{left:100%;position:absolute;top:0}@container (max-width: 220px){.rotation-ruler__tick--minor{opacity:0}}@media (prefers-reduced-motion:reduce){.rotation-ruler__ticks{transition:none}}.media-editor-route__shortcut-scope{display:contents}.media-editor-route__content{background-color:var(--wpds-color-background-surface-neutral-strong,#fff);display:flex;flex:1;min-height:0;overflow:hidden}.media-editor-route__content .media-editor__body{margin-bottom:0}@media (min-width:600px){.media-editor-route__content .media-editor__body{margin-bottom:24px}}.media-editor-route__toolbar{align-items:center;display:flex;flex-shrink:0;flex-wrap:wrap;gap:16px;justify-content:center;padding:16px 32px}.media-editor-route__toolbar:empty{display:none}'));
38472 document.head.appendChild(style);
38473 }
38474
38475 // routes/media-editor/stage.tsx
38476 var import_jsx_runtime168 = __toESM(require_jsx_runtime());
38477 var { usePostFields } = unlock3(import_editor.privateApis);
38478 var { MediaEditor: MediaEditor2 } = unlock3(privateApis);
38479 var MEDIA_LIST_PATH = "/types/attachment/list/all";
38480 var MEDIA_LIBRARY_ADMIN_PATH = "upload.php";
38481 var MEDIA_EDITOR_ADMIN_PAGE = "media-editor-wp-admin";
38482 function isMediaEditorAdminPage() {
38483 return typeof window !== "undefined" && new URLSearchParams(window.location.search).get("page") === MEDIA_EDITOR_ADMIN_PAGE;
38484 }
38485 function getMediaTitle(media) {
38486 const title = typeof media?.title === "string" ? media.title : media?.title?.rendered || media?.title?.raw;
38487 return title ? (0, import_html_entities.decodeEntities)(title) : (0, import_i18n47.__)("Edit media");
38488 }
38489 function MediaEditorRoute() {
38490 const { id } = useParams({ from: "/media-editor/$id" });
38491 const attachmentId = parseInt(id, 10);
38492 const navigate = useNavigate();
38493 const fields = usePostFields({ postType: "attachment" });
38494 const isStandaloneAdminPage = isMediaEditorAdminPage();
38495 const media = (0, import_data5.useSelect)(
38496 (select) => (
38497 /* The record of an attachment is always assignable to `Media`. */
38498 select(import_core_data3.store).getEditedEntityRecord(
38499 "postType",
38500 "attachment",
38501 attachmentId
38502 )
38503 ),
38504 [attachmentId]
38505 );
38506 const title = getMediaTitle(media || null);
38507 const navigateBack = () => {
38508 if (typeof window !== "undefined" && window.history.length > 1) {
38509 window.history.back();
38510 return;
38511 }
38512 if (isStandaloneAdminPage) {
38513 window.location.assign(MEDIA_LIBRARY_ADMIN_PATH);
38514 return;
38515 }
38516 navigate({ to: MEDIA_LIST_PATH });
38517 };
38518 return /* @__PURE__ */ (0, import_jsx_runtime168.jsx)(
38519 MediaEditor2,
38520 {
38521 id: attachmentId,
38522 fields,
38523 onClose: navigateBack,
38524 onSaved: ({ id: savedId }) => {
38525 if (savedId !== attachmentId) {
38526 navigate({ to: `/media-editor/${savedId}` });
38527 }
38528 },
38529 renderFrame: ({
38530 children,
38531 isImage,
38532 layout,
38533 onKeyDown
38534 }) => {
38535 const isNarrow = layout === "narrow";
38536 return (
38537 // The keydown handler covers the whole frame, not just the
38538 // canvas: undo/redo live in the header, so after clicking
38539 // one, focus sits outside the content region and the
38540 // keyboard shortcuts would no longer reach the handler.
38541 // `Page` takes no `onKeyDown`, hence the wrapper; it is
38542 // `display: contents`, so it adds no box to the layout.
38543 // eslint-disable-next-line jsx-a11y/no-static-element-interactions
38544 /* @__PURE__ */ (0, import_jsx_runtime168.jsx)(
38545 "div",
38546 {
38547 className: "media-editor-route__shortcut-scope",
38548 onKeyDown,
38549 children: /* @__PURE__ */ (0, import_jsx_runtime168.jsxs)(
38550 page_default,
38551 {
38552 className: "media-editor-route",
38553 ariaLabel: title,
38554 breadcrumbs: /* @__PURE__ */ (0, import_jsx_runtime168.jsx)(
38555 breadcrumbs_default,
38556 {
38557 items: isStandaloneAdminPage ? [{ label: title }] : [
38558 {
38559 label: (0, import_i18n47.__)("Media"),
38560 to: MEDIA_LIST_PATH
38561 },
38562 { label: title }
38563 ]
38564 }
38565 ),
38566 actions: /* @__PURE__ */ (0, import_jsx_runtime168.jsxs)(import_jsx_runtime168.Fragment, { children: [
38567 !isNarrow && /* @__PURE__ */ (0, import_jsx_runtime168.jsx)(MediaEditor2.HistoryActions, {}),
38568 /* @__PURE__ */ (0, import_jsx_runtime168.jsx)(MediaEditor2.HeaderActions, {}),
38569 /* @__PURE__ */ (0, import_jsx_runtime168.jsx)(MediaEditor2.SaveActions, { size: "compact" })
38570 ] }),
38571 children: [
38572 /* @__PURE__ */ (0, import_jsx_runtime168.jsx)("div", { className: "media-editor-route__content", children }),
38573 isNarrow && isImage && /* @__PURE__ */ (0, import_jsx_runtime168.jsx)("div", { className: "media-editor-route__toolbar", children: /* @__PURE__ */ (0, import_jsx_runtime168.jsx)(MediaEditor2.HistoryActions, {}) })
38574 ]
38575 }
38576 )
38577 }
38578 )
38579 );
38580 }
38581 }
38582 );
38583 }
38584 var stage = MediaEditorRoute;
38585 export {
38586 stage
38587 };
38588 /*! Bundled license information:
38589
38590 use-sync-external-store/cjs/use-sync-external-store-shim.development.js:
38591 (**
38592 * @license React
38593 * use-sync-external-store-shim.development.js
38594 *
38595 * Copyright (c) Meta Platforms, Inc. and affiliates.
38596 *
38597 * This source code is licensed under the MIT license found in the
38598 * LICENSE file in the root directory of this source tree.
38599 *)
38600
38601 use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js:
38602 (**
38603 * @license React
38604 * use-sync-external-store-shim/with-selector.development.js
38605 *
38606 * Copyright (c) Meta Platforms, Inc. and affiliates.
38607 *
38608 * This source code is licensed under the MIT license found in the
38609 * LICENSE file in the root directory of this source tree.
38610 *)
38611 */
38612