@mattisvensson/strapi-plugin-webatlas 0.8.0 → 0.8.1

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