@contentstack/live-preview-utils 3.2.5 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. package/dist/legacy/light-sdk.cjs +1 -1
  2. package/dist/legacy/light-sdk.js +1 -1
  3. package/dist/legacy/livePreview/eventManager/postMessageEvent.hooks.cjs +1 -1
  4. package/dist/legacy/livePreview/eventManager/postMessageEvent.hooks.js +1 -1
  5. package/dist/legacy/preview/contentstack-live-preview-HOC.cjs +1 -1
  6. package/dist/legacy/preview/contentstack-live-preview-HOC.js +1 -1
  7. package/dist/legacy/visualBuilder/components/Tooltip.cjs +167 -0
  8. package/dist/legacy/visualBuilder/components/Tooltip.cjs.map +1 -0
  9. package/dist/legacy/visualBuilder/components/Tooltip.d.cts +26 -0
  10. package/dist/legacy/visualBuilder/components/Tooltip.d.ts +26 -0
  11. package/dist/legacy/visualBuilder/components/Tooltip.js +140 -0
  12. package/dist/legacy/visualBuilder/components/Tooltip.js.map +1 -0
  13. package/dist/legacy/visualBuilder/components/fieldLabelWrapper.cjs +115 -15
  14. package/dist/legacy/visualBuilder/components/fieldLabelWrapper.cjs.map +1 -1
  15. package/dist/legacy/visualBuilder/components/fieldLabelWrapper.js +117 -17
  16. package/dist/legacy/visualBuilder/components/fieldLabelWrapper.js.map +1 -1
  17. package/dist/legacy/visualBuilder/components/icons/index.cjs +44 -0
  18. package/dist/legacy/visualBuilder/components/icons/index.cjs.map +1 -1
  19. package/dist/legacy/visualBuilder/components/icons/index.d.cts +3 -1
  20. package/dist/legacy/visualBuilder/components/icons/index.d.ts +3 -1
  21. package/dist/legacy/visualBuilder/components/icons/index.js +32 -0
  22. package/dist/legacy/visualBuilder/components/icons/index.js.map +1 -1
  23. package/dist/legacy/visualBuilder/generators/generateOverlay.cjs +1 -0
  24. package/dist/legacy/visualBuilder/generators/generateOverlay.cjs.map +1 -1
  25. package/dist/legacy/visualBuilder/generators/generateOverlay.js +1 -0
  26. package/dist/legacy/visualBuilder/generators/generateOverlay.js.map +1 -1
  27. package/dist/legacy/visualBuilder/generators/generateToolbar.cjs +43 -10
  28. package/dist/legacy/visualBuilder/generators/generateToolbar.cjs.map +1 -1
  29. package/dist/legacy/visualBuilder/generators/generateToolbar.d.cts +11 -4
  30. package/dist/legacy/visualBuilder/generators/generateToolbar.d.ts +11 -4
  31. package/dist/legacy/visualBuilder/generators/generateToolbar.js +41 -9
  32. package/dist/legacy/visualBuilder/generators/generateToolbar.js.map +1 -1
  33. package/dist/legacy/visualBuilder/index.cjs +6 -2
  34. package/dist/legacy/visualBuilder/index.cjs.map +1 -1
  35. package/dist/legacy/visualBuilder/index.d.cts +2 -0
  36. package/dist/legacy/visualBuilder/index.d.ts +2 -0
  37. package/dist/legacy/visualBuilder/index.js +6 -2
  38. package/dist/legacy/visualBuilder/index.js.map +1 -1
  39. package/dist/legacy/visualBuilder/listeners/index.cjs +3 -1
  40. package/dist/legacy/visualBuilder/listeners/index.cjs.map +1 -1
  41. package/dist/legacy/visualBuilder/listeners/index.js +3 -1
  42. package/dist/legacy/visualBuilder/listeners/index.js.map +1 -1
  43. package/dist/legacy/visualBuilder/listeners/mouseClick.cjs +7 -3
  44. package/dist/legacy/visualBuilder/listeners/mouseClick.cjs.map +1 -1
  45. package/dist/legacy/visualBuilder/listeners/mouseClick.d.cts +4 -1
  46. package/dist/legacy/visualBuilder/listeners/mouseClick.d.ts +4 -1
  47. package/dist/legacy/visualBuilder/listeners/mouseClick.js +5 -2
  48. package/dist/legacy/visualBuilder/listeners/mouseClick.js.map +1 -1
  49. package/dist/legacy/visualBuilder/listeners/mouseHover.cjs +183 -133
  50. package/dist/legacy/visualBuilder/listeners/mouseHover.cjs.map +1 -1
  51. package/dist/legacy/visualBuilder/listeners/mouseHover.d.cts +5 -3
  52. package/dist/legacy/visualBuilder/listeners/mouseHover.d.ts +5 -3
  53. package/dist/legacy/visualBuilder/listeners/mouseHover.js +182 -133
  54. package/dist/legacy/visualBuilder/listeners/mouseHover.js.map +1 -1
  55. package/dist/legacy/visualBuilder/utils/handleIndividualFields.cjs +2 -23
  56. package/dist/legacy/visualBuilder/utils/handleIndividualFields.cjs.map +1 -1
  57. package/dist/legacy/visualBuilder/utils/handleIndividualFields.js +2 -13
  58. package/dist/legacy/visualBuilder/utils/handleIndividualFields.js.map +1 -1
  59. package/dist/legacy/visualBuilder/utils/types/postMessage.types.cjs +2 -0
  60. package/dist/legacy/visualBuilder/utils/types/postMessage.types.cjs.map +1 -1
  61. package/dist/legacy/visualBuilder/utils/types/postMessage.types.d.cts +2 -0
  62. package/dist/legacy/visualBuilder/utils/types/postMessage.types.d.ts +2 -0
  63. package/dist/legacy/visualBuilder/utils/types/postMessage.types.js +2 -0
  64. package/dist/legacy/visualBuilder/utils/types/postMessage.types.js.map +1 -1
  65. package/dist/legacy/visualBuilder/visualBuilder.style.cjs +66 -1
  66. package/dist/legacy/visualBuilder/visualBuilder.style.cjs.map +1 -1
  67. package/dist/legacy/visualBuilder/visualBuilder.style.d.cts +7 -0
  68. package/dist/legacy/visualBuilder/visualBuilder.style.d.ts +7 -0
  69. package/dist/legacy/visualBuilder/visualBuilder.style.js +66 -1
  70. package/dist/legacy/visualBuilder/visualBuilder.style.js.map +1 -1
  71. package/dist/modern/light-sdk.cjs +1 -1
  72. package/dist/modern/light-sdk.js +1 -1
  73. package/dist/modern/livePreview/eventManager/postMessageEvent.hooks.cjs +1 -1
  74. package/dist/modern/livePreview/eventManager/postMessageEvent.hooks.js +1 -1
  75. package/dist/modern/preview/contentstack-live-preview-HOC.cjs +1 -1
  76. package/dist/modern/preview/contentstack-live-preview-HOC.js +1 -1
  77. package/dist/modern/visualBuilder/components/Tooltip.cjs +167 -0
  78. package/dist/modern/visualBuilder/components/Tooltip.cjs.map +1 -0
  79. package/dist/modern/visualBuilder/components/Tooltip.d.cts +26 -0
  80. package/dist/modern/visualBuilder/components/Tooltip.d.ts +26 -0
  81. package/dist/modern/visualBuilder/components/Tooltip.js +140 -0
  82. package/dist/modern/visualBuilder/components/Tooltip.js.map +1 -0
  83. package/dist/modern/visualBuilder/components/fieldLabelWrapper.cjs +113 -15
  84. package/dist/modern/visualBuilder/components/fieldLabelWrapper.cjs.map +1 -1
  85. package/dist/modern/visualBuilder/components/fieldLabelWrapper.js +115 -17
  86. package/dist/modern/visualBuilder/components/fieldLabelWrapper.js.map +1 -1
  87. package/dist/modern/visualBuilder/components/icons/index.cjs +44 -0
  88. package/dist/modern/visualBuilder/components/icons/index.cjs.map +1 -1
  89. package/dist/modern/visualBuilder/components/icons/index.d.cts +3 -1
  90. package/dist/modern/visualBuilder/components/icons/index.d.ts +3 -1
  91. package/dist/modern/visualBuilder/components/icons/index.js +32 -0
  92. package/dist/modern/visualBuilder/components/icons/index.js.map +1 -1
  93. package/dist/modern/visualBuilder/generators/generateOverlay.cjs +1 -0
  94. package/dist/modern/visualBuilder/generators/generateOverlay.cjs.map +1 -1
  95. package/dist/modern/visualBuilder/generators/generateOverlay.js +1 -0
  96. package/dist/modern/visualBuilder/generators/generateOverlay.js.map +1 -1
  97. package/dist/modern/visualBuilder/generators/generateToolbar.cjs +42 -10
  98. package/dist/modern/visualBuilder/generators/generateToolbar.cjs.map +1 -1
  99. package/dist/modern/visualBuilder/generators/generateToolbar.d.cts +11 -4
  100. package/dist/modern/visualBuilder/generators/generateToolbar.d.ts +11 -4
  101. package/dist/modern/visualBuilder/generators/generateToolbar.js +40 -9
  102. package/dist/modern/visualBuilder/generators/generateToolbar.js.map +1 -1
  103. package/dist/modern/visualBuilder/index.cjs +6 -2
  104. package/dist/modern/visualBuilder/index.cjs.map +1 -1
  105. package/dist/modern/visualBuilder/index.d.cts +2 -0
  106. package/dist/modern/visualBuilder/index.d.ts +2 -0
  107. package/dist/modern/visualBuilder/index.js +6 -2
  108. package/dist/modern/visualBuilder/index.js.map +1 -1
  109. package/dist/modern/visualBuilder/listeners/index.cjs +3 -1
  110. package/dist/modern/visualBuilder/listeners/index.cjs.map +1 -1
  111. package/dist/modern/visualBuilder/listeners/index.js +3 -1
  112. package/dist/modern/visualBuilder/listeners/index.js.map +1 -1
  113. package/dist/modern/visualBuilder/listeners/mouseClick.cjs +7 -3
  114. package/dist/modern/visualBuilder/listeners/mouseClick.cjs.map +1 -1
  115. package/dist/modern/visualBuilder/listeners/mouseClick.d.cts +4 -1
  116. package/dist/modern/visualBuilder/listeners/mouseClick.d.ts +4 -1
  117. package/dist/modern/visualBuilder/listeners/mouseClick.js +5 -2
  118. package/dist/modern/visualBuilder/listeners/mouseClick.js.map +1 -1
  119. package/dist/modern/visualBuilder/listeners/mouseHover.cjs +183 -133
  120. package/dist/modern/visualBuilder/listeners/mouseHover.cjs.map +1 -1
  121. package/dist/modern/visualBuilder/listeners/mouseHover.d.cts +5 -3
  122. package/dist/modern/visualBuilder/listeners/mouseHover.d.ts +5 -3
  123. package/dist/modern/visualBuilder/listeners/mouseHover.js +182 -133
  124. package/dist/modern/visualBuilder/listeners/mouseHover.js.map +1 -1
  125. package/dist/modern/visualBuilder/utils/handleIndividualFields.cjs +2 -22
  126. package/dist/modern/visualBuilder/utils/handleIndividualFields.cjs.map +1 -1
  127. package/dist/modern/visualBuilder/utils/handleIndividualFields.js +2 -12
  128. package/dist/modern/visualBuilder/utils/handleIndividualFields.js.map +1 -1
  129. package/dist/modern/visualBuilder/utils/types/postMessage.types.cjs +2 -0
  130. package/dist/modern/visualBuilder/utils/types/postMessage.types.cjs.map +1 -1
  131. package/dist/modern/visualBuilder/utils/types/postMessage.types.d.cts +2 -0
  132. package/dist/modern/visualBuilder/utils/types/postMessage.types.d.ts +2 -0
  133. package/dist/modern/visualBuilder/utils/types/postMessage.types.js +2 -0
  134. package/dist/modern/visualBuilder/utils/types/postMessage.types.js.map +1 -1
  135. package/dist/modern/visualBuilder/visualBuilder.style.cjs +66 -1
  136. package/dist/modern/visualBuilder/visualBuilder.style.cjs.map +1 -1
  137. package/dist/modern/visualBuilder/visualBuilder.style.d.cts +7 -0
  138. package/dist/modern/visualBuilder/visualBuilder.style.d.ts +7 -0
  139. package/dist/modern/visualBuilder/visualBuilder.style.js +66 -1
  140. package/dist/modern/visualBuilder/visualBuilder.style.js.map +1 -1
  141. package/package.json +2 -1
@@ -60,7 +60,7 @@ var _LightLivePreviewHoC = class _LightLivePreviewHoC {
60
60
  static unsubscribeOnEntryChange() {
61
61
  }
62
62
  static getSdkVersion() {
63
- return "3.2.5";
63
+ return "3.3.0";
64
64
  }
65
65
  };
66
66
  _LightLivePreviewHoC.previewConstructors = {};
@@ -38,7 +38,7 @@ var _LightLivePreviewHoC = class _LightLivePreviewHoC {
38
38
  static unsubscribeOnEntryChange() {
39
39
  }
40
40
  static getSdkVersion() {
41
- return "3.2.5";
41
+ return "3.3.0";
42
42
  }
43
43
  };
44
44
  _LightLivePreviewHoC.previewConstructors = {};
@@ -89,7 +89,7 @@ function sendInitializeLivePreviewPostMessageEvent() {
89
89
  config: {
90
90
  shouldReload: import_configManager.default.get().ssr,
91
91
  href: window.location.href,
92
- sdkVersion: "3.2.5",
92
+ sdkVersion: "3.3.0",
93
93
  mode: import_configManager.default.get().mode
94
94
  }
95
95
  }
@@ -55,7 +55,7 @@ function sendInitializeLivePreviewPostMessageEvent() {
55
55
  config: {
56
56
  shouldReload: Config.get().ssr,
57
57
  href: window.location.href,
58
- sdkVersion: "3.2.5",
58
+ sdkVersion: "3.3.0",
59
59
  mode: Config.get().mode
60
60
  }
61
61
  }
@@ -227,7 +227,7 @@ var _ContentstackLivePreview = class _ContentstackLivePreview {
227
227
  * @returns The version of the SDK as a string.
228
228
  */
229
229
  static getSdkVersion() {
230
- return "3.2.5";
230
+ return "3.3.0";
231
231
  }
232
232
  };
233
233
  _ContentstackLivePreview.previewConstructors = {};
@@ -195,7 +195,7 @@ var _ContentstackLivePreview = class _ContentstackLivePreview {
195
195
  * @returns The version of the SDK as a string.
196
196
  */
197
197
  static getSdkVersion() {
198
- return "3.2.5";
198
+ return "3.3.0";
199
199
  }
200
200
  };
201
201
  _ContentstackLivePreview.previewConstructors = {};
@@ -0,0 +1,167 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/visualBuilder/components/Tooltip.tsx
31
+ var Tooltip_exports = {};
32
+ __export(Tooltip_exports, {
33
+ ToolbarTooltip: () => ToolbarTooltip,
34
+ default: () => Tooltip_default
35
+ });
36
+ module.exports = __toCommonJS(Tooltip_exports);
37
+ var import_preact = require("preact");
38
+ var import_hooks = require("preact/hooks");
39
+ var import_dom = require("@floating-ui/dom");
40
+ var import_visualBuilder = require("../visualBuilder.style.cjs");
41
+ var import_classnames = __toESM(require("classnames"), 1);
42
+ var import_icons = require("./icons/index.cjs");
43
+ var import_generateCustomCursor = require("../generators/generateCustomCursor.cjs");
44
+ var import_jsx_runtime = require("preact/jsx-runtime");
45
+ var Tooltip = ({ children, content, placement = "top-start" }) => {
46
+ const [isVisible, setIsVisible] = (0, import_hooks.useState)(false);
47
+ const triggerRef = (0, import_hooks.useRef)(null);
48
+ const tooltipRef = (0, import_hooks.useRef)(null);
49
+ const arrowRef = (0, import_hooks.useRef)(null);
50
+ const showTooltip = () => setIsVisible(true);
51
+ const hideTooltip = () => setIsVisible(false);
52
+ (0, import_hooks.useEffect)(() => {
53
+ if (!isVisible || !triggerRef.current || !tooltipRef.current) {
54
+ return;
55
+ }
56
+ const trigger = triggerRef.current;
57
+ const tooltip = tooltipRef.current;
58
+ (0, import_dom.computePosition)(trigger, tooltip, {
59
+ placement,
60
+ // Middleware runs in order to modify the position
61
+ middleware: [
62
+ (0, import_dom.offset)(8),
63
+ // Add 8px of space between the trigger and tooltip
64
+ (0, import_dom.flip)(),
65
+ // Flip to the opposite side if it overflows
66
+ (0, import_dom.shift)({ padding: 5 }),
67
+ // Shift to keep it in view
68
+ ...arrowRef.current ? [(0, import_dom.arrow)({ element: arrowRef.current })] : []
69
+ // Handle arrow positioning
70
+ ]
71
+ }).then(({ x, y, placement: placement2, middlewareData }) => {
72
+ Object.assign(tooltip.style, {
73
+ left: `${x}px`,
74
+ top: `${y}px`
75
+ });
76
+ if (middlewareData.arrow && arrowRef.current) {
77
+ const { x: arrowX, y: arrowY } = middlewareData.arrow;
78
+ const side = placement2.split("-")[0];
79
+ const staticSide = {
80
+ top: "bottom",
81
+ right: "left",
82
+ bottom: "top",
83
+ left: "right"
84
+ }[side];
85
+ const arrowElement = arrowRef.current;
86
+ Object.assign(arrowElement.style, {
87
+ left: "",
88
+ top: "",
89
+ right: "",
90
+ bottom: ""
91
+ });
92
+ if (placement2.includes("-start") || placement2.includes("-end")) {
93
+ const tooltipRect = tooltip.getBoundingClientRect();
94
+ if (side === "top" || side === "bottom") {
95
+ arrowElement.style.left = `${14}px`;
96
+ if (arrowY != null) {
97
+ arrowElement.style.top = `${arrowY}px`;
98
+ }
99
+ } else {
100
+ arrowElement.style.top = `${tooltipRect.height / 2 - 4}px`;
101
+ if (arrowX != null) {
102
+ arrowElement.style.left = `${arrowX}px`;
103
+ }
104
+ }
105
+ } else {
106
+ if (arrowX != null) {
107
+ arrowElement.style.left = `${arrowX}px`;
108
+ }
109
+ if (arrowY != null) {
110
+ arrowElement.style.top = `${arrowY}px`;
111
+ }
112
+ }
113
+ arrowElement.style[staticSide] = "-4px";
114
+ }
115
+ });
116
+ }, [isVisible, placement, content]);
117
+ const triggerWithListeners = (0, import_preact.cloneElement)(children, {
118
+ ref: triggerRef,
119
+ onMouseEnter: showTooltip,
120
+ onMouseLeave: hideTooltip,
121
+ onFocus: showTooltip,
122
+ onBlur: hideTooltip,
123
+ "aria-describedby": "lightweight-tooltip"
124
+ // for accessibility
125
+ });
126
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
127
+ triggerWithListeners,
128
+ isVisible && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
129
+ "div",
130
+ {
131
+ ref: tooltipRef,
132
+ role: "tooltip",
133
+ id: "lightweight-tooltip",
134
+ className: (0, import_classnames.default)("tooltip-container", (0, import_visualBuilder.visualBuilderStyles)()["tooltip-container"]),
135
+ children: [
136
+ content,
137
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: arrowRef, className: (0, import_classnames.default)("tooltip-arrow", (0, import_visualBuilder.visualBuilderStyles)()["tooltip-arrow"]) })
138
+ ]
139
+ }
140
+ )
141
+ ] });
142
+ };
143
+ function ToolbarTooltipContent({ contentTypeName, referenceFieldName }) {
144
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: (0, import_classnames.default)("toolbar-tooltip-content", (0, import_visualBuilder.visualBuilderStyles)()["toolbar-tooltip-content"]), children: [
145
+ contentTypeName && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: (0, import_classnames.default)("toolbar-tooltip-content-item", (0, import_visualBuilder.visualBuilderStyles)()["toolbar-tooltip-content-item"]), children: [
146
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.ContentTypeIcon, {}),
147
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: contentTypeName })
148
+ ] }),
149
+ referenceFieldName && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: (0, import_classnames.default)("toolbar-tooltip-content-item", (0, import_visualBuilder.visualBuilderStyles)()["toolbar-tooltip-content-item"]), children: [
150
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { dangerouslySetInnerHTML: { __html: import_generateCustomCursor.FieldTypeIconsMap.reference }, className: (0, import_classnames.default)("visual-builder__field-icon", (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__field-icon"]) }),
151
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: referenceFieldName })
152
+ ] })
153
+ ] });
154
+ }
155
+ function ToolbarTooltip({ children, data, disabled = false }) {
156
+ if (disabled) {
157
+ return children;
158
+ }
159
+ const { contentTypeName, referenceFieldName } = data;
160
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip, { content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToolbarTooltipContent, { contentTypeName, referenceFieldName }), children });
161
+ }
162
+ var Tooltip_default = Tooltip;
163
+ // Annotate the CommonJS export names for ESM import in node:
164
+ 0 && (module.exports = {
165
+ ToolbarTooltip
166
+ });
167
+ //# sourceMappingURL=Tooltip.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/visualBuilder/components/Tooltip.tsx"],"sourcesContent":["import { h, cloneElement } from 'preact';\nimport { useState, useEffect, useRef } from 'preact/hooks';\nimport {\n computePosition,\n flip,\n shift,\n offset,\n arrow\n} from '@floating-ui/dom';\nimport { visualBuilderStyles } from '../visualBuilder.style';\nimport classNames from 'classnames';\nimport { ContentTypeIcon } from './icons';\nimport { FieldTypeIconsMap } from '../generators/generateCustomCursor';\ninterface TooltipProps {\n children: JSX.Element;\n content: JSX.Element;\n placement?: 'top-start' | 'bottom-start' | 'left-start' | 'right-start';\n}\n\n/**\n * A lightweight, reusable tooltip component for Preact powered by Floating UI.\n *\n * @param {object} props - The component props.\n * @param {preact.ComponentChildren} props.children - The single child element that triggers the tooltip.\n * @param {string | preact.VNode} props.content - The content to display inside the tooltip.\n * @param {'top'|'bottom'|'left'|'right'} [props.placement='top'] - The desired placement of the tooltip.\n */\nconst Tooltip = ({ children, content, placement = 'top-start' }: TooltipProps) => {\n const [isVisible, setIsVisible] = useState(false);\n // Create refs for the trigger and the floating tooltip elements\n const triggerRef = useRef(null);\n const tooltipRef = useRef(null);\n const arrowRef = useRef(null);\n\n const showTooltip = () => setIsVisible(true);\n const hideTooltip = () => setIsVisible(false);\n\n // This effect calculates the tooltip's position whenever it becomes visible\n // or if its content or placement changes.\n useEffect(() => {\n if (!isVisible || !triggerRef.current || !tooltipRef.current) {\n return;\n }\n\n const trigger = triggerRef.current as HTMLElement;\n const tooltip = tooltipRef.current as HTMLElement;\n\n computePosition(trigger, tooltip, {\n placement,\n // Middleware runs in order to modify the position\n middleware: [\n offset(8), // Add 8px of space between the trigger and tooltip\n flip(), // Flip to the opposite side if it overflows\n shift({ padding: 5 }), // Shift to keep it in view\n ...(arrowRef.current ? [arrow({ element: arrowRef.current as HTMLElement })] : []), // Handle arrow positioning\n ],\n }).then(({ x, y, placement, middlewareData }) => {\n // Apply the calculated coordinates to the tooltip element\n Object.assign(tooltip.style, {\n left: `${x}px`,\n top: `${y}px`,\n });\n\n // Position the arrow element\n if (middlewareData.arrow && arrowRef.current) {\n const { x: arrowX, y: arrowY } = middlewareData.arrow;\n const side = placement.split('-')[0];\n const staticSide = {\n top: 'bottom',\n right: 'left',\n bottom: 'top',\n left: 'right',\n }[side] as string;\n\n const arrowElement = arrowRef.current as HTMLElement;\n \n // Reset all positioning properties\n Object.assign(arrowElement.style, {\n left: '',\n top: '',\n right: '',\n bottom: '',\n });\n\n // For placements like top-start, bottom-start, etc., we want the arrow \n // to be centered on the tooltip rather than pointing at the trigger center\n if (placement.includes('-start') || placement.includes('-end')) {\n const tooltipRect = tooltip.getBoundingClientRect();\n \n if (side === 'top' || side === 'bottom') {\n // For top/bottom placements, center the arrow horizontally\n arrowElement.style.left = `${14}px`; // 4px = half arrow width\n if (arrowY != null) {\n arrowElement.style.top = `${arrowY}px`;\n }\n } else {\n // For left/right placements, center the arrow vertically\n arrowElement.style.top = `${tooltipRect.height / 2 - 4}px`; // 4px = half arrow height\n if (arrowX != null) {\n arrowElement.style.left = `${arrowX}px`;\n }\n }\n } else {\n // For regular placements (top, bottom, left, right), use floating-ui's positioning\n if (arrowX != null) {\n arrowElement.style.left = `${arrowX}px`;\n }\n if (arrowY != null) {\n arrowElement.style.top = `${arrowY}px`;\n }\n }\n\n // Position arrow to overlap the tooltip's border\n (arrowElement.style as any)[staticSide] = '-4px';\n }\n });\n\n }, [isVisible, placement, content]);\n\n // We need to clone the child element to attach our ref and event listeners.\n // This ensures we don't wrap the child in an extra <div>.\n const triggerWithListeners = cloneElement(children, {\n ref: triggerRef,\n onMouseEnter: showTooltip,\n onMouseLeave: hideTooltip,\n onFocus: showTooltip,\n onBlur: hideTooltip,\n 'aria-describedby': 'lightweight-tooltip' // for accessibility\n });\n\n return (\n <>\n {triggerWithListeners}\n {isVisible && (\n <div\n ref={tooltipRef}\n role=\"tooltip\"\n id=\"lightweight-tooltip\"\n className={classNames(\"tooltip-container\", visualBuilderStyles()[\"tooltip-container\"])}\n >\n {content}\n <div ref={arrowRef} className={classNames(\"tooltip-arrow\", visualBuilderStyles()[\"tooltip-arrow\"])}></div>\n </div>\n )}\n </>\n );\n};\n\nfunction ToolbarTooltipContent({contentTypeName, referenceFieldName}: {contentTypeName: string, referenceFieldName: string}) {\n return (\n <div className={classNames(\"toolbar-tooltip-content\", visualBuilderStyles()[\"toolbar-tooltip-content\"])}>\n {\n contentTypeName && (\n <div className={classNames(\"toolbar-tooltip-content-item\", visualBuilderStyles()[\"toolbar-tooltip-content-item\"])}>\n <ContentTypeIcon />\n <p>{contentTypeName}</p>\n </div>\n )\n }\n {\n referenceFieldName && (\n <div className={classNames(\"toolbar-tooltip-content-item\", visualBuilderStyles()[\"toolbar-tooltip-content-item\"])}>\n <div dangerouslySetInnerHTML={{__html: FieldTypeIconsMap.reference}} className={classNames(\"visual-builder__field-icon\", visualBuilderStyles()[\"visual-builder__field-icon\"])}/>\n <p>{referenceFieldName}</p>\n </div>\n )\n }\n </div>\n )\n}\n\nexport function ToolbarTooltip({children, data, disabled = false}: {children: JSX.Element, data: {contentTypeName: string, referenceFieldName: string}, disabled?: boolean}) {\n if (disabled) {\n return children;\n }\n const { contentTypeName, referenceFieldName } = data;\n return (\n <Tooltip content={<ToolbarTooltipContent contentTypeName={contentTypeName} referenceFieldName={referenceFieldName} />}>\n {children}\n </Tooltip>\n )\n}\n\nexport default Tooltip;"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAgC;AAChC,mBAA4C;AAC5C,iBAMO;AACP,2BAAoC;AACpC,wBAAuB;AACvB,mBAAgC;AAChC,kCAAkC;AAuH1B;AAxGR,IAAM,UAAU,CAAC,EAAE,UAAU,SAAS,YAAY,YAAY,MAAoB;AAC9E,QAAM,CAAC,WAAW,YAAY,QAAI,uBAAS,KAAK;AAEhD,QAAM,iBAAa,qBAAO,IAAI;AAC9B,QAAM,iBAAa,qBAAO,IAAI;AAC9B,QAAM,eAAW,qBAAO,IAAI;AAE5B,QAAM,cAAc,MAAM,aAAa,IAAI;AAC3C,QAAM,cAAc,MAAM,aAAa,KAAK;AAI5C,8BAAU,MAAM;AACZ,QAAI,CAAC,aAAa,CAAC,WAAW,WAAW,CAAC,WAAW,SAAS;AAC1D;AAAA,IACJ;AAEA,UAAM,UAAU,WAAW;AAC3B,UAAM,UAAU,W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AC,SAAI,yBAAyB,EAAC,QAAQ,8CAAkB,UAAS,GAAG,eAAW,kBAAAA,SAAW,kCAA8B,0CAAoB,EAAE,4BAA4B,CAAC,GAAE;AAAA,MAC9K,4CAAC,OAAG,8BAAmB;AAAA,OACzB;AAAA,KAGN;AAEJ;AAEO,SAAS,eAAe,EAAC,UAAU,MAAM,WAAW,MAAK,GAA6G;AAC3K,MAAI,UAAU;AACZ,WAAO;AAAA,EACT;AACA,QAAM,EAAE,iBAAiB,mBAAmB,IAAI;AAChD,SACE,4CAAC,WAAQ,SAAS,4CAAC,yBAAsB,iBAAkC,oBAAwC,GAChH,UACH;AAEJ;AAEA,IAAO,kBAAQ;","names":["placement","classNames"]}
@@ -0,0 +1,26 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ interface TooltipProps {
4
+ children: JSX.Element;
5
+ content: JSX.Element;
6
+ placement?: 'top-start' | 'bottom-start' | 'left-start' | 'right-start';
7
+ }
8
+ /**
9
+ * A lightweight, reusable tooltip component for Preact powered by Floating UI.
10
+ *
11
+ * @param {object} props - The component props.
12
+ * @param {preact.ComponentChildren} props.children - The single child element that triggers the tooltip.
13
+ * @param {string | preact.VNode} props.content - The content to display inside the tooltip.
14
+ * @param {'top'|'bottom'|'left'|'right'} [props.placement='top'] - The desired placement of the tooltip.
15
+ */
16
+ declare const Tooltip: ({ children, content, placement }: TooltipProps) => react_jsx_runtime.JSX.Element;
17
+ declare function ToolbarTooltip({ children, data, disabled }: {
18
+ children: JSX.Element;
19
+ data: {
20
+ contentTypeName: string;
21
+ referenceFieldName: string;
22
+ };
23
+ disabled?: boolean;
24
+ }): JSX.Element;
25
+
26
+ export { ToolbarTooltip, Tooltip as default };
@@ -0,0 +1,26 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ interface TooltipProps {
4
+ children: JSX.Element;
5
+ content: JSX.Element;
6
+ placement?: 'top-start' | 'bottom-start' | 'left-start' | 'right-start';
7
+ }
8
+ /**
9
+ * A lightweight, reusable tooltip component for Preact powered by Floating UI.
10
+ *
11
+ * @param {object} props - The component props.
12
+ * @param {preact.ComponentChildren} props.children - The single child element that triggers the tooltip.
13
+ * @param {string | preact.VNode} props.content - The content to display inside the tooltip.
14
+ * @param {'top'|'bottom'|'left'|'right'} [props.placement='top'] - The desired placement of the tooltip.
15
+ */
16
+ declare const Tooltip: ({ children, content, placement }: TooltipProps) => react_jsx_runtime.JSX.Element;
17
+ declare function ToolbarTooltip({ children, data, disabled }: {
18
+ children: JSX.Element;
19
+ data: {
20
+ contentTypeName: string;
21
+ referenceFieldName: string;
22
+ };
23
+ disabled?: boolean;
24
+ }): JSX.Element;
25
+
26
+ export { ToolbarTooltip, Tooltip as default };
@@ -0,0 +1,140 @@
1
+ import "../../chunk-5WRI5ZAA.js";
2
+
3
+ // src/visualBuilder/components/Tooltip.tsx
4
+ import { cloneElement } from "preact";
5
+ import { useState, useEffect, useRef } from "preact/hooks";
6
+ import {
7
+ computePosition,
8
+ flip,
9
+ shift,
10
+ offset,
11
+ arrow
12
+ } from "@floating-ui/dom";
13
+ import { visualBuilderStyles } from "../visualBuilder.style.js";
14
+ import classNames from "classnames";
15
+ import { ContentTypeIcon } from "./icons/index.js";
16
+ import { FieldTypeIconsMap } from "../generators/generateCustomCursor.js";
17
+ import { Fragment, jsx, jsxs } from "preact/jsx-runtime";
18
+ var Tooltip = ({ children, content, placement = "top-start" }) => {
19
+ const [isVisible, setIsVisible] = useState(false);
20
+ const triggerRef = useRef(null);
21
+ const tooltipRef = useRef(null);
22
+ const arrowRef = useRef(null);
23
+ const showTooltip = () => setIsVisible(true);
24
+ const hideTooltip = () => setIsVisible(false);
25
+ useEffect(() => {
26
+ if (!isVisible || !triggerRef.current || !tooltipRef.current) {
27
+ return;
28
+ }
29
+ const trigger = triggerRef.current;
30
+ const tooltip = tooltipRef.current;
31
+ computePosition(trigger, tooltip, {
32
+ placement,
33
+ // Middleware runs in order to modify the position
34
+ middleware: [
35
+ offset(8),
36
+ // Add 8px of space between the trigger and tooltip
37
+ flip(),
38
+ // Flip to the opposite side if it overflows
39
+ shift({ padding: 5 }),
40
+ // Shift to keep it in view
41
+ ...arrowRef.current ? [arrow({ element: arrowRef.current })] : []
42
+ // Handle arrow positioning
43
+ ]
44
+ }).then(({ x, y, placement: placement2, middlewareData }) => {
45
+ Object.assign(tooltip.style, {
46
+ left: `${x}px`,
47
+ top: `${y}px`
48
+ });
49
+ if (middlewareData.arrow && arrowRef.current) {
50
+ const { x: arrowX, y: arrowY } = middlewareData.arrow;
51
+ const side = placement2.split("-")[0];
52
+ const staticSide = {
53
+ top: "bottom",
54
+ right: "left",
55
+ bottom: "top",
56
+ left: "right"
57
+ }[side];
58
+ const arrowElement = arrowRef.current;
59
+ Object.assign(arrowElement.style, {
60
+ left: "",
61
+ top: "",
62
+ right: "",
63
+ bottom: ""
64
+ });
65
+ if (placement2.includes("-start") || placement2.includes("-end")) {
66
+ const tooltipRect = tooltip.getBoundingClientRect();
67
+ if (side === "top" || side === "bottom") {
68
+ arrowElement.style.left = `${14}px`;
69
+ if (arrowY != null) {
70
+ arrowElement.style.top = `${arrowY}px`;
71
+ }
72
+ } else {
73
+ arrowElement.style.top = `${tooltipRect.height / 2 - 4}px`;
74
+ if (arrowX != null) {
75
+ arrowElement.style.left = `${arrowX}px`;
76
+ }
77
+ }
78
+ } else {
79
+ if (arrowX != null) {
80
+ arrowElement.style.left = `${arrowX}px`;
81
+ }
82
+ if (arrowY != null) {
83
+ arrowElement.style.top = `${arrowY}px`;
84
+ }
85
+ }
86
+ arrowElement.style[staticSide] = "-4px";
87
+ }
88
+ });
89
+ }, [isVisible, placement, content]);
90
+ const triggerWithListeners = cloneElement(children, {
91
+ ref: triggerRef,
92
+ onMouseEnter: showTooltip,
93
+ onMouseLeave: hideTooltip,
94
+ onFocus: showTooltip,
95
+ onBlur: hideTooltip,
96
+ "aria-describedby": "lightweight-tooltip"
97
+ // for accessibility
98
+ });
99
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
100
+ triggerWithListeners,
101
+ isVisible && /* @__PURE__ */ jsxs(
102
+ "div",
103
+ {
104
+ ref: tooltipRef,
105
+ role: "tooltip",
106
+ id: "lightweight-tooltip",
107
+ className: classNames("tooltip-container", visualBuilderStyles()["tooltip-container"]),
108
+ children: [
109
+ content,
110
+ /* @__PURE__ */ jsx("div", { ref: arrowRef, className: classNames("tooltip-arrow", visualBuilderStyles()["tooltip-arrow"]) })
111
+ ]
112
+ }
113
+ )
114
+ ] });
115
+ };
116
+ function ToolbarTooltipContent({ contentTypeName, referenceFieldName }) {
117
+ return /* @__PURE__ */ jsxs("div", { className: classNames("toolbar-tooltip-content", visualBuilderStyles()["toolbar-tooltip-content"]), children: [
118
+ contentTypeName && /* @__PURE__ */ jsxs("div", { className: classNames("toolbar-tooltip-content-item", visualBuilderStyles()["toolbar-tooltip-content-item"]), children: [
119
+ /* @__PURE__ */ jsx(ContentTypeIcon, {}),
120
+ /* @__PURE__ */ jsx("p", { children: contentTypeName })
121
+ ] }),
122
+ referenceFieldName && /* @__PURE__ */ jsxs("div", { className: classNames("toolbar-tooltip-content-item", visualBuilderStyles()["toolbar-tooltip-content-item"]), children: [
123
+ /* @__PURE__ */ jsx("div", { dangerouslySetInnerHTML: { __html: FieldTypeIconsMap.reference }, className: classNames("visual-builder__field-icon", visualBuilderStyles()["visual-builder__field-icon"]) }),
124
+ /* @__PURE__ */ jsx("p", { children: referenceFieldName })
125
+ ] })
126
+ ] });
127
+ }
128
+ function ToolbarTooltip({ children, data, disabled = false }) {
129
+ if (disabled) {
130
+ return children;
131
+ }
132
+ const { contentTypeName, referenceFieldName } = data;
133
+ return /* @__PURE__ */ jsx(Tooltip, { content: /* @__PURE__ */ jsx(ToolbarTooltipContent, { contentTypeName, referenceFieldName }), children });
134
+ }
135
+ var Tooltip_default = Tooltip;
136
+ export {
137
+ ToolbarTooltip,
138
+ Tooltip_default as default
139
+ };
140
+ //# sourceMappingURL=Tooltip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/visualBuilder/components/Tooltip.tsx"],"sourcesContent":["import { h, cloneElement } from 'preact';\nimport { useState, useEffect, useRef } from 'preact/hooks';\nimport {\n computePosition,\n flip,\n shift,\n offset,\n arrow\n} from '@floating-ui/dom';\nimport { visualBuilderStyles } from '../visualBuilder.style';\nimport classNames from 'classnames';\nimport { ContentTypeIcon } from './icons';\nimport { FieldTypeIconsMap } from '../generators/generateCustomCursor';\ninterface TooltipProps {\n children: JSX.Element;\n content: JSX.Element;\n placement?: 'top-start' | 'bottom-start' | 'left-start' | 'right-start';\n}\n\n/**\n * A lightweight, reusable tooltip component for Preact powered by Floating UI.\n *\n * @param {object} props - The component props.\n * @param {preact.ComponentChildren} props.children - The single child element that triggers the tooltip.\n * @param {string | preact.VNode} props.content - The content to display inside the tooltip.\n * @param {'top'|'bottom'|'left'|'right'} [props.placement='top'] - The desired placement of the tooltip.\n */\nconst Tooltip = ({ children, content, placement = 'top-start' }: TooltipProps) => {\n const [isVisible, setIsVisible] = useState(false);\n // Create refs for the trigger and the floating tooltip elements\n const triggerRef = useRef(null);\n const tooltipRef = useRef(null);\n const arrowRef = useRef(null);\n\n const showTooltip = () => setIsVisible(true);\n const hideTooltip = () => setIsVisible(false);\n\n // This effect calculates the tooltip's position whenever it becomes visible\n // or if its content or placement changes.\n useEffect(() => {\n if (!isVisible || !triggerRef.current || !tooltipRef.current) {\n return;\n }\n\n const trigger = triggerRef.current as HTMLElement;\n const tooltip = tooltipRef.current as HTMLElement;\n\n computePosition(trigger, tooltip, {\n placement,\n // Middleware runs in order to modify the position\n middleware: [\n offset(8), // Add 8px of space between the trigger and tooltip\n flip(), // Flip to the opposite side if it overflows\n shift({ padding: 5 }), // Shift to keep it in view\n ...(arrowRef.current ? [arrow({ element: arrowRef.current as HTMLElement })] : []), // Handle arrow positioning\n ],\n }).then(({ x, y, placement, middlewareData }) => {\n // Apply the calculated coordinates to the tooltip element\n Object.assign(tooltip.style, {\n left: `${x}px`,\n top: `${y}px`,\n });\n\n // Position the arrow element\n if (middlewareData.arrow && arrowRef.current) {\n const { x: arrowX, y: arrowY } = middlewareData.arrow;\n const side = placement.split('-')[0];\n const staticSide = {\n top: 'bottom',\n right: 'left',\n bottom: 'top',\n left: 'right',\n }[side] as string;\n\n const arrowElement = arrowRef.current as HTMLElement;\n \n // Reset all positioning properties\n Object.assign(arrowElement.style, {\n left: '',\n top: '',\n right: '',\n bottom: '',\n });\n\n // For placements like top-start, bottom-start, etc., we want the arrow \n // to be centered on the tooltip rather than pointing at the trigger center\n if (placement.includes('-start') || placement.includes('-end')) {\n const tooltipRect = tooltip.getBoundingClientRect();\n \n if (side === 'top' || side === 'bottom') {\n // For top/bottom placements, center the arrow horizontally\n arrowElement.style.left = `${14}px`; // 4px = half arrow width\n if (arrowY != null) {\n arrowElement.style.top = `${arrowY}px`;\n }\n } else {\n // For left/right placements, center the arrow vertically\n arrowElement.style.top = `${tooltipRect.height / 2 - 4}px`; // 4px = half arrow height\n if (arrowX != null) {\n arrowElement.style.left = `${arrowX}px`;\n }\n }\n } else {\n // For regular placements (top, bottom, left, right), use floating-ui's positioning\n if (arrowX != null) {\n arrowElement.style.left = `${arrowX}px`;\n }\n if (arrowY != null) {\n arrowElement.style.top = `${arrowY}px`;\n }\n }\n\n // Position arrow to overlap the tooltip's border\n (arrowElement.style as any)[staticSide] = '-4px';\n }\n });\n\n }, [isVisible, placement, content]);\n\n // We need to clone the child element to attach our ref and event listeners.\n // This ensures we don't wrap the child in an extra <div>.\n const triggerWithListeners = cloneElement(children, {\n ref: triggerRef,\n onMouseEnter: showTooltip,\n onMouseLeave: hideTooltip,\n onFocus: showTooltip,\n onBlur: hideTooltip,\n 'aria-describedby': 'lightweight-tooltip' // for accessibility\n });\n\n return (\n <>\n {triggerWithListeners}\n {isVisible && (\n <div\n ref={tooltipRef}\n role=\"tooltip\"\n id=\"lightweight-tooltip\"\n className={classNames(\"tooltip-container\", visualBuilderStyles()[\"tooltip-container\"])}\n >\n {content}\n <div ref={arrowRef} className={classNames(\"tooltip-arrow\", visualBuilderStyles()[\"tooltip-arrow\"])}></div>\n </div>\n )}\n </>\n );\n};\n\nfunction ToolbarTooltipContent({contentTypeName, referenceFieldName}: {contentTypeName: string, referenceFieldName: string}) {\n return (\n <div className={classNames(\"toolbar-tooltip-content\", visualBuilderStyles()[\"toolbar-tooltip-content\"])}>\n {\n contentTypeName && (\n <div className={classNames(\"toolbar-tooltip-content-item\", visualBuilderStyles()[\"toolbar-tooltip-content-item\"])}>\n <ContentTypeIcon />\n <p>{contentTypeName}</p>\n </div>\n )\n }\n {\n referenceFieldName && (\n <div className={classNames(\"toolbar-tooltip-content-item\", visualBuilderStyles()[\"toolbar-tooltip-content-item\"])}>\n <div dangerouslySetInnerHTML={{__html: FieldTypeIconsMap.reference}} className={classNames(\"visual-builder__field-icon\", visualBuilderStyles()[\"visual-builder__field-icon\"])}/>\n <p>{referenceFieldName}</p>\n </div>\n )\n }\n </div>\n )\n}\n\nexport function ToolbarTooltip({children, data, disabled = false}: {children: JSX.Element, data: {contentTypeName: string, referenceFieldName: string}, disabled?: boolean}) {\n if (disabled) {\n return children;\n }\n const { contentTypeName, referenceFieldName } = data;\n return (\n <Tooltip content={<ToolbarTooltipContent contentTypeName={contentTypeName} referenceFieldName={referenceFieldName} />}>\n {children}\n </Tooltip>\n )\n}\n\nexport default Tooltip;"],"mappings":";;;AAAA,SAAY,oBAAoB;AAChC,SAAS,UAAU,WAAW,cAAc;AAC5C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,2BAA2B;AACpC,OAAO,gBAAgB;AACvB,SAAS,uBAAuB;AAChC,SAAS,yBAAyB;AAuH1B,mBAUY,KAPJ,YAHR;AAxGR,IAAM,UAAU,CAAC,EAAE,UAAU,SAAS,YAAY,YAAY,MAAoB;AAC9E,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,KAAK;AAEhD,QAAM,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