@mattisvensson/strapi-plugin-webatlas 0.2.3 → 0.2.5

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