@headwai/chat-bubble 3.0.4 → 3.0.5
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.
|
@@ -286,7 +286,7 @@ ${H.text}
|
|
|
286
286
|
`,Z.log(`Message timestamp: ${x}, content: ${S}`)}else S+=`[${I}]:
|
|
287
287
|
${H.text}
|
|
288
288
|
|
|
289
|
-
`,Z.log(`Message content: ${S}`)}});const C=new Blob([S],{type:"text/plain"}),P=URL.createObjectURL(C),L=document.createElement("a");L.href=P,L.download=`chat-history-${e}.txt`,document.body.appendChild(L),L.click(),document.body.removeChild(L),URL.revokeObjectURL(P),Z.log("Message history downloaded")}ps(()=>{p()});const b=S=>S.key==="Enter"&&p(),T=S=>S.key==="Enter"&&y(),R=S=>S.key==="Enter"&&v();return r.$$set=S=>{"iconPath"in S&&t(0,a=S.iconPath),"chatTitle"in S&&t(1,s=S.chatTitle),"fontFamily"in S&&t(2,o=S.fontFamily),"chatHeaderBackground"in S&&t(3,l=S.chatHeaderBackground),"initialMessage"in S&&t(9,u=S.initialMessage),"deepChatRef"in S&&t(10,c=S.deepChatRef),"modelId"in S&&t(11,d=S.modelId),"apiUrl"in S&&t(12,f=S.apiUrl),"apiKey"in S&&t(13,h=S.apiKey)},[a,s,o,l,e,n,v,p,y,u,c,d,f,h,b,T,R]}class wc extends zn{constructor(i){super(),Vn(this,i,Ec,Sc,rn,{iconPath:0,chatTitle:1,fontFamily:2,chatHeaderBackground:3,initialMessage:9,deepChatRef:10,modelId:11,apiUrl:12,apiKey:13})}}function Cc(r){let i,t,e,n,a;return{c(){i=ge("div"),t=ge("img"),Nn(t.src,e=r[1])||j(t,"src",e),j(t,"alt","Headwai Chat Bubble"),j(t,"class","svelte-15lda29"),j(i,"class","ai-assistant-icon svelte-15lda29"),vt(i,"background",r[0]),j(i,"role","button"),j(i,"tabindex","0")},m(s,o){an(s,i,o),ie(i,t),n||(a=[He(i,"click",r[2]),He(i,"keydown",r[3])],n=!0)},p(s,[o]){o&2&&!Nn(t.src,e=s[1])&&j(t,"src",e),o&1&&vt(i,"background",s[0])},i:ve,o:ve,d(s){s&&kt(i),n=!1,tt(a)}}}function Tc(r,i,t){let e;Ae(r,qn,l=>t(4,e=l));let{faviconBackgroundColor:n}=i,{iconPath:a}=i;function s(){qn.set(!e)}const o=l=>l.key==="Enter"&&s();return r.$$set=l=>{"faviconBackgroundColor"in l&&t(0,n=l.faviconBackgroundColor),"iconPath"in l&&t(1,a=l.iconPath)},[n,a,s,o]}class Ac extends zn{constructor(i){super(),Vn(this,i,Tc,Cc,rn,{faviconBackgroundColor:0,iconPath:1})}}function Mc(r){let i,t;return{c(){i=ge("div"),t=ge("deep-chat"),Oe(t,"demo","false"),Oe(t,"
|
|
289
|
+
`,Z.log(`Message content: ${S}`)}});const C=new Blob([S],{type:"text/plain"}),P=URL.createObjectURL(C),L=document.createElement("a");L.href=P,L.download=`chat-history-${e}.txt`,document.body.appendChild(L),L.click(),document.body.removeChild(L),URL.revokeObjectURL(P),Z.log("Message history downloaded")}ps(()=>{p()});const b=S=>S.key==="Enter"&&p(),T=S=>S.key==="Enter"&&y(),R=S=>S.key==="Enter"&&v();return r.$$set=S=>{"iconPath"in S&&t(0,a=S.iconPath),"chatTitle"in S&&t(1,s=S.chatTitle),"fontFamily"in S&&t(2,o=S.fontFamily),"chatHeaderBackground"in S&&t(3,l=S.chatHeaderBackground),"initialMessage"in S&&t(9,u=S.initialMessage),"deepChatRef"in S&&t(10,c=S.deepChatRef),"modelId"in S&&t(11,d=S.modelId),"apiUrl"in S&&t(12,f=S.apiUrl),"apiKey"in S&&t(13,h=S.apiKey)},[a,s,o,l,e,n,v,p,y,u,c,d,f,h,b,T,R]}class wc extends zn{constructor(i){super(),Vn(this,i,Ec,Sc,rn,{iconPath:0,chatTitle:1,fontFamily:2,chatHeaderBackground:3,initialMessage:9,deepChatRef:10,modelId:11,apiUrl:12,apiKey:13})}}function Cc(r){let i,t,e,n,a;return{c(){i=ge("div"),t=ge("img"),Nn(t.src,e=r[1])||j(t,"src",e),j(t,"alt","Headwai Chat Bubble"),j(t,"class","svelte-15lda29"),j(i,"class","ai-assistant-icon svelte-15lda29"),vt(i,"background",r[0]),j(i,"role","button"),j(i,"tabindex","0")},m(s,o){an(s,i,o),ie(i,t),n||(a=[He(i,"click",r[2]),He(i,"keydown",r[3])],n=!0)},p(s,[o]){o&2&&!Nn(t.src,e=s[1])&&j(t,"src",e),o&1&&vt(i,"background",s[0])},i:ve,o:ve,d(s){s&&kt(i),n=!1,tt(a)}}}function Tc(r,i,t){let e;Ae(r,qn,l=>t(4,e=l));let{faviconBackgroundColor:n}=i,{iconPath:a}=i;function s(){qn.set(!e)}const o=l=>l.key==="Enter"&&s();return r.$$set=l=>{"faviconBackgroundColor"in l&&t(0,n=l.faviconBackgroundColor),"iconPath"in l&&t(1,a=l.iconPath)},[n,a,s,o]}class Ac extends zn{constructor(i){super(),Vn(this,i,Tc,Cc,rn,{faviconBackgroundColor:0,iconPath:1})}}function Mc(r){let i,t;return{c(){i=ge("div"),t=ge("deep-chat"),Oe(t,"demo","false"),Oe(t,"textInput",r[1]),Oe(t,"messageStyles",r[2]),Oe(t,"history",r[3]),Oe(t,"connect",r[4]),Oe(t,"requestBodyLimits",r[5]),Oe(t,"requestInterceptor",r[6]),Oe(t,"responseInterceptor",r[7]),Oe(t,"onMessage",r[8]),j(i,"class","chat-content svelte-i2r2w9")},m(e,n){an(e,i,n),ie(i,t),r[23](t)},p:ve,i:ve,o:ve,d(e){e&&kt(i),r[23](null)}}}function xc(r){return r.map(i=>{let t=i.text||i.content;return{role:i.role==="ai"?"assistant":i.role,content:t}})}function Ic(r,i,t){let e,n,a,s,o,l;Ae(r,Pn,M=>t(24,e=M)),Ae(r,On,M=>t(25,n=M)),Ae(r,Rn,M=>t(26,a=M)),Ae(r,In,M=>t(27,s=M)),Ae(r,xn,M=>t(28,o=M)),Ae(r,Ln,M=>t(29,l=M));let{deepChatRef:u}=i,{placeholderText:c}=i,{fontFamily:d}=i,{fontSize:f}=i,{userMessageBackgroundColor:h}=i,{userMessageTextColor:v}=i,{aiMessageBackgroundColor:p}=i,{aiMessageTextColor:g}=i,{feedbackMessageBackgroundColor:y}=i,{feedbackMessageTextColor:b}=i,{initialMessage:T}=i,{apiUrl:R}=i,{apiKey:S}=i,{modelId:C}=i,{maxMessages:P}=i;const L={placeholder:{text:c},styles:{container:{fontFamily:d,fontSize:f}}},H={default:{shared:{bubble:{fontFamily:d,fontSize:f}},user:{bubble:{backgroundColor:h,color:v}},ai:{bubble:{backgroundColor:p,color:g}},feedback:{bubble:{backgroundColor:y,color:b}}}},I=[{role:"ai",text:T,custom:{timestamp:Math.floor(Date.now()/1e3)}}],x={type:"websocket",url:`${R}/api/chat/completions`,headers:{Authorization:`Bearer ${S}`,"Content-Type":"application/json"},additionalBodyProps:{model:C,stream:!0,params:{},tool_servers:[],features:{image_generation:!1,code_interpreter:!1,web_search:!1,memory:!1},variables:{"{{USER_NAME}}":"David Schneebauer | headwAI GmbH","{{USER_LOCATION}}":"Unknown","{{CURRENT_DATETIME}}":new Date().toISOString().slice(0,19).replace("T"," "),"{{CURRENT_DATE}}":new Date().toISOString().slice(0,10),"{{CURRENT_TIME}}":new Date().toTimeString().slice(0,8),"{{CURRENT_WEEKDAY}}":new Date().toLocaleDateString("en-US",{weekday:"long"}),"{{CURRENT_TIMEZONE}}":Intl.DateTimeFormat().resolvedOptions().timeZone,"{{USER_LANGUAGE}}":"en-GB"},...n&&{chat_id:n},background_tasks:{title_generation:!0,tags_generation:!1,follow_up_generation:!1}},stream:!0},A={maxMessages:P},D=async M=>{if(M.body&&M.body.messages){M.body.messages=xc(M.body.messages).map(J=>(J.role==="assistant"&&J.content&&(J.content=_c(J.content)),J)),M.body.messages=M.body.messages.filter(J=>J.role!=="feedback");const K=M.body.messages.filter(J=>J.role==="user");K.length>0&&xn.set(K[K.length-1].content),n&&(M.body.chat_id=n)}return M},w=M=>{Z.log(M),M.sources&&Array.isArray(M.sources)&&(Rn.set(M.sources),Z.log(`Found ${M.sources.length} sources in response`),Z.log("assistantMessageSources:",M.sources));try{const K=bc(M);K.length>0&&(Ln.set(K),Z.log(`Found ${K.length} references in response`))}catch{}if(M.choices&&M.choices[0]&&M.choices[0].delta){const K=M.choices[0].delta,J=K.content||"";return J&&In.update(te=>te+J),M.choices[0].finish_reason&&Z.log("Streaming response ended"),{text:J,role:K.role==="assistant"?"ai":K.role||"ai"}}if(M.choices&&M.choices[0]&&M.choices[0].message){const K=M.choices[0].message;return Z.log("Non-streaming response received"),{text:K.content,role:K.role==="assistant"?"ai":K.role}}return M.text||M.html||M.files?M:typeof M=="string"?{text:M}:M};async function W(M){const{message:K,isHistory:J}=M;if(Z.log(M),!J&&(K.role==="ai"||K.role==="assistant")){Z.log("🤖 AI answered:",K.text);const te=K.text||"";let _e=te;if(l.length>0&&u){Z.log("📚 Formatting and updating AI message with references");const Le=kc(l,te);_e=te+Le,Le?(Z.log("Found inline citations, adding references"),u.updateMessage({text:_e},u.getMessages().length-1)):Z.log("No inline citations found, skipping references")}u.scrollToBottom(),ee(o,s,a);const he=e.filter(Le=>Le.role==="assistant").pop();Z.log("Last assistant message:",he);const Se=he?he.id:Xt();Z.log("Using assistant message ID for feedback:",Se);const Te=u.getMessages().length;u.addMessage({html:`
|
|
290
290
|
<div class="feedback">
|
|
291
291
|
<div class="feedback-icons">
|
|
292
292
|
<span class="feedback-icon feedback-icon-positive" title="Good response" onclick="window.handleFeedback('${Se}', 'positive', '${Te}')" style="cursor: pointer;">
|
|
@@ -403,4 +403,4 @@ ${H.text}
|
|
|
403
403
|
</span>
|
|
404
404
|
</div>
|
|
405
405
|
</div>
|
|
406
|
-
`,role:"feedback"},J)}async function fe(M,K){if(!(!n||!K||!M||(e.forEach(te=>{te.id===M&&te.role==="assistant"&&(te.feedbackId=K.id,te.annotation={rating:K.data.rating})}),!e.find(te=>te.id===M))))try{const te=e.filter(Ce=>Ce.role==="assistant");if(te.length===0){Z.error("No assistant messages found to update with feedback");return}const _e=te[te.length-1],he={};e.forEach(Ce=>{he[Ce.id]=Ce});const Se={chat:{models:[C],history:{messages:he,currentId:_e.id},messages:e,params:{}}},Le=`${R}/api/v1/chats/${n}`,lt=await fetch(Le,{method:"POST",headers:{Authorization:`Bearer ${S}`,"Content-Type":"application/json"},body:JSON.stringify(Se)});lt.ok?(Z.log("Assistant message updated with feedback successfully"),Or(e)):Z.error("Failed to update assistant message with feedback:",lt.statusText)}catch{}}typeof window<"u"&&(window.handleFeedback=ne);function ue(M){Bn[M?"unshift":"push"](()=>{u=M,t(0,u)})}return r.$$set=M=>{"deepChatRef"in M&&t(0,u=M.deepChatRef),"placeholderText"in M&&t(9,c=M.placeholderText),"fontFamily"in M&&t(10,d=M.fontFamily),"fontSize"in M&&t(11,f=M.fontSize),"userMessageBackgroundColor"in M&&t(12,h=M.userMessageBackgroundColor),"userMessageTextColor"in M&&t(13,v=M.userMessageTextColor),"aiMessageBackgroundColor"in M&&t(14,p=M.aiMessageBackgroundColor),"aiMessageTextColor"in M&&t(15,g=M.aiMessageTextColor),"feedbackMessageBackgroundColor"in M&&t(16,y=M.feedbackMessageBackgroundColor),"feedbackMessageTextColor"in M&&t(17,b=M.feedbackMessageTextColor),"initialMessage"in M&&t(18,T=M.initialMessage),"apiUrl"in M&&t(19,R=M.apiUrl),"apiKey"in M&&t(20,S=M.apiKey),"modelId"in M&&t(21,C=M.modelId),"maxMessages"in M&&t(22,P=M.maxMessages)},[u,L,H,I,x,A,D,w,W,c,d,f,h,v,p,g,y,b,T,R,S,C,P,ue]}class Rc extends zn{constructor(i){super(),Vn(this,i,Ic,Mc,rn,{deepChatRef:0,placeholderText:9,fontFamily:10,fontSize:11,userMessageBackgroundColor:12,userMessageTextColor:13,aiMessageBackgroundColor:14,aiMessageTextColor:15,feedbackMessageBackgroundColor:16,feedbackMessageTextColor:17,initialMessage:18,apiUrl:19,apiKey:20,modelId:21,maxMessages:22},null,[-1,-1])}}function ri(r){let i,t;return i=new Ac({props:{faviconBackgroundColor:r[15],iconPath:r[13]}}),{c(){ur(i.$$.fragment)},m(e,n){Dn(i,e,n),t=!0},p:ve,i(e){t||(Me(i.$$.fragment,e),t=!0)},o(e){Je(i.$$.fragment,e),t=!1},d(e){Fn(i,e)}}}function ai(r){let i,t,e,n,a,s;t=new wc({props:{iconPath:r[13],chatTitle:r[9]||void 0||"Headwai Chat Bubble",fontFamily:r[14],chatHeaderBackground:r[15],initialMessage:r[12],deepChatRef:r[10],modelId:r[16],apiUrl:r[17],apiKey:r[18]}});function o(u){r[26](u)}let l={placeholderText:r[1]||
|
|
406
|
+
`,role:"feedback"},J)}async function fe(M,K){if(!(!n||!K||!M||(e.forEach(te=>{te.id===M&&te.role==="assistant"&&(te.feedbackId=K.id,te.annotation={rating:K.data.rating})}),!e.find(te=>te.id===M))))try{const te=e.filter(Ce=>Ce.role==="assistant");if(te.length===0){Z.error("No assistant messages found to update with feedback");return}const _e=te[te.length-1],he={};e.forEach(Ce=>{he[Ce.id]=Ce});const Se={chat:{models:[C],history:{messages:he,currentId:_e.id},messages:e,params:{}}},Le=`${R}/api/v1/chats/${n}`,lt=await fetch(Le,{method:"POST",headers:{Authorization:`Bearer ${S}`,"Content-Type":"application/json"},body:JSON.stringify(Se)});lt.ok?(Z.log("Assistant message updated with feedback successfully"),Or(e)):Z.error("Failed to update assistant message with feedback:",lt.statusText)}catch{}}typeof window<"u"&&(window.handleFeedback=ne);function ue(M){Bn[M?"unshift":"push"](()=>{u=M,t(0,u)})}return r.$$set=M=>{"deepChatRef"in M&&t(0,u=M.deepChatRef),"placeholderText"in M&&t(9,c=M.placeholderText),"fontFamily"in M&&t(10,d=M.fontFamily),"fontSize"in M&&t(11,f=M.fontSize),"userMessageBackgroundColor"in M&&t(12,h=M.userMessageBackgroundColor),"userMessageTextColor"in M&&t(13,v=M.userMessageTextColor),"aiMessageBackgroundColor"in M&&t(14,p=M.aiMessageBackgroundColor),"aiMessageTextColor"in M&&t(15,g=M.aiMessageTextColor),"feedbackMessageBackgroundColor"in M&&t(16,y=M.feedbackMessageBackgroundColor),"feedbackMessageTextColor"in M&&t(17,b=M.feedbackMessageTextColor),"initialMessage"in M&&t(18,T=M.initialMessage),"apiUrl"in M&&t(19,R=M.apiUrl),"apiKey"in M&&t(20,S=M.apiKey),"modelId"in M&&t(21,C=M.modelId),"maxMessages"in M&&t(22,P=M.maxMessages)},[u,L,H,I,x,A,D,w,W,c,d,f,h,v,p,g,y,b,T,R,S,C,P,ue]}class Rc extends zn{constructor(i){super(),Vn(this,i,Ic,Mc,rn,{deepChatRef:0,placeholderText:9,fontFamily:10,fontSize:11,userMessageBackgroundColor:12,userMessageTextColor:13,aiMessageBackgroundColor:14,aiMessageTextColor:15,feedbackMessageBackgroundColor:16,feedbackMessageTextColor:17,initialMessage:18,apiUrl:19,apiKey:20,modelId:21,maxMessages:22},null,[-1,-1])}}function ri(r){let i,t;return i=new Ac({props:{faviconBackgroundColor:r[15],iconPath:r[13]}}),{c(){ur(i.$$.fragment)},m(e,n){Dn(i,e,n),t=!0},p:ve,i(e){t||(Me(i.$$.fragment,e),t=!0)},o(e){Je(i.$$.fragment,e),t=!1},d(e){Fn(i,e)}}}function ai(r){let i,t,e,n,a,s;t=new wc({props:{iconPath:r[13],chatTitle:r[9]||void 0||"Headwai Chat Bubble",fontFamily:r[14],chatHeaderBackground:r[15],initialMessage:r[12],deepChatRef:r[10],modelId:r[16],apiUrl:r[17],apiKey:r[18]}});function o(u){r[26](u)}let l={placeholderText:r[1]||"Welcome to the demo!",fontFamily:r[14],fontSize:r[8]||"16px",userMessageBackgroundColor:r[2]||void 0||"#007bff",userMessageTextColor:r[4]||void 0||"#000000",aiMessageBackgroundColor:r[3]||void 0||"#f1f3f4",aiMessageTextColor:r[5]||void 0||"#000000",feedbackMessageBackgroundColor:r[6]||void 0||"#ffffff",feedbackMessageTextColor:r[7]||void 0||"#000000",initialMessage:r[12],apiUrl:r[17],apiKey:r[18],modelId:r[16],maxMessages:parseInt(r[0]||void 0)||0};return r[10]!==void 0&&(l.deepChatRef=r[10]),n=new Rc({props:l}),Bn.push(()=>ks(n,"deepChatRef",o)),{c(){i=ge("div"),ur(t.$$.fragment),e=mt(),ur(n.$$.fragment),j(i,"class","chat-container svelte-hopfzj")},m(u,c){an(u,i,c),Dn(t,i,null),ie(i,e),Dn(n,i,null),s=!0},p(u,c){const d={};c&512&&(d.chatTitle=u[9]||void 0||"Headwai Chat Bubble"),c&1024&&(d.deepChatRef=u[10]),t.$set(d);const f={};c&2&&(f.placeholderText=u[1]||"Welcome to the demo!"),c&256&&(f.fontSize=u[8]||"16px"),c&4&&(f.userMessageBackgroundColor=u[2]||void 0||"#007bff"),c&16&&(f.userMessageTextColor=u[4]||void 0||"#000000"),c&8&&(f.aiMessageBackgroundColor=u[3]||void 0||"#f1f3f4"),c&32&&(f.aiMessageTextColor=u[5]||void 0||"#000000"),c&64&&(f.feedbackMessageBackgroundColor=u[6]||void 0||"#ffffff"),c&128&&(f.feedbackMessageTextColor=u[7]||void 0||"#000000"),c&1&&(f.maxMessages=parseInt(u[0]||void 0)||0),!a&&c&1024&&(a=!0,f.deepChatRef=u[10],gs(()=>a=!1)),n.$set(f)},i(u){s||(Me(t.$$.fragment,u),Me(n.$$.fragment,u),s=!0)},o(u){Je(t.$$.fragment,u),Je(n.$$.fragment,u),s=!1},d(u){u&&kt(i),Fn(t),Fn(n)}}}function Lc(r){let i,t,e,n=!r[11]&&ri(r),a=r[11]&&ai(r);return{c(){i=ge("main"),n&&n.c(),t=mt(),a&&a.c(),j(i,"class","svelte-hopfzj")},m(s,o){an(s,i,o),n&&n.m(i,null),ie(i,t),a&&a.m(i,null),e=!0},p(s,[o]){s[11]?n&&(ta(),Je(n,1,1,()=>{n=null}),na()):n?(n.p(s,o),o&2048&&Me(n,1)):(n=ri(s),n.c(),Me(n,1),n.m(i,t)),s[11]?a?(a.p(s,o),o&2048&&Me(a,1)):(a=ai(s),a.c(),Me(a,1),a.m(i,null)):a&&(ta(),Je(a,1,1,()=>{a=null}),na())},i(s){e||(Me(n),Me(a),e=!0)},o(s){Je(n),Je(a),e=!1},d(s){s&&kt(i),n&&n.d(),a&&a.d()}}}function Oc(r,i,t){let e;Ae(r,qn,w=>t(11,e=w));let{apiUrl:n=void 0}=i,{apiKey:a=void 0}=i,{modelId:s=void 0}=i,{maxMessages:o=void 0}=i,{placeholderText:l=void 0}=i,{faviconPath:u=void 0}=i,{initialMessage:c=void 0}=i,{userMessageBackgroundColor:d=void 0}=i,{aiMessageBackgroundColor:f=void 0}=i,{userMessageTextColor:h=void 0}=i,{aiMessageTextColor:v=void 0}=i,{feedbackMessageBackgroundColor:p=void 0}=i,{feedbackMessageTextColor:g=void 0}=i,{faviconBackgroundColor:y=void 0}=i,{fontFamily:b=void 0}=i,{fontSize:T=void 0}=i,{chatTitle:R=void 0}=i,S;const C=c||void 0||"Hey, how can I help you?",P=u||void 0||yc,L=b||'"Bitcount Grid Double", system-ui',H=y||void 0||"#667eea",I=s||"test-model",x=(n||"https://localchat.headwai.org/").replace(/\/$/,""),A=a||"sk-47ec23c1fd214846ada1e9c812596eef";function D(w){S=w,t(10,S)}return r.$$set=w=>{"apiUrl"in w&&t(19,n=w.apiUrl),"apiKey"in w&&t(20,a=w.apiKey),"modelId"in w&&t(21,s=w.modelId),"maxMessages"in w&&t(0,o=w.maxMessages),"placeholderText"in w&&t(1,l=w.placeholderText),"faviconPath"in w&&t(22,u=w.faviconPath),"initialMessage"in w&&t(23,c=w.initialMessage),"userMessageBackgroundColor"in w&&t(2,d=w.userMessageBackgroundColor),"aiMessageBackgroundColor"in w&&t(3,f=w.aiMessageBackgroundColor),"userMessageTextColor"in w&&t(4,h=w.userMessageTextColor),"aiMessageTextColor"in w&&t(5,v=w.aiMessageTextColor),"feedbackMessageBackgroundColor"in w&&t(6,p=w.feedbackMessageBackgroundColor),"feedbackMessageTextColor"in w&&t(7,g=w.feedbackMessageTextColor),"faviconBackgroundColor"in w&&t(24,y=w.faviconBackgroundColor),"fontFamily"in w&&t(25,b=w.fontFamily),"fontSize"in w&&t(8,T=w.fontSize),"chatTitle"in w&&t(9,R=w.chatTitle)},[o,l,d,f,h,v,p,g,T,R,S,e,C,P,L,H,I,x,A,n,a,s,u,c,y,b,D]}class Pr extends zn{constructor(i){super(),Vn(this,i,Oc,Lc,rn,{apiUrl:19,apiKey:20,modelId:21,maxMessages:0,placeholderText:1,faviconPath:22,initialMessage:23,userMessageBackgroundColor:2,aiMessageBackgroundColor:3,userMessageTextColor:4,aiMessageTextColor:5,feedbackMessageBackgroundColor:6,feedbackMessageTextColor:7,faviconBackgroundColor:24,fontFamily:25,fontSize:8,chatTitle:9})}}function is(){const r={apiUrl:"https://localchat.headwai.org/",apiKey:"sk-47ec23c1fd214846ada1e9c812596eef",modelId:"test-model",maxMessages:void 0,placeholderText:"Welcome to the demo!",userMessageBackgroundColor:void 0,aiMessageBackgroundColor:void 0,userMessageTextColor:void 0,aiMessageTextColor:void 0,faviconBackgroundColor:void 0,chatTitle:void 0},i=typeof window<"u"&&window.HEADWAI_CHAT_BUBBLE_CONFIG||{};return{...r,...i}}typeof window<"u"&&window.document&&document.addEventListener("DOMContentLoaded",()=>{const r=is(),i=document.querySelectorAll("[data-chat-bubble]");if(i.length===0){const t=document.getElementById("chat-bubble-container");t&&new Pr({target:t,props:r})}else i.forEach(t=>{const e={...r},n={chatBubbleApiUrl:"apiUrl",chatBubbleApiKey:"apiKey",chatBubbleModelId:"modelId",chatBubbleMaxMessages:"maxMessages",chatBubblePlaceholderText:"placeholderText",chatBubbleFaviconPath:"faviconPath",chatBubbleInitialMessage:"initialMessage",chatBubbleUserMessageBackgroundColor:"userMessageBackgroundColor",chatBubbleAiMessageBackgroundColor:"aiMessageBackgroundColor",chatBubbleUserMessageTextColor:"userMessageTextColor",chatBubbleAiMessageTextColor:"aiMessageTextColor",chatBubbleFaviconBackgroundColor:"faviconBackgroundColor",chatBubbleChatTitle:"chatTitle"};Object.keys(t.dataset).forEach(a=>{n[a]&&(e[n[a]]=t.dataset[a])}),new Pr({target:t,props:e})})});window.ChatBubble={init:(r,i={})=>new Pr({target:r,props:{...is(),...i}})};
|