@epam/ai-dial-chat-overlay 1.1.0-dev.9 → 1.1.0-dev.90
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.
- package/index.d.ts +2 -3
- package/index.d.ts.map +1 -1
- package/index.js +118 -79
- package/lib/ChatOverlay.d.ts +10 -2
- package/lib/ChatOverlay.d.ts.map +1 -1
- package/lib/ChatOverlayManager.d.ts +3 -7
- package/lib/ChatOverlayManager.d.ts.map +1 -1
- package/lib/internal/deferred-request.d.ts +3 -5
- package/lib/internal/deferred-request.d.ts.map +1 -1
- package/package.json +1 -4
- package/protocol/overlay-protocol.d.ts +380 -0
- package/protocol/overlay-protocol.d.ts.map +1 -0
- package/protocol.d.ts +2 -0
- package/protocol.d.ts.map +1 -0
package/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export { ChatOverlay } from './lib/ChatOverlay';
|
|
1
|
+
export { ChatOverlay, ChatOverlayRequestError } from './lib/ChatOverlay';
|
|
2
2
|
export { ChatOverlayManager, OverlayPosition } from './lib/ChatOverlayManager';
|
|
3
3
|
export type { ChatOverlayManagerOptions } from './lib/ChatOverlayManager';
|
|
4
|
-
export
|
|
5
|
-
export { OverlayEventType, OverlayFeature, OverlayRequestType, } from '@epam/ai-dial-chat-shared';
|
|
4
|
+
export * from './protocol';
|
|
6
5
|
//# sourceMappingURL=index.d.ts.map
|
package/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC/E,YAAY,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAC1E,cAAc,YAAY,CAAC"}
|
package/index.js
CHANGED
|
@@ -1,6 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
//#region src/protocol/overlay-protocol.ts
|
|
2
|
+
var e = "@DIAL_OVERLAY", t = /* @__PURE__ */ function(e) {
|
|
3
|
+
return e.GetMessages = "@DIAL_OVERLAY/GET_MESSAGES", e.SendMessage = "@DIAL_OVERLAY/SEND_MESSAGE", e.SetInputContent = "@DIAL_OVERLAY/SET_INPUT_CONTENT", e.SetSystemPrompt = "@DIAL_OVERLAY/SET_SYSTEM_PROMPT", e.SetTemperature = "@DIAL_OVERLAY/SET_TEMPERATURE", e.SetOverlayOptions = "@DIAL_OVERLAY/SET_OVERLAY_OPTIONS", e.GetConversations = "@DIAL_OVERLAY/GET_CONVERSATIONS", e.GetSelectedConversations = "@DIAL_OVERLAY/GET_SELECTED_CONVERSATIONS", e.SelectConversation = "@DIAL_OVERLAY/SELECT_CONVERSATION", e.CreateConversation = "@DIAL_OVERLAY/CREATE_CONVERSATION", e.CreateLocalConversation = "@DIAL_OVERLAY/CREATE_LOCAL_CONVERSATION", e.DeleteConversation = "@DIAL_OVERLAY/DELETE_CONVERSATION", e.RenameConversation = "@DIAL_OVERLAY/RENAME_CONVERSATION", e;
|
|
4
|
+
}({}), n = /* @__PURE__ */ function(e) {
|
|
5
|
+
return e.InitReady = "@DIAL_OVERLAY/INIT_READY", e.Ready = "@DIAL_OVERLAY/READY", e.ReadyToInteract = "@DIAL_OVERLAY/READY_TO_INTERACT", e.SelectedConversationLoaded = "@DIAL_OVERLAY/SELECTED_CONVERSATION_LOADED", e.GptStartGenerating = "@DIAL_OVERLAY/GPT_START_GENERATING", e.GptEndGenerating = "@DIAL_OVERLAY/GPT_END_GENERATING", e.StopGenerating = "@DIAL_OVERLAY/STOP_GENERATING", e.ConversationsUpdated = "@DIAL_OVERLAY/CONVERSATIONS_UPDATED", e;
|
|
6
|
+
}({}), r = /* @__PURE__ */ function(e) {
|
|
7
|
+
return e.CodeApps = "code-apps", e.CustomApplications = "custom-applications", e.HideCustomAppCreation = "hide-custom-app-creation", e.DisabledSend = "disabled-send", e.SkipFocusChatInputOnload = "skip-focus-chat-input-onload", e.DislikeComment = "dislike-comment", e.InputFiles = "input-files", e.Likes = "likes", e.LiveChatInteraction = "live-chat-interaction", e.DisallowChangeAgent = "disallow-change-agent", e.HideNewConversation = "hide-new-conversation", e.EmptyChatSettings = "empty-chat-settings", e.HideEmptyChatChangeAgent = "hide-empty-chat-change-agent", e.AttachmentsManager = "attachments-manager", e.ConversationsPanelToggle = "conversations-panel-toggle", e.ConversationsSection = "conversations-section", e.Header = "header", e.ShowConversationsSectionByDefault = "showConversationsSectionByDefault", e.Catalog = "catalog", e.CatalogHideMyApps = "catalog-hide-my-apps", e.CatalogTableView = "catalog-table-view", e.HideDeleteUserMessage = "hide-delete-user-message", e.HideEditUserMessage = "hide-edit-user-message", e.HideRegenerateAssistantMessage = "hide-regenerate-assistant-message", e.ConversationsPublishing = "conversations-publishing", e.ApplicationsSharing = "applications-sharing", e.ConversationsSharing = "conversations-sharing", e.ToolsetsSharing = "toolsets-sharing", e.Toolsets = "toolsets", e.CustomApps = "custom-apps", e.HideUserMenu = "hide-user-menu", e.HideUserSettings = "hide-user-settings", e.VoiceInput = "voice-input", e;
|
|
8
|
+
}({}), i = /* @__PURE__ */ function(e) {
|
|
9
|
+
return e.External = "external", e.SameWindow = "sameWindow", e;
|
|
10
|
+
}({}), a = /* @__PURE__ */ function(e) {
|
|
11
|
+
return e.ActiveConversationUnavailable = "ACTIVE_CONVERSATION_UNAVAILABLE", e.ConversationListUnavailable = "CONVERSATION_LIST_UNAVAILABLE", e.InvalidPayload = "INVALID_PAYLOAD", e.RequestExecutionFailed = "REQUEST_EXECUTION_FAILED", e;
|
|
12
|
+
}({}), o = (e) => {
|
|
13
|
+
if (typeof e != "object" || !e) return !1;
|
|
14
|
+
let n = e;
|
|
15
|
+
return typeof n.type == "string" && Object.values(t).includes(n.type) && typeof n.requestId == "string" && (!("expiresAt" in n) || typeof n.expiresAt == "number" && Number.isFinite(n.expiresAt));
|
|
16
|
+
}, s = (e) => {
|
|
17
|
+
if (typeof e != "object" || !e) return !1;
|
|
18
|
+
let n = e;
|
|
19
|
+
if (typeof n.type != "string" || typeof n.requestId != "string" || !Object.values(t).some((e) => n.type === `${e}/RESPONSE`)) return !1;
|
|
20
|
+
if (!("error" in n)) return !0;
|
|
21
|
+
let r = n.error;
|
|
22
|
+
return typeof r == "object" && !!r && typeof r.code == "string" && Object.values(a).includes(r.code) && typeof r.message == "string";
|
|
23
|
+
}, c = (e) => {
|
|
24
|
+
if (typeof e != "object" || !e) return !1;
|
|
25
|
+
let t = e;
|
|
26
|
+
return typeof t.type == "string" && Object.values(n).includes(t.type) && !("requestId" in t);
|
|
27
|
+
}, l = "<svg viewBox=\"0 0 50 50\" width=\"32\" height=\"32\" role=\"presentation\" aria-hidden=\"true\"><circle cx=\"25\" cy=\"25\" r=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"4\" stroke-linecap=\"round\" stroke-dasharray=\"31.4 31.4\"><animateTransform attributeName=\"transform\" type=\"rotate\" from=\"0 25 25\" to=\"360 25 25\" dur=\"1s\" repeatCount=\"indefinite\" /></circle></svg>", u = 0, d = () => (u += 1, `dial-overlay-${Date.now()}-${u}`), f = class {
|
|
28
|
+
requestType;
|
|
4
29
|
requestId;
|
|
5
30
|
responseType;
|
|
6
31
|
promise;
|
|
@@ -9,7 +34,7 @@ var c = "<svg viewBox=\"0 0 50 50\" width=\"32\" height=\"32\" role=\"presentati
|
|
|
9
34
|
settled = !1;
|
|
10
35
|
timeoutHandle;
|
|
11
36
|
constructor(e, t) {
|
|
12
|
-
this.requestId =
|
|
37
|
+
this.requestType = e, this.requestId = d(), this.responseType = `${e}/RESPONSE`, this.promise = new Promise((e, t) => {
|
|
13
38
|
this.resolveFn = e, this.rejectFn = t;
|
|
14
39
|
}), this.timeoutHandle = setTimeout(() => {
|
|
15
40
|
this.reject(/* @__PURE__ */ Error(`ChatOverlay: request "${e}" timed out after ${t}ms`));
|
|
@@ -24,9 +49,9 @@ var c = "<svg viewBox=\"0 0 50 50\" width=\"32\" height=\"32\" role=\"presentati
|
|
|
24
49
|
reject(e) {
|
|
25
50
|
this.settled || (this.settled = !0, clearTimeout(this.timeoutHandle), this.rejectFn(e));
|
|
26
51
|
}
|
|
27
|
-
},
|
|
52
|
+
}, p = (e, t) => {
|
|
28
53
|
Object.assign(e.style, t);
|
|
29
|
-
},
|
|
54
|
+
}, m = class {
|
|
30
55
|
promise;
|
|
31
56
|
resolveFn;
|
|
32
57
|
rejectFn;
|
|
@@ -42,24 +67,30 @@ var c = "<svg viewBox=\"0 0 50 50\" width=\"32\" height=\"32\" role=\"presentati
|
|
|
42
67
|
reject(e) {
|
|
43
68
|
this.settled || (this.settled = !0, this.rejectFn(e));
|
|
44
69
|
}
|
|
45
|
-
},
|
|
70
|
+
}, h = 1e4, g = "data-dial-overlay-loader", _ = class extends Error {
|
|
71
|
+
code;
|
|
72
|
+
requestType;
|
|
73
|
+
constructor(e, t) {
|
|
74
|
+
super(`ChatOverlay: request "${e}" failed [${t.code}]: ${t.message}`), this.name = "ChatOverlayRequestError", this.code = t.code, this.requestType = e;
|
|
75
|
+
}
|
|
76
|
+
}, v = (e) => {
|
|
46
77
|
if (typeof e != "string") return e;
|
|
47
78
|
let t = document.querySelector(e);
|
|
48
79
|
if (!t) throw Error(`ChatOverlay: no element matches selector "${e}"`);
|
|
49
80
|
return t;
|
|
50
|
-
},
|
|
81
|
+
}, y = (e) => {
|
|
51
82
|
let t = document.createElement("iframe");
|
|
52
83
|
t.src = e.domain, t.name = "overlay", t.setAttribute("aria-label", "DIAL Chat"), t.setAttribute("sandbox", "allow-same-origin allow-scripts allow-modals allow-forms allow-popups allow-downloads allow-popups-to-escape-sandbox");
|
|
53
84
|
let n = ["clipboard-write"];
|
|
54
|
-
return e.enabledFeatures?.includes(r.VoiceInput) && n.push("microphone"), t.setAttribute("allow", n.join("; ")),
|
|
85
|
+
return e.enabledFeatures?.includes(r.VoiceInput) && n.push("microphone"), t.setAttribute("allow", n.join("; ")), p(t, {
|
|
55
86
|
border: "none",
|
|
56
87
|
display: "block",
|
|
57
88
|
width: "100%",
|
|
58
89
|
height: "100%"
|
|
59
90
|
}), t;
|
|
60
|
-
},
|
|
91
|
+
}, b = (e) => {
|
|
61
92
|
let t = document.createElement("div");
|
|
62
|
-
return t.setAttribute(
|
|
93
|
+
return t.setAttribute(g, ""), t.innerHTML = e.loaderInnerHTML ?? l, p(t, {
|
|
63
94
|
position: "absolute",
|
|
64
95
|
inset: "0",
|
|
65
96
|
zIndex: "2",
|
|
@@ -69,14 +100,14 @@ var c = "<svg viewBox=\"0 0 50 50\" width=\"32\" height=\"32\" role=\"presentati
|
|
|
69
100
|
boxSizing: "border-box",
|
|
70
101
|
background: "#ffffff",
|
|
71
102
|
color: "#2764d9"
|
|
72
|
-
}), e.loaderClass && (t.className = e.loaderClass), e.loaderStyles &&
|
|
73
|
-
},
|
|
103
|
+
}), e.loaderClass && (t.className = e.loaderClass), e.loaderStyles && p(t, e.loaderStyles), t;
|
|
104
|
+
}, x = class {
|
|
74
105
|
root;
|
|
75
106
|
iframe;
|
|
76
107
|
loader;
|
|
77
108
|
options;
|
|
78
109
|
targetOrigin;
|
|
79
|
-
readyGate = new
|
|
110
|
+
readyGate = new m();
|
|
80
111
|
pendingRequests = /* @__PURE__ */ new Map();
|
|
81
112
|
eventSubscribers = /* @__PURE__ */ new Map();
|
|
82
113
|
messageListener = (e) => {
|
|
@@ -84,62 +115,62 @@ var c = "<svg viewBox=\"0 0 50 50\" width=\"32\" height=\"32\" role=\"presentati
|
|
|
84
115
|
};
|
|
85
116
|
isDestroyed = !1;
|
|
86
117
|
constructor(e, t) {
|
|
87
|
-
this.root =
|
|
118
|
+
this.root = v(e), this.options = { ...t }, this.targetOrigin = new URL(t.domain).origin, this.iframe = y(this.options), this.loader = b(this.options);
|
|
88
119
|
let n = window.getComputedStyle(this.root).position;
|
|
89
|
-
(n === "static" || n === "") &&
|
|
120
|
+
(n === "static" || n === "") && p(this.root, { position: "relative" }), this.root.appendChild(this.loader), this.root.appendChild(this.iframe), window.addEventListener("message", this.messageListener), this.readyGate.promise.catch(() => void 0);
|
|
90
121
|
}
|
|
91
122
|
ready() {
|
|
92
123
|
return this.readyGate.promise;
|
|
93
124
|
}
|
|
94
125
|
getMessages() {
|
|
95
|
-
return this.send(
|
|
126
|
+
return this.send(t.GetMessages);
|
|
96
127
|
}
|
|
97
128
|
sendMessage(e) {
|
|
98
|
-
let
|
|
99
|
-
return this.send(
|
|
129
|
+
let n = { content: e };
|
|
130
|
+
return this.send(t.SendMessage, n);
|
|
100
131
|
}
|
|
101
132
|
setInputContent(e) {
|
|
102
|
-
let
|
|
103
|
-
return this.send(
|
|
133
|
+
let n = { content: e };
|
|
134
|
+
return this.send(t.SetInputContent, n);
|
|
104
135
|
}
|
|
105
136
|
setSystemPrompt(e) {
|
|
106
|
-
let
|
|
107
|
-
return this.send(
|
|
137
|
+
let n = { systemPrompt: e };
|
|
138
|
+
return this.send(t.SetSystemPrompt, n);
|
|
108
139
|
}
|
|
109
140
|
setTemperature(e) {
|
|
110
|
-
let
|
|
111
|
-
return this.send(
|
|
141
|
+
let n = { temperature: e };
|
|
142
|
+
return this.send(t.SetTemperature, n);
|
|
112
143
|
}
|
|
113
144
|
getConversations() {
|
|
114
|
-
return this.send(
|
|
145
|
+
return this.send(t.GetConversations);
|
|
115
146
|
}
|
|
116
147
|
getSelectedConversations() {
|
|
117
|
-
return this.send(
|
|
148
|
+
return this.send(t.GetSelectedConversations);
|
|
118
149
|
}
|
|
119
150
|
selectConversation(e) {
|
|
120
|
-
let
|
|
121
|
-
return this.send(
|
|
151
|
+
let n = { id: e };
|
|
152
|
+
return this.send(t.SelectConversation, n);
|
|
122
153
|
}
|
|
123
154
|
createConversation(e) {
|
|
124
|
-
let
|
|
125
|
-
return this.send(
|
|
155
|
+
let n = { ...e };
|
|
156
|
+
return this.send(t.CreateConversation, n);
|
|
126
157
|
}
|
|
127
158
|
createLocalConversation() {
|
|
128
|
-
return this.send(
|
|
159
|
+
return this.send(t.CreateLocalConversation);
|
|
129
160
|
}
|
|
130
161
|
deleteConversation(e) {
|
|
131
|
-
let
|
|
132
|
-
return this.send(
|
|
162
|
+
let n = { id: e };
|
|
163
|
+
return this.send(t.DeleteConversation, n);
|
|
133
164
|
}
|
|
134
|
-
renameConversation(e,
|
|
135
|
-
let
|
|
165
|
+
renameConversation(e, n) {
|
|
166
|
+
let r = {
|
|
136
167
|
id: e,
|
|
137
|
-
newName:
|
|
168
|
+
newName: n
|
|
138
169
|
};
|
|
139
|
-
return this.send(
|
|
170
|
+
return this.send(t.RenameConversation, r);
|
|
140
171
|
}
|
|
141
172
|
setOverlayOptions(e) {
|
|
142
|
-
return this.options.theme = e.theme ?? this.options.theme, this.options.modelId = e.modelId ?? this.options.modelId, this.options.overlayConversationId = e.overlayConversationId ?? this.options.overlayConversationId, this.sendCurrentOverlayOptions();
|
|
173
|
+
return this.options.theme = e.theme ?? this.options.theme, this.options.modelId = e.modelId ?? this.options.modelId, this.options.overlayConversationId = e.overlayConversationId ?? this.options.overlayConversationId, this.options.enabledFeatures = e.enabledFeatures ?? this.options.enabledFeatures, Object.hasOwn(e, "auth") && (this.options.auth = e.auth), this.sendCurrentOverlayOptions();
|
|
143
174
|
}
|
|
144
175
|
subscribe(e, t) {
|
|
145
176
|
let n = this.eventSubscribers.get(e) ?? /* @__PURE__ */ new Set(), r = t;
|
|
@@ -162,14 +193,16 @@ var c = "<svg viewBox=\"0 0 50 50\" width=\"32\" height=\"32\" role=\"presentati
|
|
|
162
193
|
}
|
|
163
194
|
sendCurrentOverlayOptions() {
|
|
164
195
|
let e = { hostDomain: window.location.origin };
|
|
165
|
-
|
|
196
|
+
this.options.theme !== void 0 && (e.theme = this.options.theme), this.options.modelId !== void 0 && (e.modelId = this.options.modelId), this.options.overlayConversationId !== void 0 && (e.overlayConversationId = this.options.overlayConversationId), this.options.enabledFeatures !== void 0 && (e.enabledFeatures = this.options.enabledFeatures);
|
|
197
|
+
let n = this.options.auth?.providerUiModes;
|
|
198
|
+
return n !== void 0 && Object.keys(n).length > 0 && (e.authProviderUiModes = n), this.send(t.SetOverlayOptions, e, { bypassReadyGate: !0 });
|
|
166
199
|
}
|
|
167
200
|
send(e, t, n) {
|
|
168
201
|
return this.isDestroyed ? Promise.reject(/* @__PURE__ */ Error("ChatOverlay: instance was destroyed")) : n?.bypassReadyGate ? this.dispatchRequest(e, t) : this.readyGate.promise.then(() => this.dispatchRequest(e, t));
|
|
169
202
|
}
|
|
170
203
|
dispatchRequest(e, t) {
|
|
171
204
|
if (this.isDestroyed) return Promise.reject(/* @__PURE__ */ Error("ChatOverlay: instance was destroyed"));
|
|
172
|
-
let n = this.options.requestTimeout ??
|
|
205
|
+
let n = this.options.requestTimeout ?? h, r = new f(e, n);
|
|
173
206
|
this.pendingRequests.set(r.requestId, r), r.promise.finally(() => {
|
|
174
207
|
this.pendingRequests.delete(r.requestId);
|
|
175
208
|
}).catch(() => void 0);
|
|
@@ -188,15 +221,21 @@ var c = "<svg viewBox=\"0 0 50 50\" width=\"32\" height=\"32\" role=\"presentati
|
|
|
188
221
|
this.handleResponse(t);
|
|
189
222
|
return;
|
|
190
223
|
}
|
|
191
|
-
|
|
224
|
+
c(t) && this.handleEvent(t);
|
|
192
225
|
}
|
|
193
226
|
handleResponse(e) {
|
|
194
227
|
let t = this.pendingRequests.get(e.requestId);
|
|
195
|
-
!t || !t.matches(e.type, e.requestId)
|
|
228
|
+
if (!(!t || !t.matches(e.type, e.requestId))) {
|
|
229
|
+
if (this.pendingRequests.delete(e.requestId), e.error) {
|
|
230
|
+
t.reject(new _(t.requestType, e.error));
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
t.resolve(e.payload);
|
|
234
|
+
}
|
|
196
235
|
}
|
|
197
236
|
handleEvent(e) {
|
|
198
|
-
let
|
|
199
|
-
|
|
237
|
+
let t = e.type;
|
|
238
|
+
t === n.Ready && this.sendCurrentOverlayOptions().catch(() => void 0), t === (this.options.loaderHideEvent ?? n.Ready) && this.hideLoader(), t === n.ReadyToInteract && this.readyGate.resolve(!0), this.notifySubscribers(t, e.payload);
|
|
200
239
|
}
|
|
201
240
|
hideLoader() {
|
|
202
241
|
this.loader.style.display = "none";
|
|
@@ -204,41 +243,41 @@ var c = "<svg viewBox=\"0 0 50 50\" width=\"32\" height=\"32\" role=\"presentati
|
|
|
204
243
|
notifySubscribers(e, t) {
|
|
205
244
|
this.eventSubscribers.get(e)?.forEach((e) => e(t));
|
|
206
245
|
}
|
|
207
|
-
},
|
|
208
|
-
if (document.getElementById(
|
|
246
|
+
}, S = 768, C = 380, w = 600, T = 999999, E = "24px", D = "<svg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" aria-hidden=\"true\" focusable=\"false\"><path fill=\"currentColor\" d=\"M4 4h16v12H7l-3 3V4z\"/></svg>", O = "<svg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" aria-hidden=\"true\" focusable=\"false\"><path fill=\"currentColor\" d=\"M18.3 5.71 12 12.01l-6.3-6.3-1.4 1.41 6.29 6.29-6.29 6.29 1.4 1.41 6.3-6.3 6.3 6.3 1.4-1.41-6.29-6.29 6.29-6.29z\"/></svg>", k = "<svg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" aria-hidden=\"true\" focusable=\"false\"><path fill=\"currentColor\" d=\"M4 4h6v2H6v4H4V4zm10 0h6v6h-2V6h-4V4zM4 14h2v4h4v2H4v-6zm14 0h2v6h-6v-2h4v-4z\"/></svg>", A = "dial-overlay-manager-styles", j = () => {
|
|
247
|
+
if (document.getElementById(A)) return;
|
|
209
248
|
let e = document.createElement("style");
|
|
210
|
-
e.id =
|
|
211
|
-
},
|
|
249
|
+
e.id = A, e.textContent = "\n.dial-overlay-btn {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 48px;\n height: 48px;\n border: none;\n border-radius: 999px;\n cursor: pointer;\n background: #2764d9;\n color: #ffffff;\n}\n.dial-overlay-btn:hover,\n.dial-overlay-btn:focus-visible {\n background: #1d4fb8;\n outline: 2px solid #1d4fb8;\n outline-offset: 2px;\n}\n", document.head.appendChild(e);
|
|
250
|
+
}, M = (e, t) => {
|
|
212
251
|
let n = document.createElement("button");
|
|
213
252
|
return n.type = "button", n.className = "dial-overlay-btn", n.setAttribute("aria-label", e), n.innerHTML = t, n;
|
|
214
|
-
},
|
|
253
|
+
}, N = (e) => typeof e == "number" ? `${e}px` : e, P = /* @__PURE__ */ function(e) {
|
|
215
254
|
return e.LeftBottom = "left-bottom", e.LeftTop = "left-top", e.RightBottom = "right-bottom", e.RightTop = "right-top", e;
|
|
216
|
-
}({}),
|
|
255
|
+
}({}), F = {
|
|
217
256
|
"right-bottom": {
|
|
218
|
-
insetInlineEnd:
|
|
219
|
-
insetBlockEnd:
|
|
257
|
+
insetInlineEnd: E,
|
|
258
|
+
insetBlockEnd: E,
|
|
220
259
|
insetInlineStart: "auto",
|
|
221
260
|
insetBlockStart: "auto"
|
|
222
261
|
},
|
|
223
262
|
"right-top": {
|
|
224
|
-
insetInlineEnd:
|
|
225
|
-
insetBlockStart:
|
|
263
|
+
insetInlineEnd: E,
|
|
264
|
+
insetBlockStart: E,
|
|
226
265
|
insetInlineStart: "auto",
|
|
227
266
|
insetBlockEnd: "auto"
|
|
228
267
|
},
|
|
229
268
|
"left-bottom": {
|
|
230
|
-
insetInlineStart:
|
|
231
|
-
insetBlockEnd:
|
|
269
|
+
insetInlineStart: E,
|
|
270
|
+
insetBlockEnd: E,
|
|
232
271
|
insetInlineEnd: "auto",
|
|
233
272
|
insetBlockStart: "auto"
|
|
234
273
|
},
|
|
235
274
|
"left-top": {
|
|
236
|
-
insetInlineStart:
|
|
237
|
-
insetBlockStart:
|
|
275
|
+
insetInlineStart: E,
|
|
276
|
+
insetBlockStart: E,
|
|
238
277
|
insetInlineEnd: "auto",
|
|
239
278
|
insetBlockEnd: "auto"
|
|
240
279
|
}
|
|
241
|
-
},
|
|
280
|
+
}, I = class {
|
|
242
281
|
overlays = /* @__PURE__ */ new Map();
|
|
243
282
|
abortController = new AbortController();
|
|
244
283
|
isDestroyed = !1;
|
|
@@ -250,9 +289,9 @@ var c = "<svg viewBox=\"0 0 50 50\" width=\"32\" height=\"32\" role=\"presentati
|
|
|
250
289
|
}
|
|
251
290
|
createOverlay(e) {
|
|
252
291
|
if (this.overlays.has(e.overlayId)) throw Error(`ChatOverlayManager: overlay "${e.overlayId}" already exists`);
|
|
253
|
-
|
|
292
|
+
j();
|
|
254
293
|
let t = document.createElement("div");
|
|
255
|
-
t.setAttribute("data-dial-overlay-container", e.overlayId),
|
|
294
|
+
t.setAttribute("data-dial-overlay-container", e.overlayId), p(t, {
|
|
256
295
|
display: "flex",
|
|
257
296
|
flexDirection: "column",
|
|
258
297
|
overflow: "hidden",
|
|
@@ -261,24 +300,24 @@ var c = "<svg viewBox=\"0 0 50 50\" width=\"32\" height=\"32\" role=\"presentati
|
|
|
261
300
|
background: "#ffffff"
|
|
262
301
|
});
|
|
263
302
|
let n = document.createElement("div");
|
|
264
|
-
|
|
303
|
+
p(n, {
|
|
265
304
|
display: "flex",
|
|
266
305
|
justifyContent: "flex-end",
|
|
267
306
|
gap: "8px",
|
|
268
307
|
padding: "8px"
|
|
269
308
|
});
|
|
270
|
-
let r =
|
|
309
|
+
let r = M(e.closeButtonAriaLabel ?? "Collapse", O);
|
|
271
310
|
n.appendChild(r);
|
|
272
311
|
let i;
|
|
273
|
-
e.allowFullscreen && (i =
|
|
312
|
+
e.allowFullscreen && (i = M(e.fullscreenButtonAriaLabel ?? "Open full screen", k), n.appendChild(i));
|
|
274
313
|
let a = document.createElement("div");
|
|
275
|
-
|
|
314
|
+
p(a, {
|
|
276
315
|
flex: "1",
|
|
277
316
|
minHeight: "0"
|
|
278
317
|
}), t.appendChild(n), t.appendChild(a), document.body.appendChild(t);
|
|
279
|
-
let o = new
|
|
318
|
+
let o = new x(a, e);
|
|
280
319
|
e.allowFullscreen && o.allowFullscreen();
|
|
281
|
-
let s =
|
|
320
|
+
let s = M(e.toggleButtonAriaLabel ?? "Open chat", D);
|
|
282
321
|
document.body.appendChild(s);
|
|
283
322
|
let c = {
|
|
284
323
|
overlay: o,
|
|
@@ -363,16 +402,16 @@ var c = "<svg viewBox=\"0 0 50 50\" width=\"32\" height=\"32\" role=\"presentati
|
|
|
363
402
|
return t;
|
|
364
403
|
}
|
|
365
404
|
applyLayout(e) {
|
|
366
|
-
let { options: t, container: n, toggleButton: r } = e, i = t.position ?? "right-bottom", a = String(t.zIndex ??
|
|
367
|
-
if (
|
|
405
|
+
let { options: t, container: n, toggleButton: r } = e, i = t.position ?? "right-bottom", a = String(t.zIndex ?? T);
|
|
406
|
+
if (p(r, {
|
|
368
407
|
position: "fixed",
|
|
369
408
|
zIndex: a,
|
|
370
|
-
...
|
|
371
|
-
}),
|
|
409
|
+
...F[i]
|
|
410
|
+
}), p(n, {
|
|
372
411
|
position: "fixed",
|
|
373
412
|
zIndex: a
|
|
374
|
-
}), window.innerWidth <=
|
|
375
|
-
|
|
413
|
+
}), window.innerWidth <= S) {
|
|
414
|
+
p(n, {
|
|
376
415
|
insetInlineStart: "0",
|
|
377
416
|
insetInlineEnd: "0",
|
|
378
417
|
insetBlockStart: "0",
|
|
@@ -383,12 +422,12 @@ var c = "<svg viewBox=\"0 0 50 50\" width=\"32\" height=\"32\" role=\"presentati
|
|
|
383
422
|
});
|
|
384
423
|
return;
|
|
385
424
|
}
|
|
386
|
-
|
|
387
|
-
width:
|
|
388
|
-
height:
|
|
389
|
-
...
|
|
425
|
+
p(n, {
|
|
426
|
+
width: N(t.width ?? C),
|
|
427
|
+
height: N(t.height ?? w),
|
|
428
|
+
...F[i]
|
|
390
429
|
});
|
|
391
430
|
}
|
|
392
431
|
};
|
|
393
432
|
//#endregion
|
|
394
|
-
export {
|
|
433
|
+
export { x as ChatOverlay, I as ChatOverlayManager, _ as ChatOverlayRequestError, e as DIAL_OVERLAY_NAMESPACE, i as OverlayAuthUiMode, n as OverlayEventType, r as OverlayFeature, P as OverlayPosition, a as OverlayRequestErrorCode, t as OverlayRequestType, c as isOverlayMessageEvent, o as isOverlayMessageRequest, s as isOverlayMessageResponse };
|
package/lib/ChatOverlay.d.ts
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import { ChatOverlayOptions, CreateConversationResponse, CreateLocalConversationResponse, DeleteConversationResponse, GetConversationsResponse, GetMessagesResponse, GetSelectedConversationsResponse, OverlayEventType, RenameConversationResponse, SelectConversationResponse, SendMessageResponse, SetOverlayOptionsResponse, SetSystemPromptResponse, SetTemperatureResponse } from '
|
|
1
|
+
import { ChatOverlayOptions, CreateConversationResponse, CreateLocalConversationResponse, DeleteConversationResponse, GetConversationsResponse, GetMessagesResponse, GetSelectedConversationsResponse, OverlayRequestError, OverlayEventType, RenameConversationResponse, SelectConversationResponse, SendMessageResponse, SetOverlayOptionsResponse, SetSystemPromptResponse, SetTemperatureResponse } from '../protocol';
|
|
2
|
+
/** Error returned by the embedded chat for a well-formed overlay request. */
|
|
3
|
+
export declare class ChatOverlayRequestError extends Error {
|
|
4
|
+
/** Stable embedded-chat error code. */
|
|
5
|
+
readonly code: OverlayRequestError['code'];
|
|
6
|
+
/** Request type that failed. */
|
|
7
|
+
readonly requestType: string;
|
|
8
|
+
constructor(requestType: string, error: OverlayRequestError);
|
|
9
|
+
}
|
|
2
10
|
/**
|
|
3
11
|
* A single embedded DIAL Chat iframe controlled over the `@DIAL_OVERLAY`
|
|
4
12
|
* `postMessage` protocol. Construct with a root element (or selector) and
|
|
@@ -55,7 +63,7 @@ export declare class ChatOverlay {
|
|
|
55
63
|
* embedded app. Bypasses the readiness gate — it is also how the initial
|
|
56
64
|
* handshake options exchange happens, before `ready()` resolves.
|
|
57
65
|
*/
|
|
58
|
-
setOverlayOptions(options: Partial<Pick<ChatOverlayOptions, 'theme' | 'modelId' | 'overlayConversationId'>>): Promise<SetOverlayOptionsResponse>;
|
|
66
|
+
setOverlayOptions(options: Partial<Pick<ChatOverlayOptions, 'theme' | 'modelId' | 'overlayConversationId' | 'enabledFeatures' | 'auth'>>): Promise<SetOverlayOptionsResponse>;
|
|
59
67
|
/** Registers `callback` to be invoked with each `eventType` event's payload. */
|
|
60
68
|
subscribe<T = unknown>(eventType: OverlayEventType, callback: (payload: T) => void): () => void;
|
|
61
69
|
/** Grants the iframe permission to enter fullscreen. */
|
package/lib/ChatOverlay.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatOverlay.d.ts","sourceRoot":"","sources":["../../src/lib/ChatOverlay.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EAEvB,KAAK,0BAA0B,EAC/B,KAAK,+BAA+B,EAEpC,KAAK,0BAA0B,EAC/B,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,EACxB,KAAK,gCAAgC,EAIrC,gBAAgB,EAIhB,KAAK,0BAA0B,EAE/B,KAAK,0BAA0B,EAE/B,KAAK,mBAAmB,EAGxB,KAAK,yBAAyB,EAE9B,KAAK,uBAAuB,EAE5B,KAAK,sBAAsB,EAG5B,MAAM,
|
|
1
|
+
{"version":3,"file":"ChatOverlay.d.ts","sourceRoot":"","sources":["../../src/lib/ChatOverlay.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EAEvB,KAAK,0BAA0B,EAC/B,KAAK,+BAA+B,EAEpC,KAAK,0BAA0B,EAC/B,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,EACxB,KAAK,gCAAgC,EAIrC,KAAK,mBAAmB,EACxB,gBAAgB,EAIhB,KAAK,0BAA0B,EAE/B,KAAK,0BAA0B,EAE/B,KAAK,mBAAmB,EAGxB,KAAK,yBAAyB,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I;IAkBZ,OAAO,CAAC,eAAe;IA+BvB,OAAO,CAAC,aAAa;IAcrB,OAAO,CAAC,cAAc;IAetB,OAAO,CAAC,WAAW;IAmBnB,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,iBAAiB;CAO1B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChatOverlayOptions, CreateConversationResponse, CreateLocalConversationResponse, DeleteConversationResponse, GetConversationsResponse, GetMessagesResponse, GetSelectedConversationsResponse, OverlayEventType, RenameConversationResponse, SelectConversationResponse, SendMessageResponse, SetOverlayOptionsResponse, SetSystemPromptResponse, SetTemperatureResponse } from '
|
|
1
|
+
import { ChatOverlayOptions, CreateConversationResponse, CreateLocalConversationResponse, DeleteConversationResponse, GetConversationsResponse, GetMessagesResponse, GetSelectedConversationsResponse, OverlayEventType, RenameConversationResponse, SelectConversationResponse, SendMessageResponse, SetOverlayOptionsResponse, SetSystemPromptResponse, SetTemperatureResponse } from '../protocol';
|
|
2
2
|
/** Fixed-position placement for a `ChatOverlayManager`-created overlay. */
|
|
3
3
|
export declare enum OverlayPosition {
|
|
4
4
|
/** Anchored to the start (left in LTR) edge, bottom corner. */
|
|
@@ -31,11 +31,7 @@ export interface ChatOverlayManagerOptions extends ChatOverlayOptions {
|
|
|
31
31
|
/** Accessible name for the fullscreen button. Defaults to `'Open full screen'`. */
|
|
32
32
|
fullscreenButtonAriaLabel?: string;
|
|
33
33
|
}
|
|
34
|
-
/**
|
|
35
|
-
* Creates and positions one or more `ChatOverlay` instances behind
|
|
36
|
-
* fixed-position toggle/close/(optional) fullscreen chrome, keyed by
|
|
37
|
-
* `overlayId`.
|
|
38
|
-
*/
|
|
34
|
+
/** Creates and positions one or more `ChatOverlay` instances behind fixed-position toggle/close/fullscreen chrome, keyed by `overlayId`. */
|
|
39
35
|
export declare class ChatOverlayManager {
|
|
40
36
|
private readonly overlays;
|
|
41
37
|
private readonly abortController;
|
|
@@ -79,7 +75,7 @@ export declare class ChatOverlayManager {
|
|
|
79
75
|
/** Renames the conversation matching `id` to `newName` for `overlayId`. */
|
|
80
76
|
renameConversation(overlayId: string, id: string, newName: string): Promise<RenameConversationResponse>;
|
|
81
77
|
/** Updates theme/model/conversation options for `overlayId`. */
|
|
82
|
-
setOverlayOptions(overlayId: string, options: Partial<Pick<ChatOverlayOptions, 'theme' | 'modelId' | 'overlayConversationId'>>): Promise<SetOverlayOptionsResponse>;
|
|
78
|
+
setOverlayOptions(overlayId: string, options: Partial<Pick<ChatOverlayOptions, 'theme' | 'modelId' | 'overlayConversationId' | 'enabledFeatures'>>): Promise<SetOverlayOptionsResponse>;
|
|
83
79
|
/** Subscribes to an event from `overlayId`'s embedded app. */
|
|
84
80
|
subscribe<T = unknown>(overlayId: string, eventType: OverlayEventType, callback: (payload: T) => void): () => void;
|
|
85
81
|
/** Requests fullscreen for `overlayId`. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatOverlayManager.d.ts","sourceRoot":"","sources":["../../src/lib/ChatOverlayManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,0BAA0B,EAC1B,+BAA+B,EAC/B,0BAA0B,EAC1B,wBAAwB,EACxB,mBAAmB,EACnB,gCAAgC,EAChC,gBAAgB,EAChB,0BAA0B,EAC1B,0BAA0B,EAC1B,mBAAmB,EACnB,yBAAyB,EACzB,uBAAuB,EACvB,sBAAsB,EACvB,MAAM,
|
|
1
|
+
{"version":3,"file":"ChatOverlayManager.d.ts","sourceRoot":"","sources":["../../src/lib/ChatOverlayManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,0BAA0B,EAC1B,+BAA+B,EAC/B,0BAA0B,EAC1B,wBAAwB,EACxB,mBAAmB,EACnB,gCAAgC,EAChC,gBAAgB,EAChB,0BAA0B,EAC1B,0BAA0B,EAC1B,mBAAmB,EACnB,yBAAyB,EACzB,uBAAuB,EACvB,sBAAsB,EACvB,MAAM,aAAa,C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B,SAAS,EAAE,MAAM,EACjB,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,0BAA0B,CAAC;IAItC,gEAAgE;IAChE,iBAAiB,CACf,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,OAAO,CACd,IAAI,CACF,kBAAkB,EAClB,OAAO,GAAG,SAAS,GAAG,uBAAuB,GAAG,iBAAiB,CAClE,CACF,GACA,OAAO,CAAC,yBAAyB,CAAC;IAIrC,8DAA8D;IAC9D,SAAS,CAAC,CAAC,GAAG,OAAO,EACnB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,gBAAgB,EAC3B,QAAQ,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,IAAI,GAC7B,MAAM,IAAI;IAIb,2CAA2C;IAC3C,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIhD,wFAAwF;IACxF,OAAO,IAAI,IAAI;IAcf,OAAO,CAAC,QAAQ;IAQhB,OAAO,CAAC,WAAW;CAgCpB"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A single outstanding request: owns its `requestId`, races its response
|
|
3
|
-
* promise against a per-request timeout, and rejects with a descriptive
|
|
4
|
-
* error naming the request type and timeout when unanswered in time.
|
|
5
|
-
*/
|
|
1
|
+
/** A single outstanding overlay request: owns its `requestId` and resolves/rejects when the matching response arrives or the timeout elapses. */
|
|
6
2
|
export declare class DeferredRequest<T = unknown> {
|
|
3
|
+
/** Exact request type sent to the embedded app. */
|
|
4
|
+
readonly requestType: string;
|
|
7
5
|
/** Unique id used to match this request to its response message. */
|
|
8
6
|
readonly requestId: string;
|
|
9
7
|
/** Exact response type expected for this request. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deferred-request.d.ts","sourceRoot":"","sources":["../../../src/lib/internal/deferred-request.ts"],"names":[],"mappings":"AAOA
|
|
1
|
+
{"version":3,"file":"deferred-request.d.ts","sourceRoot":"","sources":["../../../src/lib/internal/deferred-request.ts"],"names":[],"mappings":"AAOA,iJAAiJ;AACjJ,qBAAa,eAAe,CAAC,CAAC,GAAG,OAAO;IACtC,mDAAmD;IACnD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,oEAAoE;IACpE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,qDAAqD;IACrD,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,yEAAyE;IACzE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IAE7B,OAAO,CAAC,SAAS,CAAsB;IACvC,OAAO,CAAC,QAAQ,CAA8B;IAC9C,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAgC;gBAElD,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;IAiBlD,uEAAuE;IACvE,OAAO,CAAC,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO;IAIzD,mEAAmE;IACnE,OAAO,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI;IASvB,mEAAmE;IACnE,MAAM,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI;CAQ/B"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@epam/ai-dial-chat-overlay",
|
|
3
3
|
"description": "Embeddable postMessage-based ChatOverlay/ChatOverlayManager widget for hosting a DIAL Chat instance inside a third-party page",
|
|
4
|
-
"version": "1.1.0-dev.
|
|
4
|
+
"version": "1.1.0-dev.90",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./index.js",
|
|
@@ -15,9 +15,6 @@
|
|
|
15
15
|
"default": "./index.js"
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
|
-
"peerDependencies": {
|
|
19
|
-
"@epam/ai-dial-chat-shared": "1.1.0-dev.9"
|
|
20
|
-
},
|
|
21
18
|
"repository": {
|
|
22
19
|
"type": "git",
|
|
23
20
|
"url": "git+https://github.com/epam/ai-dial-chat.git",
|
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
/** Namespace prefix for every `@DIAL_OVERLAY` postMessage type string. */
|
|
2
|
+
export declare const DIAL_OVERLAY_NAMESPACE = "@DIAL_OVERLAY";
|
|
3
|
+
/** Request message types the host can send to the embedded app. */
|
|
4
|
+
export declare enum OverlayRequestType {
|
|
5
|
+
/** Fetch the active conversation's messages. */
|
|
6
|
+
GetMessages = "@DIAL_OVERLAY/GET_MESSAGES",
|
|
7
|
+
/** Send a new message in the active conversation. */
|
|
8
|
+
SendMessage = "@DIAL_OVERLAY/SEND_MESSAGE",
|
|
9
|
+
/** Set the current text content of the message input. */
|
|
10
|
+
SetInputContent = "@DIAL_OVERLAY/SET_INPUT_CONTENT",
|
|
11
|
+
/** Set the active conversation's system prompt. */
|
|
12
|
+
SetSystemPrompt = "@DIAL_OVERLAY/SET_SYSTEM_PROMPT",
|
|
13
|
+
/** Set the active conversation's temperature. */
|
|
14
|
+
SetTemperature = "@DIAL_OVERLAY/SET_TEMPERATURE",
|
|
15
|
+
/** Set host-provided options (theme, model, conversation, host domain). */
|
|
16
|
+
SetOverlayOptions = "@DIAL_OVERLAY/SET_OVERLAY_OPTIONS",
|
|
17
|
+
/** Fetch the current user's conversation list. */
|
|
18
|
+
GetConversations = "@DIAL_OVERLAY/GET_CONVERSATIONS",
|
|
19
|
+
/** Fetch the currently displayed (active) conversation(s). */
|
|
20
|
+
GetSelectedConversations = "@DIAL_OVERLAY/GET_SELECTED_CONVERSATIONS",
|
|
21
|
+
/** Navigate to and load a specific conversation by id. */
|
|
22
|
+
SelectConversation = "@DIAL_OVERLAY/SELECT_CONVERSATION",
|
|
23
|
+
/** Create a new conversation, persisting immediately if a first message is given. */
|
|
24
|
+
CreateConversation = "@DIAL_OVERLAY/CREATE_CONVERSATION",
|
|
25
|
+
/** Open the conversation composer without persisting anything. */
|
|
26
|
+
CreateLocalConversation = "@DIAL_OVERLAY/CREATE_LOCAL_CONVERSATION",
|
|
27
|
+
/** Delete a conversation by id. */
|
|
28
|
+
DeleteConversation = "@DIAL_OVERLAY/DELETE_CONVERSATION",
|
|
29
|
+
/** Rename a conversation by id. */
|
|
30
|
+
RenameConversation = "@DIAL_OVERLAY/RENAME_CONVERSATION"
|
|
31
|
+
}
|
|
32
|
+
/** Event message types the embedded app sends to the host. */
|
|
33
|
+
export declare enum OverlayEventType {
|
|
34
|
+
/** Sent once, immediately, before any host identity is known. */
|
|
35
|
+
InitReady = "@DIAL_OVERLAY/INIT_READY",
|
|
36
|
+
/** Sent once, after auth/model-load state resolves. */
|
|
37
|
+
Ready = "@DIAL_OVERLAY/READY",
|
|
38
|
+
/** Sent once, after the active conversation has been selected/loaded for the first time. */
|
|
39
|
+
ReadyToInteract = "@DIAL_OVERLAY/READY_TO_INTERACT",
|
|
40
|
+
/** Sent whenever the app finishes loading a conversation (initial load or navigation). */
|
|
41
|
+
SelectedConversationLoaded = "@DIAL_OVERLAY/SELECTED_CONVERSATION_LOADED",
|
|
42
|
+
/** Sent when a generation starts for the active conversation. */
|
|
43
|
+
GptStartGenerating = "@DIAL_OVERLAY/GPT_START_GENERATING",
|
|
44
|
+
/** Sent when a generation completes for the active conversation. */
|
|
45
|
+
GptEndGenerating = "@DIAL_OVERLAY/GPT_END_GENERATING",
|
|
46
|
+
/** Sent when a user (or host) stops an in-flight generation. */
|
|
47
|
+
StopGenerating = "@DIAL_OVERLAY/STOP_GENERATING",
|
|
48
|
+
/** Sent whenever the app's conversation list changes. */
|
|
49
|
+
ConversationsUpdated = "@DIAL_OVERLAY/CONVERSATIONS_UPDATED"
|
|
50
|
+
}
|
|
51
|
+
/** Optional embed-time features a host can opt into via `ChatOverlayOptions.enabledFeatures`. */
|
|
52
|
+
export declare enum OverlayFeature {
|
|
53
|
+
/** Enables the "Add app" menu's Code Apps entry. */
|
|
54
|
+
CodeApps = "code-apps",
|
|
55
|
+
/** Enables the "Add app" menu's custom-application creation entry point. */
|
|
56
|
+
CustomApplications = "custom-applications",
|
|
57
|
+
/** Hides the "Custom app" creation entry in the "Add app" menu. */
|
|
58
|
+
HideCustomAppCreation = "hide-custom-app-creation",
|
|
59
|
+
/** Disables the send action on the chat input without removing the button. */
|
|
60
|
+
DisabledSend = "disabled-send",
|
|
61
|
+
/** Suppresses the chat input's auto-focus effect on load. */
|
|
62
|
+
SkipFocusChatInputOnload = "skip-focus-chat-input-onload",
|
|
63
|
+
/** Enables the comment field in the negative-feedback (dislike) modal. */
|
|
64
|
+
DislikeComment = "dislike-comment",
|
|
65
|
+
/** Enables attaching files to a message via the conversation input. */
|
|
66
|
+
InputFiles = "input-files",
|
|
67
|
+
/** Enables like/dislike actions on assistant messages. */
|
|
68
|
+
Likes = "likes",
|
|
69
|
+
/** Enables the live-chat-interaction sign-in UI affordance. */
|
|
70
|
+
LiveChatInteraction = "live-chat-interaction",
|
|
71
|
+
/** Restricts (disables) changing the selected agent/model on the conversation top bar. */
|
|
72
|
+
DisallowChangeAgent = "disallow-change-agent",
|
|
73
|
+
/** Hides the new-conversation controls in the header/layout. */
|
|
74
|
+
HideNewConversation = "hide-new-conversation",
|
|
75
|
+
/** Enables the empty-chat (new conversation composer) settings UI. */
|
|
76
|
+
EmptyChatSettings = "empty-chat-settings",
|
|
77
|
+
/** Hides the model selector on the empty-chat composer screen. */
|
|
78
|
+
HideEmptyChatChangeAgent = "hide-empty-chat-change-agent",
|
|
79
|
+
/** Enables the attachments-manager (`AttachmentCanvasProvider`) mount. */
|
|
80
|
+
AttachmentsManager = "attachments-manager",
|
|
81
|
+
/** Enables the conversations-panel toggle button. */
|
|
82
|
+
ConversationsPanelToggle = "conversations-panel-toggle",
|
|
83
|
+
/** Enables the conversations sidebar section. */
|
|
84
|
+
ConversationsSection = "conversations-section",
|
|
85
|
+
/** Enables the app header. */
|
|
86
|
+
Header = "header",
|
|
87
|
+
/** Makes the conversations sidebar section open by default. */
|
|
88
|
+
ShowConversationsSectionByDefault = "showConversationsSectionByDefault",
|
|
89
|
+
/** Enables the catalog (`/catalog`) route. */
|
|
90
|
+
Catalog = "catalog",
|
|
91
|
+
/** Restricts the catalog to hide the current user's own/shared-with-me apps. */
|
|
92
|
+
CatalogHideMyApps = "catalog-hide-my-apps",
|
|
93
|
+
/** Makes the catalog's table view the initial default (instead of grid). */
|
|
94
|
+
CatalogTableView = "catalog-table-view",
|
|
95
|
+
/** Hides the delete action on a user's own messages. */
|
|
96
|
+
HideDeleteUserMessage = "hide-delete-user-message",
|
|
97
|
+
/** Hides the edit action on a user's own messages. */
|
|
98
|
+
HideEditUserMessage = "hide-edit-user-message",
|
|
99
|
+
/** Hides the regenerate action on assistant messages. */
|
|
100
|
+
HideRegenerateAssistantMessage = "hide-regenerate-assistant-message",
|
|
101
|
+
/** Enables the conversation-publishing entry point. */
|
|
102
|
+
ConversationsPublishing = "conversations-publishing",
|
|
103
|
+
/** Enables the application-sharing entry point. */
|
|
104
|
+
ApplicationsSharing = "applications-sharing",
|
|
105
|
+
/** Enables the conversation-sharing entry point. */
|
|
106
|
+
ConversationsSharing = "conversations-sharing",
|
|
107
|
+
/** Enables the toolset-sharing entry point. */
|
|
108
|
+
ToolsetsSharing = "toolsets-sharing",
|
|
109
|
+
/** Enables toolsets functionality. */
|
|
110
|
+
Toolsets = "toolsets",
|
|
111
|
+
/** Enables the custom-app creation entry in the catalog. */
|
|
112
|
+
CustomApps = "custom-apps",
|
|
113
|
+
/** Hides the user avatar/menu button in the header. */
|
|
114
|
+
HideUserMenu = "hide-user-menu",
|
|
115
|
+
/** Hides the settings entry in the user menu. */
|
|
116
|
+
HideUserSettings = "hide-user-settings",
|
|
117
|
+
/** Enables the `microphone` permission on the iframe's `allow` attribute for voice input. */
|
|
118
|
+
VoiceInput = "voice-input"
|
|
119
|
+
}
|
|
120
|
+
/** Controls how an overlay starts authentication for a configured provider. */
|
|
121
|
+
export declare enum OverlayAuthUiMode {
|
|
122
|
+
/** Opens authentication in a separate browser window or tab. */
|
|
123
|
+
External = "external",
|
|
124
|
+
/** Navigates the embedded overlay window through authentication. */
|
|
125
|
+
SameWindow = "sameWindow"
|
|
126
|
+
}
|
|
127
|
+
/** Machine-readable reasons why an overlay request could not be completed. */
|
|
128
|
+
export declare enum OverlayRequestErrorCode {
|
|
129
|
+
/** The method requires an open conversation, but the composer is currently shown. */
|
|
130
|
+
ActiveConversationUnavailable = "ACTIVE_CONVERSATION_UNAVAILABLE",
|
|
131
|
+
/** The method requires the conversation-list integration, but it is not available. */
|
|
132
|
+
ConversationListUnavailable = "CONVERSATION_LIST_UNAVAILABLE",
|
|
133
|
+
/** The request payload does not match the method contract. */
|
|
134
|
+
InvalidPayload = "INVALID_PAYLOAD",
|
|
135
|
+
/** The embedded chat failed while executing the requested operation. */
|
|
136
|
+
RequestExecutionFailed = "REQUEST_EXECUTION_FAILED"
|
|
137
|
+
}
|
|
138
|
+
/** Structured failure returned for an overlay request. */
|
|
139
|
+
export interface OverlayRequestError {
|
|
140
|
+
/** Stable code suitable for programmatic handling. */
|
|
141
|
+
code: OverlayRequestErrorCode;
|
|
142
|
+
/** Human-readable explanation suitable for logs and diagnostics. */
|
|
143
|
+
message: string;
|
|
144
|
+
}
|
|
145
|
+
/** Minimal message shape carried in overlay protocol payloads. */
|
|
146
|
+
export interface OverlayChatMessage {
|
|
147
|
+
/** Message id. */
|
|
148
|
+
id: string;
|
|
149
|
+
/** Author role, e.g. `'user'`, `'assistant'`, or `'system'`. */
|
|
150
|
+
role: string;
|
|
151
|
+
/** Message text content. */
|
|
152
|
+
content: string;
|
|
153
|
+
}
|
|
154
|
+
/** Host-agnostic conversation projection for the overlay protocol. */
|
|
155
|
+
export interface OverlayConversation {
|
|
156
|
+
/** Conversation id. */
|
|
157
|
+
id: string;
|
|
158
|
+
/** Conversation title. */
|
|
159
|
+
title: string;
|
|
160
|
+
/** Epoch milliseconds of the conversation's last update. */
|
|
161
|
+
updatedAt: number;
|
|
162
|
+
/** Whether the conversation is pinned. */
|
|
163
|
+
isPinned: boolean;
|
|
164
|
+
/** Whether the current user has read-only access. */
|
|
165
|
+
isReadonly: boolean;
|
|
166
|
+
/** Whether the conversation was shared with the current user. */
|
|
167
|
+
sharedWithMe: boolean;
|
|
168
|
+
/** Whether the conversation was published with the current user. */
|
|
169
|
+
publishedWithMe: boolean;
|
|
170
|
+
}
|
|
171
|
+
/** Error signal carried by conversation-list method responses. */
|
|
172
|
+
export interface OverlayConversationError {
|
|
173
|
+
/** `NOT_FOUND` for an unknown/inaccessible id, `FORBIDDEN` for a read-only/shared-without-write-access conversation, `INVALID_ARGUMENT` for a rejected value (e.g. blank rename). */
|
|
174
|
+
code: 'NOT_FOUND' | 'FORBIDDEN' | 'INVALID_ARGUMENT';
|
|
175
|
+
/** Human-readable description of the failure. */
|
|
176
|
+
message: string;
|
|
177
|
+
}
|
|
178
|
+
/** Options passed to `ChatOverlay`'s constructor. */
|
|
179
|
+
export interface ChatOverlayOptions {
|
|
180
|
+
/** Full URL of the chat app instance to embed (origin + optional path). */
|
|
181
|
+
domain: string;
|
|
182
|
+
/** Milliseconds to wait for a request's response before rejecting. Defaults to `10000`. */
|
|
183
|
+
requestTimeout?: number;
|
|
184
|
+
/** Inline CSS properties applied to the loader element while it is visible. */
|
|
185
|
+
loaderStyles?: Record<string, string>;
|
|
186
|
+
/** CSS class applied to the loader element. */
|
|
187
|
+
loaderClass?: string;
|
|
188
|
+
/** Custom HTML rendered inside the loader element, replacing the default spinner. */
|
|
189
|
+
loaderInnerHTML?: string;
|
|
190
|
+
/** Event whose receipt hides the loader. Defaults to `OverlayEventType.Ready`. */
|
|
191
|
+
loaderHideEvent?: OverlayEventType;
|
|
192
|
+
/** Embed-time features to enable, e.g. microphone access for voice input. */
|
|
193
|
+
enabledFeatures?: OverlayFeature[];
|
|
194
|
+
/** Theme name applied to the embedded app. */
|
|
195
|
+
theme?: string;
|
|
196
|
+
/** Deployment/model id to select in the embedded app. */
|
|
197
|
+
modelId?: string;
|
|
198
|
+
/** Conversation id the embedded app should load and display. */
|
|
199
|
+
overlayConversationId?: string;
|
|
200
|
+
/** Per-provider authentication UI behavior configured by the embedding host. */
|
|
201
|
+
auth?: {
|
|
202
|
+
providerUiModes?: Record<string, OverlayAuthUiMode>;
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
/** Payload of a `SET_OVERLAY_OPTIONS` request. */
|
|
206
|
+
export interface SetOverlayOptionsPayload {
|
|
207
|
+
/** Origin of the host page, used by the app to target responses/events. */
|
|
208
|
+
hostDomain: string;
|
|
209
|
+
/** Theme name to apply, if provided. */
|
|
210
|
+
theme?: string;
|
|
211
|
+
/** Deployment/model id to select, if provided. */
|
|
212
|
+
modelId?: string;
|
|
213
|
+
/** Conversation id to navigate to and load, if provided. */
|
|
214
|
+
overlayConversationId?: string;
|
|
215
|
+
/**
|
|
216
|
+
* UI-feature keys that replace (not merge with) the app's current effective
|
|
217
|
+
* UI-feature set, if provided. Array only — no comma-separated-string form.
|
|
218
|
+
*/
|
|
219
|
+
enabledFeatures?: string[];
|
|
220
|
+
/** Opaque per-provider authentication UI modes supplied by the host. */
|
|
221
|
+
authProviderUiModes?: Record<string, string>;
|
|
222
|
+
}
|
|
223
|
+
/** Payload of a `SEND_MESSAGE` request. */
|
|
224
|
+
export interface SendMessagePayload {
|
|
225
|
+
/** Text content of the message to send. */
|
|
226
|
+
content: string;
|
|
227
|
+
}
|
|
228
|
+
/** Payload of a `SET_INPUT_CONTENT` request. */
|
|
229
|
+
export interface SetInputContentPayload {
|
|
230
|
+
/** Text content to set in the message input. */
|
|
231
|
+
content: string;
|
|
232
|
+
}
|
|
233
|
+
/** Payload of a `SET_SYSTEM_PROMPT` request. */
|
|
234
|
+
export interface SetSystemPromptPayload {
|
|
235
|
+
/** System prompt to persist on the active conversation. */
|
|
236
|
+
systemPrompt: string;
|
|
237
|
+
}
|
|
238
|
+
/** Payload of a `SET_TEMPERATURE` request. */
|
|
239
|
+
export interface SetTemperaturePayload {
|
|
240
|
+
/** Temperature value to persist on the active conversation. */
|
|
241
|
+
temperature: number;
|
|
242
|
+
}
|
|
243
|
+
/** Payload of a `SELECT_CONVERSATION` request. */
|
|
244
|
+
export interface SelectConversationPayload {
|
|
245
|
+
/** Id of the conversation to select. */
|
|
246
|
+
id: string;
|
|
247
|
+
}
|
|
248
|
+
/** Payload of a `DELETE_CONVERSATION` request. */
|
|
249
|
+
export interface DeleteConversationPayload {
|
|
250
|
+
/** Id of the conversation to delete. */
|
|
251
|
+
id: string;
|
|
252
|
+
}
|
|
253
|
+
/** Payload of a `RENAME_CONVERSATION` request. */
|
|
254
|
+
export interface RenameConversationPayload {
|
|
255
|
+
/** Id of the conversation to rename. */
|
|
256
|
+
id: string;
|
|
257
|
+
/** New title for the conversation. */
|
|
258
|
+
newName: string;
|
|
259
|
+
}
|
|
260
|
+
/** Payload of a `CREATE_CONVERSATION` request. */
|
|
261
|
+
export interface CreateConversationPayload {
|
|
262
|
+
/** Deployment/model id to create the conversation with, if given. */
|
|
263
|
+
deploymentId?: string;
|
|
264
|
+
/** Initial message to persist immediately. Omitted/blank opens the composer instead. */
|
|
265
|
+
firstMessage?: string;
|
|
266
|
+
}
|
|
267
|
+
/** Response payload of a `GET_MESSAGES` request. */
|
|
268
|
+
export interface GetMessagesResponse {
|
|
269
|
+
/** Messages in the active conversation. */
|
|
270
|
+
messages: OverlayChatMessage[];
|
|
271
|
+
}
|
|
272
|
+
/** Response payload of a `SEND_MESSAGE` request. */
|
|
273
|
+
export interface SendMessageResponse {
|
|
274
|
+
/** Messages in the active conversation after the send. */
|
|
275
|
+
messages: OverlayChatMessage[];
|
|
276
|
+
}
|
|
277
|
+
/** Response payload of a `SET_SYSTEM_PROMPT` request. */
|
|
278
|
+
export interface SetSystemPromptResponse {
|
|
279
|
+
/** System prompt value that was persisted. */
|
|
280
|
+
systemPrompt: string;
|
|
281
|
+
}
|
|
282
|
+
/** Response payload of a `SET_TEMPERATURE` request. */
|
|
283
|
+
export interface SetTemperatureResponse {
|
|
284
|
+
/** Temperature value that was persisted. */
|
|
285
|
+
temperature: number;
|
|
286
|
+
}
|
|
287
|
+
/** Response payload of a `SET_OVERLAY_OPTIONS` request. */
|
|
288
|
+
export interface SetOverlayOptionsResponse {
|
|
289
|
+
/** Whether the supplied options were applied (`false` only signals a fallback, never a thrown error). */
|
|
290
|
+
applied: boolean;
|
|
291
|
+
}
|
|
292
|
+
/** Response payload of a `GET_CONVERSATIONS` request. */
|
|
293
|
+
export interface GetConversationsResponse {
|
|
294
|
+
/** The current user's conversation list. */
|
|
295
|
+
conversations: OverlayConversation[];
|
|
296
|
+
}
|
|
297
|
+
/** Response payload of a `GET_SELECTED_CONVERSATIONS` request. */
|
|
298
|
+
export interface GetSelectedConversationsResponse {
|
|
299
|
+
/** Currently displayed conversation(s); empty when no conversation is mounted. */
|
|
300
|
+
conversations: OverlayConversation[];
|
|
301
|
+
}
|
|
302
|
+
/** Response payload of a `SELECT_CONVERSATION` request. */
|
|
303
|
+
export interface SelectConversationResponse {
|
|
304
|
+
/** The now-selected conversation's projection, present on success. */
|
|
305
|
+
conversation?: OverlayConversation;
|
|
306
|
+
/** Present when the selection failed. */
|
|
307
|
+
error?: OverlayConversationError;
|
|
308
|
+
}
|
|
309
|
+
/** Response payload of a `CREATE_CONVERSATION` request. */
|
|
310
|
+
export interface CreateConversationResponse {
|
|
311
|
+
/** The created conversation's projection, or `null` when the composer path was taken. */
|
|
312
|
+
conversation: OverlayConversation | null;
|
|
313
|
+
/** Present when creation failed. */
|
|
314
|
+
error?: OverlayConversationError;
|
|
315
|
+
}
|
|
316
|
+
/** Response payload of a `CREATE_LOCAL_CONVERSATION` request. */
|
|
317
|
+
export interface CreateLocalConversationResponse {
|
|
318
|
+
/** Always `null` — the composer opens without persisting anything. */
|
|
319
|
+
conversation: null;
|
|
320
|
+
}
|
|
321
|
+
/** Response payload of a `DELETE_CONVERSATION` request. */
|
|
322
|
+
export interface DeleteConversationResponse {
|
|
323
|
+
/** Present when deletion failed. */
|
|
324
|
+
error?: OverlayConversationError;
|
|
325
|
+
}
|
|
326
|
+
/** Response payload of a `RENAME_CONVERSATION` request. */
|
|
327
|
+
export interface RenameConversationResponse {
|
|
328
|
+
/** The renamed conversation's projection, present on success. */
|
|
329
|
+
conversation?: OverlayConversation;
|
|
330
|
+
/** Present when the rename failed. */
|
|
331
|
+
error?: OverlayConversationError;
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* A request message sent from the host (library) to the embedded app.
|
|
335
|
+
* `type` is always `'${OverlayRequestType}'`.
|
|
336
|
+
*/
|
|
337
|
+
export interface OverlayMessageRequest<TPayload = unknown> {
|
|
338
|
+
/** Full wire type string, one of the `OverlayRequestType` values. */
|
|
339
|
+
type: `${OverlayRequestType}`;
|
|
340
|
+
/** Unique id used to match this request to its response. */
|
|
341
|
+
requestId: string;
|
|
342
|
+
/**
|
|
343
|
+
* Epoch milliseconds after which the embedded app must stop waiting for
|
|
344
|
+
* prerequisites (such as an active conversation bridge) and drop the request.
|
|
345
|
+
*/
|
|
346
|
+
expiresAt?: number;
|
|
347
|
+
/** Request-specific payload. */
|
|
348
|
+
payload?: TPayload;
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* A response message sent from the embedded app to the host (library),
|
|
352
|
+
* answering a specific request by `requestId`.
|
|
353
|
+
*/
|
|
354
|
+
export interface OverlayMessageResponse<TPayload = unknown> {
|
|
355
|
+
/** Full wire type string, always `'${OverlayRequestType}/RESPONSE'`. */
|
|
356
|
+
type: `${OverlayRequestType}/RESPONSE`;
|
|
357
|
+
/** `requestId` of the request this message answers. */
|
|
358
|
+
requestId: string;
|
|
359
|
+
/** Response-specific payload. */
|
|
360
|
+
payload?: TPayload;
|
|
361
|
+
/** Present when the embedded chat could not complete the request. */
|
|
362
|
+
error?: OverlayRequestError;
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* An event message sent from the embedded app to the host (library),
|
|
366
|
+
* with no associated request (no `requestId` field).
|
|
367
|
+
*/
|
|
368
|
+
export interface OverlayMessageEvent<TPayload = unknown> {
|
|
369
|
+
/** Full wire type string, one of the `OverlayEventType` values. */
|
|
370
|
+
type: `${OverlayEventType}`;
|
|
371
|
+
/** Event-specific payload. */
|
|
372
|
+
payload?: TPayload;
|
|
373
|
+
}
|
|
374
|
+
/** Narrows an arbitrary value to a well-formed `OverlayMessageRequest`. */
|
|
375
|
+
export declare const isOverlayMessageRequest: (data: unknown) => data is OverlayMessageRequest;
|
|
376
|
+
/** Narrows an arbitrary value to a well-formed `OverlayMessageResponse`. */
|
|
377
|
+
export declare const isOverlayMessageResponse: (data: unknown) => data is OverlayMessageResponse;
|
|
378
|
+
/** Narrows an arbitrary value to a well-formed `OverlayMessageEvent`. */
|
|
379
|
+
export declare const isOverlayMessageEvent: (data: unknown) => data is OverlayMessageEvent;
|
|
380
|
+
//# sourceMappingURL=overlay-protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overlay-protocol.d.ts","sourceRoot":"","sources":["../../src/protocol/overlay-protocol.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,eAAO,MAAM,sBAAsB,kBAAkB,CAAC;AAEtD,mEAAmE;AACnE,oBAAY,kBAAkB;IAC5B,gDAAgD;IAChD,WAAW,+BAA+B;IAC1C,qDAAqD;IACrD,WAAW,+BAA+B;IAC1C,yDAAyD;IACzD,eAAe,oCAAoC;IACnD,mDAAmD;IACnD,eAAe,oCAAoC;IACnD,iDAAiD;IACjD,cAAc,kCAAkC;IAChD,2EAA2E;IAC3E,iBAAiB,sCAAsC;IACvD,kDAAkD;IAClD,gBAAgB,oCAAoC;IACpD,8DAA8D;IAC9D,wBAAwB,6CAA6C;IACrE,0DAA0D;IAC1D,kBAAkB,sCAAsC;IACxD,qFAAqF;IACrF,kBAAkB,sCAAsC;IACxD,kEAAkE;IAClE,uBAAuB,4CAA4C;IACnE,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