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