ai12z 3.13.3 → 3.14.1-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/ai12z-bot.cjs.entry.js +107 -19
- package/dist/cjs/ai12z-chat-message.cjs.entry.js +17 -46
- package/dist/cjs/ai12z-knowledge-box.cjs.entry.js +14 -60
- package/dist/cjs/index.cjs.js +1 -0
- package/dist/cjs/styleSheetRegistry-7aecMygn.js +175 -0
- package/dist/collection/components/ai12z-bot/ai12z-bot.js +32 -13
- package/dist/collection/components/ai12z-knowledge-box/ai12z-knowledge-box.js +15 -61
- package/dist/collection/components/ai12z-knowledge-box/components/ai12z-chat-message.js +16 -46
- package/dist/collection/utils/liveagents/providers/salesforce.js +75 -6
- package/dist/collection/utils/styleSheetRegistry.js +169 -0
- package/dist/components/ai12z-bot.js +1 -1
- package/dist/components/ai12z-chat-message.js +1 -1
- package/dist/components/ai12z-chat.js +1 -1
- package/dist/components/ai12z-container.js +1 -1
- package/dist/components/ai12z-cta.js +1 -1
- package/dist/components/ai12z-form.js +1 -1
- package/dist/components/ai12z-inline-search.js +1 -1
- package/dist/components/ai12z-input-form.js +1 -1
- package/dist/components/ai12z-knowledge-box.js +1 -1
- package/dist/components/ai12z-search-panel.js +1 -1
- package/dist/components/audio-recorder.js +1 -1
- package/dist/components/dynamic-form.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/interaction-buttons.js +1 -1
- package/dist/components/item-list.js +1 -1
- package/dist/components/{p-DKxaam7U.js → p-3j2aDKYq.js} +1 -1
- package/dist/components/{p-BP8ig03d.js → p-AQ1MS6Ps.js} +1 -1
- package/dist/components/p-B9IJbo4G.js +1 -0
- package/dist/components/p-BP6_06aA.js +1 -0
- package/dist/components/{p-DsZWeAcM.js → p-BWMhH2R1.js} +1 -1
- package/dist/components/{p-5UYwpNzl.js → p-BaXs0IIw.js} +1 -1
- package/dist/components/{p-Gr6Q2s96.js → p-Bnj1LjUJ.js} +1 -1
- package/dist/components/p-BwpiW24r.js +1 -0
- package/dist/components/{p-Bo3Ig8oX.js → p-BwqXbNCx.js} +1 -1
- package/dist/components/{p-D2nUK4Pa.js → p-COqFEHJ7.js} +1 -1
- package/dist/components/p-C_wQhGjc.js +1 -0
- package/dist/components/{p-DA32xa7d.js → p-Ci85xHWQ.js} +1 -1
- package/dist/components/{p-DUaZgAhA.js → p-CrfXJRIo.js} +1 -1
- package/dist/components/{p-DJ68HDol.js → p-DkRAkHLI.js} +2 -2
- package/dist/components/{p-ha1wIlZ-.js → p-Dubjoiw6.js} +1 -1
- package/dist/components/{p-C2wKkcYa.js → p-DvtUY5FW.js} +1 -1
- package/dist/components/{p-J--erGbY.js → p-dQEvevXk.js} +1 -1
- package/dist/{library/p-DAGa-uHD.js → components/p-g36mIk7k.js} +1 -1
- package/dist/components/{p-q7YWDP9B.js → p-pOVc-eI8.js} +1 -1
- package/dist/components/{p-BCJzelr9.js → p-qwKoi5kn.js} +1 -1
- package/dist/components/{p-CKAp10SJ.js → p-xTOLReQF.js} +1 -1
- package/dist/components/privacy-modal.js +1 -1
- package/dist/components/search-results-page.js +1 -1
- package/dist/esm/ai12z-bot.entry.js +115 -27
- package/dist/esm/ai12z-category_2.entry.js +3 -3
- package/dist/esm/ai12z-chat-message.entry.js +17 -46
- package/dist/esm/ai12z-chat_2.entry.js +8 -8
- package/dist/esm/ai12z-container.entry.js +3 -3
- package/dist/esm/ai12z-cta.entry.js +4 -4
- package/dist/esm/ai12z-form.entry.js +2 -2
- package/dist/esm/ai12z-inline-search.entry.js +2 -2
- package/dist/esm/ai12z-knowledge-box.entry.js +18 -64
- package/dist/esm/ai12z-search-panel.entry.js +1 -1
- package/dist/esm/chat-avatar_6.entry.js +1 -1
- package/dist/esm/{ctaHelpers-BhM8KbEY.js → ctaHelpers-DrH6S5iU.js} +1 -1
- package/dist/esm/dynamic-form.entry.js +1 -1
- package/dist/esm/{index-BQKLwW-C.js → index-VWr-8RG8.js} +1 -1
- package/dist/esm/index.js +10 -9
- package/dist/esm/item-list.entry.js +2 -2
- package/dist/esm/{keyboard-shortcuts-Bd3LDe9j.js → keyboard-shortcuts-BhKv64FZ.js} +2 -2
- package/dist/esm/{parseHelper-9rP0JS7J.js → parseHelper-kOGOndOe.js} +1 -1
- package/dist/esm/{processCarouselData-Bf2pDFsV.js → processCarouselData-DX152a4X.js} +1 -1
- package/dist/esm/{reCaptchaHelpers-CUcgfdqX.js → reCaptchaHelpers-DUpCzUFb.js} +1 -1
- package/dist/esm/search-results-page.entry.js +4 -4
- package/dist/esm/{socket-service-B1OMbkCM.js → socket-service-D_h5x8Gr.js} +1 -1
- package/dist/esm/styleSheetRegistry-Bfi9VkqK.js +172 -0
- package/dist/esm/{surveyHelpers-CvrZlir1.js → surveyHelpers-D-00eWjv.js} +1 -1
- package/dist/esm/{utils-BTLjNTwP.js → utils-DK_Yhmpx.js} +1 -1
- package/dist/library/index.esm.js +1 -1
- package/dist/library/library.esm.js +1 -1
- package/dist/library/{p-cd764f70.entry.js → p-11c1f91d.entry.js} +1 -1
- package/dist/library/{p-806bfb3d.entry.js → p-1d382046.entry.js} +1 -1
- package/dist/library/{p-0641ba91.entry.js → p-252bb713.entry.js} +2 -2
- package/dist/library/p-25a678ca.entry.js +1 -0
- package/dist/library/p-4a58c695.entry.js +1 -0
- package/dist/library/p-53edf210.entry.js +1 -0
- package/dist/library/p-646a7eae.entry.js +1 -0
- package/dist/library/{p-60d5d99f.entry.js → p-6ea05db1.entry.js} +1 -1
- package/dist/library/{p-7f0e306c.entry.js → p-7154a204.entry.js} +1 -1
- package/dist/library/{p-07f11cb8.entry.js → p-72a5eaf2.entry.js} +1 -1
- package/dist/library/{p-2d262192.entry.js → p-8f238b3f.entry.js} +1 -1
- package/dist/library/p-9cffb6fa.entry.js +1 -0
- package/dist/library/{p-y3Go1NSi.js → p-BCkDiHIY.js} +1 -1
- package/dist/{components/p-BhV62IFF.js → library/p-By1gJKXA.js} +1 -1
- package/dist/library/{p-Bbow4UZX.js → p-C0wNDqKO.js} +1 -1
- package/dist/library/p-C3yxqbFh.js +1 -0
- package/dist/library/p-CwZwG6gL.js +1 -0
- package/dist/library/{p-D5m1leH0.js → p-D1IPrgJe.js} +3 -3
- package/dist/library/{p-NAKC5NP9.js → p-KSKiM1sy.js} +1 -1
- package/dist/library/{p-C1eU4fpM.js → p-TJuczvVq.js} +1 -1
- package/dist/library/{p-CnadO0kA.js → p-ZyOWOLs5.js} +1 -1
- package/dist/library/{p-94bf0c7f.entry.js → p-cbfc9f73.entry.js} +1 -1
- package/dist/library/{p-014d5664.entry.js → p-d8506e43.entry.js} +1 -1
- package/dist/library/{p-BZ_koFpE.js → p-n8ydBHE4.js} +1 -1
- package/dist/types/components/ai12z-bot/ai12z-bot.d.ts +1 -0
- package/dist/types/components/ai12z-knowledge-box/ai12z-knowledge-box.d.ts +0 -3
- package/dist/types/components/ai12z-knowledge-box/components/ai12z-chat-message.d.ts +0 -2
- package/dist/types/utils/liveagents/providers/salesforce.d.ts +2 -0
- package/dist/types/utils/styleSheetRegistry.d.ts +40 -0
- package/package.json +2 -2
- package/dist/components/p-B3lv_O-6.js +0 -1
- package/dist/components/p-CLdlCTTp.js +0 -1
- package/dist/components/p-DT0Uarfg.js +0 -1
- package/dist/components/p-zVXADzTq.js +0 -1
- package/dist/library/p-29cd4edc.entry.js +0 -1
- package/dist/library/p-6f3727d3.entry.js +0 -1
- package/dist/library/p-83a71da9.entry.js +0 -1
- package/dist/library/p-DoBD_KPG.js +0 -1
- package/dist/library/p-d3a2acee.entry.js +0 -1
- package/dist/library/p-dc131a5c.entry.js +0 -1
|
@@ -66,6 +66,67 @@ class SalesforceLiveAgentProvider {
|
|
|
66
66
|
this.configSettings = null;
|
|
67
67
|
this.sessionContext = null;
|
|
68
68
|
this.endpointSSE = "";
|
|
69
|
+
this.checkAgentAvailability = async (conversationId) => {
|
|
70
|
+
var _a, _b, _c;
|
|
71
|
+
this.availabilityAbort = new AbortController();
|
|
72
|
+
const { signal } = this.availabilityAbort;
|
|
73
|
+
// MIAW routing is async — poll until a RoutingResult entry appears or we time out.
|
|
74
|
+
const POLL_INTERVAL_MS = 1500;
|
|
75
|
+
const MAX_WAIT_MS = 20000;
|
|
76
|
+
const startTime = Date.now();
|
|
77
|
+
while (Date.now() - startTime < MAX_WAIT_MS) {
|
|
78
|
+
if (signal.aborted)
|
|
79
|
+
return false;
|
|
80
|
+
const availabilityRes = await fetch(`${(_a = this.configSettings) === null || _a === void 0 ? void 0 : _a.instanceUrl}/iamessage/api/v2/conversation/${conversationId}/entries`, {
|
|
81
|
+
method: "GET",
|
|
82
|
+
signal,
|
|
83
|
+
headers: {
|
|
84
|
+
"Content-Type": "application/json",
|
|
85
|
+
"Authorization": `Bearer ${(_b = this.sessionContext) === null || _b === void 0 ? void 0 : _b.accessToken}`,
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
if (!availabilityRes.ok) {
|
|
89
|
+
logger.warn(`Agent availability check failed: ${availabilityRes.status} ${availabilityRes.statusText}`);
|
|
90
|
+
ChatEventBus.emit("AGENT_UNAVAILABLE", { reason: "request_error" });
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
const availabilityData = await availabilityRes.json();
|
|
94
|
+
logger.debug("Agent availability check result:", availabilityData);
|
|
95
|
+
const entries = (_c = availabilityData === null || availabilityData === void 0 ? void 0 : availabilityData.conversationEntries) !== null && _c !== void 0 ? _c : [];
|
|
96
|
+
const routingEntry = entries.find((e) => e.entryType === "RoutingResult");
|
|
97
|
+
if (routingEntry) {
|
|
98
|
+
// entryPayload may arrive as a JSON string — parse it if needed
|
|
99
|
+
let entryPayload = routingEntry.entryPayload;
|
|
100
|
+
if (typeof entryPayload === "string") {
|
|
101
|
+
try {
|
|
102
|
+
entryPayload = JSON.parse(entryPayload);
|
|
103
|
+
}
|
|
104
|
+
catch (_d) {
|
|
105
|
+
logger.warn("Failed to parse RoutingResult entryPayload");
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
const failureReason = entryPayload === null || entryPayload === void 0 ? void 0 : entryPayload.failureReason;
|
|
109
|
+
if (failureReason) {
|
|
110
|
+
logger.warn("Routing failed with reason:", failureReason);
|
|
111
|
+
ChatEventBus.emit("AGENT_UNAVAILABLE", { reason: failureReason });
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
logger.debug("Agent routed successfully");
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
// conversationEntries is empty — routing hasn't completed yet, retry
|
|
118
|
+
logger.debug(`No RoutingResult yet (entries: ${entries.length}), retrying in ${POLL_INTERVAL_MS}ms…`);
|
|
119
|
+
// await new Promise(resolve => setTimeout(resolve, POLL_INTERVAL_MS))
|
|
120
|
+
await new Promise((resolve, reject) => {
|
|
121
|
+
const t = setTimeout(resolve, POLL_INTERVAL_MS);
|
|
122
|
+
signal.addEventListener("abort", () => { clearTimeout(t); reject(); }, { once: true });
|
|
123
|
+
}).catch(() => null);
|
|
124
|
+
}
|
|
125
|
+
// Timed out — no routing result arrived within the window
|
|
126
|
+
logger.warn("Timed out waiting for MIAW routing result");
|
|
127
|
+
ChatEventBus.emit("AGENT_UNAVAILABLE", { reason: "timeout" });
|
|
128
|
+
return false;
|
|
129
|
+
};
|
|
69
130
|
this.configSettings = null;
|
|
70
131
|
this.sessionContext = null;
|
|
71
132
|
this.endpointSSE = utils.getEndpoint(envMode);
|
|
@@ -177,8 +238,15 @@ class SalesforceLiveAgentProvider {
|
|
|
177
238
|
if (formatInitialMessages) {
|
|
178
239
|
this.sendMessage({ isNewSession: true, sessionId: ((_m = this.sessionContext) === null || _m === void 0 ? void 0 : _m.sessionId) || "", message: formatInitialMessages });
|
|
179
240
|
}
|
|
180
|
-
|
|
181
|
-
|
|
241
|
+
if (await this.checkAgentAvailability(this.sessionContext.conversationId || "")) {
|
|
242
|
+
logger.debug("Agent is available, starting to listen to messages");
|
|
243
|
+
this.listenToMessages();
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
// AGENT_UNAVAILABLE (with reason: failureReason | "timeout" | "request_error")
|
|
247
|
+
// was already emitted by checkAgentAvailability
|
|
248
|
+
logger.warn("No agent assigned — skipping SSE listener setup");
|
|
249
|
+
}
|
|
182
250
|
}
|
|
183
251
|
}
|
|
184
252
|
/**
|
|
@@ -611,13 +679,14 @@ class SalesforceLiveAgentProvider {
|
|
|
611
679
|
* It sends a POST request to the Salesforce MIAW API to close the conversation.
|
|
612
680
|
*/
|
|
613
681
|
async endChat(_sessionId) {
|
|
614
|
-
var _a, _b, _c, _d, _e;
|
|
682
|
+
var _a, _b, _c, _d, _e, _f;
|
|
683
|
+
(_a = this.availabilityAbort) === null || _a === void 0 ? void 0 : _a.abort();
|
|
615
684
|
// console.log("this.sessionContext?.conversationId", this.sessionContext?.conversationId)
|
|
616
|
-
if ((
|
|
617
|
-
const res = await fetch(`${(
|
|
685
|
+
if ((_b = this.sessionContext) === null || _b === void 0 ? void 0 : _b.conversationId) {
|
|
686
|
+
const res = await fetch(`${(_c = this.configSettings) === null || _c === void 0 ? void 0 : _c.instanceUrl}/iamessage/api/v2/conversation/${(_d = this.sessionContext) === null || _d === void 0 ? void 0 : _d.conversationId}?esDeveloperName=${(_e = this.configSettings) === null || _e === void 0 ? void 0 : _e.messagingChannelId}`, {
|
|
618
687
|
method: "DELETE",
|
|
619
688
|
headers: {
|
|
620
|
-
"Authorization": `Bearer ${(
|
|
689
|
+
"Authorization": `Bearer ${(_f = this.sessionContext) === null || _f === void 0 ? void 0 : _f.accessToken}`,
|
|
621
690
|
"Content-Type": "application/json",
|
|
622
691
|
},
|
|
623
692
|
});
|
|
@@ -1253,6 +1322,7 @@ const Ai12zBot = class {
|
|
|
1253
1322
|
if (currentDomElement) {
|
|
1254
1323
|
// Append the agent event messages to the current message bubble
|
|
1255
1324
|
currentDomElement.parentNode.appendChild(agentEventMessages);
|
|
1325
|
+
this.currentDomId = "";
|
|
1256
1326
|
return agentEventMessages;
|
|
1257
1327
|
}
|
|
1258
1328
|
}
|
|
@@ -1302,9 +1372,6 @@ const Ai12zBot = class {
|
|
|
1302
1372
|
this.agentEventHandler = event => {
|
|
1303
1373
|
this.isTypingIndicatorVisible = false;
|
|
1304
1374
|
if ((event === null || event === void 0 ? void 0 : event.length) > 0) {
|
|
1305
|
-
if (this.isLiveAgentEnabled && this.currentDomId === "") {
|
|
1306
|
-
this.currentDomId = this.messages[this.messages.length - 1].id;
|
|
1307
|
-
}
|
|
1308
1375
|
// Persist each system event into this.messages so they survive page reload
|
|
1309
1376
|
const systemMessages = event.map((evt) => ({
|
|
1310
1377
|
id: evt.id || `system-${utils.generateUUID()}`,
|
|
@@ -1346,6 +1413,16 @@ const Ai12zBot = class {
|
|
|
1346
1413
|
this.isLiveAgent = true;
|
|
1347
1414
|
this.updateBotState();
|
|
1348
1415
|
};
|
|
1416
|
+
this.handleAgentUnavailable = () => {
|
|
1417
|
+
this.addEventMessage("Live Agent is currently unavailable. Please try again later.");
|
|
1418
|
+
this.isTypingIndicatorVisible = false;
|
|
1419
|
+
this.isLiveAgent = false;
|
|
1420
|
+
this.liveAgentSessionId = "";
|
|
1421
|
+
this.liveAgentConversationId = "";
|
|
1422
|
+
this.updateBotState();
|
|
1423
|
+
this.announce("Live agent is currently unavailable");
|
|
1424
|
+
this.clearEvents();
|
|
1425
|
+
};
|
|
1349
1426
|
this.toggleBot = _e => {
|
|
1350
1427
|
// e.stopPropagation()
|
|
1351
1428
|
this.isToggled = !this.isToggled;
|
|
@@ -2017,6 +2094,9 @@ const Ai12zBot = class {
|
|
|
2017
2094
|
this.socket.on(endEvent, async (rawData) => {
|
|
2018
2095
|
// For v2, adapt the response format to match legacy expectations
|
|
2019
2096
|
const data = protocol === "v2" ? responseAdapter.adaptCompleteToLegacy(rawData) : rawData;
|
|
2097
|
+
if (data.showInput !== undefined && typeof data.showInput === "boolean") {
|
|
2098
|
+
this.botSettings.showInput = data.showInput;
|
|
2099
|
+
}
|
|
2020
2100
|
this.unreadCount++;
|
|
2021
2101
|
const { id, idChanged, orphaned } = parseHelper.ensureMessageId(this.currentDomId, this.messages, "chatbot");
|
|
2022
2102
|
this.currentDomId = id;
|
|
@@ -2500,7 +2580,9 @@ const Ai12zBot = class {
|
|
|
2500
2580
|
this.liveAgentSessionId = "";
|
|
2501
2581
|
this.liveAgentConversationId = "";
|
|
2502
2582
|
this.liveAgentButtonText = "Talk to a Live Agent";
|
|
2503
|
-
this.sendMessage(((_a = this.botSettings) === null || _a === void 0 ? void 0 : _a.llmMessageOnDisconnect) !== ""
|
|
2583
|
+
this.sendMessage(((_a = this.botSettings) === null || _a === void 0 ? void 0 : _a.llmMessageOnDisconnect) !== ""
|
|
2584
|
+
? (_b = this.botSettings) === null || _b === void 0 ? void 0 : _b.llmMessageOnDisconnect
|
|
2585
|
+
: "The live agent has been disconnected. Please do not initiate the live agent directive again.", ((_c = this.botSettings) === null || _c === void 0 ? void 0 : _c.userMessageOnDisconnect) !== "" ? (_d = this.botSettings) === null || _d === void 0 ? void 0 : _d.userMessageOnDisconnect : "The live agent has ended the conversation.", { isLiveChatEnded: true });
|
|
2504
2586
|
this.announce("Live agent chat ended");
|
|
2505
2587
|
this.clearEvents();
|
|
2506
2588
|
}
|
|
@@ -2521,6 +2603,7 @@ const Ai12zBot = class {
|
|
|
2521
2603
|
this.liveAgentListenersRegistered = true;
|
|
2522
2604
|
ChatEventBus.on("FINDING_AGENT", this.findingAgent);
|
|
2523
2605
|
ChatEventBus.on("AGENT_EVENT", this.agentEventHandler);
|
|
2606
|
+
ChatEventBus.on("AGENT_UNAVAILABLE", this.handleAgentUnavailable);
|
|
2524
2607
|
ChatEventBus.on("TYPING_STARTED", this.handleTypingStarted);
|
|
2525
2608
|
ChatEventBus.on("TYPING_STOPPED", this.handleTypingStopped);
|
|
2526
2609
|
ChatEventBus.on("AGENT_MESSAGE", this.agentMessageCreated);
|
|
@@ -2532,6 +2615,7 @@ const Ai12zBot = class {
|
|
|
2532
2615
|
this.liveAgentListenersRegistered = false;
|
|
2533
2616
|
ChatEventBus.off("FINDING_AGENT", this.findingAgent);
|
|
2534
2617
|
ChatEventBus.off("AGENT_EVENT", this.agentEventHandler);
|
|
2618
|
+
ChatEventBus.off("AGENT_UNAVAILABLE", this.handleAgentUnavailable);
|
|
2535
2619
|
ChatEventBus.off("AGENT_MESSAGE", this.agentMessageCreated);
|
|
2536
2620
|
ChatEventBus.off("AGENT_ERROR", this.handleAgentError);
|
|
2537
2621
|
ChatEventBus.off("CONVERSATION_CLOSED", this.handleAgentConversationEnded);
|
|
@@ -2742,7 +2826,7 @@ const Ai12zBot = class {
|
|
|
2742
2826
|
}
|
|
2743
2827
|
}
|
|
2744
2828
|
render() {
|
|
2745
|
-
var _a, _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _w, _x, _y;
|
|
2829
|
+
var _a, _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _w, _x, _y, _z;
|
|
2746
2830
|
if (!this.canRender) {
|
|
2747
2831
|
return (index.h(index.Host, null, index.h("span", { style: { display: "none" } }, "Failed to load ai12z bot control due to insufficient fund")));
|
|
2748
2832
|
}
|
|
@@ -2825,7 +2909,11 @@ const Ai12zBot = class {
|
|
|
2825
2909
|
"opacity-90": !this.isProse,
|
|
2826
2910
|
"max-w-full break-words @md:text-body2 box-border @md:pr-4 flex-1 rounded-lg text-gray-30 pr-2 text-body3": true,
|
|
2827
2911
|
}, innerHTML: message.text, id: message.id }, message.isLoading && (index.h("div", { class: "w-full rounded-md", id: "spinner" }, index.h("div", { class: "flex animate-pulse space-x-4" }, index.h("div", { class: "flex-1 space-y-3 py-1" }, index.h("div", { class: "h-4 rounded bg-gray-200" }), index.h("div", { class: "space-y-3" }, index.h("div", { class: "grid grid-cols-3 gap-4" }, index.h("div", { class: "col-span-2 h-4 rounded bg-gray-200" }), index.h("div", { class: "col-span-1 h-4 rounded bg-gray-200" })), index.h("div", { class: "h-4 rounded bg-gray-200" }))))))), message.text !== "" && message.showIcon && ((_c = this.botSettings.showMessageIcons) !== null && _c !== void 0 ? _c : true) && (index.h("interaction-buttons", { message: message, chatArray: this.messages, currentIndex: idx, dataKey: this.dataKey, dataMode: this.dataMode, voice: this.voice, voiceType: this.voiceType, source: "bot", conversationId: this.conversationId, projectId: ((_d = this.botSettings) === null || _d === void 0 ? void 0 : _d.pId) || "" })), index.h("div", { class: "text-gray-30 pt-2 text-body4" }, this.botSettings.botName, " \u2022 ", message.timestamp)))));
|
|
2828
|
-
}), this.showHistory && (index.h("chatbot-history", { chatList: this.conversationHistory, botName: (_s = this.botSettings) === null || _s === void 0 ? void 0 : _s.botName, styles: this.customStyle, scripts: this.customJS })), index.h("div", { class: "h-px pt-2px", style: { overflowAnchor: "auto" } })), index.h("div", { role: "status", "aria-live": "polite", "aria-atomic": "true", class: "sr-only" }, this.announceMessage)))), index.h("form", { "data-testid": "user-input", class: `relative pointer-events-auto ${this.isOpened ? "p-2.5" : ""} searchform user-input`, "aria-label": "Message Area", "aria-hidden": "false", style: {
|
|
2912
|
+
}), this.showHistory && (index.h("chatbot-history", { chatList: this.conversationHistory, botName: (_s = this.botSettings) === null || _s === void 0 ? void 0 : _s.botName, styles: this.customStyle, scripts: this.customJS })), index.h("div", { class: "h-px pt-2px", style: { overflowAnchor: "auto" } })), index.h("div", { role: "status", "aria-live": "polite", "aria-atomic": "true", class: "sr-only" }, this.announceMessage)))), ((_t = this.botSettings) === null || _t === void 0 ? void 0 : _t.showInput) !== false && (index.h("form", { "data-testid": "user-input", class: `relative pointer-events-auto ${this.isOpened ? "p-2.5" : ""} searchform user-input`, "aria-label": "Message Area", "aria-hidden": "false", style: {
|
|
2913
|
+
opacity: !this.isMinimized ? "1" : "0",
|
|
2914
|
+
transform: "translateX(0)",
|
|
2915
|
+
pointerEvents: !this.isMinimized ? "auto" : "none",
|
|
2916
|
+
} }, !this.isOpened && (index.h("div", { class: `absolute right-4 md:right-0 border-2 border-white border-solid rounded-full ${this.isContent ? "" : "top-0"} minimize-input` }, index.h("button", { class: "rounded-full flex items-center justify-center disabled:cursor-not-allowed bg-gray-500 bg-opacity-60 hover:bg-opacity-80 h-5 w-5 bot-btn-primary", "aria-label": "Minimize Bot", tabindex: "0", onClick: e => {
|
|
2829
2917
|
e.preventDefault();
|
|
2830
2918
|
this.isMinimized = !this.isMinimized;
|
|
2831
2919
|
this.isOpened = !this.isMinimized;
|
|
@@ -2857,12 +2945,12 @@ const Ai12zBot = class {
|
|
|
2857
2945
|
.filter(Boolean)
|
|
2858
2946
|
.join(" "), "aria-placeholder": this.isLiveAgent
|
|
2859
2947
|
? "Type a message to the agent..."
|
|
2860
|
-
: ((
|
|
2861
|
-
? (
|
|
2948
|
+
: ((_u = this.botSettings) === null || _u === void 0 ? void 0 : _u.botPlaceholderText) !== ""
|
|
2949
|
+
? (_w = this.botSettings) === null || _w === void 0 ? void 0 : _w.botPlaceholderText
|
|
2862
2950
|
: "Ask me anything", "aria-label": "Type your message here", class: `resize-none overflow-hidden text-ellipsis focus:outline-none w-full custom-input ${this.hideAllButtons ? "hidden" : ""}`, "data-testid": "user-input-textarea", rows: this.rowCount, name: "userMessage", placeholder: this.isLiveAgent
|
|
2863
2951
|
? "Type a message to the agent..."
|
|
2864
|
-
: ((
|
|
2865
|
-
? (
|
|
2952
|
+
: ((_x = this.botSettings) === null || _x === void 0 ? void 0 : _x.botPlaceholderText) !== ""
|
|
2953
|
+
? (_y = this.botSettings) === null || _y === void 0 ? void 0 : _y.botPlaceholderText
|
|
2866
2954
|
: "Ask me anything", ref: el => (this.inputEl = el), onKeyUp: _e => {
|
|
2867
2955
|
this.adjustHeight();
|
|
2868
2956
|
}, onKeyDown: e => {
|
|
@@ -2914,7 +3002,7 @@ const Ai12zBot = class {
|
|
|
2914
3002
|
this.isOpened = true;
|
|
2915
3003
|
this.isContent = false;
|
|
2916
3004
|
this.handleSend(button.label);
|
|
2917
|
-
} }, button.label)))))))), index.h("div", {
|
|
3005
|
+
} }, button.label))))))))), index.h("div", {
|
|
2918
3006
|
// slot="bot"
|
|
2919
3007
|
class: "pointer-events-auto fixed right-7 whitespace-nowrap transition-transform duration-300 ease-in-out fab", style: {
|
|
2920
3008
|
opacity: this.isMinimized ? "1" : "0",
|
|
@@ -2924,8 +3012,8 @@ const Ai12zBot = class {
|
|
|
2924
3012
|
}, onClick: () => {
|
|
2925
3013
|
this.openChat();
|
|
2926
3014
|
}
|
|
2927
|
-
}, this.isBot && index.h("slot", { name: "bot" }), !this.isBot && (index.h("button", { class: "rounded-full flex cursor-pointer items-center pr-[14px] md:gap-x-3 focus:outline focus:outline-2 focus:outline-offset-2 focus:outline-blue-focused bot-btn-primary", tabindex: "0", "aria-label": "open Bot" }, index.h("div", { class: "w-10 h-10 flex items-center justify-center bg-white rounded-full border relative" }, this.botSettings.botLaunchIcon && index.h("img", { src: this.botSettings.botLaunchIcon, alt: "bot icon", class: "w-8 h-8 rounded-lg" }), !this.botSettings.botLaunchIcon && (index.h("svg", { viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", stroke: "#2095ae", "aria-hidden": "true" }, index.h("g", { "stroke-width": "0" }), index.h("g", { "stroke-linecap": "round", "stroke-linejoin": "round" }), index.h("g", null, " ", index.h("path", { d: "M21 12C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3C16.9706 3 21 7.02944 21 12Z", stroke: "#2095ae", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" }), " ")))), index.h("span", { class: "bot-name" }, " ", (
|
|
2928
|
-
|
|
3015
|
+
}, this.isBot && index.h("slot", { name: "bot" }), !this.isBot && (index.h("button", { class: "rounded-full flex cursor-pointer items-center pr-[14px] md:gap-x-3 focus:outline focus:outline-2 focus:outline-offset-2 focus:outline-blue-focused bot-btn-primary", tabindex: "0", "aria-label": "open Bot" }, index.h("div", { class: "w-10 h-10 flex items-center justify-center bg-white rounded-full border relative" }, this.botSettings.botLaunchIcon && index.h("img", { src: this.botSettings.botLaunchIcon, alt: "bot icon", class: "w-8 h-8 rounded-lg" }), !this.botSettings.botLaunchIcon && (index.h("svg", { viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", stroke: "#2095ae", "aria-hidden": "true" }, index.h("g", { "stroke-width": "0" }), index.h("g", { "stroke-linecap": "round", "stroke-linejoin": "round" }), index.h("g", null, " ", index.h("path", { d: "M21 12C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3C16.9706 3 21 7.02944 21 12Z", stroke: "#2095ae", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" }), " ")))), index.h("span", { class: "bot-name" }, " ", (_z = this.botSettings) === null || _z === void 0 ? void 0 :
|
|
3016
|
+
_z.botName, " ")))))), index.h("keyboard-shortcuts-dialog", { show: this.showShortcutsDialog, shortcuts: this.shortcuts, onCloseDialog: () => {
|
|
2929
3017
|
this.showShortcutsDialog = false;
|
|
2930
3018
|
} }), index.h("delete-confirmation-modal", { show: this.showLiveAgentEndDialog, dialogTitle: "End live agent chat?", message: "You are about to end the current live agent conversation. You can continue chatting with the bot after ending it.", confirmButtonText: "End", onConfirmDelete: () => {
|
|
2931
3019
|
this.confirmEndLiveAgent();
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
var index = require('./index-Ct2DwlDF.js');
|
|
4
4
|
var botHelpers = require('./botHelpers-D5Dj7TRA.js');
|
|
5
|
-
var
|
|
5
|
+
var styleSheetRegistry = require('./styleSheetRegistry-7aecMygn.js');
|
|
6
|
+
require('./utils-BAJarpnb.js');
|
|
6
7
|
|
|
7
8
|
const ai12zChatMessageCss = () => `.show-more-btn{background:none;color:var(--ai12z-knowledge-box-show-more-color, #4a8aff);font-size:16px;cursor:pointer;font-weight:500;border-radius:6px;transition:color 0.2s ease, background 0.2s ease;border:1px solid var(--ai12z-knowledge-box-show-more-border, blue);padding:10px;border-radius:20px;align-items:center;justify-content:center;margin:auto;display:block;z-index:20;position:relative;width:30%}.show-more-btn:hover{color:var(--ai12z-knowledge-box-show-more-hover-color, #1a73e8);background:rgba(74, 138, 255, 0.08)}.show-more-btn:active{background:rgba(74, 138, 255, 0.15)}.show-more-btn svg{vertical-align:middle;gap:5px;transition:transform 0.3s ease-in-out;display:inline-block;margin-left:10px;font-size:20}.message-text{line-height:1.55;font-size:15px;color:var(--ai12z-knowledge-box-text-color, #1e1e1e);transition:max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1);overflow:hidden}.fade-overlay{position:absolute;bottom:0;left:0;right:0;height:100px;z-index:10;pointer-events:none;opacity:1;transition:opacity 0.3s ease-in-out;background:linear-gradient( to bottom, rgba(255, 255, 255, 0) 0%, var(--ai12z-knowledge-box-bg-color, #ffffff) 85% )}.chat-message{position:relative;}.custom-line-clamp{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:var(--line-clamp);line-clamp:var(--line-clamp)}.ai12z-form-honeypot{position:absolute;left:-10000px;top:auto;width:1px;height:1px;overflow:hidden}.ai12zBtn{background-color:var(--ai12z-knowledge-box-primary-color);color:white;padding:5px 10px;border:none;border-radius:5px;cursor:pointer;text-decoration:none;margin:5px}`;
|
|
8
9
|
|
|
@@ -54,70 +55,40 @@ const Ai12zChatMessage = class {
|
|
|
54
55
|
botHelpers.initializeScript(event.detail.id, this.mainObject);
|
|
55
56
|
}
|
|
56
57
|
componentWillLoad() {
|
|
57
|
-
var _a, _b;
|
|
58
|
-
if ((_a = this.kbSettings) === null || _a === void 0 ? void 0 : _a.customCSS) {
|
|
59
|
-
utils.insertStyles(this.kbSettings.customCSS, this.el);
|
|
60
|
-
}
|
|
61
|
-
if ((_b = this.kbSettings) === null || _b === void 0 ? void 0 : _b.customJS) {
|
|
62
|
-
this.loadScript(this.kbSettings.customJS);
|
|
63
|
-
}
|
|
64
58
|
this.loadScriptsSequentially();
|
|
65
59
|
}
|
|
66
60
|
componentDidLoad() {
|
|
67
|
-
|
|
61
|
+
var _a, _b;
|
|
62
|
+
// Initialise the ai12z global exactly once; never overwrite an existing value.
|
|
68
63
|
if (!window["ai12z"]) {
|
|
69
64
|
window["ai12z"] = {};
|
|
70
65
|
}
|
|
71
66
|
const ai12zHeading = document.createElement("script");
|
|
72
|
-
ai12zHeading.text = `
|
|
73
|
-
var ai12zChat = window["ai12z"] = {}
|
|
74
|
-
`;
|
|
75
|
-
document.head.appendChild(ai12zHeading);
|
|
67
|
+
ai12zHeading.text = `var ai12zChat = window["ai12z"] = {}`;
|
|
76
68
|
this.el.shadowRoot.appendChild(ai12zHeading);
|
|
77
69
|
this.checkOverflow();
|
|
78
|
-
this
|
|
79
|
-
|
|
80
|
-
injectCustomAssets() {
|
|
81
|
-
var _a, _b;
|
|
70
|
+
// Adopt customCSS in this shadow root using the shared CSSStyleSheet
|
|
71
|
+
// already constructed by the parent knowledge-box (zero extra fetches).
|
|
82
72
|
if ((_a = this.kbSettings) === null || _a === void 0 ? void 0 : _a.customCSS) {
|
|
83
|
-
|
|
73
|
+
styleSheetRegistry.adoptStyleSheet(this.kbSettings.customCSS, this.el.shadowRoot);
|
|
84
74
|
}
|
|
85
75
|
if ((_b = this.kbSettings) === null || _b === void 0 ? void 0 : _b.customJS) {
|
|
86
|
-
|
|
76
|
+
styleSheetRegistry.loadScriptOnce(this.kbSettings.customJS, this.el.shadowRoot);
|
|
87
77
|
}
|
|
88
78
|
}
|
|
89
79
|
async loadScriptsSequentially() {
|
|
90
80
|
try {
|
|
91
|
-
//
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
await
|
|
95
|
-
|
|
96
|
-
await
|
|
97
|
-
// 6. Load Survey UI
|
|
98
|
-
await this.loadScript(`${this.surveyCDNPath}/survey-js-ui@2.3.4/survey-js-ui.min.js`);
|
|
99
|
-
// console.log("All Survey.js scripts loaded successfully")
|
|
81
|
+
// Survey.js scripts are loaded into shadowRoot exactly once
|
|
82
|
+
// (loadScriptOnce deduplicates across all component instances).
|
|
83
|
+
await styleSheetRegistry.loadScriptOnce(`${this.surveyCDNPath}/survey-core@2.3.4/survey.core.min.js`, this.el.shadowRoot);
|
|
84
|
+
await styleSheetRegistry.loadScriptOnce(`${this.surveyCDNPath}/survey-core@2.3.4/survey.i18n.min.js`, this.el.shadowRoot);
|
|
85
|
+
await styleSheetRegistry.loadScriptOnce(`${this.surveyCDNPath}/survey-core@2.3.4/themes/index.min.js`, this.el.shadowRoot);
|
|
86
|
+
await styleSheetRegistry.loadScriptOnce(`${this.surveyCDNPath}/survey-js-ui@2.3.4/survey-js-ui.min.js`, this.el.shadowRoot);
|
|
100
87
|
}
|
|
101
88
|
catch (error) {
|
|
102
89
|
console.error("Failed to load Survey.js scripts:", error);
|
|
103
90
|
}
|
|
104
91
|
}
|
|
105
|
-
loadScript(src) {
|
|
106
|
-
return new Promise((resolve, reject) => {
|
|
107
|
-
if (document.querySelector(`script[src="${src}"]`)) {
|
|
108
|
-
resolve();
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
const script = document.createElement("script");
|
|
112
|
-
script.src = src;
|
|
113
|
-
script.async = false;
|
|
114
|
-
script.onload = () => resolve();
|
|
115
|
-
script.onerror = () => reject(new Error(`Failed to load script: ${src}`));
|
|
116
|
-
// Load in document head for global access
|
|
117
|
-
// document.head.appendChild(script)
|
|
118
|
-
this.el.shadowRoot.appendChild(script);
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
92
|
onTextChange() {
|
|
122
93
|
// if (!this.isExpanded && !this.streaming) {
|
|
123
94
|
// this.updateCollapsedHeight();
|
|
@@ -185,9 +156,9 @@ const Ai12zChatMessage = class {
|
|
|
185
156
|
render() {
|
|
186
157
|
var _a, _b, _c, _d;
|
|
187
158
|
const lineClamp = (_b = (_a = this.kbSettings) === null || _a === void 0 ? void 0 : _a.numberOfLines) !== null && _b !== void 0 ? _b : 10;
|
|
188
|
-
return (index.h("div", { key: '
|
|
159
|
+
return (index.h("div", { key: '2d24739583f2f73daa28590c6c121531cf6ab4ce', class: "chat-message" }, index.h("div", { key: '9e8ca0a62a0de746f367164ff51ea9b9a22e93a0', ref: (el) => this.messageRef = el, class: { 'message-text': true, "custom-line-clamp": !this.isExpanded && !this.isCollapsing && this.showButton }, style: {
|
|
189
160
|
"--line-clamp": `${lineClamp}`,
|
|
190
|
-
}, innerHTML: this.text, onClick: this.showButton ? this.toggleExpand : undefined }), !this.isExpanded && this.showButton && this.canExpand && index.h("div", { key: '
|
|
161
|
+
}, innerHTML: this.text, onClick: this.showButton ? this.toggleExpand : undefined }), !this.isExpanded && this.showButton && this.canExpand && index.h("div", { key: '12f386a03fc84f97d2e585ea21cf4f8d31964c34', class: "fade-overlay" }), this.showButton && this.canExpand && index.h("button", { key: '1633be8cd35334eae64f75d7ce5fd87b30054849', class: "show-more-btn", onClick: this.toggleExpand }, this.isExpanded ? (((_c = this.kbSettings) === null || _c === void 0 ? void 0 : _c.showLessButtonLabel) || "Show less") : (((_d = this.kbSettings) === null || _d === void 0 ? void 0 : _d.showMoreButtonLabel) || "Show more"), this.isExpanded ? index.h("svg", { width: "1em", height: "1em", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" }, index.h("polyline", { points: "6 9 12 15 18 9" })) : index.h("svg", { width: "1em", height: "1em", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" }, index.h("polyline", { points: "18 15 12 9 6 15" })))));
|
|
191
162
|
}
|
|
192
163
|
get el() { return index.getElement(this); }
|
|
193
164
|
static get watchers() { return {
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var index = require('./index-Ct2DwlDF.js');
|
|
4
4
|
var utils = require('./utils-BAJarpnb.js');
|
|
5
|
+
var styleSheetRegistry = require('./styleSheetRegistry-7aecMygn.js');
|
|
5
6
|
var responseAdapter = require('./response-adapter-CKKyyhMj.js');
|
|
6
7
|
var processCarouselData = require('./processCarouselData-YEoGs649.js');
|
|
7
8
|
var globalStore = require('./global-store-R6x06KvJ.js');
|
|
@@ -38,7 +39,6 @@ const Ai12zKnowledgeBox = class {
|
|
|
38
39
|
this.welcomeReady = true;
|
|
39
40
|
this.cdnPath = "https://cdn.ai12z.net/assets/kb";
|
|
40
41
|
this.initializeScript = id => {
|
|
41
|
-
console.log("Initializing script for ID:", id);
|
|
42
42
|
setTimeout(() => {
|
|
43
43
|
this.initializeScripts.emit({ id });
|
|
44
44
|
}, 1000);
|
|
@@ -240,7 +240,7 @@ const Ai12zKnowledgeBox = class {
|
|
|
240
240
|
};
|
|
241
241
|
utils.getConfig(payload, this.dataMode)
|
|
242
242
|
.then(async (data) => {
|
|
243
|
-
var _a, _b, _c, _d, _e
|
|
243
|
+
var _a, _b, _c, _d, _e;
|
|
244
244
|
if (data) {
|
|
245
245
|
this.kbSettings = data;
|
|
246
246
|
switch ((_a = this.kbSettings) === null || _a === void 0 ? void 0 : _a.questionType) {
|
|
@@ -260,10 +260,10 @@ const Ai12zKnowledgeBox = class {
|
|
|
260
260
|
this.addEventListeners(`.ai12z-kb-wrapper`);
|
|
261
261
|
const welcomeLoads = [];
|
|
262
262
|
if ((_d = this.kbSettings.welcome) === null || _d === void 0 ? void 0 : _d.scripts) {
|
|
263
|
-
welcomeLoads.push(
|
|
263
|
+
welcomeLoads.push(styleSheetRegistry.loadScriptOnce(this.kbSettings.welcome.scripts, this.el.shadowRoot));
|
|
264
264
|
}
|
|
265
265
|
if ((_e = this.kbSettings.welcome) === null || _e === void 0 ? void 0 : _e.styles) {
|
|
266
|
-
welcomeLoads.push(
|
|
266
|
+
welcomeLoads.push(styleSheetRegistry.adoptStyleSheet(this.kbSettings.welcome.styles, this.el.shadowRoot));
|
|
267
267
|
}
|
|
268
268
|
if (welcomeLoads.length > 0) {
|
|
269
269
|
await Promise.all(welcomeLoads);
|
|
@@ -285,18 +285,10 @@ const Ai12zKnowledgeBox = class {
|
|
|
285
285
|
document.head.appendChild(linkEl);
|
|
286
286
|
}
|
|
287
287
|
if (this.kbSettings.customCSS) {
|
|
288
|
-
|
|
288
|
+
styleSheetRegistry.adoptStyleSheet(this.kbSettings.customCSS, this.el.shadowRoot);
|
|
289
289
|
}
|
|
290
290
|
if (this.kbSettings.customJS) {
|
|
291
|
-
|
|
292
|
-
console.warn("[ai12z] Blocked customJS injection: URL must use HTTPS.", this.kbSettings.customJS);
|
|
293
|
-
}
|
|
294
|
-
else {
|
|
295
|
-
const scriptEl = document.createElement("script");
|
|
296
|
-
scriptEl.setAttribute("type", "text/javascript");
|
|
297
|
-
scriptEl.setAttribute("src", this.kbSettings.customJS);
|
|
298
|
-
(_f = this.el.shadowRoot) === null || _f === void 0 ? void 0 : _f.appendChild(scriptEl);
|
|
299
|
-
}
|
|
291
|
+
styleSheetRegistry.loadScriptOnce(this.kbSettings.customJS, this.el.shadowRoot);
|
|
300
292
|
}
|
|
301
293
|
}
|
|
302
294
|
})
|
|
@@ -306,49 +298,6 @@ const Ai12zKnowledgeBox = class {
|
|
|
306
298
|
this.errored.emit(error);
|
|
307
299
|
});
|
|
308
300
|
}
|
|
309
|
-
insertStyles(linkURL) {
|
|
310
|
-
const linkEl = document.createElement("link");
|
|
311
|
-
linkEl.setAttribute("rel", "stylesheet");
|
|
312
|
-
linkEl.setAttribute("href", linkURL);
|
|
313
|
-
const shadowRoot = this.el.shadowRoot;
|
|
314
|
-
if (shadowRoot) {
|
|
315
|
-
shadowRoot.appendChild(linkEl);
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
insertStylesAsync(linkURL) {
|
|
319
|
-
return new Promise(resolve => {
|
|
320
|
-
const shadowRoot = this.el.shadowRoot;
|
|
321
|
-
if (!shadowRoot) {
|
|
322
|
-
resolve();
|
|
323
|
-
return;
|
|
324
|
-
}
|
|
325
|
-
const linkEl = document.createElement("link");
|
|
326
|
-
linkEl.setAttribute("rel", "stylesheet");
|
|
327
|
-
linkEl.setAttribute("href", linkURL);
|
|
328
|
-
linkEl.addEventListener("load", () => resolve());
|
|
329
|
-
linkEl.addEventListener("error", () => resolve());
|
|
330
|
-
shadowRoot.appendChild(linkEl);
|
|
331
|
-
});
|
|
332
|
-
}
|
|
333
|
-
insertScriptAsync(scriptURL) {
|
|
334
|
-
if (!utils.isValidHttpsUrl(scriptURL)) {
|
|
335
|
-
console.warn("[ai12z] Blocked script injection: URL must use HTTPS.", scriptURL);
|
|
336
|
-
return Promise.resolve();
|
|
337
|
-
}
|
|
338
|
-
return new Promise(resolve => {
|
|
339
|
-
const shadowRoot = this.el.shadowRoot;
|
|
340
|
-
if (!shadowRoot) {
|
|
341
|
-
resolve();
|
|
342
|
-
return;
|
|
343
|
-
}
|
|
344
|
-
const scriptEl = document.createElement("script");
|
|
345
|
-
scriptEl.setAttribute("type", "text/javascript");
|
|
346
|
-
scriptEl.setAttribute("src", scriptURL);
|
|
347
|
-
scriptEl.addEventListener("load", () => resolve());
|
|
348
|
-
scriptEl.addEventListener("error", () => resolve());
|
|
349
|
-
shadowRoot.appendChild(scriptEl);
|
|
350
|
-
});
|
|
351
|
-
}
|
|
352
301
|
getResults(type) {
|
|
353
302
|
var _a, _b;
|
|
354
303
|
// console.log("Getting results for question:", this.question)
|
|
@@ -462,9 +411,14 @@ const Ai12zKnowledgeBox = class {
|
|
|
462
411
|
}
|
|
463
412
|
}
|
|
464
413
|
componentWillLoad() {
|
|
465
|
-
|
|
414
|
+
styleSheetRegistry.adoptStyleSheet(`https://cdn.ai12z.net/assets/bot/v2/tailwind.min.css`, this.el.shadowRoot);
|
|
466
415
|
this.socketConnection();
|
|
467
416
|
this.getConfig();
|
|
417
|
+
const w = window;
|
|
418
|
+
if (!w.ai12z)
|
|
419
|
+
w.ai12z = {};
|
|
420
|
+
if (!w.ai12zChat)
|
|
421
|
+
w.ai12zChat = w.ai12z;
|
|
468
422
|
}
|
|
469
423
|
disconnectedCallback() {
|
|
470
424
|
if (this.socket) {
|
|
@@ -653,7 +607,7 @@ const Ai12zKnowledgeBox = class {
|
|
|
653
607
|
}
|
|
654
608
|
render() {
|
|
655
609
|
var _a, _b;
|
|
656
|
-
return (index.h("div", { key: '
|
|
610
|
+
return (index.h("div", { key: 'f26a34215a56acd7d3f393a4f0d23727c74ba40a', class: "ai12z-kb-wrapper" }, this.error ? index.h("p", { class: "ai12z-suggest-error-msg" }, "Error please try again!") : null, this.items.map(item => {
|
|
657
611
|
var _a, _b, _c, _d;
|
|
658
612
|
return (index.h("div", { class: "prose max-w-none ai12z-suggest-container" }, index.h("div", null, index.h("div", null, index.h("div", { class: "flex flex-row gap-1" }, index.h("div", { class: "flex items-center gap-2 mb-3", style: { width: "90%" } }, ((_a = this.kbSettings) === null || _a === void 0 ? void 0 : _a.showTitle) && (index.h("svg", { width: "28", height: "28", viewBox: "0 0 48 48", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg", class: "diamond-icon" + (this.isLoading && !this.finalResponse ? " loading" : "") }, index.h("path", { d: "M24 2c-3 8-8 13-16 16 8 3 13 8 16 16 3-8 8-13 16-16-8-3-13-8-16-16z" }))), ((_b = this.kbSettings) === null || _b === void 0 ? void 0 : _b.showTitle) && (index.h("h5", { class: "text-lg font-semibold text-gray-800 m-0" }, !this.finalResponse ? "Generating..." : (_c = this.kbSettings.title) !== null && _c !== void 0 ? _c : "AI Overview"))), item.thumbsUpDown && !this.isLoading && (index.h("div", null, index.h("button", { id: `thumbsUp_${item.insightId}`, onClick: () => {
|
|
659
613
|
var _a;
|
|
@@ -674,7 +628,7 @@ const Ai12zKnowledgeBox = class {
|
|
|
674
628
|
questionText: this.question,
|
|
675
629
|
});
|
|
676
630
|
}, class: "chat-thumbs-down", "aria-label": "Thumbs Down" }, index.h("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", "stroke-width": "1.5", stroke: "currentColor", class: "w-6 h-6" }, index.h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "M7.498 15.25H4.372c-1.026 0-1.945-.694-2.054-1.715a12.137 12.137 0 0 1-.068-1.285c0-2.848.992-5.464 2.649-7.521C5.287 4.247 5.886 4 6.504 4h4.016a4.5 4.5 0 0 1 1.423.23l3.114 1.04a4.5 4.5 0 0 0 1.423.23h1.294M7.498 15.25c.618 0 .991.724.725 1.282A7.471 7.471 0 0 0 7.5 19.75 2.25 2.25 0 0 0 9.75 22a.75.75 0 0 0 .75-.75v-.633c0-.573.11-1.14.322-1.672.304-.76.93-1.33 1.653-1.715a9.04 9.04 0 0 0 2.86-2.4c.498-.634 1.226-1.08 2.032-1.08h.384m-10.253 1.5H9.7m8.075-9.75c.01.05.027.1.05.148.593 1.2.925 2.55.925 3.977 0 1.487-.36 2.89-.999 4.125m.023-8.25c-.076-.365.183-.75.575-.75h.908c.889 0 1.713.518 1.972 1.368.339 1.11.521 2.287.521 3.507 0 1.553-.295 3.036-.831 4.398-.306.774-1.086 1.227-1.918 1.227h-1.053c-.472 0-.745-.556-.5-.96a8.95 8.95 0 0 0 .303-.54" }))))))), !this.isLoading && (index.h("div", null, ((_d = this.searchResults) === null || _d === void 0 ? void 0 : _d.controlType) !== "form" && (index.h("ai12z-chat-message", { id: item.id, text: this.currentStreamingText, kbSettings: this.kbSettings, "show-button": this.showButton, streaming: this.isStreaming && item.id === this.domId })), index.h("div", { class: { "ai12z-suggest-relevance": true, "ai12z-suggest-hide": !item["isRelevance"] } }, index.h("a", { href: "" }, item["relevanceScore"])), index.h("div", { class: "custom-privacy" }, index.h("slot", { name: "custom-privacy" })))), this.isLoading && (index.h("div", { class: "w-full rounded-md", id: "spinner" }, index.h("div", { class: "flex animate-pulse space-x-4" }, index.h("div", { class: "flex-1 space-y-3 py-1" }, index.h("div", { class: "h-4 rounded bg-gray-200" }), index.h("div", { class: "space-y-3" }, index.h("div", { class: "grid grid-cols-3 gap-4" }, index.h("div", { class: "col-span-2 h-4 rounded bg-gray-200" }), index.h("div", { class: "col-span-1 h-4 rounded bg-gray-200" })), index.h("div", { class: "h-4 rounded bg-gray-200" })))))))));
|
|
677
|
-
}), ((_a = this.kbSettings) === null || _a === void 0 ? void 0 : _a.questionType) === "staticHtml" && this.items.length === 0 && this.welcomeReady && (index.h("div", { key: '
|
|
631
|
+
}), ((_a = this.kbSettings) === null || _a === void 0 ? void 0 : _a.questionType) === "staticHtml" && this.items.length === 0 && this.welcomeReady && (index.h("div", { key: '340c562562715563715e5a103019dd19458c994f', class: "ai12z-suggest-answer", innerHTML: (_b = this.kbSettings.welcome) === null || _b === void 0 ? void 0 : _b.message }))));
|
|
678
632
|
}
|
|
679
633
|
static get assetsDirs() { return ["assets"]; }
|
|
680
634
|
get el() { return index.getElement(this); }
|
package/dist/cjs/index.cjs.js
CHANGED
|
@@ -26,6 +26,7 @@ require('./app-store-D249GRTi.js');
|
|
|
26
26
|
require('./parseHelper-Cp45LpWl.js');
|
|
27
27
|
require('./SearchResult-DirxAsMi.js');
|
|
28
28
|
require('./socket-service-L0xv4YGT.js');
|
|
29
|
+
require('./styleSheetRegistry-7aecMygn.js');
|
|
29
30
|
require('./analyticsService-CkAva47S.js');
|
|
30
31
|
|
|
31
32
|
|