@contentstack/live-preview-utils 4.3.0 → 4.4.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 (110) hide show
  1. package/README.md +96 -30
  2. package/dist/legacy/chunk-HZF5SLJ7.js +625 -0
  3. package/dist/legacy/chunk-HZF5SLJ7.js.map +1 -0
  4. package/dist/legacy/index.d.cts +1 -1
  5. package/dist/legacy/index.d.ts +1 -1
  6. package/dist/legacy/light-sdk.cjs +1 -1
  7. package/dist/legacy/light-sdk.cjs.map +1 -1
  8. package/dist/legacy/light-sdk.js +1 -1
  9. package/dist/legacy/light-sdk.js.map +1 -1
  10. package/dist/legacy/livePreview/editButton/editButton.cjs +2 -0
  11. package/dist/legacy/livePreview/editButton/editButton.cjs.map +1 -1
  12. package/dist/legacy/livePreview/editButton/editButton.js +2 -0
  13. package/dist/legacy/livePreview/editButton/editButton.js.map +1 -1
  14. package/dist/legacy/livePreview/eventManager/livePreviewEventManager.cjs +172 -432
  15. package/dist/legacy/livePreview/eventManager/livePreviewEventManager.cjs.map +1 -1
  16. package/dist/legacy/livePreview/eventManager/livePreviewEventManager.js +1 -1
  17. package/dist/legacy/livePreview/eventManager/postMessageEvent.hooks.cjs +1 -1
  18. package/dist/legacy/livePreview/eventManager/postMessageEvent.hooks.js +1 -1
  19. package/dist/legacy/preview/contentstack-live-preview-HOC.cjs +1 -1
  20. package/dist/legacy/preview/contentstack-live-preview-HOC.js +1 -1
  21. package/dist/legacy/timeline/timelinePostMessage/timelinePostMessage.cjs +172 -432
  22. package/dist/legacy/timeline/timelinePostMessage/timelinePostMessage.cjs.map +1 -1
  23. package/dist/legacy/timeline/timelinePostMessage/timelinePostMessage.js +1 -1
  24. package/dist/legacy/visualBuilder/components/fieldLabelWrapper.cjs +111 -27
  25. package/dist/legacy/visualBuilder/components/fieldLabelWrapper.cjs.map +1 -1
  26. package/dist/legacy/visualBuilder/components/fieldLabelWrapper.js +112 -28
  27. package/dist/legacy/visualBuilder/components/fieldLabelWrapper.js.map +1 -1
  28. package/dist/legacy/visualBuilder/utils/getWorkflowStageDetails.cjs +4 -0
  29. package/dist/legacy/visualBuilder/utils/getWorkflowStageDetails.cjs.map +1 -1
  30. package/dist/legacy/visualBuilder/utils/getWorkflowStageDetails.d.cts +8 -1
  31. package/dist/legacy/visualBuilder/utils/getWorkflowStageDetails.d.ts +8 -1
  32. package/dist/legacy/visualBuilder/utils/getWorkflowStageDetails.js +4 -0
  33. package/dist/legacy/visualBuilder/utils/getWorkflowStageDetails.js.map +1 -1
  34. package/dist/legacy/visualBuilder/utils/isFieldDisabled.cjs +41 -6
  35. package/dist/legacy/visualBuilder/utils/isFieldDisabled.cjs.map +1 -1
  36. package/dist/legacy/visualBuilder/utils/isFieldDisabled.d.cts +9 -1
  37. package/dist/legacy/visualBuilder/utils/isFieldDisabled.d.ts +9 -1
  38. package/dist/legacy/visualBuilder/utils/isFieldDisabled.js +41 -6
  39. package/dist/legacy/visualBuilder/utils/isFieldDisabled.js.map +1 -1
  40. package/dist/legacy/visualBuilder/utils/types/postMessage.types.cjs +1 -0
  41. package/dist/legacy/visualBuilder/utils/types/postMessage.types.cjs.map +1 -1
  42. package/dist/legacy/visualBuilder/utils/types/postMessage.types.d.cts +1 -0
  43. package/dist/legacy/visualBuilder/utils/types/postMessage.types.d.ts +1 -0
  44. package/dist/legacy/visualBuilder/utils/types/postMessage.types.js +1 -0
  45. package/dist/legacy/visualBuilder/utils/types/postMessage.types.js.map +1 -1
  46. package/dist/legacy/visualBuilder/utils/visualBuilderPostMessage.cjs +172 -432
  47. package/dist/legacy/visualBuilder/utils/visualBuilderPostMessage.cjs.map +1 -1
  48. package/dist/legacy/visualBuilder/utils/visualBuilderPostMessage.js +1 -1
  49. package/dist/legacy/visualBuilder/visualBuilder.style.cjs +30 -0
  50. package/dist/legacy/visualBuilder/visualBuilder.style.cjs.map +1 -1
  51. package/dist/legacy/visualBuilder/visualBuilder.style.d.cts +5 -0
  52. package/dist/legacy/visualBuilder/visualBuilder.style.d.ts +5 -0
  53. package/dist/legacy/visualBuilder/visualBuilder.style.js +30 -0
  54. package/dist/legacy/visualBuilder/visualBuilder.style.js.map +1 -1
  55. package/dist/modern/chunk-4RUJZCI2.js +625 -0
  56. package/dist/modern/chunk-4RUJZCI2.js.map +1 -0
  57. package/dist/modern/light-sdk.cjs +1 -1
  58. package/dist/modern/light-sdk.cjs.map +1 -1
  59. package/dist/modern/light-sdk.js +1 -1
  60. package/dist/modern/light-sdk.js.map +1 -1
  61. package/dist/modern/livePreview/editButton/editButton.cjs +2 -0
  62. package/dist/modern/livePreview/editButton/editButton.cjs.map +1 -1
  63. package/dist/modern/livePreview/editButton/editButton.js +2 -0
  64. package/dist/modern/livePreview/editButton/editButton.js.map +1 -1
  65. package/dist/modern/livePreview/eventManager/livePreviewEventManager.cjs +172 -432
  66. package/dist/modern/livePreview/eventManager/livePreviewEventManager.cjs.map +1 -1
  67. package/dist/modern/livePreview/eventManager/livePreviewEventManager.js +1 -1
  68. package/dist/modern/livePreview/eventManager/postMessageEvent.hooks.cjs +1 -1
  69. package/dist/modern/livePreview/eventManager/postMessageEvent.hooks.js +1 -1
  70. package/dist/modern/preview/contentstack-live-preview-HOC.cjs +1 -1
  71. package/dist/modern/preview/contentstack-live-preview-HOC.js +1 -1
  72. package/dist/modern/timeline/timelinePostMessage/timelinePostMessage.cjs +172 -432
  73. package/dist/modern/timeline/timelinePostMessage/timelinePostMessage.cjs.map +1 -1
  74. package/dist/modern/timeline/timelinePostMessage/timelinePostMessage.js +1 -1
  75. package/dist/modern/visualBuilder/components/fieldLabelWrapper.cjs +110 -27
  76. package/dist/modern/visualBuilder/components/fieldLabelWrapper.cjs.map +1 -1
  77. package/dist/modern/visualBuilder/components/fieldLabelWrapper.js +111 -28
  78. package/dist/modern/visualBuilder/components/fieldLabelWrapper.js.map +1 -1
  79. package/dist/modern/visualBuilder/utils/getWorkflowStageDetails.cjs +4 -0
  80. package/dist/modern/visualBuilder/utils/getWorkflowStageDetails.cjs.map +1 -1
  81. package/dist/modern/visualBuilder/utils/getWorkflowStageDetails.d.cts +8 -1
  82. package/dist/modern/visualBuilder/utils/getWorkflowStageDetails.d.ts +8 -1
  83. package/dist/modern/visualBuilder/utils/getWorkflowStageDetails.js +4 -0
  84. package/dist/modern/visualBuilder/utils/getWorkflowStageDetails.js.map +1 -1
  85. package/dist/modern/visualBuilder/utils/isFieldDisabled.cjs +40 -6
  86. package/dist/modern/visualBuilder/utils/isFieldDisabled.cjs.map +1 -1
  87. package/dist/modern/visualBuilder/utils/isFieldDisabled.d.cts +9 -1
  88. package/dist/modern/visualBuilder/utils/isFieldDisabled.d.ts +9 -1
  89. package/dist/modern/visualBuilder/utils/isFieldDisabled.js +40 -6
  90. package/dist/modern/visualBuilder/utils/isFieldDisabled.js.map +1 -1
  91. package/dist/modern/visualBuilder/utils/types/postMessage.types.cjs +1 -0
  92. package/dist/modern/visualBuilder/utils/types/postMessage.types.cjs.map +1 -1
  93. package/dist/modern/visualBuilder/utils/types/postMessage.types.d.cts +1 -0
  94. package/dist/modern/visualBuilder/utils/types/postMessage.types.d.ts +1 -0
  95. package/dist/modern/visualBuilder/utils/types/postMessage.types.js +1 -0
  96. package/dist/modern/visualBuilder/utils/types/postMessage.types.js.map +1 -1
  97. package/dist/modern/visualBuilder/utils/visualBuilderPostMessage.cjs +172 -432
  98. package/dist/modern/visualBuilder/utils/visualBuilderPostMessage.cjs.map +1 -1
  99. package/dist/modern/visualBuilder/utils/visualBuilderPostMessage.js +1 -1
  100. package/dist/modern/visualBuilder/visualBuilder.style.cjs +30 -0
  101. package/dist/modern/visualBuilder/visualBuilder.style.cjs.map +1 -1
  102. package/dist/modern/visualBuilder/visualBuilder.style.d.cts +5 -0
  103. package/dist/modern/visualBuilder/visualBuilder.style.d.ts +5 -0
  104. package/dist/modern/visualBuilder/visualBuilder.style.js +30 -0
  105. package/dist/modern/visualBuilder/visualBuilder.style.js.map +1 -1
  106. package/package.json +9 -9
  107. package/dist/legacy/chunk-7SRLYDRL.js +0 -885
  108. package/dist/legacy/chunk-7SRLYDRL.js.map +0 -1
  109. package/dist/modern/chunk-JYE4G3PN.js +0 -885
  110. package/dist/modern/chunk-JYE4G3PN.js.map +0 -1
@@ -0,0 +1,625 @@
1
+ import {
2
+ __commonJS
3
+ } from "./chunk-5WRI5ZAA.js";
4
+
5
+ // node_modules/@contentstack/advanced-post-message/dist/index.js
6
+ var require_dist = __commonJS({
7
+ "node_modules/@contentstack/advanced-post-message/dist/index.js"(exports, module) {
8
+ "use strict";
9
+ !(function(e, t) {
10
+ "object" == typeof exports && "object" == typeof module ? module.exports = t() : "function" == typeof define && define.amd ? define([], t) : "object" == typeof exports ? exports.ContentstackAdvPostMessage = t() : e.ContentstackAdvPostMessage = t();
11
+ })(exports, () => {
12
+ return e = { 706(e2, t2, r) {
13
+ "use strict";
14
+ Object.defineProperty(t2, "__esModule", { value: true }), t2.Config = void 0;
15
+ var n = r(450), o = r(666), i = r(628), s = r(399), a = (function() {
16
+ function e3() {
17
+ this.config = (0, o.getDefaultConfig)();
18
+ }
19
+ return e3.prototype.replace = function(e4) {
20
+ !(function(e5, t3) {
21
+ var r2, o2, a2, c;
22
+ if (t3.debug = null !== (r2 = e5.debug) && void 0 !== r2 ? r2 : t3.debug, "" === e5.channelId) throw new Error((0, i.getErrorMessage)(n.ERROR_MESSAGES.common.channelIdRequired));
23
+ t3.channelId = null !== (o2 = e5.channelId) && void 0 !== o2 ? o2 : t3.channelId, t3.suppressErrors = null !== (a2 = e5.suppressErrors) && void 0 !== a2 ? a2 : t3.suppressErrors, t3.targetOrigin = null !== (c = e5.targetOrigin) && void 0 !== c ? c : t3.targetOrigin;
24
+ var u = (0, s.getWindow)();
25
+ e5.target ? t3.targetWindow = e5.target : t3.targetWindow = u || { postMessage: function() {
26
+ } };
27
+ })(e4, this.config);
28
+ }, e3.prototype.set = function(e4, t3) {
29
+ this.config[e4] = t3;
30
+ }, e3.prototype.get = function(e4) {
31
+ return this.config[e4];
32
+ }, e3.prototype.getAll = function() {
33
+ return this.config;
34
+ }, e3.prototype.reset = function() {
35
+ this.config = (0, o.getDefaultConfig)();
36
+ }, e3;
37
+ })();
38
+ t2.Config = a;
39
+ }, 851(e2, t2) {
40
+ "use strict";
41
+ Object.defineProperty(t2, "__esModule", { value: true }), t2.ERROR_CODES = t2.ERROR_MESSAGES = void 0, t2.ERROR_MESSAGES = { common: { windowClosed: "The window closed before the response was received", windowNotFound: "The window was not found.", channelIdRequired: "The channelId is required" }, sendEvent: { receiverReturnedError: "The receiver returned an error", eventCancelled: "The event was cancelled", noAckReceived: "The ACK was not received" }, receiveEvent: { noRequestListenerFound: function(e3) {
42
+ return 'No request listener found for event "'.concat(e3, '"');
43
+ }, codeReturnedError: "The code returned an error", noResponseListenerFound: function(e3) {
44
+ return 'No response listener found for hash "'.concat(e3, '"');
45
+ }, noAckListenerFound: function(e3) {
46
+ return 'No ack listener found for hash "'.concat(e3, '"');
47
+ }, unknownNature: function(e3) {
48
+ return 'The nature "'.concat(e3, '" is unknown');
49
+ } }, registerEvent: { eventAlreadyRegistered: function(e3) {
50
+ return 'The event "'.concat(e3, '" is already registered');
51
+ } }, unregisterEvent: { eventDoesNotExist: function(e3) {
52
+ return 'The event "'.concat(e3, '" does not exist');
53
+ } } }, t2.ERROR_CODES = { common: { windowClosed: "WINDOW_CLOSED", windowNotFound: "WINDOW_NOT_FOUND" }, sendEvent: { receiverReturnedError: "RECEIVER_RETURNED_ERROR", eventCancelled: "EVENT_CANCELLED", noAckReceived: "NO_ACK_RECEIVED" }, receiveEvent: { noRequestListenerFound: "NO_REQUEST_LISTENER_FOUND", codeReturnedError: "CODE_RETURNED_ERROR", noResponseListenerFound: "NO_RESPONSE_LISTENER_FOUND", noAckListenerFound: "NO_ACK_LISTENER_FOUND", unknownNature: "UNKNOWN_NATURE" }, registerEvent: { eventAlreadyRegistered: "EVENT_ALREADY_REGISTERED" }, unregisterEvent: { eventDoesNotExist: "EVENT_DOES_NOT_EXIST" } };
54
+ }, 450(e2, t2, r) {
55
+ "use strict";
56
+ var n = this && this.__createBinding || (Object.create ? function(e3, t3, r2, n2) {
57
+ void 0 === n2 && (n2 = r2);
58
+ var o2 = Object.getOwnPropertyDescriptor(t3, r2);
59
+ o2 && !("get" in o2 ? !t3.__esModule : o2.writable || o2.configurable) || (o2 = { enumerable: true, get: function() {
60
+ return t3[r2];
61
+ } }), Object.defineProperty(e3, n2, o2);
62
+ } : function(e3, t3, r2, n2) {
63
+ void 0 === n2 && (n2 = r2), e3[n2] = t3[r2];
64
+ }), o = this && this.__exportStar || function(e3, t3) {
65
+ for (var r2 in e3) "default" === r2 || Object.prototype.hasOwnProperty.call(t3, r2) || n(t3, e3, r2);
66
+ };
67
+ Object.defineProperty(t2, "__esModule", { value: true }), t2.EVENT_MANAGER_NAME = t2.ANY_ORIGIN = t2.RESPONSE_CYCLE = void 0, t2.RESPONSE_CYCLE = 500, t2.ANY_ORIGIN = "*", t2.EVENT_MANAGER_NAME = "contentstack-adv-post-message", o(r(851), t2);
68
+ }, 666(e2, t2, r) {
69
+ "use strict";
70
+ Object.defineProperty(t2, "__esModule", { value: true }), t2.getDefaultConfig = void 0;
71
+ var n = r(450);
72
+ t2.getDefaultConfig = function() {
73
+ return { targetOrigin: n.ANY_ORIGIN, targetWindow: { postMessage: function() {
74
+ } }, debug: false, channelId: "", suppressErrors: false };
75
+ };
76
+ }, 156(e2, t2, r) {
77
+ "use strict";
78
+ var n = this && this.__assign || function() {
79
+ return n = Object.assign || function(e3) {
80
+ for (var t3, r2 = 1, n2 = arguments.length; r2 < n2; r2++) for (var o2 in t3 = arguments[r2]) Object.prototype.hasOwnProperty.call(t3, o2) && (e3[o2] = t3[o2]);
81
+ return e3;
82
+ }, n.apply(this, arguments);
83
+ }, o = this && this.__createBinding || (Object.create ? function(e3, t3, r2, n2) {
84
+ void 0 === n2 && (n2 = r2);
85
+ var o2 = Object.getOwnPropertyDescriptor(t3, r2);
86
+ o2 && !("get" in o2 ? !t3.__esModule : o2.writable || o2.configurable) || (o2 = { enumerable: true, get: function() {
87
+ return t3[r2];
88
+ } }), Object.defineProperty(e3, n2, o2);
89
+ } : function(e3, t3, r2, n2) {
90
+ void 0 === n2 && (n2 = r2), e3[n2] = t3[r2];
91
+ }), i = this && this.__exportStar || function(e3, t3) {
92
+ for (var r2 in e3) "default" === r2 || Object.prototype.hasOwnProperty.call(t3, r2) || o(t3, e3, r2);
93
+ }, s = this && this.__awaiter || function(e3, t3, r2, n2) {
94
+ return new (r2 || (r2 = Promise))(function(o2, i2) {
95
+ function s2(e4) {
96
+ try {
97
+ c2(n2.next(e4));
98
+ } catch (e5) {
99
+ i2(e5);
100
+ }
101
+ }
102
+ function a2(e4) {
103
+ try {
104
+ c2(n2.throw(e4));
105
+ } catch (e5) {
106
+ i2(e5);
107
+ }
108
+ }
109
+ function c2(e4) {
110
+ var t4;
111
+ e4.done ? o2(e4.value) : (t4 = e4.value, t4 instanceof r2 ? t4 : new r2(function(e5) {
112
+ e5(t4);
113
+ })).then(s2, a2);
114
+ }
115
+ c2((n2 = n2.apply(e3, t3 || [])).next());
116
+ });
117
+ }, a = this && this.__generator || function(e3, t3) {
118
+ var r2, n2, o2, i2, s2 = { label: 0, sent: function() {
119
+ if (1 & o2[0]) throw o2[1];
120
+ return o2[1];
121
+ }, trys: [], ops: [] };
122
+ return i2 = { next: a2(0), throw: a2(1), return: a2(2) }, "function" == typeof Symbol && (i2[Symbol.iterator] = function() {
123
+ return this;
124
+ }), i2;
125
+ function a2(a3) {
126
+ return function(c2) {
127
+ return (function(a4) {
128
+ if (r2) throw new TypeError("Generator is already executing.");
129
+ for (; i2 && (i2 = 0, a4[0] && (s2 = 0)), s2; ) try {
130
+ if (r2 = 1, n2 && (o2 = 2 & a4[0] ? n2.return : a4[0] ? n2.throw || ((o2 = n2.return) && o2.call(n2), 0) : n2.next) && !(o2 = o2.call(n2, a4[1])).done) return o2;
131
+ switch (n2 = 0, o2 && (a4 = [2 & a4[0], o2.value]), a4[0]) {
132
+ case 0:
133
+ case 1:
134
+ o2 = a4;
135
+ break;
136
+ case 4:
137
+ return s2.label++, { value: a4[1], done: false };
138
+ case 5:
139
+ s2.label++, n2 = a4[1], a4 = [0];
140
+ continue;
141
+ case 7:
142
+ a4 = s2.ops.pop(), s2.trys.pop();
143
+ continue;
144
+ default:
145
+ if (!((o2 = (o2 = s2.trys).length > 0 && o2[o2.length - 1]) || 6 !== a4[0] && 2 !== a4[0])) {
146
+ s2 = 0;
147
+ continue;
148
+ }
149
+ if (3 === a4[0] && (!o2 || a4[1] > o2[0] && a4[1] < o2[3])) {
150
+ s2.label = a4[1];
151
+ break;
152
+ }
153
+ if (6 === a4[0] && s2.label < o2[1]) {
154
+ s2.label = o2[1], o2 = a4;
155
+ break;
156
+ }
157
+ if (o2 && s2.label < o2[2]) {
158
+ s2.label = o2[2], s2.ops.push(a4);
159
+ break;
160
+ }
161
+ o2[2] && s2.ops.pop(), s2.trys.pop();
162
+ continue;
163
+ }
164
+ a4 = t3.call(e3, s2);
165
+ } catch (e4) {
166
+ a4 = [6, e4], n2 = 0;
167
+ } finally {
168
+ r2 = o2 = 0;
169
+ }
170
+ if (5 & a4[0]) throw a4[1];
171
+ return { value: a4[0] ? a4[1] : void 0, done: true };
172
+ })([a3, c2]);
173
+ };
174
+ }
175
+ };
176
+ Object.defineProperty(t2, "__esModule", { value: true }), t2.EventManager = void 0;
177
+ var c = r(834), u = r(706), d = r(450), f = r(897), l = r(628), h = r(768), g = r(610), p = r(399), v = r(574), E = (function() {
178
+ function e3(e4, t3) {
179
+ if (void 0 === t3 && (t3 = {}), this.requestMessageHandlers = /* @__PURE__ */ new Map(), this.responseMessageHandlers = /* @__PURE__ */ new Map(), !e4) throw new Error((0, l.getErrorMessage)(d.ERROR_MESSAGES.common.channelIdRequired));
180
+ this.config = new u.Config(), this.config.replace(n(n({}, t3), { channelId: e4 })), this.logger = new l.Logger(this.config), this.postMessage = new f.PostMessage(this.logger, this.config), this.handleIncomingMessage = this.handleIncomingMessage.bind(this), this.send = this.send.bind(this), this.on = this.on.bind(this), this.unregisterEvent = this.unregisterEvent.bind(this);
181
+ var r2 = (0, p.getWindow)();
182
+ r2 ? r2.addEventListener("message", this.handleIncomingMessage) : this.logger.debug((0, l.getErrorMessage)(d.ERROR_MESSAGES.common.windowNotFound));
183
+ }
184
+ return e3.prototype.handleIncomingMessage = function(e4) {
185
+ return s(this, void 0, void 0, function() {
186
+ var t3, r2, n2, o2, i2, s2, u2, f2, h2, g2, p2, E2, y = this;
187
+ return a(this, function(a2) {
188
+ if (t3 = e4.data, r2 = t3.type, n2 = t3.channel, o2 = t3.payload, i2 = t3.eventManager, s2 = t3.metadata, u2 = t3.error, i2 !== d.EVENT_MANAGER_NAME || n2 !== this.config.get("channelId")) return [2];
189
+ switch (f2 = s2.hash, h2 = s2.nature) {
190
+ case v.EditorPostMessageNature.REQUEST:
191
+ return this.logger.debug("REQUEST received", e4.data), this.config.get("targetWindow").closed && this.logger.error((0, l.getErrorMessage)(d.ERROR_MESSAGES.common.windowClosed)), this.postMessage.sendAck({ type: r2, hash: f2 }), this.requestMessageHandlers.has(r2) ? (g2 = this.requestMessageHandlers.get(r2).handler, p2 = { data: o2 }, [2, c.ZalgoPromise.all([c.ZalgoPromise.try(function() {
192
+ return g2(p2);
193
+ }).then(function(e5) {
194
+ y.postMessage.sendResponse({ type: r2, hash: f2, payload: e5, error: void 0 });
195
+ }).catch(function(e5) {
196
+ y.logger.error((0, l.getErrorMessage)(d.ERROR_MESSAGES.receiveEvent.codeReturnedError), e5);
197
+ })])]) : (this.logger.debug((0, l.getErrorMessage)(d.ERROR_MESSAGES.receiveEvent.noRequestListenerFound(r2))), this.postMessage.sendResponse({ type: r2, hash: f2, payload: void 0, error: { code: d.ERROR_CODES.receiveEvent.noRequestListenerFound, message: (0, l.getErrorMessage)(d.ERROR_MESSAGES.receiveEvent.noRequestListenerFound(r2)) } }), [2]);
198
+ case v.EditorPostMessageNature.RESPONSE:
199
+ if (this.logger.debug("RESPONSE received", e4.data), !this.responseMessageHandlers.has(f2)) return this.logger.error((0, l.getErrorMessage)(d.ERROR_MESSAGES.receiveEvent.noResponseListenerFound(f2))), [2];
200
+ E2 = this.responseMessageHandlers.get(f2), u2 ? E2.promise.reject(u2) : E2.promise.resolve(o2);
201
+ break;
202
+ case v.EditorPostMessageNature.ACK:
203
+ if (this.logger.debug("ACK received", e4.data), !this.responseMessageHandlers.has(f2)) return this.logger.error((0, l.getErrorMessage)(d.ERROR_MESSAGES.receiveEvent.noAckListenerFound(f2))), [2];
204
+ (E2 = this.responseMessageHandlers.get(f2)).hasReceivedAck = true;
205
+ break;
206
+ default:
207
+ this.logger.error((0, l.getErrorMessage)(d.ERROR_MESSAGES.receiveEvent.unknownNature(h2)), e4.data);
208
+ }
209
+ return [2];
210
+ });
211
+ });
212
+ }, e3.prototype.send = function(e4, t3) {
213
+ return s(this, void 0, void 0, function() {
214
+ var r2, n2, o2, i2, s2, u2 = this;
215
+ return a(this, function(a2) {
216
+ return r2 = new c.ZalgoPromise(), n2 = (0, g.uniqueId)(e4), o2 = { type: e4, promise: r2, hasCancelled: false, hasReceivedAck: false }, this.responseMessageHandlers.set(n2, o2), i2 = 1e3, s2 = (0, h.safeInterval)(function() {
217
+ return u2.config.get("targetWindow").closed ? r2.reject(new Error((0, l.getErrorMessage)(d.ERROR_MESSAGES.common.windowClosed))) : (i2 = Math.max(i2 - d.RESPONSE_CYCLE, 0), !o2.hasReceivedAck && i2 <= 0 ? r2.reject((0, l.getErrorMessage)(d.ERROR_MESSAGES.sendEvent.noAckReceived)) : void 0);
218
+ }, d.RESPONSE_CYCLE), r2.finally(function() {
219
+ u2.responseMessageHandlers.delete(n2), s2.cancel();
220
+ }).catch(function(e5) {
221
+ u2.logger.debug((0, l.getErrorMessage)(d.ERROR_MESSAGES.sendEvent.receiverReturnedError), e5);
222
+ }), this.postMessage.sendRequest({ type: e4, hash: n2, error: void 0, payload: t3 }), [2, r2];
223
+ });
224
+ });
225
+ }, e3.prototype.on = function(e4, t3) {
226
+ var r2 = this;
227
+ this.requestMessageHandlers.has(e4) && this.logger.error((0, l.getErrorMessage)(d.ERROR_MESSAGES.registerEvent.eventAlreadyRegistered(e4)));
228
+ var n2 = { handler: t3 };
229
+ return this.requestMessageHandlers.set(e4, n2), { unregister: function() {
230
+ r2.unregisterEvent(e4);
231
+ } };
232
+ }, e3.prototype.unregisterEvent = function(e4) {
233
+ this.requestMessageHandlers.has(e4) ? (this.logger.debug("Unregistering event", e4), this.requestMessageHandlers.delete(e4)) : this.logger.error((0, l.getErrorMessage)(d.ERROR_MESSAGES.unregisterEvent.eventDoesNotExist(e4)));
234
+ }, e3.prototype.updateConfig = function(e4) {
235
+ this.config.replace(e4);
236
+ }, e3.prototype.destroy = function(e4) {
237
+ var t3;
238
+ this.requestMessageHandlers.clear(), this.responseMessageHandlers.clear(), (null == e4 ? void 0 : e4.soft) || null === (t3 = (0, p.getWindow)()) || void 0 === t3 || t3.removeEventListener("message", this.handleIncomingMessage);
239
+ }, e3;
240
+ })();
241
+ t2.EventManager = E, i(r(574), t2);
242
+ }, 897(e2, t2, r) {
243
+ "use strict";
244
+ var n = this && this.__assign || function() {
245
+ return n = Object.assign || function(e3) {
246
+ for (var t3, r2 = 1, n2 = arguments.length; r2 < n2; r2++) for (var o2 in t3 = arguments[r2]) Object.prototype.hasOwnProperty.call(t3, o2) && (e3[o2] = t3[o2]);
247
+ return e3;
248
+ }, n.apply(this, arguments);
249
+ };
250
+ Object.defineProperty(t2, "__esModule", { value: true }), t2.PostMessage = void 0;
251
+ var o = r(574), i = (function() {
252
+ function e3(e4, t3) {
253
+ this.logger = e4, this.sendResponse = this.sendResponse.bind(this), this.sendRequest = this.sendRequest.bind(this), this.sendAck = this.sendAck.bind(this), this.getMessage = this.getMessage.bind(this), this.config = t3.getAll();
254
+ }
255
+ return e3.prototype.sendRequest = function(e4) {
256
+ var t3 = n(n({}, e4), { nature: o.EditorPostMessageNature.REQUEST });
257
+ this.logger.debug("Sending REQUEST", t3);
258
+ var r2 = this.getMessage(t3);
259
+ this.config.targetWindow.postMessage(r2, this.config.targetOrigin);
260
+ }, e3.prototype.sendResponse = function(e4) {
261
+ var t3 = n(n({}, e4), { nature: o.EditorPostMessageNature.RESPONSE });
262
+ this.logger.debug("Sending RESPONSE", t3);
263
+ var r2 = this.getMessage(t3);
264
+ this.config.targetWindow.postMessage(r2, this.config.targetOrigin);
265
+ }, e3.prototype.sendAck = function(e4) {
266
+ var t3 = n(n({}, e4), { payload: void 0, error: void 0, nature: o.EditorPostMessageNature.ACK });
267
+ this.logger.debug("Sending ACK", t3);
268
+ var r2 = this.getMessage(t3);
269
+ this.config.targetWindow.postMessage(r2, this.config.targetOrigin);
270
+ }, e3.prototype.getMessage = function(e4) {
271
+ var t3 = e4.nature, r2 = e4.hash, n2 = e4.payload, o2 = e4.type, i2 = e4.error;
272
+ return { eventManager: "contentstack-adv-post-message", metadata: { hash: r2, nature: t3 }, channel: this.config.channelId, error: i2, payload: n2, type: o2 };
273
+ }, e3;
274
+ })();
275
+ t2.PostMessage = i;
276
+ }, 255(e2, t2) {
277
+ "use strict";
278
+ Object.defineProperty(t2, "__esModule", { value: true });
279
+ }, 884(e2, t2) {
280
+ "use strict";
281
+ Object.defineProperty(t2, "__esModule", { value: true });
282
+ }, 574(e2, t2, r) {
283
+ "use strict";
284
+ var n = this && this.__createBinding || (Object.create ? function(e3, t3, r2, n2) {
285
+ void 0 === n2 && (n2 = r2);
286
+ var o2 = Object.getOwnPropertyDescriptor(t3, r2);
287
+ o2 && !("get" in o2 ? !t3.__esModule : o2.writable || o2.configurable) || (o2 = { enumerable: true, get: function() {
288
+ return t3[r2];
289
+ } }), Object.defineProperty(e3, n2, o2);
290
+ } : function(e3, t3, r2, n2) {
291
+ void 0 === n2 && (n2 = r2), e3[n2] = t3[r2];
292
+ }), o = this && this.__exportStar || function(e3, t3) {
293
+ for (var r2 in e3) "default" === r2 || Object.prototype.hasOwnProperty.call(t3, r2) || n(t3, e3, r2);
294
+ };
295
+ Object.defineProperty(t2, "__esModule", { value: true }), o(r(884), t2), o(r(145), t2), o(r(255), t2);
296
+ }, 145(e2, t2) {
297
+ "use strict";
298
+ var r;
299
+ Object.defineProperty(t2, "__esModule", { value: true }), t2.EditorPostMessageNature = void 0, (function(e3) {
300
+ e3.ACK = "ACK", e3.RESPONSE = "RESPONSE", e3.REQUEST = "REQUEST";
301
+ })(r || (t2.EditorPostMessageNature = r = {}));
302
+ }, 628(e2, t2, r) {
303
+ "use strict";
304
+ var n = this && this.__spreadArray || function(e3, t3, r2) {
305
+ if (r2 || 2 === arguments.length) for (var n2, o2 = 0, i2 = t3.length; o2 < i2; o2++) !n2 && o2 in t3 || (n2 || (n2 = Array.prototype.slice.call(t3, 0, o2)), n2[o2] = t3[o2]);
306
+ return e3.concat(n2 || Array.prototype.slice.call(t3));
307
+ };
308
+ Object.defineProperty(t2, "__esModule", { value: true }), t2.getErrorMessage = t2.Logger = void 0;
309
+ var o = r(450), i = (function() {
310
+ function e3(e4) {
311
+ this.config = e4, this.prefix = o.EVENT_MANAGER_NAME, this.log = this.log.bind(this), this.info = this.info.bind(this), this.debug = this.debug.bind(this), this.error = this.error.bind(this);
312
+ }
313
+ return e3.prototype.log = function() {
314
+ for (var e4 = [], t3 = 0; t3 < arguments.length; t3++) e4[t3] = arguments[t3];
315
+ console.log.apply(console, n([this.prefix], e4, false));
316
+ }, e3.prototype.info = function() {
317
+ for (var e4 = [], t3 = 0; t3 < arguments.length; t3++) e4[t3] = arguments[t3];
318
+ console.info.apply(console, n([this.prefix], e4, false));
319
+ }, e3.prototype.debug = function() {
320
+ for (var e4 = [], t3 = 0; t3 < arguments.length; t3++) e4[t3] = arguments[t3];
321
+ this.config.get("debug") && console.debug.apply(console, n(n([this.prefix, "DEBUG:"], e4, false), [this.getDebugOptions()], false));
322
+ }, e3.prototype.error = function() {
323
+ for (var e4 = [], t3 = 0; t3 < arguments.length; t3++) e4[t3] = arguments[t3];
324
+ this.config.get("suppressErrors") || console.error.apply(console, n([this.prefix], e4, false));
325
+ }, e3.prototype.getDebugOptions = function() {
326
+ return { targetOrigin: this.config.get("targetOrigin"), targetWindow: this.config.get("targetWindow") };
327
+ }, e3;
328
+ })();
329
+ t2.Logger = i, t2.getErrorMessage = function(e3) {
330
+ return o.EVENT_MANAGER_NAME + ": " + e3;
331
+ };
332
+ }, 768(e2, t2) {
333
+ "use strict";
334
+ Object.defineProperty(t2, "__esModule", { value: true }), t2.safeInterval = void 0, t2.safeInterval = function(e3, t3) {
335
+ var r;
336
+ return (function n() {
337
+ r = setTimeout(function() {
338
+ e3(), n();
339
+ }, t3);
340
+ })(), { cancel: function() {
341
+ clearTimeout(r);
342
+ } };
343
+ };
344
+ }, 610(e2, t2) {
345
+ "use strict";
346
+ Object.defineProperty(t2, "__esModule", { value: true }), t2.uniqueId = void 0, t2.uniqueId = function(e3) {
347
+ var t3 = ("undefined" != typeof crypto && "function" == typeof crypto.randomUUID ? crypto.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(e4) {
348
+ var t4 = 16 * Math.random() | 0;
349
+ return ("x" === e4 ? t4 : 3 & t4 | 8).toString(16);
350
+ })).split("-")[0];
351
+ return e3 ? "".concat(e3, "-").concat(t3) : t3;
352
+ };
353
+ }, 399(e2, t2) {
354
+ "use strict";
355
+ Object.defineProperty(t2, "__esModule", { value: true }), t2.getWindow = void 0, t2.getWindow = function() {
356
+ return "undefined" != typeof window ? window : null;
357
+ };
358
+ }, 994(e2) {
359
+ "undefined" != typeof self && self, e2.exports = (function(e3) {
360
+ var t2 = {};
361
+ function r(n) {
362
+ if (t2[n]) return t2[n].exports;
363
+ var o = t2[n] = { i: n, l: false, exports: {} };
364
+ return e3[n].call(o.exports, o, o.exports, r), o.l = true, o.exports;
365
+ }
366
+ return r.m = e3, r.c = t2, r.d = function(e4, t3, n) {
367
+ r.o(e4, t3) || Object.defineProperty(e4, t3, { enumerable: true, get: n });
368
+ }, r.r = function(e4) {
369
+ "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(e4, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(e4, "__esModule", { value: true });
370
+ }, r.t = function(e4, t3) {
371
+ if (1 & t3 && (e4 = r(e4)), 8 & t3) return e4;
372
+ if (4 & t3 && "object" == typeof e4 && e4 && e4.__esModule) return e4;
373
+ var n = /* @__PURE__ */ Object.create(null);
374
+ if (r.r(n), Object.defineProperty(n, "default", { enumerable: true, value: e4 }), 2 & t3 && "string" != typeof e4) for (var o in e4) r.d(n, o, function(t4) {
375
+ return e4[t4];
376
+ }.bind(null, o));
377
+ return n;
378
+ }, r.n = function(e4) {
379
+ var t3 = e4 && e4.__esModule ? function() {
380
+ return e4.default;
381
+ } : function() {
382
+ return e4;
383
+ };
384
+ return r.d(t3, "a", t3), t3;
385
+ }, r.o = function(e4, t3) {
386
+ return {}.hasOwnProperty.call(e4, t3);
387
+ }, r.p = "", r(r.s = 0);
388
+ })([function(e3, t2, r) {
389
+ "use strict";
390
+ function n(e4) {
391
+ try {
392
+ if (!e4) return false;
393
+ if ("undefined" != typeof Promise && e4 instanceof Promise) return true;
394
+ if ("undefined" != typeof window && "function" == typeof window.Window && e4 instanceof window.Window) return false;
395
+ if ("undefined" != typeof window && "function" == typeof window.constructor && e4 instanceof window.constructor) return false;
396
+ var t3 = {}.toString;
397
+ if (t3) {
398
+ var r2 = t3.call(e4);
399
+ if ("[object Window]" === r2 || "[object global]" === r2 || "[object DOMWindow]" === r2) return false;
400
+ }
401
+ if ("function" == typeof e4.then) return true;
402
+ } catch (e5) {
403
+ return false;
404
+ }
405
+ return false;
406
+ }
407
+ r.r(t2), r.d(t2, "ZalgoPromise", function() {
408
+ return f;
409
+ });
410
+ var o, i = [], s = [], a = 0;
411
+ function c() {
412
+ if (!a && o) {
413
+ var e4 = o;
414
+ o = null, e4.resolve();
415
+ }
416
+ }
417
+ function u() {
418
+ a += 1;
419
+ }
420
+ function d() {
421
+ a -= 1, c();
422
+ }
423
+ var f = (function() {
424
+ function e4(e5) {
425
+ var t4 = this;
426
+ if (this.resolved = void 0, this.rejected = void 0, this.errorHandled = void 0, this.value = void 0, this.error = void 0, this.handlers = void 0, this.dispatching = void 0, this.stack = void 0, this.resolved = false, this.rejected = false, this.errorHandled = false, this.handlers = [], e5) {
427
+ var r2, n2, o2 = false, i2 = false, s2 = false;
428
+ u();
429
+ try {
430
+ e5(function(e6) {
431
+ s2 ? t4.resolve(e6) : (o2 = true, r2 = e6);
432
+ }, function(e6) {
433
+ s2 ? t4.reject(e6) : (i2 = true, n2 = e6);
434
+ });
435
+ } catch (e6) {
436
+ return d(), void this.reject(e6);
437
+ }
438
+ d(), s2 = true, o2 ? this.resolve(r2) : i2 && this.reject(n2);
439
+ }
440
+ }
441
+ var t3 = e4.prototype;
442
+ return t3.resolve = function(e5) {
443
+ if (this.resolved || this.rejected) return this;
444
+ if (n(e5)) throw new Error("Can not resolve promise with another promise");
445
+ return this.resolved = true, this.value = e5, this.dispatch(), this;
446
+ }, t3.reject = function(e5) {
447
+ var t4 = this;
448
+ if (this.resolved || this.rejected) return this;
449
+ if (n(e5)) throw new Error("Can not reject promise with another promise");
450
+ if (!e5) {
451
+ var r2 = e5 && "function" == typeof e5.toString ? e5.toString() : {}.toString.call(e5);
452
+ e5 = new Error("Expected reject to be called with Error, got " + r2);
453
+ }
454
+ return this.rejected = true, this.error = e5, this.errorHandled || setTimeout(function() {
455
+ t4.errorHandled || (function(e6, t5) {
456
+ if (-1 === i.indexOf(e6)) {
457
+ i.push(e6), setTimeout(function() {
458
+ throw e6;
459
+ }, 1);
460
+ for (var r3 = 0; r3 < s.length; r3++) s[r3](e6, t5);
461
+ }
462
+ })(e5, t4);
463
+ }, 1), this.dispatch(), this;
464
+ }, t3.asyncReject = function(e5) {
465
+ return this.errorHandled = true, this.reject(e5), this;
466
+ }, t3.dispatch = function() {
467
+ var t4 = this.resolved, r2 = this.rejected, o2 = this.handlers;
468
+ if (!this.dispatching && (t4 || r2)) {
469
+ this.dispatching = true, u();
470
+ for (var i2 = function(e5, t5) {
471
+ return e5.then(function(e6) {
472
+ t5.resolve(e6);
473
+ }, function(e6) {
474
+ t5.reject(e6);
475
+ });
476
+ }, s2 = 0; s2 < o2.length; s2++) {
477
+ var a2 = o2[s2], c2 = a2.onSuccess, f2 = a2.onError, l = a2.promise, h = void 0;
478
+ if (t4) try {
479
+ h = c2 ? c2(this.value) : this.value;
480
+ } catch (e5) {
481
+ l.reject(e5);
482
+ continue;
483
+ }
484
+ else if (r2) {
485
+ if (!f2) {
486
+ l.reject(this.error);
487
+ continue;
488
+ }
489
+ try {
490
+ h = f2(this.error);
491
+ } catch (e5) {
492
+ l.reject(e5);
493
+ continue;
494
+ }
495
+ }
496
+ if (h instanceof e4 && (h.resolved || h.rejected)) {
497
+ var g = h;
498
+ g.resolved ? l.resolve(g.value) : l.reject(g.error), g.errorHandled = true;
499
+ } else n(h) ? h instanceof e4 && (h.resolved || h.rejected) ? h.resolved ? l.resolve(h.value) : l.reject(h.error) : i2(h, l) : l.resolve(h);
500
+ }
501
+ o2.length = 0, this.dispatching = false, d();
502
+ }
503
+ }, t3.then = function(t4, r2) {
504
+ if (t4 && "function" != typeof t4 && !t4.call) throw new Error("Promise.then expected a function for success handler");
505
+ if (r2 && "function" != typeof r2 && !r2.call) throw new Error("Promise.then expected a function for error handler");
506
+ var n2 = new e4();
507
+ return this.handlers.push({ promise: n2, onSuccess: t4, onError: r2 }), this.errorHandled = true, this.dispatch(), n2;
508
+ }, t3.catch = function(e5) {
509
+ return this.then(void 0, e5);
510
+ }, t3.finally = function(t4) {
511
+ if (t4 && "function" != typeof t4 && !t4.call) throw new Error("Promise.finally expected a function");
512
+ return this.then(function(r2) {
513
+ return e4.try(t4).then(function() {
514
+ return r2;
515
+ });
516
+ }, function(r2) {
517
+ return e4.try(t4).then(function() {
518
+ throw r2;
519
+ });
520
+ });
521
+ }, t3.timeout = function(e5, t4) {
522
+ var r2 = this;
523
+ if (this.resolved || this.rejected) return this;
524
+ var n2 = setTimeout(function() {
525
+ r2.resolved || r2.rejected || r2.reject(t4 || new Error("Promise timed out after " + e5 + "ms"));
526
+ }, e5);
527
+ return this.then(function(e6) {
528
+ return clearTimeout(n2), e6;
529
+ });
530
+ }, t3.toPromise = function() {
531
+ if ("undefined" == typeof Promise) throw new TypeError("Could not find Promise");
532
+ return Promise.resolve(this);
533
+ }, t3.lazy = function() {
534
+ return this.errorHandled = true, this;
535
+ }, e4.resolve = function(t4) {
536
+ return t4 instanceof e4 ? t4 : n(t4) ? new e4(function(e5, r2) {
537
+ return t4.then(e5, r2);
538
+ }) : new e4().resolve(t4);
539
+ }, e4.reject = function(t4) {
540
+ return new e4().reject(t4);
541
+ }, e4.asyncReject = function(t4) {
542
+ return new e4().asyncReject(t4);
543
+ }, e4.all = function(t4) {
544
+ var r2 = new e4(), o2 = t4.length, i2 = [].slice();
545
+ if (!o2) return r2.resolve(i2), r2;
546
+ for (var s2 = function(e5, t5, n2) {
547
+ return t5.then(function(t6) {
548
+ i2[e5] = t6, 0 == (o2 -= 1) && r2.resolve(i2);
549
+ }, function(e6) {
550
+ n2.reject(e6);
551
+ });
552
+ }, a2 = 0; a2 < t4.length; a2++) {
553
+ var c2 = t4[a2];
554
+ if (c2 instanceof e4) {
555
+ if (c2.resolved) {
556
+ i2[a2] = c2.value, o2 -= 1;
557
+ continue;
558
+ }
559
+ } else if (!n(c2)) {
560
+ i2[a2] = c2, o2 -= 1;
561
+ continue;
562
+ }
563
+ s2(a2, e4.resolve(c2), r2);
564
+ }
565
+ return 0 === o2 && r2.resolve(i2), r2;
566
+ }, e4.hash = function(t4) {
567
+ var r2 = {}, o2 = [], i2 = function(e5) {
568
+ if (t4.hasOwnProperty(e5)) {
569
+ var i3 = t4[e5];
570
+ n(i3) ? o2.push(i3.then(function(t5) {
571
+ r2[e5] = t5;
572
+ })) : r2[e5] = i3;
573
+ }
574
+ };
575
+ for (var s2 in t4) i2(s2);
576
+ return e4.all(o2).then(function() {
577
+ return r2;
578
+ });
579
+ }, e4.map = function(t4, r2) {
580
+ return e4.all(t4.map(r2));
581
+ }, e4.onPossiblyUnhandledException = function(e5) {
582
+ return (function(e6) {
583
+ return s.push(e6), { cancel: function() {
584
+ s.splice(s.indexOf(e6), 1);
585
+ } };
586
+ })(e5);
587
+ }, e4.try = function(t4, r2, n2) {
588
+ if (t4 && "function" != typeof t4 && !t4.call) throw new Error("Promise.try expected a function");
589
+ var o2;
590
+ u();
591
+ try {
592
+ o2 = t4.apply(r2, n2 || []);
593
+ } catch (t5) {
594
+ return d(), e4.reject(t5);
595
+ }
596
+ return d(), e4.resolve(o2);
597
+ }, e4.delay = function(t4) {
598
+ return new e4(function(e5) {
599
+ setTimeout(e5, t4);
600
+ });
601
+ }, e4.isPromise = function(t4) {
602
+ return !!(t4 && t4 instanceof e4) || n(t4);
603
+ }, e4.flush = function() {
604
+ return t4 = o = o || new e4(), c(), t4;
605
+ var t4;
606
+ }, e4;
607
+ })();
608
+ }]);
609
+ }, 834(e2, t2, r) {
610
+ e2.exports = r(994);
611
+ } }, t = {}, (function r(n) {
612
+ var o = t[n];
613
+ if (void 0 !== o) return o.exports;
614
+ var i = t[n] = { exports: {} };
615
+ return e[n].call(i.exports, i, i.exports, r), i.exports;
616
+ })(156);
617
+ var e, t;
618
+ });
619
+ }
620
+ });
621
+
622
+ export {
623
+ require_dist
624
+ };
625
+ //# sourceMappingURL=chunk-HZF5SLJ7.js.map