@mattisvensson/strapi-plugin-webatlas 0.4.2 → 0.5.0

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