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