ai12z 3.17.1-alpha.3 → 3.17.1-alpha.4
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-beacon.cjs.entry.js +1 -1
- package/dist/cjs/ai12z-bot.cjs.entry.js +1 -1
- package/dist/cjs/ai12z-chat_2.cjs.entry.js +1 -1
- package/dist/cjs/ai12z-cta.cjs.entry.js +1 -1
- package/dist/cjs/ai12z-knowledge-box.cjs.entry.js +1 -1
- package/dist/cjs/{beacon-DwOvY6Ne.js → beacon-Qui7JFxE.js} +8 -1
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/search-results-page.cjs.entry.js +1 -1
- package/dist/collection/utils/beacon.js +8 -1
- package/dist/components/ai12z-beacon.js +1 -1
- package/dist/components/ai12z-bot.js +1 -1
- package/dist/components/ai12z-chat.js +1 -1
- package/dist/components/ai12z-cta.js +1 -1
- package/dist/components/ai12z-inline-search.js +1 -1
- package/dist/components/ai12z-knowledge-box.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/{p-D4Bi4PpL.js → p-60cjMOJ4.js} +1 -1
- package/dist/components/{p-BpnC79Lm.js → p-BeUTZLNf.js} +1 -1
- package/dist/components/{p-ChhV7973.js → p-BkTlHh9c.js} +1 -1
- package/dist/components/{p-wcfgc9LM.js → p-BvzGHML-.js} +1 -1
- package/dist/components/{p-DqZdaqsU.js → p-C8IRCewt.js} +1 -1
- package/dist/components/{p-DVU3eIHC.js → p-CJ31xs4L.js} +1 -1
- package/dist/components/p-D5Grnjb5.js +1 -0
- package/dist/components/{p-yhzHvmpm.js → p-qiYTcubE.js} +1 -1
- package/dist/components/search-results-page.js +1 -1
- package/dist/esm/ai12z-beacon.entry.js +1 -1
- package/dist/esm/ai12z-bot.entry.js +1 -1
- package/dist/esm/ai12z-chat_2.entry.js +1 -1
- package/dist/esm/ai12z-cta.entry.js +1 -1
- package/dist/esm/ai12z-knowledge-box.entry.js +1 -1
- package/dist/esm/{beacon-DOd-Eyt3.js → beacon-DpRoUXFM.js} +8 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/search-results-page.entry.js +1 -1
- package/dist/library/index.esm.js +1 -1
- package/dist/library/library.esm.js +1 -1
- package/dist/library/{p-8f1bffc1.entry.js → p-985d9580.entry.js} +1 -1
- package/dist/library/p-B-vRsNiN.js +1 -0
- package/dist/library/{p-673c9f70.entry.js → p-d966f948.entry.js} +1 -1
- package/dist/library/{p-910a4e9a.entry.js → p-d9de54c0.entry.js} +1 -1
- package/dist/library/{p-43279753.entry.js → p-e3549867.entry.js} +1 -1
- package/dist/library/p-f178510e.entry.js +1 -0
- package/dist/library/{p-bbcbf218.entry.js → p-f65caaee.entry.js} +1 -1
- package/package.json +2 -2
- package/dist/components/p-DVE50Spy.js +0 -1
- package/dist/library/p-De893Lcf.js +0 -1
- package/dist/library/p-d7128597.entry.js +0 -1
|
@@ -15,7 +15,7 @@ var keyboardShortcuts = require('./keyboard-shortcuts-CBUd9KfQ.js');
|
|
|
15
15
|
var ctaHelpers = require('./ctaHelpers-CdztrD6A.js');
|
|
16
16
|
var appStore = require('./app-store-BtkiHvcw.js');
|
|
17
17
|
var parseHelper = require('./parseHelper-BuoIRCbd.js');
|
|
18
|
-
var beacon = require('./beacon-
|
|
18
|
+
var beacon = require('./beacon-Qui7JFxE.js');
|
|
19
19
|
var bodyScrollLock = require('./bodyScrollLock-C7gKTAfx.js');
|
|
20
20
|
require('./_commonjsHelpers-MBWFX2dn.js');
|
|
21
21
|
|
|
@@ -11,7 +11,7 @@ var surveyHelpers = require('./surveyHelpers-B9t5lxy4.js');
|
|
|
11
11
|
var keyboardShortcuts = require('./keyboard-shortcuts-CBUd9KfQ.js');
|
|
12
12
|
var analyticsService = require('./analyticsService-CkAva47S.js');
|
|
13
13
|
var botHelpers = require('./botHelpers-D5Dj7TRA.js');
|
|
14
|
-
var beacon = require('./beacon-
|
|
14
|
+
var beacon = require('./beacon-Qui7JFxE.js');
|
|
15
15
|
require('./_commonjsHelpers-MBWFX2dn.js');
|
|
16
16
|
require('./logger-2ZBZCKdM.js');
|
|
17
17
|
require('./response-adapter-CKKyyhMj.js');
|
|
@@ -7,7 +7,7 @@ var socketService = require('./socket-service-j9VBg1pS.js');
|
|
|
7
7
|
var globalStore = require('./global-store-R6x06KvJ.js');
|
|
8
8
|
var reCaptchaHelpers = require('./reCaptchaHelpers-DIDQT22p.js');
|
|
9
9
|
var ctaHelpers = require('./ctaHelpers-CdztrD6A.js');
|
|
10
|
-
var beacon = require('./beacon-
|
|
10
|
+
var beacon = require('./beacon-Qui7JFxE.js');
|
|
11
11
|
var appStore = require('./app-store-BtkiHvcw.js');
|
|
12
12
|
var bodyScrollLock = require('./bodyScrollLock-C7gKTAfx.js');
|
|
13
13
|
var purify_es = require('./purify.es-B7Ashs9w.js');
|
|
@@ -10,7 +10,7 @@ var index$1 = require('./index-B6xfVjPU.js');
|
|
|
10
10
|
var surveyHelpers = require('./surveyHelpers-B9t5lxy4.js');
|
|
11
11
|
var botHelpers = require('./botHelpers-D5Dj7TRA.js');
|
|
12
12
|
var analyticsService = require('./analyticsService-CkAva47S.js');
|
|
13
|
-
var beacon = require('./beacon-
|
|
13
|
+
var beacon = require('./beacon-Qui7JFxE.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)}}`;
|
|
@@ -91,8 +91,15 @@ function detectEngine() {
|
|
|
91
91
|
const currentHostname = window.location.hostname.toLowerCase();
|
|
92
92
|
const isInternalReferrer = hostname === currentHostname;
|
|
93
93
|
if (hostname && !isInternalReferrer) {
|
|
94
|
+
// First, check exact hostname matches.
|
|
94
95
|
for (const item of ENGINE_MAP) {
|
|
95
|
-
if (item.hosts.some(host => hostname === host
|
|
96
|
+
if (item.hosts.some(host => hostname === host)) {
|
|
97
|
+
return item.engine;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
// Then, check subdomain/parent-domain matches.
|
|
101
|
+
for (const item of ENGINE_MAP) {
|
|
102
|
+
if (item.hosts.some(host => hostname.endsWith(`.${host}`))) {
|
|
96
103
|
return item.engine;
|
|
97
104
|
}
|
|
98
105
|
}
|
package/dist/cjs/index.cjs.js
CHANGED
|
@@ -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-
|
|
13
|
+
require('./beacon-Qui7JFxE.js');
|
|
14
14
|
require('./utils-DZMolZh2.js');
|
|
15
15
|
require('./response-adapter-CKKyyhMj.js');
|
|
16
16
|
require('./processCarouselData-BXglENd8.js');
|
|
@@ -7,7 +7,7 @@ var socketService = require('./socket-service-j9VBg1pS.js');
|
|
|
7
7
|
var ctaHelpers = require('./ctaHelpers-CdztrD6A.js');
|
|
8
8
|
var globalStore = require('./global-store-R6x06KvJ.js');
|
|
9
9
|
var reCaptchaHelpers = require('./reCaptchaHelpers-DIDQT22p.js');
|
|
10
|
-
var beacon = require('./beacon-
|
|
10
|
+
var beacon = require('./beacon-Qui7JFxE.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))}.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)}#searchPanel{flex:1;min-height:0;display:flex;flex-direction:column}.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}.search-layout-no-aside{grid-template-columns:minmax(0, 1fr)}.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}.has-conversation .welcome-template-container{display:none}}.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}}.chat-panel{flex:1;min-height:0;display:flex;flex-direction:column}.chat-content-wrapper{min-height:0;overflow-y:auto;flex:1}.chat-fixed-section{flex-shrink:0;display:flex;flex-direction:column;position:sticky;top:0;z-index:1000}.textarea-at-top .chat-fixed-section{top:0;bottom:auto;order:1}.textarea-at-top .chat-content-wrapper{order:2}.textarea-at-top .chat-fieldset{order:1}.textarea-at-top .welcome-template-container{order:2}.textarea-at-bottom .chat-content-wrapper{order:1}.textarea-at-bottom .chat-fixed-section{top:auto;bottom:0;order:2}.textarea-at-bottom .welcome-template-container{order:1}.textarea-at-bottom .chat-fieldset{order:2}`;
|
|
@@ -89,8 +89,15 @@ export function detectEngine() {
|
|
|
89
89
|
const currentHostname = window.location.hostname.toLowerCase();
|
|
90
90
|
const isInternalReferrer = hostname === currentHostname;
|
|
91
91
|
if (hostname && !isInternalReferrer) {
|
|
92
|
+
// First, check exact hostname matches.
|
|
92
93
|
for (const item of ENGINE_MAP) {
|
|
93
|
-
if (item.hosts.some(host => hostname === host
|
|
94
|
+
if (item.hosts.some(host => hostname === host)) {
|
|
95
|
+
return item.engine;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
// Then, check subdomain/parent-domain matches.
|
|
99
|
+
for (const item of ENGINE_MAP) {
|
|
100
|
+
if (item.hosts.some(host => hostname.endsWith(`.${host}`))) {
|
|
94
101
|
return item.engine;
|
|
95
102
|
}
|
|
96
103
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as
|
|
1
|
+
import{A as o,d as s}from"./p-C8IRCewt.js";const t=o,p=s;export{t as Ai12zBeacon,p as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as
|
|
1
|
+
import{A as o,d as s}from"./p-qiYTcubE.js";const p=o,r=s;export{p as Ai12zBot,r as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{M as o,d as
|
|
1
|
+
import{M as o,d as s}from"./p-BeUTZLNf.js";const p=o,r=s;export{p as Ai12zChat,r as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as o,d as s}from"./p-
|
|
1
|
+
import{A as o,d as s}from"./p-BvzGHML-.js";const p=o,r=s;export{p as Ai12zCta,r as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as o,d as s}from"./p-
|
|
1
|
+
import{A as o,d as s}from"./p-BkTlHh9c.js";const p=o,r=s;export{p as Ai12zInlineSearch,r as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as
|
|
1
|
+
import{A as s,d as o}from"./p-CJ31xs4L.js";const p=s,r=o;export{p as Ai12zKnowledgeBox,r as defineCustomElement}
|
package/dist/components/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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-
|
|
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-C8IRCewt.js";export{A as Ai12zBot}from"./p-qiYTcubE.js";export{A as Ai12zCta}from"./p-BvzGHML-.js";export{A as Ai12zKnowledgeBox}from"./p-CJ31xs4L.js";export{S as Ai12zSearchPanel}from"./p-VL7c6YwM.js";export{S as Ai12zSearchResultsPage}from"./p-60cjMOJ4.js";export{A as Ai12zInlineSearch}from"./p-BkTlHh9c.js";export{A as Ai12zForm}from"./p-DM33B5uU.js";export{A as Ai12zContainer}from"./p-CmXVb_3J.js";e();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e,p as t,H as s,e as i,E as a,f as o,h as c}from"./p-rVmRQ8bG.js";import{d as r,n,h as l,o as h,E as d,a as f,q as b}from"./p-djQQf6su.js";import{d as p,S as u}from"./p-CaMH5wYq.js";import{d as m,S as g}from"./p-BpnC79Lm.js";import{n as v,m as y,k as x,a as k,i as w}from"./p-CW_iO9zy.js";import{e as C}from"./p-CNxI_jB-.js";import{i as z}from"./p-DVE50Spy.js";import{d as S}from"./p-DkBtust7.js";const E=t(class extends s{constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow(),this.messageSent=i(this,"messageSent",7),this.messageReceived=i(this,"messageReceived",7),this.errored=i(this,"errored",7),this.startStream=i(this,"startStream",7),this.cdnPath="https://cdn.ai12z.net/assets/cta",this.dataKey=a.DATA_KEY||"",this.dataMode=a.DATA_MODE||"prod",this.excludeTags=[],this.includeTags=[],this.query="",this.searchResultSettings={},this.searchResults=[],this.hideAllButtons=!1,this.isChat=!1,this.chatHistory=[],this.aiMessageId=null,this.thumbsId=null,this.isOpen=!1,this.capturedFile=null,this.imgFiles=[],this.displayText="",this.questionCounter=0,this.emptyMessageError=!1,this.announceMessage="",this.isRendered=!1,this.imagesBase64List=[],this.handleKeyDown=e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),this.query&&this.query.trim().length>0||this.imagesBase64List.length>0?this.handleFormSubmit(e):(this.emptyMessageError=!0,this.searchInputElem&&this.searchInputElem.focus(),setTimeout((()=>{this.emptyMessageError=!1}),3e3)))},this.adjustHeight=()=>{this.searchInputElem.style.height="auto",this.searchInputElem.style.height=this.searchInputElem.scrollHeight+"px"},this.updateInputFromTranscript=async e=>{this.query=e,await new Promise(requestAnimationFrame),this.adjustHeight(),this.searchResultSettings.autoSearch&&e.trim().length>3&&await this.fetchSearchResults()},this.toggleBox=e=>{e.stopPropagation(),this.isOpen=!this.isOpen},this.handleClickOutside=e=>{this.isOpen&&this.menuElem&&!this.menuElem.contains(e.target)&&(this.isOpen=!1)}}async fetchSearchResults(){const e=await n(this.dataKey,this.dataMode,this.query);this.searchResults=e.docs?[...e.docs]:[]}messageReceivedHandler(e){e.detail&&e.detail.data.context&&e.detail.data.context.length>0&&this.searchResultSettings.autoSearch&&(this.searchResults=e.detail.data.context||[])}async sendMessage(e,t){this.query=null!=t?t:e,this.handleFormSubmit(new SubmitEvent("submit")),this.messageSent.emit(e)}async sendJSON(e,t){this.displayText=t,this.query=e,this.handleFormSubmit(new SubmitEvent("submit")),this.messageSent.emit(e)}async configSearchSettings(){var e,t,s,i;const o={apiKey:this.dataKey,configId:this.configId,configType:"searchResult"};try{const c=await l(o,this.dataMode);if(c){if(this.searchResultSettings=c,null===(e=null==c?void 0:c.v3)||void 0===e?void 0:e.siteKey)try{const e=await C(c._id,c.v3.siteKey,"searchResult",this.dataKey,this.dataMode,(e=>{this.errored.emit(e)}));this.isRendered=!!e}catch(e){console.error("Recaptcha verification failed:",e),this.isRendered=!1}else this.isRendered=!0;if(void 0===(null===(t=this.searchResultSettings)||void 0===t?void 0:t.autoSearch)&&(this.searchResultSettings.autoSearch=!0),this.searchResultSettings.theme){let e="";e="custom"!==this.searchResultSettings.theme?`${this.cdnPath}/${a.CDN_PATH}/themes/theme-${this.searchResultSettings.theme}.css`:this.searchResultSettings.customTheme;const t=document.createElement("link");t.setAttribute("rel","stylesheet"),t.setAttribute("href",e),document.head.appendChild(t)}if(void 0===(null===(s=this.searchResultSettings)||void 0===s?void 0:s.categorize)&&(this.searchResultSettings.categorize=!0),this.searchResultSettings.customCSS&&this.insertCustomCSS(this.searchResultSettings.customCSS),this.searchResultSettings.welcome&&this.invokeWelcomeAssets(),this.searchResultSettings.customJS){const e=document.createElement("script");e.setAttribute("type","text/javascript"),e.setAttribute("src",this.searchResultSettings.customJS),null===(i=this.el.shadowRoot)||void 0===i||i.appendChild(e)}this.searchResultSettings.textareaAtBottom=!!this.searchResultSettings.hasOwnProperty("inputFieldPosition")&&"bottom"===this.searchResultSettings.inputFieldPosition}}catch(e){console.error("Error loading configuration:",e)}}async invokeWelcomeAssets(){await this.loadWelcomeAssets()}insertCustomCSS(e){const t=document.createElement("link");t.setAttribute("rel","stylesheet"),t.setAttribute("href",e);const s=this.el.shadowRoot;s&&s.appendChild(t)}async componentWillLoad(){h(`https://cdn.ai12z.net/assets/bot/${a.CDN_PATH}/tailwind.min.css`,this.el);const e=new URLSearchParams(window.location.search);this.query=e.get("searchText"),await this.configSearchSettings(),this.searchResultSettings.disableBeacon||z(this.dataKey,this.dataMode),document.addEventListener("click",this.handleClickOutside)}async componentDidLoad(){if(d(this.el),o.register("ai12z-search-results-page",this),o.setActive("ai12z-search-results-page"),this.query&&this.query.length>0){const e=this.el.shadowRoot.querySelector("#search-input");if(e){const t=new InputEvent("input",{bubbles:!0});Object.defineProperty(t,"target",{writable:!1,value:e}),e.value=this.query,this.searchResultSettings.loadResults&&this.query.length>3?(await this.fetchSearchResults(),this.handleFormSubmit(new SubmitEvent("submit"))):this.handleFormSubmit(new SubmitEvent("submit")),e.dispatchEvent(t)}}}disconnectedCallback(){document.removeEventListener("click",this.handleClickOutside)}surveyHandler(e){if("button"===e.detail.type)this.query=e.detail.results,this.handleFormSubmit(new SubmitEvent("submit"));else if("carousel"===e.detail.type)this.chatHistory=[...this.chatHistory,e.detail.results];else if("update"===e.detail.type){const t=this.chatHistory.findIndex((t=>t.id===e.detail.results.id));this.chatHistory=[...this.chatHistory.slice(0,t),e.detail.results,...this.chatHistory.slice(t+1)]}else if("sendMessage"===e.detail.type)e.detail.results.length>1?(this.displayText=e.detail.results[1],this.query=e.detail.results[0],this.handleFormSubmit(new SubmitEvent("submit"))):(this.query=e.detail.results[0],this.handleFormSubmit(new SubmitEvent("submit")));else if("sendJSON"===e.detail.type)this.displayText=e.detail.results[1],this.query=e.detail.results[0],this.handleFormSubmit(new SubmitEvent("submit"));else{const t=e.detail,s=`This JSON is from a form submission [${t.keyName}]: ${JSON.stringify(t.results,null,2)}. There is no need to show the form [${t.keyName}] again.`;this.query=s,this.displayText=t.completeText,this.handleFormSubmit(new SubmitEvent("submit"),{isHide:!0})}}async handleInput(e){if(this.query=e.target.value,this.query.trim().length>3)this.searchResultSettings.autoSearch&&this.fetchSearchResults();else if(!this.isChat)return this.showWelcomeTemplate=!0,void(this.searchResults=[])}async loadWelcomeAssets(){var e,t;const s=[];if(null===(e=this.searchResultSettings.welcome)||void 0===e?void 0:e.styles){const e=new Promise((e=>{v(this.el.shadowRoot,this.searchResultSettings.welcome.styles),setTimeout(e,100)}));s.push(e)}if(null===(t=this.searchResultSettings.welcome)||void 0===t?void 0:t.scripts){const e=new Promise((e=>{y(this.el.shadowRoot,this.searchResultSettings.welcome.scripts),setTimeout(e,200)}));s.push(e)}await Promise.all(s),this.query&&0!==this.query.length||(this.showWelcomeTemplate=!0)}startTimer(){var e;this.timer=x((()=>{this.questionCounter=0,k("ai12z-search-result-data",{qCounter:this.questionCounter})}),null===(e=this.searchResultSettings)||void 0===e?void 0:e.autoResetTimer)}announce(e){this.announceMessage=e,setTimeout((()=>{this.announceMessage=""}),1e3)}async handleFormSubmit(e,t){var s,i,a,o;if(e.stopPropagation(),e.preventDefault(),(!this.query||0===this.query.trim().length)&&this.imagesBase64List&&this.imagesBase64List.length<1)return this.emptyMessageError=!0,this.searchInputElem&&this.searchInputElem.focus(),void setTimeout((()=>{this.emptyMessageError=!1}),3e3);this.emptyMessageError=!1,this.announce("Message sent successfully"),(null===(s=this.searchResultSettings)||void 0===s?void 0:s.keepWelcomeVisible)||(this.showWelcomeTemplate=!1),this.isChat=!0,this.isChat&&(this.questionCounter++,k("ai12z-search-result-data",{qCounter:this.questionCounter})),0===this.chatHistory.length&&(null===(i=this.searchResultSettings)||void 0===i?void 0:i.autoResetTimer)>0&&this.isChat&&this.startTimer(),0!==this.chatHistory.length||this.socketService||(this.socketService=g.createInstance(this.dataMode,this.dataKey),await this.socketService.waitForConnection());try{let e={answer:"",formModel:null,insight_id:null};this.chatHistory.push({message:this.displayText?this.displayText:this.query,images:this.imagesBase64List,status:"success",type:"user",isHide:(null==t?void 0:t.isHide)||!1}),this.imgFiles=this.imagesBase64List.length>0?this.imagesBase64List:[],e.answer=(null===(a=this.searchResultSettings)||void 0===a?void 0:a.maxQuestion)>0&&this.questionCounter>(null===(o=this.searchResultSettings)||void 0===o?void 0:o.maxQuestion)?this.searchResultSettings.msgLimit:null==e?void 0:e.answer,this.aiMessageId="",this.thumbsId=f(),this.chatHistory.push({message:'<div class="animate-ping">...</div>',type:"ai",status:"pending",id:this.aiMessageId}),this.chatHistory.pop(),this.chatHistory=[...this.chatHistory,{message:null==e?void 0:e.answer,type:"ai",status:"success",insightId:null==e?void 0:e.insight_id,id:this.aiMessageId,thumbsId:this.thumbsId,formModel:null==e?void 0:e.formModel,isLoading:!0}],requestAnimationFrame((()=>{requestAnimationFrame((()=>{var e;w(this.questionCounter,null===(e=this.searchResultSettings)||void 0===e?void 0:e.maxQuestion)?(this.chatHistory[this.chatHistory.length-1].id=`chatbot-${f()}`,this.startStream.emit({search:this.query,maxQuestion:!0,chatData:this.chatHistory[this.chatHistory.length-1]})):this.startStream.emit({search:this.query,imgFiles:this.imgFiles})}))})),setTimeout((()=>{this.query="",this.displayText="",this.searchInputElem.value="",this.imagesBase64List=[];const e=this.el.shadowRoot.querySelector("#previewContainer");e&&(e.innerHTML=""),this.adjustHeight()}),1e3)}catch(e){console.error("Error:",e)}}onInputChange(e){if(!(e.length>0))return console.error(0===e.length||"NO IMAGE UPLOADED"),!1;this.uploadImage(e)}uploadImage(e){let t,s=[];if(!(e.length>10||this.imagesBase64List.length>10))for(var i=0;i<e.length;i++){const a=e[i].type;if(!a.match("image.*"))return;t=e[i];const o=new FileReader;o.onload=()=>{const e=this.el.shadowRoot.querySelector("#previewContainer"),t=`data:${a};base64,${o.result.split(",")[1]}`;this.imagesBase64List.push(t),s=this.imagesBase64List;const i=document.createElement("div");i.classList.add("image-Container"),i.classList.add("sc-ai12z-input-form");const c=document.createElement("img");c.setAttribute("src",o.result),c.style.width="70px",c.style.height="50px",c.style.borderRadius="12px";const r=document.createElement("span");r.textContent="x",r.classList.add("delete-image"),r.classList.add("sc-ai12z-input-form"),e.appendChild(i),i.appendChild(c),i.appendChild(r),r.onclick=e=>{let t=s.indexOf(e.target.previousSibling?e.target.previousSibling.src:null);t>-1&&s.splice(t,1),i.remove()}},o.readAsDataURL(t),o.onloadend=()=>{},o.onerror=e=>{console.error("something went wrong...",e)}}}async captureScreen(){try{const e=await navigator.mediaDevices.getDisplayMedia({video:!0}),t=document.createElement("video");t.srcObject=e,t.autoplay=!0,document.body.appendChild(t),await new Promise((e=>t.onloadedmetadata=e)),await new Promise((e=>setTimeout(e,500)));const s=document.createElement("canvas");s.width=t.videoWidth,s.height=t.videoHeight;const i=s.getContext("2d");i&&(i.drawImage(t,0,0,s.width,s.height),s.toBlob((e=>{if(e){const t=new File([e],`screenshot-${Date.now()}.png`,{type:"image/png"});this.capturedFile=t,this.uploadImage([t])}}),"image/png")),e.getTracks().forEach((e=>e.stop())),document.body.removeChild(t)}catch(e){console.error("Error capturing screen:",e)}}handleFollowUp(e){this.chatHistory=[],this.isChat=!1,this.showWelcomeTemplate=!0}render(){var e,t,s,i,a,o,r,n;return c("div",{key:"a6283dff13ee01d01252c09ae291177bf8cc1901",class:"flex w-full"},this.isRendered&&c("div",{key:"23046b03f263a7d47da205ad292c77fa97f4b16b",class:{"search-layout":!0,"search-layout-no-aside":!this.searchResultSettings.autoSearch}},c("div",{key:"191c8e52a398dc6814bfbc9ce9df34d06d9f836e",class:"left-column"},c("div",{key:"579ad4b91532c15ddb072fca2600643092e30112",class:{"flex flex-col relative h-full":!0,"chat-panel":!0,"textarea-at-bottom":this.searchResultSettings.textareaAtBottom,"textarea-at-top":!this.searchResultSettings.textareaAtBottom},id:"searchPanel"},c("div",{key:"107ca0052b12590a4797e7a31b8596e6e8cf54a4",class:"chat-content-wrapper"},this.isChat&&c("ai12z-chat",{key:"b8e109afd4f6a3758be07bca9284441de1ab9972",chats:this.chatHistory,env:this.dataMode,query:this.query,apiKey:this.dataKey,aiMessageId:this.aiMessageId,imgFiles:this.imgFiles,target:null!==(e=this.searchResultSettings.linkTarget)&&void 0!==e?e:"_blank",voiceType:null!==(t=this.searchResultSettings.voiceType)&&void 0!==t?t:"default",voice:null!==(s=this.searchResultSettings.voice)&&void 0!==s?s:"Google US English",onFeedback:async e=>{const{feedback:t,insightId:s}=e.detail;b(this.dataKey,this.dataMode,s,t)},componentType:"search",dataAttributes:this.dataAttributes,socketIn:this.socketService,customJS:this.searchResultSettings.customJS,customstyle:this.searchResultSettings.customCSS,avatarUrl:this.searchResultSettings.botAvatar,settings:this.searchResultSettings,chatExcludeTags:this.excludeTags,chatIncludeTags:this.includeTags})),c("div",{key:"6d622117737f7af6b2bfb0fa99e87d6a67b96ebd",class:{"chat-fixed-section":!0,"has-conversation":(null===(i=this.chatHistory)||void 0===i?void 0:i.length)>0}},c("fieldset",{key:"fca18d5cda45d3e793db5dc6f8029471167b15b0",class:"chat-fieldset",style:{paddingBottom:this.searchResultSettings.textareaAtBottom||this.chatHistory.length>0?"12px":"0px"}},c("form",{key:"48c8ed8eba7fb0bc2a304453d9c8609a458b5a5f",class:"flex flex-col rounded-2xl p-2.5 search-page-container",id:"searchForm"},c("div",{key:"2cc31a7e3daabbfc6ea0f46cdcf36c3d5c3e4daa",class:"flex"},c("div",{key:"ced7f3c9645d82d4194c8cacf7d7c36d50ac223b",class:"flex items-center justify-between"},!this.hideAllButtons&&(this.searchResultSettings.enableAttachment||this.searchResultSettings.clearMemory)&&c("div",{key:"f0f47a1bcfe06e9490916d93d617e371ff5bcc41",class:"relative inline-block",style:{width:"5%"}},c("button",{key:"008e057db17fa006e201e22be1fca15ed301a038",class:"plus-icon chat-btn-primary","aria-label":"Add Options",title:"Add images or capture screen",tabindex:"0",onClick:e=>{e.stopPropagation(),e.preventDefault(),this.toggleBox(e)}},c("svg",{key:"b3ada1ba98f667e3eeb5f5bfab7b8b07a76c2a77",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",width:"20",height:"20"},c("path",{key:"987acb52a36aa78e2263cae340659561094eb163",d:"M10.75 4.75a.75.75 0 0 0-1.5 0v4.5h-4.5a.75.75 0 0 0 0 1.5h4.5v4.5a.75.75 0 0 0 1.5 0v-4.5h4.5a.75.75 0 0 0 0-1.5h-4.5v-4.5Z"}))),c("div",{key:"4101b554a883fddfb636c0b5aed4248be9e268ef",class:`absolute left-0 ${this.searchResultSettings.textareaAtBottom?"bottom-full mb-1":"top-full mt-1"} w-48 bg-white rounded-lg shadow-lg transition-all duration-300 ease-in-out \n ${this.isOpen?"opacity-100 scale-100 pointer-events-auto":"opacity-0 scale-90 pointer-events-none"}`,style:{zIndex:"1001"},ref:e=>this.menuElem=e},c("ul",{key:"1b5f6236602b3f6416f2e505551113d101a03dc1",class:"space-y-2"},this.searchResultSettings.enableAttachment&&c("li",{key:"30845cfd833860f808884bf96dfaa806148c9a7c",class:"px-4 py-2 hover:bg-gray-100 cursor-pointer flex",onClick:()=>{this.uploadImageEle.click(),this.isOpen=!1}},c("input",{key:"c4aa4b26be720fbdff5831172f81112ba35c169b",type:"file",multiple:!0,name:"files[]",id:"fileInput",accept:"image/*",class:"hidden image-upload__input",onChange:e=>{this.onInputChange(e.target.files)},ref:e=>this.uploadImageEle=e}),c("div",{key:"8eaabf1b1eafe646236060ff9134df1428b50abd",class:"mr-1"},c("svg",{key:"b0b21c34ae158a0561d1a8d8bdf0b409453a016e",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",class:"h-5 w-5 shrink-0"},c("path",{key:"62ad2e7d3492fd06b5ffc2cfc451adc36bd1b24f","fill-rule":"evenodd","clip-rule":"evenodd",d:"M18.0322 5.02393C17.7488 5.00078 17.3766 5 16.8 5H11.5002C11.3 6 11.0989 6.91141 10.8903 7.85409C10.7588 8.44955 10.6432 8.97304 10.3675 9.41399C10.1262 9.80009 9.80009 10.1262 9.41399 10.3675C8.97304 10.6432 8.44955 10.7588 7.85409 10.8903C7.81276 10.8994 7.77108 10.9086 7.72906 10.9179L5.21693 11.4762C5.1442 11.4924 5.07155 11.5001 5 11.5002V16.8C5 17.3766 5.00078 17.7488 5.02393 18.0322C5.04612 18.3038 5.0838 18.4045 5.109 18.454C5.20487 18.6422 5.35785 18.7951 5.54601 18.891C5.59546 18.9162 5.69617 18.9539 5.96784 18.9761C6.25118 18.9992 6.62345 19 7.2 19H10C10.5523 19 11 19.4477 11 20C11 20.5523 10.5523 21 10 21H7.16144C6.6343 21 6.17954 21 5.80497 20.9694C5.40963 20.9371 5.01641 20.8658 4.63803 20.673C4.07354 20.3854 3.6146 19.9265 3.32698 19.362C3.13419 18.9836 3.06287 18.5904 3.03057 18.195C2.99997 17.8205 2.99998 17.3657 3 16.8385L3 11C3 8.92477 4.02755 6.93324 5.4804 5.4804C6.93324 4.02755 8.92477 3 11 3L16.8385 3C17.3657 2.99998 17.8205 2.99997 18.195 3.03057C18.5904 3.06287 18.9836 3.13419 19.362 3.32698C19.9265 3.6146 20.3854 4.07354 20.673 4.63803C20.8658 5.01641 20.9371 5.40963 20.9694 5.80497C21 6.17954 21 6.6343 21 7.16144V10C21 10.5523 20.5523 11 20 11C19.4477 11 19 10.5523 19 10V7.2C19 6.62345 18.9992 6.25118 18.9761 5.96784C18.9539 5.69617 18.9162 5.59546 18.891 5.54601C18.7951 5.35785 18.6422 5.20487 18.454 5.109C18.4045 5.0838 18.3038 5.04612 18.0322 5.02393ZM5.28014 9.41336L7.2952 8.96556C8.08861 8.78925 8.24308 8.74089 8.35381 8.67166C8.48251 8.59121 8.59121 8.48251 8.67166 8.35381C8.74089 8.24308 8.78925 8.08861 8.96556 7.2952L9.41336 5.28014C8.51014 5.59289 7.63524 6.15398 6.89461 6.89461C6.15398 7.63524 5.59289 8.51014 5.28014 9.41336ZM17 15C17 14.4477 17.4477 14 18 14C18.5523 14 19 14.4477 19 15V17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H19V21C19 21.5523 18.5523 22 18 22C17.4477 22 17 21.5523 17 21V19H15C14.4477 19 14 18.5523 14 18C14 17.4477 14.4477 17 15 17H17V15Z",fill:"currentColor"}))),c("div",{key:"c89a3a52d9d9b6fc4ef4403998568848fc0a4e17"},"Upload Images")),this.searchResultSettings.clearMemory&&c("li",{key:"07368e687d48fcbd9f6cba7919a53bee518d38d2",class:"px-4 py-2 hover:bg-gray-100 cursor-pointer flex",onClick:e=>{this.handleFollowUp(e),this.toggleBox(e)}},c("div",{key:"f627aa827d02b125d69ef61f428aa985620a372d",class:"mr-1"},c("svg",{key:"8649b07dbb836e04fafe81a6a7fa26e1b48588ac",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",width:"20",height:"20"},c("path",{key:"0da0575e53e7afc703a6f4323652b77a17e35662","fill-rule":"evenodd",d:"M4.755 10.059a7.5 7.5 0 0 1 12.548-3.364l1.903 1.903h-3.183a.75.75 0 1 0 0 1.5h4.992a.75.75 0 0 0 .75-.75V4.356a.75.75 0 0 0-1.5 0v3.18l-1.9-1.9A9 9 0 0 0 3.306 9.67a.75.75 0 1 0 1.45.388Zm15.408 3.352a.75.75 0 0 0-.919.53 7.5 7.5 0 0 1-12.548 3.364l-1.902-1.903h3.183a.75.75 0 0 0 0-1.5H2.984a.75.75 0 0 0-.75.75v4.992a.75.75 0 0 0 1.5 0v-3.18l1.9 1.9a9 9 0 0 0 15.059-4.035.75.75 0 0 0-.53-.918Z","clip-rule":"evenodd"}))),c("div",{key:"0eddc4bdadb5176f0f55861ee2f7c509080487be"},"Start Over")))))),c("div",{key:"c854e0fde73511f1bd2dc01b0e2669317e749e98",class:"w-full mt-1 search-input-container "+(this.hideAllButtons?"hidden":"")},c("div",{key:"9eb6ff6826ff7d77444832928bc278c300abec41",id:"previewContainer",class:"preview-container"}),c("label",{key:"382aa4ce0ab7079224506299dbea9b6c559de7ef",htmlFor:"search-input",class:"sr-only"},"Your message"),c("textarea",{key:"79e7de45d6f3b3f3a6d95ef6799f4fc0c21bfbb3",id:"search-input","aria-describedby":this.emptyMessageError?"search-message-error search-hint":"search-hint","aria-invalid":this.emptyMessageError,class:`bg-inherit w-full outline-none resize-none ${(null===(a=this.searchResults)||void 0===a?void 0:a.length)>0?"input-border":""} search-input`,ref:e=>{this.searchInputElem=e,null==e||e.focus()},placeholder:this.searchResultSettings.placeholder,value:this.query,rows:1,onInput:e=>this.handleInput(e),onKeyDown:this.handleKeyDown,onKeyUp:this.adjustHeight,onFocus:()=>{this.el.shadowRoot.querySelector("#searchPanel").classList.add("input-focus-color")},onBlur:()=>this.el.shadowRoot.querySelector("#searchPanel").classList.remove("input-focus-color")}),c("div",{key:"c516fbb97d13d5ed7f6d4969c3b6d678d38c6855",role:"status","aria-live":"polite","aria-atomic":"true",class:"sr-only"},this.announceMessage),c("span",{key:"b13bab95c5c33c431aed8b6a4dfbeb04d48203ef",class:"sr-only"},"Press Enter to send, Shift+Enter for new line")),c("div",{key:"cd4a91f875dbbc5ab18b631bee02bb954eb8e711",class:"icons flex items-center space-x-2 "+(this.hideAllButtons?"w-full":"w-auto")},this.searchResultSettings.enableMic&&c("audio-recorder",{key:"82623c24f8d8b9b9fbbce220b926af1f385c9ea0","component-type":"search",onStartRecord:()=>{this.hideAllButtons=!0},onStopRecord:()=>{this.hideAllButtons=!1},onSendTranscript:e=>{this.updateInputFromTranscript(e.detail)},style:{width:"100%"}}),!this.hideAllButtons&&c("span",{key:"74bb04b7ec4885a50f982a191076422829052e04",class:"search-icon"},c("button",{key:"eb088dec0b6d2ccfe95a99b7f4d8c5ff7d910cc1",id:"send-message-button",class:"text-white transition rounded-lg p-1.5 self-center submit-button chat-btn-primary",onClick:e=>this.handleFormSubmit(e),"aria-label":"Send Message",tabindex:"0",title:"Send Message"},c("svg",{key:"785e98c6ef214461b1bbe5664e5eed65132b5134",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",fill:"currentColor",class:"size-6"},c("path",{key:"b239070399caba52c418f049ea53d39c9848b76f","fill-rule":"evenodd",d:"M8 14a.75.75 0 0 1-.75-.75V4.56L4.03 7.78a.75.75 0 0 1-1.06-1.06l4.5-4.5a.75.75 0 0 1 1.06 0l4.5 4.5a.75.75 0 0 1-1.06 1.06L8.75 4.56v8.69A.75.75 0 0 1 8 14Z","clip-rule":"evenodd"}))))))),0===this.chatHistory.length&&c("div",{key:"f793b7a8b4d4cbc3cd6f0d6efa333b11c468a373",class:"enter-tip "+(this.searchResultSettings.textareaAtBottom?"order-2 mt-1":"order-1 mb-1"),role:"tooltip"},"Tip: Press Enter to send, Shift+Enter for new line")),this.emptyMessageError&&c("div",{key:"50a56faef934ea25a0be0980e3bbc1f7a822ab17",class:"error-message-container "+(this.searchResultSettings.textareaAtBottom?"order-2 mt-1":"order-1 mb-1")},c("span",{key:"3e77ff3d7bd8e3c3517871b684f8402671a5feb6",id:"search-message-error",class:"error-msg",role:"alert"},"Message cannot be empty. Please enter a message to send.")),this.showWelcomeTemplate&&c("div",{key:"c395c98161f48acdcea51e53c884e6c0cf4d9255",class:"welcome-template-container"},c("div",{key:"b10a9a9ded7d6cf1b3b973522bf91354bba064b2",class:"welcome-template-content",innerHTML:null===(o=this.searchResultSettings.welcome)||void 0===o?void 0:o.message}))))),this.searchResultSettings.autoSearch&&c("aside",{key:"cf68d4d08554846e944e295e36fdaee91085350b",class:"quick-links-column","aria-hidden":"true"},this.searchResults&&this.searchResults.length>0&&c("div",{key:"ad8b6eebf78b652d989c14d8b8ec4c7872bd8d7a",class:{"search-results":this.searchResults&&this.searchResults.length>0}},c("h3",{key:"762404e54ece30fb70f5bb0a72fba773329ce96b",class:"title"},"Sources"),this.searchResultSettings.categorize&&c("ai12z-category",{key:"557147f79bab3ca5f6f617ca2fabc0abd5d16fb0",categoryList:this.searchResults,linkTarget:null!==(r=this.searchResultSettings.linkTarget)&&void 0!==r?r:"_blank"}),!this.searchResultSettings.categorize&&c(u,{key:"6486a83ed5e2c5295fa82fdc591c799d6dc64a32",results:this.searchResults,linkTarget:null!==(n=this.searchResultSettings.linkTarget)&&void 0!==n?n:"_blank"})),!this.searchResults||0===this.searchResults.length&&this.searchResultSettings.autoSearch&&c("div",{key:"901d9fad3d7f59d13e551e01fadcf25bb871e4d9",class:"sources-panel"},c("h3",{key:"6f900ef45c5877d95abce286f6b39441a7c599d9",class:"title"},"Sources"),c("div",{key:"dd6ed90c0adb9725d3a82ede757eabbd4a45b6bb",class:"skeleton-list"},c("div",{key:"8f5d0975d512e87285801ada311c09f3e7e084f4",class:"skeleton-line"}),c("div",{key:"8d44d116c2c313056e1c8b3fd0dc745a3fb1725e",class:"skeleton-line"}),c("div",{key:"af0fa6c1eb7dd4305bdca315e4926d647b414992",class:"skeleton-line short"}),c("div",{key:"68a80031cea402b90640f289fef2a41a3467ace1",class:"divider"}),c("div",{key:"cf06eb6e74aa4618ccf88f428ac2ce2dc453f45a",class:"skeleton-line"}),c("div",{key:"d15e54b7ca4a74f5f7c04696a6009d5117a0315c",class:"skeleton-line short"}),c("div",{key:"eab4e7c664dab7efd4592be75bf0c763bd810e08",class:"divider"}),c("div",{key:"6674679a2215612c52ed3a112f3d956cb9acc8f7",class:"skeleton-line"}),c("div",{key:"e260fa9ee01276dee7df32482f3fb0350ac3b0e7",class:"skeleton-line"}),c("div",{key:"d6cad7e8859d5b3df778f6e2951d6316a623f9a9",class:"skeleton-line short"}))))))}get el(){return this}static get style(){return":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))}.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)}#searchPanel{flex:1;min-height:0;display:flex;flex-direction:column}.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}.search-layout-no-aside{grid-template-columns:minmax(0, 1fr)}.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}.has-conversation .welcome-template-container{display:none}}.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}}.chat-panel{flex:1;min-height:0;display:flex;flex-direction:column}.chat-content-wrapper{min-height:0;overflow-y:auto;flex:1}.chat-fixed-section{flex-shrink:0;display:flex;flex-direction:column;position:sticky;top:0;z-index:1000}.textarea-at-top .chat-fixed-section{top:0;bottom:auto;order:1}.textarea-at-top .chat-content-wrapper{order:2}.textarea-at-top .chat-fieldset{order:1}.textarea-at-top .welcome-template-container{order:2}.textarea-at-bottom .chat-content-wrapper{order:1}.textarea-at-bottom .chat-fixed-section{top:auto;bottom:0;order:2}.textarea-at-bottom .welcome-template-container{order:1}.textarea-at-bottom .chat-fieldset{order:2}"}},[1,"search-results-page",{dataKey:[513,"data-key"],dataMode:[513,"data-mode"],dataAttributes:[1,"data-attributes"],excludeTags:[16],includeTags:[16],configId:[1,"config-id"],query:[32],searchResultSettings:[32],searchResults:[32],hideAllButtons:[32],isChat:[32],chatHistory:[32],aiMessageId:[32],socketService:[32],thumbsId:[32],isOpen:[32],capturedFile:[32],imgFiles:[32],displayText:[32],showWelcomeTemplate:[32],timer:[32],questionCounter:[32],emptyMessageError:[32],announceMessage:[32],isRendered:[32],sendMessage:[64],sendJSON:[64]},[[4,"messageReceived","messageReceivedHandler"],[4,"survey","surveyHandler"]]]);function T(){"undefined"!=typeof customElements&&["search-results-page","ai12z-category","ai12z-chat","audio-recorder","item-list"].forEach((t=>{switch(t){case"search-results-page":customElements.get(e(t))||customElements.define(e(t),E);break;case"ai12z-category":customElements.get(e(t))||p();break;case"ai12z-chat":customElements.get(e(t))||m();break;case"audio-recorder":customElements.get(e(t))||S();break;case"item-list":customElements.get(e(t))||r()}}))}T();export{E as S,T as d}
|
|
1
|
+
import{t as e,p as t,H as s,e as i,E as a,f as o,h as c}from"./p-rVmRQ8bG.js";import{d as r,n,h as l,o as h,E as d,a as f,q as b}from"./p-djQQf6su.js";import{d as p,S as u}from"./p-CaMH5wYq.js";import{d as m,S as g}from"./p-BeUTZLNf.js";import{n as v,m as y,k as x,a as k,i as w}from"./p-CW_iO9zy.js";import{e as C}from"./p-CNxI_jB-.js";import{i as z}from"./p-D5Grnjb5.js";import{d as S}from"./p-DkBtust7.js";const E=t(class extends s{constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow(),this.messageSent=i(this,"messageSent",7),this.messageReceived=i(this,"messageReceived",7),this.errored=i(this,"errored",7),this.startStream=i(this,"startStream",7),this.cdnPath="https://cdn.ai12z.net/assets/cta",this.dataKey=a.DATA_KEY||"",this.dataMode=a.DATA_MODE||"prod",this.excludeTags=[],this.includeTags=[],this.query="",this.searchResultSettings={},this.searchResults=[],this.hideAllButtons=!1,this.isChat=!1,this.chatHistory=[],this.aiMessageId=null,this.thumbsId=null,this.isOpen=!1,this.capturedFile=null,this.imgFiles=[],this.displayText="",this.questionCounter=0,this.emptyMessageError=!1,this.announceMessage="",this.isRendered=!1,this.imagesBase64List=[],this.handleKeyDown=e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),this.query&&this.query.trim().length>0||this.imagesBase64List.length>0?this.handleFormSubmit(e):(this.emptyMessageError=!0,this.searchInputElem&&this.searchInputElem.focus(),setTimeout((()=>{this.emptyMessageError=!1}),3e3)))},this.adjustHeight=()=>{this.searchInputElem.style.height="auto",this.searchInputElem.style.height=this.searchInputElem.scrollHeight+"px"},this.updateInputFromTranscript=async e=>{this.query=e,await new Promise(requestAnimationFrame),this.adjustHeight(),this.searchResultSettings.autoSearch&&e.trim().length>3&&await this.fetchSearchResults()},this.toggleBox=e=>{e.stopPropagation(),this.isOpen=!this.isOpen},this.handleClickOutside=e=>{this.isOpen&&this.menuElem&&!this.menuElem.contains(e.target)&&(this.isOpen=!1)}}async fetchSearchResults(){const e=await n(this.dataKey,this.dataMode,this.query);this.searchResults=e.docs?[...e.docs]:[]}messageReceivedHandler(e){e.detail&&e.detail.data.context&&e.detail.data.context.length>0&&this.searchResultSettings.autoSearch&&(this.searchResults=e.detail.data.context||[])}async sendMessage(e,t){this.query=null!=t?t:e,this.handleFormSubmit(new SubmitEvent("submit")),this.messageSent.emit(e)}async sendJSON(e,t){this.displayText=t,this.query=e,this.handleFormSubmit(new SubmitEvent("submit")),this.messageSent.emit(e)}async configSearchSettings(){var e,t,s,i;const o={apiKey:this.dataKey,configId:this.configId,configType:"searchResult"};try{const c=await l(o,this.dataMode);if(c){if(this.searchResultSettings=c,null===(e=null==c?void 0:c.v3)||void 0===e?void 0:e.siteKey)try{const e=await C(c._id,c.v3.siteKey,"searchResult",this.dataKey,this.dataMode,(e=>{this.errored.emit(e)}));this.isRendered=!!e}catch(e){console.error("Recaptcha verification failed:",e),this.isRendered=!1}else this.isRendered=!0;if(void 0===(null===(t=this.searchResultSettings)||void 0===t?void 0:t.autoSearch)&&(this.searchResultSettings.autoSearch=!0),this.searchResultSettings.theme){let e="";e="custom"!==this.searchResultSettings.theme?`${this.cdnPath}/${a.CDN_PATH}/themes/theme-${this.searchResultSettings.theme}.css`:this.searchResultSettings.customTheme;const t=document.createElement("link");t.setAttribute("rel","stylesheet"),t.setAttribute("href",e),document.head.appendChild(t)}if(void 0===(null===(s=this.searchResultSettings)||void 0===s?void 0:s.categorize)&&(this.searchResultSettings.categorize=!0),this.searchResultSettings.customCSS&&this.insertCustomCSS(this.searchResultSettings.customCSS),this.searchResultSettings.welcome&&this.invokeWelcomeAssets(),this.searchResultSettings.customJS){const e=document.createElement("script");e.setAttribute("type","text/javascript"),e.setAttribute("src",this.searchResultSettings.customJS),null===(i=this.el.shadowRoot)||void 0===i||i.appendChild(e)}this.searchResultSettings.textareaAtBottom=!!this.searchResultSettings.hasOwnProperty("inputFieldPosition")&&"bottom"===this.searchResultSettings.inputFieldPosition}}catch(e){console.error("Error loading configuration:",e)}}async invokeWelcomeAssets(){await this.loadWelcomeAssets()}insertCustomCSS(e){const t=document.createElement("link");t.setAttribute("rel","stylesheet"),t.setAttribute("href",e);const s=this.el.shadowRoot;s&&s.appendChild(t)}async componentWillLoad(){h(`https://cdn.ai12z.net/assets/bot/${a.CDN_PATH}/tailwind.min.css`,this.el);const e=new URLSearchParams(window.location.search);this.query=e.get("searchText"),await this.configSearchSettings(),this.searchResultSettings.disableBeacon||z(this.dataKey,this.dataMode),document.addEventListener("click",this.handleClickOutside)}async componentDidLoad(){if(d(this.el),o.register("ai12z-search-results-page",this),o.setActive("ai12z-search-results-page"),this.query&&this.query.length>0){const e=this.el.shadowRoot.querySelector("#search-input");if(e){const t=new InputEvent("input",{bubbles:!0});Object.defineProperty(t,"target",{writable:!1,value:e}),e.value=this.query,this.searchResultSettings.loadResults&&this.query.length>3?(await this.fetchSearchResults(),this.handleFormSubmit(new SubmitEvent("submit"))):this.handleFormSubmit(new SubmitEvent("submit")),e.dispatchEvent(t)}}}disconnectedCallback(){document.removeEventListener("click",this.handleClickOutside)}surveyHandler(e){if("button"===e.detail.type)this.query=e.detail.results,this.handleFormSubmit(new SubmitEvent("submit"));else if("carousel"===e.detail.type)this.chatHistory=[...this.chatHistory,e.detail.results];else if("update"===e.detail.type){const t=this.chatHistory.findIndex((t=>t.id===e.detail.results.id));this.chatHistory=[...this.chatHistory.slice(0,t),e.detail.results,...this.chatHistory.slice(t+1)]}else if("sendMessage"===e.detail.type)e.detail.results.length>1?(this.displayText=e.detail.results[1],this.query=e.detail.results[0],this.handleFormSubmit(new SubmitEvent("submit"))):(this.query=e.detail.results[0],this.handleFormSubmit(new SubmitEvent("submit")));else if("sendJSON"===e.detail.type)this.displayText=e.detail.results[1],this.query=e.detail.results[0],this.handleFormSubmit(new SubmitEvent("submit"));else{const t=e.detail,s=`This JSON is from a form submission [${t.keyName}]: ${JSON.stringify(t.results,null,2)}. There is no need to show the form [${t.keyName}] again.`;this.query=s,this.displayText=t.completeText,this.handleFormSubmit(new SubmitEvent("submit"),{isHide:!0})}}async handleInput(e){if(this.query=e.target.value,this.query.trim().length>3)this.searchResultSettings.autoSearch&&this.fetchSearchResults();else if(!this.isChat)return this.showWelcomeTemplate=!0,void(this.searchResults=[])}async loadWelcomeAssets(){var e,t;const s=[];if(null===(e=this.searchResultSettings.welcome)||void 0===e?void 0:e.styles){const e=new Promise((e=>{v(this.el.shadowRoot,this.searchResultSettings.welcome.styles),setTimeout(e,100)}));s.push(e)}if(null===(t=this.searchResultSettings.welcome)||void 0===t?void 0:t.scripts){const e=new Promise((e=>{y(this.el.shadowRoot,this.searchResultSettings.welcome.scripts),setTimeout(e,200)}));s.push(e)}await Promise.all(s),this.query&&0!==this.query.length||(this.showWelcomeTemplate=!0)}startTimer(){var e;this.timer=x((()=>{this.questionCounter=0,k("ai12z-search-result-data",{qCounter:this.questionCounter})}),null===(e=this.searchResultSettings)||void 0===e?void 0:e.autoResetTimer)}announce(e){this.announceMessage=e,setTimeout((()=>{this.announceMessage=""}),1e3)}async handleFormSubmit(e,t){var s,i,a,o;if(e.stopPropagation(),e.preventDefault(),(!this.query||0===this.query.trim().length)&&this.imagesBase64List&&this.imagesBase64List.length<1)return this.emptyMessageError=!0,this.searchInputElem&&this.searchInputElem.focus(),void setTimeout((()=>{this.emptyMessageError=!1}),3e3);this.emptyMessageError=!1,this.announce("Message sent successfully"),(null===(s=this.searchResultSettings)||void 0===s?void 0:s.keepWelcomeVisible)||(this.showWelcomeTemplate=!1),this.isChat=!0,this.isChat&&(this.questionCounter++,k("ai12z-search-result-data",{qCounter:this.questionCounter})),0===this.chatHistory.length&&(null===(i=this.searchResultSettings)||void 0===i?void 0:i.autoResetTimer)>0&&this.isChat&&this.startTimer(),0!==this.chatHistory.length||this.socketService||(this.socketService=g.createInstance(this.dataMode,this.dataKey),await this.socketService.waitForConnection());try{let e={answer:"",formModel:null,insight_id:null};this.chatHistory.push({message:this.displayText?this.displayText:this.query,images:this.imagesBase64List,status:"success",type:"user",isHide:(null==t?void 0:t.isHide)||!1}),this.imgFiles=this.imagesBase64List.length>0?this.imagesBase64List:[],e.answer=(null===(a=this.searchResultSettings)||void 0===a?void 0:a.maxQuestion)>0&&this.questionCounter>(null===(o=this.searchResultSettings)||void 0===o?void 0:o.maxQuestion)?this.searchResultSettings.msgLimit:null==e?void 0:e.answer,this.aiMessageId="",this.thumbsId=f(),this.chatHistory.push({message:'<div class="animate-ping">...</div>',type:"ai",status:"pending",id:this.aiMessageId}),this.chatHistory.pop(),this.chatHistory=[...this.chatHistory,{message:null==e?void 0:e.answer,type:"ai",status:"success",insightId:null==e?void 0:e.insight_id,id:this.aiMessageId,thumbsId:this.thumbsId,formModel:null==e?void 0:e.formModel,isLoading:!0}],requestAnimationFrame((()=>{requestAnimationFrame((()=>{var e;w(this.questionCounter,null===(e=this.searchResultSettings)||void 0===e?void 0:e.maxQuestion)?(this.chatHistory[this.chatHistory.length-1].id=`chatbot-${f()}`,this.startStream.emit({search:this.query,maxQuestion:!0,chatData:this.chatHistory[this.chatHistory.length-1]})):this.startStream.emit({search:this.query,imgFiles:this.imgFiles})}))})),setTimeout((()=>{this.query="",this.displayText="",this.searchInputElem.value="",this.imagesBase64List=[];const e=this.el.shadowRoot.querySelector("#previewContainer");e&&(e.innerHTML=""),this.adjustHeight()}),1e3)}catch(e){console.error("Error:",e)}}onInputChange(e){if(!(e.length>0))return console.error(0===e.length||"NO IMAGE UPLOADED"),!1;this.uploadImage(e)}uploadImage(e){let t,s=[];if(!(e.length>10||this.imagesBase64List.length>10))for(var i=0;i<e.length;i++){const a=e[i].type;if(!a.match("image.*"))return;t=e[i];const o=new FileReader;o.onload=()=>{const e=this.el.shadowRoot.querySelector("#previewContainer"),t=`data:${a};base64,${o.result.split(",")[1]}`;this.imagesBase64List.push(t),s=this.imagesBase64List;const i=document.createElement("div");i.classList.add("image-Container"),i.classList.add("sc-ai12z-input-form");const c=document.createElement("img");c.setAttribute("src",o.result),c.style.width="70px",c.style.height="50px",c.style.borderRadius="12px";const r=document.createElement("span");r.textContent="x",r.classList.add("delete-image"),r.classList.add("sc-ai12z-input-form"),e.appendChild(i),i.appendChild(c),i.appendChild(r),r.onclick=e=>{let t=s.indexOf(e.target.previousSibling?e.target.previousSibling.src:null);t>-1&&s.splice(t,1),i.remove()}},o.readAsDataURL(t),o.onloadend=()=>{},o.onerror=e=>{console.error("something went wrong...",e)}}}async captureScreen(){try{const e=await navigator.mediaDevices.getDisplayMedia({video:!0}),t=document.createElement("video");t.srcObject=e,t.autoplay=!0,document.body.appendChild(t),await new Promise((e=>t.onloadedmetadata=e)),await new Promise((e=>setTimeout(e,500)));const s=document.createElement("canvas");s.width=t.videoWidth,s.height=t.videoHeight;const i=s.getContext("2d");i&&(i.drawImage(t,0,0,s.width,s.height),s.toBlob((e=>{if(e){const t=new File([e],`screenshot-${Date.now()}.png`,{type:"image/png"});this.capturedFile=t,this.uploadImage([t])}}),"image/png")),e.getTracks().forEach((e=>e.stop())),document.body.removeChild(t)}catch(e){console.error("Error capturing screen:",e)}}handleFollowUp(e){this.chatHistory=[],this.isChat=!1,this.showWelcomeTemplate=!0}render(){var e,t,s,i,a,o,r,n;return c("div",{key:"a6283dff13ee01d01252c09ae291177bf8cc1901",class:"flex w-full"},this.isRendered&&c("div",{key:"23046b03f263a7d47da205ad292c77fa97f4b16b",class:{"search-layout":!0,"search-layout-no-aside":!this.searchResultSettings.autoSearch}},c("div",{key:"191c8e52a398dc6814bfbc9ce9df34d06d9f836e",class:"left-column"},c("div",{key:"579ad4b91532c15ddb072fca2600643092e30112",class:{"flex flex-col relative h-full":!0,"chat-panel":!0,"textarea-at-bottom":this.searchResultSettings.textareaAtBottom,"textarea-at-top":!this.searchResultSettings.textareaAtBottom},id:"searchPanel"},c("div",{key:"107ca0052b12590a4797e7a31b8596e6e8cf54a4",class:"chat-content-wrapper"},this.isChat&&c("ai12z-chat",{key:"b8e109afd4f6a3758be07bca9284441de1ab9972",chats:this.chatHistory,env:this.dataMode,query:this.query,apiKey:this.dataKey,aiMessageId:this.aiMessageId,imgFiles:this.imgFiles,target:null!==(e=this.searchResultSettings.linkTarget)&&void 0!==e?e:"_blank",voiceType:null!==(t=this.searchResultSettings.voiceType)&&void 0!==t?t:"default",voice:null!==(s=this.searchResultSettings.voice)&&void 0!==s?s:"Google US English",onFeedback:async e=>{const{feedback:t,insightId:s}=e.detail;b(this.dataKey,this.dataMode,s,t)},componentType:"search",dataAttributes:this.dataAttributes,socketIn:this.socketService,customJS:this.searchResultSettings.customJS,customstyle:this.searchResultSettings.customCSS,avatarUrl:this.searchResultSettings.botAvatar,settings:this.searchResultSettings,chatExcludeTags:this.excludeTags,chatIncludeTags:this.includeTags})),c("div",{key:"6d622117737f7af6b2bfb0fa99e87d6a67b96ebd",class:{"chat-fixed-section":!0,"has-conversation":(null===(i=this.chatHistory)||void 0===i?void 0:i.length)>0}},c("fieldset",{key:"fca18d5cda45d3e793db5dc6f8029471167b15b0",class:"chat-fieldset",style:{paddingBottom:this.searchResultSettings.textareaAtBottom||this.chatHistory.length>0?"12px":"0px"}},c("form",{key:"48c8ed8eba7fb0bc2a304453d9c8609a458b5a5f",class:"flex flex-col rounded-2xl p-2.5 search-page-container",id:"searchForm"},c("div",{key:"2cc31a7e3daabbfc6ea0f46cdcf36c3d5c3e4daa",class:"flex"},c("div",{key:"ced7f3c9645d82d4194c8cacf7d7c36d50ac223b",class:"flex items-center justify-between"},!this.hideAllButtons&&(this.searchResultSettings.enableAttachment||this.searchResultSettings.clearMemory)&&c("div",{key:"f0f47a1bcfe06e9490916d93d617e371ff5bcc41",class:"relative inline-block",style:{width:"5%"}},c("button",{key:"008e057db17fa006e201e22be1fca15ed301a038",class:"plus-icon chat-btn-primary","aria-label":"Add Options",title:"Add images or capture screen",tabindex:"0",onClick:e=>{e.stopPropagation(),e.preventDefault(),this.toggleBox(e)}},c("svg",{key:"b3ada1ba98f667e3eeb5f5bfab7b8b07a76c2a77",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",width:"20",height:"20"},c("path",{key:"987acb52a36aa78e2263cae340659561094eb163",d:"M10.75 4.75a.75.75 0 0 0-1.5 0v4.5h-4.5a.75.75 0 0 0 0 1.5h4.5v4.5a.75.75 0 0 0 1.5 0v-4.5h4.5a.75.75 0 0 0 0-1.5h-4.5v-4.5Z"}))),c("div",{key:"4101b554a883fddfb636c0b5aed4248be9e268ef",class:`absolute left-0 ${this.searchResultSettings.textareaAtBottom?"bottom-full mb-1":"top-full mt-1"} w-48 bg-white rounded-lg shadow-lg transition-all duration-300 ease-in-out \n ${this.isOpen?"opacity-100 scale-100 pointer-events-auto":"opacity-0 scale-90 pointer-events-none"}`,style:{zIndex:"1001"},ref:e=>this.menuElem=e},c("ul",{key:"1b5f6236602b3f6416f2e505551113d101a03dc1",class:"space-y-2"},this.searchResultSettings.enableAttachment&&c("li",{key:"30845cfd833860f808884bf96dfaa806148c9a7c",class:"px-4 py-2 hover:bg-gray-100 cursor-pointer flex",onClick:()=>{this.uploadImageEle.click(),this.isOpen=!1}},c("input",{key:"c4aa4b26be720fbdff5831172f81112ba35c169b",type:"file",multiple:!0,name:"files[]",id:"fileInput",accept:"image/*",class:"hidden image-upload__input",onChange:e=>{this.onInputChange(e.target.files)},ref:e=>this.uploadImageEle=e}),c("div",{key:"8eaabf1b1eafe646236060ff9134df1428b50abd",class:"mr-1"},c("svg",{key:"b0b21c34ae158a0561d1a8d8bdf0b409453a016e",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",class:"h-5 w-5 shrink-0"},c("path",{key:"62ad2e7d3492fd06b5ffc2cfc451adc36bd1b24f","fill-rule":"evenodd","clip-rule":"evenodd",d:"M18.0322 5.02393C17.7488 5.00078 17.3766 5 16.8 5H11.5002C11.3 6 11.0989 6.91141 10.8903 7.85409C10.7588 8.44955 10.6432 8.97304 10.3675 9.41399C10.1262 9.80009 9.80009 10.1262 9.41399 10.3675C8.97304 10.6432 8.44955 10.7588 7.85409 10.8903C7.81276 10.8994 7.77108 10.9086 7.72906 10.9179L5.21693 11.4762C5.1442 11.4924 5.07155 11.5001 5 11.5002V16.8C5 17.3766 5.00078 17.7488 5.02393 18.0322C5.04612 18.3038 5.0838 18.4045 5.109 18.454C5.20487 18.6422 5.35785 18.7951 5.54601 18.891C5.59546 18.9162 5.69617 18.9539 5.96784 18.9761C6.25118 18.9992 6.62345 19 7.2 19H10C10.5523 19 11 19.4477 11 20C11 20.5523 10.5523 21 10 21H7.16144C6.6343 21 6.17954 21 5.80497 20.9694C5.40963 20.9371 5.01641 20.8658 4.63803 20.673C4.07354 20.3854 3.6146 19.9265 3.32698 19.362C3.13419 18.9836 3.06287 18.5904 3.03057 18.195C2.99997 17.8205 2.99998 17.3657 3 16.8385L3 11C3 8.92477 4.02755 6.93324 5.4804 5.4804C6.93324 4.02755 8.92477 3 11 3L16.8385 3C17.3657 2.99998 17.8205 2.99997 18.195 3.03057C18.5904 3.06287 18.9836 3.13419 19.362 3.32698C19.9265 3.6146 20.3854 4.07354 20.673 4.63803C20.8658 5.01641 20.9371 5.40963 20.9694 5.80497C21 6.17954 21 6.6343 21 7.16144V10C21 10.5523 20.5523 11 20 11C19.4477 11 19 10.5523 19 10V7.2C19 6.62345 18.9992 6.25118 18.9761 5.96784C18.9539 5.69617 18.9162 5.59546 18.891 5.54601C18.7951 5.35785 18.6422 5.20487 18.454 5.109C18.4045 5.0838 18.3038 5.04612 18.0322 5.02393ZM5.28014 9.41336L7.2952 8.96556C8.08861 8.78925 8.24308 8.74089 8.35381 8.67166C8.48251 8.59121 8.59121 8.48251 8.67166 8.35381C8.74089 8.24308 8.78925 8.08861 8.96556 7.2952L9.41336 5.28014C8.51014 5.59289 7.63524 6.15398 6.89461 6.89461C6.15398 7.63524 5.59289 8.51014 5.28014 9.41336ZM17 15C17 14.4477 17.4477 14 18 14C18.5523 14 19 14.4477 19 15V17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H19V21C19 21.5523 18.5523 22 18 22C17.4477 22 17 21.5523 17 21V19H15C14.4477 19 14 18.5523 14 18C14 17.4477 14.4477 17 15 17H17V15Z",fill:"currentColor"}))),c("div",{key:"c89a3a52d9d9b6fc4ef4403998568848fc0a4e17"},"Upload Images")),this.searchResultSettings.clearMemory&&c("li",{key:"07368e687d48fcbd9f6cba7919a53bee518d38d2",class:"px-4 py-2 hover:bg-gray-100 cursor-pointer flex",onClick:e=>{this.handleFollowUp(e),this.toggleBox(e)}},c("div",{key:"f627aa827d02b125d69ef61f428aa985620a372d",class:"mr-1"},c("svg",{key:"8649b07dbb836e04fafe81a6a7fa26e1b48588ac",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",width:"20",height:"20"},c("path",{key:"0da0575e53e7afc703a6f4323652b77a17e35662","fill-rule":"evenodd",d:"M4.755 10.059a7.5 7.5 0 0 1 12.548-3.364l1.903 1.903h-3.183a.75.75 0 1 0 0 1.5h4.992a.75.75 0 0 0 .75-.75V4.356a.75.75 0 0 0-1.5 0v3.18l-1.9-1.9A9 9 0 0 0 3.306 9.67a.75.75 0 1 0 1.45.388Zm15.408 3.352a.75.75 0 0 0-.919.53 7.5 7.5 0 0 1-12.548 3.364l-1.902-1.903h3.183a.75.75 0 0 0 0-1.5H2.984a.75.75 0 0 0-.75.75v4.992a.75.75 0 0 0 1.5 0v-3.18l1.9 1.9a9 9 0 0 0 15.059-4.035.75.75 0 0 0-.53-.918Z","clip-rule":"evenodd"}))),c("div",{key:"0eddc4bdadb5176f0f55861ee2f7c509080487be"},"Start Over")))))),c("div",{key:"c854e0fde73511f1bd2dc01b0e2669317e749e98",class:"w-full mt-1 search-input-container "+(this.hideAllButtons?"hidden":"")},c("div",{key:"9eb6ff6826ff7d77444832928bc278c300abec41",id:"previewContainer",class:"preview-container"}),c("label",{key:"382aa4ce0ab7079224506299dbea9b6c559de7ef",htmlFor:"search-input",class:"sr-only"},"Your message"),c("textarea",{key:"79e7de45d6f3b3f3a6d95ef6799f4fc0c21bfbb3",id:"search-input","aria-describedby":this.emptyMessageError?"search-message-error search-hint":"search-hint","aria-invalid":this.emptyMessageError,class:`bg-inherit w-full outline-none resize-none ${(null===(a=this.searchResults)||void 0===a?void 0:a.length)>0?"input-border":""} search-input`,ref:e=>{this.searchInputElem=e,null==e||e.focus()},placeholder:this.searchResultSettings.placeholder,value:this.query,rows:1,onInput:e=>this.handleInput(e),onKeyDown:this.handleKeyDown,onKeyUp:this.adjustHeight,onFocus:()=>{this.el.shadowRoot.querySelector("#searchPanel").classList.add("input-focus-color")},onBlur:()=>this.el.shadowRoot.querySelector("#searchPanel").classList.remove("input-focus-color")}),c("div",{key:"c516fbb97d13d5ed7f6d4969c3b6d678d38c6855",role:"status","aria-live":"polite","aria-atomic":"true",class:"sr-only"},this.announceMessage),c("span",{key:"b13bab95c5c33c431aed8b6a4dfbeb04d48203ef",class:"sr-only"},"Press Enter to send, Shift+Enter for new line")),c("div",{key:"cd4a91f875dbbc5ab18b631bee02bb954eb8e711",class:"icons flex items-center space-x-2 "+(this.hideAllButtons?"w-full":"w-auto")},this.searchResultSettings.enableMic&&c("audio-recorder",{key:"82623c24f8d8b9b9fbbce220b926af1f385c9ea0","component-type":"search",onStartRecord:()=>{this.hideAllButtons=!0},onStopRecord:()=>{this.hideAllButtons=!1},onSendTranscript:e=>{this.updateInputFromTranscript(e.detail)},style:{width:"100%"}}),!this.hideAllButtons&&c("span",{key:"74bb04b7ec4885a50f982a191076422829052e04",class:"search-icon"},c("button",{key:"eb088dec0b6d2ccfe95a99b7f4d8c5ff7d910cc1",id:"send-message-button",class:"text-white transition rounded-lg p-1.5 self-center submit-button chat-btn-primary",onClick:e=>this.handleFormSubmit(e),"aria-label":"Send Message",tabindex:"0",title:"Send Message"},c("svg",{key:"785e98c6ef214461b1bbe5664e5eed65132b5134",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",fill:"currentColor",class:"size-6"},c("path",{key:"b239070399caba52c418f049ea53d39c9848b76f","fill-rule":"evenodd",d:"M8 14a.75.75 0 0 1-.75-.75V4.56L4.03 7.78a.75.75 0 0 1-1.06-1.06l4.5-4.5a.75.75 0 0 1 1.06 0l4.5 4.5a.75.75 0 0 1-1.06 1.06L8.75 4.56v8.69A.75.75 0 0 1 8 14Z","clip-rule":"evenodd"}))))))),0===this.chatHistory.length&&c("div",{key:"f793b7a8b4d4cbc3cd6f0d6efa333b11c468a373",class:"enter-tip "+(this.searchResultSettings.textareaAtBottom?"order-2 mt-1":"order-1 mb-1"),role:"tooltip"},"Tip: Press Enter to send, Shift+Enter for new line")),this.emptyMessageError&&c("div",{key:"50a56faef934ea25a0be0980e3bbc1f7a822ab17",class:"error-message-container "+(this.searchResultSettings.textareaAtBottom?"order-2 mt-1":"order-1 mb-1")},c("span",{key:"3e77ff3d7bd8e3c3517871b684f8402671a5feb6",id:"search-message-error",class:"error-msg",role:"alert"},"Message cannot be empty. Please enter a message to send.")),this.showWelcomeTemplate&&c("div",{key:"c395c98161f48acdcea51e53c884e6c0cf4d9255",class:"welcome-template-container"},c("div",{key:"b10a9a9ded7d6cf1b3b973522bf91354bba064b2",class:"welcome-template-content",innerHTML:null===(o=this.searchResultSettings.welcome)||void 0===o?void 0:o.message}))))),this.searchResultSettings.autoSearch&&c("aside",{key:"cf68d4d08554846e944e295e36fdaee91085350b",class:"quick-links-column","aria-hidden":"true"},this.searchResults&&this.searchResults.length>0&&c("div",{key:"ad8b6eebf78b652d989c14d8b8ec4c7872bd8d7a",class:{"search-results":this.searchResults&&this.searchResults.length>0}},c("h3",{key:"762404e54ece30fb70f5bb0a72fba773329ce96b",class:"title"},"Sources"),this.searchResultSettings.categorize&&c("ai12z-category",{key:"557147f79bab3ca5f6f617ca2fabc0abd5d16fb0",categoryList:this.searchResults,linkTarget:null!==(r=this.searchResultSettings.linkTarget)&&void 0!==r?r:"_blank"}),!this.searchResultSettings.categorize&&c(u,{key:"6486a83ed5e2c5295fa82fdc591c799d6dc64a32",results:this.searchResults,linkTarget:null!==(n=this.searchResultSettings.linkTarget)&&void 0!==n?n:"_blank"})),!this.searchResults||0===this.searchResults.length&&this.searchResultSettings.autoSearch&&c("div",{key:"901d9fad3d7f59d13e551e01fadcf25bb871e4d9",class:"sources-panel"},c("h3",{key:"6f900ef45c5877d95abce286f6b39441a7c599d9",class:"title"},"Sources"),c("div",{key:"dd6ed90c0adb9725d3a82ede757eabbd4a45b6bb",class:"skeleton-list"},c("div",{key:"8f5d0975d512e87285801ada311c09f3e7e084f4",class:"skeleton-line"}),c("div",{key:"8d44d116c2c313056e1c8b3fd0dc745a3fb1725e",class:"skeleton-line"}),c("div",{key:"af0fa6c1eb7dd4305bdca315e4926d647b414992",class:"skeleton-line short"}),c("div",{key:"68a80031cea402b90640f289fef2a41a3467ace1",class:"divider"}),c("div",{key:"cf06eb6e74aa4618ccf88f428ac2ce2dc453f45a",class:"skeleton-line"}),c("div",{key:"d15e54b7ca4a74f5f7c04696a6009d5117a0315c",class:"skeleton-line short"}),c("div",{key:"eab4e7c664dab7efd4592be75bf0c763bd810e08",class:"divider"}),c("div",{key:"6674679a2215612c52ed3a112f3d956cb9acc8f7",class:"skeleton-line"}),c("div",{key:"e260fa9ee01276dee7df32482f3fb0350ac3b0e7",class:"skeleton-line"}),c("div",{key:"d6cad7e8859d5b3df778f6e2951d6316a623f9a9",class:"skeleton-line short"}))))))}get el(){return this}static get style(){return":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))}.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)}#searchPanel{flex:1;min-height:0;display:flex;flex-direction:column}.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}.search-layout-no-aside{grid-template-columns:minmax(0, 1fr)}.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}.has-conversation .welcome-template-container{display:none}}.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}}.chat-panel{flex:1;min-height:0;display:flex;flex-direction:column}.chat-content-wrapper{min-height:0;overflow-y:auto;flex:1}.chat-fixed-section{flex-shrink:0;display:flex;flex-direction:column;position:sticky;top:0;z-index:1000}.textarea-at-top .chat-fixed-section{top:0;bottom:auto;order:1}.textarea-at-top .chat-content-wrapper{order:2}.textarea-at-top .chat-fieldset{order:1}.textarea-at-top .welcome-template-container{order:2}.textarea-at-bottom .chat-content-wrapper{order:1}.textarea-at-bottom .chat-fixed-section{top:auto;bottom:0;order:2}.textarea-at-bottom .welcome-template-container{order:1}.textarea-at-bottom .chat-fieldset{order:2}"}},[1,"search-results-page",{dataKey:[513,"data-key"],dataMode:[513,"data-mode"],dataAttributes:[1,"data-attributes"],excludeTags:[16],includeTags:[16],configId:[1,"config-id"],query:[32],searchResultSettings:[32],searchResults:[32],hideAllButtons:[32],isChat:[32],chatHistory:[32],aiMessageId:[32],socketService:[32],thumbsId:[32],isOpen:[32],capturedFile:[32],imgFiles:[32],displayText:[32],showWelcomeTemplate:[32],timer:[32],questionCounter:[32],emptyMessageError:[32],announceMessage:[32],isRendered:[32],sendMessage:[64],sendJSON:[64]},[[4,"messageReceived","messageReceivedHandler"],[4,"survey","surveyHandler"]]]);function T(){"undefined"!=typeof customElements&&["search-results-page","ai12z-category","ai12z-chat","audio-recorder","item-list"].forEach((t=>{switch(t){case"search-results-page":customElements.get(e(t))||customElements.define(e(t),E);break;case"ai12z-category":customElements.get(e(t))||p();break;case"ai12z-chat":customElements.get(e(t))||m();break;case"audio-recorder":customElements.get(e(t))||S();break;case"item-list":customElements.get(e(t))||r()}}))}T();export{E as S,T as d}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{E as t,t as i,p as s,H as e,e as o,h as n}from"./p-rVmRQ8bG.js";import{s as a,p as r}from"./p-BJOnT4k4.js";import{e as l,s as h,p as c}from"./p-CW_iO9zy.js";import{i as d,g as u,d as p,H as v,u as m,e as b,j as g,a as w,C as f}from"./p-djQQf6su.js";import{l as x,b as y,a as k}from"./p-B_OuPB-D.js";import{r as C}from"./p-M51H23z5.js";import{w as S,h as z}from"./p-D338smYm.js";import{t as H,g as M}from"./p-ChFVg77w.js";import{l as I,b as $}from"./p-DmqUTHP1.js";import{s as T}from"./p-DVE50Spy.js";class j{constructor(i,s=""){this.socketId="",this.socket=null,this.mode=t.DATA_MODE,this.connectionPromise=null,this.apiKey="",this.protocol="legacy",this.authenticated=!1,this.mode=i,this.apiKey=s,this.protocol=d(i),this.initSocket()}initSocket(){if(this.socket&&(this.clearSocketListeners(),this.socket.disconnect(),this.socket=null),!this.socket){let t=u(this.mode);this.connectionPromise=new Promise(((i,s)=>{let e=!1;const o=setTimeout((()=>{e||(e=!0,console.error("Socket connection timed out"),window.dispatchEvent(new CustomEvent("socketError",{detail:{message:"Unable to connect to server. Please try again later.",code:"CONNECTION_TIMEOUT"}})),s(new Error("Unable to connect to server. Please try again later.")))}),3e4);this.socket=x(t,{transports:"v2"===this.protocol?["websocket","polling"]:["polling"]}),this.socket.on("connect",(()=>{var t;this.socketId=null===(t=this.socket)||void 0===t?void 0:t.id,this.socketId&&j.instances.set(this.socketId,this),"v2"===this.protocol&&this.apiKey?this.socket.emit("authenticate",{api_key:this.apiKey}):e||(e=!0,clearTimeout(o),i())})),"v2"===this.protocol?(this.socket.on("authenticated",(()=>{this.authenticated=!0,e||(e=!0,clearTimeout(o),i())})),this.socket.on("chunk",(t=>{const i=y(t);window.dispatchEvent(new CustomEvent("streamResponse",{detail:i}))})),this.socket.on("complete",(t=>{const i=k(t);window.dispatchEvent(new CustomEvent("endResponse",{detail:i}))}))):(this.socket.on("response",(t=>{window.dispatchEvent(new CustomEvent("streamResponse",{detail:t}))})),this.socket.on("end_response",(t=>{window.dispatchEvent(new CustomEvent("endResponse",{detail:t}))}))),this.socket.on("close",(()=>{this.clearSocketListeners(),this.authenticated=!1,this.socket=null,setTimeout((()=>this.initSocket()),3e3)})),this.socket.on("error",(t=>{console.error("WebSocket error:",t),"v2"===this.protocol&&window.dispatchEvent(new CustomEvent("socketError",{detail:t}))})),this.socket.on("disconnect",(()=>{this.socketId&&j.instances.delete(this.socketId),this.authenticated=!1}))})),this.connectionPromise=this.connectionPromise.catch((t=>{console.error("Socket connection failed:",t.message)}))}}clearSocketListeners(){this.socket&&(this.socket.off("connect"),this.socket.off("response"),this.socket.off("end_response"),this.socket.off("chunk"),this.socket.off("complete"),this.socket.off("authenticated"),this.socket.off("close"),this.socket.off("error"),this.socket.off("disconnect"))}static createInstance(t,i=""){return new j(t,i)}static getInstanceById(t){return j.instances.get(t)}getSocket(){return this.socket}getSocketId(){return this.socketId}getProtocol(){return this.protocol}isAuthenticated(){return"legacy"===this.protocol||this.authenticated}async waitForConnection(){this.connectionPromise&&await this.connectionPromise}isConnected(){var t,i;return null!==(i=null===(t=this.socket)||void 0===t?void 0:t.connected)&&void 0!==i&&i}disconnect(){this.socket&&(this.clearSocketListeners(),this.socket.disconnect(),this.socket=null),this.socketId&&(j.instances.delete(this.socketId),this.socketId=""),this.authenticated=!1}static disconnectSocketById(t){const i=j.instances.get(t);i&&i.socket?(i.socket.disconnect(),j.instances.delete(t)):console.error(`Socket with ID ${t} not found`)}}j.instances=new Map;const E=s(class extends e{constructor(i){super(),!1!==i&&this.__registerHost(),this.__attachShadow(),this.feedback=o(this,"feedback",7),this.survey=o(this,"survey",7),this.stateChanged=o(this,"stateChanged",7),this.messageReceived=o(this,"messageReceived",7),this.formSubmitted=o(this,"formComplete",7),this.surveyCDNPath="https://cdn.ai12z.net/pkg/surveyjs",this.surveyScriptsLoaded=null,this.chats=[],this.chatExcludeTags=[],this.chatIncludeTags=[],this.componentType="search",this.chatPosition="below",this.copied=!1,this.isPlayed=!1,this.buttons=[],this.currentPage=0,this.currentSlide=0,this.scriptArray=[],this.isProse=!0,this.isProcessingEndResponse=!1,this.surveyDomId="",this.focusedIndex=-1,this.chatItemRefs=[],this.styles=[`https://cdn.ai12z.net/assets/bot/${t.CDN_PATH}/tailwind.min.css`,"https://unpkg.com/@highlightjs/cdn-assets@11.11.1/styles/default.min.css","https://cdn.ai12z.net/pkg/surveyjs/survey-core@2.3.4/survey-core.min.css"],this.getUpdatedChat=(t,i)=>{var s,e,o,n,a;const r=`ai-message-${this.generateUUID()}`,l=this.generateUUID();let h={message:i,type:"ai",status:"success",insightId:t.insightId,id:r,thumbsId:l,controlType:null!==(a=null===(n=null===(o=null===(e=null===(s=t.controlData)||void 0===s?void 0:s.data)||void 0===e?void 0:e.source)||void 0===o?void 0:o.carousel)||void 0===n?void 0:n.type)&&void 0!==a?a:""};return this.survey.emit({results:h,type:"carousel"}),h},this.updateChatMessage=(t,i)=>{const s=this.chats.findIndex((t=>t.id===this.aiMessageId));-1!==s&&(this.chats[s].message=t,this.chats[s].clipboard=t,"form"===i.controlType&&(this.chats[s].controlType=i.controlType,this.chats[s].itemComponent=i,this.chats[s].surveyDomId=i.surveyDomId),this.chats=[...this.chats])},this.handlePrev=()=>{this.currentSlide=(this.currentSlide-1+this.itemList.length)%this.itemList.length,this.processTemplateData(this.currentChatData,"","pagination")},this.handleNext=()=>{this.currentSlide=(this.currentSlide+1)%this.itemList.length,this.processTemplateData(this.currentChatData,"","pagination")},this.handleButtonClick=t=>()=>{this.survey.emit({results:t,type:"button"})},this.handleMessage=(t,i)=>{const s=new a.Converter,e=this.element.shadowRoot.querySelector(`#${i}`);if(!e)return void console.error(`Message bubble with ID ${i} not found.`);var o=e.getAttribute("data-bubbleText")||"";e.setAttribute("data-bubbleText",o+=t),e.setAttribute("aria-label",o),e.setAttribute("role","log"),e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","false");let n=s.makeHtml(o);const r=document.getElementById("spinner");r&&(r.style.display="none"),e.innerHTML=n,this.chats[this.chats.length-1].status="success"},this.scrollToBottom=()=>{this.scrollBottom=this.element.shadowRoot.querySelector(".scroll-bottom"),this.scrollBottom.scrollIntoView({behavior:"smooth",block:"end"})},this.disableFeedback=t=>{const i=this.element.shadowRoot.querySelector(`#thumbsUp_${t}`),s=this.element.shadowRoot.querySelector(`#thumbsDown_${t}`);i.classList.add("not-allowed"),i.setAttribute("disabled","true"),s.classList.add("not-allowed"),s.setAttribute("disabled","true")},this.thumbsUp=(t,i,s)=>{const e=this.element.shadowRoot.querySelector(`#thumbsUp_${t}`);e.classList.add("thumbs-up"),e.innerHTML='\n <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">\n <path d="M7.493 18.5c-.425 0-.82-.236-.975-.632A7.48 7.48 0 0 1 6 15.125c0-1.75.599-3.358 1.602-4.634.151-.192.373-.309.6-.397.473-.183.89-.514 1.212-.924a9.042 9.042 0 0 1 2.861-2.4c.723-.384 1.35-.956 1.653-1.715a4.498 4.498 0 0 0 .322-1.672V2.75A.75.75 0 0 1 15 2a2.25 2.25 0 0 1 2.25 2.25c0 1.152-.26 2.243-.723 3.218-.266.558.107 1.282.725 1.282h3.126c1.026 0 1.945.694 2.054 1.715.045.422.068.85.068 1.285a11.95 11.95 0 0 1-2.649 7.521c-.388.482-.987.729-1.605.729H14.23c-.483 0-.964-.078-1.423-.23l-3.114-1.04a4.501 4.501 0 0 0-1.423-.23h-.777ZM2.331 10.727a11.969 11.969 0 0 0-.831 4.398 12 12 0 0 0 .52 3.507C2.28 19.482 3.105 20 3.994 20H4.9c.445 0 .72-.498.523-.898a8.963 8.963 0 0 1-.924-3.977c0-1.708.476-3.305 1.302-4.666.245-.403-.028-.959-.5-.959H4.25c-.832 0-1.612.453-1.918 1.227Z" />\n </svg>\n ',this.disableFeedback(t),this.feedback.emit({insightId:i,feedback:{value:1}}),H("up",i||t,s)},this.thumbsDown=(t,i,s)=>{const e=this.element.shadowRoot.querySelector(`#thumbsDown_${t}`);e.classList.add("thumbs-down"),e.innerHTML='\n <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">\n <path d="M15.73 5.5h1.035A7.465 7.465 0 0 1 18 9.625a7.465 7.465 0 0 1-1.235 4.125h-.148c-.806 0-1.534.446-2.031 1.08a9.04 9.04 0 0 1-2.861 2.4c-.723.384-1.35.956-1.653 1.715a4.499 4.499 0 0 0-.322 1.672v.633A.75.75 0 0 1 9 22a2.25 2.25 0 0 1-2.25-2.25c0-1.152.26-2.243.723-3.218.266-.558-.107-1.282-.725-1.282H3.622c-1.026 0-1.945-.694-2.054-1.715A12.137 12.137 0 0 1 1.5 12.25c0-2.848.992-5.464 2.649-7.521C4.537 4.247 5.136 4 5.754 4H9.77a4.5 4.5 0 0 1 1.423.23l3.114 1.04a4.5 4.5 0 0 0 1.423.23ZM21.669 14.023c.536-1.362.831-2.845.831-4.398 0-1.22-.182-2.398-.52-3.507-.26-.85-1.084-1.368-1.973-1.368H19.1c-.445 0-.72.498-.523.898.591 1.2.924 2.55.924 3.977a8.958 8.958 0 0 1-1.302 4.666c-.245.403.028.959.5.959h1.053c.832 0 1.612-.453 1.918-1.227Z" />\n </svg>\n ',this.disableFeedback(t),this.feedback.emit({insightId:i,feedback:{value:-1}}),H("down",i||t,s)}}handleChatKeyNav(t,i){var s,e;if("ArrowDown"===t.key){t.preventDefault(),t.stopPropagation();const e=Math.min(this.chats.length-1,i+1);this.focusedIndex=e,null===(s=this.chatItemRefs[e])||void 0===s||s.focus()}else if("ArrowUp"===t.key){t.preventDefault(),t.stopPropagation();const s=Math.max(0,i-1);this.focusedIndex=s,null===(e=this.chatItemRefs[s])||void 0===e||e.focus()}}componentDidLoad(){const t=document.createElement("script");t.text='\n var ai12zChat = window["ai12z"] = {}\n ',document.head.appendChild(t),this.element.shadowRoot.appendChild(t),setTimeout((()=>{var t,i;if(this.customstyle){const i=document.createElement("link");i.setAttribute("rel","stylesheet"),i.setAttribute("href",this.customstyle),null===(t=this.element.shadowRoot)||void 0===t||t.appendChild(i)}if(this.customJS){const t=document.createElement("script");t.setAttribute("type","text/javascript"),t.setAttribute("src",this.customJS),null===(i=this.element.shadowRoot)||void 0===i||i.appendChild(t)}}),500),this.loadScriptsSequentially()}async loadScriptsSequentially(){return this.surveyScriptsLoaded||(this.surveyScriptsLoaded=(async()=>{try{await this.loadScript(`${this.surveyCDNPath}/survey-core@2.3.4/survey.core.min.js`),await this.loadScript(`${this.surveyCDNPath}/survey-core@2.3.4/survey.i18n.min.js`),await this.loadScript(`${this.surveyCDNPath}/survey-core@2.3.4/themes/index.min.js`),await this.loadScript(`${this.surveyCDNPath}/survey-js-ui@2.3.4/survey-js-ui.min.js`),this.loadStyles()}catch(t){throw console.error("Failed to load Survey.js scripts:",t),t}})()),this.surveyScriptsLoaded}loadScript(t){return new Promise(((i,s)=>{if(document.querySelector(`script[src="${t}"]`))return void i();const e=document.createElement("script");e.src=t,e.async=!1,e.onload=()=>i(),e.onerror=()=>s(new Error(`Failed to load script: ${t}`)),this.element.shadowRoot.appendChild(e)}))}loadStyles(){for(const t of this.styles){const i=document.createElement("link");i.rel="stylesheet",i.href=t,i.onerror=t=>{console.error("Failed to load style:",t)},this.element.shadowRoot.appendChild(i)}}scrollToLatestBubble(){var t;if("search"===this.componentType){const i=this.element.closest(".chat-content-wrapper"),s=null===(t=this.element.shadowRoot)||void 0===t?void 0:t.querySelector(".chat-list"),e=null==s?void 0:s.querySelectorAll(".non-pending-user"),o=null==e?void 0:e[e.length-1];if(i&&o){const t=i.getBoundingClientRect(),s=o.getBoundingClientRect();i.scrollTo({top:s.top-t.top+i.scrollTop,behavior:"smooth"})}return}const i=this.element.shadowRoot.querySelector(".chat-list"),s=null==i?void 0:i.querySelectorAll(".non-pending-user"),e=null==s?void 0:s[s.length-1];e&&e.scrollIntoView({behavior:"smooth",block:"start"})}componentWillLoad(){this.loadStyles(),"undefined"==typeof window||window.Handlebars||(window.Handlebars=v)}async hydrateMessagesFromState(){var t,i,s;if((null===(t=this.element)||void 0===t?void 0:t.shadowRoot)&&0!==this.chats.length){await this.loadScriptsSequentially(),await new Promise((t=>requestAnimationFrame((()=>t()))));for(const t of this.chats){if("template"===t.controlType)this.processTemplateData(t,t.itemComponent,t.controlType);else if("form"===t.controlType){if(!t.surveyDomId)continue;this.surveyDomId=t.surveyDomId;const i=await S(`#${t.id}`,this.element);i.querySelector(`#${t.surveyDomId}`)||await S(`#${t.surveyDomId}`,this.element),i.style.width="100%",i.parentElement.style.width="100%",await this.renderSurvey(t.itemComponent)}else if("carousel"===t.controlType&&"carousel"===(null===(i=t.itemComponent)||void 0===i?void 0:i.controlType))this.processChatData(t,t.itemComponent);else if(!t.controlType){t.text=m(t.text,this.target||"_blank","ai12z-cta-link",null===(s=this.settings)||void 0===s?void 0:s.utm,"answer");const i=b(t.text);t.text=i.body,this.buttons=i.buttons,this.addEventListeners(`#${t.id}`)}"form"!==t.controlType&&(this.hideSpinner(t).then((()=>{console.log("spinner is hidden")})),this.checkHighlightcode(t.id))}}}disconnectedCallback(){window.ai12z={},this.chats=[]}watchHandler(t,i){}getProjectId(){var t,i,s,e;return null!==(e=null!==(i=null===(t=this.settings)||void 0===t?void 0:t.pId)&&void 0!==i?i:null===(s=this.dataAttributes)||void 0===s?void 0:s.projectId)&&void 0!==e?e:null}streamResponseHandler(t){const{id:i,idChanged:s}=l(this.aiMessageId,this.chats,"ai-message");this.aiMessageId=i,s&&(this.chats=[...this.chats]),requestAnimationFrame((()=>this.handleMessage(t.detail.data,this.aiMessageId)))}async renderSurvey(t){await this.loadScriptsSequentially(),await C({chat:t,surveyDomId:this.surveyDomId,shadowRoot:this.element.shadowRoot,config:{dataKey:this.apiKey,dataMode:this.env,dataAttributes:this.dataAttributes,formSubmitRenderCallback:t=>{this.handleSurveyCompletionRender(t)},onSubmitError:t=>{var i;const s=null===(i=this.element.shadowRoot)||void 0===i?void 0:i.querySelector(`#${this.surveyDomId}`);s?s.innerHTML="Form submission blocked by validation"!==t?"Failed to submit form":"Submission blocked due to suspicious activity.":console.error(`Survey element not found for DOM ID: ${this.surveyDomId}`)}}})}handleSurveyCompletionRender(t){t&&(this.element.shadowRoot.querySelector(`#${t.domId}`).parentElement.innerHTML=t.completedHtml,this.formSubmitted.emit(t),this.survey.emit(t))}endResponseHandler(t){const{id:i,idChanged:s,orphaned:e}=l(this.aiMessageId,this.chats,"ai-message");this.aiMessageId=i,s&&(this.chats=[...this.chats]),e||this.messageReceived.emit({data:t.detail,domId:this.aiMessageId}),this.isProcessingEndResponse?console.log("Already processing endResponse, ignoring duplicate"):(this.scrollToLatestBubble(),this.isProcessingEndResponse=!0,2!==this.chats.length||this.settings.disableBeacon||T(this.apiKey,this.env,t.detail.conversationId),requestAnimationFrame((async()=>{var i,s,e,o;try{const n={element:this.element,hideSpinner:t=>{this.hideSpinner(t)},getUpdatedChat:(t,i)=>this.getUpdatedChat(i,t),updateChatMessage:(t,i)=>{this.updateChatMessage(t,i)},renderSurvey:t=>this.renderSurvey(t),processTemplateData:(t,i)=>this.processTemplateData(t,i,"carousel"),processChatData:(t,i)=>this.processChatData(t,i),checkHighlightcode:t=>this.checkHighlightcode(t),addEventListeners:t=>this.addEventListeners(t),customStyle:this.customstyle,customJS:this.customJS,conversationId:this.conversationId,controlSettings:this.settings,utmConfig:null===(i=this.settings)||void 0===i?void 0:i.utm};await z({data:t.detail,currentDomId:this.aiMessageId,inputType:"cta",setMessages:t=>{this.chats=[...this.chats,t],this.aiMessageId=t.id,requestAnimationFrame((()=>{setTimeout((()=>{t&&t.id&&this.hideSpinner(t).then((()=>{}))}),100)}))},setSurveyDomId:t=>{this.surveyDomId=t},setButtons:t=>{this.buttons=t},config:n}),this.conversationId=t.detail.conversationId,h(this.getProjectId(),this.chats,this.conversationId,null!==(o=null===(e=null===(s=this.settings)||void 0===s?void 0:s._id)||void 0===e?void 0:e.$oid)&&void 0!==o?o:"","ai12z-cta-history","search"),this.aiMessageId=""}catch(t){console.error("Error handling end_response:",t)}finally{setTimeout((()=>{this.isProcessingEndResponse=!1}),500)}})))}checkHighlightcode(t=""){var i;try{if(!t)return console.warn("highlightcodeId is empty"),void(this.isProse=!0);const s=null===(i=this.element.shadowRoot)||void 0===i?void 0:i.querySelector(`#${t}`);if(!s)return console.warn(`Element with id '${t}' not found in shadowRoot`),void(this.isProse=!0);const e=s.querySelectorAll("pre");e.length>0?(s.classList.remove("prose"),import("./p-BO_7DTeV.js").then((function(t){return t.i})).then((({default:t})=>{t.configure({ignoreUnescapedHTML:!0}),e.forEach((i=>{i.dataset.highlighted?console.warn("Element previously highlighted..."):t.highlightElement(i)}))})).catch((t=>console.error("Failed to load highlight.js:",t)))):s.classList.add("prose")}catch(t){console.error("Error in highlightcode:",t),this.isProse=!0}}buttonClickHandler(t){this.survey.emit({results:t.detail,type:"button"})}get mainObject(){return window.ai12z||(window.ai12z={}),window.ai12z}generateUUID(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var i=16*Math.random()|0;return("x"==t?i:3&i|8).toString(16)}))}async processChatData(t,i){r(t,i,this.element,(t=>this.hideSpinner(t)),(t=>{this.survey.emit({results:t,type:"update"})}),this.customJS,this.customstyle,!1,"ai")}addEventforReadMore(){this.element.shadowRoot.querySelectorAll(".read-more").forEach((t=>{t.addEventListener("click",(t=>{const i=t.target.closest(".card"),s=i.querySelector(".short-description"),e=i.querySelector(".long-description"),o=i.querySelector(".card-image");s.classList.toggle("hidden"),e.classList.toggle("hidden"),s.classList.contains("hidden")?(o.classList.add("hidden"),i.classList.remove("md:grid-cols-2"),t.target.textContent="Show Less"):(o.classList.remove("hidden"),i.classList.add("md:grid-cols-2"),t.target.textContent="Read More")}))}))}addEventforPanel(t,i){this.element.shadowRoot.querySelectorAll(".panel-button").forEach((t=>{t.addEventListener("click",(t=>{"panel"===t.target.getAttribute("data-type")&&this.processTemplateData(this.currentChatData,"","pagination")}))}))}handleIndicatorClick(t){this.currentSlide=t,this.processTemplateData(this.currentChatData,"","pagination")}updateCarousel(){var t,i;const s=null!==(t=this.element.shadowRoot.querySelector(".prev"))&&void 0!==t?t:this.element.shadowRoot.querySelector(".prev-btn"),e=null!==(i=this.element.shadowRoot.querySelector(".next"))&&void 0!==i?i:this.element.shadowRoot.querySelector(".next-btn");this.element.shadowRoot.querySelectorAll(".indicator").forEach(((t,i)=>{t.addEventListener("click",(()=>this.handleIndicatorClick(i)))})),null==s||s.addEventListener("click",this.handlePrev),null==e||e.addEventListener("click",this.handleNext)}renderPagination(t){let i,s,e,o,n;switch(t){case"carousel":return i=1,o=this.itemList,n={paginatedItems:o,isFirstSlide:0===this.currentSlide,isLastSlide:this.currentSlide===this.itemList.length-1,transform:`-${100*this.currentSlide}%`,currentSlide:this.currentSlide},{context:n,end:e};case"list":return i=5,s=this.currentPage*i,e=s+i,o=this.itemList.slice(s,e),n={items:o,hasPrev:this.currentPage>0,hasNext:e<this.itemList.length},{context:n,end:e}}}addEventforPagination(t){var i,s;null===(i=this.element.shadowRoot.querySelector(".prev-btn"))||void 0===i||i.addEventListener("click",(()=>{this.currentPage>0&&(this.currentPage--,this.processTemplateData(this.currentChatData,"","pagination"))})),null===(s=this.element.shadowRoot.querySelector(".next-btn"))||void 0===s||s.addEventListener("click",(()=>{t<this.itemList.length&&(this.currentPage++,this.processTemplateData(this.currentChatData,"","pagination"))}))}addEventforcardButton(t,i){this.element.shadowRoot.querySelectorAll(".card-button").forEach((s=>{s.addEventListener("click",(s=>{var e,o;v.registerHelper("json",(function(t){return JSON.stringify(t)}));const n=s.target.getAttribute("data-id"),a=s.target.getAttribute("data-type"),r=s.target.getAttribute("data-url");if("panel"===a){const a=v.compile(i[Number(n)+1].content),r=this.element.shadowRoot.querySelectorAll(".carousel-card"),l=s.target.closest(".carousel-card").getAttribute("data-index");r[l].innerHTML=a({form:null===(e=t.items[l].panels[Number(n)])||void 0===e?void 0:e.form,formSettings:t.formSettings,buttons:null===(o=t.items[l].panels[Number(n)])||void 0===o?void 0:o.buttons}),this.addEventforPanel(i,t)}"url"===a&&window.open(r,"_blank")}))}))}async processTemplateData(t,i,s){this.currentChatData=t,await this.waitForElementRender(`#${t.id}`).then((async()=>{var e,o,n,a,r;this.hideSpinner(t);const l=this.element.shadowRoot.querySelector(`#${t.id}`);let h;if(l){if("carousel"===s&&(this.currentTemplate=null===(e=i.controlData)||void 0===e?void 0:e.template,this.currentResponse=null===(o=i.controlData)||void 0===o?void 0:o.data.source,this.itemList=this.currentResponse.items),l.parentElement.style.width="90%",h=v.compile(null===(n=this.currentTemplate[0])||void 0===n?void 0:n.content),"list"===this.currentResponse.process)l.innerHTML=h(this.renderPagination("list").context),this.addEventforPagination(this.renderPagination("list").end);else if("carousel"===this.currentResponse.process)v.registerHelper("eq",(function(t,i){return t===i})),l.innerHTML=h(this.renderPagination("carousel").context),this.updateCarousel();else{v.registerHelper("processArray",(function(t){return Array.isArray(t)?new v.SafeString(JSON.stringify(t)):""})),t.data=i.controlData.data,i.controlData&&i.controlData.data&&(i.controlData.data.msgId=t.id);const s=null===(a=i.controlData)||void 0===a?void 0:a.styles,e=null===(r=i.controlData)||void 0===r?void 0:r.Scripts;s&&I(s,this.element.shadowRoot),l.innerHTML=h({msgId:`${t.id}`,source:this.currentResponse,llm:i.controlData.data.llm}),e&&$(e,l),setTimeout((()=>{this.renderTemplateData(t)}),1e3)}this.addEventforReadMore(),this.addEventforcardButton(this.currentResponse,this.currentTemplate),t.message=l.innerHTML,this.survey.emit({results:t,type:"update"})}}))}renderTemplateData(t){this.mainObject[`${t.id}`]||(this.mainObject[`${t.id}`]={}),this.element.shadowRoot.querySelectorAll(`#${t.id} script`).forEach((t=>{var i;const s=document.createElement("script");s.type="text/javascript",t.src?s.src=t.src:s.innerHTML+=t.innerHTML,s.src||this.scriptArray.push(s),null===(i=t.parentNode)||void 0===i||i.removeChild(t),s.src&&!this.element.shadowRoot.querySelector(`script[src="${s.src}"]`)?this.element.shadowRoot.appendChild(s):this.element.shadowRoot.querySelector('script[type="text/javascript"]')&&!s.src&&(this.scriptArray.length>1?this.scriptArray.forEach((t=>{t.src||t.innerHTML===s.innerHTML||this.element.shadowRoot.appendChild(s)})):this.element.shadowRoot.appendChild(s))})),setTimeout((()=>{this.initializeScript(t.id)}),1e3)}initializeScript(t){"function"==typeof this.mainObject[`${t}`].onLoadCallback&&this.mainObject[`${t}`].onLoadCallback()}hideSpinner(t){return new Promise((i=>{const s=this.element.shadowRoot.querySelector(`#${t.id}`);s&&s.querySelector("#spinner")&&(s.querySelector("#spinner").style.display="none"),i(!0)}))}waitForElementRender(t){return new Promise((i=>{if(this.element.shadowRoot.querySelector(t))return void i();const s=new MutationObserver((()=>{this.element.shadowRoot.querySelector(t)&&(i(),s.disconnect())}));s.observe(this.element.shadowRoot,{childList:!0,subtree:!0})}))}waitForElementToAdd(t){return new Promise((i=>{const s=new MutationObserver((()=>{i(),s.disconnect()}));s.observe(t,{childList:!0,subtree:!0})}))}async invokeSocket(){var i,s,e,o,n,a;let r=null===(i=this.socketIn)||void 0===i?void 0:i.getSocketId();if(!r)return void console.error("Socket ID not available");let l=j.getInstanceById(r);if(!l){console.warn(`No socket service found for socket ID: ${r}, attempting to wait for connection...`);try{await this.socketIn.waitForConnection(),r=this.socketIn.getSocketId(),l=j.getInstanceById(r)}catch(t){console.error("Failed to wait for connection:",t)}}if(!l){console.warn("Creating new socket service...");try{const i=j.createInstance(this.env,null!==(s=this.apiKey)&&void 0!==s?s:t.DATA_KEY);if(await i.waitForConnection(),this.socketIn=i,r=i.getSocketId(),l=j.getInstanceById(r),!l)return void console.error("Failed to create and retrieve new socket service")}catch(t){return void console.error("Failed to create new socket service:",t)}}const h=l.getSocket();if(!h)return void console.error("Socket not available from service");let c,d;"v2"===l.getProtocol()?(d="query",c={query:this.query,conversation_id:this.conversationId||"",base64_images:(null===(e=this.imgFiles)||void 0===e?void 0:e.length)>0?this.imgFiles:void 0}):(d="evaluate_query",c={apiKey:null!==(o=this.apiKey)&&void 0!==o?o:t.DATA_KEY,query:this.query,conversationId:null!==(n=this.conversationId)&&void 0!==n?n:"",base64Images:(null===(a=this.imgFiles)||void 0===a?void 0:a.length)>0?this.imgFiles:[],event:"evaluate_query",attributes:this.dataAttributes,excludeTags:this.chatExcludeTags,includeTags:this.chatIncludeTags,meta:g()}),h.emit(d,c,(t=>{t&&(console.error("Error occurred while evaluating query:",t),this.aiMessageId=`chatbot-${w()}`,this.chats[this.chats.length-1].id=this.aiMessageId,this.chats[this.chats.length-1].text="Error connecting to server. Please try again later.")}))}addEventListeners(t){const i=this.element.shadowRoot.querySelector(t);i&&this.buttons.forEach((t=>{const s=i.querySelector(`#${t.id}`);if(s){const i=s.getAttribute("data-original-click");if(!i)return void console.warn(`originalClickHandler is not defined for button with id: ${t.id}`);const e=i.match(/^([\w.]+)\s*\(([\s\S]*)\)$/);if(e){const i=e[1],o=e[2],n=i.includes(".")?i.split(".").pop():i;s.addEventListener("click",(()=>{try{switch(n){case"sendQuery":console.warn("sendQuery is deprecated, use sendMessage instead"),this.survey.emit({results:t.label,type:"button"});break;case"sendMessage":case"ai12zCtrl.sendMessage":const i=c(o);if(!i)return;this.survey.emit({results:i,type:"sendMessage"});break;case"sendJSON":case"ai12zCtrl.sendJSON":const s=c(o);if(!s)return;this.survey.emit({results:s,type:"sendJSON"})}}catch(t){console.error(`Error invoking ${i}:`,t)}}))}}}))}stopStreamInputHandler(t){this.socketIn&&j.disconnectSocketById(t.detail.socketId)}startStreamInputHandler(t){var i,s,e;(null===(i=t.detail)||void 0===i?void 0:i.maxQuestion)?setTimeout((()=>{this.hideSpinner(t.detail.chatData),this.scrollToLatestBubble()}),1e3):(this.query=null===(s=t.detail)||void 0===s?void 0:s.search,this.imgFiles=null===(e=t.detail)||void 0===e?void 0:e.imgFiles,this.invokeSocket(),this.chats.length>2&&setTimeout((()=>{this.scrollToLatestBubble()}),500))}highlightcode(){const t=this.element.shadowRoot.querySelectorAll("pre");t.length>0&&(this.isProse=!1,import("./p-BO_7DTeV.js").then((function(t){return t.i})).then((({default:i})=>{i.configure({ignoreUnescapedHTML:!0}),t.forEach((t=>{i.highlightElement(t)}))})).catch((t=>console.error("Failed to load highlight.js:",t))))}copyToClipboard(t){navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([t],{type:"text/html"}),"text/plain":new Blob([this.removeHtmlTags(t)],{type:"text/plain"})})]).then((()=>{this.copied=!0,setTimeout((()=>{this.copied=!1}),2e3)}))}removeHtmlTags(t){const i=document.createElement("div");return i.innerHTML=t,i.textContent||i.innerText||""}async speakText(i){var s,e;if("default"===this.voiceType)if("speechSynthesis"in window){const t=window.speechSynthesis.getVoices().find((t=>t.name===this.voice));this.isPlayed=!0;const s=new SpeechSynthesisUtterance(i);s.lang="en-US",s.rate=1,s.pitch=1,s.voice=t,window.speechSynthesis.speak(s)}else alert("Speech Synthesis API is not supported in your browser.");if("google"===this.voiceType){const o=await f(null!==(s=this.apiKey)&&void 0!==s?s:t.DATA_KEY,null!==(e=this.env)&&void 0!==e?e:t.DATA_MODE,i,this.voice),n=this.base64ToBlob(o.audio_content,"audio/mpeg"),a=URL.createObjectURL(n);this.audioElement=new Audio(a),this.audioElement.onended=()=>{this.isPlayed=!1},this.audioElement.paused?(this.audioElement.play(),this.isPlayed=!0):(this.audioElement.pause(),this.audioElement.currentTime=0,this.audioElement.src="",this.audioElement=null,this.isPlayed=!1)}}base64ToBlob(t,i){const s=atob(t),e=new Array(s.length).fill(0).map(((t,i)=>s.charCodeAt(i))),o=new Uint8Array(e);return new Blob([o],{type:i})}render(){var t;return n("div",{key:"5883ac798ea9966385dc63a39f5e4bc2afb4c866"},n("ul",{key:"f46ac1484464dac37be35530bd44f4702ddbdb97",id:"main-content",tabindex:"-1",class:{"chat-list":!0,"custom-list":"search"===this.componentType,"custom-chat-bottom-height":"inline"===this.componentType,"custom-chat-above-height":"inline"===this.componentType&&"above"===this.chatPosition},style:{maxHeight:"search"!==this.componentType?"80vh":"none",overflowY:"search"!==this.componentType?"auto":"visible",height:"search"===this.componentType?"auto":"100%"}},null===(t=this.chats)||void 0===t?void 0:t.map(((t,i)=>{var s,e,o,a,r;const l="ai"===t.type&&(i===this.chats.length-1||"ai"!==(null===(s=this.chats[i+1])||void 0===s?void 0:s.type));return n("li",{class:{"text-md":!0,"chat-list-item":!0,"chat-align-list":"user"!==t.type,"chat-not-user-list":"user"===t.type,"pointer-events-none":"user"===t.type},tabindex:i===this.focusedIndex?0:-1,onKeyDown:t=>this.handleChatKeyNav(t,i),ref:t=>this.chatItemRefs[i]=t,role:"article","aria-label":`${"user"===t.type?"Your message":"Bot response"} ${i+1}`},"user"!==t.type&&n("div",{class:"chat-inner-list default-avatar"},!this.avatarUrl&&n("svg",{viewBox:"0 0 48 48",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",class:"w-8 h-8 "+(l?"md:block":"opacity-0")},n("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"})),this.avatarUrl&&n("div",{class:"avatar-container "+(l?"md:block":"opacity-0")},n("img",{src:this.avatarUrl,alt:"Avatar",class:"avatar-image w-8 h-8 rounded-full"}))),"pending"===t.status&&n("div",{class:"pending-chat"},n("svg",{class:"animate-spin h-5 w-5 text-gray-400",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},n("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"}),n("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 0 1 4 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"}))),n("div",{id:"parent-element",onMouseEnter:t=>{let i=t.target.querySelector(".non-user-container");i&&(i.style.display="block")},onMouseLeave:t=>{let i=t.target.querySelector(".non-user-container");i&&(i.style.display="none")},style:{width:"user"!==t.type?"90%":"auto"}},"pending"!==t.status&&!("user"===t.type&&t.isHide)&&n("div",{class:{"p-4":!0,"max-w-full":"search"===this.componentType,prose:!0,"custom-prose":!0,"transition-all":!0,"duration-300":!0,"opacity-100":this.isProse,"opacity-90":!this.isProse,resize:null===(e=t.formModel)||void 0===e?void 0:e.hasOwnProperty("answer"),"non-pending-user":!0},id:t.id,innerHTML:t.message},null===(o=null==t?void 0:t.images)||void 0===o?void 0:o.map((t=>n("img",{src:t,class:"thumbnail",alt:"thumbnail",width:"70",height:"50"}))),"user"!==t.type&&n("div",{class:"w-full rounded-md",id:"spinner"},n("div",{class:"flex animate-pulse space-x-4"},n("div",{class:"flex-1 space-y-3 py-1"},n("div",{class:"h-4 rounded bg-gray-200"}),n("div",{class:"space-y-3"},n("div",{class:"grid grid-cols-3 gap-4"},n("div",{class:"col-span-2 h-4 rounded bg-gray-200"}),n("div",{class:"col-span-1 h-4 rounded bg-gray-200"})),n("div",{class:"h-4 rounded bg-gray-200"})))))),"user"!==t.type&&t.clipboard&&(null===(a=this.settings.showMessageIcons)||void 0===a||a)&&!t.surveyDomId&&n("div",{class:"non-user-container",style:{display:"none"}},this.isPlayed&&n("button",{class:"copy-btn","aria-label":"Stop",tabindex:"0",onClick:()=>{this.isPlayed=!1,window.speechSynthesis.cancel(),this.audioElement&&(this.audioElement.pause(),this.audioElement.currentTime=0,this.audioElement.src="",this.audioElement=null)}},n("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",class:"icon-md-heavy"},n("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22C6.47715 22 2 17.5228 2 12ZM9.5 8.5C8.94772 8.5 8.5 8.94772 8.5 9.5V14.5C8.5 15.0523 8.94772 15.5 9.5 15.5H14.5C15.0523 15.5 15.5 15.0523 15.5 14.5V9.5C15.5 8.94772 15.0523 8.5 14.5 8.5H9.5Z",fill:"currentColor"}))),!this.isPlayed&&n("button",{class:"copy-btn",onClick:()=>this.speakText(this.removeHtmlTags(t.clipboard)),"aria-label":"Play",tabindex:"0"},n("svg",{class:"w-6 h-6",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},n("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M11 4.9099C11 4.47485 10.4828 4.24734 10.1621 4.54132L6.67572 7.7372C6.49129 7.90626 6.25019 8.00005 6 8.00005H4C3.44772 8.00005 3 8.44776 3 9.00005V15C3 15.5523 3.44772 16 4 16H6C6.25019 16 6.49129 16.0938 6.67572 16.2629L10.1621 19.4588C10.4828 19.7527 11 19.5252 11 19.0902V4.9099ZM8.81069 3.06701C10.4142 1.59714 13 2.73463 13 4.9099V19.0902C13 21.2655 10.4142 22.403 8.81069 20.9331L5.61102 18H4C2.34315 18 1 16.6569 1 15V9.00005C1 7.34319 2.34315 6.00005 4 6.00005H5.61102L8.81069 3.06701ZM20.3166 6.35665C20.8019 6.09313 21.409 6.27296 21.6725 6.75833C22.5191 8.3176 22.9996 10.1042 22.9996 12.0001C22.9996 13.8507 22.5418 15.5974 21.7323 17.1302C21.4744 17.6185 20.8695 17.8054 20.3811 17.5475C19.8927 17.2896 19.7059 16.6846 19.9638 16.1962C20.6249 14.9444 20.9996 13.5175 20.9996 12.0001C20.9996 10.4458 20.6064 8.98627 19.9149 7.71262C19.6514 7.22726 19.8312 6.62017 20.3166 6.35665ZM15.7994 7.90049C16.241 7.5688 16.8679 7.65789 17.1995 8.09947C18.0156 9.18593 18.4996 10.5379 18.4996 12.0001C18.4996 13.3127 18.1094 14.5372 17.4385 15.5604C17.1357 16.0222 16.5158 16.1511 16.0539 15.8483C15.5921 15.5455 15.4632 14.9255 15.766 14.4637C16.2298 13.7564 16.4996 12.9113 16.4996 12.0001C16.4996 10.9859 16.1653 10.0526 15.6004 9.30063C15.2687 8.85905 15.3578 8.23218 15.7994 7.90049Z",fill:"currentColor"}))),n("button",{class:"copy-btn",onClick:()=>this.copyToClipboard(t.clipboard),"aria-label":"Copy to Clipboard",tabindex:"0"},!this.copied&&n("svg",{class:"w-6 h-6",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},n("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M7 5C7 3.34315 8.34315 2 10 2H19C20.6569 2 22 3.34315 22 5V14C22 15.6569 20.6569 17 19 17H17V19C17 20.6569 15.6569 22 14 22H5C3.34315 22 2 20.6569 2 19V10C2 8.34315 3.34315 7 5 7H7V5ZM9 7H14C15.6569 7 17 8.34315 17 10V15H19C19.5523 15 20 14.5523 20 14V5C20 4.44772 19.5523 4 19 4H10C9.44772 4 9 4.44772 9 5V7ZM5 9C4.44772 9 4 9.44772 4 10V19C4 19.5523 4.44772 20 5 20H14C14.5523 20 15 19.5523 15 19V10C15 9.44772 14.5523 9 14 9H5Z",fill:"currentColor"})),this.copied&&n("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",class:"w-6 h-6"},n("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M19.8198 6.19526C20.0601 6.45561 20.0601 6.87772 19.8198 7.13807L9.9736 17.8047C9.73328 18.0651 9.34364 18.0651 9.10332 17.8047L4.18024 12.4714C3.93992 12.2111 3.93992 11.7889 4.18024 11.5286C4.42056 11.2682 4.8102 11.2682 5.05053 11.5286L9.53846 16.3905L18.9495 6.19526C19.1898 5.93491 19.5794 5.93491 19.8198 6.19526Z",fill:"currentColor"}))),n("button",{id:`thumbsUp_${t.thumbsId}`,onClick:()=>this.thumbsUp(t.thumbsId,t.insightId,{dataKey:this.apiKey,dataMode:this.env,conversationId:this.conversationId,projectId:this.getProjectId(),questionText:M(this.chats,t.insightId)||""}),class:"chat-thumbs-up","aria-label":"Thumbs Up",tabindex:"0"},n("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"},n("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M6.633 10.25c.806 0 1.533-.446 2.031-1.08a9.041 9.041 0 0 1 2.861-2.4c.723-.384 1.35-.956 1.653-1.715a4.498 4.498 0 0 0 .322-1.672V2.75a.75.75 0 0 1 .75-.75 2.25 2.25 0 0 1 2.25 2.25c0 1.152-.26 2.243-.723 3.218-.266.558.107 1.282.725 1.282m0 0h3.126c1.026 0 1.945.694 2.054 1.715.045.422.068.85.068 1.285a11.95 11.95 0 0 1-2.649 7.521c-.388.482-.987.729-1.605.729H13.48c-.483 0-.964-.078-1.423-.23l-3.114-1.04a4.501 4.501 0 0 0-1.423-.23H5.904m10.598-9.75H14.25M5.904 18.5c.083.205.173.405.27.602.197.4-.078.898-.523.898h-.908c-.889 0-1.713-.518-1.972-1.368a12 12 0 0 1-.521-3.507c0-1.553.295-3.036.831-4.398C3.387 9.953 4.167 9.5 5 9.5h1.053c.472 0 .745.556.5.96a8.958 8.958 0 0 0-1.302 4.665c0 1.194.232 2.333.654 3.375Z"}))),n("button",{id:`thumbsDown_${t.thumbsId}`,onClick:()=>this.thumbsDown(t.thumbsId,t.insightId,{dataKey:this.apiKey,dataMode:this.env,conversationId:this.conversationId,projectId:this.getProjectId(),questionText:M(this.chats,t.insightId)||""}),class:"chat-thumbs-up","aria-label":"Thumbs Down",tabindex:"0"},n("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"},n("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"}))),n("button",{class:"copy-btn",tabindex:"0","aria-label":"Send Email"},n("a",{href:`mailto:?subject=${encodeURIComponent(null===(r=this.chats[i-1])||void 0===r?void 0:r.message)}&body=${encodeURIComponent(this.removeHtmlTags(t.clipboard))}`,target:"_blank","aria-label":"Send Email"},n("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"},n("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"})," "))))))})),n("div",{key:"53802e68891a2c65e85f5df2086b129bcd15fb04",class:"scroll-bottom"})))}get element(){return this}static get watchers(){return{chats:[{watchHandler:0}]}}static get style(){return":host{font-family:var(--ai12z-font-family) !important;font-size:var(--ai12z-font-size) !important;color:var(--ai12z-font-color, black);text-align:var(--ai12z-text-align, left)}.not-allowed{cursor:not-allowed}.prose.custom-prose{--tw-prose-body:var(--ai12z-bubble-font-color);--tw-prose-bold:var(--ai12z-bubble-font-color);--tw-prose-links:var(--ai12z-link-color);--tw-prose-headings:var(--ai12z-bubble-font-color)}.ai12z-cta-link{color:var(--ai12z-link-color);text-decoration:underline}.ai12z-cta-link:hover{color:var(--ai12z-link-hover-color)}@media (max-width: 768px){.chat-align-list{padding:16px 16px 16px 0px !important}.chat-not-user-list{padding-inline-start:40px !important}}.thumbs-up{fill:var(--ai12z-feedback-selected);width:24px}.thumbs-down{fill:var(--ai12z-feedback-selected);width:24px}.chat-thumbs-up{color:var(--ai12z-feedback-color)}.default-avatar{color:var(--ai12z-default-avatar-color, var(--ai12z-primary-color))}.chat-list{margin-top:20px;overflow-y:auto;display:flex;flex-direction:column}.custom-chat-top-height{max-height:100vh}@media (max-width: 768px){.custom-chat-bottom-height{max-height:700px}.default-avatar{display:none !important}}.custom-chat-bottom-height{max-height:100%}.custom-chat-above-height{max-height:80vh;margin-bottom:20px}.custom-list{overflow-y:auto}.chat-list-item{padding:32px 8px 0 4px;display:flex;position:relative;color:var(--ai12z-bubble-font-color);font-size:var(--ai12z-bubble-font-size)}.chat-align-list{justify-content:flex-start;padding-inline-end:40px}.chat-not-user-list{justify-content:flex-end;padding-inline-start:80px}.chat-inner-list{display:flex;align-items:flex-end;padding-right:8px}.pending-chat{display:flex;justify-content:center;align-items:center;border-width:1px;padding:20px;line-height:28px;border-radius:8px}.non-pending-user{line-height:28px;border-radius:8px}.chat-not-user-list #parent-element .non-pending-user{background-color:var(--ai12z-user-bubble-background, var(--ai12z-bubble-background))}.chat-align-list #parent-element .non-pending-user{background-color:var(--ai12z-ai-bubble-background, var(--ai12z-bubble-background));border:var(--ai12z-ai-bubble-border)}#parent-element{position:relative}.non-user-container{position:absolute;right:0;top:0;width:176px}.thumbnail{margin-bottom:30px;width:70%}.ai12z_image_result{max-width:500px;width:100%;border-radius:5%;padding:20px}.ai12z_image_caption{margin:20px;padding:1px;background-color:#f0f0f0;border-radius:5px;text-align:center}.resize{width:100%}.prose.prose-w-none *{all:unset;}.non-pending-user .ai12zBtn{background-color:var(--ai12z-primary-color);color:white;padding:5px 10px;border:none;border-radius:5px;cursor:pointer;text-decoration:none;margin:5px}.ai12zBtn:active{background-color:rgb(118 135 214)}::-webkit-scrollbar{width:12px;height:12px}::-webkit-scrollbar-track{background:#f1f1f1;border-radius:10px}::-webkit-scrollbar-thumb{background-color:#888;border-radius:10px;border:2px solid #f1f1f1}::-webkit-scrollbar-thumb:hover{background:#555}.copy-btn{color:var(--ai12z-feedback-color)}.list-btn{background-color:#007bff;color:white;padding:5px 10px;border:none;border-radius:5px;cursor:pointer;text-decoration:none;margin:5px;max-width:100%;}.pagination-controls{display:flex;justify-content:space-between;margin-top:20px}.pagination-controls button{padding:10px 20px;border:none;background-color:#007bff;color:white;cursor:pointer;border-radius:5px}.pagination-controls button:disabled{background-color:#ccc;cursor:not-allowed}.pagination-controls span{align-self:center;font-size:1.1em}.hidden{display:none}.carousel-container{position:relative;display:flex;overflow:hidden;margin:0 auto;width:100%;max-width:100%}.carousel-items{display:flex;transition:transform 0.3s ease-in-out;width:100%}.carousel-card{flex-shrink:0;width:100%}.card img{width:100%;height:auto}.card-body{margin:15px}.prev,.next{background:#007bff;border:none;color:white;padding:10px;cursor:pointer;border-radius:50%;position:absolute;top:50%;transform:translateY(-50%);z-index:10}.prev{cursor:pointer;left:0px}.next{cursor:pointer;right:0px}.carousel-indicators{display:flex;justify-content:center;margin-top:10px;bottom:4px;left:50%}.indicator{width:10px;height:10px;background-color:gray;border-radius:50%;margin:0 5px;cursor:pointer}button:focus-visible{outline:2px solid var(--ai12z-focus-visible-color, #0A2A43);outline-offset:2px}button.chat-btn-primary:focus-visible{outline:2px solid var(--ai12z-focus-visible-color-primary, --ai12z-focus-visible-color);outline-offset:2px}button.chat-btn-secondary:focus-visible{outline:2px solid var(--ai12z-focus-visible-color-secondary, --ai12z-focus-visible-color)}.ai12z-form-honeypot{position:absolute;left:-10000px;top:auto;width:1px;height:1px;overflow:hidden}"}},[1,"ai12z-chat",{chatId:[1,"chat-id"],chats:[1032],query:[1025],apiKey:[1,"api-key"],aiMessageId:[1025,"ai-message-id"],imgFiles:[1032,"img-files"],env:[1025],conversationId:[1025,"conversation-id"],dataAttributes:[8,"data-attributes"],chatExcludeTags:[16],chatIncludeTags:[16],target:[1],voiceType:[1,"voice-type"],voice:[1],componentType:[1,"component-type"],chatPosition:[1,"chat-position"],socketIn:[16],customstyle:[1],customJS:[1,"custom-j-s"],avatarUrl:[1,"avatar-url"],settings:[8],scrollBottom:[32],copied:[32],isPlayed:[32],buttons:[32],itemList:[32],currentChatData:[32],currentTemplate:[32],currentPage:[32],currentResponse:[32],currentSlide:[32],scriptArray:[32],isProse:[32],isProcessingEndResponse:[32],surveyDomId:[32],focusedIndex:[32],hydrateMessagesFromState:[64]},[[8,"streamResponse","streamResponseHandler"],[8,"endResponse","endResponseHandler"],[0,"buttonClick","buttonClickHandler"],[4,"stopStream","stopStreamInputHandler"],[4,"startStream","startStreamInputHandler"]],{chats:[{watchHandler:0}]}]);function L(){"undefined"!=typeof customElements&&["ai12z-chat","item-list"].forEach((t=>{switch(t){case"ai12z-chat":customElements.get(i(t))||customElements.define(i(t),E);break;case"item-list":customElements.get(i(t))||p()}}))}L();export{E as M,j as S,L as d}
|
|
1
|
+
import{E as t,t as i,p as s,H as e,e as o,h as n}from"./p-rVmRQ8bG.js";import{s as a,p as r}from"./p-BJOnT4k4.js";import{e as l,s as h,p as c}from"./p-CW_iO9zy.js";import{i as d,g as u,d as p,H as v,u as m,e as b,j as g,a as w,C as f}from"./p-djQQf6su.js";import{l as x,b as y,a as k}from"./p-B_OuPB-D.js";import{r as C}from"./p-M51H23z5.js";import{w as z,h as S}from"./p-D338smYm.js";import{t as H,g as M}from"./p-ChFVg77w.js";import{l as I,b as $}from"./p-DmqUTHP1.js";import{s as T}from"./p-D5Grnjb5.js";class j{constructor(i,s=""){this.socketId="",this.socket=null,this.mode=t.DATA_MODE,this.connectionPromise=null,this.apiKey="",this.protocol="legacy",this.authenticated=!1,this.mode=i,this.apiKey=s,this.protocol=d(i),this.initSocket()}initSocket(){if(this.socket&&(this.clearSocketListeners(),this.socket.disconnect(),this.socket=null),!this.socket){let t=u(this.mode);this.connectionPromise=new Promise(((i,s)=>{let e=!1;const o=setTimeout((()=>{e||(e=!0,console.error("Socket connection timed out"),window.dispatchEvent(new CustomEvent("socketError",{detail:{message:"Unable to connect to server. Please try again later.",code:"CONNECTION_TIMEOUT"}})),s(new Error("Unable to connect to server. Please try again later.")))}),3e4);this.socket=x(t,{transports:"v2"===this.protocol?["websocket","polling"]:["polling"]}),this.socket.on("connect",(()=>{var t;this.socketId=null===(t=this.socket)||void 0===t?void 0:t.id,this.socketId&&j.instances.set(this.socketId,this),"v2"===this.protocol&&this.apiKey?this.socket.emit("authenticate",{api_key:this.apiKey}):e||(e=!0,clearTimeout(o),i())})),"v2"===this.protocol?(this.socket.on("authenticated",(()=>{this.authenticated=!0,e||(e=!0,clearTimeout(o),i())})),this.socket.on("chunk",(t=>{const i=y(t);window.dispatchEvent(new CustomEvent("streamResponse",{detail:i}))})),this.socket.on("complete",(t=>{const i=k(t);window.dispatchEvent(new CustomEvent("endResponse",{detail:i}))}))):(this.socket.on("response",(t=>{window.dispatchEvent(new CustomEvent("streamResponse",{detail:t}))})),this.socket.on("end_response",(t=>{window.dispatchEvent(new CustomEvent("endResponse",{detail:t}))}))),this.socket.on("close",(()=>{this.clearSocketListeners(),this.authenticated=!1,this.socket=null,setTimeout((()=>this.initSocket()),3e3)})),this.socket.on("error",(t=>{console.error("WebSocket error:",t),"v2"===this.protocol&&window.dispatchEvent(new CustomEvent("socketError",{detail:t}))})),this.socket.on("disconnect",(()=>{this.socketId&&j.instances.delete(this.socketId),this.authenticated=!1}))})),this.connectionPromise=this.connectionPromise.catch((t=>{console.error("Socket connection failed:",t.message)}))}}clearSocketListeners(){this.socket&&(this.socket.off("connect"),this.socket.off("response"),this.socket.off("end_response"),this.socket.off("chunk"),this.socket.off("complete"),this.socket.off("authenticated"),this.socket.off("close"),this.socket.off("error"),this.socket.off("disconnect"))}static createInstance(t,i=""){return new j(t,i)}static getInstanceById(t){return j.instances.get(t)}getSocket(){return this.socket}getSocketId(){return this.socketId}getProtocol(){return this.protocol}isAuthenticated(){return"legacy"===this.protocol||this.authenticated}async waitForConnection(){this.connectionPromise&&await this.connectionPromise}isConnected(){var t,i;return null!==(i=null===(t=this.socket)||void 0===t?void 0:t.connected)&&void 0!==i&&i}disconnect(){this.socket&&(this.clearSocketListeners(),this.socket.disconnect(),this.socket=null),this.socketId&&(j.instances.delete(this.socketId),this.socketId=""),this.authenticated=!1}static disconnectSocketById(t){const i=j.instances.get(t);i&&i.socket?(i.socket.disconnect(),j.instances.delete(t)):console.error(`Socket with ID ${t} not found`)}}j.instances=new Map;const E=s(class extends e{constructor(i){super(),!1!==i&&this.__registerHost(),this.__attachShadow(),this.feedback=o(this,"feedback",7),this.survey=o(this,"survey",7),this.stateChanged=o(this,"stateChanged",7),this.messageReceived=o(this,"messageReceived",7),this.formSubmitted=o(this,"formComplete",7),this.surveyCDNPath="https://cdn.ai12z.net/pkg/surveyjs",this.surveyScriptsLoaded=null,this.chats=[],this.chatExcludeTags=[],this.chatIncludeTags=[],this.componentType="search",this.chatPosition="below",this.copied=!1,this.isPlayed=!1,this.buttons=[],this.currentPage=0,this.currentSlide=0,this.scriptArray=[],this.isProse=!0,this.isProcessingEndResponse=!1,this.surveyDomId="",this.focusedIndex=-1,this.chatItemRefs=[],this.styles=[`https://cdn.ai12z.net/assets/bot/${t.CDN_PATH}/tailwind.min.css`,"https://unpkg.com/@highlightjs/cdn-assets@11.11.1/styles/default.min.css","https://cdn.ai12z.net/pkg/surveyjs/survey-core@2.3.4/survey-core.min.css"],this.getUpdatedChat=(t,i)=>{var s,e,o,n,a;const r=`ai-message-${this.generateUUID()}`,l=this.generateUUID();let h={message:i,type:"ai",status:"success",insightId:t.insightId,id:r,thumbsId:l,controlType:null!==(a=null===(n=null===(o=null===(e=null===(s=t.controlData)||void 0===s?void 0:s.data)||void 0===e?void 0:e.source)||void 0===o?void 0:o.carousel)||void 0===n?void 0:n.type)&&void 0!==a?a:""};return this.survey.emit({results:h,type:"carousel"}),h},this.updateChatMessage=(t,i)=>{const s=this.chats.findIndex((t=>t.id===this.aiMessageId));-1!==s&&(this.chats[s].message=t,this.chats[s].clipboard=t,"form"===i.controlType&&(this.chats[s].controlType=i.controlType,this.chats[s].itemComponent=i,this.chats[s].surveyDomId=i.surveyDomId),this.chats=[...this.chats])},this.handlePrev=()=>{this.currentSlide=(this.currentSlide-1+this.itemList.length)%this.itemList.length,this.processTemplateData(this.currentChatData,"","pagination")},this.handleNext=()=>{this.currentSlide=(this.currentSlide+1)%this.itemList.length,this.processTemplateData(this.currentChatData,"","pagination")},this.handleButtonClick=t=>()=>{this.survey.emit({results:t,type:"button"})},this.handleMessage=(t,i)=>{const s=new a.Converter,e=this.element.shadowRoot.querySelector(`#${i}`);if(!e)return void console.error(`Message bubble with ID ${i} not found.`);var o=e.getAttribute("data-bubbleText")||"";e.setAttribute("data-bubbleText",o+=t),e.setAttribute("aria-label",o),e.setAttribute("role","log"),e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","false");let n=s.makeHtml(o);const r=document.getElementById("spinner");r&&(r.style.display="none"),e.innerHTML=n,this.chats[this.chats.length-1].status="success"},this.scrollToBottom=()=>{this.scrollBottom=this.element.shadowRoot.querySelector(".scroll-bottom"),this.scrollBottom.scrollIntoView({behavior:"smooth",block:"end"})},this.disableFeedback=t=>{const i=this.element.shadowRoot.querySelector(`#thumbsUp_${t}`),s=this.element.shadowRoot.querySelector(`#thumbsDown_${t}`);i.classList.add("not-allowed"),i.setAttribute("disabled","true"),s.classList.add("not-allowed"),s.setAttribute("disabled","true")},this.thumbsUp=(t,i,s)=>{const e=this.element.shadowRoot.querySelector(`#thumbsUp_${t}`);e.classList.add("thumbs-up"),e.innerHTML='\n <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">\n <path d="M7.493 18.5c-.425 0-.82-.236-.975-.632A7.48 7.48 0 0 1 6 15.125c0-1.75.599-3.358 1.602-4.634.151-.192.373-.309.6-.397.473-.183.89-.514 1.212-.924a9.042 9.042 0 0 1 2.861-2.4c.723-.384 1.35-.956 1.653-1.715a4.498 4.498 0 0 0 .322-1.672V2.75A.75.75 0 0 1 15 2a2.25 2.25 0 0 1 2.25 2.25c0 1.152-.26 2.243-.723 3.218-.266.558.107 1.282.725 1.282h3.126c1.026 0 1.945.694 2.054 1.715.045.422.068.85.068 1.285a11.95 11.95 0 0 1-2.649 7.521c-.388.482-.987.729-1.605.729H14.23c-.483 0-.964-.078-1.423-.23l-3.114-1.04a4.501 4.501 0 0 0-1.423-.23h-.777ZM2.331 10.727a11.969 11.969 0 0 0-.831 4.398 12 12 0 0 0 .52 3.507C2.28 19.482 3.105 20 3.994 20H4.9c.445 0 .72-.498.523-.898a8.963 8.963 0 0 1-.924-3.977c0-1.708.476-3.305 1.302-4.666.245-.403-.028-.959-.5-.959H4.25c-.832 0-1.612.453-1.918 1.227Z" />\n </svg>\n ',this.disableFeedback(t),this.feedback.emit({insightId:i,feedback:{value:1}}),H("up",i||t,s)},this.thumbsDown=(t,i,s)=>{const e=this.element.shadowRoot.querySelector(`#thumbsDown_${t}`);e.classList.add("thumbs-down"),e.innerHTML='\n <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">\n <path d="M15.73 5.5h1.035A7.465 7.465 0 0 1 18 9.625a7.465 7.465 0 0 1-1.235 4.125h-.148c-.806 0-1.534.446-2.031 1.08a9.04 9.04 0 0 1-2.861 2.4c-.723.384-1.35.956-1.653 1.715a4.499 4.499 0 0 0-.322 1.672v.633A.75.75 0 0 1 9 22a2.25 2.25 0 0 1-2.25-2.25c0-1.152.26-2.243.723-3.218.266-.558-.107-1.282-.725-1.282H3.622c-1.026 0-1.945-.694-2.054-1.715A12.137 12.137 0 0 1 1.5 12.25c0-2.848.992-5.464 2.649-7.521C4.537 4.247 5.136 4 5.754 4H9.77a4.5 4.5 0 0 1 1.423.23l3.114 1.04a4.5 4.5 0 0 0 1.423.23ZM21.669 14.023c.536-1.362.831-2.845.831-4.398 0-1.22-.182-2.398-.52-3.507-.26-.85-1.084-1.368-1.973-1.368H19.1c-.445 0-.72.498-.523.898.591 1.2.924 2.55.924 3.977a8.958 8.958 0 0 1-1.302 4.666c-.245.403.028.959.5.959h1.053c.832 0 1.612-.453 1.918-1.227Z" />\n </svg>\n ',this.disableFeedback(t),this.feedback.emit({insightId:i,feedback:{value:-1}}),H("down",i||t,s)}}handleChatKeyNav(t,i){var s,e;if("ArrowDown"===t.key){t.preventDefault(),t.stopPropagation();const e=Math.min(this.chats.length-1,i+1);this.focusedIndex=e,null===(s=this.chatItemRefs[e])||void 0===s||s.focus()}else if("ArrowUp"===t.key){t.preventDefault(),t.stopPropagation();const s=Math.max(0,i-1);this.focusedIndex=s,null===(e=this.chatItemRefs[s])||void 0===e||e.focus()}}componentDidLoad(){const t=document.createElement("script");t.text='\n var ai12zChat = window["ai12z"] = {}\n ',document.head.appendChild(t),this.element.shadowRoot.appendChild(t),setTimeout((()=>{var t,i;if(this.customstyle){const i=document.createElement("link");i.setAttribute("rel","stylesheet"),i.setAttribute("href",this.customstyle),null===(t=this.element.shadowRoot)||void 0===t||t.appendChild(i)}if(this.customJS){const t=document.createElement("script");t.setAttribute("type","text/javascript"),t.setAttribute("src",this.customJS),null===(i=this.element.shadowRoot)||void 0===i||i.appendChild(t)}}),500),this.loadScriptsSequentially()}async loadScriptsSequentially(){return this.surveyScriptsLoaded||(this.surveyScriptsLoaded=(async()=>{try{await this.loadScript(`${this.surveyCDNPath}/survey-core@2.3.4/survey.core.min.js`),await this.loadScript(`${this.surveyCDNPath}/survey-core@2.3.4/survey.i18n.min.js`),await this.loadScript(`${this.surveyCDNPath}/survey-core@2.3.4/themes/index.min.js`),await this.loadScript(`${this.surveyCDNPath}/survey-js-ui@2.3.4/survey-js-ui.min.js`),this.loadStyles()}catch(t){throw console.error("Failed to load Survey.js scripts:",t),t}})()),this.surveyScriptsLoaded}loadScript(t){return new Promise(((i,s)=>{if(document.querySelector(`script[src="${t}"]`))return void i();const e=document.createElement("script");e.src=t,e.async=!1,e.onload=()=>i(),e.onerror=()=>s(new Error(`Failed to load script: ${t}`)),this.element.shadowRoot.appendChild(e)}))}loadStyles(){for(const t of this.styles){const i=document.createElement("link");i.rel="stylesheet",i.href=t,i.onerror=t=>{console.error("Failed to load style:",t)},this.element.shadowRoot.appendChild(i)}}scrollToLatestBubble(){var t;if("search"===this.componentType){const i=this.element.closest(".chat-content-wrapper"),s=null===(t=this.element.shadowRoot)||void 0===t?void 0:t.querySelector(".chat-list"),e=null==s?void 0:s.querySelectorAll(".non-pending-user"),o=null==e?void 0:e[e.length-1];if(i&&o){const t=i.getBoundingClientRect(),s=o.getBoundingClientRect();i.scrollTo({top:s.top-t.top+i.scrollTop,behavior:"smooth"})}return}const i=this.element.shadowRoot.querySelector(".chat-list"),s=null==i?void 0:i.querySelectorAll(".non-pending-user"),e=null==s?void 0:s[s.length-1];e&&e.scrollIntoView({behavior:"smooth",block:"start"})}componentWillLoad(){this.loadStyles(),"undefined"==typeof window||window.Handlebars||(window.Handlebars=v)}async hydrateMessagesFromState(){var t,i,s;if((null===(t=this.element)||void 0===t?void 0:t.shadowRoot)&&0!==this.chats.length){await this.loadScriptsSequentially(),await new Promise((t=>requestAnimationFrame((()=>t()))));for(const t of this.chats){if("template"===t.controlType)this.processTemplateData(t,t.itemComponent,t.controlType);else if("form"===t.controlType){if(!t.surveyDomId)continue;this.surveyDomId=t.surveyDomId;const i=await z(`#${t.id}`,this.element);i.querySelector(`#${t.surveyDomId}`)||await z(`#${t.surveyDomId}`,this.element),i.style.width="100%",i.parentElement.style.width="100%",await this.renderSurvey(t.itemComponent)}else if("carousel"===t.controlType&&"carousel"===(null===(i=t.itemComponent)||void 0===i?void 0:i.controlType))this.processChatData(t,t.itemComponent);else if(!t.controlType){t.text=m(t.text,this.target||"_blank","ai12z-cta-link",null===(s=this.settings)||void 0===s?void 0:s.utm,"answer");const i=b(t.text);t.text=i.body,this.buttons=i.buttons,this.addEventListeners(`#${t.id}`)}"form"!==t.controlType&&(this.hideSpinner(t).then((()=>{console.log("spinner is hidden")})),this.checkHighlightcode(t.id))}}}disconnectedCallback(){window.ai12z={},this.chats=[]}watchHandler(t,i){}getProjectId(){var t,i,s,e;return null!==(e=null!==(i=null===(t=this.settings)||void 0===t?void 0:t.pId)&&void 0!==i?i:null===(s=this.dataAttributes)||void 0===s?void 0:s.projectId)&&void 0!==e?e:null}streamResponseHandler(t){const{id:i,idChanged:s}=l(this.aiMessageId,this.chats,"ai-message");this.aiMessageId=i,s&&(this.chats=[...this.chats]),requestAnimationFrame((()=>this.handleMessage(t.detail.data,this.aiMessageId)))}async renderSurvey(t){await this.loadScriptsSequentially(),await C({chat:t,surveyDomId:this.surveyDomId,shadowRoot:this.element.shadowRoot,config:{dataKey:this.apiKey,dataMode:this.env,dataAttributes:this.dataAttributes,formSubmitRenderCallback:t=>{this.handleSurveyCompletionRender(t)},onSubmitError:t=>{var i;const s=null===(i=this.element.shadowRoot)||void 0===i?void 0:i.querySelector(`#${this.surveyDomId}`);s?s.innerHTML="Form submission blocked by validation"!==t?"Failed to submit form":"Submission blocked due to suspicious activity.":console.error(`Survey element not found for DOM ID: ${this.surveyDomId}`)}}})}handleSurveyCompletionRender(t){t&&(this.element.shadowRoot.querySelector(`#${t.domId}`).parentElement.innerHTML=t.completedHtml,this.formSubmitted.emit(t),this.survey.emit(t))}endResponseHandler(t){const{id:i,idChanged:s,orphaned:e}=l(this.aiMessageId,this.chats,"ai-message");this.aiMessageId=i,s&&(this.chats=[...this.chats]),e||this.messageReceived.emit({data:t.detail,domId:this.aiMessageId}),this.isProcessingEndResponse?console.log("Already processing endResponse, ignoring duplicate"):(this.scrollToLatestBubble(),this.isProcessingEndResponse=!0,2!==this.chats.length||this.settings.disableBeacon||T(this.apiKey,this.env,t.detail.conversationId),requestAnimationFrame((async()=>{var i,s,e,o;try{const n={element:this.element,hideSpinner:t=>{this.hideSpinner(t)},getUpdatedChat:(t,i)=>this.getUpdatedChat(i,t),updateChatMessage:(t,i)=>{this.updateChatMessage(t,i)},renderSurvey:t=>this.renderSurvey(t),processTemplateData:(t,i)=>this.processTemplateData(t,i,"carousel"),processChatData:(t,i)=>this.processChatData(t,i),checkHighlightcode:t=>this.checkHighlightcode(t),addEventListeners:t=>this.addEventListeners(t),customStyle:this.customstyle,customJS:this.customJS,conversationId:this.conversationId,controlSettings:this.settings,utmConfig:null===(i=this.settings)||void 0===i?void 0:i.utm};await S({data:t.detail,currentDomId:this.aiMessageId,inputType:"cta",setMessages:t=>{this.chats=[...this.chats,t],this.aiMessageId=t.id,requestAnimationFrame((()=>{setTimeout((()=>{t&&t.id&&this.hideSpinner(t).then((()=>{}))}),100)}))},setSurveyDomId:t=>{this.surveyDomId=t},setButtons:t=>{this.buttons=t},config:n}),this.conversationId=t.detail.conversationId,h(this.getProjectId(),this.chats,this.conversationId,null!==(o=null===(e=null===(s=this.settings)||void 0===s?void 0:s._id)||void 0===e?void 0:e.$oid)&&void 0!==o?o:"","ai12z-cta-history","search"),this.aiMessageId=""}catch(t){console.error("Error handling end_response:",t)}finally{setTimeout((()=>{this.isProcessingEndResponse=!1}),500)}})))}checkHighlightcode(t=""){var i;try{if(!t)return console.warn("highlightcodeId is empty"),void(this.isProse=!0);const s=null===(i=this.element.shadowRoot)||void 0===i?void 0:i.querySelector(`#${t}`);if(!s)return console.warn(`Element with id '${t}' not found in shadowRoot`),void(this.isProse=!0);const e=s.querySelectorAll("pre");e.length>0?(s.classList.remove("prose"),import("./p-BO_7DTeV.js").then((function(t){return t.i})).then((({default:t})=>{t.configure({ignoreUnescapedHTML:!0}),e.forEach((i=>{i.dataset.highlighted?console.warn("Element previously highlighted..."):t.highlightElement(i)}))})).catch((t=>console.error("Failed to load highlight.js:",t)))):s.classList.add("prose")}catch(t){console.error("Error in highlightcode:",t),this.isProse=!0}}buttonClickHandler(t){this.survey.emit({results:t.detail,type:"button"})}get mainObject(){return window.ai12z||(window.ai12z={}),window.ai12z}generateUUID(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var i=16*Math.random()|0;return("x"==t?i:3&i|8).toString(16)}))}async processChatData(t,i){r(t,i,this.element,(t=>this.hideSpinner(t)),(t=>{this.survey.emit({results:t,type:"update"})}),this.customJS,this.customstyle,!1,"ai")}addEventforReadMore(){this.element.shadowRoot.querySelectorAll(".read-more").forEach((t=>{t.addEventListener("click",(t=>{const i=t.target.closest(".card"),s=i.querySelector(".short-description"),e=i.querySelector(".long-description"),o=i.querySelector(".card-image");s.classList.toggle("hidden"),e.classList.toggle("hidden"),s.classList.contains("hidden")?(o.classList.add("hidden"),i.classList.remove("md:grid-cols-2"),t.target.textContent="Show Less"):(o.classList.remove("hidden"),i.classList.add("md:grid-cols-2"),t.target.textContent="Read More")}))}))}addEventforPanel(t,i){this.element.shadowRoot.querySelectorAll(".panel-button").forEach((t=>{t.addEventListener("click",(t=>{"panel"===t.target.getAttribute("data-type")&&this.processTemplateData(this.currentChatData,"","pagination")}))}))}handleIndicatorClick(t){this.currentSlide=t,this.processTemplateData(this.currentChatData,"","pagination")}updateCarousel(){var t,i;const s=null!==(t=this.element.shadowRoot.querySelector(".prev"))&&void 0!==t?t:this.element.shadowRoot.querySelector(".prev-btn"),e=null!==(i=this.element.shadowRoot.querySelector(".next"))&&void 0!==i?i:this.element.shadowRoot.querySelector(".next-btn");this.element.shadowRoot.querySelectorAll(".indicator").forEach(((t,i)=>{t.addEventListener("click",(()=>this.handleIndicatorClick(i)))})),null==s||s.addEventListener("click",this.handlePrev),null==e||e.addEventListener("click",this.handleNext)}renderPagination(t){let i,s,e,o,n;switch(t){case"carousel":return i=1,o=this.itemList,n={paginatedItems:o,isFirstSlide:0===this.currentSlide,isLastSlide:this.currentSlide===this.itemList.length-1,transform:`-${100*this.currentSlide}%`,currentSlide:this.currentSlide},{context:n,end:e};case"list":return i=5,s=this.currentPage*i,e=s+i,o=this.itemList.slice(s,e),n={items:o,hasPrev:this.currentPage>0,hasNext:e<this.itemList.length},{context:n,end:e}}}addEventforPagination(t){var i,s;null===(i=this.element.shadowRoot.querySelector(".prev-btn"))||void 0===i||i.addEventListener("click",(()=>{this.currentPage>0&&(this.currentPage--,this.processTemplateData(this.currentChatData,"","pagination"))})),null===(s=this.element.shadowRoot.querySelector(".next-btn"))||void 0===s||s.addEventListener("click",(()=>{t<this.itemList.length&&(this.currentPage++,this.processTemplateData(this.currentChatData,"","pagination"))}))}addEventforcardButton(t,i){this.element.shadowRoot.querySelectorAll(".card-button").forEach((s=>{s.addEventListener("click",(s=>{var e,o;v.registerHelper("json",(function(t){return JSON.stringify(t)}));const n=s.target.getAttribute("data-id"),a=s.target.getAttribute("data-type"),r=s.target.getAttribute("data-url");if("panel"===a){const a=v.compile(i[Number(n)+1].content),r=this.element.shadowRoot.querySelectorAll(".carousel-card"),l=s.target.closest(".carousel-card").getAttribute("data-index");r[l].innerHTML=a({form:null===(e=t.items[l].panels[Number(n)])||void 0===e?void 0:e.form,formSettings:t.formSettings,buttons:null===(o=t.items[l].panels[Number(n)])||void 0===o?void 0:o.buttons}),this.addEventforPanel(i,t)}"url"===a&&window.open(r,"_blank")}))}))}async processTemplateData(t,i,s){this.currentChatData=t,await this.waitForElementRender(`#${t.id}`).then((async()=>{var e,o,n,a,r;this.hideSpinner(t);const l=this.element.shadowRoot.querySelector(`#${t.id}`);let h;if(l){if("carousel"===s&&(this.currentTemplate=null===(e=i.controlData)||void 0===e?void 0:e.template,this.currentResponse=null===(o=i.controlData)||void 0===o?void 0:o.data.source,this.itemList=this.currentResponse.items),l.parentElement.style.width="90%",h=v.compile(null===(n=this.currentTemplate[0])||void 0===n?void 0:n.content),"list"===this.currentResponse.process)l.innerHTML=h(this.renderPagination("list").context),this.addEventforPagination(this.renderPagination("list").end);else if("carousel"===this.currentResponse.process)v.registerHelper("eq",(function(t,i){return t===i})),l.innerHTML=h(this.renderPagination("carousel").context),this.updateCarousel();else{v.registerHelper("processArray",(function(t){return Array.isArray(t)?new v.SafeString(JSON.stringify(t)):""})),t.data=i.controlData.data,i.controlData&&i.controlData.data&&(i.controlData.data.msgId=t.id);const s=null===(a=i.controlData)||void 0===a?void 0:a.styles,e=null===(r=i.controlData)||void 0===r?void 0:r.Scripts;s&&I(s,this.element.shadowRoot),l.innerHTML=h({msgId:`${t.id}`,source:this.currentResponse,llm:i.controlData.data.llm}),e&&$(e,l),setTimeout((()=>{this.renderTemplateData(t)}),1e3)}this.addEventforReadMore(),this.addEventforcardButton(this.currentResponse,this.currentTemplate),t.message=l.innerHTML,this.survey.emit({results:t,type:"update"})}}))}renderTemplateData(t){this.mainObject[`${t.id}`]||(this.mainObject[`${t.id}`]={}),this.element.shadowRoot.querySelectorAll(`#${t.id} script`).forEach((t=>{var i;const s=document.createElement("script");s.type="text/javascript",t.src?s.src=t.src:s.innerHTML+=t.innerHTML,s.src||this.scriptArray.push(s),null===(i=t.parentNode)||void 0===i||i.removeChild(t),s.src&&!this.element.shadowRoot.querySelector(`script[src="${s.src}"]`)?this.element.shadowRoot.appendChild(s):this.element.shadowRoot.querySelector('script[type="text/javascript"]')&&!s.src&&(this.scriptArray.length>1?this.scriptArray.forEach((t=>{t.src||t.innerHTML===s.innerHTML||this.element.shadowRoot.appendChild(s)})):this.element.shadowRoot.appendChild(s))})),setTimeout((()=>{this.initializeScript(t.id)}),1e3)}initializeScript(t){"function"==typeof this.mainObject[`${t}`].onLoadCallback&&this.mainObject[`${t}`].onLoadCallback()}hideSpinner(t){return new Promise((i=>{const s=this.element.shadowRoot.querySelector(`#${t.id}`);s&&s.querySelector("#spinner")&&(s.querySelector("#spinner").style.display="none"),i(!0)}))}waitForElementRender(t){return new Promise((i=>{if(this.element.shadowRoot.querySelector(t))return void i();const s=new MutationObserver((()=>{this.element.shadowRoot.querySelector(t)&&(i(),s.disconnect())}));s.observe(this.element.shadowRoot,{childList:!0,subtree:!0})}))}waitForElementToAdd(t){return new Promise((i=>{const s=new MutationObserver((()=>{i(),s.disconnect()}));s.observe(t,{childList:!0,subtree:!0})}))}async invokeSocket(){var i,s,e,o,n,a;let r=null===(i=this.socketIn)||void 0===i?void 0:i.getSocketId();if(!r)return void console.error("Socket ID not available");let l=j.getInstanceById(r);if(!l){console.warn(`No socket service found for socket ID: ${r}, attempting to wait for connection...`);try{await this.socketIn.waitForConnection(),r=this.socketIn.getSocketId(),l=j.getInstanceById(r)}catch(t){console.error("Failed to wait for connection:",t)}}if(!l){console.warn("Creating new socket service...");try{const i=j.createInstance(this.env,null!==(s=this.apiKey)&&void 0!==s?s:t.DATA_KEY);if(await i.waitForConnection(),this.socketIn=i,r=i.getSocketId(),l=j.getInstanceById(r),!l)return void console.error("Failed to create and retrieve new socket service")}catch(t){return void console.error("Failed to create new socket service:",t)}}const h=l.getSocket();if(!h)return void console.error("Socket not available from service");let c,d;"v2"===l.getProtocol()?(d="query",c={query:this.query,conversation_id:this.conversationId||"",base64_images:(null===(e=this.imgFiles)||void 0===e?void 0:e.length)>0?this.imgFiles:void 0}):(d="evaluate_query",c={apiKey:null!==(o=this.apiKey)&&void 0!==o?o:t.DATA_KEY,query:this.query,conversationId:null!==(n=this.conversationId)&&void 0!==n?n:"",base64Images:(null===(a=this.imgFiles)||void 0===a?void 0:a.length)>0?this.imgFiles:[],event:"evaluate_query",attributes:this.dataAttributes,excludeTags:this.chatExcludeTags,includeTags:this.chatIncludeTags,meta:g()}),h.emit(d,c,(t=>{t&&(console.error("Error occurred while evaluating query:",t),this.aiMessageId=`chatbot-${w()}`,this.chats[this.chats.length-1].id=this.aiMessageId,this.chats[this.chats.length-1].text="Error connecting to server. Please try again later.")}))}addEventListeners(t){const i=this.element.shadowRoot.querySelector(t);i&&this.buttons.forEach((t=>{const s=i.querySelector(`#${t.id}`);if(s){const i=s.getAttribute("data-original-click");if(!i)return void console.warn(`originalClickHandler is not defined for button with id: ${t.id}`);const e=i.match(/^([\w.]+)\s*\(([\s\S]*)\)$/);if(e){const i=e[1],o=e[2],n=i.includes(".")?i.split(".").pop():i;s.addEventListener("click",(()=>{try{switch(n){case"sendQuery":console.warn("sendQuery is deprecated, use sendMessage instead"),this.survey.emit({results:t.label,type:"button"});break;case"sendMessage":case"ai12zCtrl.sendMessage":const i=c(o);if(!i)return;this.survey.emit({results:i,type:"sendMessage"});break;case"sendJSON":case"ai12zCtrl.sendJSON":const s=c(o);if(!s)return;this.survey.emit({results:s,type:"sendJSON"})}}catch(t){console.error(`Error invoking ${i}:`,t)}}))}}}))}stopStreamInputHandler(t){this.socketIn&&j.disconnectSocketById(t.detail.socketId)}startStreamInputHandler(t){var i,s,e;(null===(i=t.detail)||void 0===i?void 0:i.maxQuestion)?setTimeout((()=>{this.hideSpinner(t.detail.chatData),this.scrollToLatestBubble()}),1e3):(this.query=null===(s=t.detail)||void 0===s?void 0:s.search,this.imgFiles=null===(e=t.detail)||void 0===e?void 0:e.imgFiles,this.invokeSocket(),this.chats.length>2&&setTimeout((()=>{this.scrollToLatestBubble()}),500))}highlightcode(){const t=this.element.shadowRoot.querySelectorAll("pre");t.length>0&&(this.isProse=!1,import("./p-BO_7DTeV.js").then((function(t){return t.i})).then((({default:i})=>{i.configure({ignoreUnescapedHTML:!0}),t.forEach((t=>{i.highlightElement(t)}))})).catch((t=>console.error("Failed to load highlight.js:",t))))}copyToClipboard(t){navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([t],{type:"text/html"}),"text/plain":new Blob([this.removeHtmlTags(t)],{type:"text/plain"})})]).then((()=>{this.copied=!0,setTimeout((()=>{this.copied=!1}),2e3)}))}removeHtmlTags(t){const i=document.createElement("div");return i.innerHTML=t,i.textContent||i.innerText||""}async speakText(i){var s,e;if("default"===this.voiceType)if("speechSynthesis"in window){const t=window.speechSynthesis.getVoices().find((t=>t.name===this.voice));this.isPlayed=!0;const s=new SpeechSynthesisUtterance(i);s.lang="en-US",s.rate=1,s.pitch=1,s.voice=t,window.speechSynthesis.speak(s)}else alert("Speech Synthesis API is not supported in your browser.");if("google"===this.voiceType){const o=await f(null!==(s=this.apiKey)&&void 0!==s?s:t.DATA_KEY,null!==(e=this.env)&&void 0!==e?e:t.DATA_MODE,i,this.voice),n=this.base64ToBlob(o.audio_content,"audio/mpeg"),a=URL.createObjectURL(n);this.audioElement=new Audio(a),this.audioElement.onended=()=>{this.isPlayed=!1},this.audioElement.paused?(this.audioElement.play(),this.isPlayed=!0):(this.audioElement.pause(),this.audioElement.currentTime=0,this.audioElement.src="",this.audioElement=null,this.isPlayed=!1)}}base64ToBlob(t,i){const s=atob(t),e=new Array(s.length).fill(0).map(((t,i)=>s.charCodeAt(i))),o=new Uint8Array(e);return new Blob([o],{type:i})}render(){var t;return n("div",{key:"5883ac798ea9966385dc63a39f5e4bc2afb4c866"},n("ul",{key:"f46ac1484464dac37be35530bd44f4702ddbdb97",id:"main-content",tabindex:"-1",class:{"chat-list":!0,"custom-list":"search"===this.componentType,"custom-chat-bottom-height":"inline"===this.componentType,"custom-chat-above-height":"inline"===this.componentType&&"above"===this.chatPosition},style:{maxHeight:"search"!==this.componentType?"80vh":"none",overflowY:"search"!==this.componentType?"auto":"visible",height:"search"===this.componentType?"auto":"100%"}},null===(t=this.chats)||void 0===t?void 0:t.map(((t,i)=>{var s,e,o,a,r;const l="ai"===t.type&&(i===this.chats.length-1||"ai"!==(null===(s=this.chats[i+1])||void 0===s?void 0:s.type));return n("li",{class:{"text-md":!0,"chat-list-item":!0,"chat-align-list":"user"!==t.type,"chat-not-user-list":"user"===t.type,"pointer-events-none":"user"===t.type},tabindex:i===this.focusedIndex?0:-1,onKeyDown:t=>this.handleChatKeyNav(t,i),ref:t=>this.chatItemRefs[i]=t,role:"article","aria-label":`${"user"===t.type?"Your message":"Bot response"} ${i+1}`},"user"!==t.type&&n("div",{class:"chat-inner-list default-avatar"},!this.avatarUrl&&n("svg",{viewBox:"0 0 48 48",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",class:"w-8 h-8 "+(l?"md:block":"opacity-0")},n("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"})),this.avatarUrl&&n("div",{class:"avatar-container "+(l?"md:block":"opacity-0")},n("img",{src:this.avatarUrl,alt:"Avatar",class:"avatar-image w-8 h-8 rounded-full"}))),"pending"===t.status&&n("div",{class:"pending-chat"},n("svg",{class:"animate-spin h-5 w-5 text-gray-400",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},n("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"}),n("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 0 1 4 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"}))),n("div",{id:"parent-element",onMouseEnter:t=>{let i=t.target.querySelector(".non-user-container");i&&(i.style.display="block")},onMouseLeave:t=>{let i=t.target.querySelector(".non-user-container");i&&(i.style.display="none")},style:{width:"user"!==t.type?"90%":"auto"}},"pending"!==t.status&&!("user"===t.type&&t.isHide)&&n("div",{class:{"p-4":!0,"max-w-full":"search"===this.componentType,prose:!0,"custom-prose":!0,"transition-all":!0,"duration-300":!0,"opacity-100":this.isProse,"opacity-90":!this.isProse,resize:null===(e=t.formModel)||void 0===e?void 0:e.hasOwnProperty("answer"),"non-pending-user":!0},id:t.id,innerHTML:t.message},null===(o=null==t?void 0:t.images)||void 0===o?void 0:o.map((t=>n("img",{src:t,class:"thumbnail",alt:"thumbnail",width:"70",height:"50"}))),"user"!==t.type&&n("div",{class:"w-full rounded-md",id:"spinner"},n("div",{class:"flex animate-pulse space-x-4"},n("div",{class:"flex-1 space-y-3 py-1"},n("div",{class:"h-4 rounded bg-gray-200"}),n("div",{class:"space-y-3"},n("div",{class:"grid grid-cols-3 gap-4"},n("div",{class:"col-span-2 h-4 rounded bg-gray-200"}),n("div",{class:"col-span-1 h-4 rounded bg-gray-200"})),n("div",{class:"h-4 rounded bg-gray-200"})))))),"user"!==t.type&&t.clipboard&&(null===(a=this.settings.showMessageIcons)||void 0===a||a)&&!t.surveyDomId&&n("div",{class:"non-user-container",style:{display:"none"}},this.isPlayed&&n("button",{class:"copy-btn","aria-label":"Stop",tabindex:"0",onClick:()=>{this.isPlayed=!1,window.speechSynthesis.cancel(),this.audioElement&&(this.audioElement.pause(),this.audioElement.currentTime=0,this.audioElement.src="",this.audioElement=null)}},n("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",class:"icon-md-heavy"},n("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22C6.47715 22 2 17.5228 2 12ZM9.5 8.5C8.94772 8.5 8.5 8.94772 8.5 9.5V14.5C8.5 15.0523 8.94772 15.5 9.5 15.5H14.5C15.0523 15.5 15.5 15.0523 15.5 14.5V9.5C15.5 8.94772 15.0523 8.5 14.5 8.5H9.5Z",fill:"currentColor"}))),!this.isPlayed&&n("button",{class:"copy-btn",onClick:()=>this.speakText(this.removeHtmlTags(t.clipboard)),"aria-label":"Play",tabindex:"0"},n("svg",{class:"w-6 h-6",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},n("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M11 4.9099C11 4.47485 10.4828 4.24734 10.1621 4.54132L6.67572 7.7372C6.49129 7.90626 6.25019 8.00005 6 8.00005H4C3.44772 8.00005 3 8.44776 3 9.00005V15C3 15.5523 3.44772 16 4 16H6C6.25019 16 6.49129 16.0938 6.67572 16.2629L10.1621 19.4588C10.4828 19.7527 11 19.5252 11 19.0902V4.9099ZM8.81069 3.06701C10.4142 1.59714 13 2.73463 13 4.9099V19.0902C13 21.2655 10.4142 22.403 8.81069 20.9331L5.61102 18H4C2.34315 18 1 16.6569 1 15V9.00005C1 7.34319 2.34315 6.00005 4 6.00005H5.61102L8.81069 3.06701ZM20.3166 6.35665C20.8019 6.09313 21.409 6.27296 21.6725 6.75833C22.5191 8.3176 22.9996 10.1042 22.9996 12.0001C22.9996 13.8507 22.5418 15.5974 21.7323 17.1302C21.4744 17.6185 20.8695 17.8054 20.3811 17.5475C19.8927 17.2896 19.7059 16.6846 19.9638 16.1962C20.6249 14.9444 20.9996 13.5175 20.9996 12.0001C20.9996 10.4458 20.6064 8.98627 19.9149 7.71262C19.6514 7.22726 19.8312 6.62017 20.3166 6.35665ZM15.7994 7.90049C16.241 7.5688 16.8679 7.65789 17.1995 8.09947C18.0156 9.18593 18.4996 10.5379 18.4996 12.0001C18.4996 13.3127 18.1094 14.5372 17.4385 15.5604C17.1357 16.0222 16.5158 16.1511 16.0539 15.8483C15.5921 15.5455 15.4632 14.9255 15.766 14.4637C16.2298 13.7564 16.4996 12.9113 16.4996 12.0001C16.4996 10.9859 16.1653 10.0526 15.6004 9.30063C15.2687 8.85905 15.3578 8.23218 15.7994 7.90049Z",fill:"currentColor"}))),n("button",{class:"copy-btn",onClick:()=>this.copyToClipboard(t.clipboard),"aria-label":"Copy to Clipboard",tabindex:"0"},!this.copied&&n("svg",{class:"w-6 h-6",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},n("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M7 5C7 3.34315 8.34315 2 10 2H19C20.6569 2 22 3.34315 22 5V14C22 15.6569 20.6569 17 19 17H17V19C17 20.6569 15.6569 22 14 22H5C3.34315 22 2 20.6569 2 19V10C2 8.34315 3.34315 7 5 7H7V5ZM9 7H14C15.6569 7 17 8.34315 17 10V15H19C19.5523 15 20 14.5523 20 14V5C20 4.44772 19.5523 4 19 4H10C9.44772 4 9 4.44772 9 5V7ZM5 9C4.44772 9 4 9.44772 4 10V19C4 19.5523 4.44772 20 5 20H14C14.5523 20 15 19.5523 15 19V10C15 9.44772 14.5523 9 14 9H5Z",fill:"currentColor"})),this.copied&&n("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",class:"w-6 h-6"},n("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M19.8198 6.19526C20.0601 6.45561 20.0601 6.87772 19.8198 7.13807L9.9736 17.8047C9.73328 18.0651 9.34364 18.0651 9.10332 17.8047L4.18024 12.4714C3.93992 12.2111 3.93992 11.7889 4.18024 11.5286C4.42056 11.2682 4.8102 11.2682 5.05053 11.5286L9.53846 16.3905L18.9495 6.19526C19.1898 5.93491 19.5794 5.93491 19.8198 6.19526Z",fill:"currentColor"}))),n("button",{id:`thumbsUp_${t.thumbsId}`,onClick:()=>this.thumbsUp(t.thumbsId,t.insightId,{dataKey:this.apiKey,dataMode:this.env,conversationId:this.conversationId,projectId:this.getProjectId(),questionText:M(this.chats,t.insightId)||""}),class:"chat-thumbs-up","aria-label":"Thumbs Up",tabindex:"0"},n("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"},n("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M6.633 10.25c.806 0 1.533-.446 2.031-1.08a9.041 9.041 0 0 1 2.861-2.4c.723-.384 1.35-.956 1.653-1.715a4.498 4.498 0 0 0 .322-1.672V2.75a.75.75 0 0 1 .75-.75 2.25 2.25 0 0 1 2.25 2.25c0 1.152-.26 2.243-.723 3.218-.266.558.107 1.282.725 1.282m0 0h3.126c1.026 0 1.945.694 2.054 1.715.045.422.068.85.068 1.285a11.95 11.95 0 0 1-2.649 7.521c-.388.482-.987.729-1.605.729H13.48c-.483 0-.964-.078-1.423-.23l-3.114-1.04a4.501 4.501 0 0 0-1.423-.23H5.904m10.598-9.75H14.25M5.904 18.5c.083.205.173.405.27.602.197.4-.078.898-.523.898h-.908c-.889 0-1.713-.518-1.972-1.368a12 12 0 0 1-.521-3.507c0-1.553.295-3.036.831-4.398C3.387 9.953 4.167 9.5 5 9.5h1.053c.472 0 .745.556.5.96a8.958 8.958 0 0 0-1.302 4.665c0 1.194.232 2.333.654 3.375Z"}))),n("button",{id:`thumbsDown_${t.thumbsId}`,onClick:()=>this.thumbsDown(t.thumbsId,t.insightId,{dataKey:this.apiKey,dataMode:this.env,conversationId:this.conversationId,projectId:this.getProjectId(),questionText:M(this.chats,t.insightId)||""}),class:"chat-thumbs-up","aria-label":"Thumbs Down",tabindex:"0"},n("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"},n("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"}))),n("button",{class:"copy-btn",tabindex:"0","aria-label":"Send Email"},n("a",{href:`mailto:?subject=${encodeURIComponent(null===(r=this.chats[i-1])||void 0===r?void 0:r.message)}&body=${encodeURIComponent(this.removeHtmlTags(t.clipboard))}`,target:"_blank","aria-label":"Send Email"},n("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"},n("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"})," "))))))})),n("div",{key:"53802e68891a2c65e85f5df2086b129bcd15fb04",class:"scroll-bottom"})))}get element(){return this}static get watchers(){return{chats:[{watchHandler:0}]}}static get style(){return":host{font-family:var(--ai12z-font-family) !important;font-size:var(--ai12z-font-size) !important;color:var(--ai12z-font-color, black);text-align:var(--ai12z-text-align, left)}.not-allowed{cursor:not-allowed}.prose.custom-prose{--tw-prose-body:var(--ai12z-bubble-font-color);--tw-prose-bold:var(--ai12z-bubble-font-color);--tw-prose-links:var(--ai12z-link-color);--tw-prose-headings:var(--ai12z-bubble-font-color)}.ai12z-cta-link{color:var(--ai12z-link-color);text-decoration:underline}.ai12z-cta-link:hover{color:var(--ai12z-link-hover-color)}@media (max-width: 768px){.chat-align-list{padding:16px 16px 16px 0px !important}.chat-not-user-list{padding-inline-start:40px !important}}.thumbs-up{fill:var(--ai12z-feedback-selected);width:24px}.thumbs-down{fill:var(--ai12z-feedback-selected);width:24px}.chat-thumbs-up{color:var(--ai12z-feedback-color)}.default-avatar{color:var(--ai12z-default-avatar-color, var(--ai12z-primary-color))}.chat-list{margin-top:20px;overflow-y:auto;display:flex;flex-direction:column}.custom-chat-top-height{max-height:100vh}@media (max-width: 768px){.custom-chat-bottom-height{max-height:700px}.default-avatar{display:none !important}}.custom-chat-bottom-height{max-height:100%}.custom-chat-above-height{max-height:80vh;margin-bottom:20px}.custom-list{overflow-y:auto}.chat-list-item{padding:32px 8px 0 4px;display:flex;position:relative;color:var(--ai12z-bubble-font-color);font-size:var(--ai12z-bubble-font-size)}.chat-align-list{justify-content:flex-start;padding-inline-end:40px}.chat-not-user-list{justify-content:flex-end;padding-inline-start:80px}.chat-inner-list{display:flex;align-items:flex-end;padding-right:8px}.pending-chat{display:flex;justify-content:center;align-items:center;border-width:1px;padding:20px;line-height:28px;border-radius:8px}.non-pending-user{line-height:28px;border-radius:8px}.chat-not-user-list #parent-element .non-pending-user{background-color:var(--ai12z-user-bubble-background, var(--ai12z-bubble-background))}.chat-align-list #parent-element .non-pending-user{background-color:var(--ai12z-ai-bubble-background, var(--ai12z-bubble-background));border:var(--ai12z-ai-bubble-border)}#parent-element{position:relative}.non-user-container{position:absolute;right:0;top:0;width:176px}.thumbnail{margin-bottom:30px;width:70%}.ai12z_image_result{max-width:500px;width:100%;border-radius:5%;padding:20px}.ai12z_image_caption{margin:20px;padding:1px;background-color:#f0f0f0;border-radius:5px;text-align:center}.resize{width:100%}.prose.prose-w-none *{all:unset;}.non-pending-user .ai12zBtn{background-color:var(--ai12z-primary-color);color:white;padding:5px 10px;border:none;border-radius:5px;cursor:pointer;text-decoration:none;margin:5px}.ai12zBtn:active{background-color:rgb(118 135 214)}::-webkit-scrollbar{width:12px;height:12px}::-webkit-scrollbar-track{background:#f1f1f1;border-radius:10px}::-webkit-scrollbar-thumb{background-color:#888;border-radius:10px;border:2px solid #f1f1f1}::-webkit-scrollbar-thumb:hover{background:#555}.copy-btn{color:var(--ai12z-feedback-color)}.list-btn{background-color:#007bff;color:white;padding:5px 10px;border:none;border-radius:5px;cursor:pointer;text-decoration:none;margin:5px;max-width:100%;}.pagination-controls{display:flex;justify-content:space-between;margin-top:20px}.pagination-controls button{padding:10px 20px;border:none;background-color:#007bff;color:white;cursor:pointer;border-radius:5px}.pagination-controls button:disabled{background-color:#ccc;cursor:not-allowed}.pagination-controls span{align-self:center;font-size:1.1em}.hidden{display:none}.carousel-container{position:relative;display:flex;overflow:hidden;margin:0 auto;width:100%;max-width:100%}.carousel-items{display:flex;transition:transform 0.3s ease-in-out;width:100%}.carousel-card{flex-shrink:0;width:100%}.card img{width:100%;height:auto}.card-body{margin:15px}.prev,.next{background:#007bff;border:none;color:white;padding:10px;cursor:pointer;border-radius:50%;position:absolute;top:50%;transform:translateY(-50%);z-index:10}.prev{cursor:pointer;left:0px}.next{cursor:pointer;right:0px}.carousel-indicators{display:flex;justify-content:center;margin-top:10px;bottom:4px;left:50%}.indicator{width:10px;height:10px;background-color:gray;border-radius:50%;margin:0 5px;cursor:pointer}button:focus-visible{outline:2px solid var(--ai12z-focus-visible-color, #0A2A43);outline-offset:2px}button.chat-btn-primary:focus-visible{outline:2px solid var(--ai12z-focus-visible-color-primary, --ai12z-focus-visible-color);outline-offset:2px}button.chat-btn-secondary:focus-visible{outline:2px solid var(--ai12z-focus-visible-color-secondary, --ai12z-focus-visible-color)}.ai12z-form-honeypot{position:absolute;left:-10000px;top:auto;width:1px;height:1px;overflow:hidden}"}},[1,"ai12z-chat",{chatId:[1,"chat-id"],chats:[1032],query:[1025],apiKey:[1,"api-key"],aiMessageId:[1025,"ai-message-id"],imgFiles:[1032,"img-files"],env:[1025],conversationId:[1025,"conversation-id"],dataAttributes:[8,"data-attributes"],chatExcludeTags:[16],chatIncludeTags:[16],target:[1],voiceType:[1,"voice-type"],voice:[1],componentType:[1,"component-type"],chatPosition:[1,"chat-position"],socketIn:[16],customstyle:[1],customJS:[1,"custom-j-s"],avatarUrl:[1,"avatar-url"],settings:[8],scrollBottom:[32],copied:[32],isPlayed:[32],buttons:[32],itemList:[32],currentChatData:[32],currentTemplate:[32],currentPage:[32],currentResponse:[32],currentSlide:[32],scriptArray:[32],isProse:[32],isProcessingEndResponse:[32],surveyDomId:[32],focusedIndex:[32],hydrateMessagesFromState:[64]},[[8,"streamResponse","streamResponseHandler"],[8,"endResponse","endResponseHandler"],[0,"buttonClick","buttonClickHandler"],[4,"stopStream","stopStreamInputHandler"],[4,"startStream","startStreamInputHandler"]],{chats:[{watchHandler:0}]}]);function L(){"undefined"!=typeof customElements&&["ai12z-chat","item-list"].forEach((t=>{switch(t){case"ai12z-chat":customElements.get(i(t))||customElements.define(i(t),E);break;case"item-list":customElements.get(i(t))||p()}}))}L();export{E as M,j as S,L as d}
|