@mattisvensson/strapi-plugin-webatlas 0.11.5 → 0.11.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4249 +0,0 @@
1
- "use strict";
2
- const React = require("react");
3
- const jsxRuntime = require("react/jsx-runtime");
4
- const icons = require("@strapi/icons");
5
- const admin = require("@strapi/strapi/admin");
6
- const designSystem = require("@strapi/design-system");
7
- const reactIntl = require("react-intl");
8
- const ReactDOM = require("react-dom");
9
- function _interopNamespace(e) {
10
- if (e && e.__esModule) return e;
11
- const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
12
- if (e) {
13
- for (const k in e) {
14
- if (k !== "default") {
15
- const d = Object.getOwnPropertyDescriptor(e, k);
16
- Object.defineProperty(n, k, d.get ? d : {
17
- enumerable: true,
18
- get: () => e[k]
19
- });
20
- }
21
- }
22
- }
23
- n.default = e;
24
- return Object.freeze(n);
25
- }
26
- const React__namespace = /* @__PURE__ */ _interopNamespace(React);
27
- const ReactDOM__namespace = /* @__PURE__ */ _interopNamespace(ReactDOM);
28
- const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
29
- const v = glob[path];
30
- if (v) {
31
- return typeof v === "function" ? v() : Promise.resolve(v);
32
- }
33
- return new Promise((_, reject) => {
34
- (typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(
35
- reject.bind(
36
- null,
37
- new Error(
38
- "Unknown variable dynamic import: " + path + (path.split("/").length !== segs ? ". Note that variables only represent file names one level deep." : "")
39
- )
40
- )
41
- );
42
- });
43
- };
44
- function transformToUrl(input, replaceSlash = true) {
45
- const specialCharMap = {
46
- ü: "ue",
47
- ä: "ae",
48
- ö: "oe",
49
- ß: "ss"
50
- };
51
- if (!input || typeof input !== "string") return "";
52
- input = input.toLowerCase();
53
- input = input.replace(/\/+/g, "/");
54
- input = input.startsWith("/") ? input.slice(1) : input;
55
- input = input.endsWith("/") ? input.slice(0, -1) : input;
56
- if (replaceSlash) {
57
- input = input.replace(/\//g, "-");
58
- } else {
59
- input = input.replace(/\/+/g, "/");
60
- input = input.startsWith("/") ? input.slice(1) : input;
61
- input = input.endsWith("/") ? input.slice(0, -1) : input;
62
- }
63
- for (const char in specialCharMap) {
64
- const regex = new RegExp(char, "g");
65
- input = input.replace(regex, specialCharMap[char]);
66
- }
67
- input = input.trim();
68
- input = input.replace(/\s+/g, "-");
69
- input = input.replace(/[^A-Za-z0-9$\-_.+!*'()/]/g, "");
70
- input = input.replace(/-+/g, "-");
71
- return input;
72
- }
73
- const version = "0.11.4";
74
- const strapi$1 = { "name": "webatlas", "displayName": "Webatlas" };
75
- const pluginPkg = {
76
- version,
77
- strapi: strapi$1
78
- };
79
- const PLUGIN_ID = pluginPkg.strapi.name.replace(/^(@[^-,.][\w,-]+\/|strapi-)plugin-/i, "") || "webatlas";
80
- const PLUGIN_NAME = pluginPkg.strapi.displayName;
81
- const PLUGIN_VERSION = pluginPkg.version;
82
- const Initializer = ({ setPlugin }) => {
83
- const ref = React.useRef(setPlugin);
84
- React.useEffect(() => {
85
- ref.current(PLUGIN_ID);
86
- }, []);
87
- return null;
88
- };
89
- const PathIcon = () => /* @__PURE__ */ jsxRuntime.jsx(icons.Link, {});
90
- const NavigationIcon = () => /* @__PURE__ */ jsxRuntime.jsx(icons.List, {});
91
- function useApi() {
92
- const { get, put, del, post } = admin.useFetchClient();
93
- const fetchAllContentTypes = async () => {
94
- try {
95
- const { data } = await get("/content-manager/content-types");
96
- return data.data;
97
- } catch (error) {
98
- strapi.log.error("Cannot fetch all content types:", error);
99
- return [];
100
- }
101
- };
102
- const fetchConfiguredContentTypes = async () => {
103
- try {
104
- const { data: config } = await get(`/${PLUGIN_ID}/config`);
105
- const configuredTypes = config?.selectedContentTypes || [];
106
- if (configuredTypes.length === 0) {
107
- return [];
108
- }
109
- const allContentTypes = await fetchAllContentTypes();
110
- const configuredUIDs = new Set(configuredTypes.map((ct) => ct.uid));
111
- return allContentTypes.filter((ct) => configuredUIDs.has(ct.uid));
112
- } catch (err) {
113
- strapi.log.error("Error fetching configured content types:", err);
114
- return [];
115
- }
116
- };
117
- const fetchAllEntities = async () => {
118
- try {
119
- const { data } = await get(`/${PLUGIN_ID}/config`);
120
- const contentTypes = data?.selectedContentTypes || [];
121
- if (!contentTypes || contentTypes.length === 0) {
122
- return [];
123
- }
124
- let entities = [];
125
- const entityResults = await Promise.allSettled(
126
- contentTypes.map(async (contentType) => {
127
- try {
128
- const { data: data2 } = await get(
129
- `/content-manager/collection-types/${contentType.uid}?pageSize=9999`
130
- );
131
- if (!data2 || !data2.results) {
132
- return null;
133
- }
134
- return {
135
- entities: data2.results,
136
- contentType
137
- };
138
- } catch (err) {
139
- strapi.log.error(`Cannot access entities for ${contentType.uid}:`, err);
140
- return null;
141
- }
142
- })
143
- );
144
- entities = entityResults.map((result) => result.status === "fulfilled" ? result.value : null).filter(Boolean);
145
- return entities;
146
- } catch (err) {
147
- strapi.log.error("Error fetching entities:", err);
148
- throw err;
149
- }
150
- };
151
- const getRelatedRoute = async (relatedDocumentId) => {
152
- const { data } = await get(`/${PLUGIN_ID}/route/related?documentId=${relatedDocumentId}`);
153
- return data;
154
- };
155
- const getRoute = async (documentId) => {
156
- const { data } = await get(`/${PLUGIN_ID}/route/${documentId}`);
157
- return data;
158
- };
159
- const getAllRoutes = async () => {
160
- const { data } = await get(`/${PLUGIN_ID}/route`);
161
- return data;
162
- };
163
- const getProhibitedRouteIds = async (documentId) => {
164
- const { data } = await get(
165
- `/${PLUGIN_ID}/route/prohibitedIds/${documentId ? `${documentId}` : ""}`
166
- );
167
- return data;
168
- };
169
- const getNavigation = async ({
170
- documentId,
171
- variant
172
- } = {}) => {
173
- const query = [];
174
- if (documentId) query.push(`documentId=${documentId}`);
175
- if (variant) query.push(`variant=${variant}`);
176
- const { data } = await get(
177
- `/${PLUGIN_ID}/navigation${query.length > 0 ? `?${query.join("&")}` : ""}`
178
- );
179
- return data;
180
- };
181
- const createNavigation = async (body) => {
182
- const { data } = await post(`/${PLUGIN_ID}/navigation`, {
183
- data: body
184
- });
185
- return data;
186
- };
187
- const deleteNavigation = async (documentId) => {
188
- const { data } = await del(`/${PLUGIN_ID}/navigation?documentId=${documentId}`);
189
- return data;
190
- };
191
- const updateNavigation = async (documentId, body) => {
192
- const { data } = await put(`/${PLUGIN_ID}/navigation?documentId=${documentId}`, {
193
- data: body
194
- });
195
- return data;
196
- };
197
- const updateNavigationItemStructure = async (documentId, navigationItems) => {
198
- const { data } = await put(`/${PLUGIN_ID}/navigation/items`, {
199
- navigationId: documentId,
200
- navigationItems
201
- });
202
- return data;
203
- };
204
- return {
205
- fetchAllContentTypes,
206
- fetchConfiguredContentTypes,
207
- fetchAllEntities,
208
- getRelatedRoute,
209
- getRoute,
210
- getAllRoutes,
211
- getProhibitedRouteIds,
212
- getNavigation,
213
- createNavigation,
214
- deleteNavigation,
215
- updateNavigation,
216
- updateNavigationItemStructure
217
- };
218
- }
219
- const useAllContentTypes = () => {
220
- const { fetchAllContentTypes } = useApi();
221
- const [contentTypes, setContentTypes] = React.useState([]);
222
- const [loading, setLoading] = React.useState(true);
223
- const [error, setError] = React.useState(null);
224
- React.useEffect(() => {
225
- const fetchEntities = async () => {
226
- try {
227
- const result = await fetchAllContentTypes();
228
- setContentTypes(result);
229
- setLoading(false);
230
- } catch (err) {
231
- setError(err);
232
- setLoading(false);
233
- }
234
- };
235
- fetchEntities();
236
- }, []);
237
- return { contentTypes, loading, error };
238
- };
239
- function usePluginConfig() {
240
- const { put, get } = admin.useFetchClient();
241
- const [config, setConfigData] = React.useState(null);
242
- const [loading, setLoading] = React.useState(true);
243
- const [fetchError, setFetchError] = React.useState(null);
244
- React.useEffect(() => {
245
- const fetchData = async () => {
246
- setLoading(true);
247
- setFetchError(null);
248
- try {
249
- const {
250
- data: { data: contentTypesArray }
251
- } = await get("/content-manager/content-types");
252
- let { data: config2 } = await get(`/${PLUGIN_ID}/config`);
253
- if (!config2 || !config2.selectedContentTypes) {
254
- throw new Error(`Couldn't fetch plugin config`);
255
- }
256
- const allowedContentTypes = contentTypesArray.filter(
257
- (type) => type.pluginOptions?.webatlas?.enabled === true
258
- );
259
- const contentTypeUids = new Set(allowedContentTypes.map((type) => type.uid));
260
- const activeContentTypes = config2.selectedContentTypes.filter(
261
- (type) => contentTypeUids.has(type.uid)
262
- );
263
- const displayConfig = {
264
- ...config2,
265
- selectedContentTypes: activeContentTypes
266
- };
267
- setConfigData(displayConfig);
268
- } catch (error) {
269
- setFetchError(error.message);
270
- } finally {
271
- setLoading(false);
272
- }
273
- };
274
- fetchData();
275
- }, []);
276
- async function setConfig(body) {
277
- try {
278
- await put(`/${PLUGIN_ID}/config`, { ...body });
279
- } catch (error) {
280
- throw error;
281
- }
282
- }
283
- return { config, loading, fetchError, setConfig };
284
- }
285
- function debounce(func, wait) {
286
- let timeout;
287
- return function executedFunction(...args) {
288
- const later = () => {
289
- clearTimeout(timeout);
290
- func(...args);
291
- };
292
- clearTimeout(timeout);
293
- timeout = setTimeout(later, wait);
294
- };
295
- }
296
- async function duplicateCheck({
297
- fetchFunction,
298
- path,
299
- routeDocumentId,
300
- withoutTransform = false
301
- }) {
302
- if (!path) throw new Error("URL is required");
303
- try {
304
- const pathToCheck = withoutTransform ? path : transformToUrl(path);
305
- const { data } = await fetchFunction(
306
- `/${PLUGIN_ID}/checkUniquePath?path=${pathToCheck}${routeDocumentId ? `&targetRouteDocumentId=${routeDocumentId}` : ""}`
307
- );
308
- if (!data.uniquePath) {
309
- throw new Error("Network response was not ok");
310
- }
311
- return data.uniquePath;
312
- } catch (err) {
313
- throw new Error("Failed to check URL uniqueness: " + err.message);
314
- }
315
- }
316
- const getTranslation = (id) => `${PLUGIN_ID}.${id}`;
317
- function PathInfo({ validationState, replacement }) {
318
- const [color, setColor] = React.useState("neutral800");
319
- const [text, setText] = React.useState(null);
320
- const { formatMessage } = reactIntl.useIntl();
321
- React.useEffect(() => {
322
- if (validationState === "initial") return;
323
- if (validationState === "checking") {
324
- setColor("neutral800");
325
- setText(
326
- formatMessage({
327
- id: getTranslation("components.pathInfo.checking"),
328
- defaultMessage: "Checking if path is available..."
329
- })
330
- );
331
- } else if (validationState === "done") {
332
- setColor(replacement ? "danger500" : "success500");
333
- setText(
334
- replacement ? `${formatMessage({
335
- id: getTranslation("components.pathInfo.notAvailable"),
336
- defaultMessage: "Path is not available. Replaced with"
337
- })} "${replacement}".` : formatMessage({
338
- id: getTranslation("components.pathInfo.available"),
339
- defaultMessage: "Path is available."
340
- })
341
- );
342
- }
343
- }, [validationState, replacement, formatMessage]);
344
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 1, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: color, children: text }) });
345
- }
346
- function OverrideCheckbox({ isOverride, setIsOverride, disabledCondition }) {
347
- const { formatMessage } = reactIntl.useIntl();
348
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 2, paddingTop: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
349
- designSystem.Checkbox,
350
- {
351
- id: "path-override-checkbox",
352
- checked: isOverride,
353
- onCheckedChange: () => setIsOverride(!isOverride),
354
- disabled: disabledCondition,
355
- children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral600", children: formatMessage({
356
- id: getTranslation("components.CMEditViewAside.path.overrideCheckbox"),
357
- defaultMessage: "Override automatic path generation"
358
- }) })
359
- }
360
- ) });
361
- }
362
- function NewPathInfo() {
363
- const { formatMessage } = reactIntl.useIntl();
364
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral600", children: formatMessage({
365
- id: getTranslation("components.CMEditViewAside.path.newPathInfo"),
366
- defaultMessage: "A new path will be created upon saving this entry."
367
- }) });
368
- }
369
- function UidPathDisplay({ path }) {
370
- const { formatMessage } = reactIntl.useIntl();
371
- return /* @__PURE__ */ jsxRuntime.jsxs(
372
- designSystem.Field.Root,
373
- {
374
- hint: formatMessage({
375
- id: getTranslation("components.CMEditViewAside.path.uidPath.hint"),
376
- defaultMessage: "Permanent UID path, cannot be changed"
377
- }),
378
- children: [
379
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Input, { value: path, disabled: true }),
380
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, {})
381
- ]
382
- }
383
- );
384
- }
385
- function _extends() {
386
- return _extends = Object.assign ? Object.assign.bind() : function(n) {
387
- for (var e = 1; e < arguments.length; e++) {
388
- var t = arguments[e];
389
- for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
390
- }
391
- return n;
392
- }, _extends.apply(null, arguments);
393
- }
394
- function $e42e1063c40fb3ef$export$b9ecd428b558ff10(originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) {
395
- return function handleEvent(event) {
396
- originalEventHandler === null || originalEventHandler === void 0 || originalEventHandler(event);
397
- if (checkForDefaultPrevented === false || !event.defaultPrevented) return ourEventHandler === null || ourEventHandler === void 0 ? void 0 : ourEventHandler(event);
398
- };
399
- }
400
- function $6ed0406888f73fc4$var$setRef(ref, value) {
401
- if (typeof ref === "function") ref(value);
402
- else if (ref !== null && ref !== void 0) ref.current = value;
403
- }
404
- function $6ed0406888f73fc4$export$43e446d32b3d21af(...refs) {
405
- return (node) => refs.forEach(
406
- (ref) => $6ed0406888f73fc4$var$setRef(ref, node)
407
- );
408
- }
409
- function $6ed0406888f73fc4$export$c7b2cbe3552a0d05(...refs) {
410
- return React.useCallback($6ed0406888f73fc4$export$43e446d32b3d21af(...refs), refs);
411
- }
412
- function $c512c27ab02ef895$export$50c7b4e9d9f19c1(scopeName, createContextScopeDeps = []) {
413
- let defaultContexts = [];
414
- function $c512c27ab02ef895$export$fd42f52fd3ae1109(rootComponentName, defaultContext) {
415
- const BaseContext = /* @__PURE__ */ React.createContext(defaultContext);
416
- const index2 = defaultContexts.length;
417
- defaultContexts = [
418
- ...defaultContexts,
419
- defaultContext
420
- ];
421
- function Provider(props) {
422
- const { scope, children, ...context } = props;
423
- const Context = (scope === null || scope === void 0 ? void 0 : scope[scopeName][index2]) || BaseContext;
424
- const value = React.useMemo(
425
- () => context,
426
- Object.values(context)
427
- );
428
- return /* @__PURE__ */ React.createElement(Context.Provider, {
429
- value
430
- }, children);
431
- }
432
- function useContext(consumerName, scope) {
433
- const Context = (scope === null || scope === void 0 ? void 0 : scope[scopeName][index2]) || BaseContext;
434
- const context = React.useContext(Context);
435
- if (context) return context;
436
- if (defaultContext !== void 0) return defaultContext;
437
- throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
438
- }
439
- Provider.displayName = rootComponentName + "Provider";
440
- return [
441
- Provider,
442
- useContext
443
- ];
444
- }
445
- const createScope = () => {
446
- const scopeContexts = defaultContexts.map((defaultContext) => {
447
- return /* @__PURE__ */ React.createContext(defaultContext);
448
- });
449
- return function useScope(scope) {
450
- const contexts = (scope === null || scope === void 0 ? void 0 : scope[scopeName]) || scopeContexts;
451
- return React.useMemo(
452
- () => ({
453
- [`__scope${scopeName}`]: {
454
- ...scope,
455
- [scopeName]: contexts
456
- }
457
- }),
458
- [
459
- scope,
460
- contexts
461
- ]
462
- );
463
- };
464
- };
465
- createScope.scopeName = scopeName;
466
- return [
467
- $c512c27ab02ef895$export$fd42f52fd3ae1109,
468
- $c512c27ab02ef895$var$composeContextScopes(createScope, ...createContextScopeDeps)
469
- ];
470
- }
471
- function $c512c27ab02ef895$var$composeContextScopes(...scopes) {
472
- const baseScope = scopes[0];
473
- if (scopes.length === 1) return baseScope;
474
- const createScope1 = () => {
475
- const scopeHooks = scopes.map(
476
- (createScope) => ({
477
- useScope: createScope(),
478
- scopeName: createScope.scopeName
479
- })
480
- );
481
- return function useComposedScopes(overrideScopes) {
482
- const nextScopes1 = scopeHooks.reduce((nextScopes, { useScope, scopeName }) => {
483
- const scopeProps = useScope(overrideScopes);
484
- const currentScope = scopeProps[`__scope${scopeName}`];
485
- return {
486
- ...nextScopes,
487
- ...currentScope
488
- };
489
- }, {});
490
- return React.useMemo(
491
- () => ({
492
- [`__scope${baseScope.scopeName}`]: nextScopes1
493
- }),
494
- [
495
- nextScopes1
496
- ]
497
- );
498
- };
499
- };
500
- createScope1.scopeName = baseScope.scopeName;
501
- return createScope1;
502
- }
503
- const $5e63c961fc1ce211$export$8c6ed5c666ac1360 = /* @__PURE__ */ React.forwardRef((props, forwardedRef) => {
504
- const { children, ...slotProps } = props;
505
- const childrenArray = React.Children.toArray(children);
506
- const slottable = childrenArray.find($5e63c961fc1ce211$var$isSlottable);
507
- if (slottable) {
508
- const newElement = slottable.props.children;
509
- const newChildren = childrenArray.map((child) => {
510
- if (child === slottable) {
511
- if (React.Children.count(newElement) > 1) return React.Children.only(null);
512
- return /* @__PURE__ */ React.isValidElement(newElement) ? newElement.props.children : null;
513
- } else return child;
514
- });
515
- return /* @__PURE__ */ React.createElement($5e63c961fc1ce211$var$SlotClone, _extends({}, slotProps, {
516
- ref: forwardedRef
517
- }), /* @__PURE__ */ React.isValidElement(newElement) ? /* @__PURE__ */ React.cloneElement(newElement, void 0, newChildren) : null);
518
- }
519
- return /* @__PURE__ */ React.createElement($5e63c961fc1ce211$var$SlotClone, _extends({}, slotProps, {
520
- ref: forwardedRef
521
- }), children);
522
- });
523
- $5e63c961fc1ce211$export$8c6ed5c666ac1360.displayName = "Slot";
524
- const $5e63c961fc1ce211$var$SlotClone = /* @__PURE__ */ React.forwardRef((props, forwardedRef) => {
525
- const { children, ...slotProps } = props;
526
- if (/* @__PURE__ */ React.isValidElement(children)) return /* @__PURE__ */ React.cloneElement(children, {
527
- ...$5e63c961fc1ce211$var$mergeProps(slotProps, children.props),
528
- ref: forwardedRef ? $6ed0406888f73fc4$export$43e446d32b3d21af(forwardedRef, children.ref) : children.ref
529
- });
530
- return React.Children.count(children) > 1 ? React.Children.only(null) : null;
531
- });
532
- $5e63c961fc1ce211$var$SlotClone.displayName = "SlotClone";
533
- const $5e63c961fc1ce211$export$d9f1ccf0bdb05d45 = ({ children }) => {
534
- return /* @__PURE__ */ React.createElement(React.Fragment, null, children);
535
- };
536
- function $5e63c961fc1ce211$var$isSlottable(child) {
537
- return /* @__PURE__ */ React.isValidElement(child) && child.type === $5e63c961fc1ce211$export$d9f1ccf0bdb05d45;
538
- }
539
- function $5e63c961fc1ce211$var$mergeProps(slotProps, childProps) {
540
- const overrideProps = {
541
- ...childProps
542
- };
543
- for (const propName in childProps) {
544
- const slotPropValue = slotProps[propName];
545
- const childPropValue = childProps[propName];
546
- const isHandler = /^on[A-Z]/.test(propName);
547
- if (isHandler) {
548
- if (slotPropValue && childPropValue) overrideProps[propName] = (...args) => {
549
- childPropValue(...args);
550
- slotPropValue(...args);
551
- };
552
- else if (slotPropValue) overrideProps[propName] = slotPropValue;
553
- } else if (propName === "style") overrideProps[propName] = {
554
- ...slotPropValue,
555
- ...childPropValue
556
- };
557
- else if (propName === "className") overrideProps[propName] = [
558
- slotPropValue,
559
- childPropValue
560
- ].filter(Boolean).join(" ");
561
- }
562
- return {
563
- ...slotProps,
564
- ...overrideProps
565
- };
566
- }
567
- const $8927f6f2acc4f386$var$NODES = [
568
- "a",
569
- "button",
570
- "div",
571
- "form",
572
- "h2",
573
- "h3",
574
- "img",
575
- "input",
576
- "label",
577
- "li",
578
- "nav",
579
- "ol",
580
- "p",
581
- "span",
582
- "svg",
583
- "ul"
584
- ];
585
- const $8927f6f2acc4f386$export$250ffa63cdc0d034 = $8927f6f2acc4f386$var$NODES.reduce((primitive, node) => {
586
- const Node2 = /* @__PURE__ */ React.forwardRef((props, forwardedRef) => {
587
- const { asChild, ...primitiveProps } = props;
588
- const Comp = asChild ? $5e63c961fc1ce211$export$8c6ed5c666ac1360 : node;
589
- React.useEffect(() => {
590
- window[Symbol.for("radix-ui")] = true;
591
- }, []);
592
- return /* @__PURE__ */ React.createElement(Comp, _extends({}, primitiveProps, {
593
- ref: forwardedRef
594
- }));
595
- });
596
- Node2.displayName = `Primitive.${node}`;
597
- return {
598
- ...primitive,
599
- [node]: Node2
600
- };
601
- }, {});
602
- function $8927f6f2acc4f386$export$6d1a0317bde7de7f(target, event) {
603
- if (target) ReactDOM.flushSync(
604
- () => target.dispatchEvent(event)
605
- );
606
- }
607
- function $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(callback) {
608
- const callbackRef = React.useRef(callback);
609
- React.useEffect(() => {
610
- callbackRef.current = callback;
611
- });
612
- return React.useMemo(
613
- () => (...args) => {
614
- var _callbackRef$current;
615
- return (_callbackRef$current = callbackRef.current) === null || _callbackRef$current === void 0 ? void 0 : _callbackRef$current.call(callbackRef, ...args);
616
- },
617
- []
618
- );
619
- }
620
- function $addc16e1bbe58fd0$export$3a72a57244d6e765(onEscapeKeyDownProp, ownerDocument = globalThis === null || globalThis === void 0 ? void 0 : globalThis.document) {
621
- const onEscapeKeyDown = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onEscapeKeyDownProp);
622
- React.useEffect(() => {
623
- const handleKeyDown = (event) => {
624
- if (event.key === "Escape") onEscapeKeyDown(event);
625
- };
626
- ownerDocument.addEventListener("keydown", handleKeyDown);
627
- return () => ownerDocument.removeEventListener("keydown", handleKeyDown);
628
- }, [
629
- onEscapeKeyDown,
630
- ownerDocument
631
- ]);
632
- }
633
- const $5cb92bef7577960e$var$CONTEXT_UPDATE = "dismissableLayer.update";
634
- const $5cb92bef7577960e$var$POINTER_DOWN_OUTSIDE = "dismissableLayer.pointerDownOutside";
635
- const $5cb92bef7577960e$var$FOCUS_OUTSIDE = "dismissableLayer.focusOutside";
636
- let $5cb92bef7577960e$var$originalBodyPointerEvents;
637
- const $5cb92bef7577960e$var$DismissableLayerContext = /* @__PURE__ */ React.createContext({
638
- layers: /* @__PURE__ */ new Set(),
639
- layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
640
- branches: /* @__PURE__ */ new Set()
641
- });
642
- const $5cb92bef7577960e$export$177fb62ff3ec1f22 = /* @__PURE__ */ React.forwardRef((props, forwardedRef) => {
643
- var _node$ownerDocument;
644
- const { disableOutsidePointerEvents = false, onEscapeKeyDown, onPointerDownOutside, onFocusOutside, onInteractOutside, onDismiss, ...layerProps } = props;
645
- const context = React.useContext($5cb92bef7577960e$var$DismissableLayerContext);
646
- const [node1, setNode] = React.useState(null);
647
- const ownerDocument = (_node$ownerDocument = node1 === null || node1 === void 0 ? void 0 : node1.ownerDocument) !== null && _node$ownerDocument !== void 0 ? _node$ownerDocument : globalThis === null || globalThis === void 0 ? void 0 : globalThis.document;
648
- const [, force] = React.useState({});
649
- const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(
650
- forwardedRef,
651
- (node) => setNode(node)
652
- );
653
- const layers = Array.from(context.layers);
654
- const [highestLayerWithOutsidePointerEventsDisabled] = [
655
- ...context.layersWithOutsidePointerEventsDisabled
656
- ].slice(-1);
657
- const highestLayerWithOutsidePointerEventsDisabledIndex = layers.indexOf(highestLayerWithOutsidePointerEventsDisabled);
658
- const index2 = node1 ? layers.indexOf(node1) : -1;
659
- const isBodyPointerEventsDisabled = context.layersWithOutsidePointerEventsDisabled.size > 0;
660
- const isPointerEventsEnabled = index2 >= highestLayerWithOutsidePointerEventsDisabledIndex;
661
- const pointerDownOutside = $5cb92bef7577960e$var$usePointerDownOutside((event) => {
662
- const target = event.target;
663
- const isPointerDownOnBranch = [
664
- ...context.branches
665
- ].some(
666
- (branch) => branch.contains(target)
667
- );
668
- if (!isPointerEventsEnabled || isPointerDownOnBranch) return;
669
- onPointerDownOutside === null || onPointerDownOutside === void 0 || onPointerDownOutside(event);
670
- onInteractOutside === null || onInteractOutside === void 0 || onInteractOutside(event);
671
- if (!event.defaultPrevented) onDismiss === null || onDismiss === void 0 || onDismiss();
672
- }, ownerDocument);
673
- const focusOutside = $5cb92bef7577960e$var$useFocusOutside((event) => {
674
- const target = event.target;
675
- const isFocusInBranch = [
676
- ...context.branches
677
- ].some(
678
- (branch) => branch.contains(target)
679
- );
680
- if (isFocusInBranch) return;
681
- onFocusOutside === null || onFocusOutside === void 0 || onFocusOutside(event);
682
- onInteractOutside === null || onInteractOutside === void 0 || onInteractOutside(event);
683
- if (!event.defaultPrevented) onDismiss === null || onDismiss === void 0 || onDismiss();
684
- }, ownerDocument);
685
- $addc16e1bbe58fd0$export$3a72a57244d6e765((event) => {
686
- const isHighestLayer = index2 === context.layers.size - 1;
687
- if (!isHighestLayer) return;
688
- onEscapeKeyDown === null || onEscapeKeyDown === void 0 || onEscapeKeyDown(event);
689
- if (!event.defaultPrevented && onDismiss) {
690
- event.preventDefault();
691
- onDismiss();
692
- }
693
- }, ownerDocument);
694
- React.useEffect(() => {
695
- if (!node1) return;
696
- if (disableOutsidePointerEvents) {
697
- if (context.layersWithOutsidePointerEventsDisabled.size === 0) {
698
- $5cb92bef7577960e$var$originalBodyPointerEvents = ownerDocument.body.style.pointerEvents;
699
- ownerDocument.body.style.pointerEvents = "none";
700
- }
701
- context.layersWithOutsidePointerEventsDisabled.add(node1);
702
- }
703
- context.layers.add(node1);
704
- $5cb92bef7577960e$var$dispatchUpdate();
705
- return () => {
706
- if (disableOutsidePointerEvents && context.layersWithOutsidePointerEventsDisabled.size === 1) ownerDocument.body.style.pointerEvents = $5cb92bef7577960e$var$originalBodyPointerEvents;
707
- };
708
- }, [
709
- node1,
710
- ownerDocument,
711
- disableOutsidePointerEvents,
712
- context
713
- ]);
714
- React.useEffect(() => {
715
- return () => {
716
- if (!node1) return;
717
- context.layers.delete(node1);
718
- context.layersWithOutsidePointerEventsDisabled.delete(node1);
719
- $5cb92bef7577960e$var$dispatchUpdate();
720
- };
721
- }, [
722
- node1,
723
- context
724
- ]);
725
- React.useEffect(() => {
726
- const handleUpdate = () => force({});
727
- document.addEventListener($5cb92bef7577960e$var$CONTEXT_UPDATE, handleUpdate);
728
- return () => document.removeEventListener($5cb92bef7577960e$var$CONTEXT_UPDATE, handleUpdate);
729
- }, []);
730
- return /* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({}, layerProps, {
731
- ref: composedRefs,
732
- style: {
733
- pointerEvents: isBodyPointerEventsDisabled ? isPointerEventsEnabled ? "auto" : "none" : void 0,
734
- ...props.style
735
- },
736
- onFocusCapture: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onFocusCapture, focusOutside.onFocusCapture),
737
- onBlurCapture: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onBlurCapture, focusOutside.onBlurCapture),
738
- onPointerDownCapture: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onPointerDownCapture, pointerDownOutside.onPointerDownCapture)
739
- }));
740
- });
741
- function $5cb92bef7577960e$var$usePointerDownOutside(onPointerDownOutside, ownerDocument = globalThis === null || globalThis === void 0 ? void 0 : globalThis.document) {
742
- const handlePointerDownOutside = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onPointerDownOutside);
743
- const isPointerInsideReactTreeRef = React.useRef(false);
744
- const handleClickRef = React.useRef(() => {
745
- });
746
- React.useEffect(() => {
747
- const handlePointerDown = (event) => {
748
- if (event.target && !isPointerInsideReactTreeRef.current) {
749
- let handleAndDispatchPointerDownOutsideEvent = function() {
750
- $5cb92bef7577960e$var$handleAndDispatchCustomEvent($5cb92bef7577960e$var$POINTER_DOWN_OUTSIDE, handlePointerDownOutside, eventDetail, {
751
- discrete: true
752
- });
753
- };
754
- const eventDetail = {
755
- originalEvent: event
756
- };
757
- if (event.pointerType === "touch") {
758
- ownerDocument.removeEventListener("click", handleClickRef.current);
759
- handleClickRef.current = handleAndDispatchPointerDownOutsideEvent;
760
- ownerDocument.addEventListener("click", handleClickRef.current, {
761
- once: true
762
- });
763
- } else handleAndDispatchPointerDownOutsideEvent();
764
- } else
765
- ownerDocument.removeEventListener("click", handleClickRef.current);
766
- isPointerInsideReactTreeRef.current = false;
767
- };
768
- const timerId = window.setTimeout(() => {
769
- ownerDocument.addEventListener("pointerdown", handlePointerDown);
770
- }, 0);
771
- return () => {
772
- window.clearTimeout(timerId);
773
- ownerDocument.removeEventListener("pointerdown", handlePointerDown);
774
- ownerDocument.removeEventListener("click", handleClickRef.current);
775
- };
776
- }, [
777
- ownerDocument,
778
- handlePointerDownOutside
779
- ]);
780
- return {
781
- // ensures we check React component tree (not just DOM tree)
782
- onPointerDownCapture: () => isPointerInsideReactTreeRef.current = true
783
- };
784
- }
785
- function $5cb92bef7577960e$var$useFocusOutside(onFocusOutside, ownerDocument = globalThis === null || globalThis === void 0 ? void 0 : globalThis.document) {
786
- const handleFocusOutside = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onFocusOutside);
787
- const isFocusInsideReactTreeRef = React.useRef(false);
788
- React.useEffect(() => {
789
- const handleFocus = (event) => {
790
- if (event.target && !isFocusInsideReactTreeRef.current) {
791
- const eventDetail = {
792
- originalEvent: event
793
- };
794
- $5cb92bef7577960e$var$handleAndDispatchCustomEvent($5cb92bef7577960e$var$FOCUS_OUTSIDE, handleFocusOutside, eventDetail, {
795
- discrete: false
796
- });
797
- }
798
- };
799
- ownerDocument.addEventListener("focusin", handleFocus);
800
- return () => ownerDocument.removeEventListener("focusin", handleFocus);
801
- }, [
802
- ownerDocument,
803
- handleFocusOutside
804
- ]);
805
- return {
806
- onFocusCapture: () => isFocusInsideReactTreeRef.current = true,
807
- onBlurCapture: () => isFocusInsideReactTreeRef.current = false
808
- };
809
- }
810
- function $5cb92bef7577960e$var$dispatchUpdate() {
811
- const event = new CustomEvent($5cb92bef7577960e$var$CONTEXT_UPDATE);
812
- document.dispatchEvent(event);
813
- }
814
- function $5cb92bef7577960e$var$handleAndDispatchCustomEvent(name, handler, detail, { discrete }) {
815
- const target = detail.originalEvent.target;
816
- const event = new CustomEvent(name, {
817
- bubbles: false,
818
- cancelable: true,
819
- detail
820
- });
821
- if (handler) target.addEventListener(name, handler, {
822
- once: true
823
- });
824
- if (discrete) $8927f6f2acc4f386$export$6d1a0317bde7de7f(target, event);
825
- else target.dispatchEvent(event);
826
- }
827
- const $9f79659886946c16$export$e5c5a5f917a5871c = Boolean(globalThis === null || globalThis === void 0 ? void 0 : globalThis.document) ? React.useLayoutEffect : () => {
828
- };
829
- const $1746a345f3d73bb7$var$useReactId = React__namespace["useId".toString()] || (() => void 0);
830
- let $1746a345f3d73bb7$var$count = 0;
831
- function $1746a345f3d73bb7$export$f680877a34711e37(deterministicId) {
832
- const [id, setId] = React__namespace.useState($1746a345f3d73bb7$var$useReactId());
833
- $9f79659886946c16$export$e5c5a5f917a5871c(() => {
834
- setId(
835
- (reactId) => reactId !== null && reactId !== void 0 ? reactId : String($1746a345f3d73bb7$var$count++)
836
- );
837
- }, [
838
- deterministicId
839
- ]);
840
- return id ? `radix-${id}` : "";
841
- }
842
- const sides = ["top", "right", "bottom", "left"];
843
- const min = Math.min;
844
- const max = Math.max;
845
- const round = Math.round;
846
- const floor = Math.floor;
847
- const createCoords = (v) => ({
848
- x: v,
849
- y: v
850
- });
851
- const oppositeSideMap = {
852
- left: "right",
853
- right: "left",
854
- bottom: "top",
855
- top: "bottom"
856
- };
857
- const oppositeAlignmentMap = {
858
- start: "end",
859
- end: "start"
860
- };
861
- function clamp(start, value, end) {
862
- return max(start, min(value, end));
863
- }
864
- function evaluate(value, param) {
865
- return typeof value === "function" ? value(param) : value;
866
- }
867
- function getSide(placement) {
868
- return placement.split("-")[0];
869
- }
870
- function getAlignment(placement) {
871
- return placement.split("-")[1];
872
- }
873
- function getOppositeAxis(axis) {
874
- return axis === "x" ? "y" : "x";
875
- }
876
- function getAxisLength(axis) {
877
- return axis === "y" ? "height" : "width";
878
- }
879
- function getSideAxis(placement) {
880
- return ["top", "bottom"].includes(getSide(placement)) ? "y" : "x";
881
- }
882
- function getAlignmentAxis(placement) {
883
- return getOppositeAxis(getSideAxis(placement));
884
- }
885
- function getAlignmentSides(placement, rects, rtl) {
886
- if (rtl === void 0) {
887
- rtl = false;
888
- }
889
- const alignment = getAlignment(placement);
890
- const alignmentAxis = getAlignmentAxis(placement);
891
- const length = getAxisLength(alignmentAxis);
892
- let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
893
- if (rects.reference[length] > rects.floating[length]) {
894
- mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
895
- }
896
- return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
897
- }
898
- function getExpandedPlacements(placement) {
899
- const oppositePlacement = getOppositePlacement(placement);
900
- return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
901
- }
902
- function getOppositeAlignmentPlacement(placement) {
903
- return placement.replace(/start|end/g, (alignment) => oppositeAlignmentMap[alignment]);
904
- }
905
- function getSideList(side, isStart, rtl) {
906
- const lr = ["left", "right"];
907
- const rl = ["right", "left"];
908
- const tb = ["top", "bottom"];
909
- const bt = ["bottom", "top"];
910
- switch (side) {
911
- case "top":
912
- case "bottom":
913
- if (rtl) return isStart ? rl : lr;
914
- return isStart ? lr : rl;
915
- case "left":
916
- case "right":
917
- return isStart ? tb : bt;
918
- default:
919
- return [];
920
- }
921
- }
922
- function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
923
- const alignment = getAlignment(placement);
924
- let list = getSideList(getSide(placement), direction === "start", rtl);
925
- if (alignment) {
926
- list = list.map((side) => side + "-" + alignment);
927
- if (flipAlignment) {
928
- list = list.concat(list.map(getOppositeAlignmentPlacement));
929
- }
930
- }
931
- return list;
932
- }
933
- function getOppositePlacement(placement) {
934
- return placement.replace(/left|right|bottom|top/g, (side) => oppositeSideMap[side]);
935
- }
936
- function expandPaddingObject(padding) {
937
- return {
938
- top: 0,
939
- right: 0,
940
- bottom: 0,
941
- left: 0,
942
- ...padding
943
- };
944
- }
945
- function getPaddingObject(padding) {
946
- return typeof padding !== "number" ? expandPaddingObject(padding) : {
947
- top: padding,
948
- right: padding,
949
- bottom: padding,
950
- left: padding
951
- };
952
- }
953
- function rectToClientRect(rect) {
954
- const {
955
- x,
956
- y,
957
- width,
958
- height
959
- } = rect;
960
- return {
961
- width,
962
- height,
963
- top: y,
964
- left: x,
965
- right: x + width,
966
- bottom: y + height,
967
- x,
968
- y
969
- };
970
- }
971
- function computeCoordsFromPlacement(_ref, placement, rtl) {
972
- let {
973
- reference,
974
- floating
975
- } = _ref;
976
- const sideAxis = getSideAxis(placement);
977
- const alignmentAxis = getAlignmentAxis(placement);
978
- const alignLength = getAxisLength(alignmentAxis);
979
- const side = getSide(placement);
980
- const isVertical = sideAxis === "y";
981
- const commonX = reference.x + reference.width / 2 - floating.width / 2;
982
- const commonY = reference.y + reference.height / 2 - floating.height / 2;
983
- const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
984
- let coords;
985
- switch (side) {
986
- case "top":
987
- coords = {
988
- x: commonX,
989
- y: reference.y - floating.height
990
- };
991
- break;
992
- case "bottom":
993
- coords = {
994
- x: commonX,
995
- y: reference.y + reference.height
996
- };
997
- break;
998
- case "right":
999
- coords = {
1000
- x: reference.x + reference.width,
1001
- y: commonY
1002
- };
1003
- break;
1004
- case "left":
1005
- coords = {
1006
- x: reference.x - floating.width,
1007
- y: commonY
1008
- };
1009
- break;
1010
- default:
1011
- coords = {
1012
- x: reference.x,
1013
- y: reference.y
1014
- };
1015
- }
1016
- switch (getAlignment(placement)) {
1017
- case "start":
1018
- coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
1019
- break;
1020
- case "end":
1021
- coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
1022
- break;
1023
- }
1024
- return coords;
1025
- }
1026
- const computePosition$1 = async (reference, floating, config) => {
1027
- const {
1028
- placement = "bottom",
1029
- strategy = "absolute",
1030
- middleware = [],
1031
- platform: platform2
1032
- } = config;
1033
- const validMiddleware = middleware.filter(Boolean);
1034
- const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(floating));
1035
- let rects = await platform2.getElementRects({
1036
- reference,
1037
- floating,
1038
- strategy
1039
- });
1040
- let {
1041
- x,
1042
- y
1043
- } = computeCoordsFromPlacement(rects, placement, rtl);
1044
- let statefulPlacement = placement;
1045
- let middlewareData = {};
1046
- let resetCount = 0;
1047
- for (let i = 0; i < validMiddleware.length; i++) {
1048
- const {
1049
- name,
1050
- fn
1051
- } = validMiddleware[i];
1052
- const {
1053
- x: nextX,
1054
- y: nextY,
1055
- data,
1056
- reset
1057
- } = await fn({
1058
- x,
1059
- y,
1060
- initialPlacement: placement,
1061
- placement: statefulPlacement,
1062
- strategy,
1063
- middlewareData,
1064
- rects,
1065
- platform: platform2,
1066
- elements: {
1067
- reference,
1068
- floating
1069
- }
1070
- });
1071
- x = nextX != null ? nextX : x;
1072
- y = nextY != null ? nextY : y;
1073
- middlewareData = {
1074
- ...middlewareData,
1075
- [name]: {
1076
- ...middlewareData[name],
1077
- ...data
1078
- }
1079
- };
1080
- if (reset && resetCount <= 50) {
1081
- resetCount++;
1082
- if (typeof reset === "object") {
1083
- if (reset.placement) {
1084
- statefulPlacement = reset.placement;
1085
- }
1086
- if (reset.rects) {
1087
- rects = reset.rects === true ? await platform2.getElementRects({
1088
- reference,
1089
- floating,
1090
- strategy
1091
- }) : reset.rects;
1092
- }
1093
- ({
1094
- x,
1095
- y
1096
- } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
1097
- }
1098
- i = -1;
1099
- }
1100
- }
1101
- return {
1102
- x,
1103
- y,
1104
- placement: statefulPlacement,
1105
- strategy,
1106
- middlewareData
1107
- };
1108
- };
1109
- async function detectOverflow(state, options) {
1110
- var _await$platform$isEle;
1111
- if (options === void 0) {
1112
- options = {};
1113
- }
1114
- const {
1115
- x,
1116
- y,
1117
- platform: platform2,
1118
- rects,
1119
- elements,
1120
- strategy
1121
- } = state;
1122
- const {
1123
- boundary = "clippingAncestors",
1124
- rootBoundary = "viewport",
1125
- elementContext = "floating",
1126
- altBoundary = false,
1127
- padding = 0
1128
- } = evaluate(options, state);
1129
- const paddingObject = getPaddingObject(padding);
1130
- const altContext = elementContext === "floating" ? "reference" : "floating";
1131
- const element = elements[altBoundary ? altContext : elementContext];
1132
- const clippingClientRect = rectToClientRect(await platform2.getClippingRect({
1133
- element: ((_await$platform$isEle = await (platform2.isElement == null ? void 0 : platform2.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || await (platform2.getDocumentElement == null ? void 0 : platform2.getDocumentElement(elements.floating)),
1134
- boundary,
1135
- rootBoundary,
1136
- strategy
1137
- }));
1138
- const rect = elementContext === "floating" ? {
1139
- x,
1140
- y,
1141
- width: rects.floating.width,
1142
- height: rects.floating.height
1143
- } : rects.reference;
1144
- const offsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(elements.floating));
1145
- const offsetScale = await (platform2.isElement == null ? void 0 : platform2.isElement(offsetParent)) ? await (platform2.getScale == null ? void 0 : platform2.getScale(offsetParent)) || {
1146
- x: 1,
1147
- y: 1
1148
- } : {
1149
- x: 1,
1150
- y: 1
1151
- };
1152
- const elementClientRect = rectToClientRect(platform2.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform2.convertOffsetParentRelativeRectToViewportRelativeRect({
1153
- elements,
1154
- rect,
1155
- offsetParent,
1156
- strategy
1157
- }) : rect);
1158
- return {
1159
- top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
1160
- bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
1161
- left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
1162
- right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
1163
- };
1164
- }
1165
- const arrow$3 = (options) => ({
1166
- name: "arrow",
1167
- options,
1168
- async fn(state) {
1169
- const {
1170
- x,
1171
- y,
1172
- placement,
1173
- rects,
1174
- platform: platform2,
1175
- elements,
1176
- middlewareData
1177
- } = state;
1178
- const {
1179
- element,
1180
- padding = 0
1181
- } = evaluate(options, state) || {};
1182
- if (element == null) {
1183
- return {};
1184
- }
1185
- const paddingObject = getPaddingObject(padding);
1186
- const coords = {
1187
- x,
1188
- y
1189
- };
1190
- const axis = getAlignmentAxis(placement);
1191
- const length = getAxisLength(axis);
1192
- const arrowDimensions = await platform2.getDimensions(element);
1193
- const isYAxis = axis === "y";
1194
- const minProp = isYAxis ? "top" : "left";
1195
- const maxProp = isYAxis ? "bottom" : "right";
1196
- const clientProp = isYAxis ? "clientHeight" : "clientWidth";
1197
- const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
1198
- const startDiff = coords[axis] - rects.reference[axis];
1199
- const arrowOffsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(element));
1200
- let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
1201
- if (!clientSize || !await (platform2.isElement == null ? void 0 : platform2.isElement(arrowOffsetParent))) {
1202
- clientSize = elements.floating[clientProp] || rects.floating[length];
1203
- }
1204
- const centerToReference = endDiff / 2 - startDiff / 2;
1205
- const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
1206
- const minPadding = min(paddingObject[minProp], largestPossiblePadding);
1207
- const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
1208
- const min$1 = minPadding;
1209
- const max2 = clientSize - arrowDimensions[length] - maxPadding;
1210
- const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
1211
- const offset2 = clamp(min$1, center, max2);
1212
- const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset2 && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
1213
- const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max2 : 0;
1214
- return {
1215
- [axis]: coords[axis] + alignmentOffset,
1216
- data: {
1217
- [axis]: offset2,
1218
- centerOffset: center - offset2 - alignmentOffset,
1219
- ...shouldAddOffset && {
1220
- alignmentOffset
1221
- }
1222
- },
1223
- reset: shouldAddOffset
1224
- };
1225
- }
1226
- });
1227
- const flip$2 = function(options) {
1228
- if (options === void 0) {
1229
- options = {};
1230
- }
1231
- return {
1232
- name: "flip",
1233
- options,
1234
- async fn(state) {
1235
- var _middlewareData$arrow, _middlewareData$flip;
1236
- const {
1237
- placement,
1238
- middlewareData,
1239
- rects,
1240
- initialPlacement,
1241
- platform: platform2,
1242
- elements
1243
- } = state;
1244
- const {
1245
- mainAxis: checkMainAxis = true,
1246
- crossAxis: checkCrossAxis = true,
1247
- fallbackPlacements: specifiedFallbackPlacements,
1248
- fallbackStrategy = "bestFit",
1249
- fallbackAxisSideDirection = "none",
1250
- flipAlignment = true,
1251
- ...detectOverflowOptions
1252
- } = evaluate(options, state);
1253
- if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
1254
- return {};
1255
- }
1256
- const side = getSide(placement);
1257
- const initialSideAxis = getSideAxis(initialPlacement);
1258
- const isBasePlacement = getSide(initialPlacement) === initialPlacement;
1259
- const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
1260
- const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
1261
- const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
1262
- if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
1263
- fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
1264
- }
1265
- const placements = [initialPlacement, ...fallbackPlacements];
1266
- const overflow = await detectOverflow(state, detectOverflowOptions);
1267
- const overflows = [];
1268
- let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
1269
- if (checkMainAxis) {
1270
- overflows.push(overflow[side]);
1271
- }
1272
- if (checkCrossAxis) {
1273
- const sides2 = getAlignmentSides(placement, rects, rtl);
1274
- overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
1275
- }
1276
- overflowsData = [...overflowsData, {
1277
- placement,
1278
- overflows
1279
- }];
1280
- if (!overflows.every((side2) => side2 <= 0)) {
1281
- var _middlewareData$flip2, _overflowsData$filter;
1282
- const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
1283
- const nextPlacement = placements[nextIndex];
1284
- if (nextPlacement) {
1285
- return {
1286
- data: {
1287
- index: nextIndex,
1288
- overflows: overflowsData
1289
- },
1290
- reset: {
1291
- placement: nextPlacement
1292
- }
1293
- };
1294
- }
1295
- 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;
1296
- if (!resetPlacement) {
1297
- switch (fallbackStrategy) {
1298
- case "bestFit": {
1299
- var _overflowsData$filter2;
1300
- const placement2 = (_overflowsData$filter2 = overflowsData.filter((d) => {
1301
- if (hasFallbackAxisSideDirection) {
1302
- const currentSideAxis = getSideAxis(d.placement);
1303
- return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
1304
- // reading directions favoring greater width.
1305
- currentSideAxis === "y";
1306
- }
1307
- return true;
1308
- }).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];
1309
- if (placement2) {
1310
- resetPlacement = placement2;
1311
- }
1312
- break;
1313
- }
1314
- case "initialPlacement":
1315
- resetPlacement = initialPlacement;
1316
- break;
1317
- }
1318
- }
1319
- if (placement !== resetPlacement) {
1320
- return {
1321
- reset: {
1322
- placement: resetPlacement
1323
- }
1324
- };
1325
- }
1326
- }
1327
- return {};
1328
- }
1329
- };
1330
- };
1331
- function getSideOffsets(overflow, rect) {
1332
- return {
1333
- top: overflow.top - rect.height,
1334
- right: overflow.right - rect.width,
1335
- bottom: overflow.bottom - rect.height,
1336
- left: overflow.left - rect.width
1337
- };
1338
- }
1339
- function isAnySideFullyClipped(overflow) {
1340
- return sides.some((side) => overflow[side] >= 0);
1341
- }
1342
- const hide$2 = function(options) {
1343
- if (options === void 0) {
1344
- options = {};
1345
- }
1346
- return {
1347
- name: "hide",
1348
- options,
1349
- async fn(state) {
1350
- const {
1351
- rects
1352
- } = state;
1353
- const {
1354
- strategy = "referenceHidden",
1355
- ...detectOverflowOptions
1356
- } = evaluate(options, state);
1357
- switch (strategy) {
1358
- case "referenceHidden": {
1359
- const overflow = await detectOverflow(state, {
1360
- ...detectOverflowOptions,
1361
- elementContext: "reference"
1362
- });
1363
- const offsets = getSideOffsets(overflow, rects.reference);
1364
- return {
1365
- data: {
1366
- referenceHiddenOffsets: offsets,
1367
- referenceHidden: isAnySideFullyClipped(offsets)
1368
- }
1369
- };
1370
- }
1371
- case "escaped": {
1372
- const overflow = await detectOverflow(state, {
1373
- ...detectOverflowOptions,
1374
- altBoundary: true
1375
- });
1376
- const offsets = getSideOffsets(overflow, rects.floating);
1377
- return {
1378
- data: {
1379
- escapedOffsets: offsets,
1380
- escaped: isAnySideFullyClipped(offsets)
1381
- }
1382
- };
1383
- }
1384
- default: {
1385
- return {};
1386
- }
1387
- }
1388
- }
1389
- };
1390
- };
1391
- async function convertValueToCoords(state, options) {
1392
- const {
1393
- placement,
1394
- platform: platform2,
1395
- elements
1396
- } = state;
1397
- const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
1398
- const side = getSide(placement);
1399
- const alignment = getAlignment(placement);
1400
- const isVertical = getSideAxis(placement) === "y";
1401
- const mainAxisMulti = ["left", "top"].includes(side) ? -1 : 1;
1402
- const crossAxisMulti = rtl && isVertical ? -1 : 1;
1403
- const rawValue = evaluate(options, state);
1404
- let {
1405
- mainAxis,
1406
- crossAxis,
1407
- alignmentAxis
1408
- } = typeof rawValue === "number" ? {
1409
- mainAxis: rawValue,
1410
- crossAxis: 0,
1411
- alignmentAxis: null
1412
- } : {
1413
- mainAxis: rawValue.mainAxis || 0,
1414
- crossAxis: rawValue.crossAxis || 0,
1415
- alignmentAxis: rawValue.alignmentAxis
1416
- };
1417
- if (alignment && typeof alignmentAxis === "number") {
1418
- crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
1419
- }
1420
- return isVertical ? {
1421
- x: crossAxis * crossAxisMulti,
1422
- y: mainAxis * mainAxisMulti
1423
- } : {
1424
- x: mainAxis * mainAxisMulti,
1425
- y: crossAxis * crossAxisMulti
1426
- };
1427
- }
1428
- const offset$2 = function(options) {
1429
- if (options === void 0) {
1430
- options = 0;
1431
- }
1432
- return {
1433
- name: "offset",
1434
- options,
1435
- async fn(state) {
1436
- var _middlewareData$offse, _middlewareData$arrow;
1437
- const {
1438
- x,
1439
- y,
1440
- placement,
1441
- middlewareData
1442
- } = state;
1443
- const diffCoords = await convertValueToCoords(state, options);
1444
- if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
1445
- return {};
1446
- }
1447
- return {
1448
- x: x + diffCoords.x,
1449
- y: y + diffCoords.y,
1450
- data: {
1451
- ...diffCoords,
1452
- placement
1453
- }
1454
- };
1455
- }
1456
- };
1457
- };
1458
- const shift$2 = function(options) {
1459
- if (options === void 0) {
1460
- options = {};
1461
- }
1462
- return {
1463
- name: "shift",
1464
- options,
1465
- async fn(state) {
1466
- const {
1467
- x,
1468
- y,
1469
- placement
1470
- } = state;
1471
- const {
1472
- mainAxis: checkMainAxis = true,
1473
- crossAxis: checkCrossAxis = false,
1474
- limiter = {
1475
- fn: (_ref) => {
1476
- let {
1477
- x: x2,
1478
- y: y2
1479
- } = _ref;
1480
- return {
1481
- x: x2,
1482
- y: y2
1483
- };
1484
- }
1485
- },
1486
- ...detectOverflowOptions
1487
- } = evaluate(options, state);
1488
- const coords = {
1489
- x,
1490
- y
1491
- };
1492
- const overflow = await detectOverflow(state, detectOverflowOptions);
1493
- const crossAxis = getSideAxis(getSide(placement));
1494
- const mainAxis = getOppositeAxis(crossAxis);
1495
- let mainAxisCoord = coords[mainAxis];
1496
- let crossAxisCoord = coords[crossAxis];
1497
- if (checkMainAxis) {
1498
- const minSide = mainAxis === "y" ? "top" : "left";
1499
- const maxSide = mainAxis === "y" ? "bottom" : "right";
1500
- const min2 = mainAxisCoord + overflow[minSide];
1501
- const max2 = mainAxisCoord - overflow[maxSide];
1502
- mainAxisCoord = clamp(min2, mainAxisCoord, max2);
1503
- }
1504
- if (checkCrossAxis) {
1505
- const minSide = crossAxis === "y" ? "top" : "left";
1506
- const maxSide = crossAxis === "y" ? "bottom" : "right";
1507
- const min2 = crossAxisCoord + overflow[minSide];
1508
- const max2 = crossAxisCoord - overflow[maxSide];
1509
- crossAxisCoord = clamp(min2, crossAxisCoord, max2);
1510
- }
1511
- const limitedCoords = limiter.fn({
1512
- ...state,
1513
- [mainAxis]: mainAxisCoord,
1514
- [crossAxis]: crossAxisCoord
1515
- });
1516
- return {
1517
- ...limitedCoords,
1518
- data: {
1519
- x: limitedCoords.x - x,
1520
- y: limitedCoords.y - y,
1521
- enabled: {
1522
- [mainAxis]: checkMainAxis,
1523
- [crossAxis]: checkCrossAxis
1524
- }
1525
- }
1526
- };
1527
- }
1528
- };
1529
- };
1530
- const limitShift$2 = function(options) {
1531
- if (options === void 0) {
1532
- options = {};
1533
- }
1534
- return {
1535
- options,
1536
- fn(state) {
1537
- const {
1538
- x,
1539
- y,
1540
- placement,
1541
- rects,
1542
- middlewareData
1543
- } = state;
1544
- const {
1545
- offset: offset2 = 0,
1546
- mainAxis: checkMainAxis = true,
1547
- crossAxis: checkCrossAxis = true
1548
- } = evaluate(options, state);
1549
- const coords = {
1550
- x,
1551
- y
1552
- };
1553
- const crossAxis = getSideAxis(placement);
1554
- const mainAxis = getOppositeAxis(crossAxis);
1555
- let mainAxisCoord = coords[mainAxis];
1556
- let crossAxisCoord = coords[crossAxis];
1557
- const rawOffset = evaluate(offset2, state);
1558
- const computedOffset = typeof rawOffset === "number" ? {
1559
- mainAxis: rawOffset,
1560
- crossAxis: 0
1561
- } : {
1562
- mainAxis: 0,
1563
- crossAxis: 0,
1564
- ...rawOffset
1565
- };
1566
- if (checkMainAxis) {
1567
- const len = mainAxis === "y" ? "height" : "width";
1568
- const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
1569
- const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
1570
- if (mainAxisCoord < limitMin) {
1571
- mainAxisCoord = limitMin;
1572
- } else if (mainAxisCoord > limitMax) {
1573
- mainAxisCoord = limitMax;
1574
- }
1575
- }
1576
- if (checkCrossAxis) {
1577
- var _middlewareData$offse, _middlewareData$offse2;
1578
- const len = mainAxis === "y" ? "width" : "height";
1579
- const isOriginSide = ["top", "left"].includes(getSide(placement));
1580
- const limitMin = rects.reference[crossAxis] - rects.floating[len] + (isOriginSide ? ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse[crossAxis]) || 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis);
1581
- const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : ((_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[crossAxis]) || 0) - (isOriginSide ? computedOffset.crossAxis : 0);
1582
- if (crossAxisCoord < limitMin) {
1583
- crossAxisCoord = limitMin;
1584
- } else if (crossAxisCoord > limitMax) {
1585
- crossAxisCoord = limitMax;
1586
- }
1587
- }
1588
- return {
1589
- [mainAxis]: mainAxisCoord,
1590
- [crossAxis]: crossAxisCoord
1591
- };
1592
- }
1593
- };
1594
- };
1595
- const size$2 = function(options) {
1596
- if (options === void 0) {
1597
- options = {};
1598
- }
1599
- return {
1600
- name: "size",
1601
- options,
1602
- async fn(state) {
1603
- var _state$middlewareData, _state$middlewareData2;
1604
- const {
1605
- placement,
1606
- rects,
1607
- platform: platform2,
1608
- elements
1609
- } = state;
1610
- const {
1611
- apply = () => {
1612
- },
1613
- ...detectOverflowOptions
1614
- } = evaluate(options, state);
1615
- const overflow = await detectOverflow(state, detectOverflowOptions);
1616
- const side = getSide(placement);
1617
- const alignment = getAlignment(placement);
1618
- const isYAxis = getSideAxis(placement) === "y";
1619
- const {
1620
- width,
1621
- height
1622
- } = rects.floating;
1623
- let heightSide;
1624
- let widthSide;
1625
- if (side === "top" || side === "bottom") {
1626
- heightSide = side;
1627
- widthSide = alignment === (await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
1628
- } else {
1629
- widthSide = side;
1630
- heightSide = alignment === "end" ? "top" : "bottom";
1631
- }
1632
- const maximumClippingHeight = height - overflow.top - overflow.bottom;
1633
- const maximumClippingWidth = width - overflow.left - overflow.right;
1634
- const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
1635
- const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
1636
- const noShift = !state.middlewareData.shift;
1637
- let availableHeight = overflowAvailableHeight;
1638
- let availableWidth = overflowAvailableWidth;
1639
- if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
1640
- availableWidth = maximumClippingWidth;
1641
- }
1642
- if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
1643
- availableHeight = maximumClippingHeight;
1644
- }
1645
- if (noShift && !alignment) {
1646
- const xMin = max(overflow.left, 0);
1647
- const xMax = max(overflow.right, 0);
1648
- const yMin = max(overflow.top, 0);
1649
- const yMax = max(overflow.bottom, 0);
1650
- if (isYAxis) {
1651
- availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
1652
- } else {
1653
- availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
1654
- }
1655
- }
1656
- await apply({
1657
- ...state,
1658
- availableWidth,
1659
- availableHeight
1660
- });
1661
- const nextDimensions = await platform2.getDimensions(elements.floating);
1662
- if (width !== nextDimensions.width || height !== nextDimensions.height) {
1663
- return {
1664
- reset: {
1665
- rects: true
1666
- }
1667
- };
1668
- }
1669
- return {};
1670
- }
1671
- };
1672
- };
1673
- function hasWindow() {
1674
- return typeof window !== "undefined";
1675
- }
1676
- function getNodeName(node) {
1677
- if (isNode(node)) {
1678
- return (node.nodeName || "").toLowerCase();
1679
- }
1680
- return "#document";
1681
- }
1682
- function getWindow(node) {
1683
- var _node$ownerDocument;
1684
- return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
1685
- }
1686
- function getDocumentElement(node) {
1687
- var _ref;
1688
- return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
1689
- }
1690
- function isNode(value) {
1691
- if (!hasWindow()) {
1692
- return false;
1693
- }
1694
- return value instanceof Node || value instanceof getWindow(value).Node;
1695
- }
1696
- function isElement(value) {
1697
- if (!hasWindow()) {
1698
- return false;
1699
- }
1700
- return value instanceof Element || value instanceof getWindow(value).Element;
1701
- }
1702
- function isHTMLElement(value) {
1703
- if (!hasWindow()) {
1704
- return false;
1705
- }
1706
- return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
1707
- }
1708
- function isShadowRoot(value) {
1709
- if (!hasWindow() || typeof ShadowRoot === "undefined") {
1710
- return false;
1711
- }
1712
- return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
1713
- }
1714
- function isOverflowElement(element) {
1715
- const {
1716
- overflow,
1717
- overflowX,
1718
- overflowY,
1719
- display
1720
- } = getComputedStyle$1(element);
1721
- return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !["inline", "contents"].includes(display);
1722
- }
1723
- function isTableElement(element) {
1724
- return ["table", "td", "th"].includes(getNodeName(element));
1725
- }
1726
- function isTopLayer(element) {
1727
- return [":popover-open", ":modal"].some((selector) => {
1728
- try {
1729
- return element.matches(selector);
1730
- } catch (e) {
1731
- return false;
1732
- }
1733
- });
1734
- }
1735
- function isContainingBlock(elementOrCss) {
1736
- const webkit = isWebKit();
1737
- const css = isElement(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
1738
- return css.transform !== "none" || css.perspective !== "none" || (css.containerType ? css.containerType !== "normal" : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== "none" : false) || !webkit && (css.filter ? css.filter !== "none" : false) || ["transform", "perspective", "filter"].some((value) => (css.willChange || "").includes(value)) || ["paint", "layout", "strict", "content"].some((value) => (css.contain || "").includes(value));
1739
- }
1740
- function getContainingBlock(element) {
1741
- let currentNode = getParentNode(element);
1742
- while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
1743
- if (isContainingBlock(currentNode)) {
1744
- return currentNode;
1745
- } else if (isTopLayer(currentNode)) {
1746
- return null;
1747
- }
1748
- currentNode = getParentNode(currentNode);
1749
- }
1750
- return null;
1751
- }
1752
- function isWebKit() {
1753
- if (typeof CSS === "undefined" || !CSS.supports) return false;
1754
- return CSS.supports("-webkit-backdrop-filter", "none");
1755
- }
1756
- function isLastTraversableNode(node) {
1757
- return ["html", "body", "#document"].includes(getNodeName(node));
1758
- }
1759
- function getComputedStyle$1(element) {
1760
- return getWindow(element).getComputedStyle(element);
1761
- }
1762
- function getNodeScroll(element) {
1763
- if (isElement(element)) {
1764
- return {
1765
- scrollLeft: element.scrollLeft,
1766
- scrollTop: element.scrollTop
1767
- };
1768
- }
1769
- return {
1770
- scrollLeft: element.scrollX,
1771
- scrollTop: element.scrollY
1772
- };
1773
- }
1774
- function getParentNode(node) {
1775
- if (getNodeName(node) === "html") {
1776
- return node;
1777
- }
1778
- const result = (
1779
- // Step into the shadow DOM of the parent of a slotted node.
1780
- node.assignedSlot || // DOM Element detected.
1781
- node.parentNode || // ShadowRoot detected.
1782
- isShadowRoot(node) && node.host || // Fallback.
1783
- getDocumentElement(node)
1784
- );
1785
- return isShadowRoot(result) ? result.host : result;
1786
- }
1787
- function getNearestOverflowAncestor(node) {
1788
- const parentNode = getParentNode(node);
1789
- if (isLastTraversableNode(parentNode)) {
1790
- return node.ownerDocument ? node.ownerDocument.body : node.body;
1791
- }
1792
- if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
1793
- return parentNode;
1794
- }
1795
- return getNearestOverflowAncestor(parentNode);
1796
- }
1797
- function getOverflowAncestors(node, list, traverseIframes) {
1798
- var _node$ownerDocument2;
1799
- if (list === void 0) {
1800
- list = [];
1801
- }
1802
- if (traverseIframes === void 0) {
1803
- traverseIframes = true;
1804
- }
1805
- const scrollableAncestor = getNearestOverflowAncestor(node);
1806
- const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
1807
- const win = getWindow(scrollableAncestor);
1808
- if (isBody) {
1809
- const frameElement = getFrameElement(win);
1810
- return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
1811
- }
1812
- return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
1813
- }
1814
- function getFrameElement(win) {
1815
- return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
1816
- }
1817
- function getCssDimensions(element) {
1818
- const css = getComputedStyle$1(element);
1819
- let width = parseFloat(css.width) || 0;
1820
- let height = parseFloat(css.height) || 0;
1821
- const hasOffset = isHTMLElement(element);
1822
- const offsetWidth = hasOffset ? element.offsetWidth : width;
1823
- const offsetHeight = hasOffset ? element.offsetHeight : height;
1824
- const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
1825
- if (shouldFallback) {
1826
- width = offsetWidth;
1827
- height = offsetHeight;
1828
- }
1829
- return {
1830
- width,
1831
- height,
1832
- $: shouldFallback
1833
- };
1834
- }
1835
- function unwrapElement(element) {
1836
- return !isElement(element) ? element.contextElement : element;
1837
- }
1838
- function getScale(element) {
1839
- const domElement = unwrapElement(element);
1840
- if (!isHTMLElement(domElement)) {
1841
- return createCoords(1);
1842
- }
1843
- const rect = domElement.getBoundingClientRect();
1844
- const {
1845
- width,
1846
- height,
1847
- $
1848
- } = getCssDimensions(domElement);
1849
- let x = ($ ? round(rect.width) : rect.width) / width;
1850
- let y = ($ ? round(rect.height) : rect.height) / height;
1851
- if (!x || !Number.isFinite(x)) {
1852
- x = 1;
1853
- }
1854
- if (!y || !Number.isFinite(y)) {
1855
- y = 1;
1856
- }
1857
- return {
1858
- x,
1859
- y
1860
- };
1861
- }
1862
- const noOffsets = /* @__PURE__ */ createCoords(0);
1863
- function getVisualOffsets(element) {
1864
- const win = getWindow(element);
1865
- if (!isWebKit() || !win.visualViewport) {
1866
- return noOffsets;
1867
- }
1868
- return {
1869
- x: win.visualViewport.offsetLeft,
1870
- y: win.visualViewport.offsetTop
1871
- };
1872
- }
1873
- function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
1874
- if (isFixed === void 0) {
1875
- isFixed = false;
1876
- }
1877
- if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
1878
- return false;
1879
- }
1880
- return isFixed;
1881
- }
1882
- function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
1883
- if (includeScale === void 0) {
1884
- includeScale = false;
1885
- }
1886
- if (isFixedStrategy === void 0) {
1887
- isFixedStrategy = false;
1888
- }
1889
- const clientRect = element.getBoundingClientRect();
1890
- const domElement = unwrapElement(element);
1891
- let scale = createCoords(1);
1892
- if (includeScale) {
1893
- if (offsetParent) {
1894
- if (isElement(offsetParent)) {
1895
- scale = getScale(offsetParent);
1896
- }
1897
- } else {
1898
- scale = getScale(element);
1899
- }
1900
- }
1901
- const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
1902
- let x = (clientRect.left + visualOffsets.x) / scale.x;
1903
- let y = (clientRect.top + visualOffsets.y) / scale.y;
1904
- let width = clientRect.width / scale.x;
1905
- let height = clientRect.height / scale.y;
1906
- if (domElement) {
1907
- const win = getWindow(domElement);
1908
- const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
1909
- let currentWin = win;
1910
- let currentIFrame = getFrameElement(currentWin);
1911
- while (currentIFrame && offsetParent && offsetWin !== currentWin) {
1912
- const iframeScale = getScale(currentIFrame);
1913
- const iframeRect = currentIFrame.getBoundingClientRect();
1914
- const css = getComputedStyle$1(currentIFrame);
1915
- const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
1916
- const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
1917
- x *= iframeScale.x;
1918
- y *= iframeScale.y;
1919
- width *= iframeScale.x;
1920
- height *= iframeScale.y;
1921
- x += left;
1922
- y += top;
1923
- currentWin = getWindow(currentIFrame);
1924
- currentIFrame = getFrameElement(currentWin);
1925
- }
1926
- }
1927
- return rectToClientRect({
1928
- width,
1929
- height,
1930
- x,
1931
- y
1932
- });
1933
- }
1934
- function getWindowScrollBarX(element, rect) {
1935
- const leftScroll = getNodeScroll(element).scrollLeft;
1936
- if (!rect) {
1937
- return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
1938
- }
1939
- return rect.left + leftScroll;
1940
- }
1941
- function getHTMLOffset(documentElement, scroll, ignoreScrollbarX) {
1942
- if (ignoreScrollbarX === void 0) {
1943
- ignoreScrollbarX = false;
1944
- }
1945
- const htmlRect = documentElement.getBoundingClientRect();
1946
- const x = htmlRect.left + scroll.scrollLeft - (ignoreScrollbarX ? 0 : (
1947
- // RTL <body> scrollbar.
1948
- getWindowScrollBarX(documentElement, htmlRect)
1949
- ));
1950
- const y = htmlRect.top + scroll.scrollTop;
1951
- return {
1952
- x,
1953
- y
1954
- };
1955
- }
1956
- function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
1957
- let {
1958
- elements,
1959
- rect,
1960
- offsetParent,
1961
- strategy
1962
- } = _ref;
1963
- const isFixed = strategy === "fixed";
1964
- const documentElement = getDocumentElement(offsetParent);
1965
- const topLayer = elements ? isTopLayer(elements.floating) : false;
1966
- if (offsetParent === documentElement || topLayer && isFixed) {
1967
- return rect;
1968
- }
1969
- let scroll = {
1970
- scrollLeft: 0,
1971
- scrollTop: 0
1972
- };
1973
- let scale = createCoords(1);
1974
- const offsets = createCoords(0);
1975
- const isOffsetParentAnElement = isHTMLElement(offsetParent);
1976
- if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1977
- if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
1978
- scroll = getNodeScroll(offsetParent);
1979
- }
1980
- if (isHTMLElement(offsetParent)) {
1981
- const offsetRect = getBoundingClientRect(offsetParent);
1982
- scale = getScale(offsetParent);
1983
- offsets.x = offsetRect.x + offsetParent.clientLeft;
1984
- offsets.y = offsetRect.y + offsetParent.clientTop;
1985
- }
1986
- }
1987
- const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll, true) : createCoords(0);
1988
- return {
1989
- width: rect.width * scale.x,
1990
- height: rect.height * scale.y,
1991
- x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
1992
- y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
1993
- };
1994
- }
1995
- function getClientRects(element) {
1996
- return Array.from(element.getClientRects());
1997
- }
1998
- function getDocumentRect(element) {
1999
- const html = getDocumentElement(element);
2000
- const scroll = getNodeScroll(element);
2001
- const body = element.ownerDocument.body;
2002
- const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
2003
- const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
2004
- let x = -scroll.scrollLeft + getWindowScrollBarX(element);
2005
- const y = -scroll.scrollTop;
2006
- if (getComputedStyle$1(body).direction === "rtl") {
2007
- x += max(html.clientWidth, body.clientWidth) - width;
2008
- }
2009
- return {
2010
- width,
2011
- height,
2012
- x,
2013
- y
2014
- };
2015
- }
2016
- function getViewportRect(element, strategy) {
2017
- const win = getWindow(element);
2018
- const html = getDocumentElement(element);
2019
- const visualViewport = win.visualViewport;
2020
- let width = html.clientWidth;
2021
- let height = html.clientHeight;
2022
- let x = 0;
2023
- let y = 0;
2024
- if (visualViewport) {
2025
- width = visualViewport.width;
2026
- height = visualViewport.height;
2027
- const visualViewportBased = isWebKit();
2028
- if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
2029
- x = visualViewport.offsetLeft;
2030
- y = visualViewport.offsetTop;
2031
- }
2032
- }
2033
- return {
2034
- width,
2035
- height,
2036
- x,
2037
- y
2038
- };
2039
- }
2040
- function getInnerBoundingClientRect(element, strategy) {
2041
- const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
2042
- const top = clientRect.top + element.clientTop;
2043
- const left = clientRect.left + element.clientLeft;
2044
- const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
2045
- const width = element.clientWidth * scale.x;
2046
- const height = element.clientHeight * scale.y;
2047
- const x = left * scale.x;
2048
- const y = top * scale.y;
2049
- return {
2050
- width,
2051
- height,
2052
- x,
2053
- y
2054
- };
2055
- }
2056
- function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
2057
- let rect;
2058
- if (clippingAncestor === "viewport") {
2059
- rect = getViewportRect(element, strategy);
2060
- } else if (clippingAncestor === "document") {
2061
- rect = getDocumentRect(getDocumentElement(element));
2062
- } else if (isElement(clippingAncestor)) {
2063
- rect = getInnerBoundingClientRect(clippingAncestor, strategy);
2064
- } else {
2065
- const visualOffsets = getVisualOffsets(element);
2066
- rect = {
2067
- x: clippingAncestor.x - visualOffsets.x,
2068
- y: clippingAncestor.y - visualOffsets.y,
2069
- width: clippingAncestor.width,
2070
- height: clippingAncestor.height
2071
- };
2072
- }
2073
- return rectToClientRect(rect);
2074
- }
2075
- function hasFixedPositionAncestor(element, stopNode) {
2076
- const parentNode = getParentNode(element);
2077
- if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
2078
- return false;
2079
- }
2080
- return getComputedStyle$1(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
2081
- }
2082
- function getClippingElementAncestors(element, cache) {
2083
- const cachedResult = cache.get(element);
2084
- if (cachedResult) {
2085
- return cachedResult;
2086
- }
2087
- let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
2088
- let currentContainingBlockComputedStyle = null;
2089
- const elementIsFixed = getComputedStyle$1(element).position === "fixed";
2090
- let currentNode = elementIsFixed ? getParentNode(element) : element;
2091
- while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
2092
- const computedStyle = getComputedStyle$1(currentNode);
2093
- const currentNodeIsContaining = isContainingBlock(currentNode);
2094
- if (!currentNodeIsContaining && computedStyle.position === "fixed") {
2095
- currentContainingBlockComputedStyle = null;
2096
- }
2097
- const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && ["absolute", "fixed"].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
2098
- if (shouldDropCurrentNode) {
2099
- result = result.filter((ancestor) => ancestor !== currentNode);
2100
- } else {
2101
- currentContainingBlockComputedStyle = computedStyle;
2102
- }
2103
- currentNode = getParentNode(currentNode);
2104
- }
2105
- cache.set(element, result);
2106
- return result;
2107
- }
2108
- function getClippingRect(_ref) {
2109
- let {
2110
- element,
2111
- boundary,
2112
- rootBoundary,
2113
- strategy
2114
- } = _ref;
2115
- const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
2116
- const clippingAncestors = [...elementClippingAncestors, rootBoundary];
2117
- const firstClippingAncestor = clippingAncestors[0];
2118
- const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
2119
- const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
2120
- accRect.top = max(rect.top, accRect.top);
2121
- accRect.right = min(rect.right, accRect.right);
2122
- accRect.bottom = min(rect.bottom, accRect.bottom);
2123
- accRect.left = max(rect.left, accRect.left);
2124
- return accRect;
2125
- }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
2126
- return {
2127
- width: clippingRect.right - clippingRect.left,
2128
- height: clippingRect.bottom - clippingRect.top,
2129
- x: clippingRect.left,
2130
- y: clippingRect.top
2131
- };
2132
- }
2133
- function getDimensions(element) {
2134
- const {
2135
- width,
2136
- height
2137
- } = getCssDimensions(element);
2138
- return {
2139
- width,
2140
- height
2141
- };
2142
- }
2143
- function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
2144
- const isOffsetParentAnElement = isHTMLElement(offsetParent);
2145
- const documentElement = getDocumentElement(offsetParent);
2146
- const isFixed = strategy === "fixed";
2147
- const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
2148
- let scroll = {
2149
- scrollLeft: 0,
2150
- scrollTop: 0
2151
- };
2152
- const offsets = createCoords(0);
2153
- if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
2154
- if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
2155
- scroll = getNodeScroll(offsetParent);
2156
- }
2157
- if (isOffsetParentAnElement) {
2158
- const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
2159
- offsets.x = offsetRect.x + offsetParent.clientLeft;
2160
- offsets.y = offsetRect.y + offsetParent.clientTop;
2161
- } else if (documentElement) {
2162
- offsets.x = getWindowScrollBarX(documentElement);
2163
- }
2164
- }
2165
- const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
2166
- const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
2167
- const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
2168
- return {
2169
- x,
2170
- y,
2171
- width: rect.width,
2172
- height: rect.height
2173
- };
2174
- }
2175
- function isStaticPositioned(element) {
2176
- return getComputedStyle$1(element).position === "static";
2177
- }
2178
- function getTrueOffsetParent(element, polyfill) {
2179
- if (!isHTMLElement(element) || getComputedStyle$1(element).position === "fixed") {
2180
- return null;
2181
- }
2182
- if (polyfill) {
2183
- return polyfill(element);
2184
- }
2185
- let rawOffsetParent = element.offsetParent;
2186
- if (getDocumentElement(element) === rawOffsetParent) {
2187
- rawOffsetParent = rawOffsetParent.ownerDocument.body;
2188
- }
2189
- return rawOffsetParent;
2190
- }
2191
- function getOffsetParent(element, polyfill) {
2192
- const win = getWindow(element);
2193
- if (isTopLayer(element)) {
2194
- return win;
2195
- }
2196
- if (!isHTMLElement(element)) {
2197
- let svgOffsetParent = getParentNode(element);
2198
- while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
2199
- if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
2200
- return svgOffsetParent;
2201
- }
2202
- svgOffsetParent = getParentNode(svgOffsetParent);
2203
- }
2204
- return win;
2205
- }
2206
- let offsetParent = getTrueOffsetParent(element, polyfill);
2207
- while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
2208
- offsetParent = getTrueOffsetParent(offsetParent, polyfill);
2209
- }
2210
- if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
2211
- return win;
2212
- }
2213
- return offsetParent || getContainingBlock(element) || win;
2214
- }
2215
- const getElementRects = async function(data) {
2216
- const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
2217
- const getDimensionsFn = this.getDimensions;
2218
- const floatingDimensions = await getDimensionsFn(data.floating);
2219
- return {
2220
- reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
2221
- floating: {
2222
- x: 0,
2223
- y: 0,
2224
- width: floatingDimensions.width,
2225
- height: floatingDimensions.height
2226
- }
2227
- };
2228
- };
2229
- function isRTL(element) {
2230
- return getComputedStyle$1(element).direction === "rtl";
2231
- }
2232
- const platform = {
2233
- convertOffsetParentRelativeRectToViewportRelativeRect,
2234
- getDocumentElement,
2235
- getClippingRect,
2236
- getOffsetParent,
2237
- getElementRects,
2238
- getClientRects,
2239
- getDimensions,
2240
- getScale,
2241
- isElement,
2242
- isRTL
2243
- };
2244
- function observeMove(element, onMove) {
2245
- let io = null;
2246
- let timeoutId;
2247
- const root = getDocumentElement(element);
2248
- function cleanup() {
2249
- var _io;
2250
- clearTimeout(timeoutId);
2251
- (_io = io) == null || _io.disconnect();
2252
- io = null;
2253
- }
2254
- function refresh(skip, threshold) {
2255
- if (skip === void 0) {
2256
- skip = false;
2257
- }
2258
- if (threshold === void 0) {
2259
- threshold = 1;
2260
- }
2261
- cleanup();
2262
- const {
2263
- left,
2264
- top,
2265
- width,
2266
- height
2267
- } = element.getBoundingClientRect();
2268
- if (!skip) {
2269
- onMove();
2270
- }
2271
- if (!width || !height) {
2272
- return;
2273
- }
2274
- const insetTop = floor(top);
2275
- const insetRight = floor(root.clientWidth - (left + width));
2276
- const insetBottom = floor(root.clientHeight - (top + height));
2277
- const insetLeft = floor(left);
2278
- const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
2279
- const options = {
2280
- rootMargin,
2281
- threshold: max(0, min(1, threshold)) || 1
2282
- };
2283
- let isFirstUpdate = true;
2284
- function handleObserve(entries) {
2285
- const ratio = entries[0].intersectionRatio;
2286
- if (ratio !== threshold) {
2287
- if (!isFirstUpdate) {
2288
- return refresh();
2289
- }
2290
- if (!ratio) {
2291
- timeoutId = setTimeout(() => {
2292
- refresh(false, 1e-7);
2293
- }, 1e3);
2294
- } else {
2295
- refresh(false, ratio);
2296
- }
2297
- }
2298
- isFirstUpdate = false;
2299
- }
2300
- try {
2301
- io = new IntersectionObserver(handleObserve, {
2302
- ...options,
2303
- // Handle <iframe>s
2304
- root: root.ownerDocument
2305
- });
2306
- } catch (e) {
2307
- io = new IntersectionObserver(handleObserve, options);
2308
- }
2309
- io.observe(element);
2310
- }
2311
- refresh(true);
2312
- return cleanup;
2313
- }
2314
- function autoUpdate(reference, floating, update, options) {
2315
- if (options === void 0) {
2316
- options = {};
2317
- }
2318
- const {
2319
- ancestorScroll = true,
2320
- ancestorResize = true,
2321
- elementResize = typeof ResizeObserver === "function",
2322
- layoutShift = typeof IntersectionObserver === "function",
2323
- animationFrame = false
2324
- } = options;
2325
- const referenceEl = unwrapElement(reference);
2326
- const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...getOverflowAncestors(floating)] : [];
2327
- ancestors.forEach((ancestor) => {
2328
- ancestorScroll && ancestor.addEventListener("scroll", update, {
2329
- passive: true
2330
- });
2331
- ancestorResize && ancestor.addEventListener("resize", update);
2332
- });
2333
- const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
2334
- let reobserveFrame = -1;
2335
- let resizeObserver = null;
2336
- if (elementResize) {
2337
- resizeObserver = new ResizeObserver((_ref) => {
2338
- let [firstEntry] = _ref;
2339
- if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
2340
- resizeObserver.unobserve(floating);
2341
- cancelAnimationFrame(reobserveFrame);
2342
- reobserveFrame = requestAnimationFrame(() => {
2343
- var _resizeObserver;
2344
- (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
2345
- });
2346
- }
2347
- update();
2348
- });
2349
- if (referenceEl && !animationFrame) {
2350
- resizeObserver.observe(referenceEl);
2351
- }
2352
- resizeObserver.observe(floating);
2353
- }
2354
- let frameId;
2355
- let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
2356
- if (animationFrame) {
2357
- frameLoop();
2358
- }
2359
- function frameLoop() {
2360
- const nextRefRect = getBoundingClientRect(reference);
2361
- if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) {
2362
- update();
2363
- }
2364
- prevRefRect = nextRefRect;
2365
- frameId = requestAnimationFrame(frameLoop);
2366
- }
2367
- update();
2368
- return () => {
2369
- var _resizeObserver2;
2370
- ancestors.forEach((ancestor) => {
2371
- ancestorScroll && ancestor.removeEventListener("scroll", update);
2372
- ancestorResize && ancestor.removeEventListener("resize", update);
2373
- });
2374
- cleanupIo == null || cleanupIo();
2375
- (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
2376
- resizeObserver = null;
2377
- if (animationFrame) {
2378
- cancelAnimationFrame(frameId);
2379
- }
2380
- };
2381
- }
2382
- const offset$1 = offset$2;
2383
- const shift$1 = shift$2;
2384
- const flip$1 = flip$2;
2385
- const size$1 = size$2;
2386
- const hide$1 = hide$2;
2387
- const arrow$2 = arrow$3;
2388
- const limitShift$1 = limitShift$2;
2389
- const computePosition = (reference, floating, options) => {
2390
- const cache = /* @__PURE__ */ new Map();
2391
- const mergedOptions = {
2392
- platform,
2393
- ...options
2394
- };
2395
- const platformWithCache = {
2396
- ...mergedOptions.platform,
2397
- _c: cache
2398
- };
2399
- return computePosition$1(reference, floating, {
2400
- ...mergedOptions,
2401
- platform: platformWithCache
2402
- });
2403
- };
2404
- var index$1 = typeof document !== "undefined" ? React.useLayoutEffect : React.useEffect;
2405
- function deepEqual(a, b) {
2406
- if (a === b) {
2407
- return true;
2408
- }
2409
- if (typeof a !== typeof b) {
2410
- return false;
2411
- }
2412
- if (typeof a === "function" && a.toString() === b.toString()) {
2413
- return true;
2414
- }
2415
- let length;
2416
- let i;
2417
- let keys;
2418
- if (a && b && typeof a === "object") {
2419
- if (Array.isArray(a)) {
2420
- length = a.length;
2421
- if (length !== b.length) return false;
2422
- for (i = length; i-- !== 0; ) {
2423
- if (!deepEqual(a[i], b[i])) {
2424
- return false;
2425
- }
2426
- }
2427
- return true;
2428
- }
2429
- keys = Object.keys(a);
2430
- length = keys.length;
2431
- if (length !== Object.keys(b).length) {
2432
- return false;
2433
- }
2434
- for (i = length; i-- !== 0; ) {
2435
- if (!{}.hasOwnProperty.call(b, keys[i])) {
2436
- return false;
2437
- }
2438
- }
2439
- for (i = length; i-- !== 0; ) {
2440
- const key = keys[i];
2441
- if (key === "_owner" && a.$$typeof) {
2442
- continue;
2443
- }
2444
- if (!deepEqual(a[key], b[key])) {
2445
- return false;
2446
- }
2447
- }
2448
- return true;
2449
- }
2450
- return a !== a && b !== b;
2451
- }
2452
- function getDPR(element) {
2453
- if (typeof window === "undefined") {
2454
- return 1;
2455
- }
2456
- const win = element.ownerDocument.defaultView || window;
2457
- return win.devicePixelRatio || 1;
2458
- }
2459
- function roundByDPR(element, value) {
2460
- const dpr = getDPR(element);
2461
- return Math.round(value * dpr) / dpr;
2462
- }
2463
- function useLatestRef(value) {
2464
- const ref = React__namespace.useRef(value);
2465
- index$1(() => {
2466
- ref.current = value;
2467
- });
2468
- return ref;
2469
- }
2470
- function useFloating(options) {
2471
- if (options === void 0) {
2472
- options = {};
2473
- }
2474
- const {
2475
- placement = "bottom",
2476
- strategy = "absolute",
2477
- middleware = [],
2478
- platform: platform2,
2479
- elements: {
2480
- reference: externalReference,
2481
- floating: externalFloating
2482
- } = {},
2483
- transform = true,
2484
- whileElementsMounted,
2485
- open
2486
- } = options;
2487
- const [data, setData] = React__namespace.useState({
2488
- x: 0,
2489
- y: 0,
2490
- strategy,
2491
- placement,
2492
- middlewareData: {},
2493
- isPositioned: false
2494
- });
2495
- const [latestMiddleware, setLatestMiddleware] = React__namespace.useState(middleware);
2496
- if (!deepEqual(latestMiddleware, middleware)) {
2497
- setLatestMiddleware(middleware);
2498
- }
2499
- const [_reference, _setReference] = React__namespace.useState(null);
2500
- const [_floating, _setFloating] = React__namespace.useState(null);
2501
- const setReference = React__namespace.useCallback((node) => {
2502
- if (node !== referenceRef.current) {
2503
- referenceRef.current = node;
2504
- _setReference(node);
2505
- }
2506
- }, []);
2507
- const setFloating = React__namespace.useCallback((node) => {
2508
- if (node !== floatingRef.current) {
2509
- floatingRef.current = node;
2510
- _setFloating(node);
2511
- }
2512
- }, []);
2513
- const referenceEl = externalReference || _reference;
2514
- const floatingEl = externalFloating || _floating;
2515
- const referenceRef = React__namespace.useRef(null);
2516
- const floatingRef = React__namespace.useRef(null);
2517
- const dataRef = React__namespace.useRef(data);
2518
- const hasWhileElementsMounted = whileElementsMounted != null;
2519
- const whileElementsMountedRef = useLatestRef(whileElementsMounted);
2520
- const platformRef = useLatestRef(platform2);
2521
- const openRef = useLatestRef(open);
2522
- const update = React__namespace.useCallback(() => {
2523
- if (!referenceRef.current || !floatingRef.current) {
2524
- return;
2525
- }
2526
- const config = {
2527
- placement,
2528
- strategy,
2529
- middleware: latestMiddleware
2530
- };
2531
- if (platformRef.current) {
2532
- config.platform = platformRef.current;
2533
- }
2534
- computePosition(referenceRef.current, floatingRef.current, config).then((data2) => {
2535
- const fullData = {
2536
- ...data2,
2537
- // The floating element's position may be recomputed while it's closed
2538
- // but still mounted (such as when transitioning out). To ensure
2539
- // `isPositioned` will be `false` initially on the next open, avoid
2540
- // setting it to `true` when `open === false` (must be specified).
2541
- isPositioned: openRef.current !== false
2542
- };
2543
- if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
2544
- dataRef.current = fullData;
2545
- ReactDOM__namespace.flushSync(() => {
2546
- setData(fullData);
2547
- });
2548
- }
2549
- });
2550
- }, [latestMiddleware, placement, strategy, platformRef, openRef]);
2551
- index$1(() => {
2552
- if (open === false && dataRef.current.isPositioned) {
2553
- dataRef.current.isPositioned = false;
2554
- setData((data2) => ({
2555
- ...data2,
2556
- isPositioned: false
2557
- }));
2558
- }
2559
- }, [open]);
2560
- const isMountedRef = React__namespace.useRef(false);
2561
- index$1(() => {
2562
- isMountedRef.current = true;
2563
- return () => {
2564
- isMountedRef.current = false;
2565
- };
2566
- }, []);
2567
- index$1(() => {
2568
- if (referenceEl) referenceRef.current = referenceEl;
2569
- if (floatingEl) floatingRef.current = floatingEl;
2570
- if (referenceEl && floatingEl) {
2571
- if (whileElementsMountedRef.current) {
2572
- return whileElementsMountedRef.current(referenceEl, floatingEl, update);
2573
- }
2574
- update();
2575
- }
2576
- }, [referenceEl, floatingEl, update, whileElementsMountedRef, hasWhileElementsMounted]);
2577
- const refs = React__namespace.useMemo(() => ({
2578
- reference: referenceRef,
2579
- floating: floatingRef,
2580
- setReference,
2581
- setFloating
2582
- }), [setReference, setFloating]);
2583
- const elements = React__namespace.useMemo(() => ({
2584
- reference: referenceEl,
2585
- floating: floatingEl
2586
- }), [referenceEl, floatingEl]);
2587
- const floatingStyles = React__namespace.useMemo(() => {
2588
- const initialStyles = {
2589
- position: strategy,
2590
- left: 0,
2591
- top: 0
2592
- };
2593
- if (!elements.floating) {
2594
- return initialStyles;
2595
- }
2596
- const x = roundByDPR(elements.floating, data.x);
2597
- const y = roundByDPR(elements.floating, data.y);
2598
- if (transform) {
2599
- return {
2600
- ...initialStyles,
2601
- transform: "translate(" + x + "px, " + y + "px)",
2602
- ...getDPR(elements.floating) >= 1.5 && {
2603
- willChange: "transform"
2604
- }
2605
- };
2606
- }
2607
- return {
2608
- position: strategy,
2609
- left: x,
2610
- top: y
2611
- };
2612
- }, [strategy, transform, elements.floating, data.x, data.y]);
2613
- return React__namespace.useMemo(() => ({
2614
- ...data,
2615
- update,
2616
- refs,
2617
- elements,
2618
- floatingStyles
2619
- }), [data, update, refs, elements, floatingStyles]);
2620
- }
2621
- const arrow$1 = (options) => {
2622
- function isRef(value) {
2623
- return {}.hasOwnProperty.call(value, "current");
2624
- }
2625
- return {
2626
- name: "arrow",
2627
- options,
2628
- fn(state) {
2629
- const {
2630
- element,
2631
- padding
2632
- } = typeof options === "function" ? options(state) : options;
2633
- if (element && isRef(element)) {
2634
- if (element.current != null) {
2635
- return arrow$2({
2636
- element: element.current,
2637
- padding
2638
- }).fn(state);
2639
- }
2640
- return {};
2641
- }
2642
- if (element) {
2643
- return arrow$2({
2644
- element,
2645
- padding
2646
- }).fn(state);
2647
- }
2648
- return {};
2649
- }
2650
- };
2651
- };
2652
- const offset = (options, deps) => ({
2653
- ...offset$1(options),
2654
- options: [options, deps]
2655
- });
2656
- const shift = (options, deps) => ({
2657
- ...shift$1(options),
2658
- options: [options, deps]
2659
- });
2660
- const limitShift = (options, deps) => ({
2661
- ...limitShift$1(options),
2662
- options: [options, deps]
2663
- });
2664
- const flip = (options, deps) => ({
2665
- ...flip$1(options),
2666
- options: [options, deps]
2667
- });
2668
- const size = (options, deps) => ({
2669
- ...size$1(options),
2670
- options: [options, deps]
2671
- });
2672
- const hide = (options, deps) => ({
2673
- ...hide$1(options),
2674
- options: [options, deps]
2675
- });
2676
- const arrow = (options, deps) => ({
2677
- ...arrow$1(options),
2678
- options: [options, deps]
2679
- });
2680
- const $7e8f5cd07187803e$export$21b07c8f274aebd5 = /* @__PURE__ */ React.forwardRef((props, forwardedRef) => {
2681
- const { children, width = 10, height = 5, ...arrowProps } = props;
2682
- return /* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.svg, _extends({}, arrowProps, {
2683
- ref: forwardedRef,
2684
- width,
2685
- height,
2686
- viewBox: "0 0 30 10",
2687
- preserveAspectRatio: "none"
2688
- }), props.asChild ? children : /* @__PURE__ */ React.createElement("polygon", {
2689
- points: "0,0 30,0 15,10"
2690
- }));
2691
- });
2692
- const $7e8f5cd07187803e$export$be92b6f5f03c0fe9 = $7e8f5cd07187803e$export$21b07c8f274aebd5;
2693
- function $db6c3485150b8e66$export$1ab7ae714698c4b8(element) {
2694
- const [size2, setSize] = React.useState(void 0);
2695
- $9f79659886946c16$export$e5c5a5f917a5871c(() => {
2696
- if (element) {
2697
- setSize({
2698
- width: element.offsetWidth,
2699
- height: element.offsetHeight
2700
- });
2701
- const resizeObserver = new ResizeObserver((entries) => {
2702
- if (!Array.isArray(entries)) return;
2703
- if (!entries.length) return;
2704
- const entry = entries[0];
2705
- let width;
2706
- let height;
2707
- if ("borderBoxSize" in entry) {
2708
- const borderSizeEntry = entry["borderBoxSize"];
2709
- const borderSize = Array.isArray(borderSizeEntry) ? borderSizeEntry[0] : borderSizeEntry;
2710
- width = borderSize["inlineSize"];
2711
- height = borderSize["blockSize"];
2712
- } else {
2713
- width = element.offsetWidth;
2714
- height = element.offsetHeight;
2715
- }
2716
- setSize({
2717
- width,
2718
- height
2719
- });
2720
- });
2721
- resizeObserver.observe(element, {
2722
- box: "border-box"
2723
- });
2724
- return () => resizeObserver.unobserve(element);
2725
- } else
2726
- setSize(void 0);
2727
- }, [
2728
- element
2729
- ]);
2730
- return size2;
2731
- }
2732
- const $cf1ac5d9fe0e8206$var$POPPER_NAME = "Popper";
2733
- const [$cf1ac5d9fe0e8206$var$createPopperContext, $cf1ac5d9fe0e8206$export$722aac194ae923] = $c512c27ab02ef895$export$50c7b4e9d9f19c1($cf1ac5d9fe0e8206$var$POPPER_NAME);
2734
- const [$cf1ac5d9fe0e8206$var$PopperProvider, $cf1ac5d9fe0e8206$var$usePopperContext] = $cf1ac5d9fe0e8206$var$createPopperContext($cf1ac5d9fe0e8206$var$POPPER_NAME);
2735
- const $cf1ac5d9fe0e8206$export$badac9ada3a0bdf9 = (props) => {
2736
- const { __scopePopper, children } = props;
2737
- const [anchor, setAnchor] = React.useState(null);
2738
- return /* @__PURE__ */ React.createElement($cf1ac5d9fe0e8206$var$PopperProvider, {
2739
- scope: __scopePopper,
2740
- anchor,
2741
- onAnchorChange: setAnchor
2742
- }, children);
2743
- };
2744
- const $cf1ac5d9fe0e8206$var$ANCHOR_NAME = "PopperAnchor";
2745
- const $cf1ac5d9fe0e8206$export$ecd4e1ccab6ed6d = /* @__PURE__ */ React.forwardRef((props, forwardedRef) => {
2746
- const { __scopePopper, virtualRef, ...anchorProps } = props;
2747
- const context = $cf1ac5d9fe0e8206$var$usePopperContext($cf1ac5d9fe0e8206$var$ANCHOR_NAME, __scopePopper);
2748
- const ref = React.useRef(null);
2749
- const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, ref);
2750
- React.useEffect(() => {
2751
- context.onAnchorChange((virtualRef === null || virtualRef === void 0 ? void 0 : virtualRef.current) || ref.current);
2752
- });
2753
- return virtualRef ? null : /* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({}, anchorProps, {
2754
- ref: composedRefs
2755
- }));
2756
- });
2757
- const $cf1ac5d9fe0e8206$var$CONTENT_NAME = "PopperContent";
2758
- const [$cf1ac5d9fe0e8206$var$PopperContentProvider, $cf1ac5d9fe0e8206$var$useContentContext] = $cf1ac5d9fe0e8206$var$createPopperContext($cf1ac5d9fe0e8206$var$CONTENT_NAME);
2759
- const $cf1ac5d9fe0e8206$export$bc4ae5855d3c4fc = /* @__PURE__ */ React.forwardRef((props, forwardedRef) => {
2760
- var _arrowSize$width, _arrowSize$height, _middlewareData$arrow, _middlewareData$arrow2, _middlewareData$arrow3, _middlewareData$trans, _middlewareData$trans2, _middlewareData$hide;
2761
- const { __scopePopper, side = "bottom", sideOffset = 0, align = "center", alignOffset = 0, arrowPadding = 0, avoidCollisions = true, collisionBoundary = [], collisionPadding: collisionPaddingProp = 0, sticky = "partial", hideWhenDetached = false, updatePositionStrategy = "optimized", onPlaced, ...contentProps } = props;
2762
- const context = $cf1ac5d9fe0e8206$var$usePopperContext($cf1ac5d9fe0e8206$var$CONTENT_NAME, __scopePopper);
2763
- const [content, setContent] = React.useState(null);
2764
- const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(
2765
- forwardedRef,
2766
- (node) => setContent(node)
2767
- );
2768
- const [arrow$12, setArrow] = React.useState(null);
2769
- const arrowSize = $db6c3485150b8e66$export$1ab7ae714698c4b8(arrow$12);
2770
- const arrowWidth = (_arrowSize$width = arrowSize === null || arrowSize === void 0 ? void 0 : arrowSize.width) !== null && _arrowSize$width !== void 0 ? _arrowSize$width : 0;
2771
- const arrowHeight = (_arrowSize$height = arrowSize === null || arrowSize === void 0 ? void 0 : arrowSize.height) !== null && _arrowSize$height !== void 0 ? _arrowSize$height : 0;
2772
- const desiredPlacement = side + (align !== "center" ? "-" + align : "");
2773
- const collisionPadding = typeof collisionPaddingProp === "number" ? collisionPaddingProp : {
2774
- top: 0,
2775
- right: 0,
2776
- bottom: 0,
2777
- left: 0,
2778
- ...collisionPaddingProp
2779
- };
2780
- const boundary = Array.isArray(collisionBoundary) ? collisionBoundary : [
2781
- collisionBoundary
2782
- ];
2783
- const hasExplicitBoundaries = boundary.length > 0;
2784
- const detectOverflowOptions = {
2785
- padding: collisionPadding,
2786
- boundary: boundary.filter($cf1ac5d9fe0e8206$var$isNotNull),
2787
- // with `strategy: 'fixed'`, this is the only way to get it to respect boundaries
2788
- altBoundary: hasExplicitBoundaries
2789
- };
2790
- const { refs, floatingStyles, placement, isPositioned, middlewareData } = useFloating({
2791
- // default to `fixed` strategy so users don't have to pick and we also avoid focus scroll issues
2792
- strategy: "fixed",
2793
- placement: desiredPlacement,
2794
- whileElementsMounted: (...args) => {
2795
- const cleanup = autoUpdate(...args, {
2796
- animationFrame: updatePositionStrategy === "always"
2797
- });
2798
- return cleanup;
2799
- },
2800
- elements: {
2801
- reference: context.anchor
2802
- },
2803
- middleware: [
2804
- offset({
2805
- mainAxis: sideOffset + arrowHeight,
2806
- alignmentAxis: alignOffset
2807
- }),
2808
- avoidCollisions && shift({
2809
- mainAxis: true,
2810
- crossAxis: false,
2811
- limiter: sticky === "partial" ? limitShift() : void 0,
2812
- ...detectOverflowOptions
2813
- }),
2814
- avoidCollisions && flip({
2815
- ...detectOverflowOptions
2816
- }),
2817
- size({
2818
- ...detectOverflowOptions,
2819
- apply: ({ elements, rects, availableWidth, availableHeight }) => {
2820
- const { width: anchorWidth, height: anchorHeight } = rects.reference;
2821
- const contentStyle = elements.floating.style;
2822
- contentStyle.setProperty("--radix-popper-available-width", `${availableWidth}px`);
2823
- contentStyle.setProperty("--radix-popper-available-height", `${availableHeight}px`);
2824
- contentStyle.setProperty("--radix-popper-anchor-width", `${anchorWidth}px`);
2825
- contentStyle.setProperty("--radix-popper-anchor-height", `${anchorHeight}px`);
2826
- }
2827
- }),
2828
- arrow$12 && arrow({
2829
- element: arrow$12,
2830
- padding: arrowPadding
2831
- }),
2832
- $cf1ac5d9fe0e8206$var$transformOrigin({
2833
- arrowWidth,
2834
- arrowHeight
2835
- }),
2836
- hideWhenDetached && hide({
2837
- strategy: "referenceHidden",
2838
- ...detectOverflowOptions
2839
- })
2840
- ]
2841
- });
2842
- const [placedSide, placedAlign] = $cf1ac5d9fe0e8206$var$getSideAndAlignFromPlacement(placement);
2843
- const handlePlaced = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onPlaced);
2844
- $9f79659886946c16$export$e5c5a5f917a5871c(() => {
2845
- if (isPositioned) handlePlaced === null || handlePlaced === void 0 || handlePlaced();
2846
- }, [
2847
- isPositioned,
2848
- handlePlaced
2849
- ]);
2850
- const arrowX = (_middlewareData$arrow = middlewareData.arrow) === null || _middlewareData$arrow === void 0 ? void 0 : _middlewareData$arrow.x;
2851
- const arrowY = (_middlewareData$arrow2 = middlewareData.arrow) === null || _middlewareData$arrow2 === void 0 ? void 0 : _middlewareData$arrow2.y;
2852
- const cannotCenterArrow = ((_middlewareData$arrow3 = middlewareData.arrow) === null || _middlewareData$arrow3 === void 0 ? void 0 : _middlewareData$arrow3.centerOffset) !== 0;
2853
- const [contentZIndex, setContentZIndex] = React.useState();
2854
- $9f79659886946c16$export$e5c5a5f917a5871c(() => {
2855
- if (content) setContentZIndex(window.getComputedStyle(content).zIndex);
2856
- }, [
2857
- content
2858
- ]);
2859
- return /* @__PURE__ */ React.createElement("div", {
2860
- ref: refs.setFloating,
2861
- "data-radix-popper-content-wrapper": "",
2862
- style: {
2863
- ...floatingStyles,
2864
- transform: isPositioned ? floatingStyles.transform : "translate(0, -200%)",
2865
- // keep off the page when measuring
2866
- minWidth: "max-content",
2867
- zIndex: contentZIndex,
2868
- ["--radix-popper-transform-origin"]: [
2869
- (_middlewareData$trans = middlewareData.transformOrigin) === null || _middlewareData$trans === void 0 ? void 0 : _middlewareData$trans.x,
2870
- (_middlewareData$trans2 = middlewareData.transformOrigin) === null || _middlewareData$trans2 === void 0 ? void 0 : _middlewareData$trans2.y
2871
- ].join(" ")
2872
- },
2873
- dir: props.dir
2874
- }, /* @__PURE__ */ React.createElement($cf1ac5d9fe0e8206$var$PopperContentProvider, {
2875
- scope: __scopePopper,
2876
- placedSide,
2877
- onArrowChange: setArrow,
2878
- arrowX,
2879
- arrowY,
2880
- shouldHideArrow: cannotCenterArrow
2881
- }, /* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({
2882
- "data-side": placedSide,
2883
- "data-align": placedAlign
2884
- }, contentProps, {
2885
- ref: composedRefs,
2886
- style: {
2887
- ...contentProps.style,
2888
- // if the PopperContent hasn't been placed yet (not all measurements done)
2889
- // we prevent animations so that users's animation don't kick in too early referring wrong sides
2890
- animation: !isPositioned ? "none" : void 0,
2891
- // hide the content if using the hide middleware and should be hidden
2892
- opacity: (_middlewareData$hide = middlewareData.hide) !== null && _middlewareData$hide !== void 0 && _middlewareData$hide.referenceHidden ? 0 : void 0
2893
- }
2894
- }))));
2895
- });
2896
- const $cf1ac5d9fe0e8206$var$ARROW_NAME = "PopperArrow";
2897
- const $cf1ac5d9fe0e8206$var$OPPOSITE_SIDE = {
2898
- top: "bottom",
2899
- right: "left",
2900
- bottom: "top",
2901
- left: "right"
2902
- };
2903
- const $cf1ac5d9fe0e8206$export$79d62cd4e10a3fd0 = /* @__PURE__ */ React.forwardRef(function $cf1ac5d9fe0e8206$export$79d62cd4e10a3fd02(props, forwardedRef) {
2904
- const { __scopePopper, ...arrowProps } = props;
2905
- const contentContext = $cf1ac5d9fe0e8206$var$useContentContext($cf1ac5d9fe0e8206$var$ARROW_NAME, __scopePopper);
2906
- const baseSide = $cf1ac5d9fe0e8206$var$OPPOSITE_SIDE[contentContext.placedSide];
2907
- return (
2908
- // we have to use an extra wrapper because `ResizeObserver` (used by `useSize`)
2909
- // doesn't report size as we'd expect on SVG elements.
2910
- // it reports their bounding box which is effectively the largest path inside the SVG.
2911
- /* @__PURE__ */ React.createElement("span", {
2912
- ref: contentContext.onArrowChange,
2913
- style: {
2914
- position: "absolute",
2915
- left: contentContext.arrowX,
2916
- top: contentContext.arrowY,
2917
- [baseSide]: 0,
2918
- transformOrigin: {
2919
- top: "",
2920
- right: "0 0",
2921
- bottom: "center 0",
2922
- left: "100% 0"
2923
- }[contentContext.placedSide],
2924
- transform: {
2925
- top: "translateY(100%)",
2926
- right: "translateY(50%) rotate(90deg) translateX(-50%)",
2927
- bottom: `rotate(180deg)`,
2928
- left: "translateY(50%) rotate(-90deg) translateX(50%)"
2929
- }[contentContext.placedSide],
2930
- visibility: contentContext.shouldHideArrow ? "hidden" : void 0
2931
- }
2932
- }, /* @__PURE__ */ React.createElement($7e8f5cd07187803e$export$be92b6f5f03c0fe9, _extends({}, arrowProps, {
2933
- ref: forwardedRef,
2934
- style: {
2935
- ...arrowProps.style,
2936
- // ensures the element can be measured correctly (mostly for if SVG)
2937
- display: "block"
2938
- }
2939
- })))
2940
- );
2941
- });
2942
- /* @__PURE__ */ Object.assign($cf1ac5d9fe0e8206$export$79d62cd4e10a3fd0, {
2943
- displayName: $cf1ac5d9fe0e8206$var$ARROW_NAME
2944
- });
2945
- function $cf1ac5d9fe0e8206$var$isNotNull(value) {
2946
- return value !== null;
2947
- }
2948
- const $cf1ac5d9fe0e8206$var$transformOrigin = (options) => ({
2949
- name: "transformOrigin",
2950
- options,
2951
- fn(data) {
2952
- var _middlewareData$arrow4, _middlewareData$arrow5, _middlewareData$arrow6, _middlewareData$arrow7, _middlewareData$arrow8;
2953
- const { placement, rects, middlewareData } = data;
2954
- const cannotCenterArrow = ((_middlewareData$arrow4 = middlewareData.arrow) === null || _middlewareData$arrow4 === void 0 ? void 0 : _middlewareData$arrow4.centerOffset) !== 0;
2955
- const isArrowHidden = cannotCenterArrow;
2956
- const arrowWidth = isArrowHidden ? 0 : options.arrowWidth;
2957
- const arrowHeight = isArrowHidden ? 0 : options.arrowHeight;
2958
- const [placedSide, placedAlign] = $cf1ac5d9fe0e8206$var$getSideAndAlignFromPlacement(placement);
2959
- const noArrowAlign = {
2960
- start: "0%",
2961
- center: "50%",
2962
- end: "100%"
2963
- }[placedAlign];
2964
- const arrowXCenter = ((_middlewareData$arrow5 = (_middlewareData$arrow6 = middlewareData.arrow) === null || _middlewareData$arrow6 === void 0 ? void 0 : _middlewareData$arrow6.x) !== null && _middlewareData$arrow5 !== void 0 ? _middlewareData$arrow5 : 0) + arrowWidth / 2;
2965
- const arrowYCenter = ((_middlewareData$arrow7 = (_middlewareData$arrow8 = middlewareData.arrow) === null || _middlewareData$arrow8 === void 0 ? void 0 : _middlewareData$arrow8.y) !== null && _middlewareData$arrow7 !== void 0 ? _middlewareData$arrow7 : 0) + arrowHeight / 2;
2966
- let x = "";
2967
- let y = "";
2968
- if (placedSide === "bottom") {
2969
- x = isArrowHidden ? noArrowAlign : `${arrowXCenter}px`;
2970
- y = `${-arrowHeight}px`;
2971
- } else if (placedSide === "top") {
2972
- x = isArrowHidden ? noArrowAlign : `${arrowXCenter}px`;
2973
- y = `${rects.floating.height + arrowHeight}px`;
2974
- } else if (placedSide === "right") {
2975
- x = `${-arrowHeight}px`;
2976
- y = isArrowHidden ? noArrowAlign : `${arrowYCenter}px`;
2977
- } else if (placedSide === "left") {
2978
- x = `${rects.floating.width + arrowHeight}px`;
2979
- y = isArrowHidden ? noArrowAlign : `${arrowYCenter}px`;
2980
- }
2981
- return {
2982
- data: {
2983
- x,
2984
- y
2985
- }
2986
- };
2987
- }
2988
- });
2989
- function $cf1ac5d9fe0e8206$var$getSideAndAlignFromPlacement(placement) {
2990
- const [side, align = "center"] = placement.split("-");
2991
- return [
2992
- side,
2993
- align
2994
- ];
2995
- }
2996
- const $cf1ac5d9fe0e8206$export$be92b6f5f03c0fe9 = $cf1ac5d9fe0e8206$export$badac9ada3a0bdf9;
2997
- const $cf1ac5d9fe0e8206$export$b688253958b8dfe7 = $cf1ac5d9fe0e8206$export$ecd4e1ccab6ed6d;
2998
- const $cf1ac5d9fe0e8206$export$7c6e2c02157bb7d2 = $cf1ac5d9fe0e8206$export$bc4ae5855d3c4fc;
2999
- const $f1701beae083dbae$export$602eac185826482c = /* @__PURE__ */ React.forwardRef((props, forwardedRef) => {
3000
- var _globalThis$document;
3001
- const { container = globalThis === null || globalThis === void 0 ? void 0 : (_globalThis$document = globalThis.document) === null || _globalThis$document === void 0 ? void 0 : _globalThis$document.body, ...portalProps } = props;
3002
- return container ? /* @__PURE__ */ ReactDOM__namespace.default.createPortal(/* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({}, portalProps, {
3003
- ref: forwardedRef
3004
- })), container) : null;
3005
- });
3006
- function $fe963b355347cc68$export$3e6543de14f8614f(initialState, machine) {
3007
- return React.useReducer((state, event) => {
3008
- const nextState = machine[state][event];
3009
- return nextState !== null && nextState !== void 0 ? nextState : state;
3010
- }, initialState);
3011
- }
3012
- const $921a889cee6df7e8$export$99c2b779aa4e8b8b = (props) => {
3013
- const { present, children } = props;
3014
- const presence = $921a889cee6df7e8$var$usePresence(present);
3015
- const child = typeof children === "function" ? children({
3016
- present: presence.isPresent
3017
- }) : React.Children.only(children);
3018
- const ref = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(presence.ref, child.ref);
3019
- const forceMount = typeof children === "function";
3020
- return forceMount || presence.isPresent ? /* @__PURE__ */ React.cloneElement(child, {
3021
- ref
3022
- }) : null;
3023
- };
3024
- $921a889cee6df7e8$export$99c2b779aa4e8b8b.displayName = "Presence";
3025
- function $921a889cee6df7e8$var$usePresence(present) {
3026
- const [node1, setNode] = React.useState();
3027
- const stylesRef = React.useRef({});
3028
- const prevPresentRef = React.useRef(present);
3029
- const prevAnimationNameRef = React.useRef("none");
3030
- const initialState = present ? "mounted" : "unmounted";
3031
- const [state, send] = $fe963b355347cc68$export$3e6543de14f8614f(initialState, {
3032
- mounted: {
3033
- UNMOUNT: "unmounted",
3034
- ANIMATION_OUT: "unmountSuspended"
3035
- },
3036
- unmountSuspended: {
3037
- MOUNT: "mounted",
3038
- ANIMATION_END: "unmounted"
3039
- },
3040
- unmounted: {
3041
- MOUNT: "mounted"
3042
- }
3043
- });
3044
- React.useEffect(() => {
3045
- const currentAnimationName = $921a889cee6df7e8$var$getAnimationName(stylesRef.current);
3046
- prevAnimationNameRef.current = state === "mounted" ? currentAnimationName : "none";
3047
- }, [
3048
- state
3049
- ]);
3050
- $9f79659886946c16$export$e5c5a5f917a5871c(() => {
3051
- const styles = stylesRef.current;
3052
- const wasPresent = prevPresentRef.current;
3053
- const hasPresentChanged = wasPresent !== present;
3054
- if (hasPresentChanged) {
3055
- const prevAnimationName = prevAnimationNameRef.current;
3056
- const currentAnimationName = $921a889cee6df7e8$var$getAnimationName(styles);
3057
- if (present) send("MOUNT");
3058
- else if (currentAnimationName === "none" || (styles === null || styles === void 0 ? void 0 : styles.display) === "none")
3059
- send("UNMOUNT");
3060
- else {
3061
- const isAnimating = prevAnimationName !== currentAnimationName;
3062
- if (wasPresent && isAnimating) send("ANIMATION_OUT");
3063
- else send("UNMOUNT");
3064
- }
3065
- prevPresentRef.current = present;
3066
- }
3067
- }, [
3068
- present,
3069
- send
3070
- ]);
3071
- $9f79659886946c16$export$e5c5a5f917a5871c(() => {
3072
- if (node1) {
3073
- const handleAnimationEnd = (event) => {
3074
- const currentAnimationName = $921a889cee6df7e8$var$getAnimationName(stylesRef.current);
3075
- const isCurrentAnimation = currentAnimationName.includes(event.animationName);
3076
- if (event.target === node1 && isCurrentAnimation)
3077
- ReactDOM.flushSync(
3078
- () => send("ANIMATION_END")
3079
- );
3080
- };
3081
- const handleAnimationStart = (event) => {
3082
- if (event.target === node1)
3083
- prevAnimationNameRef.current = $921a889cee6df7e8$var$getAnimationName(stylesRef.current);
3084
- };
3085
- node1.addEventListener("animationstart", handleAnimationStart);
3086
- node1.addEventListener("animationcancel", handleAnimationEnd);
3087
- node1.addEventListener("animationend", handleAnimationEnd);
3088
- return () => {
3089
- node1.removeEventListener("animationstart", handleAnimationStart);
3090
- node1.removeEventListener("animationcancel", handleAnimationEnd);
3091
- node1.removeEventListener("animationend", handleAnimationEnd);
3092
- };
3093
- } else
3094
- send("ANIMATION_END");
3095
- }, [
3096
- node1,
3097
- send
3098
- ]);
3099
- return {
3100
- isPresent: [
3101
- "mounted",
3102
- "unmountSuspended"
3103
- ].includes(state),
3104
- ref: React.useCallback((node) => {
3105
- if (node) stylesRef.current = getComputedStyle(node);
3106
- setNode(node);
3107
- }, [])
3108
- };
3109
- }
3110
- function $921a889cee6df7e8$var$getAnimationName(styles) {
3111
- return (styles === null || styles === void 0 ? void 0 : styles.animationName) || "none";
3112
- }
3113
- function $71cd76cc60e0454e$export$6f32135080cb4c3({ prop, defaultProp, onChange = () => {
3114
- } }) {
3115
- const [uncontrolledProp, setUncontrolledProp] = $71cd76cc60e0454e$var$useUncontrolledState({
3116
- defaultProp,
3117
- onChange
3118
- });
3119
- const isControlled = prop !== void 0;
3120
- const value1 = isControlled ? prop : uncontrolledProp;
3121
- const handleChange = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onChange);
3122
- const setValue = React.useCallback((nextValue) => {
3123
- if (isControlled) {
3124
- const setter = nextValue;
3125
- const value = typeof nextValue === "function" ? setter(prop) : nextValue;
3126
- if (value !== prop) handleChange(value);
3127
- } else setUncontrolledProp(nextValue);
3128
- }, [
3129
- isControlled,
3130
- prop,
3131
- setUncontrolledProp,
3132
- handleChange
3133
- ]);
3134
- return [
3135
- value1,
3136
- setValue
3137
- ];
3138
- }
3139
- function $71cd76cc60e0454e$var$useUncontrolledState({ defaultProp, onChange }) {
3140
- const uncontrolledState = React.useState(defaultProp);
3141
- const [value] = uncontrolledState;
3142
- const prevValueRef = React.useRef(value);
3143
- const handleChange = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onChange);
3144
- React.useEffect(() => {
3145
- if (prevValueRef.current !== value) {
3146
- handleChange(value);
3147
- prevValueRef.current = value;
3148
- }
3149
- }, [
3150
- value,
3151
- prevValueRef,
3152
- handleChange
3153
- ]);
3154
- return uncontrolledState;
3155
- }
3156
- const $ea1ef594cf570d83$export$439d29a4e110a164 = /* @__PURE__ */ React.forwardRef((props, forwardedRef) => {
3157
- return /* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.span, _extends({}, props, {
3158
- ref: forwardedRef,
3159
- style: {
3160
- // See: https://github.com/twbs/bootstrap/blob/master/scss/mixins/_screen-reader.scss
3161
- position: "absolute",
3162
- border: 0,
3163
- width: 1,
3164
- height: 1,
3165
- padding: 0,
3166
- margin: -1,
3167
- overflow: "hidden",
3168
- clip: "rect(0, 0, 0, 0)",
3169
- whiteSpace: "nowrap",
3170
- wordWrap: "normal",
3171
- ...props.style
3172
- }
3173
- }));
3174
- });
3175
- const $ea1ef594cf570d83$export$be92b6f5f03c0fe9 = $ea1ef594cf570d83$export$439d29a4e110a164;
3176
- const [$a093c7e1ec25a057$var$createTooltipContext] = $c512c27ab02ef895$export$50c7b4e9d9f19c1("Tooltip", [
3177
- $cf1ac5d9fe0e8206$export$722aac194ae923
3178
- ]);
3179
- const $a093c7e1ec25a057$var$usePopperScope = $cf1ac5d9fe0e8206$export$722aac194ae923();
3180
- const $a093c7e1ec25a057$var$PROVIDER_NAME = "TooltipProvider";
3181
- const $a093c7e1ec25a057$var$DEFAULT_DELAY_DURATION = 700;
3182
- const $a093c7e1ec25a057$var$TOOLTIP_OPEN = "tooltip.open";
3183
- const [$a093c7e1ec25a057$var$TooltipProviderContextProvider, $a093c7e1ec25a057$var$useTooltipProviderContext] = $a093c7e1ec25a057$var$createTooltipContext($a093c7e1ec25a057$var$PROVIDER_NAME);
3184
- const $a093c7e1ec25a057$export$f78649fb9ca566b8 = (props) => {
3185
- const { __scopeTooltip, delayDuration = $a093c7e1ec25a057$var$DEFAULT_DELAY_DURATION, skipDelayDuration = 300, disableHoverableContent = false, children } = props;
3186
- const [isOpenDelayed, setIsOpenDelayed] = React.useState(true);
3187
- const isPointerInTransitRef = React.useRef(false);
3188
- const skipDelayTimerRef = React.useRef(0);
3189
- React.useEffect(() => {
3190
- const skipDelayTimer = skipDelayTimerRef.current;
3191
- return () => window.clearTimeout(skipDelayTimer);
3192
- }, []);
3193
- return /* @__PURE__ */ React.createElement($a093c7e1ec25a057$var$TooltipProviderContextProvider, {
3194
- scope: __scopeTooltip,
3195
- isOpenDelayed,
3196
- delayDuration,
3197
- onOpen: React.useCallback(() => {
3198
- window.clearTimeout(skipDelayTimerRef.current);
3199
- setIsOpenDelayed(false);
3200
- }, []),
3201
- onClose: React.useCallback(() => {
3202
- window.clearTimeout(skipDelayTimerRef.current);
3203
- skipDelayTimerRef.current = window.setTimeout(
3204
- () => setIsOpenDelayed(true),
3205
- skipDelayDuration
3206
- );
3207
- }, [
3208
- skipDelayDuration
3209
- ]),
3210
- isPointerInTransitRef,
3211
- onPointerInTransitChange: React.useCallback((inTransit) => {
3212
- isPointerInTransitRef.current = inTransit;
3213
- }, []),
3214
- disableHoverableContent
3215
- }, children);
3216
- };
3217
- const $a093c7e1ec25a057$var$TOOLTIP_NAME = "Tooltip";
3218
- const [$a093c7e1ec25a057$var$TooltipContextProvider, $a093c7e1ec25a057$var$useTooltipContext] = $a093c7e1ec25a057$var$createTooltipContext($a093c7e1ec25a057$var$TOOLTIP_NAME);
3219
- const $a093c7e1ec25a057$export$28c660c63b792dea = (props) => {
3220
- const { __scopeTooltip, children, open: openProp, defaultOpen = false, onOpenChange, disableHoverableContent: disableHoverableContentProp, delayDuration: delayDurationProp } = props;
3221
- const providerContext = $a093c7e1ec25a057$var$useTooltipProviderContext($a093c7e1ec25a057$var$TOOLTIP_NAME, props.__scopeTooltip);
3222
- const popperScope = $a093c7e1ec25a057$var$usePopperScope(__scopeTooltip);
3223
- const [trigger, setTrigger] = React.useState(null);
3224
- const contentId = $1746a345f3d73bb7$export$f680877a34711e37();
3225
- const openTimerRef = React.useRef(0);
3226
- const disableHoverableContent = disableHoverableContentProp !== null && disableHoverableContentProp !== void 0 ? disableHoverableContentProp : providerContext.disableHoverableContent;
3227
- const delayDuration = delayDurationProp !== null && delayDurationProp !== void 0 ? delayDurationProp : providerContext.delayDuration;
3228
- const wasOpenDelayedRef = React.useRef(false);
3229
- const [open1 = false, setOpen] = $71cd76cc60e0454e$export$6f32135080cb4c3({
3230
- prop: openProp,
3231
- defaultProp: defaultOpen,
3232
- onChange: (open) => {
3233
- if (open) {
3234
- providerContext.onOpen();
3235
- document.dispatchEvent(new CustomEvent($a093c7e1ec25a057$var$TOOLTIP_OPEN));
3236
- } else providerContext.onClose();
3237
- onOpenChange === null || onOpenChange === void 0 || onOpenChange(open);
3238
- }
3239
- });
3240
- const stateAttribute = React.useMemo(() => {
3241
- return open1 ? wasOpenDelayedRef.current ? "delayed-open" : "instant-open" : "closed";
3242
- }, [
3243
- open1
3244
- ]);
3245
- const handleOpen = React.useCallback(() => {
3246
- window.clearTimeout(openTimerRef.current);
3247
- wasOpenDelayedRef.current = false;
3248
- setOpen(true);
3249
- }, [
3250
- setOpen
3251
- ]);
3252
- const handleClose = React.useCallback(() => {
3253
- window.clearTimeout(openTimerRef.current);
3254
- setOpen(false);
3255
- }, [
3256
- setOpen
3257
- ]);
3258
- const handleDelayedOpen = React.useCallback(() => {
3259
- window.clearTimeout(openTimerRef.current);
3260
- openTimerRef.current = window.setTimeout(() => {
3261
- wasOpenDelayedRef.current = true;
3262
- setOpen(true);
3263
- }, delayDuration);
3264
- }, [
3265
- delayDuration,
3266
- setOpen
3267
- ]);
3268
- React.useEffect(() => {
3269
- return () => window.clearTimeout(openTimerRef.current);
3270
- }, []);
3271
- return /* @__PURE__ */ React.createElement($cf1ac5d9fe0e8206$export$be92b6f5f03c0fe9, popperScope, /* @__PURE__ */ React.createElement($a093c7e1ec25a057$var$TooltipContextProvider, {
3272
- scope: __scopeTooltip,
3273
- contentId,
3274
- open: open1,
3275
- stateAttribute,
3276
- trigger,
3277
- onTriggerChange: setTrigger,
3278
- onTriggerEnter: React.useCallback(() => {
3279
- if (providerContext.isOpenDelayed) handleDelayedOpen();
3280
- else handleOpen();
3281
- }, [
3282
- providerContext.isOpenDelayed,
3283
- handleDelayedOpen,
3284
- handleOpen
3285
- ]),
3286
- onTriggerLeave: React.useCallback(() => {
3287
- if (disableHoverableContent) handleClose();
3288
- else
3289
- window.clearTimeout(openTimerRef.current);
3290
- }, [
3291
- handleClose,
3292
- disableHoverableContent
3293
- ]),
3294
- onOpen: handleOpen,
3295
- onClose: handleClose,
3296
- disableHoverableContent
3297
- }, children));
3298
- };
3299
- const $a093c7e1ec25a057$var$TRIGGER_NAME = "TooltipTrigger";
3300
- const $a093c7e1ec25a057$export$8c610744efcf8a1d = /* @__PURE__ */ React.forwardRef((props, forwardedRef) => {
3301
- const { __scopeTooltip, ...triggerProps } = props;
3302
- const context = $a093c7e1ec25a057$var$useTooltipContext($a093c7e1ec25a057$var$TRIGGER_NAME, __scopeTooltip);
3303
- const providerContext = $a093c7e1ec25a057$var$useTooltipProviderContext($a093c7e1ec25a057$var$TRIGGER_NAME, __scopeTooltip);
3304
- const popperScope = $a093c7e1ec25a057$var$usePopperScope(__scopeTooltip);
3305
- const ref = React.useRef(null);
3306
- const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, ref, context.onTriggerChange);
3307
- const isPointerDownRef = React.useRef(false);
3308
- const hasPointerMoveOpenedRef = React.useRef(false);
3309
- const handlePointerUp = React.useCallback(
3310
- () => isPointerDownRef.current = false,
3311
- []
3312
- );
3313
- React.useEffect(() => {
3314
- return () => document.removeEventListener("pointerup", handlePointerUp);
3315
- }, [
3316
- handlePointerUp
3317
- ]);
3318
- return /* @__PURE__ */ React.createElement($cf1ac5d9fe0e8206$export$b688253958b8dfe7, _extends({
3319
- asChild: true
3320
- }, popperScope), /* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.button, _extends({
3321
- // We purposefully avoid adding `type=button` here because tooltip triggers are also
3322
- // commonly anchors and the anchor `type` attribute signifies MIME type.
3323
- "aria-describedby": context.open ? context.contentId : void 0,
3324
- "data-state": context.stateAttribute
3325
- }, triggerProps, {
3326
- ref: composedRefs,
3327
- onPointerMove: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onPointerMove, (event) => {
3328
- if (event.pointerType === "touch") return;
3329
- if (!hasPointerMoveOpenedRef.current && !providerContext.isPointerInTransitRef.current) {
3330
- context.onTriggerEnter();
3331
- hasPointerMoveOpenedRef.current = true;
3332
- }
3333
- }),
3334
- onPointerLeave: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onPointerLeave, () => {
3335
- context.onTriggerLeave();
3336
- hasPointerMoveOpenedRef.current = false;
3337
- }),
3338
- onPointerDown: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onPointerDown, () => {
3339
- isPointerDownRef.current = true;
3340
- document.addEventListener("pointerup", handlePointerUp, {
3341
- once: true
3342
- });
3343
- }),
3344
- onFocus: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onFocus, () => {
3345
- if (!isPointerDownRef.current) context.onOpen();
3346
- }),
3347
- onBlur: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onBlur, context.onClose),
3348
- onClick: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onClick, context.onClose)
3349
- })));
3350
- });
3351
- const $a093c7e1ec25a057$var$PORTAL_NAME = "TooltipPortal";
3352
- const [$a093c7e1ec25a057$var$PortalProvider, $a093c7e1ec25a057$var$usePortalContext] = $a093c7e1ec25a057$var$createTooltipContext($a093c7e1ec25a057$var$PORTAL_NAME, {
3353
- forceMount: void 0
3354
- });
3355
- const $a093c7e1ec25a057$export$7b36b8f925ab7497 = (props) => {
3356
- const { __scopeTooltip, forceMount, children, container } = props;
3357
- const context = $a093c7e1ec25a057$var$useTooltipContext($a093c7e1ec25a057$var$PORTAL_NAME, __scopeTooltip);
3358
- return /* @__PURE__ */ React.createElement($a093c7e1ec25a057$var$PortalProvider, {
3359
- scope: __scopeTooltip,
3360
- forceMount
3361
- }, /* @__PURE__ */ React.createElement($921a889cee6df7e8$export$99c2b779aa4e8b8b, {
3362
- present: forceMount || context.open
3363
- }, /* @__PURE__ */ React.createElement($f1701beae083dbae$export$602eac185826482c, {
3364
- asChild: true,
3365
- container
3366
- }, children)));
3367
- };
3368
- const $a093c7e1ec25a057$var$CONTENT_NAME = "TooltipContent";
3369
- const $a093c7e1ec25a057$export$e9003e2be37ec060 = /* @__PURE__ */ React.forwardRef((props, forwardedRef) => {
3370
- const portalContext = $a093c7e1ec25a057$var$usePortalContext($a093c7e1ec25a057$var$CONTENT_NAME, props.__scopeTooltip);
3371
- const { forceMount = portalContext.forceMount, side = "top", ...contentProps } = props;
3372
- const context = $a093c7e1ec25a057$var$useTooltipContext($a093c7e1ec25a057$var$CONTENT_NAME, props.__scopeTooltip);
3373
- return /* @__PURE__ */ React.createElement($921a889cee6df7e8$export$99c2b779aa4e8b8b, {
3374
- present: forceMount || context.open
3375
- }, context.disableHoverableContent ? /* @__PURE__ */ React.createElement($a093c7e1ec25a057$var$TooltipContentImpl, _extends({
3376
- side
3377
- }, contentProps, {
3378
- ref: forwardedRef
3379
- })) : /* @__PURE__ */ React.createElement($a093c7e1ec25a057$var$TooltipContentHoverable, _extends({
3380
- side
3381
- }, contentProps, {
3382
- ref: forwardedRef
3383
- })));
3384
- });
3385
- const $a093c7e1ec25a057$var$TooltipContentHoverable = /* @__PURE__ */ React.forwardRef((props, forwardedRef) => {
3386
- const context = $a093c7e1ec25a057$var$useTooltipContext($a093c7e1ec25a057$var$CONTENT_NAME, props.__scopeTooltip);
3387
- const providerContext = $a093c7e1ec25a057$var$useTooltipProviderContext($a093c7e1ec25a057$var$CONTENT_NAME, props.__scopeTooltip);
3388
- const ref = React.useRef(null);
3389
- const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, ref);
3390
- const [pointerGraceArea, setPointerGraceArea] = React.useState(null);
3391
- const { trigger, onClose } = context;
3392
- const content = ref.current;
3393
- const { onPointerInTransitChange } = providerContext;
3394
- const handleRemoveGraceArea = React.useCallback(() => {
3395
- setPointerGraceArea(null);
3396
- onPointerInTransitChange(false);
3397
- }, [
3398
- onPointerInTransitChange
3399
- ]);
3400
- const handleCreateGraceArea = React.useCallback((event, hoverTarget) => {
3401
- const currentTarget = event.currentTarget;
3402
- const exitPoint = {
3403
- x: event.clientX,
3404
- y: event.clientY
3405
- };
3406
- const exitSide = $a093c7e1ec25a057$var$getExitSideFromRect(exitPoint, currentTarget.getBoundingClientRect());
3407
- const paddedExitPoints = $a093c7e1ec25a057$var$getPaddedExitPoints(exitPoint, exitSide);
3408
- const hoverTargetPoints = $a093c7e1ec25a057$var$getPointsFromRect(hoverTarget.getBoundingClientRect());
3409
- const graceArea = $a093c7e1ec25a057$var$getHull([
3410
- ...paddedExitPoints,
3411
- ...hoverTargetPoints
3412
- ]);
3413
- setPointerGraceArea(graceArea);
3414
- onPointerInTransitChange(true);
3415
- }, [
3416
- onPointerInTransitChange
3417
- ]);
3418
- React.useEffect(() => {
3419
- return () => handleRemoveGraceArea();
3420
- }, [
3421
- handleRemoveGraceArea
3422
- ]);
3423
- React.useEffect(() => {
3424
- if (trigger && content) {
3425
- const handleTriggerLeave = (event) => handleCreateGraceArea(event, content);
3426
- const handleContentLeave = (event) => handleCreateGraceArea(event, trigger);
3427
- trigger.addEventListener("pointerleave", handleTriggerLeave);
3428
- content.addEventListener("pointerleave", handleContentLeave);
3429
- return () => {
3430
- trigger.removeEventListener("pointerleave", handleTriggerLeave);
3431
- content.removeEventListener("pointerleave", handleContentLeave);
3432
- };
3433
- }
3434
- }, [
3435
- trigger,
3436
- content,
3437
- handleCreateGraceArea,
3438
- handleRemoveGraceArea
3439
- ]);
3440
- React.useEffect(() => {
3441
- if (pointerGraceArea) {
3442
- const handleTrackPointerGrace = (event) => {
3443
- const target = event.target;
3444
- const pointerPosition = {
3445
- x: event.clientX,
3446
- y: event.clientY
3447
- };
3448
- const hasEnteredTarget = (trigger === null || trigger === void 0 ? void 0 : trigger.contains(target)) || (content === null || content === void 0 ? void 0 : content.contains(target));
3449
- const isPointerOutsideGraceArea = !$a093c7e1ec25a057$var$isPointInPolygon(pointerPosition, pointerGraceArea);
3450
- if (hasEnteredTarget) handleRemoveGraceArea();
3451
- else if (isPointerOutsideGraceArea) {
3452
- handleRemoveGraceArea();
3453
- onClose();
3454
- }
3455
- };
3456
- document.addEventListener("pointermove", handleTrackPointerGrace);
3457
- return () => document.removeEventListener("pointermove", handleTrackPointerGrace);
3458
- }
3459
- }, [
3460
- trigger,
3461
- content,
3462
- pointerGraceArea,
3463
- onClose,
3464
- handleRemoveGraceArea
3465
- ]);
3466
- return /* @__PURE__ */ React.createElement($a093c7e1ec25a057$var$TooltipContentImpl, _extends({}, props, {
3467
- ref: composedRefs
3468
- }));
3469
- });
3470
- const [$a093c7e1ec25a057$var$VisuallyHiddenContentContextProvider, $a093c7e1ec25a057$var$useVisuallyHiddenContentContext] = $a093c7e1ec25a057$var$createTooltipContext($a093c7e1ec25a057$var$TOOLTIP_NAME, {
3471
- isInside: false
3472
- });
3473
- const $a093c7e1ec25a057$var$TooltipContentImpl = /* @__PURE__ */ React.forwardRef((props, forwardedRef) => {
3474
- const { __scopeTooltip, children, "aria-label": ariaLabel, onEscapeKeyDown, onPointerDownOutside, ...contentProps } = props;
3475
- const context = $a093c7e1ec25a057$var$useTooltipContext($a093c7e1ec25a057$var$CONTENT_NAME, __scopeTooltip);
3476
- const popperScope = $a093c7e1ec25a057$var$usePopperScope(__scopeTooltip);
3477
- const { onClose } = context;
3478
- React.useEffect(() => {
3479
- document.addEventListener($a093c7e1ec25a057$var$TOOLTIP_OPEN, onClose);
3480
- return () => document.removeEventListener($a093c7e1ec25a057$var$TOOLTIP_OPEN, onClose);
3481
- }, [
3482
- onClose
3483
- ]);
3484
- React.useEffect(() => {
3485
- if (context.trigger) {
3486
- const handleScroll = (event) => {
3487
- const target = event.target;
3488
- if (target !== null && target !== void 0 && target.contains(context.trigger)) onClose();
3489
- };
3490
- window.addEventListener("scroll", handleScroll, {
3491
- capture: true
3492
- });
3493
- return () => window.removeEventListener("scroll", handleScroll, {
3494
- capture: true
3495
- });
3496
- }
3497
- }, [
3498
- context.trigger,
3499
- onClose
3500
- ]);
3501
- return /* @__PURE__ */ React.createElement($5cb92bef7577960e$export$177fb62ff3ec1f22, {
3502
- asChild: true,
3503
- disableOutsidePointerEvents: false,
3504
- onEscapeKeyDown,
3505
- onPointerDownOutside,
3506
- onFocusOutside: (event) => event.preventDefault(),
3507
- onDismiss: onClose
3508
- }, /* @__PURE__ */ React.createElement($cf1ac5d9fe0e8206$export$7c6e2c02157bb7d2, _extends({
3509
- "data-state": context.stateAttribute
3510
- }, popperScope, contentProps, {
3511
- ref: forwardedRef,
3512
- style: {
3513
- ...contentProps.style,
3514
- "--radix-tooltip-content-transform-origin": "var(--radix-popper-transform-origin)",
3515
- "--radix-tooltip-content-available-width": "var(--radix-popper-available-width)",
3516
- "--radix-tooltip-content-available-height": "var(--radix-popper-available-height)",
3517
- "--radix-tooltip-trigger-width": "var(--radix-popper-anchor-width)",
3518
- "--radix-tooltip-trigger-height": "var(--radix-popper-anchor-height)"
3519
- }
3520
- }), /* @__PURE__ */ React.createElement($5e63c961fc1ce211$export$d9f1ccf0bdb05d45, null, children), /* @__PURE__ */ React.createElement($a093c7e1ec25a057$var$VisuallyHiddenContentContextProvider, {
3521
- scope: __scopeTooltip,
3522
- isInside: true
3523
- }, /* @__PURE__ */ React.createElement($ea1ef594cf570d83$export$be92b6f5f03c0fe9, {
3524
- id: context.contentId,
3525
- role: "tooltip"
3526
- }, ariaLabel || children))));
3527
- });
3528
- function $a093c7e1ec25a057$var$getExitSideFromRect(point, rect) {
3529
- const top = Math.abs(rect.top - point.y);
3530
- const bottom = Math.abs(rect.bottom - point.y);
3531
- const right = Math.abs(rect.right - point.x);
3532
- const left = Math.abs(rect.left - point.x);
3533
- switch (Math.min(top, bottom, right, left)) {
3534
- case left:
3535
- return "left";
3536
- case right:
3537
- return "right";
3538
- case top:
3539
- return "top";
3540
- case bottom:
3541
- return "bottom";
3542
- default:
3543
- throw new Error("unreachable");
3544
- }
3545
- }
3546
- function $a093c7e1ec25a057$var$getPaddedExitPoints(exitPoint, exitSide, padding = 5) {
3547
- const paddedExitPoints = [];
3548
- switch (exitSide) {
3549
- case "top":
3550
- paddedExitPoints.push({
3551
- x: exitPoint.x - padding,
3552
- y: exitPoint.y + padding
3553
- }, {
3554
- x: exitPoint.x + padding,
3555
- y: exitPoint.y + padding
3556
- });
3557
- break;
3558
- case "bottom":
3559
- paddedExitPoints.push({
3560
- x: exitPoint.x - padding,
3561
- y: exitPoint.y - padding
3562
- }, {
3563
- x: exitPoint.x + padding,
3564
- y: exitPoint.y - padding
3565
- });
3566
- break;
3567
- case "left":
3568
- paddedExitPoints.push({
3569
- x: exitPoint.x + padding,
3570
- y: exitPoint.y - padding
3571
- }, {
3572
- x: exitPoint.x + padding,
3573
- y: exitPoint.y + padding
3574
- });
3575
- break;
3576
- case "right":
3577
- paddedExitPoints.push({
3578
- x: exitPoint.x - padding,
3579
- y: exitPoint.y - padding
3580
- }, {
3581
- x: exitPoint.x - padding,
3582
- y: exitPoint.y + padding
3583
- });
3584
- break;
3585
- }
3586
- return paddedExitPoints;
3587
- }
3588
- function $a093c7e1ec25a057$var$getPointsFromRect(rect) {
3589
- const { top, right, bottom, left } = rect;
3590
- return [
3591
- {
3592
- x: left,
3593
- y: top
3594
- },
3595
- {
3596
- x: right,
3597
- y: top
3598
- },
3599
- {
3600
- x: right,
3601
- y: bottom
3602
- },
3603
- {
3604
- x: left,
3605
- y: bottom
3606
- }
3607
- ];
3608
- }
3609
- function $a093c7e1ec25a057$var$isPointInPolygon(point, polygon) {
3610
- const { x, y } = point;
3611
- let inside = false;
3612
- for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
3613
- const xi = polygon[i].x;
3614
- const yi = polygon[i].y;
3615
- const xj = polygon[j].x;
3616
- const yj = polygon[j].y;
3617
- const intersect = yi > y !== yj > y && x < (xj - xi) * (y - yi) / (yj - yi) + xi;
3618
- if (intersect) inside = !inside;
3619
- }
3620
- return inside;
3621
- }
3622
- function $a093c7e1ec25a057$var$getHull(points) {
3623
- const newPoints = points.slice();
3624
- newPoints.sort((a, b) => {
3625
- if (a.x < b.x) return -1;
3626
- else if (a.x > b.x) return 1;
3627
- else if (a.y < b.y) return -1;
3628
- else if (a.y > b.y) return 1;
3629
- else return 0;
3630
- });
3631
- return $a093c7e1ec25a057$var$getHullPresorted(newPoints);
3632
- }
3633
- function $a093c7e1ec25a057$var$getHullPresorted(points) {
3634
- if (points.length <= 1) return points.slice();
3635
- const upperHull = [];
3636
- for (let i = 0; i < points.length; i++) {
3637
- const p = points[i];
3638
- while (upperHull.length >= 2) {
3639
- const q = upperHull[upperHull.length - 1];
3640
- const r = upperHull[upperHull.length - 2];
3641
- if ((q.x - r.x) * (p.y - r.y) >= (q.y - r.y) * (p.x - r.x)) upperHull.pop();
3642
- else break;
3643
- }
3644
- upperHull.push(p);
3645
- }
3646
- upperHull.pop();
3647
- const lowerHull = [];
3648
- for (let i1 = points.length - 1; i1 >= 0; i1--) {
3649
- const p = points[i1];
3650
- while (lowerHull.length >= 2) {
3651
- const q = lowerHull[lowerHull.length - 1];
3652
- const r = lowerHull[lowerHull.length - 2];
3653
- if ((q.x - r.x) * (p.y - r.y) >= (q.y - r.y) * (p.x - r.x)) lowerHull.pop();
3654
- else break;
3655
- }
3656
- lowerHull.push(p);
3657
- }
3658
- lowerHull.pop();
3659
- if (upperHull.length === 1 && lowerHull.length === 1 && upperHull[0].x === lowerHull[0].x && upperHull[0].y === lowerHull[0].y) return upperHull;
3660
- else return upperHull.concat(lowerHull);
3661
- }
3662
- const $a093c7e1ec25a057$export$2881499e37b75b9a = $a093c7e1ec25a057$export$f78649fb9ca566b8;
3663
- const $a093c7e1ec25a057$export$be92b6f5f03c0fe9 = $a093c7e1ec25a057$export$28c660c63b792dea;
3664
- const $a093c7e1ec25a057$export$41fb9f06171c75f4 = $a093c7e1ec25a057$export$8c610744efcf8a1d;
3665
- const $a093c7e1ec25a057$export$602eac185826482c = $a093c7e1ec25a057$export$7b36b8f925ab7497;
3666
- const $a093c7e1ec25a057$export$7c6e2c02157bb7d2 = $a093c7e1ec25a057$export$e9003e2be37ec060;
3667
- function Tooltip({ description }) {
3668
- return /* @__PURE__ */ jsxRuntime.jsx($a093c7e1ec25a057$export$2881499e37b75b9a, { children: /* @__PURE__ */ jsxRuntime.jsxs($a093c7e1ec25a057$export$be92b6f5f03c0fe9, { children: [
3669
- /* @__PURE__ */ jsxRuntime.jsx($a093c7e1ec25a057$export$41fb9f06171c75f4, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(icons.Information, { "aria-hidden": "true" }) }),
3670
- /* @__PURE__ */ jsxRuntime.jsx($a093c7e1ec25a057$export$602eac185826482c, { children: /* @__PURE__ */ jsxRuntime.jsx($a093c7e1ec25a057$export$7c6e2c02157bb7d2, { sideOffset: 5, style: { zIndex: 9999 }, children: /* @__PURE__ */ jsxRuntime.jsx(
3671
- designSystem.Box,
3672
- {
3673
- padding: 2,
3674
- margin: 2,
3675
- background: "neutral1000",
3676
- hasRadius: true,
3677
- shadow: "filterShadow",
3678
- maxWidth: "300px",
3679
- children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral0", children: description })
3680
- }
3681
- ) }) })
3682
- ] }) });
3683
- }
3684
- function PathInput({ path, dispatchPath, isOverride, config, hasUserInteracted }) {
3685
- const { formatMessage } = reactIntl.useIntl();
3686
- const displayedPath = isOverride && path.overridePath !== void 0 ? path.overridePath : path.value ?? "";
3687
- const inputBorder = path.replacement === null ? "" : path.replacement ? "1px solid #ee5e52" : "1px solid #5cb176";
3688
- return /* @__PURE__ */ jsxRuntime.jsxs(
3689
- designSystem.Field.Root,
3690
- {
3691
- hint: config.default ? formatMessage({
3692
- id: getTranslation("components.CMEditViewAside.path.input.start"),
3693
- defaultMessage: "Edit the"
3694
- }) + ' "' + config.default + '" ' + formatMessage({
3695
- id: getTranslation("components.CMEditViewAside.path.input.end"),
3696
- defaultMessage: "field to generate a path"
3697
- }) : formatMessage({
3698
- id: getTranslation("components.CMEditViewAside.path.input.noSourceField"),
3699
- defaultMessage: "Use the override option to set a custom path"
3700
- }),
3701
- children: [
3702
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Label, { children: [
3703
- formatMessage({
3704
- id: getTranslation("components.CMEditViewAside.path.input.label"),
3705
- defaultMessage: "Path"
3706
- }),
3707
- /* @__PURE__ */ jsxRuntime.jsx(
3708
- Tooltip,
3709
- {
3710
- description: formatMessage({
3711
- id: getTranslation("components.CMEditViewAside.path.input.tooltip"),
3712
- defaultMessage: "The following characters are valid: A-Z, a-z, 0-9, /, -, _, $, ., +, !, *, ', (, )"
3713
- })
3714
- }
3715
- )
3716
- ] }),
3717
- /* @__PURE__ */ jsxRuntime.jsx(
3718
- designSystem.Field.Input,
3719
- {
3720
- id: "path-input",
3721
- value: displayedPath,
3722
- onChange: (e) => {
3723
- hasUserInteracted.current = true;
3724
- dispatchPath({ type: "SET_OVERRIDEPATH", payload: e.target.value });
3725
- },
3726
- disabled: !isOverride,
3727
- onBlur: (e) => {
3728
- dispatchPath({
3729
- type: "SET_OVERRIDEPATH",
3730
- payload: transformToUrl(e.target.value, false)
3731
- });
3732
- dispatchPath({
3733
- type: "SET_URL_CHECK_FLAG",
3734
- payload: true
3735
- });
3736
- },
3737
- style: { outline: inputBorder }
3738
- }
3739
- ),
3740
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, {})
3741
- ]
3742
- }
3743
- );
3744
- }
3745
- function RouteStructure({
3746
- routes,
3747
- selectedParent,
3748
- setSelectedParent,
3749
- canonicalPath,
3750
- prohibitedRouteIds
3751
- }) {
3752
- const { formatMessage } = reactIntl.useIntl();
3753
- const filteredRoutes = React.useMemo(() => {
3754
- return [...routes].sort((a, b) => a.title.localeCompare(b.title)).filter(
3755
- (route) => !prohibitedRouteIds?.includes(route.documentId) || route.documentId === selectedParent?.documentId
3756
- );
3757
- }, [routes, prohibitedRouteIds, selectedParent]);
3758
- const handleSelectParent = (value) => {
3759
- const parentRoute = routes.find((route) => route.documentId === value) || null;
3760
- setSelectedParent(parentRoute);
3761
- };
3762
- return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { paddingBottom: 2, children: [
3763
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { children: [
3764
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: formatMessage({
3765
- id: getTranslation("components.CMEditViewAside.path.input.parentSelect.label"),
3766
- defaultMessage: "Place under"
3767
- }) }),
3768
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.SingleSelect, { value: selectedParent?.documentId || "", onValueChange: handleSelectParent, children: [
3769
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "", children: formatMessage({
3770
- id: getTranslation("components.CMEditViewAside.path.input.parentSelect.rootPath"),
3771
- defaultMessage: "None (root path)"
3772
- }) }),
3773
- filteredRoutes.map((route) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: route.documentId, children: route.title }, route.documentId))
3774
- ] })
3775
- ] }),
3776
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { marginTop: 4, children: [
3777
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Label, { children: [
3778
- formatMessage({
3779
- id: getTranslation("components.CMEditViewAside.canonicalPath.input.label"),
3780
- defaultMessage: "Canonical Path"
3781
- }),
3782
- /* @__PURE__ */ jsxRuntime.jsx(
3783
- Tooltip,
3784
- {
3785
- description: formatMessage({
3786
- id: getTranslation("components.CMEditViewAside.canonicalPath.input.tooltip"),
3787
- defaultMessage: "The path determined by your content's natural hierarchy, independent of where it appears in navigation menus."
3788
- })
3789
- }
3790
- )
3791
- ] }),
3792
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Input, { id: "canonicalPath-input", value: canonicalPath, disabled: true }),
3793
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, {})
3794
- ] })
3795
- ] });
3796
- }
3797
- function buildPath(type, slug, parent) {
3798
- const parentSlug = type === "canonical" ? parent?.canonicalPath : parent?.path;
3799
- const parentPath = parentSlug ? `${parentSlug}/` : "";
3800
- return `${parentPath}${transformToUrl(slug)}`;
3801
- }
3802
- function reducer(state, action) {
3803
- switch (action.type) {
3804
- case "DEFAULT":
3805
- return {
3806
- ...state,
3807
- value: action.payload,
3808
- prevValue: state.value,
3809
- needsUrlCheck: true
3810
- };
3811
- case "NO_URL_CHECK":
3812
- return {
3813
- ...state,
3814
- value: action.payload,
3815
- prevValue: state.value,
3816
- needsUrlCheck: false
3817
- };
3818
- case "NO_TRANSFORM_AND_CHECK":
3819
- return {
3820
- ...state,
3821
- value: action.payload,
3822
- prevValue: state.value,
3823
- needsUrlCheck: false
3824
- };
3825
- case "SET_URL_CHECK_FLAG":
3826
- return { ...state, needsUrlCheck: action.payload || false };
3827
- case "SET_REPLACEMENT":
3828
- return { ...state, replacement: action.payload };
3829
- case "SET_UIDPATH":
3830
- return { ...state, uidPath: action.payload };
3831
- case "SET_SLUG":
3832
- return { ...state, slug: action.payload };
3833
- case "SET_CANONICALPATH":
3834
- return { ...state, canonicalPath: action.payload };
3835
- case "SET_OVERRIDEPATH":
3836
- return { ...state, overridePath: action.payload };
3837
- default:
3838
- throw new Error();
3839
- }
3840
- }
3841
- const Panel = ({ config }) => {
3842
- const { form, model } = admin.unstable_useContentManagerContext();
3843
- const { initialValues, values, onChange } = form;
3844
- const { getRelatedRoute, getAllRoutes, getProhibitedRouteIds } = useApi();
3845
- const { formatMessage } = reactIntl.useIntl();
3846
- const { get } = admin.useFetchClient();
3847
- const {
3848
- allowedActions: { canUpdate, canCreate }
3849
- } = admin.useRBAC([
3850
- {
3851
- action: "plugin::content-manager.explorer.update",
3852
- subject: model,
3853
- properties: {},
3854
- conditions: []
3855
- },
3856
- {
3857
- action: "plugin::content-manager.explorer.create",
3858
- subject: model,
3859
- properties: {},
3860
- conditions: []
3861
- }
3862
- ]);
3863
- const [route, setRoute] = React.useState(null);
3864
- const [routes, setRoutes] = React.useState([]);
3865
- const [prohibitedRouteIds, setProhibitedRouteIds] = React.useState([]);
3866
- const [selectedParent, setSelectedParent] = React.useState(null);
3867
- const [isOverride, setIsOverride] = React.useState(false);
3868
- const [validationState, setValidationState] = React.useState("initial");
3869
- const [initialLoadComplete, setInitialLoadComplete] = React.useState(false);
3870
- const [path, dispatchPath] = React.useReducer(reducer, {
3871
- needsUrlCheck: false,
3872
- value: "",
3873
- prevValue: "",
3874
- replacement: null,
3875
- uidPath: "",
3876
- canonicalPath: "",
3877
- slug: "",
3878
- overridePath: ""
3879
- });
3880
- const hasUserChangedField = React.useRef(false);
3881
- const hasUserInteracted = React.useRef(false);
3882
- const initialPath = React.useRef("");
3883
- const prevSourceValueRef = React.useRef(null);
3884
- const sourceFieldValue = values[config?.default] || "";
3885
- const initialSourceFieldValue = initialValues[config?.default] || "";
3886
- const latestCheckPathRef = React.useRef(checkPath);
3887
- latestCheckPathRef.current = checkPath;
3888
- const debouncedCheckPath = React.useRef(
3889
- debounce((p, id) => latestCheckPathRef.current(p, id), 250)
3890
- ).current;
3891
- const latestCheckCanonicalRef = React.useRef(checkCanonicalPath);
3892
- latestCheckCanonicalRef.current = checkCanonicalPath;
3893
- const debouncedCheckCanonicalPath = React.useRef(
3894
- debounce((p, id) => latestCheckCanonicalRef.current(p, id), 250)
3895
- ).current;
3896
- React.useEffect(() => {
3897
- async function fetchAllRoutes() {
3898
- const allRoutes = await getAllRoutes();
3899
- setRoutes(allRoutes);
3900
- }
3901
- fetchAllRoutes();
3902
- }, []);
3903
- React.useEffect(() => {
3904
- const slug = transformToUrl(sourceFieldValue);
3905
- const overridePath = transformToUrl(path.overridePath || "", false);
3906
- const data = {
3907
- path: isOverride ? overridePath : path.value,
3908
- isOverride,
3909
- parentDocumentId: selectedParent?.documentId || null,
3910
- slug: isOverride ? overridePath : slug
3911
- };
3912
- if (hasUserChangedField.current || hasUserInteracted.current) {
3913
- onChange("webatlas", data);
3914
- }
3915
- }, [
3916
- path.value,
3917
- path.overridePath,
3918
- isOverride,
3919
- selectedParent,
3920
- sourceFieldValue,
3921
- hasUserChangedField,
3922
- hasUserInteracted
3923
- ]);
3924
- React.useEffect(() => {
3925
- if (!initialLoadComplete) return;
3926
- if (sourceFieldValue !== initialSourceFieldValue) {
3927
- hasUserChangedField.current = true;
3928
- }
3929
- if (!sourceFieldValue) {
3930
- dispatchPath({ type: "NO_URL_CHECK", payload: "" });
3931
- return;
3932
- }
3933
- if (initialLoadComplete && (hasUserChangedField.current || !route) && prevSourceValueRef.current !== sourceFieldValue && !isOverride) {
3934
- const newPath = buildPath("path", sourceFieldValue, selectedParent);
3935
- const type = sourceFieldValue === initialSourceFieldValue ? "NO_URL_CHECK" : "DEFAULT";
3936
- const slug = transformToUrl(sourceFieldValue);
3937
- dispatchPath({ type, payload: newPath });
3938
- dispatchPath({ type: "SET_SLUG", payload: slug });
3939
- dispatchPath({ type: "SET_OVERRIDEPATH", payload: slug });
3940
- prevSourceValueRef.current = sourceFieldValue;
3941
- }
3942
- const canonicalPath = buildPath("canonical", sourceFieldValue, selectedParent);
3943
- dispatchPath({ type: "SET_CANONICALPATH", payload: canonicalPath });
3944
- debouncedCheckCanonicalPath(canonicalPath, route?.documentId || null);
3945
- }, [
3946
- sourceFieldValue,
3947
- initialSourceFieldValue,
3948
- initialLoadComplete,
3949
- selectedParent,
3950
- isOverride,
3951
- route
3952
- ]);
3953
- React.useEffect(() => {
3954
- if (!initialLoadComplete) return;
3955
- if (path.needsUrlCheck && path.value) {
3956
- if (path.uidPath === path.value || initialPath.current === path.value) return;
3957
- debouncedCheckPath(path.value, route?.documentId || null);
3958
- dispatchPath({ type: "SET_URL_CHECK_FLAG" });
3959
- } else {
3960
- setValidationState("idle");
3961
- dispatchPath({ type: "SET_REPLACEMENT", payload: null });
3962
- }
3963
- }, [path.needsUrlCheck, path.value, path.uidPath, route, initialLoadComplete]);
3964
- React.useEffect(() => {
3965
- async function fetchRelatedRute() {
3966
- if (!initialValues.documentId) {
3967
- setInitialLoadComplete(true);
3968
- return;
3969
- }
3970
- try {
3971
- const route2 = await getRelatedRoute(initialValues.documentId);
3972
- if (!route2) return;
3973
- initialPath.current = route2.uidPath;
3974
- setRoute(route2);
3975
- setIsOverride(route2.isOverride || false);
3976
- dispatchPath({ type: "SET_OVERRIDEPATH", payload: route2.path || "" });
3977
- dispatchPath({
3978
- type: "NO_TRANSFORM_AND_CHECK",
3979
- payload: route2.path || ""
3980
- });
3981
- dispatchPath({ type: "SET_UIDPATH", payload: route2.uidPath || "" });
3982
- dispatchPath({ type: "SET_SLUG", payload: route2.slug || "" });
3983
- dispatchPath({
3984
- type: "SET_CANONICALPATH",
3985
- payload: route2.canonicalPath || ""
3986
- });
3987
- const key = config?.default;
3988
- if (key) {
3989
- prevSourceValueRef.current = values[key];
3990
- }
3991
- } catch (err) {
3992
- setRoute(null);
3993
- strapi.log.error(err);
3994
- } finally {
3995
- setInitialLoadComplete(true);
3996
- }
3997
- }
3998
- fetchRelatedRute();
3999
- }, [config]);
4000
- React.useEffect(() => {
4001
- if (!route || !routes.length) return;
4002
- const parentRoute = routes.find(
4003
- (singleRoute) => singleRoute.documentId === route.parent?.documentId
4004
- );
4005
- setSelectedParent(parentRoute || null);
4006
- }, [route, routes]);
4007
- React.useEffect(() => {
4008
- async function fetchProhibitedRouteIds() {
4009
- const prohibitedIds = await getProhibitedRouteIds(route?.documentId);
4010
- setProhibitedRouteIds(prohibitedIds);
4011
- }
4012
- fetchProhibitedRouteIds();
4013
- }, [route]);
4014
- React.useEffect(() => {
4015
- if (!sourceFieldValue || isOverride || !hasUserChangedField.current && !hasUserInteracted.current)
4016
- return;
4017
- const newPath = buildPath("path", sourceFieldValue, selectedParent);
4018
- dispatchPath({ type: "DEFAULT", payload: newPath });
4019
- }, [selectedParent, sourceFieldValue, route, isOverride]);
4020
- async function checkCanonicalPath(path2, routeDocumentId) {
4021
- if (!path2) return;
4022
- try {
4023
- const result = await duplicateCheck({
4024
- fetchFunction: get,
4025
- path: path2,
4026
- routeDocumentId,
4027
- withoutTransform: true
4028
- });
4029
- dispatchPath({ type: "SET_CANONICALPATH", payload: result });
4030
- } catch (err) {
4031
- strapi.log.error(err);
4032
- }
4033
- }
4034
- async function checkPath(path2, routeDocumentId) {
4035
- if (!path2) return;
4036
- setValidationState("checking");
4037
- dispatchPath({ type: "SET_REPLACEMENT", payload: "" });
4038
- try {
4039
- const data = await duplicateCheck({
4040
- fetchFunction: get,
4041
- path: path2,
4042
- routeDocumentId,
4043
- withoutTransform: true
4044
- });
4045
- if (!data || data === path2) return;
4046
- dispatchPath({ type: "NO_URL_CHECK", payload: data });
4047
- dispatchPath({ type: "SET_REPLACEMENT", payload: data });
4048
- } catch (err) {
4049
- strapi.log.error(err);
4050
- } finally {
4051
- setValidationState("done");
4052
- }
4053
- }
4054
- if (!initialLoadComplete)
4055
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral600", children: formatMessage({
4056
- id: getTranslation("loading"),
4057
- defaultMessage: "Loading..."
4058
- }) });
4059
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { tag: "aside", "aria-labelledby": "URL Route", width: "100%", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 1, children: [
4060
- !route && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
4061
- /* @__PURE__ */ jsxRuntime.jsx(NewPathInfo, {}),
4062
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Divider, { marginTop: 2, marginBottom: 2 })
4063
- ] }),
4064
- /* @__PURE__ */ jsxRuntime.jsx(
4065
- RouteStructure,
4066
- {
4067
- canonicalPath: path.canonicalPath,
4068
- routes,
4069
- selectedParent,
4070
- setSelectedParent: (val) => {
4071
- hasUserInteracted.current = true;
4072
- setSelectedParent(val);
4073
- },
4074
- prohibitedRouteIds
4075
- }
4076
- ),
4077
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Divider, { marginTop: 2, marginBottom: 2 }),
4078
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { children: [
4079
- /* @__PURE__ */ jsxRuntime.jsx(
4080
- PathInput,
4081
- {
4082
- path,
4083
- dispatchPath,
4084
- isOverride,
4085
- config,
4086
- hasUserInteracted
4087
- }
4088
- ),
4089
- validationState !== "initial" && /* @__PURE__ */ jsxRuntime.jsx(PathInfo, { validationState, replacement: path.replacement })
4090
- ] }),
4091
- /* @__PURE__ */ jsxRuntime.jsx(
4092
- OverrideCheckbox,
4093
- {
4094
- isOverride,
4095
- setIsOverride: (val) => {
4096
- hasUserInteracted.current = true;
4097
- setIsOverride(val);
4098
- },
4099
- disabledCondition: !canCreate && !canUpdate
4100
- }
4101
- ),
4102
- path.uidPath && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
4103
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Divider, { marginTop: 2, marginBottom: 2 }),
4104
- /* @__PURE__ */ jsxRuntime.jsx(UidPathDisplay, { path: path.uidPath })
4105
- ] })
4106
- ] }) });
4107
- };
4108
- const pluginPermissions = {
4109
- "cm.aside": [{ action: `plugin::${PLUGIN_ID}.cm.aside`, subject: null }],
4110
- "page.navigation": [{ action: `plugin::${PLUGIN_ID}.page.navigation`, subject: null }],
4111
- "page.routes": [{ action: `plugin::${PLUGIN_ID}.page.routes`, subject: null }],
4112
- "settings.general": [{ action: `plugin::${PLUGIN_ID}.settings.general`, subject: null }],
4113
- "settings.navigation": [{ action: `plugin::${PLUGIN_ID}.settings.navigation`, subject: null }]
4114
- };
4115
- const CMEditViewAside = ({ model }) => {
4116
- const { contentTypes } = useAllContentTypes();
4117
- const { config } = usePluginConfig();
4118
- const { formatMessage } = reactIntl.useIntl();
4119
- const [isAllowedContentType, setIsAllowedContentType] = React.useState(false);
4120
- const [isLoading, setIsLoading] = React.useState(true);
4121
- const [contentTypeConfig, setContentTypeConfig] = React.useState(null);
4122
- const [isActiveContentType, setIsActiveContentType] = React.useState(false);
4123
- const panelTitle = PLUGIN_NAME;
4124
- React.useEffect(() => {
4125
- const contentType = contentTypes?.find((ct) => ct.uid === model);
4126
- setIsAllowedContentType(!!contentType?.pluginOptions?.webatlas?.enabled);
4127
- }, [contentTypes, model]);
4128
- React.useEffect(() => {
4129
- if (!config) return;
4130
- setIsActiveContentType(false);
4131
- setContentTypeConfig(null);
4132
- config?.selectedContentTypes?.forEach((type) => {
4133
- if (type.uid === model) {
4134
- setIsActiveContentType(true);
4135
- setContentTypeConfig(type);
4136
- }
4137
- });
4138
- setIsLoading(false);
4139
- }, [config, model]);
4140
- const {
4141
- allowedActions: { canAside }
4142
- } = admin.useRBAC({
4143
- cmAside: pluginPermissions["cm.aside"]
4144
- });
4145
- if (!canAside || !isAllowedContentType || !isActiveContentType || !contentTypeConfig) return null;
4146
- if (!config) {
4147
- strapi.log.error("CMEditViewAside: Plugin is not configured.");
4148
- return null;
4149
- }
4150
- if (isLoading)
4151
- return {
4152
- title: panelTitle,
4153
- content: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral600", children: formatMessage({
4154
- id: getTranslation("loading"),
4155
- defaultMessage: "Loading..."
4156
- }) })
4157
- };
4158
- return {
4159
- title: panelTitle,
4160
- content: /* @__PURE__ */ jsxRuntime.jsx(Panel, { config: contentTypeConfig })
4161
- };
4162
- };
4163
- const index = {
4164
- register(app) {
4165
- app.addMenuLink({
4166
- to: `plugins/${PLUGIN_ID}/paths`,
4167
- icon: PathIcon,
4168
- intlLabel: {
4169
- id: `${PLUGIN_ID}.link.paths`,
4170
- defaultMessage: "Paths"
4171
- },
4172
- Component: () => Promise.resolve().then(() => require("./index-BztvKcfc.js")),
4173
- permissions: [pluginPermissions["page.routes"][0]]
4174
- });
4175
- app.addMenuLink({
4176
- to: `plugins/${PLUGIN_ID}/navigation`,
4177
- icon: NavigationIcon,
4178
- intlLabel: {
4179
- id: `${PLUGIN_ID}.link.navigation`,
4180
- defaultMessage: "Navigation"
4181
- },
4182
- Component: () => Promise.resolve().then(() => require("./index-BiXgA5Ru.js")),
4183
- permissions: [pluginPermissions["page.navigation"][0]]
4184
- });
4185
- app.addSettingsLink(
4186
- {
4187
- id: PLUGIN_ID,
4188
- intlLabel: {
4189
- id: `${PLUGIN_ID}.settings.section`,
4190
- defaultMessage: PLUGIN_NAME
4191
- }
4192
- },
4193
- {
4194
- intlLabel: {
4195
- id: `${PLUGIN_ID}.settings.section.general`,
4196
- defaultMessage: "General"
4197
- },
4198
- id: `${PLUGIN_ID}-general`,
4199
- to: `${PLUGIN_ID}/general`,
4200
- Component: () => Promise.resolve().then(() => require("./index-DcUmtUyp.js")),
4201
- permissions: [pluginPermissions["settings.general"][0]]
4202
- }
4203
- );
4204
- app.addSettingsLink(PLUGIN_ID, {
4205
- intlLabel: {
4206
- id: `${PLUGIN_ID}.settings.navigation`,
4207
- defaultMessage: "Navigation"
4208
- },
4209
- id: `${PLUGIN_ID}-navigation`,
4210
- to: `${PLUGIN_ID}/navigation`,
4211
- Component: () => Promise.resolve().then(() => require("./index-CyzPvvul.js")),
4212
- permissions: [pluginPermissions["settings.navigation"][0]]
4213
- });
4214
- app.registerPlugin({
4215
- id: PLUGIN_ID,
4216
- initializer: Initializer,
4217
- isReady: false,
4218
- name: PLUGIN_ID
4219
- });
4220
- },
4221
- bootstrap(app) {
4222
- app.getPlugin("content-manager").apis.addEditViewSidePanel([CMEditViewAside]);
4223
- },
4224
- async registerTrads({ locales }) {
4225
- return Promise.all(
4226
- locales.map(async (locale) => {
4227
- try {
4228
- const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/de.json": () => Promise.resolve().then(() => require("./de-CqU1FU8C.js")), "./translations/en.json": () => Promise.resolve().then(() => require("./en-C7I90FwV.js")) }), `./translations/${locale}.json`, 3);
4229
- return { data, locale };
4230
- } catch {
4231
- return { data: {}, locale };
4232
- }
4233
- })
4234
- );
4235
- }
4236
- };
4237
- exports.PLUGIN_ID = PLUGIN_ID;
4238
- exports.PLUGIN_NAME = PLUGIN_NAME;
4239
- exports.PLUGIN_VERSION = PLUGIN_VERSION;
4240
- exports.PathInfo = PathInfo;
4241
- exports.Tooltip = Tooltip;
4242
- exports.debounce = debounce;
4243
- exports.duplicateCheck = duplicateCheck;
4244
- exports.getTranslation = getTranslation;
4245
- exports.index = index;
4246
- exports.pluginPermissions = pluginPermissions;
4247
- exports.useAllContentTypes = useAllContentTypes;
4248
- exports.useApi = useApi;
4249
- exports.usePluginConfig = usePluginConfig;