ai12z 3.16.1-alpha.5 → 3.16.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/cjs/ai12z-beacon.cjs.entry.js +1 -1
  2. package/dist/cjs/ai12z-bot.cjs.entry.js +7 -5
  3. package/dist/cjs/ai12z-chat_2.cjs.entry.js +6 -6
  4. package/dist/cjs/ai12z-cta.cjs.entry.js +1 -1
  5. package/dist/cjs/ai12z-knowledge-box.cjs.entry.js +1 -1
  6. package/dist/cjs/{beacon-CHsypFIj.js → beacon-Bhd49ADQ.js} +18 -2
  7. package/dist/cjs/index.cjs.js +1 -1
  8. package/dist/cjs/search-results-page.cjs.entry.js +1 -1
  9. package/dist/collection/components/ai12z-bot/ai12z-bot.js +6 -4
  10. package/dist/collection/components/ai12z-cta/components/Chat.js +5 -5
  11. package/dist/collection/utils/beacon.js +18 -2
  12. package/dist/collection/utils/ctaHelpers.js +0 -16
  13. package/dist/components/ai12z-beacon.js +1 -1
  14. package/dist/components/ai12z-bot.js +1 -1
  15. package/dist/components/ai12z-chat.js +1 -1
  16. package/dist/components/ai12z-cta.js +1 -1
  17. package/dist/components/ai12z-inline-search.js +1 -1
  18. package/dist/components/ai12z-knowledge-box.js +1 -1
  19. package/dist/components/index.js +1 -1
  20. package/dist/components/{p--yAsbu4H.js → p-B_GRAsXZ.js} +1 -1
  21. package/dist/components/{p-Di0FiI3Q.js → p-CMc63lZp.js} +1 -1
  22. package/dist/components/{p-tcK5_WYS.js → p-CO7OM6cu.js} +1 -1
  23. package/dist/components/p-CYh3so8v.js +1 -0
  24. package/dist/components/p-CnIXGAt8.js +1 -0
  25. package/dist/components/p-DKF8ThBg.js +1 -0
  26. package/dist/components/p-HTPyCRCK.js +1 -0
  27. package/dist/components/{p-Dcm7MWBo.js → p-fVj5IyS0.js} +1 -1
  28. package/dist/components/search-results-page.js +1 -1
  29. package/dist/esm/ai12z-beacon.entry.js +1 -1
  30. package/dist/esm/ai12z-bot.entry.js +7 -5
  31. package/dist/esm/ai12z-chat_2.entry.js +6 -6
  32. package/dist/esm/ai12z-cta.entry.js +1 -1
  33. package/dist/esm/ai12z-knowledge-box.entry.js +1 -1
  34. package/dist/esm/{beacon-CvlGzRRz.js → beacon-BLOfGU2-.js} +18 -2
  35. package/dist/esm/index.js +1 -1
  36. package/dist/esm/search-results-page.entry.js +1 -1
  37. package/dist/library/index.esm.js +1 -1
  38. package/dist/library/library.esm.js +1 -1
  39. package/dist/library/{p-58b00a22.entry.js → p-03851cc8.entry.js} +1 -1
  40. package/dist/library/{p-ceb2e683.entry.js → p-516bf868.entry.js} +1 -1
  41. package/dist/library/{p-b277fee9.entry.js → p-65d17a5b.entry.js} +1 -1
  42. package/dist/library/p-CTRVp5uQ.js +1 -0
  43. package/dist/library/p-b01d3dff.entry.js +1 -0
  44. package/dist/library/{p-cbf75654.entry.js → p-d4e410ff.entry.js} +1 -1
  45. package/dist/library/p-f1b93099.entry.js +1 -0
  46. package/dist/types/utils/ctaHelpers.d.ts +0 -1
  47. package/dist/types/utils/utils.d.ts +1 -1
  48. package/package.json +2 -2
  49. package/dist/components/p-6FdpADZf.js +0 -1
  50. package/dist/components/p-BVqv7Ldi.js +0 -1
  51. package/dist/components/p-Caiprvn4.js +0 -1
  52. package/dist/components/p-CfANO9-0.js +0 -1
  53. package/dist/library/p-16b01d52.entry.js +0 -1
  54. package/dist/library/p-6e1f9c89.entry.js +0 -1
  55. package/dist/library/p-BNcQ63DZ.js +0 -1
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var index = require('./index-v8T1EJAJ.js');
4
- var beacon = require('./beacon-CHsypFIj.js');
4
+ var beacon = require('./beacon-Bhd49ADQ.js');
5
5
  require('./utils-BsCPba57.js');
6
6
 
7
7
  const Ai12zBeacon = class {
@@ -15,7 +15,7 @@ var keyboardShortcuts = require('./keyboard-shortcuts-BfEhZKK-.js');
15
15
  var ctaHelpers = require('./ctaHelpers-DL-PGlAx.js');
16
16
  var appStore = require('./app-store-BtkiHvcw.js');
17
17
  var parseHelper = require('./parseHelper-B8pslVtS.js');
18
- var beacon = require('./beacon-CHsypFIj.js');
18
+ var beacon = require('./beacon-Bhd49ADQ.js');
19
19
  var bodyScrollLock = require('./bodyScrollLock-C7gKTAfx.js');
20
20
  require('./_commonjsHelpers-MBWFX2dn.js');
21
21
 
@@ -2261,6 +2261,11 @@ const Ai12zBot = class {
2261
2261
  this.currentDomId = id;
2262
2262
  if (idChanged)
2263
2263
  this.messages = [...this.messages];
2264
+ // capture once, before handleEndResponse mutates this.messages
2265
+ const isFirstExchange = this.messages.length === 2;
2266
+ if (isFirstExchange) {
2267
+ beacon.setConversationId(this.dataKey, this.dataMode, data.conversationId);
2268
+ }
2264
2269
  if (!orphaned) {
2265
2270
  this.messageReceived.emit({ data, domId: this.currentDomId });
2266
2271
  }
@@ -2331,16 +2336,13 @@ const Ai12zBot = class {
2331
2336
  }
2332
2337
  // ✅ Common cleanup
2333
2338
  this.conversationId = data.conversationId;
2334
- if (this.messages.length === 2) {
2335
- beacon.setConversationId(this.dataKey, this.dataMode, this.conversationId);
2336
- }
2337
2339
  // this.saveConversation()
2338
2340
  ctaHelpers.saveConversation((_b = this.botSettings) === null || _b === void 0 ? void 0 : _b.pId, this.messages, this.conversationId, (_d = (_c = this.botSettings._id) === null || _c === void 0 ? void 0 : _c.$oid) !== null && _d !== void 0 ? _d : "", this.visitorID, "bot", {
2339
2341
  isMinimized: this.isMinimized,
2340
2342
  isOpened: this.isOpened,
2341
2343
  isExpanded: this.isExpanded,
2342
2344
  });
2343
- if (this.visitorID && this.messages.length === 2) {
2345
+ if (this.visitorID && isFirstExchange) {
2344
2346
  const sessionKey = botHelpers.getBotStateKey(this.botSettings.pId, (_f = this.botSettings._id) === null || _f === void 0 ? void 0 : _f.$oid);
2345
2347
  sessionStorage.setItem(sessionKey, JSON.stringify({
2346
2348
  isMinimized: this.isMinimized,
@@ -11,7 +11,7 @@ var surveyHelpers = require('./surveyHelpers-D0AfNAN8.js');
11
11
  var keyboardShortcuts = require('./keyboard-shortcuts-BfEhZKK-.js');
12
12
  var analyticsService = require('./analyticsService-CkAva47S.js');
13
13
  var botHelpers = require('./botHelpers-D5Dj7TRA.js');
14
- var beacon = require('./beacon-CHsypFIj.js');
14
+ var beacon = require('./beacon-Bhd49ADQ.js');
15
15
  require('./_commonjsHelpers-MBWFX2dn.js');
16
16
  require('./logger-2ZBZCKdM.js');
17
17
  require('./response-adapter-CKKyyhMj.js');
@@ -400,6 +400,9 @@ const MyChat = class {
400
400
  }
401
401
  this.scrollToLatestBubble();
402
402
  this.isProcessingEndResponse = true;
403
+ if (this.chats.length === 2) {
404
+ beacon.setConversationId(this.apiKey, this.env, event.detail.conversationId);
405
+ }
403
406
  // const idx = this.chats.findIndex(item => item.id === this.aiMessageId)
404
407
  requestAnimationFrame(async () => {
405
408
  var _a, _b, _c, _d;
@@ -455,9 +458,6 @@ const MyChat = class {
455
458
  });
456
459
  // ✅ Common cleanup
457
460
  this.conversationId = event.detail.conversationId;
458
- if (this.chats.length === 2) {
459
- beacon.setConversationId(this.apiKey, this.env, this.conversationId);
460
- }
461
461
  ctaHelpers.saveConversation(this.getProjectId(), this.chats, this.conversationId, (_d = (_c = (_b = this.settings) === null || _b === void 0 ? void 0 : _b._id) === null || _c === void 0 ? void 0 : _c.$oid) !== null && _d !== void 0 ? _d : "", "ai12z-cta-history", "search");
462
462
  this.aiMessageId = "";
463
463
  }
@@ -1142,7 +1142,7 @@ const MyChat = class {
1142
1142
  render() {
1143
1143
  var _a;
1144
1144
  const email = "";
1145
- return (index.h("div", { key: 'f831dd4187ff1bf14c6d841cef5497e2f1286649' }, index.h("ul", { key: '408075b0d4bb3131c867c020dcc3e00b16cc22c2', id: "main-content", tabindex: "-1", class: {
1145
+ return (index.h("div", { key: '0ffe4268143c465bfd5b0ef098680d355aa49527' }, index.h("ul", { key: '2ca1aaa847f8cd9a184a70bbd833f75d148cbd18', id: "main-content", tabindex: "-1", class: {
1146
1146
  "chat-list": true,
1147
1147
  "custom-list": this.componentType === "search",
1148
1148
  // "custom-chat-top-height": this.componentType === "search",
@@ -1209,7 +1209,7 @@ const MyChat = class {
1209
1209
  projectId: this.getProjectId(),
1210
1210
  questionText: analyticsService.getQuestionText(this.chats, chat.insightId) || "",
1211
1211
  }), class: "chat-thumbs-up", "aria-label": "Thumbs Down", tabindex: "0" }, 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" }))), index.h("button", { class: "copy-btn", tabindex: "0", "aria-label": "Send Email" }, index.h("a", { href: `mailto:${email}?subject=${encodeURIComponent((_e = this.chats[idx - 1]) === null || _e === void 0 ? void 0 : _e.message)}&body=${encodeURIComponent(this.removeHtmlTags(chat.clipboard))}`, target: "_blank", "aria-label": "Send Email" }, index.h("svg", { viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", stroke: "currentColor", "stroke-width": "0.3", class: "w-6 h-6" }, index.h("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M3.75 5.25L3 6V18L3.75 18.75H20.25L21 18V6L20.25 5.25H3.75ZM4.5 7.6955V17.25H19.5V7.69525L11.9999 14.5136L4.5 7.6955ZM18.3099 6.75H5.68986L11.9999 12.4864L18.3099 6.75Z", fill: "currentColor" }), " "))))))));
1212
- }), index.h("div", { key: 'd1bb0335acf2e6aa3e732a3733b1a20cbf9b0180', class: "scroll-bottom" }))));
1212
+ }), index.h("div", { key: '9786756a0b61d0f64e57dd3518dd48f6531345ae', class: "scroll-bottom" }))));
1213
1213
  }
1214
1214
  get element() { return index.getElement(this); }
1215
1215
  static get watchers() { return {
@@ -7,7 +7,7 @@ var socketService = require('./socket-service-Dqfi4_qU.js');
7
7
  var globalStore = require('./global-store-R6x06KvJ.js');
8
8
  var reCaptchaHelpers = require('./reCaptchaHelpers-Djq71pt4.js');
9
9
  var ctaHelpers = require('./ctaHelpers-DL-PGlAx.js');
10
- var beacon = require('./beacon-CHsypFIj.js');
10
+ var beacon = require('./beacon-Bhd49ADQ.js');
11
11
  var appStore = require('./app-store-BtkiHvcw.js');
12
12
  var bodyScrollLock = require('./bodyScrollLock-C7gKTAfx.js');
13
13
  require('./response-adapter-CKKyyhMj.js');
@@ -10,7 +10,7 @@ var index$1 = require('./index-CHyfwy-h.js');
10
10
  var surveyHelpers = require('./surveyHelpers-D0AfNAN8.js');
11
11
  var botHelpers = require('./botHelpers-D5Dj7TRA.js');
12
12
  var analyticsService = require('./analyticsService-CkAva47S.js');
13
- var beacon = require('./beacon-CHsypFIj.js');
13
+ var beacon = require('./beacon-Bhd49ADQ.js');
14
14
  require('./_commonjsHelpers-MBWFX2dn.js');
15
15
 
16
16
  const ai12zKnowledgeBoxCss = () => `:host{font-family:var(--ai12z-knowledge-box-font-family) !important;font-size:var(--ai12z-knowledge-box-font-size) !important;color:var(--ai12z-knowledge-box-font-color, black);text-align:var(--ai12z-knowledge-box-text-align, left)}.ai12z-kb-wrapper{background-color:var(--ai12z-knowledge-box-bg-color)}.ai12z-suggest-container{padding:32px 32px 32px 32px;flex:none}.ai12z-suggest-answer{font-size:var(--ai12z-knowledge-box-font-size)}.ai12z-suggest-title{font-weight:700}.ai12z-suggest-align{float:left}.ai12z-suggest-relevance{text-align:end}.ai12z-suggest-error-msg{color:rgb(239 68 68)}.ai12z-suggest-hide{display:none}.ai12z-suggest-thumbs{margin-left:90%}.ai12z-suggest-thumbs-up{fill:var(--ai12z-feedback-selected);width:24px}.ai12z-suggest-thumbs-down{fill:var(--ai12z-feedback-selected);width:24px}.not-allowed{cursor:not-allowed}.ai12zBtn{background-color:var(--ai12z-knowledge-box-button-bgcolor);color:var(--ai12z-knowledge-box-button-color) !important;padding:5px 10px;border:none;border-radius:5px;cursor:pointer;text-decoration:none !important;margin:5px}.custom-privacy{color:var(--ai12z-knowledge-box-privacy-color);text-align:center;font-size:var(--ai12z-knowledge-box-privacy-font-size);margin-top:10px}button:focus-visible{outline:2px solid var(--ai12z-knowledge-box-focus-visible-color, #0A2A43);outline-offset:2px}button.kb-btn-primary:focus-visible{outline:2px solid var(--ai12z-knowledge-box-focus-visible-color-primary, --ai12z-knowledge-box-focus-visible-color);outline-offset:2px}button.kb-btn-secondary:focus-visible{outline:2px solid var(--ai12z-knowledge-box-focus-visible-color-secondary, --ai12z-knowledge-box-focus-visible-color)}.diamond-icon{color:var(--ai12z-knowledge-box-icon-color, #a5e6e6);width:28px;height:28px;transform-origin:center;}.diamond-icon.loading{animation:rotate 2s linear infinite}@keyframes rotate{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}`;
@@ -85,6 +85,7 @@ const ENGINE_MAP = [
85
85
  { engine: "you", hosts: ["you.com"] },
86
86
  ];
87
87
  function detectEngine() {
88
+ var _a;
88
89
  const referrerUrl = getReferrerUrl();
89
90
  const hostname = referrerUrl === null || referrerUrl === void 0 ? void 0 : referrerUrl.hostname.toLowerCase();
90
91
  const currentHostname = window.location.hostname.toLowerCase();
@@ -107,6 +108,16 @@ function detectEngine() {
107
108
  // allow only a conservative charset for engine classification
108
109
  return /^[a-z0-9_.-]+$/.test(s) ? s : null;
109
110
  };
111
+ const sanitizeHostnameForEngine = (hostname) => {
112
+ if (!hostname)
113
+ return null;
114
+ const value = hostname.toLowerCase().trim();
115
+ // Don't truncate hostnames.
116
+ // Reject values that are too long or contain unexpected characters.
117
+ if (value.length > 253)
118
+ return null;
119
+ return /^[a-z0-9_.:-]+$/.test(value) ? value : null;
120
+ };
110
121
  const utmSource = sanitizeUtmForEngine(rawUtmSource);
111
122
  if (utmSource) {
112
123
  // If utm matches a supported engine, return that engine; otherwise
@@ -115,7 +126,7 @@ function detectEngine() {
115
126
  // the sentinel "other".
116
127
  return SUPPORTED_ENGINES.includes(utmSource) ? utmSource : utmSource;
117
128
  }
118
- return hostname && !isInternalReferrer ? hostname : "direct";
129
+ return hostname && !isInternalReferrer ? (_a = sanitizeHostnameForEngine(hostname)) !== null && _a !== void 0 ? _a : "direct" : "direct";
119
130
  }
120
131
  function inferEngineType(engine, explicitType) {
121
132
  return ENGINE_TYPE_MAP[engine];
@@ -152,10 +163,15 @@ async function waitForPendingBeacon(timeoutMs = 10000) {
152
163
  return sessionStorage.getItem("ai12zBeaconId");
153
164
  }
154
165
  // Hosts for which beacon creation and conversation setting should be disabled.
155
- let excludedBeaconHosts = ["ai12z.net"];
166
+ const excludedBeaconHosts = ["ai12z.net"];
167
+ const allowedBeaconHosts = ["docs.ai12z.net"];
156
168
  function isHostExcluded() {
157
169
  try {
158
170
  const hostname = window.location.hostname.toLowerCase();
171
+ // Explicitly allow docs.ai12z.net
172
+ if (allowedBeaconHosts.includes(hostname)) {
173
+ return false;
174
+ }
159
175
  return excludedBeaconHosts.some(h => h && (hostname === h || hostname.endsWith(`.${h}`)));
160
176
  }
161
177
  catch (_a) {
@@ -10,7 +10,7 @@ var ai12zInlineSearch_entry = require('./ai12z-inline-search.entry.cjs.js');
10
10
  var ai12zForm_entry = require('./ai12z-form.entry.cjs.js');
11
11
  var ai12zContainer_entry = require('./ai12z-container.entry.cjs.js');
12
12
  require('./index-v8T1EJAJ.js');
13
- require('./beacon-CHsypFIj.js');
13
+ require('./beacon-Bhd49ADQ.js');
14
14
  require('./utils-BsCPba57.js');
15
15
  require('./response-adapter-CKKyyhMj.js');
16
16
  require('./processCarouselData-DVJtwUsv.js');
@@ -7,7 +7,7 @@ var socketService = require('./socket-service-Dqfi4_qU.js');
7
7
  var ctaHelpers = require('./ctaHelpers-DL-PGlAx.js');
8
8
  var globalStore = require('./global-store-R6x06KvJ.js');
9
9
  var reCaptchaHelpers = require('./reCaptchaHelpers-Djq71pt4.js');
10
- var beacon = require('./beacon-CHsypFIj.js');
10
+ var beacon = require('./beacon-Bhd49ADQ.js');
11
11
  require('./response-adapter-CKKyyhMj.js');
12
12
 
13
13
  const searchResultsViewCss = () => `:host{display:block;width:100%;font-family:var(--ai12z-font-family);font-size:var(--ai12z-font-size);color:var(--ai12z-font-color, black);text-align:var(--ai12z-text-align, left)}.search-page-container{background-color:var(--ai12z-search-bar-bgcolor, rgb(244, 242, 238))}.submit-button{background-color:var(--ai12z-search-bar-button-bgcolor, var(--ai12z-primary-color))}.custom-svg-checkbox{margin-top:4px;width:16px;height:16px;position:absolute}.follow-up-input{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:16px;height:16px;border-width:2px;flex-shrink:0;margin-top:4px;border-radius:2px;border-color:rgb(59 130 246)}.follow-up-input:checked{background-color:var(--ai12z-followup-bg-color);border-width:0px}.follow-up{display:flex;gap:8px;color:var(--ai12z-followup-color);font-size:var(--ai12z-followup-font-size)}.image-Container{position:relative;display:inline-block;margin-right:10px}.delete-image{opacity:3;position:absolute;right:3px;top:0;cursor:pointer;line-height:10px}.plus-icon{color:var(--ai12z-plus-icon-color)}.search-panel-wrapper{height:100%;display:flex;flex-direction:column}#searchPanel{flex:1;display:flex;flex-direction:column;}.content-area{flex:1;overflow-y:auto}.welcome-template-container{flex-shrink:0;padding:16px;background:rgba(255, 255, 255, 0.95);backdrop-filter:blur(8px);margin-left:auto;margin-right:auto;}.welcome-template-container{animation:slideUp 0.3s ease-out}@keyframes slideUp{from{transform:translateY(100%);opacity:0}to{transform:translateY(0);opacity:1}}.error-message-container{margin-top:4px}.error-msg{color:#dc2626;font-size:12px;display:block;animation:slideIn 0.2s ease-out}.enter-tip{font-size:12px;color:#fff;margin-left:10px}#searchForm{margin:0px}.search-layout{display:grid;grid-template-columns:minmax(0, 1fr) 420px;gap:32px;width:100%;padding:0 16px}.left-column{height:100vh;display:flex;flex-direction:column}.quick-links-column{position:sticky;top:88px;height:-moz-fit-content;height:fit-content;}.chat-fieldset{border:2px solid var(--ai12z-primary-color);border-radius:16px;padding:12px;margin:0;background-color:var(--ai12z-primary-color)}.cta-search-results{border-top-width:1px;border-bottom-width:0px;border-color:rgb(243 244 246)}.cta-search-results-list{position:relative;padding-bottom:20px;padding-top:20px}.cta-search-results-list:hover{background-color:var(--ai12z-hover-bg-color)}.cta-search-container{margin-left:auto;margin-right:auto;display:flex;max-width:896px;justify-content:space-between;-moz-column-gap:24px;column-gap:24px}.cta-search-container-two{display:flex;min-width:0px;-moz-column-gap:16px;column-gap:16px}.cta-search-container-three{min-width:0px;flex:1 1 auto}.cta-search-text{font-weight:600;line-height:24px;font-size:var(--ai12z-search-result-title-font-size);color:var(--ai12z-search-result-title-color)}.cta-search-text-position{position:absolute;left:0px;right:0px;top:-1px;bottom:0px}.cta-search-description{margin-top:4px;display:flex;font-size:var(--ai12z-search-result-description-font-size);line-height:16px;line-height:20px;color:var(--ai12z-search-result-description-color)}.cta-search-list-arrow{display:flex;align-items:center;flex-shrink:0;-moz-column-gap:16px;column-gap:16px}.custom-icon-width{width:64px}.results-icon svg{width:24px;height:24px}@keyframes slideIn{from{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}.chat-content-wrapper::-webkit-scrollbar{width:8px}.chat-content-wrapper::-webkit-scrollbar-track{background:var(--ai12z-scrollbar-track-color, #f1f1f1);border-radius:10px}.chat-content-wrapper::-webkit-scrollbar-button{display:none}.chat-content-wrapper::-webkit-scrollbar-thumb{background:var(--ai12z-scrollbar-thumb-color, #888);border-radius:10px}.chat-content-wrapper::-webkit-scrollbar-thumb:hover{background:var(--ai12z-scrollbar-thumb-hover-color, #555)}.chat-content-wrapper{scrollbar-width:thin;scrollbar-color:var(--ai12z-scrollbar-thumb-color, #888) var(--ai12z-scrollbar-track-color, #f1f1f1);min-height:0}@media (max-width: 768px){.search-layout{grid-template-columns:1fr;gap:16px}.quick-links-column{display:none}.welcome-template-container{padding:12px}.welcome-template-content{padding:16px;border-radius:12px}.chat-content-wrapper::-webkit-scrollbar{width:4px}}.sources-panel{width:360px;padding:16px;border-radius:12px;font-family:system-ui, -apple-system, sans-serif}.title{margin:0 0 12px;font-size:16px;font-weight:600;color:#0f172a}.skeleton-list{display:flex;flex-direction:column;gap:10px}.skeleton-line{height:14px;border-radius:999px;background:linear-gradient( 90deg, #e5e7eb 25%, #f1f5f9 37%, #e5e7eb 63% );background-size:400% 100%;}.skeleton-line.short{width:65%}.divider{height:1px;background:#e2e8f0;margin:6px 0}@keyframes shimmer{0%{background-position:100% 0}100%{background-position:-100% 0}}`;
@@ -1227,6 +1227,11 @@ export class Ai12zBot {
1227
1227
  this.currentDomId = id;
1228
1228
  if (idChanged)
1229
1229
  this.messages = [...this.messages];
1230
+ // capture once, before handleEndResponse mutates this.messages
1231
+ const isFirstExchange = this.messages.length === 2;
1232
+ if (isFirstExchange) {
1233
+ setConversationId(this.dataKey, this.dataMode, data.conversationId);
1234
+ }
1230
1235
  if (!orphaned) {
1231
1236
  this.messageReceived.emit({ data, domId: this.currentDomId });
1232
1237
  }
@@ -1297,16 +1302,13 @@ export class Ai12zBot {
1297
1302
  }
1298
1303
  // ✅ Common cleanup
1299
1304
  this.conversationId = data.conversationId;
1300
- if (this.messages.length === 2) {
1301
- setConversationId(this.dataKey, this.dataMode, this.conversationId);
1302
- }
1303
1305
  // this.saveConversation()
1304
1306
  saveConversation((_b = this.botSettings) === null || _b === void 0 ? void 0 : _b.pId, this.messages, this.conversationId, (_d = (_c = this.botSettings._id) === null || _c === void 0 ? void 0 : _c.$oid) !== null && _d !== void 0 ? _d : "", this.visitorID, "bot", {
1305
1307
  isMinimized: this.isMinimized,
1306
1308
  isOpened: this.isOpened,
1307
1309
  isExpanded: this.isExpanded,
1308
1310
  });
1309
- if (this.visitorID && this.messages.length === 2) {
1311
+ if (this.visitorID && isFirstExchange) {
1310
1312
  const sessionKey = getBotStateKey(this.botSettings.pId, (_f = this.botSettings._id) === null || _f === void 0 ? void 0 : _f.$oid);
1311
1313
  sessionStorage.setItem(sessionKey, JSON.stringify({
1312
1314
  isMinimized: this.isMinimized,
@@ -392,6 +392,9 @@ export class MyChat {
392
392
  }
393
393
  this.scrollToLatestBubble();
394
394
  this.isProcessingEndResponse = true;
395
+ if (this.chats.length === 2) {
396
+ setConversationId(this.apiKey, this.env, event.detail.conversationId);
397
+ }
395
398
  // const idx = this.chats.findIndex(item => item.id === this.aiMessageId)
396
399
  requestAnimationFrame(async () => {
397
400
  var _a, _b, _c, _d;
@@ -447,9 +450,6 @@ export class MyChat {
447
450
  });
448
451
  // ✅ Common cleanup
449
452
  this.conversationId = event.detail.conversationId;
450
- if (this.chats.length === 2) {
451
- setConversationId(this.apiKey, this.env, this.conversationId);
452
- }
453
453
  saveConversation(this.getProjectId(), this.chats, this.conversationId, (_d = (_c = (_b = this.settings) === null || _b === void 0 ? void 0 : _b._id) === null || _c === void 0 ? void 0 : _c.$oid) !== null && _d !== void 0 ? _d : "", "ai12z-cta-history", "search");
454
454
  this.aiMessageId = "";
455
455
  }
@@ -1135,7 +1135,7 @@ export class MyChat {
1135
1135
  render() {
1136
1136
  var _a;
1137
1137
  const email = "";
1138
- return (h("div", { key: 'f831dd4187ff1bf14c6d841cef5497e2f1286649' }, h("ul", { key: '408075b0d4bb3131c867c020dcc3e00b16cc22c2', id: "main-content", tabindex: "-1", class: {
1138
+ return (h("div", { key: '0ffe4268143c465bfd5b0ef098680d355aa49527' }, h("ul", { key: '2ca1aaa847f8cd9a184a70bbd833f75d148cbd18', id: "main-content", tabindex: "-1", class: {
1139
1139
  "chat-list": true,
1140
1140
  "custom-list": this.componentType === "search",
1141
1141
  // "custom-chat-top-height": this.componentType === "search",
@@ -1202,7 +1202,7 @@ export class MyChat {
1202
1202
  projectId: this.getProjectId(),
1203
1203
  questionText: getQuestionText(this.chats, chat.insightId) || "",
1204
1204
  }), class: "chat-thumbs-up", "aria-label": "Thumbs Down", tabindex: "0" }, 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" }, 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" }))), h("button", { class: "copy-btn", tabindex: "0", "aria-label": "Send Email" }, h("a", { href: `mailto:${email}?subject=${encodeURIComponent((_e = this.chats[idx - 1]) === null || _e === void 0 ? void 0 : _e.message)}&body=${encodeURIComponent(this.removeHtmlTags(chat.clipboard))}`, target: "_blank", "aria-label": "Send Email" }, h("svg", { viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", stroke: "currentColor", "stroke-width": "0.3", class: "w-6 h-6" }, h("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M3.75 5.25L3 6V18L3.75 18.75H20.25L21 18V6L20.25 5.25H3.75ZM4.5 7.6955V17.25H19.5V7.69525L11.9999 14.5136L4.5 7.6955ZM18.3099 6.75H5.68986L11.9999 12.4864L18.3099 6.75Z", fill: "currentColor" }), " "))))))));
1205
- }), h("div", { key: 'd1bb0335acf2e6aa3e732a3733b1a20cbf9b0180', class: "scroll-bottom" }))));
1205
+ }), h("div", { key: '9786756a0b61d0f64e57dd3518dd48f6531345ae', class: "scroll-bottom" }))));
1206
1206
  }
1207
1207
  static get is() { return "ai12z-chat"; }
1208
1208
  static get encapsulation() { return "shadow"; }
@@ -83,6 +83,7 @@ export const ENGINE_MAP = [
83
83
  { engine: "you", hosts: ["you.com"] },
84
84
  ];
85
85
  export function detectEngine() {
86
+ var _a;
86
87
  const referrerUrl = getReferrerUrl();
87
88
  const hostname = referrerUrl === null || referrerUrl === void 0 ? void 0 : referrerUrl.hostname.toLowerCase();
88
89
  const currentHostname = window.location.hostname.toLowerCase();
@@ -105,6 +106,16 @@ export function detectEngine() {
105
106
  // allow only a conservative charset for engine classification
106
107
  return /^[a-z0-9_.-]+$/.test(s) ? s : null;
107
108
  };
109
+ const sanitizeHostnameForEngine = (hostname) => {
110
+ if (!hostname)
111
+ return null;
112
+ const value = hostname.toLowerCase().trim();
113
+ // Don't truncate hostnames.
114
+ // Reject values that are too long or contain unexpected characters.
115
+ if (value.length > 253)
116
+ return null;
117
+ return /^[a-z0-9_.:-]+$/.test(value) ? value : null;
118
+ };
108
119
  const utmSource = sanitizeUtmForEngine(rawUtmSource);
109
120
  if (utmSource) {
110
121
  // If utm matches a supported engine, return that engine; otherwise
@@ -113,7 +124,7 @@ export function detectEngine() {
113
124
  // the sentinel "other".
114
125
  return SUPPORTED_ENGINES.includes(utmSource) ? utmSource : utmSource;
115
126
  }
116
- return hostname && !isInternalReferrer ? hostname : "direct";
127
+ return hostname && !isInternalReferrer ? (_a = sanitizeHostnameForEngine(hostname)) !== null && _a !== void 0 ? _a : "direct" : "direct";
117
128
  }
118
129
  function inferEngineType(engine, explicitType) {
119
130
  if (explicitType && SUPPORTED_ENGINE_TYPES.includes(explicitType)) {
@@ -153,10 +164,15 @@ async function waitForPendingBeacon(timeoutMs = 10000) {
153
164
  return sessionStorage.getItem("ai12zBeaconId");
154
165
  }
155
166
  // Hosts for which beacon creation and conversation setting should be disabled.
156
- let excludedBeaconHosts = ["ai12z.net"];
167
+ const excludedBeaconHosts = ["ai12z.net"];
168
+ const allowedBeaconHosts = ["docs.ai12z.net"];
157
169
  function isHostExcluded() {
158
170
  try {
159
171
  const hostname = window.location.hostname.toLowerCase();
172
+ // Explicitly allow docs.ai12z.net
173
+ if (allowedBeaconHosts.includes(hostname)) {
174
+ return false;
175
+ }
160
176
  return excludedBeaconHosts.some(h => h && (hostname === h || hostname.endsWith(`.${h}`)));
161
177
  }
162
178
  catch (_a) {
@@ -78,22 +78,6 @@ export function detectLanguage() {
78
78
  export function isMac() {
79
79
  return /(Mac|iPhone|iPod|iPad)/i.test(navigator.userAgent);
80
80
  }
81
- // Utility: Lock or unlock body scroll on iOS devices when modals are opened/closed
82
- export function lockBodyScrollForIOS(lock) {
83
- const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent);
84
- if (!isIOS)
85
- return;
86
- if (lock) {
87
- document.body.style.overflow = "hidden";
88
- document.body.style.position = "fixed";
89
- document.body.style.width = "100%";
90
- }
91
- else {
92
- document.body.style.overflow = "";
93
- document.body.style.position = "";
94
- document.body.style.width = "";
95
- }
96
- }
97
81
  // Utility: Set local storage data
98
82
  export function setLocalData(key, data) {
99
83
  localStorage.setItem(key, JSON.stringify(data));
@@ -1 +1 @@
1
- import{A as o,d as p}from"./p-Caiprvn4.js";const r=o,s=p;export{r as Ai12zBeacon,s as defineCustomElement}
1
+ import{A as o,d as s}from"./p-HTPyCRCK.js";const p=o,r=s;export{p as Ai12zBeacon,r as defineCustomElement}
@@ -1 +1 @@
1
- import{A as o,d as s}from"./p-CfANO9-0.js";const p=o,r=s;export{p as Ai12zBot,r as defineCustomElement}
1
+ import{A as o,d as s}from"./p-CnIXGAt8.js";const t=o,p=s;export{t as Ai12zBot,p as defineCustomElement}
@@ -1 +1 @@
1
- import{M as o,d as s}from"./p-BVqv7Ldi.js";const p=o,r=s;export{p as Ai12zChat,r as defineCustomElement}
1
+ import{M as o,d as s}from"./p-CYh3so8v.js";const p=o,r=s;export{p as Ai12zChat,r as defineCustomElement}
@@ -1 +1 @@
1
- import{A as s,d as o}from"./p--yAsbu4H.js";const p=s,r=o;export{p as Ai12zCta,r as defineCustomElement}
1
+ import{A as s,d as o}from"./p-B_GRAsXZ.js";const p=s,r=o;export{p as Ai12zCta,r as defineCustomElement}
@@ -1 +1 @@
1
- import{A as o,d as s}from"./p-Dcm7MWBo.js";const m=o,p=s;export{m as Ai12zInlineSearch,p as defineCustomElement}
1
+ import{A as o,d as s}from"./p-fVj5IyS0.js";const p=o,r=s;export{p as Ai12zInlineSearch,r as defineCustomElement}
@@ -1 +1 @@
1
- import{A as o,d as s}from"./p-Di0FiI3Q.js";const i=o,p=s;export{i as Ai12zKnowledgeBox,p as defineCustomElement}
1
+ import{A as o,d as p}from"./p-CMc63lZp.js";const s=o,r=p;export{s as Ai12zKnowledgeBox,r as defineCustomElement}
@@ -1 +1 @@
1
- import{g as o}from"./p-rVmRQ8bG.js";export{a as getAssetPath,r as render,s as setAssetPath,b as setNonce,c as setPlatformOptions}from"./p-rVmRQ8bG.js";export{A as Ai12zBeacon}from"./p-Caiprvn4.js";export{A as Ai12zBot}from"./p-CfANO9-0.js";export{A as Ai12zCta}from"./p--yAsbu4H.js";export{A as Ai12zKnowledgeBox}from"./p-Di0FiI3Q.js";export{S as Ai12zSearchPanel}from"./p-BjX5cCOG.js";export{S as Ai12zSearchResultsPage}from"./p-tcK5_WYS.js";export{A as Ai12zInlineSearch}from"./p-Dcm7MWBo.js";export{A as Ai12zForm}from"./p-BRLTYejK.js";export{A as Ai12zContainer}from"./p-CAK1__lu.js";o();
1
+ import{g as e}from"./p-rVmRQ8bG.js";export{a as getAssetPath,r as render,s as setAssetPath,b as setNonce,c as setPlatformOptions}from"./p-rVmRQ8bG.js";export{A as Ai12zBeacon}from"./p-HTPyCRCK.js";export{A as Ai12zBot}from"./p-CnIXGAt8.js";export{A as Ai12zCta}from"./p-B_GRAsXZ.js";export{A as Ai12zKnowledgeBox}from"./p-CMc63lZp.js";export{S as Ai12zSearchPanel}from"./p-BjX5cCOG.js";export{S as Ai12zSearchResultsPage}from"./p-CO7OM6cu.js";export{A as Ai12zInlineSearch}from"./p-fVj5IyS0.js";export{A as Ai12zForm}from"./p-BRLTYejK.js";export{A as Ai12zContainer}from"./p-CAK1__lu.js";e();